Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/fstream.c

    rb72bad4f r90c3b1c  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr 27 18:20:30 2016
    13 // Update Count     : 187
     12// Last Modified On : Mon Feb 29 18:41:10 2016
     13// Update Count     : 162
    1414//
    1515
     
    2525}
    2626
    27 #define IO_MSG "I/O error: "
     27#define IO_MSG "I/O error "
    2828
    29 _Bool sepPrt( ofstream * os ) { return os->sepOnOff; }
    30 void sepOn( ofstream * os ) { os->sepOnOff = 1; }
    31 void sepOff( ofstream * os ) { os->sepOnOff = 0; }
    32 void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
    33 void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
     29_Bool sepPrt( ofstream * os ) { return os->separate == 1; }
     30void sepOn( ofstream * os ) { if ( os->separate != 2 ) os->separate = 1; }
     31void sepOff( ofstream * os ) { if ( os->separate != 2 ) os->separate = 0; }
    3432void sepSet( ofstream * os, const char * s ) {
    3533        strncpy( &(os->separator[0]), s, separateSize - 1 );
     
    3735} // sepSet
    3836const char * sepGet( ofstream * os ) { return &(os->separator[0]); }
    39 _Bool sepDisable( ofstream *os ) {
    40         _Bool temp = os->sepDefault;
    41         os->sepDefault = 0;
    42         sepReset( os );
    43         return temp;
    44 } // sepDisable
    45 _Bool sepEnable( ofstream *os ) {
    46         _Bool temp = os->sepDefault;
    47         os->sepDefault = 1;
    48         sepReset( os );
    49         return temp;
    50 } // sepEnable
     37void sepDisable( ofstream *os ) { os->separate = 2; }
     38void sepEnable( ofstream *os ) { os->separate = 0; }
    5139
    5240int fail( ofstream * os ) {
     
    6149        FILE *file = fopen( name, mode );
    6250        if ( file == 0 ) {                                                                      // do not change unless successful
    63                 fprintf( stderr, IO_MSG "open output file \"%s\", ", name );
    64                 perror( 0 );
     51                perror( IO_MSG "open output" );
    6552                exit( EXIT_FAILURE );
    6653        } // if
     
    9380int prtfmt( ofstream * os, const char fmt[], ... ) {
    9481    va_list args;
     82
    9583    va_start( args, fmt );
    9684    int len = vfprintf( (FILE *)(os->file), fmt, args );
     
    10290        } // if
    10391    va_end( args );
    104 
    105         sepReset( os );                                                                         // reset separator
    10692        return len;
    10793} // prtfmt
    10894
    10995
    110 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, { ' ', '\0' } };
     96static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 0, { ' ', '\0' } };
    11197ofstream *sout = &soutFile;
    112 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, { ' ', '\0' } };
     98static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 0, { ' ', '\0' } };
    11399ofstream *serr = &serrFile;
    114100
     
    128114        FILE *t = fopen( name, mode );
    129115        if ( t == 0 ) {                                                                         // do not change unless successful
    130                 fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
    131                 perror( 0 );
     116                perror( IO_MSG "open input" );
    132117                exit( EXIT_FAILURE );
    133118        } // if
     
    190175// Local Variables: //
    191176// tab-width: 4 //
     177// compile-command: "cfa fstream.c" //
    192178// End: //
Note: See TracChangeset for help on using the changeset viewer.