Esempio n. 1
0
func (grok *Grok) AddPattern(name, pattern string) {
	cname := C.CString(name)
	cpattern := C.CString(pattern)
	defer C.free(unsafe.Pointer(cname))
	defer C.free(unsafe.Pointer(cpattern))

	C.grok_pattern_add(grok.g, cname, C.strlen(cname), cpattern, C.strlen(cpattern))
}
Esempio n. 2
0
func (this *Grok) AddPattern(name, pattern string) (err error) {
	name_c := C.CString(name)
	defer C.free(unsafe.Pointer(name_c))
	pattern_c := C.CString(pattern)
	defer C.free(unsafe.Pointer(pattern_c))

	ret := C.grok_pattern_add(this.Obj, name_c, C.size_t(len(name)), pattern_c, C.size_t(len(pattern)))
	if ret != GROK_OK {
		err = errors.New("Failed to add pattern " + name)
	}
	return
}
Esempio n. 3
0
func (grok *Grok) AddPattern(word string, regexp string) error {
	//const char *regexp = NULL;

	word_len := C.size_t(len(word))
	regexp_len := C.size_t(len(regexp))

	cword := C.CString(word)
	defer C.free(unsafe.Pointer(cword))
	cregexp := C.CString(regexp)
	defer C.free(unsafe.Pointer(cregexp))

	ret := C.grok_pattern_add(grok.grok, cword, word_len, cregexp, regexp_len)
	if ret != C.GROK_OK {
		return GrokError{ret}
	}
	return nil
}