Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/fstream.c

    r6152c81 r829c907  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 14:48:09 2017
    13 // Update Count     : 192
     12// Last Modified On : Tue Mar 21 20:56:10 2017
     13// Update Count     : 215
    1414//
    1515
     
    3333void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
    3434void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
     35
     36const char * sepGetCur( ofstream * os ) { return os->sepCur; }
     37void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; }
     38
    3539const char * sepGet( ofstream * os ) { return &(os->separator[0]); }
    3640
     
    3842        strncpy( &(os->separator[0]), s, separateSize - 1 );
    3943        os->separator[separateSize - 1] = '\0';
     44} // sepSet
     45
     46const char * sepGetTuple( ofstream * os ) { return &(os->tupleSeparator[0]); }
     47
     48void sepSetTuple( ofstream * os, const char * s ) {
     49        strncpy( &(os->tupleSeparator[0]), s, separateSize - 1 );
     50        os->tupleSeparator[separateSize - 1] = '\0';
    4051} // sepSet
    4152
     
    95106} // write
    96107
    97 int prtfmt( ofstream * os, const char fmt[], ... ) {
     108int fmt( ofstream * os, const char format[], ... ) {
    98109        va_list args;
    99         va_start( args, fmt );
    100         int len = vfprintf( (FILE *)(os->file), fmt, args );
     110        va_start( args, format );
     111        int len = vfprintf( (FILE *)(os->file), format, args );
    101112        if ( len == EOF ) {
    102113                if ( ferror( (FILE *)(os->file) ) ) {
     
    109120        sepReset( os );                                                                         // reset separator
    110121        return len;
    111 } // prtfmt
    112 
    113 
    114 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, { ' ', '\0' } };
     122} // fmt
     123
     124void ?{}( ofstream * this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {
     125        this->file = file;
     126        this->sepDefault = sepDefault;
     127        this->sepOnOff = sepOnOff;
     128        sepSet( this, separator );
     129        sepSetCur( this, sepGet( this ) );
     130        sepSetTuple( this, tupleSeparator );
     131}
     132
     133static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, " ", ", " };
    115134ofstream *sout = &soutFile;
    116 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, { ' ', '\0' } };
     135static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, " ", ", " };
    117136ofstream *serr = &serrFile;
    118137
     
    173192} // ungetc
    174193
    175 int scanfmt( ifstream * is, const char fmt[], ... ) {
     194int fmt( ifstream * is, const char format[], ... ) {
    176195        va_list args;
    177196
    178         va_start( args, fmt );
    179         int len = vfscanf( (FILE *)(is->file), fmt, args );
     197        va_start( args, format );
     198        int len = vfscanf( (FILE *)(is->file), format, args );
    180199        if ( len == EOF ) {
    181200                if ( ferror( (FILE *)(is->file) ) ) {
     
    186205        va_end( args );
    187206        return len;
    188 } // prtfmt
     207} // fmt
    189208
    190209
Note: See TracChangeset for help on using the changeset viewer.