Beispiel #1
0
// ReadRules retrieves a compiled ruleset from an io.Reader
func ReadRules(rd io.Reader) (*Rules, error) {
	var yrRules *C.YR_RULES
	var stream C.YR_STREAM
	stream.user_data = unsafe.Pointer(&rd)
	stream.read = C.YR_STREAM_READ_FUNC(C.stream_read)
	if err := newError(C.yr_rules_load_stream(&stream, &yrRules)); err != nil {
		return nil, err
	}
	r := &Rules{rules: &rules{cptr: yrRules}}
	runtime.SetFinalizer(r.rules, (*rules).finalize)
	return r, nil
}
Beispiel #2
0
func readStream(r io.Reader) *C.YR_STREAM {
	stream := new(C.YR_STREAM)
	stream.user_data = unsafe.Pointer(&r)
	stream.read = (C.YR_STREAM_READ_FUNC)(C.goStreamRead)
	return stream
}