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

Function cmdline_in

dpdk/lib/cmdline/cmdline.c:134–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134int
135cmdline_in(struct cmdline *cl, const char *buf, int size)
136{
137 const char *history, *buffer;
138 size_t histlen, buflen;
139 int ret = 0;
140 int i, same;
141
142 if (!cl || !buf)
143 return -1;
144
145 for (i=0; i<size; i++) {
146 ret = rdline_char_in(&cl->rdl, buf[i]);
147
148 if (ret == RDLINE_RES_VALIDATED) {
149 buffer = rdline_get_buffer(&cl->rdl);
150 history = rdline_get_history_item(&cl->rdl, 0);
151 if (history) {
152 histlen = strnlen(history, RDLINE_BUF_SIZE);
153 same = !memcmp(buffer, history, histlen) &&
154 buffer[histlen] == '\n';
155 }
156 else
157 same = 0;
158 buflen = strnlen(buffer, RDLINE_BUF_SIZE);
159 if (buflen > 1 && !same)
160 rdline_add_history(&cl->rdl, buffer);
161 rdline_newline(&cl->rdl, cl->prompt);
162 }
163 else if (ret == RDLINE_RES_EOF)
164 return -1;
165 else if (ret == RDLINE_RES_EXITED)
166 return -1;
167 }
168 return i;
169}
170
171void
172cmdline_quit(struct cmdline *cl)

Callers 3

cmdline_interactFunction · 0.85
test_cmdline_fnsFunction · 0.85
mainFunction · 0.85

Calls 6

rdline_char_inFunction · 0.85
rdline_get_bufferFunction · 0.85
rdline_get_history_itemFunction · 0.85
strnlenFunction · 0.85
rdline_add_historyFunction · 0.85
rdline_newlineFunction · 0.85

Tested by 2

test_cmdline_fnsFunction · 0.68
mainFunction · 0.68