IDZEBRA 2.2.11
mod_grs_regx.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <yaz/tpath.h>
#include <yaz/snprintf.h>
#include <idzebra/util.h>
#include <dfa.h>
#include <idzebra/recgrs.h>

Go to the source code of this file.

Data Structures

struct  regxCode
struct  lexRuleAction
struct  lexRuleInfo
struct  lexRule
struct  lexContext
struct  lexConcatBuf
struct  lexSpec
struct  lexSpecs

Macros

#define REGX_DEBUG   0
#define F_WIN_EOF   2000000000
#define F_WIN_READ   1
#define REGX_EOF   0
#define REGX_PATTERN   1
#define REGX_BODY   2
#define REGX_BEGIN   3
#define REGX_END   4
#define REGX_CODE   5
#define REGX_CONTEXT   6
#define REGX_INIT   7
#define REGX_MAX_ARGS   20

Functions

static char * f_win_get (struct lexSpec *spec, off_t start_pos, off_t end_pos, int *size)
static int f_win_advance (struct lexSpec *spec, int *pos)
static void regxCodeDel (struct regxCode **pp)
static void regxCodeMk (struct regxCode **pp, const char *buf, int len)
static struct DFA * lexSpecDFA (void)
static void actionListDel (struct lexRuleAction **rap)
static struct lexContext * lexContextCreate (const char *name)
static void lexContextDestroy (struct lexContext *p)
static struct lexSpec * lexSpecCreate (const char *name, data1_handle dh)
static void lexSpecDestroy (struct lexSpec **pp)
static int readParseToken (const char **cpp, int *len)
static int actionListMk (struct lexSpec *spec, const char *s, struct lexRuleAction **ap)
int readOneSpec (struct lexSpec *spec, const char *s)
int readFileSpec (struct lexSpec *spec)
static void execData (struct lexSpec *spec, const char *ebuf, int elen, int formatted_text, const char *attribute_str, int attribute_len)
static void execDataP (struct lexSpec *spec, const char *ebuf, int elen, int formatted_text)
static void tagDataRelease (struct lexSpec *spec)
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 void tagStrip (const char **tag, int *len)
static void tagBegin (struct lexSpec *spec, const char *tag, int len)
static void tagEnd (struct lexSpec *spec, int min_level, const char *tag, int len)
static int tryMatch (struct lexSpec *spec, int *pptr, int *mptr, struct DFA *dfa, int greedy)
static int execTok (struct lexSpec *spec, const char **src, const char **tokBuf, int *tokLen)
static char * regxStrz (const char *src, int len, char *str)
static void execCode (struct lexSpec *spec, struct regxCode *code)
static int execAction (struct lexSpec *spec, struct lexRuleAction *ap, int start_ptr, int *pptr)
static int execRule (struct lexSpec *spec, struct lexContext *context, int ruleNo, int start_ptr, int *pptr)
int lexNode (struct lexSpec *spec, int *ptr)
static data1_node * lexRoot (struct lexSpec *spec, off_t offset, const char *context_name)
void grs_destroy (void *clientData)
void * grs_init (Res res, RecType recType)
ZEBRA_RES grs_config (void *clientData, Res res, const char *args)
data1_node * grs_read_regx (struct grs_read_info *p)
static int extract_regx (void *clientData, struct recExtractCtrl *ctrl)
static int retrieve_regx (void *clientData, struct recRetrieveCtrl *ctrl)

Variables

static struct recType regx_type
RecType idzebra_filter []

Macro Definition Documentation

◆ F_WIN_EOF

#define F_WIN_EOF   2000000000

Definition at line 45 of file mod_grs_regx.c.

Referenced by execAction(), f_win_advance(), lexNode(), and tryMatch().

◆ F_WIN_READ

#define F_WIN_READ   1

Definition at line 46 of file mod_grs_regx.c.

◆ REGX_BEGIN

#define REGX_BEGIN   3

Definition at line 51 of file mod_grs_regx.c.

Referenced by actionListMk(), readOneSpec(), and readParseToken().

◆ REGX_BODY

#define REGX_BODY   2

Definition at line 50 of file mod_grs_regx.c.

Referenced by actionListMk(), and readParseToken().

◆ REGX_CODE

#define REGX_CODE   5

Definition at line 53 of file mod_grs_regx.c.

Referenced by actionListDel(), actionListMk(), execAction(), readOneSpec(), and readParseToken().

◆ REGX_CONTEXT

#define REGX_CONTEXT   6

Definition at line 54 of file mod_grs_regx.c.

Referenced by readOneSpec(), and readParseToken().

◆ REGX_DEBUG

#define REGX_DEBUG   0

Definition at line 43 of file mod_grs_regx.c.

◆ REGX_END

#define REGX_END   4

Definition at line 52 of file mod_grs_regx.c.

Referenced by actionListMk(), execAction(), readOneSpec(), and readParseToken().

◆ REGX_EOF

#define REGX_EOF   0

Definition at line 48 of file mod_grs_regx.c.

◆ REGX_INIT

#define REGX_INIT   7

Definition at line 55 of file mod_grs_regx.c.

Referenced by actionListMk(), readOneSpec(), and readParseToken().

◆ REGX_MAX_ARGS

#define REGX_MAX_ARGS   20

Definition at line 57 of file mod_grs_regx.c.

Referenced by execAction().

◆ REGX_PATTERN

#define REGX_PATTERN   1

Definition at line 49 of file mod_grs_regx.c.

Referenced by actionListDel(), actionListMk(), execAction(), readOneSpec(), and readParseToken().

Function Documentation

◆ actionListDel()

◆ actionListMk()

