// Bind wraps ctxvfs.NameSpace.Bind
544639
func (a *AtomicFS) Bind(old string, newfs ctxvfs.FileSystem, new string, mode ctxvfs.BindMode) {
	// We do copy-on-write
	a.mu.Lock()
	defer a.mu.Unlock()

	fs1 := a.v.Load().(ctxvfs.NameSpace)
	fs2 := make(ctxvfs.NameSpace)
	for k, v := range fs1 {
		fs2[k] = v
	}
	fs2.Bind(old, newfs, new, mode)
	a.v.Store(fs2)
}
1131762
func (s *RemoteApplication) Bindings() map[string]string {
	result := make(map[string]string)
	for epName, spName := range s.doc.Bindings {
		result[epName] = spName
	}
	return result
}
335629
func (ph Placeholders) Bind(name string, dst interface{}) error {
	v := ph.Value(name)
	if v == nil {
		return errors.New("Placeholder with name " + name + " not found")
	}

	return ConvertValue(v, dst)
}
56037
func (e *endpoint) Bind(addr tcpip.FullAddress) (err *tcpip.Error) {
	e.mu.Lock()
	defer e.mu.Unlock()

	// Don't allow binding once endpoint is not in the initial state
	// anymore. This is because once the endpoint goes into a connected or
	// listen state, it is already bound.
	if e.state != stateInitial {
		return tcpip.ErrAlreadyBound
	}

	e.bindAddress = addr.Addr
	netProto, err := e.checkV4Mapped(&addr)
	if err != nil {
		return err
	}

	// Expand netProtos to include v4 and v6 if the caller is binding to a
	// wildcard (empty) address, and this is an IPv6 endpoint with v6only
	// set to false.
	netProtos := []tcpip.NetworkProtocolNumber{netProto}
	if netProto == header.IPv6ProtocolNumber && !e.v6only && addr.Addr == "" {
		netProtos = []tcpip.NetworkProtocolNumber{
			header.IPv6ProtocolNumber,
			header.IPv4ProtocolNumber,
		}
	}

	port, err := e.stack.ReservePort(netProtos, ProtocolNumber, addr.Addr, addr.Port, e.reusePort)
	if err != nil {
		return err
	}

	e.isPortReserved = true
	e.effectiveNetProtos = netProtos
	e.id.LocalPort = port

	// Any failures beyond this point must remove the port registration.
	defer func() {
		if err != nil {
			e.stack.ReleasePort(netProtos, ProtocolNumber, addr.Addr, port)
			e.isPortReserved = false
			e.effectiveNetProtos = nil
			e.id.LocalPort = 0
			e.id.LocalAddress = ""
			e.boundNICID = 0
		}
	}()

	// If an address is specified, we must ensure that it's one of our
	// local addresses.
	if len(addr.Addr) != 0 {
		nic := e.stack.CheckLocalAddress(addr.NIC, netProto, addr.Addr)
		if nic == 0 {
			return tcpip.ErrBadLocalAddress
		}

		e.boundNICID = nic
		e.id.LocalAddress = addr.Addr
	}

	// Mark endpoint as bound.
	e.state = stateBound

	return nil
}
303471
func Bind(val interface{}) HandlerFunc {
	value := reflect.ValueOf(val)
	if value.Kind() == reflect.Ptr {
		panic(`Bind struct can not be a pointer. Example:
	Use: gin.Bind(Struct{}) instead of gin.Bind(&Struct{})
`)
	}
	typ := value.Type()

	return func(c *Context) {
		obj := reflect.New(typ).Interface()
		if c.Bind(obj) == nil {
			c.Set(BindKey, obj)
		}
	}
}
1147541
func (t *BoolFlag) Bind(flagset *pflag.FlagSet, v *viper.Viper) (err error) {
	t.config(v)
	flagset.BoolP(t.Name, t.ShortHand, t.Default, t.Usage)
	return bindFlagSet(flagset, v, t.Name, t.EnvVar, t.Hidden, "bool")
}
821906
func (c *Tethering) Bind(port int) (*gcdmessage.ChromeResponse, error) {
	var v TetheringBindParams
	v.Port = port
	return c.BindWithParams(&v)
}
984389
func (r *Chain) Bind(rnx EventHandler) Chains {
	return r.Next(func(ev Event, nx EventHandler) {
		rnx(ev)
		nx(ev)
	})
}
214936
func (stmt *OCI8Stmt) bind(ctx context.Context, args []namedValue) ([]oci8Bind, error) {
	if len(args) == 0 {
		return nil, nil
	}

	var binds []oci8Bind
	var err error

	for i, arg := range args {
		var sbind oci8Bind
		sbind.length = (*C.ub2)(C.malloc(C.sizeof_ub2))
		*sbind.length = 0
		sbind.indicator = (*C.sb2)(C.malloc(C.sizeof_sb2))
		*sbind.indicator = 0

		argInterface := arg.Value
		var isOut bool
		var isNill bool
		sbind.out, isOut = argInterface.(sql.Out)
		if isOut {
			argInterface, err = driver.DefaultParameterConverter.ConvertValue(sbind.out.Dest)
			if err != nil {
				binds = append(binds, sbind)
				freeBinds(binds)
				return nil, err
			}
			switch argInterface.(type) {
			case nil:
				isNill = true
				argInterface = sbind.out.Dest
				switch argInterface.(type) {
				case *sql.NullBool:
					argInterface = false
				case *sql.NullFloat64:
					argInterface = float64(0)
				case *sql.NullInt64:
					argInterface = int64(0)
				case *sql.NullString:
					argInterface = ""
				}
			}
		}

		switch argValue := argInterface.(type) {

		case nil:
			sbind.dataType = C.SQLT_AFC
			sbind.pbuf = nil
			sbind.maxSize = 0
			*sbind.indicator = -1 // set to null

		case []byte:
			if isOut {

				sbind.dataType = C.SQLT_BIN
				sbind.pbuf = unsafe.Pointer(cByteN(argValue, 32768))
				sbind.maxSize = 32767
				if sbind.out.In && !isNill {
					*sbind.length = C.ub2(len(argValue))
				} else {
					*sbind.indicator = -1 // set to null
				}

			} else {
				sbind.dataType = C.SQLT_BIN
				sbind.pbuf = unsafe.Pointer(cByte(argValue))
				sbind.maxSize = C.sb4(len(argValue))
				*sbind.length = C.ub2(len(argValue))
			}

		case time.Time:
			sbind.dataType = C.SQLT_TIMESTAMP_TZ
			sbind.maxSize = C.sb4(sizeOfNilPointer)
			*sbind.length = C.ub2(sizeOfNilPointer)

			// TODO: wrap up date time construction into Go function

			var timestampP *unsafe.Pointer
			timestampP, _, err = stmt.conn.ociDescriptorAlloc(C.OCI_DTYPE_TIMESTAMP_TZ, 0)
			if err != nil {
				binds = append(binds, sbind)
				freeBinds(binds)
				return nil, err
			}
			pt := unsafe.Pointer(timestampP)

			zone, offset := argValue.Zone()
			size := len(zone)
			if size < 16 {
				size = 16
			}
			zoneText := cStringN(zone, size)
			defer C.free(unsafe.Pointer(zoneText))

			tryagain := false

			rv := C.OCIDateTimeConstruct(
				unsafe.Pointer(stmt.conn.env),
				stmt.conn.errHandle,
				(*C.OCIDateTime)(*(*unsafe.Pointer)(pt)),
				C.sb2(argValue.Year()),
				C.ub1(argValue.Month()),
				C.ub1(argValue.Day()),
				C.ub1(argValue.Hour()),
				C.ub1(argValue.Minute()),
				C.ub1(argValue.Second()),
				C.ub4(argValue.Nanosecond()),
				zoneText,
				C.size_t(len(zone)),
			)
			if rv != C.OCI_SUCCESS {
				tryagain = true
			} else {
				// check if oracle timezone offset is same ?
				rvz := C.WrapOCIDateTimeGetTimeZoneNameOffset(
					stmt.conn.env,
					stmt.conn.errHandle,
					(*C.OCIDateTime)(*(*unsafe.Pointer)(pt)))
				if rvz.rv != C.OCI_SUCCESS {
					binds = append(binds, sbind)
					freeBinds(binds)
					return nil, stmt.conn.getError(rvz.rv)
				}
				if offset != int(rvz.h)*60*60+int(rvz.m)*60 {
					// fmt.Println("oracle timezone offset dont match", zone, offset, int(rvz.h)*60*60+int(rvz.m)*60)
					tryagain = true
				}
			}

			if tryagain {
				sign := '+'
				if offset < 0 {
					offset = -offset
					sign = '-'
				}
				offset /= 60
				// oracle accept zones "[+-]hh:mm", try second time
				zone = fmt.Sprintf("%c%02d:%02d", sign, offset/60, offset%60)
				if size < len(zone) {
					size = len(zone)
					zoneText = cStringN(zone, size)
					defer C.free(unsafe.Pointer(zoneText))
				} else {
					copy((*[1 << 30]byte)(unsafe.Pointer(zoneText))[:len(zone)], zone)
				}

				rv := C.OCIDateTimeConstruct(
					unsafe.Pointer(stmt.conn.env),
					stmt.conn.errHandle,
					(*C.OCIDateTime)(*(*unsafe.Pointer)(pt)),
					C.sb2(argValue.Year()),
					C.ub1(argValue.Month()),
					C.ub1(argValue.Day()),
					C.ub1(argValue.Hour()),
					C.ub1(argValue.Minute()),
					C.ub1(argValue.Second()),
					C.ub4(argValue.Nanosecond()),
					zoneText,
					C.size_t(len(zone)),
				)
				if rv != C.OCI_SUCCESS {
					binds = append(binds, sbind)
					freeBinds(binds)
					return nil, stmt.conn.getError(rv)
				}
			}

			sbind.pbuf = unsafe.Pointer((*C.char)(pt))

		case string:
			if isOut {

				sbind.dataType = C.SQLT_CHR
				sbind.pbuf = unsafe.Pointer(cStringN(argValue, 32768))
				sbind.maxSize = 32767
				if sbind.out.In && !isNill {
					*sbind.length = C.ub2(len(argValue))
				} else {
					*sbind.indicator = -1 // set to null
				}

			} else {
				sbind.dataType = C.SQLT_AFC
				sbind.pbuf = unsafe.Pointer(C.CString(argValue))
				sbind.maxSize = C.sb4(len(argValue))
				*sbind.length = C.ub2(len(argValue))
			}

		case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr:
			buffer := bytes.Buffer{}
			err = binary.Write(&buffer, binary.LittleEndian, argValue)
			if err != nil {
				return nil, fmt.Errorf("binary read for column %v - error: %v", i, err)
			}
			sbind.dataType = C.SQLT_INT
			sbind.pbuf = unsafe.Pointer(cByte(buffer.Bytes()))
			sbind.maxSize = C.sb4(buffer.Len())
			*sbind.length = C.ub2(buffer.Len())
			if isOut && sbind.out.In && isNill {
				*sbind.indicator = -1 // set to null
			}

		case float32, float64:
			buffer := bytes.Buffer{}
			err = binary.Write(&buffer, binary.LittleEndian, argValue)
			if err != nil {
				return nil, fmt.Errorf("binary read for column %v - error: %v", i, err)
			}
			sbind.dataType = C.SQLT_BDOUBLE
			sbind.pbuf = unsafe.Pointer(cByte(buffer.Bytes()))
			sbind.maxSize = C.sb4(buffer.Len())
			*sbind.length = C.ub2(buffer.Len())
			if isOut && sbind.out.In && isNill {
				*sbind.indicator = -1 // set to null
			}

		case bool: // oracle does not have bool, handle as 0/1 int
			sbind.dataType = C.SQLT_INT
			if argValue {
				sbind.pbuf = unsafe.Pointer(cByte([]byte{1}))
			} else {
				sbind.pbuf = unsafe.Pointer(cByte([]byte{0}))
			}
			sbind.maxSize = 1
			*sbind.length = 1
			if isOut && sbind.out.In && isNill {
				*sbind.indicator = -1 // set to null
			}

		default:
			if isOut {
				// TODO: should this error instead of setting to null?
				sbind.dataType = C.SQLT_AFC
				sbind.pbuf = nil
				sbind.maxSize = 0
				*sbind.length = 0
				*sbind.indicator = -1 // set to null
			} else {
				d := fmt.Sprintf("%v", argValue)
				sbind.dataType = C.SQLT_AFC
				sbind.pbuf = unsafe.Pointer(C.CString(d))
				sbind.maxSize = C.sb4(len(d))
				*sbind.length = C.ub2(len(d))
			}
		}

		// add to binds now so if error will be freed by freeBinds call
		binds = append(binds, sbind)

		if arg.Name != "" {
			err = stmt.ociBindByName([]byte(":"+arg.Name), &sbind)
		} else {
			err = stmt.ociBindByPos(C.ub4(i+1), &sbind)
		}
		if err != nil {
			freeBinds(binds)
			return nil, err
		}

	}

	return binds, nil
}
565207
func bindMap(bindType int, query string, args map[string]interface{}) (string, []interface{}, error) {
	bound, names, err := compileNamedQuery([]byte(query), bindType)
	if err != nil {
		return "", []interface{}{}, err
	}

	arglist, err := bindMapArgs(names, args)
	return bound, arglist, err
}
997092
func bind(c Conn, p pdu.Body) (pdu.Body, error) {
	f := p.Fields()
	f.Set(pdufield.InterfaceVersion, 0x34)
	err := c.Write(p)
	if err != nil {
		return nil, err
	}
	resp, err := c.Read()
	if err != nil {
		return nil, err
	}
	h := resp.Header()
	if h.Status != 0 {
		return nil, h.Status
	}
	return resp, nil
}
561268
func (c *Context) BindFramebuffer(target int, framebuffer *js.Object) {
	c.Call("bindFramebuffer", target, framebuffer)
}
522426
func (c *Container) Bind(fn interface{}) {
	w := newServiceWrapper(fn, false, c.serviceConstructorArgs)
	c.registered = append(c.registered, w)
}
459656
func parseBind(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
	if flags.Changed("bind") {
		binds, err := flags.GetStringSlice("bind")
		if err != nil {
			return err
		}

		container := spec.Task.GetContainer()

		for _, bind := range binds {
			parts := strings.SplitN(bind, ":", 2)
			if len(parts) != 2 {
				return fmt.Errorf("bind format %q not supported", bind)
			}
			container.Mounts = append(container.Mounts, api.Mount{
				Type:   api.MountTypeBind,
				Source: parts[0],
				Target: parts[1],
			})
		}
	}

	return nil
}
511281
func (e *endpoint) Bind(addr tcpip.FullAddress) *tcpip.Error {
	e.mu.Lock()
	defer e.mu.Unlock()

	err := e.bindLocked(addr)
	if err != nil {
		return err
	}

	// Save the effective NICID generated by bindLocked.
	e.bindNICID = e.regNICID

	return nil
}
287713
func (s *Session) Bind(ctx context.Context, uid string) error {
	if uid == "" {
		return constants.ErrIllegalUID
	}

	if s.UID() != "" {
		return constants.ErrSessionAlreadyBound
	}

	s.uid = uid
	for _, cb := range sessionBindCallbacks {
		err := cb(ctx, s)
		if err != nil {
			s.uid = ""
			return err
		}
	}

	for _, cb := range afterBindCallbacks {
		err := cb(ctx, s)
		if err != nil {
			s.uid = ""
			return err
		}
	}

	// if code running on frontend server
	if s.IsFrontend {
		sessionsByUID.Store(uid, s)
	} else {
		// If frontentID is set this means it is a remote call and the current server
		// is not the frontend server that received the user request
		err := s.bindInFront(ctx)
		if err != nil {
			logger.Log.Error("error while trying to push session to front: ", err)
			s.uid = ""
			return err
		}
	}
	return nil
}
147211
func (c *Context) BindQuery(obj interface{}) error {
	return c.MustBindWith(obj, binding.Query)
}