/trunk/uspace/lib/libc/include/stdio.h |
---|
106,6 → 106,7 |
/* File stream functions */ |
extern FILE *fopen(const char *, const char *); |
extern FILE *fdopen(int, const char *); |
extern int fclose(FILE *); |
extern size_t fread(void *, size_t, size_t, FILE *); |
112,6 → 113,7 |
extern size_t fwrite(const void *, size_t, size_t, FILE *); |
extern int fseek(FILE *, long, int); |
extern void rewind(FILE *); |
extern int ftell(FILE *); |
extern int feof(FILE *); |
/trunk/uspace/lib/libc/generic/io/io.c |
---|
192,6 → 192,26 |
return stream; |
} |
FILE *fdopen(int fd, const char *mode) |
{ |
/* Open file. */ |
FILE *stream = malloc(sizeof(FILE)); |
if (stream == NULL) { |
errno = ENOMEM; |
return NULL; |
} |
stream->fd = fd; |
stream->error = false; |
stream->eof = false; |
stream->klog = false; |
stream->phone = -1; |
list_append(&stream->link, &files); |
return stream; |
} |
FILE *fopen_node(fdi_node_t *node, const char *mode) |
{ |
int flags; |
378,6 → 398,11 |
return 0; |
} |
void rewind(FILE *stream) |
{ |
(void) fseek(stream, 0, SEEK_SET); |
} |
int fflush(FILE *stream) |
{ |
if (stream->klog) { |