Changeset 080ad7f in mainline


Ignore:
Timestamp:
2009-06-09T11:10:00Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ebe70f1
Parents:
bd8bfcbd
Message:

simple implementation of fdopen() and rewind()

Location:
uspace/lib/libc
Files:
2 edited

Legend:

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

    rbd8bfcbd r080ad7f  
    193193}
    194194
     195FILE *fdopen(int fd, const char *mode)
     196{
     197        /* Open file. */
     198        FILE *stream = malloc(sizeof(FILE));
     199        if (stream == NULL) {
     200                errno = ENOMEM;
     201                return NULL;
     202        }
     203       
     204        stream->fd = fd;
     205        stream->error = false;
     206        stream->eof = false;
     207        stream->klog = false;
     208        stream->phone = -1;
     209       
     210        list_append(&stream->link, &files);
     211       
     212        return stream;
     213}
     214
    195215FILE *fopen_node(fdi_node_t *node, const char *mode)
    196216{
     
    379399}
    380400
     401void rewind(FILE *stream)
     402{
     403        (void) fseek(stream, 0, SEEK_SET);
     404}
     405
    381406int fflush(FILE *stream)
    382407{
  • uspace/lib/libc/include/stdio.h

    rbd8bfcbd r080ad7f  
    107107/* File stream functions */
    108108extern FILE *fopen(const char *, const char *);
     109extern FILE *fdopen(int, const char *);
    109110extern int fclose(FILE *);
    110111
     
    113114
    114115extern int fseek(FILE *, long, int);
     116extern void rewind(FILE *);
    115117extern int ftell(FILE *);
    116118extern int feof(FILE *);
Note: See TracChangeset for help on using the changeset viewer.