IDZEBRA  2.2.7
Data Structures | Macros | Functions | Variables
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
 

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 DFAlexSpecDFA (void)
 
static void actionListDel (struct lexRuleAction **rap)
 
static struct lexContextlexContextCreate (const char *name)
 
static void lexContextDestroy (struct lexContext *p)
 
static struct lexSpeclexSpecCreate (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_nodelexRoot (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_nodegrs_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.

◆ 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.

◆ REGX_BODY

#define REGX_BODY   2

Definition at line 50 of file mod_grs_regx.c.

◆ REGX_CODE

#define REGX_CODE   5

Definition at line 53 of file mod_grs_regx.c.

◆ REGX_CONTEXT

#define REGX_CONTEXT   6

Definition at line 54 of file mod_grs_regx.c.

◆ 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.

◆ 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.

◆ REGX_PATTERN

#define REGX_PATTERN   1

Definition at line 49 of file mod_grs_regx.c.

Function Documentation

◆ actionListDel()

static void actionListDel ( struct lexRuleAction **  rap)
static

◆ actionListMk()

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

◆ execAction()

static int execAction ( struct lexSpec spec,
struct lexRuleAction ap,
int  start_ptr,
int *  pptr 
)
static

◆ execCode()

static void execCode ( struct lexSpec spec,
struct regxCode code 
)
static

◆ execData()

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

◆ execDataP()

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

Definition at line 774 of file mod_grs_regx.c.

References execData(), and data1_node::formatted_text.

Referenced by lexNode().

◆ execRule()

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

Definition at line 1691 of file mod_grs_regx.c.

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

Referenced by lexNode().

◆ execTok()

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

Definition at line 1007 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()

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

Definition at line 1934 of file mod_grs_regx.c.

References grs_read_regx(), and zebra_grs_extract().

◆ f_win_advance()

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

Definition at line 184 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()

static 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 1888 of file mod_grs_regx.c.

References lexSpecs::type, and ZEBRA_OK.

◆ grs_destroy()

void grs_destroy ( void *  clientData)

Definition at line 1869 of file mod_grs_regx.c.

References lexSpecDestroy(), and lexSpecs::spec.

◆ grs_init()

void* grs_init ( Res  res,
RecType  recType 
)

Definition at line 1879 of file mod_grs_regx.c.

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

◆ grs_read_regx()

data1_node* grs_read_regx ( struct grs_read_info p)

◆ lexContextCreate()

static struct lexContext* lexContextCreate ( const char *  name)
static

◆ lexContextDestroy()

static void lexContextDestroy ( struct lexContext p)
static

◆ lexNode()

int lexNode ( struct lexSpec spec,
int *  ptr 
)

◆ lexRoot()

static data1_node* lexRoot ( struct lexSpec spec,
off_t  offset,
const char *  context_name 
)
static

◆ lexSpecCreate()

static struct lexSpec* lexSpecCreate ( const char *  name,
data1_handle  dh 
)
static

◆ lexSpecDestroy()

static void lexSpecDestroy ( struct lexSpec **  pp)
static

◆ lexSpecDFA()

static struct DFA* lexSpecDFA ( void  )
static

Definition at line 234 of file mod_grs_regx.c.

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

Referenced by actionListMk(), and lexContextCreate().

◆ readFileSpec()

int readFileSpec ( struct lexSpec spec)

◆ readOneSpec()

int readOneSpec ( struct lexSpec spec,
const char *  s 
)

◆ readParseToken()

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

Definition at line 368 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()

static void regxCodeDel ( struct regxCode **  pp)
static

Definition at line 203 of file mod_grs_regx.c.

References regxCode::str.

Referenced by actionListDel().

◆ regxCodeMk()

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

Definition at line 218 of file mod_grs_regx.c.

References regxCode::str.

Referenced by actionListMk().

◆ regxStrz()

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

Definition at line 1072 of file mod_grs_regx.c.

Referenced by execCode().

◆ retrieve_regx()

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

Definition at line 1939 of file mod_grs_regx.c.

◆ tagBegin()

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

◆ tagDataRelease()

static void tagDataRelease ( struct lexSpec spec)
static

◆ tagEnd()

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

◆ tagStrip()

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

Definition at line 870 of file mod_grs_regx.c.

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

Referenced by tagBegin(), and tagEnd().

◆ tryMatch()

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

◆ variantBegin()

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

Variable Documentation

◆ idzebra_filter

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

Definition at line 2029 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_destroy(void *clientData)
void * grs_init(Res res, RecType recType)
static int retrieve_regx(void *clientData, struct recRetrieveCtrl *ctrl)

Definition at line 1939 of file mod_grs_regx.c.