Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/console.c

    r63ed840 r28a5ebd  
    243243}
    244244
     245/** Get string from input character device.
     246 *
     247 * Read characters from input character device until first occurrence
     248 * 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 */
     257size_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 */
     289char32_t getc(indev_t *indev)
     290{
     291        char32_t ch = indev_pop_character(indev);
     292        putuchar(ch);
     293        return ch;
     294}
     295
    245296void kio_update(void *event)
    246297{
     
    328379                 * The early_putuchar() function is used to output
    329380                 * the character for low-level debugging purposes.
    330                  * Note that the early_putuchar() function might be
     381                 * Note that the early_putc() function might be
    331382                 * a no-op on certain hardware configurations.
    332383                 */
Note: See TracChangeset for help on using the changeset viewer.