1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
16 #include "cmdline_parse.h"
17 #include "cmdline_rdline.h"
18 #include "cmdline_socket.h"
22 cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path)
26 /* everything else is checked in cmdline_new() */
30 fd = open(path, O_RDONLY, 0);
32 dprintf("open() failed\n");
35 return cmdline_new(ctx, prompt, fd, -1);
39 cmdline_stdin_new(cmdline_parse_ctx_t *ctx, const char *prompt)
42 struct termios oldterm, term;
44 tcgetattr(0, &oldterm);
45 memcpy(&term, &oldterm, sizeof(term));
46 term.c_lflag &= ~(ICANON | ECHO | ISIG);
47 tcsetattr(0, TCSANOW, &term);
50 cl = cmdline_new(ctx, prompt, 0, 1);
53 memcpy(&cl->oldterm, &oldterm, sizeof(term));
59 cmdline_stdin_exit(struct cmdline *cl)
64 tcsetattr(fileno(stdin), TCSANOW, &cl->oldterm);