MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cmdline_new

Function cmdline_new

dpdk/lib/cmdline/cmdline.c:68–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68struct cmdline *
69cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out)
70{
71 struct cmdline *cl;
72 int ret;
73
74 if (!ctx || !prompt)
75 return NULL;
76
77 cl = malloc(sizeof(struct cmdline));
78 if (cl == NULL)
79 return NULL;
80 memset(cl, 0, sizeof(struct cmdline));
81 cl->s_in = s_in;
82 cl->s_out = s_out;
83 cl->ctx = ctx;
84
85 ret = rdline_init(&cl->rdl, cmdline_write_char, cmdline_valid_buffer,
86 cmdline_complete_buffer, cl);
87 if (ret != 0) {
88 free(cl);
89 return NULL;
90 }
91
92 cmdline_set_prompt(cl, prompt);
93 rdline_newline(&cl->rdl, cl->prompt);
94
95 return cl;
96}
97
98struct rdline*
99cmdline_get_rdline(struct cmdline *cl)

Callers 5

cmdline_file_newFunction · 0.85
cmdline_stdin_newFunction · 0.85
test_cmdline_parse_fnsFunction · 0.85
test_cmdline_fnsFunction · 0.85
mainFunction · 0.85

Calls 6

mallocFunction · 0.85
memsetFunction · 0.85
rdline_initFunction · 0.85
cmdline_set_promptFunction · 0.85
rdline_newlineFunction · 0.85
freeFunction · 0.50

Tested by 3

test_cmdline_parse_fnsFunction · 0.68
test_cmdline_fnsFunction · 0.68
mainFunction · 0.68