// SetNum sets a number in the specified field of the engine configuration. // Certain fields accept only 32-bit numbers, silently truncating the higher bits // of the engine config. See dat.go for more information. func (e *Engine) SetNum(field EngineField, num uint64) error { err := C.cl_engine_set_num((*C.struct_cl_engine)(e), C.enum_cl_engine_field(field), C.longlong(num)) if ErrorCode(err) != Success { return fmt.Errorf("%v", StrError(ErrorCode(err))) } return nil }
// GetNum acquires a number from the specified field of the engine configuration. Tests show that // the ClamAV library will not overflow 32-bit fields, so a GetNum on a 32-bit field can safely be // cast to uint32. func (e *Engine) GetNum(field EngineField) (uint64, error) { var err ErrorCode ne := (*C.struct_cl_engine)(e) num := uint64(C.cl_engine_get_num(ne, C.enum_cl_engine_field(field), (*C.int)(unsafe.Pointer(&err)))) if err != Success { return num, fmt.Errorf("%v", StrError(ErrorCode(err))) } return num, nil }
// GetString returns a string from the corresponding field of the engine configuration. func (e *Engine) GetString(field EngineField) (string, error) { var err ErrorCode str := C.GoString(C.cl_engine_get_str((*C.struct_cl_engine)(e), C.enum_cl_engine_field(field), (*C.int)(unsafe.Pointer(&err)))) if err != Success { return "", fmt.Errorf("%v", StrError(ErrorCode(err))) } return str, nil }
// SetString sets a string in the corresponding field of the engine configuration. // See dat.go for the corresponding (char *) fields in ClamAV. func (e *Engine) SetString(field EngineField, s string) error { str := C.CString(s) defer C.free(unsafe.Pointer(str)) err := C.cl_engine_set_str((*C.struct_cl_engine)(e), C.enum_cl_engine_field(field), str) if ErrorCode(err) != Success { return fmt.Errorf("%v", StrError(ErrorCode(err))) } return nil }