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

Function cngets

freebsd/kern/kern_cons.c:448–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448void
449cngets(char *cp, size_t size, int visible)
450{
451 char *lp, *end;
452 int c;
453
454 cngrab();
455
456 lp = cp;
457 end = cp + size - 1;
458 for (;;) {
459 c = cngetc() & 0177;
460 switch (c) {
461 case '\n':
462 case '\r':
463 cnputc(c);
464 *lp = '\0';
465 cnungrab();
466 return;
467 case '\b':
468 case '\177':
469 if (lp > cp) {
470 if (visible)
471 cnputs("\b \b");
472 lp--;
473 }
474 continue;
475 case '\0':
476 continue;
477 default:
478 if (lp < end) {
479 switch (visible) {
480 case GETS_NOECHO:
481 break;
482 case GETS_ECHOPASS:
483 cnputc('*');
484 break;
485 default:
486 cnputc(c);
487 break;
488 }
489 *lp++ = c;
490 }
491 }
492 }
493}
494
495void
496cnputc(int c)

Callers 1

parse_dir_askFunction · 0.85

Calls 5

cngrabFunction · 0.85
cngetcFunction · 0.85
cnputcFunction · 0.85
cnungrabFunction · 0.85
cnputsFunction · 0.85

Tested by

no test coverage detected