// See also https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterLookupByUUID
3040
func (c *Connect) LookupNWFilterByUUID(uuid []byte) (*NWFilter, error) {
	if len(uuid) != C.VIR_UUID_BUFLEN {
		return nil, fmt.Errorf("UUID must be exactly %d bytes in size",
			int(C.VIR_UUID_BUFLEN))
	}
	cUuid := make([]C.uchar, C.VIR_UUID_BUFLEN)
	for i := 0; i < C.VIR_UUID_BUFLEN; i++ {
		cUuid[i] = C.uchar(uuid[i])
	}
	var err C.virError
	ptr := C.virNWFilterLookupByUUIDWrapper(c.ptr, &cUuid[0], &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &NWFilter{ptr: ptr}, nil
}
779015
func (hook *FluentHook) AddFilter(name string, fn func(interface{}) interface{}) {
	hook.filters[name] = fn
}
1215340
func (f *NWFilterBinding) Free() error {
	if C.LIBVIR_VERSION_NUMBER < 4005000 {
		return makeNotImplementedError("virNWFilterBindingFree")
	}
	var err C.virError
	ret := C.virNWFilterBindingFreeWrapper(f.ptr, &err)
	if ret == -1 {
		return makeError(&err)
	}
	return nil
}
721000
func filter(vs []NetworkDevice, f func(NetworkDevice) bool) []NetworkDevice {
	var vsf []NetworkDevice
	for _, v := range vs {
		if f(v) {
			vsf = append(vsf, v)
		}
	}
	return vsf
}
677632
func (r *Render) TemplateLookup(t string) *template.Template {
	return r.templates.Lookup(t)
}
807514
func uuidFromPath(path string) string {
	path = strings.TrimPrefix(path, guiURLPathPrefix)
	uuid := strings.SplitN(path, "/", 2)[0]
	if names.IsValidModel(uuid) {
		return uuid
	}
	return ""
}
599690
func (f *NWFilter) Undefine() error {
	var err C.virError
	result := C.virNWFilterUndefineWrapper(f.ptr, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}
1167213
func (h *Hostlist) FilterByDomainV(domain string, version int) (hostnames []*Hostname) {
	if version != 4 && version != 6 {
		panic(ErrInvalidVersionArg)
	}
	for _, hostname := range *h {
		if hostname.Domain == domain && hostname.IPv6 == (version == 6) {
			hostnames = append(hostnames, hostname)
		}
	}
	return
}
1059840
func (u Util) userLookup(name string) (*user.User, error) {
	res := &C.lookup_res_t{}

	if ret, err := C.user_lookup(C.CString(u.DestDir),
		C.CString(name), res); ret < 0 {
		return nil, fmt.Errorf("lookup failed: %v", err)
	}

	if res.name == nil {
		return nil, fmt.Errorf("user %q not found", name)
	}

	homedir, err := u.JoinPath(C.GoString(res.home))
	if err != nil {
		return nil, err
	}

	usr := &user.User{
		Name:    C.GoString(res.name),
		Uid:     fmt.Sprintf("%d", int(res.uid)),
		Gid:     fmt.Sprintf("%d", int(res.gid)),
		HomeDir: homedir,
	}

	C.user_lookup_res_free(res)

	return usr, nil
}
169192
func (t *Template) GetAllAWSGuardDutyFilterResources() map[string]*resources.AWSGuardDutyFilter {
	results := map[string]*resources.AWSGuardDutyFilter{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSGuardDutyFilter:
			results[name] = resource
		}
	}
	return results
}
152624
func IdentityFilterByProfileURL(profileURL string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("profile_url = ?", profileURL).Limit(1)
	}
}
539034
func (c *NWFilterBinding) Ref() error {
	if C.LIBVIR_VERSION_NUMBER < 4005000 {
		return makeNotImplementedError("virNWFilterBindingRef")
	}
	var err C.virError
	ret := C.virNWFilterBindingRefWrapper(c.ptr, &err)
	if ret == -1 {
		return makeError(&err)
	}
	return nil
}
579599
func findNewestFilter(filterName string, logInfo serviceLogInfo, logFilters []*logfilter.LogFilter) (string, bool) {
	matchingFilters := []*logfilter.LogFilter{}
	for _, filter := range logFilters {
		if filterName == filter.Name {
			matchingFilters = append(matchingFilters, filter)
		}
	}

	var closest *logfilter.LogFilter
	var filterVersion version.Version
	svcVersion := version.Version(logInfo.Version)
	for _, filter := range matchingFilters {
		filterVersion = version.Version(filter.Version)
		if svcVersion.Equal(filterVersion) {
			closest = filter
			break
		} else if closest == nil || version.Version(closest.Version).LessThan(filterVersion) {
			closest = filter
		}
	}
	if closest == nil {
		return "", false
	}
	if !svcVersion.Equal(filterVersion)  {
		plog.WithFields(log.Fields{
			"serviceid": logInfo.ID,
			"servicename": logInfo.Name,
			"serviceversion": logInfo.Version,
			"filter": filterName,
			"filterversion": closest.Version,
		}).Warn("Unable to find exact match for service log filter version")
	}
	return closest.Filter, true
}
839065
func (s *RouterService) GetVirtualRouterElementByID(id string, opts ...OptionFunc) (*VirtualRouterElement, int, error) {
	p := &ListVirtualRouterElementsParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListVirtualRouterElements(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.VirtualRouterElements[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for VirtualRouterElement UUID: %s!", id)
}
417210
func (c *Connect) LookupNetworkByUUIDString(uuid string) (*Network, error) {
	cUuid := C.CString(uuid)
	defer C.free(unsafe.Pointer(cUuid))
	var err C.virError
	ptr := C.virNetworkLookupByUUIDStringWrapper(c.ptr, cUuid, &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &Network{ptr: ptr}, nil
}
392959
func FilterBySubject(subj string) (CertificateFilter, error) {
	subjFilter, err := regexp.Compile(subj)
	if err != nil {
		return nil, err
	}

	return func(cm *CertificateMetadata) bool {
		return subjFilter.MatchString(cm.Subject)
	}, nil
}
1104075
func (r Utility_Network) NsLookup(address *string, typ *string) (resp string, err error) {
	params := []interface{}{
		address,
		typ,
	}
	err = r.Session.DoRequest("SoftLayer_Utility_Network", "nsLookup", params, &r.Options, &resp)
	return
}