cmdline: use SPDX tags
[dpdk.git] / lib / librte_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 #include <termios.h>
11 #include <cmdline_rdline.h>
12 #include <cmdline_parse.h>
13
14 /**
15  * @file
16  *
17  * Command line API
18  */
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 struct cmdline {
25         int s_in;
26         int s_out;
27         cmdline_parse_ctx_t *ctx;
28         struct rdline rdl;
29         char prompt[RDLINE_PROMPT_SIZE];
30         struct termios oldterm;
31 };
32
33 struct cmdline *cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out);
34 void cmdline_set_prompt(struct cmdline *cl, const char *prompt);
35 void cmdline_free(struct cmdline *cl);
36 void cmdline_printf(const struct cmdline *cl, const char *fmt, ...)
37         __attribute__((format(printf,2,3)));
38 int cmdline_in(struct cmdline *cl, const char *buf, int size);
39 int cmdline_write_char(struct rdline *rdl, char c);
40
41 /**
42  * This function is nonblocking equivalent of ``cmdline_interact()``. It polls
43  * *cl* for one character and interpret it. If return value is *RDLINE_EXITED*
44  * it mean that ``cmdline_quit()`` was invoked.
45  *
46  * @param cl
47  *   The command line object.
48  *
49  * @return
50  *   On success return object status - one of *enum rdline_status*.
51  *   On error return negative value.
52  */
53 int cmdline_poll(struct cmdline *cl);
54
55 void cmdline_interact(struct cmdline *cl);
56 void cmdline_quit(struct cmdline *cl);
57
58 #ifdef __cplusplus
59 }
60 #endif
61
62 #endif /* _CMDLINE_SOCKET_H_ */