Changeset 63ed840 in mainline
- Timestamp:
- 2023-10-27T19:45:12Z (14 months ago)
- Branches:
- master, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1170cfc7
- Parents:
- 34120f10
- Location:
- kernel/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/console/console.h
r34120f10 r63ed840 69 69 SPINLOCK_EXTERN(kio_lock); 70 70 71 extern char32_t getc(indev_t *indev);72 extern size_t gets(indev_t *indev, char *buf, size_t buflen);73 71 extern sys_errno_t sys_kio(int cmd, uspace_addr_t buf, size_t size); 74 72 -
kernel/generic/src/console/console.c
r34120f10 r63ed840 243 243 } 244 244 245 /** Get string from input character device.246 *247 * Read characters from input character device until first occurrence248 * of newline character.249 *250 * @param indev Input character device.251 * @param buf Buffer where to store string terminated by NULL.252 * @param buflen Size of the buffer.253 *254 * @return Number of characters read.255 *256 */257 size_t gets(indev_t *indev, char *buf, size_t buflen)258 {259 size_t offset = 0;260 size_t count = 0;261 buf[offset] = 0;262 263 char32_t ch;264 while ((ch = indev_pop_character(indev)) != '\n') {265 if (ch == '\b') {266 if (count > 0) {267 /* Space, backspace, space */268 putuchar('\b');269 putuchar(' ');270 putuchar('\b');271 272 count--;273 offset = str_lsize(buf, count);274 buf[offset] = 0;275 }276 }277 278 if (chr_encode(ch, buf, &offset, buflen - 1) == EOK) {279 putuchar(ch);280 count++;281 buf[offset] = 0;282 }283 }284 285 return count;286 }287 288 /** Get character from input device & echo it to screen */289 char32_t getc(indev_t *indev)290 {291 char32_t ch = indev_pop_character(indev);292 putuchar(ch);293 return ch;294 }295 296 245 void kio_update(void *event) 297 246 {
Note:
See TracChangeset
for help on using the changeset viewer.