macsim/macsim-seq.c
// redirect a stream to a file
redirect a stream to a file
redirect a stream to a file
bool redirect_stream(FILE **stream, char *filename)
{
    if (!filename)
    {
        user_printf("Filename expected\n");
        return 0;
    }
    FILE *f = *stream;
    if (f && f!=stdout)
        fclose(f);
    f = fopen(filename, "w");
    if (!f)
        fatal("Could not open '%s'", filename);
    *stream = f;
    return 1;
}
bool redirect_stream ( FILE * * stream , char * filename ) { if ( ! filename ) { user_printf ( " \n " ) ; return 0 ; } FILE * f = * stream ; if ( f && f != stdout ) fclose ( f ) ; f = fopen ( filename , " " ) ; if ( ! f ) fatal ( " " , filename ) ; * stream = f ; return 1 ; }
redirect a stream to a file
redirect a stream to a file