30#include <yaz/snprintf.h>
39#define HAVE_TCL_OBJECTS
45#define F_WIN_EOF 2000000000
57#define REGX_MAX_ARGS 20
119 Tcl_Interp *tcl_interp;
153 if (off >= 0 && end_pos <= spec->
f_win_end)
155 *size = end_pos - start_pos;
158 if (off < 0 || start_pos >= spec->
f_win_end)
169 if (*size > end_pos - start_pos)
170 *size = end_pos - start_pos;
173 for (i = 0; i<spec->
f_win_end - start_pos; i++)
181 if (*size > end_pos - start_pos)
182 *size = end_pos - start_pos;
195 buf =
f_win_get (spec, *pos, *pos+1, &size);
212 Tcl_DecrRefCount (p->tcl_obj);
224 p = (
struct regxCode *) xmalloc (
sizeof(*p));
225 p->
str = (
char *) xmalloc (len+1);
226 memcpy (p->
str, buf, len);
229 p->tcl_obj = Tcl_NewStringObj ((
char *) buf, len);
231 Tcl_IncrRefCount (p->tcl_obj);
251 for (ra = *rap; ra; ra = ra1)
291 for (rp = p->
rules; rp; rp = rp1)
309 p = (
struct lexSpec *) xmalloc (
sizeof(*p));
310 p->
name = (
char *) xmalloc (strlen(
name)+1);
360 Tcl_DeleteInterp (p->tcl_interp);
372 const char *cp = *cpp;
376 while (*cp ==
' ' || *cp ==
'\t' || *cp ==
'\n' || *cp ==
'\r')
405 if (*cp >=
'a' && *cp <=
'z')
407 else if (*cp >=
'A' && *cp <=
'Z')
408 cmd[i] = *cp +
'a' -
'A';
411 if (i < (
int)
sizeof(cmd)-2)
418 yaz_log (YLOG_WARN,
"bad character %d %c", *cp, *cp);
420 while (*cp && *cp !=
' ' && *cp !=
'\t' &&
421 *cp !=
'\n' && *cp !=
'\r')
427 if (!strcmp (cmd,
"begin"))
429 else if (!strcmp (cmd,
"end"))
431 else if (!strcmp (cmd,
"body"))
433 else if (!strcmp (cmd,
"context"))
435 else if (!strcmp (cmd,
"init"))
439 yaz_log (YLOG_WARN,
"bad command %s", cmd);
468 (*ap)->u.pattern.body = bodyMark;
472 r =
dfa_parse ((*ap)->u.pattern.dfa, &s);
478 yaz_log(YLOG_WARN,
"regular expression error '%.*s'", pos, s0);
485 printf(
"pattern: %.*s\n", pos, s0);
491 yaz_log (YLOG_WARN,
"cannot use BEGIN here");
494 yaz_log (YLOG_WARN,
"cannot use INIT here");
516 char context_name[32];
520 yaz_log (YLOG_WARN,
"missing name after CONTEXT keyword");
525 memcpy (context_name, s, len);
526 context_name[len] =
'\0';
556 yaz_log (YLOG_WARN,
"regular expression error. r=%d", r);
561 yaz_log (YLOG_WARN,
"expects / at end of pattern. got %c", *s);
565 rp = (
struct lexRule *) xmalloc (
sizeof(*rp));
577 int c, i, errors = 0;
583 if (spec->tcl_interp)
585 yaz_snprintf(fname,
sizeof(fname),
"%s.tflt", spec->
name);
591 yaz_snprintf(fname,
sizeof(fname),
"%s.flt", spec->
name);
596 yaz_log(YLOG_ERRNO|YLOG_WARN,
"cannot read spec file %s", spec->
name);
599 yaz_log(YLOG_LOG,
"reading regx filter %s", fname);
601 if (spec->tcl_interp)
602 yaz_log(YLOG_LOG,
"Tcl enabled");
612 lineBuf = wrbuf_alloc();
617 wrbuf_rewind (lineBuf);
618 if (c ==
'#' || c ==
'\n' || c ==
' ' || c ==
'\t' || c ==
'\r')
620 while (c !=
'\n' && c != EOF)
633 wrbuf_putc(lineBuf, c);
641 if (c !=
' ' && c !=
'\t')
646 wrbuf_putc(lineBuf,
'\0');
652 wrbuf_destroy(lineBuf);
659 for (i = 0; i < lc->
ruleNo; i++)
672static struct lexSpec *curLexSpec = NULL;
676 const char *ebuf,
int elen,
int formatted_text,
677 const char *attribute_str,
int attribute_len)
686 yaz_log (YLOG_LOG,
"data(%d bytes) %.40s ... %.*s", elen,
687 ebuf, 40, ebuf + elen-40);
688 else if (elen == 1 && ebuf[0] ==
'\n')
690 yaz_log (YLOG_LOG,
"data(new line)");
693 yaz_log (YLOG_LOG,
"data(%d bytes) %.*s", elen, elen, ebuf);
695 yaz_log (YLOG_LOG,
"data(%d bytes)", elen);
711 for (ap = &res->
u.
tag.attributes; *ap; ap = &(*ap)->
next)
712 if (strlen((*ap)->name) == attribute_len &&
713 !memcmp((*ap)->name, attribute_str, attribute_len))
718 *ap = nmem_malloc(spec->
m,
sizeof(**ap));
720 (*ap)->name = nmem_malloc(spec->
m, attribute_len+1);
721 memcpy((*ap)->name, attribute_str, attribute_len);
722 (*ap)->name[attribute_len] =
'\0';
724 (*ap)->value = nmem_malloc(spec->
m, elen+1);
725 memcpy((*ap)->value, ebuf, elen);
726 (*ap)->value[elen] =
'\0';
732 char *nv = nmem_malloc(spec->
m, elen + 1 + strlen((*ap)->value));
733 strcpy(nv, (*ap)->value);
734 memcpy (nv + strlen(nv), ebuf, elen);
735 nv[strlen(nv)+elen] =
'\0';
743 org_len = res->
u.
data.len;
752 res->
u.
data.data = 0;
760 char *old_buf, *new_buf;
766 memcpy (new_buf, old_buf, org_len);
772 res->
u.
data.len += elen;
790 assert (!res->
u.
data.data);
791 assert (res->
u.
data.len > 0);
793 res->
u.
data.data = (
char *) nmem_malloc (spec->
m, res->
u.
data.len);
802 const char *class_str,
int class_len,
803 const char *type_str,
int type_len,
804 const char *value_str,
int value_len)
814 yaz_log (YLOG_WARN,
"in variant begin. No record type defined");
819 memcpy (tclass, class_str, class_len);
820 tclass[class_len] =
'\0';
824 memcpy (ttype, type_str, type_len);
825 ttype[type_len] =
'\0';
828 yaz_log (YLOG_LOG,
"variant begin(%s,%s,%d)", tclass, ttype,
853 yaz_log (YLOG_LOG,
"variant node(%d)", spec->
d1_level);
861 memcpy (res->
lbuf, value_str, value_len);
862 res->
lbuf[value_len] =
'\0';
876 for (i = *
len; i > 0 && isspace((*
tag)[i-1]); --i)
879 for (i = 0; i < *
len && isspace((*
tag)[i]); i++)
890 yaz_log (YLOG_WARN,
"in element begin. No record type defined");
898 yaz_log (YLOG_LOG,
"begin tag(%.*s, %d)",
len,
tag, spec->
d1_level);
924 yaz_log (YLOG_LOG,
"end tag(%d)", spec->
d1_level);
930 struct DFA *dfa,
int greedy)
935 unsigned char c_prev = 0;
937 int start_ptr = *pptr;
950 if (dfa->
states[0] == state)
988 else if (c >= t->
ch[0] && c <= t->
ch[1])
991 if (state->
rule_no && c_prev ==
'\n')
1010 const char **tokBuf,
int *tokLen)
1012 const char *s = *src;
1014 while (*s ==
' ' || *s ==
'\t')
1018 if (*s ==
'$' && s[1] >=
'0' && s[1] <=
'9')
1022 while (*s >=
'0' && *s <=
'9')
1023 n = n*10 + (*s++ -
'0');
1037 else if (*s ==
'\"')
1040 while (*s && *s !=
'\"')
1042 *tokLen = s - *tokBuf;
1047 else if (*s ==
'\n' || *s ==
';')
1055 while (*s && *s !=
' ' && *s !=
'\t' && *s !=
'\n' && *s !=
'\r' &&
1058 *tokLen = s - *tokBuf;
1065 while (*s && *s !=
' ' && *s !=
'\t' && *s !=
'\n' && *s !=
'\r' &&
1068 *tokLen = s - *tokBuf;
1074static char *
regxStrz (
const char *src,
int len,
char *str)
1078 memcpy (str, src, len);
1084static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp,
1085 int argc,
const char **argv)
1090 if (!strcmp(argv[1],
"record") && argc == 3)
1092 const char *absynName = argv[2];
1096 yaz_log (YLOG_LOG,
"begin record %s", absynName);
1110 else if (!strcmp(argv[1],
"element") && argc == 3)
1112 tagBegin (spec, argv[2], strlen(argv[2]));
1114 else if (!strcmp (argv[1],
"variant") && argc == 5)
1117 argv[3], strlen(argv[3]),
1118 argv[4], strlen(argv[4]));
1120 else if (!strcmp (argv[1],
"context") && argc == 3)
1124 yaz_log (YLOG_LOG,
"begin context %s",argv[2]);
1126 while (lc && strcmp (argv[2], lc->
name))
1133 yaz_log (YLOG_WARN,
"unknown context %s", argv[2]);
1140static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp,
1141 int argc,
const char **argv)
1147 if (!strcmp (argv[1],
"record"))
1155 yaz_log (YLOG_LOG,
"end record");
1159 else if (!strcmp (argv[1],
"element"))
1162 const char *element = 0;
1163 if (argc >= 3 && !strcmp(argv[2],
"-record"))
1172 tagEnd (spec, min_level, element, (element ? strlen(element) : 0));
1176 yaz_log (YLOG_LOG,
"end element end records");
1181 else if (!strcmp (argv[1],
"context"))
1184 yaz_log (YLOG_LOG,
"end context");
1194static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp,
1195 int argc,
const char **argv)
1199 const char *element = 0;
1200 const char *attribute = 0;
1205 if (!strcmp(
"-text", argv[argi]))
1210 else if (!strcmp(
"-element", argv[argi]))
1214 element = argv[argi++];
1216 else if (!strcmp(
"-attribute", argv[argi]))
1220 attribute = argv[argi++];
1226 tagBegin (spec, element, strlen(element));
1230#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
1232 char *native = Tcl_UtfToExternalDString(0, argv[argi], -1, &ds);
1233 execData (spec, native, strlen(native), textFlag, attribute,
1234 attribute ? strlen(attribute) : 0);
1235 Tcl_DStringFree (&ds);
1237 execData (spec, argv[argi], strlen(argv[argi]), textFlag, attribute,
1238 attribute ? strlen(attribute) : 0);
1243 tagEnd (spec, 2, NULL, 0);
1247static int cmd_tcl_unread (ClientData clientData, Tcl_Interp *interp,
1248 int argc,
const char **argv)
1257 if (!strcmp(
"-offset", argv[argi]))
1262 offset = atoi(argv[argi]);
1271 no = atoi(argv[argi]);
1282 for (i = 0; i < spec->
arg_no; i++)
1284 char var_name[10], *var_buf;
1287 yaz_snprintf(var_name,
sizeof(var_name),
"%d", i);
1292 ch = var_buf[var_len];
1293 var_buf[var_len] =
'\0';
1294 Tcl_SetVar (spec->tcl_interp, var_name, var_buf, 0);
1295 var_buf[var_len] = ch;
1299 ret = Tcl_GlobalEvalObj(spec->tcl_interp, code->tcl_obj);
1301 ret = Tcl_GlobalEval (spec->tcl_interp, code->
str);
1305 const char *err = Tcl_GetVar(spec->tcl_interp,
"errorInfo", 0);
1306 yaz_log(YLOG_FATAL,
"Tcl error, line=%d, \"%s\"\n%s",
1307#
if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 5
1308 spec->tcl_interp->errorLine,
1309 spec->tcl_interp->result,
1311 Tcl_GetErrorLine(spec->tcl_interp),
1312 Tcl_GetStringResult(spec->tcl_interp),
1314 err ? err :
"[NO ERRORINFO]");
1322 const char *s = code->
str;
1324 const char *cmd_str;
1326 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1333 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1336 p =
regxStrz (cmd_str, cmd_len, ptmp);
1337 if (!strcmp (p,
"begin"))
1339 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1342 yaz_log (YLOG_WARN,
"missing keyword after 'begin'");
1345 p =
regxStrz (cmd_str, cmd_len, ptmp);
1346 if (!strcmp (p,
"record"))
1348 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1353 static char absynName[64];
1358 memcpy (absynName, cmd_str, cmd_len);
1359 absynName[cmd_len] =
'\0';
1361 yaz_log (YLOG_LOG,
"begin record %s", absynName);
1375 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1377 else if (!strcmp (p,
"element"))
1379 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1383 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1385 else if (!strcmp (p,
"variant"))
1388 const char *class_str = NULL;
1390 const char *type_str = NULL;
1392 const char *value_str = NULL;
1393 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1396 class_str = cmd_str;
1397 class_len = cmd_len;
1398 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1404 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1407 value_str = cmd_str;
1408 value_len = cmd_len;
1411 type_str, type_len, value_str, value_len);
1414 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1416 else if (!strcmp (p,
"context"))
1421 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1422 p =
regxStrz (cmd_str, cmd_len, ptmp);
1424 yaz_log (YLOG_LOG,
"begin context %s", p);
1426 while (lc && strcmp (p, lc->
name))
1431 yaz_log (YLOG_WARN,
"unknown context %s", p);
1434 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1438 yaz_log (YLOG_WARN,
"bad keyword '%s' after begin", p);
1441 else if (!strcmp (p,
"end"))
1443 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1446 yaz_log (YLOG_WARN,
"missing keyword after 'end'");
1449 p =
regxStrz (cmd_str, cmd_len, ptmp);
1450 if (!strcmp (p,
"record"))
1457 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1459 yaz_log (YLOG_LOG,
"end record");
1463 else if (!strcmp (p,
"element"))
1466 while ((r =
execTok (spec, &s, &cmd_str, &cmd_len)) == 3)
1468 if (cmd_len==7 && !memcmp (
"-record", cmd_str, cmd_len))
1473 tagEnd (spec, min_level, cmd_str, cmd_len);
1474 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1477 tagEnd (spec, min_level, NULL, 0);
1481 yaz_log (YLOG_LOG,
"end element end records");
1487 else if (!strcmp (p,
"context"))
1490 yaz_log (YLOG_LOG,
"end context");
1494 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1497 yaz_log (YLOG_WARN,
"bad keyword '%s' after end", p);
1499 else if (!strcmp (p,
"data"))
1503 const char *element_str = NULL;
1505 const char *attribute_str = NULL;
1507 while ((r =
execTok (spec, &s, &cmd_str, &cmd_len)) == 3)
1509 if (cmd_len==5 && !memcmp (
"-text", cmd_str, cmd_len))
1511 else if (cmd_len==8 && !memcmp (
"-element", cmd_str, cmd_len))
1513 r =
execTok (spec, &s, &element_str, &element_len);
1517 else if (cmd_len==10 && !memcmp (
"-attribute", cmd_str,
1520 r =
execTok (spec, &s, &attribute_str, &attribute_len);
1525 yaz_log (YLOG_WARN,
"bad data option: %.*s",
1530 yaz_log (YLOG_WARN,
"missing data item after data");
1534 tagBegin (spec, element_str, element_len);
1537 execData (spec, cmd_str, cmd_len, textFlag,
1538 attribute_str, attribute_len);
1539 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1542 tagEnd (spec, 2, NULL, 0);
1544 else if (!strcmp (p,
"unread"))
1547 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1548 if (r==3 && cmd_len == 7 && !memcmp (
"-offset", cmd_str, cmd_len))
1550 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1553 yaz_log (YLOG_WARN,
"missing number after -offset");
1556 p =
regxStrz (cmd_str, cmd_len, ptmp);
1558 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1564 yaz_log (YLOG_WARN,
"missing index after unread command");
1567 if (cmd_len != 1 || *cmd_str <
'0' || *cmd_str >
'9')
1569 yaz_log (YLOG_WARN,
"bad index after unread command");
1574 no = *cmd_str -
'0';
1579 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1581 else if (!strcmp (p,
"context"))
1586 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1587 p =
regxStrz (cmd_str, cmd_len, ptmp);
1589 while (lc && strcmp (p, lc->
name))
1594 yaz_log (YLOG_WARN,
"unknown context %s", p);
1597 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1601 yaz_log (YLOG_WARN,
"unknown code command '%.*s'", cmd_len, cmd_str);
1602 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1607 yaz_log (YLOG_WARN,
"ignoring token %.*s", cmd_len, cmd_str);
1609 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1617 int start_ptr,
int *pptr)
1641 yaz_log(YLOG_DEBUG,
"Pattern match rest of record");
1649 spec->
arg_end[arg_no] = *pptr;
1659 spec->
arg_end[arg_no] = *pptr;
1667 if (spec->tcl_interp)
1668 execTcl(spec, ap->
u.
code);
1690 int ruleNo,
int start_ptr,
int *pptr)
1693 yaz_log (YLOG_LOG,
"exec rule %d",
ruleNo);
1705 unsigned char c_prev =
'\n';
1708 int last_ptr = *ptr;
1709 int start_ptr = *ptr;
1710 int skip_ptr = *ptr;
1722 if (skip_ptr < start_ptr)
1727 buf =
f_win_get (spec, skip_ptr, start_ptr, &size);
1733 if (!
execRule (spec, context, last_rule, start_ptr, ptr))
1739 else if (skip_ptr < *ptr)
1744 buf =
f_win_get (spec, skip_ptr, *ptr, &size);
1758 if (skip_ptr < start_ptr)
1763 buf =
f_win_get (spec, skip_ptr, start_ptr, &size);
1768 if (!
execRule (spec, context, last_rule, start_ptr, ptr))
1772 off_t end_offset = *ptr;
1774 yaz_log (YLOG_LOG,
"regx: endf ptr=%d", *ptr);
1783 last_ptr = start_ptr = *ptr;
1798 else if (c >= t->
ch[0] && c <= t->
ch[1])
1824 const char *context_name)
1835 if (!strcmp (lt->
name, context_name))
1841 yaz_log (YLOG_WARN,
"cannot find context %s", context_name);
1881 strcpy(specs->
type,
"");
1889 if (strlen(args) <
sizeof(specs->
type))
1890 strcpy(specs->
type, args);
1902 yaz_log (YLOG_LOG,
"grs_read_regx");
1904 if (!*curLexSpec || strcmp ((*curLexSpec)->name, specs->
type))
1916 (*curLexSpec)->dh = p->
dh;
1918 if (start_offset == 0)
1920 (*curLexSpec)->f_win_start = 0;
1921 (*curLexSpec)->f_win_end = 0;
1924 (*curLexSpec)->stream = p->
stream;
1926 (*curLexSpec)->f_win_size = 500000;
1928 (*curLexSpec)->m = p->
mem;
1929 return lexRoot (*curLexSpec, start_offset,
"main");
1958 struct lexSpec **curLexSpec = &specs->spec;
1962 yaz_log (YLOG_LOG,
"grs_read_tcl");
1964 if (!*curLexSpec || strcmp ((*curLexSpec)->name, specs->type))
1966 Tcl_Interp *tcl_interp;
1970 Tcl_FindExecutable(
"");
1971 tcl_interp = (*curLexSpec)->tcl_interp = Tcl_CreateInterp();
1972 Tcl_Init(tcl_interp);
1973 Tcl_CreateCommand (tcl_interp,
"begin", cmd_tcl_begin, *curLexSpec, 0);
1974 Tcl_CreateCommand (tcl_interp,
"end", cmd_tcl_end, *curLexSpec, 0);
1975 Tcl_CreateCommand (tcl_interp,
"data", cmd_tcl_data, *curLexSpec, 0);
1976 Tcl_CreateCommand (tcl_interp,
"unread", cmd_tcl_unread,
1985 (*curLexSpec)->dh = p->dh;
1986 start_offset = p->stream->tellf(p->stream);
1987 if (start_offset == 0)
1989 (*curLexSpec)->f_win_start = 0;
1990 (*curLexSpec)->f_win_end = 0;
1991 (*curLexSpec)->f_win_rf = p->stream->readf;
1992 (*curLexSpec)->f_win_sf = p->stream->seekf;
1993 (*curLexSpec)->stream = p->stream;
1994 (*curLexSpec)->f_win_ef = p->stream->endf;
1995 (*curLexSpec)->f_win_size = 500000;
1997 (*curLexSpec)->m = p->mem;
1998 return lexRoot (*curLexSpec, start_offset,
"main");
2001static int extract_tcl(
void *clientData,
struct recExtractCtrl *ctrl)
2006static int retrieve_tcl(
void *clientData,
struct recRetrieveCtrl *ctrl)
2011static struct recType tcl_type = {
2024#if IDZEBRA_STATIC_GRS_REGX
2025idzebra_filter_grs_regx
data1_node * data1_mk_root(data1_handle dh, NMEM nmem, const char *name)
data1_node * data1_mk_tag_n(data1_handle dh, NMEM nmem, const char *tag, size_t len, const char **attr, data1_node *at)
FILE * data1_path_fopen(data1_handle dh, const char *file, const char *mode)
data1_vartype * data1_getvartypeby_absyn(data1_handle dh, data1_absyn *absyn, char *zclass, char *type)
data1_node * data1_mk_node2(data1_handle dh, NMEM m, int type, data1_node *parent)
data1_node * data1_mk_tag(data1_handle dh, NMEM nmem, const char *tag, const char **attr, data1_node *at)
struct data1_handle_info * data1_handle
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 struct DFA * lexSpecDFA(void)
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 int execAction(struct lexSpec *spec, struct lexRuleAction *ap, int start_ptr, int *pptr)
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 data1_node * lexRoot(struct lexSpec *spec, off_t offset, const char *context_name)
static void actionListDel(struct lexRuleAction **rap)
static void tagStrip(const char **tag, int *len)
static int actionListMk(struct lexSpec *spec, const char *s, struct lexRuleAction **ap)
static struct lexContext * lexContextCreate(const char *name)
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)
static char * regxStrz(const char *src, int len, char *str)
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)
void * grs_init(Res res, RecType recType)
int lexNode(struct lexSpec *spec, int *ptr)
data1_node * grs_read_regx(struct grs_read_info *p)
void grs_destroy(void *clientData)
static int tryMatch(struct lexSpec *spec, int *pptr, int *mptr, struct DFA *dfa, int greedy)
static int retrieve_regx(void *clientData, struct recRetrieveCtrl *ctrl)
static struct recType regx_type
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 * parent
struct data1_node::@301101362156040217205154262063004221063310255144::@326023201334017323323260313204345146150132264306 variant
struct data1_node::@301101362156040217205154262063004221063310255144::@312107066076370025032234161075372154153236151322 root
struct data1_absyn * absyn
union data1_node::@301101362156040217205154262063004221063310255144 u
struct data1_xattr * next
struct ZebraRecStream * stream
struct lexRuleAction * endActionList
struct lexRuleInfo ** fastRule
struct lexRuleAction * beginActionList
struct lexRuleAction * initActionList
struct lexRuleAction * next
struct lexRuleAction::@361152206274041047011207072351072023354250134264::@331307174160120347270273164353043313014042030275 pattern
union lexRuleAction::@361152206274041047011207072351072023354250134264 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)
int arg_start[REGX_MAX_ARGS]
struct ZebraRecStream * stream
struct lexContext ** context_stack
int arg_end[REGX_MAX_ARGS]
int(* f_win_rf)(struct ZebraRecStream *, char *, size_t)
struct lexConcatBuf * concatBuf
short ZEBRA_RES
Common return type for Zebra API.