// PeripheralDiscovered returns a Handler, which sets the specified function to be called when a remote peripheral device is found during scan procedure.
542638
func PeripheralDiscovered(f func(Peripheral, *Advertisement, int)) Handler {
	return func(d Device) { d.(*device).peripheralDiscovered = f }
}
1013101
func findSELinuxfsMount(s *bufio.Scanner) string {
	for s.Scan() {
		txt := s.Text()
		// The first field after - is fs type.
		// Safe as spaces in mountpoints are encoded as \040
		if !strings.Contains(txt, " - selinuxfs ") {
			continue
		}
		const mPos = 5 // mount point is 5th field
		fields := strings.SplitN(txt, " ", mPos+1)
		if len(fields) < mPos+1 {
			continue
		}
		return fields[mPos-1]
	}

	return ""
}
40749
func (l *Scanner) SkipEscaped(c byte) {
	if l.err {
		return
	}
	// Reset scanner state.
	l.resetItem()

	if i := ScanUntil(l.data[l.pos:], c); i == -1 {
		// Reached the end of data.
		l.pos = len(l.data)
	} else {
		l.pos += i + 1
	}
}
1141910
func (fr *FileReport) IsCovered(row int) bool {
	if fr == nil {
		return false
	}
	for _, r := range fr.Covered {
		if r.In(row) {
			return true
		}
	}
	return false
}
641974
func (r Report) IsCovered(file string, row int) bool {
	return r.Files[file].IsCovered(row)
}
823484
func (r Hardware_Router) GetHardwareFunction() (resp datatypes.Hardware_Function, err error) {
	err = r.Session.DoRequest("SoftLayer_Hardware_Router", "getHardwareFunction", nil, &r.Options, &resp)
	return
}
858871
func TCPRedirectHandler(opts ...HandlerOption) Handler {
	h := &tcpRedirectHandler{}
	h.Init(opts...)

	return h
}
197800
func (h *handler) fetchScanFunc(br blob.Ref, searchFunc func(blob.Ref) (*search.SearchResult, error)) (mediaObject, error) {
	var mo mediaObject
	res, err := searchFunc(br)
	if err != nil {
		return mo, err
	}
	if len(res.Blobs) != 1 {
		return mo, os.ErrNotExist
	}
	if res.Describe == nil || len(res.Describe.Meta) == 0 {
		return mo, errors.New("scan permanode was not described")
	}
	for _, des := range res.Describe.Meta {
		if des.Permanode == nil {
			continue
		}
		scan, err := h.describeScan(des)
		if err != nil {
			return mo, fmt.Errorf("error describing scan %v: %v", des.BlobRef, err)
		}
		return scan, nil
	}
	return mo, os.ErrNotExist
}
81010
func (d *Interfaces) detectVIP(interfaces []string) {

	var keyConfCluster pfconfigdriver.NetInterface
	keyConfCluster.PfconfigNS = "config::Pf(CLUSTER," + pfconfigdriver.FindClusterName(ctx) + ")"

	for _, v := range interfaces {
		keyConfCluster.PfconfigHashNS = "interface " + v
		pfconfigdriver.FetchDecodeSocket(ctx, &keyConfCluster)
		// Nothing in keyConfCluster.Ip so we are not in cluster mode
		if keyConfCluster.Ip == "" {
			VIP[v] = true
			continue
		}

		if _, found := VIP[v]; !found {
			VIP[v] = false
		}

		eth, _ := net.InterfaceByName(v)
		adresses, _ := eth.Addrs()
		var found bool
		found = false
		for _, adresse := range adresses {
			IP, _, _ := net.ParseCIDR(adresse.String())
			VIPIp[v] = net.ParseIP(keyConfCluster.Ip)
			if IP.Equal(VIPIp[v]) {
				found = true
				if VIP[v] == false {
					log.LoggerWContext(ctx).Info(v + " got the VIP")
					if h, ok := intNametoInterface[v]; ok {
						go h.handleApiReq(ApiReq{Req: "initialease", NetInterface: v, NetWork: ""})
					}
					VIP[v] = true
				}
			}
		}
		if found == false {
			VIP[v] = false
		}
	}
}
960621
func valueDescriptorByDeviceIdHandler(w http.ResponseWriter, r *http.Request) {
	defer r.Body.Close()

	vars := mux.Vars(r)

	deviceId, err := url.QueryUnescape(vars["id"])
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		LoggingClient.Error("Error unescaping the device ID: " + err.Error())
		return
	}

	ctx := r.Context()
	// Get the value descriptors
	vdList, err := getValueDescriptorsByDeviceId(deviceId, ctx)
	if err != nil {
		switch err := err.(type) {
		case *types.ErrServiceClient:
			http.Error(w, err.Error(), err.StatusCode)
		case *errors.ErrDbNotFound:
			http.Error(w, err.Error(), http.StatusNotFound)
			return
		default:
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	}

	encode(vdList, w)
}
404428
func (sl *HealthCheckStatusListener) HealthCheckRecovered(entry *health.State, recordedFailures int64, failureDurationSeconds float64) {
	svcLogger.Printf("Recovering from %d contiguous errors, lasting %1.2f seconds: %+v", recordedFailures, failureDurationSeconds, entry)
}
962324
func (h *Handle) Unselected() uint64 {
	h.Lock()
	defer h.Unlock()
	return h.unselected
}
964875
func (s *GitScanner) ScanLeftToRemote(left string, cb GitScannerFoundPointer) error {
	callback, err := firstGitScannerCallback(cb, s.FoundPointer)
	if err != nil {
		return err
	}

	s.mu.Lock()
	if len(s.remote) == 0 {
		s.mu.Unlock()
		return fmt.Errorf("Unable to scan starting at %q: no remote set.", left)
	}
	s.mu.Unlock()

	return scanLeftRightToChan(s, callback, left, "", s.opts(ScanLeftToRemoteMode))
}
1205416
func (k *KeybaseDaemonRPC) OnDisconnected(ctx context.Context,
	status rpc.DisconnectStatus) {
	if status == rpc.StartingNonFirstConnection {
		k.log.Warning("KeybaseDaemonRPC is disconnected")
	}

	k.ClearCaches(ctx)

	k.lock.Lock()
	defer k.lock.Unlock()
	k.server = nil
}
381314
func (r Hardware_Router) GetMetricTrackingObject() (resp datatypes.Metric_Tracking_Object_HardwareServer, err error) {
	err = r.Session.DoRequest("SoftLayer_Hardware_Router", "getMetricTrackingObject", nil, &r.Options, &resp)
	return
}
727414
func (fr *FileReport) IsNotCovered(row int) bool {
	if fr == nil {
		return false
	}
	for _, r := range fr.NotCovered {
		if r.In(row) {
			return true
		}
	}
	return false
}
667663
func BidiCopy(out net.Conn, in net.Conn, bufOut []byte, bufIn []byte) (outErr error, inErr error) {
	stop := uint32(0)
	outErrCh := make(chan error, 1)
	inErrCh := make(chan error, 1)
	go doCopy(out, in, bufIn, outErrCh, &stop)
	go doCopy(in, out, bufOut, inErrCh, &stop)
	return <-outErrCh, <-inErrCh
}