Changes in src/libcfa/fstream.c [b72bad4f:90c3b1c]
- File:
-
- 1 edited
-
src/libcfa/fstream.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/fstream.c
rb72bad4f r90c3b1c 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Apr 27 18:20:30 201613 // Update Count : 1 8712 // Last Modified On : Mon Feb 29 18:41:10 2016 13 // Update Count : 162 14 14 // 15 15 … … 25 25 } 26 26 27 #define IO_MSG "I/O error :"27 #define IO_MSG "I/O error " 28 28 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; } 30 void sepOn( ofstream * os ) { if ( os->separate != 2 ) os->separate = 1; } 31 void sepOff( ofstream * os ) { if ( os->separate != 2 ) os->separate = 0; } 34 32 void sepSet( ofstream * os, const char * s ) { 35 33 strncpy( &(os->separator[0]), s, separateSize - 1 ); … … 37 35 } // sepSet 38 36 const 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 37 void sepDisable( ofstream *os ) { os->separate = 2; } 38 void sepEnable( ofstream *os ) { os->separate = 0; } 51 39 52 40 int fail( ofstream * os ) { … … 61 49 FILE *file = fopen( name, mode ); 62 50 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" ); 65 52 exit( EXIT_FAILURE ); 66 53 } // if … … 93 80 int prtfmt( ofstream * os, const char fmt[], ... ) { 94 81 va_list args; 82 95 83 va_start( args, fmt ); 96 84 int len = vfprintf( (FILE *)(os->file), fmt, args ); … … 102 90 } // if 103 91 va_end( args ); 104 105 sepReset( os ); // reset separator106 92 return len; 107 93 } // prtfmt 108 94 109 95 110 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1,0, { ' ', '\0' } };96 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 0, { ' ', '\0' } }; 111 97 ofstream *sout = &soutFile; 112 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1,0, { ' ', '\0' } };98 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 0, { ' ', '\0' } }; 113 99 ofstream *serr = &serrFile; 114 100 … … 128 114 FILE *t = fopen( name, mode ); 129 115 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" ); 132 117 exit( EXIT_FAILURE ); 133 118 } // if … … 190 175 // Local Variables: // 191 176 // tab-width: 4 // 177 // compile-command: "cfa fstream.c" // 192 178 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.