// CheckTty checks if we are trying to attach to a container tty
// from a non-tty client input stream, and if so, returns an error.
320712
func (i *In) CheckTty(attachStdin, ttyMode bool) error {
	// In order to attach to a container tty, input stream for the client must
	// be a tty itself: redirecting or piping the client standard input is
	// incompatible with `docker run -t`, `docker exec -t` or `docker attach`.
	if ttyMode && attachStdin && !i.isTerminal {
		eText := "the input device is not a TTY"
		if runtime.GOOS == "windows" {
			return errors.New(eText + ".  If you are using mintty, try prefixing the command with 'winpty'")
		}
		return errors.New(eText)
	}
	return nil
}
967125
func checkConsole(f *os.File) error {
	var termios unix.Termios
	if tcget(f.Fd(), &termios) != nil {
		return ErrNotAConsole
	}
	return nil
}
1219978
func (r *RPCWrapper) CheckValidity(req *Request, secret string) bool {

	digest := hmac.New(sha256.New, []byte(secret))

	hash, err := payloadHash(req.Payload)
	if err != nil {
		return false
	}

	if _, err := digest.Write(hash); err != nil {
		return false
	}

	return hmac.Equal(req.HashAuth, digest.Sum(nil))
}
836186
func checkValid(data []byte, scan *Scanner) error {
	scan.Reset()
	for _, c := range data {
		scan.bytes++
		if scan.Step(scan, int(c)) == ScanError {
			return scan.Err
		}
	}
	if scan.EOF() == ScanError {
		return scan.Err
	}
	return nil
}
880008
func checkWallet(client *sshClient, network string) (*walletInfos, error) {
	// Inspect a possible web wallet container on the host
	infos, err := inspectContainer(client, fmt.Sprintf("%s_wallet_1", network))
	if err != nil {
		return nil, err
	}
	if !infos.running {
		return nil, ErrServiceOffline
	}
	// Resolve the port from the host, or the reverse proxy
	webPort := infos.portmap["80/tcp"]
	if webPort == 0 {
		if proxy, _ := checkNginx(client, network); proxy != nil {
			webPort = proxy.port
		}
	}
	if webPort == 0 {
		return nil, ErrNotExposed
	}
	// Resolve the host from the reverse-proxy and the config values
	host := infos.envvars["VIRTUAL_HOST"]
	if host == "" {
		host = client.server
	}
	// Run a sanity check to see if the devp2p and RPC ports are reachable
	nodePort := infos.portmap[infos.envvars["NODE_PORT"]]
	if err = checkPort(client.server, nodePort); err != nil {
		log.Warn(fmt.Sprintf("Wallet devp2p port seems unreachable"), "server", client.server, "port", nodePort, "err", err)
	}
	rpcPort := infos.portmap["8545/tcp"]
	if err = checkPort(client.server, rpcPort); err != nil {
		log.Warn(fmt.Sprintf("Wallet RPC port seems unreachable"), "server", client.server, "port", rpcPort, "err", err)
	}
	// Assemble and return the useful infos
	stats := &walletInfos{
		datadir:  infos.volumes["/root/.ethereum"],
		nodePort: nodePort,
		rpcPort:  rpcPort,
		webHost:  host,
		webPort:  webPort,
		ethstats: infos.envvars["STATS"],
	}
	return stats, nil
}
881753
func (b *BigIP) checkError(resp []byte) error {
	if len(resp) == 0 {
		return nil
	}

	var reqError RequestError

	err := json.Unmarshal(resp, &reqError)
	if err != nil {
		return errors.New(fmt.Sprintf("%s\n%s", err.Error(), string(resp[:])))
	}

	err = reqError.Error()
	if err != nil {
		return err
	}

	return nil
}
1195891
func (runner *suiteRunner) checkFixtureArgs() bool {
	succeeded := true
	argType := reflect.TypeOf(&C{})
	for _, method := range []*methodType{runner.setUpSuite, runner.tearDownSuite, runner.setUpTest, runner.tearDownTest} {
		if method != nil {
			mt := method.Type()
			if mt.NumIn() != 1 || mt.In(0) != argType {
				succeeded = false
				runner.runFunc(method, fixtureKd, "", nil, func(c *C) {
					c.logArgPanic(method, "*check.C")
					c.status = panickedSt
				})
			}
		}
	}
	return succeeded
}
609519
func checkStrings(L *lua.LState, n int) []string {
	params := L.GetTop()
	if n > params {
		return []string{}
	}
	args := make([]string, 0, (params - n + 1))
	for i := n; i <= params; i++ {
		p := L.Get(i)
		if p.Type() == lua.LTUserData {
			continue
		}
		L.CheckTypes(i, lua.LTString, lua.LTNumber)
		args = append(args, p.String())
	}
	return args
}
681340
func (s *Snappy) CheckExt(filename string) error {
	if filepath.Ext(filename) != ".sz" {
		return fmt.Errorf("filename must have a .sz extension")
	}
	return nil
}
220904
func (tc *typeChecker) CheckBody(env *TypeEnv, body Body) (*TypeEnv, Errors) {

	if env == nil {
		env = NewTypeEnv()
	} else {
		env = env.wrap()
	}

	WalkExprs(body, func(expr *Expr) bool {

		closureErrs := tc.checkClosures(env, expr)
		for _, err := range closureErrs {
			tc.err(err)
		}

		hasClosureErrors := len(closureErrs) > 0

		vis := newRefChecker(env)
		Walk(vis, expr)
		for _, err := range vis.errs {
			tc.err(err)
		}

		hasRefErrors := len(vis.errs) > 0

		if err := tc.checkExpr(env, expr); err != nil {
			// Suppress this error if a more actionable one has occurred. In
			// this case, if an error occurred in a ref or closure contained in
			// this expression, and the error is due to a nil type, then it's
			// likely to be the result of the more specific error.
			skip := (hasClosureErrors || hasRefErrors) && causedByNilType(err)
			if !skip {
				tc.err(err)
			}
		}

		return true
	})

	return env, tc.errs
}
771650
func checkContentType(contentType string) error {
	if contentType == "" {
		return nil
	}

	mType, mParams, err := mime.ParseMediaType(contentType)
	if err != nil {
		return err
	}

	if mType != "text/xml" && mType != "application/xml" {
		return fmt.Errorf("unsupported content type %q", mType)
	}

	charset, _ := mParams["charset"]
	if charset != "" && strings.ToLower(charset) != "utf-8" {
		return fmt.Errorf("unsupported content charset %q", charset)
	}

	return nil
}
11297
func CheckSimpleCommand() (err error) {
	cli, err := newClient()
	if err != nil {
		return fmt.Errorf("creating client: %v", err)
	}
	echoStr := "hello"
	config := &docker.ContainerConfig{
		Image: "ubuntu:14.04",
		Cmd:   []string{"echo", "-n", echoStr},
	}
	cid, err := cli.CreateContainer(config, "hellotest")
	if err != nil {
		return fmt.Errorf("creating container: %v", err)
	}
	defer func() {
		rcErr := cli.RemoveContainer(cid, true, false)
		if err == nil {
			err = rcErr
		} else if rcErr != nil {
			fmt.Fprintf(os.Stderr, "removing container %v\n", rcErr)
		}
	}()

	// attach to the container
	streamOpts := &docker.AttachOptions{Stream: true, Stdout: true, Stderr: true}
	stream, err := cli.Attach(cid, streamOpts)
	if err != nil {
		return err
	}
	defer stream.Close()

	// start the container
	err = cli.StartContainer(cid, &docker.HostConfig{})
	if err != nil {
		return err
	}

	var stderr bytes.Buffer
	var stdout bytes.Buffer
	if err = docker.SplitStream(stream, &stdout, &stderr); err != nil {
		return fmt.Errorf("reading stdout: %v", err)
	}

	// wait for the container to exit
	exitCode, err := cli.Wait(cid)
	if err != nil {
		return err
	}

	if exitCode != 0 {
		return fmt.Errorf("bad exit code %d %s", exitCode, stderr)
	}
	if out := stdout.String(); out != echoStr {
		return fmt.Errorf("expected '%s' from echo, got '%s'", echoStr, out)
	}
	if sErr := stderr.String(); sErr != "" {
		return fmt.Errorf("expected no response from stderr, got '%s'", sErr)
	}

	return nil
}
727081
func (t Topology) CheckValid() error {
	switch t {
	case TopologyNetwork, TopologyDirectedNetwork, TopologyDependency, TopologyTree:
		return nil
	default:
		return errors.NewBadParameterError("topolgy", t).Expected(TopologyNetwork + "|" + TopologyDirectedNetwork + "|" + TopologyDependency + "|" + TopologyTree)
	}
}
997984
func (e Event) Check() error {
	if len(e.Title) == 0 {
		return fmt.Errorf("statsd.Event title is required")
	}
	if len(e.Text) == 0 {
		return fmt.Errorf("statsd.Event text is required")
	}
	return nil
}
1141745
func checkValid(data []byte, scan *scanner) error {
	scan.reset()
	for _, c := range data {
		scan.bytes++
		if scan.step(scan, int(c)) == scanError {
			return scan.err
		}
	}
	if scan.eof() == scanError {
		return scan.err
	}
	return nil
}
261166
func (daemon *Daemon) checkContainer(container *container.Container, conditions ...func(*container.Container) error) error {
	for _, condition := range conditions {
		if err := condition(container); err != nil {
			return err
		}
	}
	return nil
}
377819
func NewTty(cmd *exec.Cmd) *Tty {
	// Nothing special for Windows at this time
	tty := &Tty{}
	tty.cmd = cmd
	return tty
}