Changes in / [9ec25a6:b670523] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/stdio.c

    r9ec25a6 rb670523  
    3535#define POSIX_INTERNAL
    3636
    37 #include <assert.h>
    38 #include "errno.h"
    3937#include "common.h"
    4038#include "stdio.h"
    41 #include "string.h"
    42 /* not the best of solutions, but freopen will eventually
    43    need to be implemented in libc anyway */
    44 #include "../c/generic/private/stdio.h"
    4539
    4640FILE *posix_freopen(const char *restrict filename,
     
    4842                    FILE *restrict stream)
    4943{
    50         assert(mode != NULL);
    51         assert(stream != NULL);
    52 
    53         if (filename == NULL) {
    54                 // TODO
    55                
    56                 /* print error to stderr as well, to avoid hard to find problems
    57                    with buggy apps that expect this to work */
    58                 fprintf(stderr, "ERROR: Application wants to use freopen() to change mode of opened stream.\n"
    59                                 "       libposix does not support that yet, the application may function improperly.\n");
    60                 errno = ENOTSUP;
    61                 return NULL;
    62         }
    63 
    64         FILE* copy = malloc(sizeof(FILE));
    65         if (copy == NULL) {
    66                 errno = ENOMEM;
    67                 return NULL;
    68         }
    69         memcpy(copy, stream, sizeof(FILE));
    70         fclose(copy);   /* copy is now freed */
    71        
    72         copy = fopen(filename, mode);         /* open new stream */
    73         if (copy == NULL) {
    74                 /* fopen() sets errno */
    75                 return NULL;
    76         }
    77        
    78         /* move the new stream to the original location */
    79         memcpy(stream, copy, sizeof (FILE));
    80         free(copy);
    81        
    82         /* update references in the file list */
    83         stream->link.next->prev = &stream->link;
    84         stream->link.prev->next = &stream->link;
    85        
    86         return stream;
     44        // TODO
     45        not_implemented();
    8746}
    8847
Note: See TracChangeset for help on using the changeset viewer.