MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / get_line

Function get_line

src/utilities/ibmgr/ibmgr.cpp:226–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224
225
226static bool get_line( int *argc, SCHAR** argv, TEXT* stuff)
227{
228/**************************************
229 *
230 * g e t _ l i n e
231 *
232 **************************************
233 *
234 * Functional description
235 * Read the current line and put its pieces into an argc/argv
236 * structure. Reads a max of MAXARGS - 1 pieces (argv [0] is
237 * unused), and a max of MAXSTUFF characters, at which point
238 *
239 **************************************/
240 TEXT msg[MSG_LEN];
241
242 SRVRMGR_msg_get(MSG_PROMPT, msg);
243 printf("%s ", msg); // "FBMGR> "
244
245 //if (sw_service_gsec)
246 // putc ('\001', stdout);
247
248 fflush(stdout);
249 *argc = 1;
250 TEXT* cursor = stuff;
251 USHORT count = MAXSTUFF - 1;
252 bool first = true;
253
254 // for each input character, if it's white space (or any non-printable,
255 // non-newline for that matter), ignore it; if it's a newline, we're
256 // done; otherwise, put it in the current argument
257
258 while (*argc < MAXARGS && count > 0)
259 {
260 TEXT c = getc(stdin);
261 if (c > ' ' && c <= '~')
262 {
263 // note that the first argument gets a '-' appended to the front to fool
264 // the switch checker into thinking it came from the command line
265
266 for (argv[(*argc)++] = cursor; count > 0; count--)
267 {
268 if (first)
269 {
270 first = false;
271 if (c != '?')
272 {
273 *cursor++ = '-';
274 count--;
275 }
276 }
277 *cursor++ = c;
278 c = getc(stdin);
279 if (c <= ' ' || c > '~')
280 break;
281 }
282 *cursor++ = '\0';
283 count--;

Callers 1

CLIB_ROUTINE mainFunction · 0.70

Calls 3

SRVRMGR_msg_getFunction · 0.85
fflushFunction · 0.85
getcFunction · 0.85

Tested by

no test coverage detected