Exemplo n.º 1
0
func (r *Rules) ScanFile(path string, fn Callback) error {
	cpath := C.CString(path)
	code := C.yr_rules_scan_file(r.handle, cpath, 0, callback, *(*unsafe.Pointer)(unsafe.Pointer(&fn)), 0)
	C.free(unsafe.Pointer(cpath))

	if code != C.ERROR_SUCCESS {
		return Error(code)
	}

	return nil
}
Exemplo n.º 2
0
// ScanFile scans a file using the ruleset.
func (r *Rules) ScanFile(filename string, flags ScanFlags, timeout time.Duration) (matches []MatchRule, err error) {
	cfilename := C.CString(filename)
	defer C.free(unsafe.Pointer(cfilename))
	dummy = &matches
	err = newError(C.yr_rules_scan_file(
		r.cptr,
		cfilename,
		C.int(flags),
		C.YR_CALLBACK_FUNC(C.rules_callback),
		unsafe.Pointer(&matches),
		C.int(timeout/time.Second)))
	return
}