/*
Examples:

    IsTerminal(os.Stdin)
    IsTerminal(os.Stdout)
    IsTerminal(os.Stderr)
*/
967161
func IsTerminal(file *os.File) bool {
	var st uint32
	return getConsoleMode(syscall.Handle(file.Fd()), &st) == nil
}
360331
func (r *TaskService) Stdout(taskId string) *TaskStdoutCall {
	c := &TaskStdoutCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.taskId = taskId
	return c
}
119553
func WithStdinContext(closer io.ReadCloser) func(*icmd.Cmd) func() {
	return func(cmd *icmd.Cmd) func() {
		cmd.Command = append(cmd.Command, "-")
		cmd.Stdin = closer
		return func() {
			// FIXME(vdemeester) we should not ignore the error here…
			closer.Close()
		}
	}
}
113988
func NewTerminal(ctx *ServerContext) (Terminal, error) {
	// It doesn't matter what mode the cluster is in, if this is a Teleport node
	// return a local terminal.
	if ctx.srv.Component() == teleport.ComponentNode {
		return newLocalTerminal(ctx)
	}

	// If this is not a Teleport node, find out what mode the cluster is in and
	// return the correct terminal.
	if ctx.ClusterConfig.GetSessionRecording() == services.RecordAtProxy {
		return newRemoteTerminal(ctx)
	}
	return newLocalTerminal(ctx)
}
1090942
func IsTerminal(file *os.File) bool {
	var termios syscall.Termios
	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, file.Fd(),
		uintptr(syscall.TCGETS), uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
	return err == 0
}
979314
func IsTerminal(w io.Writer) bool {
	fw, ok := w.(interface {
		Fd() uintptr
	})
	if !ok {
		return false
	}
	var st uint32
	r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fw.Fd(), uintptr(unsafe.Pointer(&st)), 0)
	return r != 0 && e == 0
}
516667
func main() {

	var inputbytes, utf8bytes, outputbytes []byte

	flag.Parse()

	// print help/version/list/usage...
	someSortOfHelp()

	// read input from stdin or file
	inputbytes = getInputBytes()

	// convert inputformat to UTF-8 (decode)
	utf8bytes = getUtf8FromInput(inputbytes)

	// convert UTF-8 to output format (encode)
	outputbytes = convertToDesired(utf8bytes)

	// write output to stdout or file
	writeOutput(outputbytes)

}
772192
func Examples(s string) string {
	if len(s) == 0 {
		return s
	}
	return normalizer{s}.trim().indent().string
}
169296
func IsTerminal(fd int) bool {
	var st uint32
	r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
	return r != 0 && e == 0
}
121027
func StdoutLoggerWithLevel(lvl string) loggerGenerator {
	l := logger.ParseLevel(lvl)
	return stdLogger(l, os.Stdout)
}
586464
func NewTerminal(req TerminalRequest, authProvider AuthProvider, ctx *SessionContext) (*TerminalHandler, error) {

	// Make sure whatever session is requested is a valid session.
	_, err := session.ParseID(string(req.SessionID))
	if err != nil {
		return nil, trace.BadParameter("sid: invalid session id")
	}

	if req.Login == "" {
		return nil, trace.BadParameter("login: missing login")
	}
	if req.Term.W <= 0 || req.Term.H <= 0 {
		return nil, trace.BadParameter("term: bad term dimensions")
	}

	servers, err := authProvider.GetNodes(req.Namespace, services.SkipValidation())
	if err != nil {
		return nil, trace.Wrap(err)
	}

	hostName, hostPort, err := resolveServerHostPort(req.Server, servers)
	if err != nil {
		return nil, trace.BadParameter("invalid server name %q: %v", req.Server, err)
	}

	return &TerminalHandler{
		log: logrus.WithFields(logrus.Fields{
			trace.Component: teleport.ComponentWebsocket,
		}),
		params:       req,
		ctx:          ctx,
		hostName:     hostName,
		hostPort:     hostPort,
		authProvider: authProvider,
		encoder:      unicode.UTF8.NewEncoder(),
		decoder:      unicode.UTF8.NewDecoder(),
	}, nil
}
484462
func isTerminalFunc(fd int) bool {
	var st uint32
	r, _, errno := syscall.Syscall(procMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
	if errno != 0 {
		return false
	}

	return r != 0
}
134533
func (pr *PluralRule) Examples() (integer []string, decimal []string) {
	ex := strings.Replace(pr.Rule, ", …", "", -1)
	ddelim := "@decimal"
	if i := strings.Index(ex, ddelim); i > 0 {
		dex := strings.TrimSpace(ex[i+len(ddelim):])
		decimal = strings.Split(dex, ", ")
		ex = ex[:i]
	}
	idelim := "@integer"
	if i := strings.Index(ex, idelim); i > 0 {
		iex := strings.TrimSpace(ex[i+len(idelim):])
		integer = strings.Split(iex, ", ")
	}
	return integer, decimal
}
705706
func main() {
	if len(os.Args) != 2 {
		stderr("usage: %s [main|sidekick|preStart|postStop]", os.Args[0])
		os.Exit(64)
	}
	mode := os.Args[1]
	var res results
	switch strings.ToLower(mode) {
	case "main":
		res = validateMain()
	case "sidekick":
		res = validateSidekick()
	case "prestart":
		res = validatePrestart()
	case "poststop":
		res = validatePoststop()
	default:
		stderr("unrecognized mode: %s", mode)
		os.Exit(64)
	}
	if len(res) == 0 {
		fmt.Printf("%s OK\n", mode)
		os.Exit(0)
	}
	fmt.Printf("%s FAIL\n", mode)
	for _, err := range res {
		fmt.Fprintln(os.Stderr, "==>", err)
	}
	os.Exit(1)
}
228165
func main() {
	loggingConfig := &LoggingConfig{
		RootSink: Sink().
			AddSinks(
				// Log everything to Stderr
				Sink().SetOutput(StderrOutput()),
				Sink().SetTransform(FilterTransform(ExcludeWhenAllMatch,
					"module", "p2p",
					"captured_logging_source", "tendermint_log15")).
					AddSinks(
						Sink().SetOutput(StdoutOutput()),
					),
			),
	}
	fmt.Println(loggingConfig.RootTOMLString())
}
1015772
func IsTerminalReader(r io.Reader) bool {
	file, ok := r.(*os.File)
	return ok && term.IsTerminal(file.Fd())
}
152863
func (i *Instance) WriteStdin(val []byte) (int, error) {
	return i.Terminal.WriteStdin(val)
}