lib: remove librte_ prefix from directory names
[dpdk.git] / lib / cmdline / cmdline.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation.
3  * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
4  * All rights reserved.
5  */
6
7 #ifndef _CMDLINE_H_
8 #define _CMDLINE_H_
9
10 #ifndef RTE_EXEC_ENV_WINDOWS
11 #include <termios.h>
12 #endif
13
14 #include <rte_common.h>
15 #include <rte_compat.h>
16
17 #include <cmdline_rdline.h>
18 #include <cmdline_parse.h>
19
20 /**
21  * @file
22  *
23  * Command line API
24  */
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #ifndef RTE_EXEC_ENV_WINDOWS
31
32 struct cmdline {
33         int s_in;
34         int s_out;
35         cmdline_parse_ctx_t *ctx;
36         struct rdline rdl;
37         char prompt[RDLINE_PROMPT_SIZE];
38         struct termios oldterm;
39 };
40
41 #else
42
43 struct cmdline;
44
45 #endif /* RTE_EXEC_ENV_WINDOWS */
46
47 struct cmdline *cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out);
48 void cmdline_set_prompt(struct cmdline *cl, const char *prompt);
49 void cmdline_free(struct cmdline *cl);
50 void cmdline_printf(const struct cmdline *cl, const char *fmt, ...)
51         __rte_format_printf(2, 3);
52 int cmdline_in(struct cmdline *cl, const char *buf, int size);
53 int cmdline_write_char(struct rdline *rdl, char c);
54
55 __rte_experimental
56 struct rdline *
57 cmdline_get_rdline(struct cmdline *cl);
58
59 /**
60  * This function is nonblocking equivalent of ``cmdline_interact()``. It polls
61  * *cl* for one character and interpret it. If return value is *RDLINE_EXITED*
62  * it mean that ``cmdline_quit()`` was invoked.
63  *
64  * @param cl
65  *   The command line object.
66  *
67  * @return
68  *   On success return object status - one of *enum rdline_status*.
69  *   On error return negative value.
70  */
71 int cmdline_poll(struct cmdline *cl);
72
73 void cmdline_interact(struct cmdline *cl);
74 void cmdline_quit(struct cmdline *cl);
75
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif /* _CMDLINE_SOCKET_H_ */