// NewBindTransceiver creates a new Bind PDU.
9476
func NewBindTransceiver() Body {
	b := newBind(&Header{ID: BindTransceiverID})
	b.init()
	return b
}
603119
func (h *netlinkHandle) EnsureAddressBind(address, devName string) (exist bool, err error) {
	dev, err := h.LinkByName(devName)
	if err != nil {
		return false, fmt.Errorf("error get interface: %s, err: %v", devName, err)
	}
	addr := net.ParseIP(address)
	if addr == nil {
		return false, fmt.Errorf("error parse ip address: %s", address)
	}
	if err := h.AddrAdd(dev, &netlink.Addr{IPNet: netlink.NewIPNet(addr)}); err != nil {
		// "EEXIST" will be returned if the address is already bound to device
		if err == unix.EEXIST {
			return true, nil
		}
		return false, fmt.Errorf("error bind address: %s to interface: %s, err: %v", address, devName, err)
	}
	return false, nil
}
1069742
func (ns *NatsRPCClient) BroadcastSessionBind(uid string) error {
	msg := &protos.BindMsg{
		Uid: uid,
		Fid: ns.server.ID,
	}
	msgData, err := proto.Marshal(msg)
	if err != nil {
		return err
	}
	return ns.Send(GetBindBroadcastTopic(ns.server.Type), msgData)
}
500046
func (h *BindHandle) DropBindRecord(record *BindRecord) (err error) {
	exec, _ := h.sctx.Context.(sqlexec.SQLExecutor)
	h.sctx.Lock()

	_, err = exec.Execute(context.TODO(), "BEGIN")
	if err != nil {
		h.sctx.Unlock()
		return
	}

	defer func() {
		if err != nil {
			_, err1 := exec.Execute(context.TODO(), "ROLLBACK")
			h.sctx.Unlock()
			terror.Log(err1)
			return
		}

		_, err = exec.Execute(context.TODO(), "COMMIT")
		h.sctx.Unlock()
		if err != nil {
			return
		}

		hash, meta := newBindMetaWithoutAst(record)
		h.removeBindMeta(hash, meta)
	}()

	txn, err1 := h.sctx.Context.Txn(true)
	if err1 != nil {
		return err1
	}

	updateTs := types.Time{
		Time: types.FromGoTime(oracle.GetTimeFromTS(txn.StartTS())),
		Type: mysql.TypeDatetime,
		Fsp:  3,
	}
	record.Status = deleted
	record.UpdateTime = updateTs

	_, err = exec.Execute(context.TODO(), h.logicalDeleteBindInfoSQL(record.OriginalSQL, record.Db, updateTs))
	return err
}
1309028
func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
	req := c.Request()
	if req.ContentLength == 0 {
		if req.Method == http.MethodGet || req.Method == http.MethodDelete {
			if err = b.bindData(i, c.QueryParams(), "query"); err != nil {
				return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
			}
			return
		}
		return NewHTTPError(http.StatusBadRequest, "Request body can't be empty")
	}
	ctype := req.Header.Get(HeaderContentType)
	switch {
	case strings.HasPrefix(ctype, MIMEApplicationJSON):
		if err = json.NewDecoder(req.Body).Decode(i); err != nil {
			if ute, ok := err.(*json.UnmarshalTypeError); ok {
				return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unmarshal type error: expected=%v, got=%v, field=%v, offset=%v", ute.Type, ute.Value, ute.Field, ute.Offset)).SetInternal(err)
			} else if se, ok := err.(*json.SyntaxError); ok {
				return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: offset=%v, error=%v", se.Offset, se.Error())).SetInternal(err)
			}
			return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
		}
	case strings.HasPrefix(ctype, MIMEApplicationXML), strings.HasPrefix(ctype, MIMETextXML):
		if err = xml.NewDecoder(req.Body).Decode(i); err != nil {
			if ute, ok := err.(*xml.UnsupportedTypeError); ok {
				return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unsupported type error: type=%v, error=%v", ute.Type, ute.Error())).SetInternal(err)
			} else if se, ok := err.(*xml.SyntaxError); ok {
				return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: line=%v, error=%v", se.Line, se.Error())).SetInternal(err)
			}
			return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
		}
	case strings.HasPrefix(ctype, MIMEApplicationForm), strings.HasPrefix(ctype, MIMEMultipartForm):
		params, err := c.FormParams()
		if err != nil {
			return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
		}
		if err = b.bindData(i, params, "form"); err != nil {
			return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
		}
	default:
		return ErrUnsupportedMediaType
	}
	return
}
720597
func ConvertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, error) {
	var pbs []json.RawMessage

	// Enumerate through the port bindings specified by the user and convert
	// them into the internal structure matching the JSON blob that can be
	// understood by the HCS.
	for _, elem := range portBindings {
		proto := strings.ToUpper(elem.Proto.String())
		if proto != "TCP" && proto != "UDP" {
			return nil, fmt.Errorf("invalid protocol %s", elem.Proto.String())
		}

		if elem.HostPort != elem.HostPortEnd {
			return nil, fmt.Errorf("Windows does not support more than one host port in NAT settings")
		}

		if len(elem.HostIP) != 0 {
			return nil, fmt.Errorf("Windows does not support host IP addresses in NAT settings")
		}

		encodedPolicy, err := json.Marshal(hcsshim.NatPolicy{
			Type:         "NAT",
			ExternalPort: elem.HostPort,
			InternalPort: elem.Port,
			Protocol:     elem.Proto.String(),
		})

		if err != nil {
			return nil, err
		}
		pbs = append(pbs, encodedPolicy)
	}
	return pbs, nil
}
1069707
func (stmt *OCI8Stmt) ociBindByName(name []byte, bind *oci8Bind) error {
	result := C.OCIBindByName(
		stmt.stmt,                      // The statement handle
		&bind.bindHandle,               // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deallocated.
		stmt.conn.errHandle,            // An error handle
		(*C.OraText)(&name[0]),         // The placeholder, specified by its name, that maps to a variable in the statement associated with the statement handle.
		C.sb4(len(name)),               // The length of the name specified in placeholder, in number of bytes regardless of the encoding.
		bind.pbuf,                      // The pointer to a data value or an array of data values of type specified in the dty parameter
		bind.maxSize,                   // The maximum size possible in bytes of any data value for this bind variable
		bind.dataType,                  // The data type of the values being bound
		unsafe.Pointer(bind.indicator), // Pointer to an indicator variable or array
		bind.length,                    // lengths are in bytes in general
		nil,                            // Pointer to the array of column-level return codes
		0,                              // A maximum array length parameter
		nil,                            // Current array length parameter
		C.OCI_DEFAULT,                  // The mode. Recommended to set to OCI_DEFAULT, which makes the bind variable have the same encoding as its statement.
	)

	return stmt.conn.getError(result)
}
536339
func (f FlagInfo) BindTransformingStringFlag(flags *pflag.FlagSet, target *string, transformer func(string) (string, error)) FlagInfo {
	// you can't register a flag without a long name
	if len(f.LongName) > 0 {
		flags.VarP(newTransformingStringValue(f.Default, target, transformer), f.LongName, f.ShortName, f.Description)
	}
	return f
}
1160815
func NewBindTransmitterResp() Body {
	b := newBindResp(&Header{ID: BindTransmitterRespID})
	b.init()
	return b
}
1101264
func newBytesBinParser(b []byte) *binParser {
	p := &binParser{bufio.NewReader(bytes.NewReader(b)), 0, 0}
	if p.r == nil {
		return nil
	}
	return p
}
1363267
func normalizeBind(addr, bind string) (string, error) {
	if addr == "" {
		return bind, nil
	}
	return parseSingleIPTemplate(addr)
}
117866
func NewNetTransport(config *NetTransportConfig) (*NetTransport, error) {
	// If we reject the empty list outright we can assume that there's at
	// least one listener of each type later during operation.
	if len(config.BindAddrs) == 0 {
		return nil, fmt.Errorf("At least one bind address is required")
	}

	// Build out the new transport.
	var ok bool
	t := NetTransport{
		config:   config,
		packetCh: make(chan *Packet),
		streamCh: make(chan net.Conn),
		logger:   config.Logger,
	}

	// Clean up listeners if there's an error.
	defer func() {
		if !ok {
			t.Shutdown()
		}
	}()

	// Build all the TCP and UDP listeners.
	port := config.BindPort
	for _, addr := range config.BindAddrs {
		ip := net.ParseIP(addr)

		tcpAddr := &net.TCPAddr{IP: ip, Port: port}
		tcpLn, err := net.ListenTCP("tcp", tcpAddr)
		if err != nil {
			return nil, fmt.Errorf("Failed to start TCP listener on %q port %d: %v", addr, port, err)
		}
		t.tcpListeners = append(t.tcpListeners, tcpLn)

		// If the config port given was zero, use the first TCP listener
		// to pick an available port and then apply that to everything
		// else.
		if port == 0 {
			port = tcpLn.Addr().(*net.TCPAddr).Port
		}

		udpAddr := &net.UDPAddr{IP: ip, Port: port}
		udpLn, err := net.ListenUDP("udp", udpAddr)
		if err != nil {
			return nil, fmt.Errorf("Failed to start UDP listener on %q port %d: %v", addr, port, err)
		}
		if err := setUDPRecvBuf(udpLn); err != nil {
			return nil, fmt.Errorf("Failed to resize UDP buffer: %v", err)
		}
		t.udpListeners = append(t.udpListeners, udpLn)
	}

	// Fire them up now that we've been able to create them all.
	for i := 0; i < len(config.BindAddrs); i++ {
		t.wg.Add(2)
		go t.tcpListen(t.tcpListeners[i])
		go t.udpListen(t.udpListeners[i])
	}

	ok = true
	return &t, nil
}
899605
func NewBindReceiver() Body {
	b := newBind(&Header{ID: BindReceiverID})
	b.init()
	return b
}
201043
func (stmt *OCI8Stmt) outputBoundParameters(binds []oci8Bind) error {
	var err error

	for i, bind := range binds {
		if bind.pbuf != nil {
			switch dest := bind.out.Dest.(type) {
			case *string:
				switch {
				case *bind.indicator > 0: // indicator variable is the actual length before truncation
					spaces := int(*bind.indicator) - int(*bind.length)
					if spaces < 0 {
						return fmt.Errorf("spaces less than 0 for column %v", i)
					}
					*dest = C.GoStringN((*C.char)(bind.pbuf), C.int(*bind.length)) + strings.Repeat(" ", spaces)
				case *bind.indicator == 0: // Normal
					*dest = C.GoStringN((*C.char)(bind.pbuf), C.int(*bind.length))
				case *bind.indicator == -1: // The selected value is null
					*dest = "" // best attempt at Go nil string
				case *bind.indicator == -2: // Item is greater than the length of the output variable; the item has been truncated.
					*dest = C.GoStringN((*C.char)(bind.pbuf), C.int(*bind.length))
					// TODO: should this be an error?
				default:
					return fmt.Errorf("unknown column indicator %d for column %v", *bind.indicator, i)
				}
			case *sql.NullString:
				switch {
				case *bind.indicator > 0: // indicator variable is the actual length before truncation
					spaces := int(*bind.indicator) - int(*bind.length)
					if spaces < 0 {
						return fmt.Errorf("spaces less than 0 for column %v", i)
					}
					dest.String = C.GoStringN((*C.char)(bind.pbuf), C.int(*bind.length)) + strings.Repeat(" ", spaces)
					dest.Valid = true
				case *bind.indicator == 0: // Normal
					dest.String = C.GoStringN((*C.char)(bind.pbuf), C.int(*bind.length))
					dest.Valid = true
				case *bind.indicator == -1: // The selected value is null
					dest.String = ""
					dest.Valid = false
				case *bind.indicator == -2: // Item is greater than the length of the output variable; the item has been truncated.
					dest.String = C.GoStringN((*C.char)(bind.pbuf), C.int(*bind.length))
					dest.Valid = true
					// TODO: should this be an error?
				default:
					return fmt.Errorf("unknown column indicator %d for column %v", *bind.indicator, i)
				}

			case *int:
				*dest = int(getInt64(bind.pbuf))
			case *int64:
				*dest = getInt64(bind.pbuf)
			case *int32:
				*dest = int32(getInt64(bind.pbuf))
			case *int16:
				*dest = int16(getInt64(bind.pbuf))
			case *int8:
				*dest = int8(getInt64(bind.pbuf))
			case *sql.NullInt64:
				if *bind.indicator == -1 {
					dest.Int64 = 0
					dest.Valid = false
				} else {
					dest.Int64 = getInt64(bind.pbuf)
					dest.Valid = true
				}

			case *uint:
				*dest = uint(getUint64(bind.pbuf))
			case *uint64:
				*dest = getUint64(bind.pbuf)
			case *uint32:
				*dest = uint32(getUint64(bind.pbuf))
			case *uint16:
				*dest = uint16(getUint64(bind.pbuf))
			case *uint8:
				*dest = uint8(getUint64(bind.pbuf))
			case *uintptr:
				*dest = uintptr(getUint64(bind.pbuf))

			case *float64:
				buf := (*[8]byte)(bind.pbuf)[0:8]
				var data float64
				err = binary.Read(bytes.NewReader(buf), binary.LittleEndian, &data)
				if err != nil {
					return fmt.Errorf("binary read for column %v - error: %v", i, err)
				}
				*dest = data
			case *float32:
				// statement is using SQLT_BDOUBLE to bind
				// need to read as float64 because of the 8 bits
				buf := (*[8]byte)(bind.pbuf)[0:8]
				var data float64
				err = binary.Read(bytes.NewReader(buf), binary.LittleEndian, &data)
				if err != nil {
					return fmt.Errorf("binary read for column %v - error: %v", i, err)
				}
				*dest = float32(data)
			case *sql.NullFloat64:
				if *bind.indicator == -1 {
					dest.Float64 = 0
					dest.Valid = false
				} else {
					buf := (*[8]byte)(bind.pbuf)[0:8]
					var data float64
					err = binary.Read(bytes.NewReader(buf), binary.LittleEndian, &data)
					if err != nil {
						return fmt.Errorf("binary read for column %v - error: %v", i, err)
					}
					dest.Float64 = data
					dest.Valid = true
				}

			case *bool:
				buf := (*[1 << 30]byte)(bind.pbuf)[0:1]
				*dest = buf[0] != 0
			case *sql.NullBool:
				if *bind.indicator == -1 {
					dest.Bool = false
					dest.Valid = false
				} else {
					buf := (*[1 << 30]byte)(bind.pbuf)[0:1]
					dest.Bool = buf[0] != 0
					dest.Valid = true
				}

			case *[]byte:
				switch {
				case *bind.indicator > 0: // indicator variable is the actual length before truncation
					if int(*bind.indicator)-int(*bind.length) < 0 {
						return fmt.Errorf("spaces less than 0 for column %v", i)
					}
					*dest = C.GoBytes(bind.pbuf, C.int(*bind.indicator))
				case *bind.indicator == 0: // Normal
					*dest = C.GoBytes(bind.pbuf, C.int(*bind.length))
				case *bind.indicator == -1: // The selected value is null
					*dest = nil
				case *bind.indicator == -2: // Item is greater than the length of the output variable; the item has been truncated.
					*dest = C.GoBytes(bind.pbuf, C.int(*bind.length))
					// TODO: should this be an error?
				default:
					return fmt.Errorf("unknown column indicator %d for column %v", *bind.indicator, i)
				}
			}

		}
	}

	return nil
}
10985
func getBinderFunc(client clientset.Interface, extenders []algorithm.SchedulerExtender) func(pod *v1.Pod) Binder {
	var extenderBinder algorithm.SchedulerExtender
	for i := range extenders {
		if extenders[i].IsBinder() {
			extenderBinder = extenders[i]
			break
		}
	}
	defaultBinder := &binder{client}
	return func(pod *v1.Pod) Binder {
		if extenderBinder != nil && extenderBinder.IsInterested(pod) {
			return extenderBinder
		}
		return defaultBinder
	}
}
1209469
func (o *untypedRequestBinder) Bind(request *http.Request, routeParams RouteParams, consumer runtime.Consumer, data interface{}) error {
	val := reflect.Indirect(reflect.ValueOf(data))
	isMap := val.Kind() == reflect.Map
	var result []error
	debugLog("binding %d parameters for %s %s", len(o.Parameters), request.Method, request.URL.EscapedPath())
	for fieldName, param := range o.Parameters {
		binder := o.paramBinders[fieldName]
		debugLog("binding parameter %s for %s %s", fieldName, request.Method, request.URL.EscapedPath())
		var target reflect.Value
		if !isMap {
			binder.Name = fieldName
			target = val.FieldByName(fieldName)
		}

		if isMap {
			tpe := binder.Type()
			if tpe == nil {
				if param.Schema.Type.Contains("array") {
					tpe = reflect.TypeOf([]interface{}{})
				} else {
					tpe = reflect.TypeOf(map[string]interface{}{})
				}
			}
			target = reflect.Indirect(reflect.New(tpe))

		}

		if !target.IsValid() {
			result = append(result, errors.New(500, "parameter name %q is an unknown field", binder.Name))
			continue
		}

		if err := binder.Bind(request, routeParams, consumer, target); err != nil {
			result = append(result, err)
			continue
		}

		if binder.validator != nil {
			rr := binder.validator.Validate(target.Interface())
			if rr != nil && rr.HasErrors() {
				result = append(result, rr.AsError())
			}
		}

		if isMap {
			val.SetMapIndex(reflect.ValueOf(param.Name), target)
		}
	}

	if len(result) > 0 {
		return errors.CompositeValidationError(result...)
	}

	return nil
}
559861
func BindImporter(opts SassOptions, resolver ImportResolver) int {

	idx := globalImports.Set(resolver)
	ptr := unsafe.Pointer(uintptr(idx))

	imper := C.sass_make_importer(
		C.Sass_Importer_Fn(C.SassImporterHandler),
		C.double(0),
		ptr,
	)
	impers := C.sass_make_importer_list(1)
	C.sass_importer_set_list_entry(impers, 0, imper)

	C.sass_option_set_c_importers(
		(*C.struct_Sass_Options)(unsafe.Pointer(opts)),
		impers,
	)
	return idx
}