int actionListMk ( struct lexSpec * spec,
const char * s,
struct lexRuleAction ** ap )
static

◆ execAction()

◆ execCode()

◆ execData()

void execData ( struct lexSpec * spec,
const char * ebuf,
int elen,
int formatted_text,
const char * attribute_str,
int attribute_len )
static

◆ execDataP()

void execDataP ( struct lexSpec * spec,
const char * ebuf,
int elen,
int formatted_text )
static

Definition at line 776 of file mod_grs_regx.c.

References execData(), and data1_node::formatted_text.

Referenced by lexNode().

◆ execRule()

int execRule ( struct lexSpec * spec,
struct lexContext * context,
int ruleNo,
int start_ptr,
int * pptr )
static

Definition at line 1689 of file mod_grs_regx.c.

References lexRuleInfo::actionList, execAction(), lexContext::fastRule, and lexContext::ruleNo.

Referenced by lexNode().

◆ execTok()

int execTok ( struct lexSpec * spec,
const char ** src,
const char ** tokBuf,
int * tokLen )
static

Definition at line 1009 of file mod_grs_regx.c.

References lexSpec::arg_end, lexSpec::arg_no, lexSpec::arg_start, and f_win_get().

Referenced by execCode().

◆ extract_regx()

int extract_regx ( void * clientData,
struct recExtractCtrl * ctrl )
static

Definition at line 1932 of file mod_grs_regx.c.

References grs_read_regx(), and zebra_grs_extract().

◆ f_win_advance()

int f_win_advance ( struct lexSpec * spec,
int * pos )
static

Definition at line 186 of file mod_grs_regx.c.

References lexSpec::f_win_buf, lexSpec::f_win_end, F_WIN_EOF, f_win_get(), and lexSpec::f_win_start.

Referenced by lexNode(), and tryMatch().

◆ f_win_get()

char * f_win_get ( struct lexSpec * spec,
off_t start_pos,
off_t end_pos,
int * size )
static

◆ grs_config()

ZEBRA_RES grs_config ( void * clientData,
Res res,
const char * args )

Definition at line 1886 of file mod_grs_regx.c.

References lexSpecs::type, and ZEBRA_OK.

◆ grs_destroy()

void grs_destroy ( void * clientData)

Definition at line 1867 of file mod_grs_regx.c.

References lexSpecDestroy(), and lexSpecs::spec.

◆ grs_init()

void * grs_init ( Res res,
RecType recType )

Definition at line 1877 of file mod_grs_regx.c.

References lexSpecs::spec, and lexSpecs::type.

◆ grs_read_regx()

◆ lexContextCreate()

◆ lexContextDestroy()

◆ lexNode()

◆ lexRoot()

◆ lexSpecCreate()

◆ lexSpecDestroy()

◆ lexSpecDFA()

struct DFA * lexSpecDFA ( void )
static

Definition at line 236 of file mod_grs_regx.c.

References dfa_init(), dfa_parse_cmap_add(), and dfa_parse_cmap_del().

Referenced by actionListMk(), and lexContextCreate().

◆ readFileSpec()

◆ readOneSpec()

◆ readParseToken()

int readParseToken ( const char ** cpp,
int * len )
static

Definition at line 370 of file mod_grs_regx.c.

References REGX_BEGIN, REGX_BODY, REGX_CODE, REGX_CONTEXT, REGX_END, REGX_INIT, and REGX_PATTERN.

Referenced by actionListMk(), and readOneSpec().

◆ regxCodeDel()

void regxCodeDel ( struct regxCode ** pp)
static

Definition at line 205 of file mod_grs_regx.c.

References regxCode::str.

Referenced by actionListDel().

◆ regxCodeMk()

void regxCodeMk ( struct regxCode ** pp,
const char * buf,
int len )
static

Definition at line 220 of file mod_grs_regx.c.

References regxCode::str.

Referenced by actionListMk().

◆ regxStrz()

char * regxStrz ( const char * src,
int len,
char * str )
static

Definition at line 1074 of file mod_grs_regx.c.

Referenced by execCode().

◆ retrieve_regx()

int retrieve_regx ( void * clientData,
struct recRetrieveCtrl * ctrl )
static

Definition at line 1937 of file mod_grs_regx.c.

References grs_read_regx(), and zebra_grs_retrieve().

◆ tagBegin()

void tagBegin ( struct lexSpec * spec,
const char * tag,
int len )
static

◆ tagDataRelease()

◆ tagEnd()

void tagEnd ( struct lexSpec * spec,
int min_level,
const char * tag,
int len )
static

◆ tagStrip()

void tagStrip ( const char ** tag,
int * len )
static

Definition at line 872 of file mod_grs_regx.c.

References data1_node::len, and data1_node::tag.

Referenced by tagBegin(), and tagEnd().

◆ tryMatch()

int tryMatch ( struct lexSpec * spec,
int * pptr,
int * mptr,
struct DFA * dfa,
int greedy )
static

◆ variantBegin()

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

Variable Documentation

◆ idzebra_filter

RecType idzebra_filter[]
Initial value:
= {
0,
}
static struct recType regx_type

Definition at line 2027 of file mod_grs_regx.c.

◆ regx_type

struct recType regx_type
static
Initial value:
= {
0,
"grs.regx",
}
static int extract_regx(void *clientData, struct recExtractCtrl *ctrl)
ZEBRA_RES grs_config(void *clientData, Res res, const char *args)
void * grs_init(Res res, RecType recType)
void grs_destroy(void *clientData)
static int retrieve_regx(void *clientData, struct recRetrieveCtrl *ctrl)

Definition at line 1942 of file mod_grs_regx.c.