2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: msvcrt/conio/cgets.c
6 * PROGRAMMER: Eric Kohl (Imported from DJGPP)
14 char *_cgets(char *string
)
17 unsigned int maxlen_wanted
;
21 * Be smart and check for NULL pointer.
22 * Don't know wether TURBOC does this.
26 maxlen_wanted
= (unsigned int)((unsigned char)string
[0]);
29 * Should the string be shorter maxlen_wanted including or excluding
30 * the trailing '\0' ? We don't take any risk.
32 while(len
< maxlen_wanted
-1)
36 * shold we check for backspace here?
37 * TURBOC does (just checked) but doesn't in cscanf (thats harder
38 * or even impossible). We do the same.
44 _cputs("\b \b"); /* go back, clear char on screen with space
47 sp
[len
] = '\0'; /* clear the character in the string */
57 /* special character ends input */
59 _ungetch(c
); /* keep the char for later processing */
68 sp
[maxlen_wanted
-1] = '\0';
69 string
[1] = (char)((unsigned char)len
);