struct cmdline exposes platform-specific members it contains, most
notably struct termios that is only available on Unix. While ABI
considerations prevent from hinding the definition on already supported
platforms, struct cmdline is considered logically opaque from now on.
Add a deprecation notice targeted at 20.11.
* Remove tests checking struct cmdline content as meaningless.
* Fix missing cmdline_free() in unit test.
* Add cmdline_get_rdline() to access history buffer indirectly.
The new function is currently used only in tests.
Suggested-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
struct cmdline *cl,
__rte_unused void *data)
{
struct cmdline *cl,
__rte_unused void *data)
{
+ struct rdline *rdl = cmdline_get_rdline(cl);
+
cmdline_printf(cl, "History buffer size: %zu\n",
cmdline_printf(cl, "History buffer size: %zu\n",
- sizeof(cl->rdl.history_buf));
+ sizeof(rdl->history_buf));
}
cmdline_parse_token_string_t cmd_get_history_bufsize_tok =
}
cmdline_parse_token_string_t cmd_get_history_bufsize_tok =
struct cmdline *cl,
__rte_unused void *data)
{
struct cmdline *cl,
__rte_unused void *data)
{
- rdline_clear_history(&cl->rdl);
+ struct rdline *rdl = cmdline_get_rdline(cl);
+
+ rdline_clear_history(rdl);
}
cmdline_parse_token_string_t cmd_clear_history_tok =
}
cmdline_parse_token_string_t cmd_clear_history_tok =
static int
test_cmdline_parse_fns(void)
{
static int
test_cmdline_parse_fns(void)
{
+ struct cmdline *cl;
+ cmdline_parse_ctx_t ctx;
int i = 0;
char dst[CMDLINE_TEST_BUFSIZE];
int i = 0;
char dst[CMDLINE_TEST_BUFSIZE];
+ cl = cmdline_new(&ctx, "prompt", -1, -1);
+ if (cl == NULL) {
+ printf("Error: cannot create cmdline to test parse fns!\n");
+ return -1;
+ }
+
if (cmdline_parse(NULL, "buffer") >= 0)
goto error;
if (cmdline_parse(NULL, "buffer") >= 0)
goto error;
- if (cmdline_parse(&cl, NULL) >= 0)
+ if (cmdline_parse(cl, NULL) >= 0)
goto error;
if (cmdline_complete(NULL, "buffer", &i, dst, sizeof(dst)) >= 0)
goto error;
goto error;
if (cmdline_complete(NULL, "buffer", &i, dst, sizeof(dst)) >= 0)
goto error;
- if (cmdline_complete(&cl, NULL, &i, dst, sizeof(dst)) >= 0)
+ if (cmdline_complete(cl, NULL, &i, dst, sizeof(dst)) >= 0)
- if (cmdline_complete(&cl, "buffer", NULL, dst, sizeof(dst)) >= 0)
+ if (cmdline_complete(cl, "buffer", NULL, dst, sizeof(dst)) >= 0)
- if (cmdline_complete(&cl, "buffer", &i, NULL, sizeof(dst)) >= 0)
+ if (cmdline_complete(cl, "buffer", &i, NULL, sizeof(dst)) >= 0)
test_cmdline_fns(void)
{
cmdline_parse_ctx_t ctx;
test_cmdline_fns(void)
{
cmdline_parse_ctx_t ctx;
- struct cmdline cl, *tmp;
memset(&ctx, 0, sizeof(ctx));
memset(&ctx, 0, sizeof(ctx));
- tmp = cmdline_new(&ctx, "test", -1, -1);
- if (tmp == NULL)
+ cl = cmdline_new(&ctx, "test", -1, -1);
+ if (cl == NULL)
goto error;
if (cmdline_new(NULL, "prompt", 0, 0) != NULL)
goto error;
if (cmdline_new(NULL, "prompt", 0, 0) != NULL)
goto error;
if (cmdline_in(NULL, "buffer", CMDLINE_TEST_BUFSIZE) >= 0)
goto error;
goto error;
if (cmdline_in(NULL, "buffer", CMDLINE_TEST_BUFSIZE) >= 0)
goto error;
- if (cmdline_in(&cl, NULL, CMDLINE_TEST_BUFSIZE) >= 0)
+ if (cmdline_in(cl, NULL, CMDLINE_TEST_BUFSIZE) >= 0)
goto error;
if (cmdline_write_char(NULL, 0) >= 0)
goto error;
goto error;
if (cmdline_write_char(NULL, 0) >= 0)
goto error;
cmdline_set_prompt(NULL, "prompt");
cmdline_free(NULL);
cmdline_printf(NULL, "format");
cmdline_set_prompt(NULL, "prompt");
cmdline_free(NULL);
cmdline_printf(NULL, "format");
- /* this should fail as stream handles are invalid */
- cmdline_printf(tmp, "format");
cmdline_interact(NULL);
cmdline_quit(NULL);
cmdline_interact(NULL);
cmdline_quit(NULL);
- /* check if void calls change anything when they should fail */
- cl = *tmp;
-
- cmdline_printf(&cl, NULL);
- if (memcmp(&cl, tmp, sizeof(cl))) goto mismatch;
- cmdline_set_prompt(&cl, NULL);
- if (memcmp(&cl, tmp, sizeof(cl))) goto mismatch;
- cmdline_in(&cl, NULL, CMDLINE_TEST_BUFSIZE);
- if (memcmp(&cl, tmp, sizeof(cl))) goto mismatch;
-
- cmdline_free(tmp);
-
return 0;
error:
printf("Error: function accepted null parameter!\n");
return 0;
error:
printf("Error: function accepted null parameter!\n");
- return -1;
-mismatch:
- printf("Error: data changed!\n");
+ if (cl != NULL)
+ cmdline_free(cl);
In this case the function will return -1 unless the environment is unset first
(using ``rte_power_unset_env``). Other function usage scenarios will not change.
In this case the function will return -1 unless the environment is unset first
(using ``rte_power_unset_env``). Other function usage scenarios will not change.
+* cmdline: ``cmdline`` structure will be made opaque to hide platform-specific
+ content. On Linux and FreeBSD, supported prior to DPDK 20.11,
+ original structure will be kept until DPDK 21.11.
+
* dpdk-setup.sh: This old script relies on deprecated stuff, and especially
``make``. Given environments are too much variables for such a simple script,
it will be removed in DPDK 20.11.
* dpdk-setup.sh: This old script relies on deprecated stuff, and especially
``make``. Given environments are too much variables for such a simple script,
it will be removed in DPDK 20.11.
#include <fcntl.h>
#include <poll.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <errno.h>
#include <netinet/in.h>
#include <rte_string_fns.h>
#include <netinet/in.h>
#include <rte_string_fns.h>
-#include "cmdline_parse.h"
-#include "cmdline_rdline.h"
#include "cmdline.h"
static void
#include "cmdline.h"
static void
+struct rdline*
+cmdline_get_rdline(struct cmdline *cl)
+{
+ return &cl->rdl;
+}
+
void
cmdline_free(struct cmdline *cl)
{
void
cmdline_free(struct cmdline *cl)
{
#ifndef _CMDLINE_H_
#define _CMDLINE_H_
#ifndef _CMDLINE_H_
#define _CMDLINE_H_
+#ifndef RTE_EXEC_ENV_WINDOWS
+#include <termios.h>
+#endif
+
#include <cmdline_rdline.h>
#include <cmdline_parse.h>
#include <cmdline_rdline.h>
#include <cmdline_parse.h>
+#ifndef RTE_EXEC_ENV_WINDOWS
+
struct cmdline {
int s_in;
int s_out;
struct cmdline {
int s_in;
int s_out;
struct termios oldterm;
};
struct termios oldterm;
};
+#else
+
+struct cmdline;
+
+#endif /* RTE_EXEC_ENV_WINDOWS */
+
struct cmdline *cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out);
void cmdline_set_prompt(struct cmdline *cl, const char *prompt);
void cmdline_free(struct cmdline *cl);
struct cmdline *cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out);
void cmdline_set_prompt(struct cmdline *cl, const char *prompt);
void cmdline_free(struct cmdline *cl);
int cmdline_in(struct cmdline *cl, const char *buf, int size);
int cmdline_write_char(struct rdline *rdl, char c);
int cmdline_in(struct cmdline *cl, const char *buf, int size);
int cmdline_write_char(struct rdline *rdl, char c);
+__rte_experimental
+struct rdline *
+cmdline_get_rdline(struct cmdline *cl);
+
/**
* This function is nonblocking equivalent of ``cmdline_interact()``. It polls
* *cl* for one character and interpret it. If return value is *RDLINE_EXITED*
/**
* This function is nonblocking equivalent of ``cmdline_interact()``. It polls
* *cl* for one character and interpret it. If return value is *RDLINE_EXITED*
#include <string.h>
#include <inttypes.h>
#include <ctype.h>
#include <string.h>
#include <inttypes.h>
#include <ctype.h>
#include <netinet/in.h>
#include <rte_string_fns.h>
#include <netinet/in.h>
#include <rte_string_fns.h>
-#include "cmdline_rdline.h"
-#include "cmdline_parse.h"
#include "cmdline.h"
#ifdef RTE_LIBRTE_CMDLINE_DEBUG
#include "cmdline.h"
#ifdef RTE_LIBRTE_CMDLINE_DEBUG
#include <stdarg.h>
#include <inttypes.h>
#include <fcntl.h>
#include <stdarg.h>
#include <inttypes.h>
#include <fcntl.h>
-#include "cmdline_parse.h"
-#include "cmdline_rdline.h"
-#include "cmdline_socket.h"
+#include "cmdline_socket.h"
struct cmdline *
cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path)
struct cmdline *
cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path)
+
+EXPERIMENTAL {
+ global:
+
+ cmdline_get_rdline;
+
+ local: *;
+};