grok.h File Reference

Go to the source code of this file.

Data Structures

struct  grok_pattern
struct  grok

Typedefs

typedef struct grok grok_t
typedef struct grok_pattern grok_pattern_t

Functions

grok_tgrok_new ()
 Create a new grok_t instance.
void grok_init (grok_t *grok)
 Initialize a grok_t instance.
void grok_clone (grok_t *dst, const grok_t *src)
 Shallow clone of a grok instance.
void grok_free (grok_t *grok)
 Free a grok instance.
void grok_free_clone (const grok_t *grok)
const char * grok_version ()
 Get the library's version number.
int grok_compile (grok_t *grok, const char *pattern)
 Compile a pattern.
int grok_compilen (grok_t *grok, const char *pattern, int length)
 Compile a pattern with known length.
int grok_exec (const grok_t *grok, const char *text, grok_match_t *gm)
 Execute against a string input.
int grok_execn (const grok_t *grok, const char *text, int textlen, grok_match_t *gm)
int grok_match_get_named_substring (const grok_match_t *gm, const char *name, const char **substr, int *len)

Variables

int g_grok_global_initialized
pcre * g_pattern_re
int g_pattern_num_captures
int g_cap_name
int g_cap_pattern
int g_cap_subname
int g_cap_predicate

Detailed Description


Function Documentation

void grok_clone ( grok_t dst,
const grok_t src 
)

Shallow clone of a grok instance.

This is useful for creating new grok_t instances with the same loaded patterns. It also copies the log settings.

Parameters:
dst pointer to destination grok_t you want to clone into.
src pointer to source grok_t you can to clone from.
int grok_compile ( grok_t grok,
const char *  pattern 
)

Compile a pattern.

PCRE syntax is supported.

Grok extends this syntax with %{PATTERN} syntax This allows you to use predefined patterns anywhere in your regular expression.

Parameters:
grok the grok_t instance to compile into.
pattern the string regexp pattern to compile.
int grok_compilen ( grok_t grok,
const char *  pattern,
int  length 
)

Compile a pattern with known length.

Parameters:
pattern the string pattern to compile
length the length of the pattern
See also:
grok_compile()
int grok_exec ( const grok_t grok,
const char *  text,
grok_match_t gm 
)

Execute against a string input.

Parameters:
text the text to match.
gm The grok_match_t to store match result in. If NULL, no storing is attempted.
Returns:
GROK_OK if match successful, GROK_ERROR_NOMATCH if no match.
int grok_execn ( const grok_t grok,
const char *  text,
int  textlen,
grok_match_t gm 
)
See also:
grok_exec
void grok_free ( grok_t grok  ) 

Free a grok instance.

This will clean up any memory allocated by the grok_t instance during it's life. Finally, this method will free() the grok_t pointer you gave.

Do not use this method on grok_t instances you created with grok_clone.

Parameters:
grok the grok_t instance you want to free.
void grok_init ( grok_t grok  ) 

Initialize a grok_t instance.

This is useful if you have a grok_t as a stack variable rather than heap.

grok_t* grok_new (  ) 

Create a new grok_t instance.

The new grok_t instance is initialized with grok_init() already, so you do not need to call it.

You should use grok_free() on the result when you want to free it.

Returns:
pointer to new grok_t instance or NULL on failure.
const char* grok_version (  ) 

Get the library's version number.

Returns:
string representing grok's version.
 All Data Structures Files Functions Variables

Generated on Tue Apr 20 01:29:03 2010 for grok by  doxygen 1.6.1