Changeset f389409 in mainline for uspace/lib/libc/generic/io/io.c


Ignore:
Timestamp:
2010-02-23T19:33:45Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
Children:
09ababb7, 68acf21
Parents:
5e50394 (diff), c62d2e1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge fgets() function. (Needed by SBI).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/io/io.c

    r5e50394 rf389409  
    536536}
    537537
     538char *fgets(char *str, int size, FILE *stream)
     539{
     540        char c;
     541        int idx;
     542
     543        idx = 0;
     544        while (idx < size - 1) {
     545                c = fgetc(stream);
     546                if (c == EOF)
     547                        break;
     548
     549                str[idx++] = c;
     550
     551                if (c == '\n')
     552                        break;
     553        }
     554
     555        if (ferror(stream))
     556                return NULL;
     557
     558        if (idx == 0)
     559                return NULL;
     560
     561        str[idx] = '\0';
     562        return str;
     563}
     564
    538565int getchar(void)
    539566{
Note: See TracChangeset for help on using the changeset viewer.