Index: src/libcfa/fstream.c
===================================================================
--- src/libcfa/fstream.c	(revision 6ba0659196615bb32989214ed6976c448620b387)
+++ src/libcfa/fstream.c	(revision bd91e2afb6df92caef7c482fb7c8ab8a8a35bf42)
@@ -7,9 +7,9 @@
 // fstream.c -- 
 //
-// Author           : Richard C. Bilson
+// Author           : Peter A. Buhr
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Feb 17 14:03:05 2016
-// Update Count     : 76
+// Last Modified On : Mon Feb 29 18:41:10 2016
+// Update Count     : 162
 //
 
@@ -17,40 +17,53 @@
 
 extern "C" {
-#include <stdio.h>
-#include <stdlib.h>
+#include <stdio.h>										// vfprintf, vfscanf
+#include <stdlib.h>										// exit
+#include <stdarg.h>										// varargs
+#include <string.h>										// strlen
+#include <float.h>										// DBL_DIG, LDBL_DIG
+#include <complex.h>									// creal, cimag
 }
-
-struct ofstream {
-	FILE *file;
-};
 
 #define IO_MSG "I/O error "
 
+_Bool sepPrt( ofstream * os ) { return os->separate == 1; }
+void sepOn( ofstream * os ) { if ( os->separate != 2 ) os->separate = 1; }
+void sepOff( ofstream * os ) { if ( os->separate != 2 ) os->separate = 0; }
+void sepSet( ofstream * os, const char * s ) {
+	strncpy( &(os->separator[0]), s, separateSize - 1 );
+	os->separator[separateSize - 1] = '\0';
+} // sepSet
+const char * sepGet( ofstream * os ) { return &(os->separator[0]); }
+void sepDisable( ofstream *os ) { os->separate = 2; }
+void sepEnable( ofstream *os ) { os->separate = 0; }
+
 int fail( ofstream * os ) {
-	return ferror( os->file );
+	return ferror( (FILE *)(os->file) );
 } // fail
 
 int flush( ofstream * os ) {
-	return fflush( os->file );
+	return fflush( (FILE *)(os->file) );
 } // flush
 
-void open( ofstream ** os, const char * name, const char * mode ) {
-	FILE *t = fopen( name, mode );
-	if ( t == 0 ) {										// do not change unless successful
+void open( ofstream * os, const char * name, const char * mode ) {
+	FILE *file = fopen( name, mode );
+	if ( file == 0 ) {									// do not change unless successful
 		perror( IO_MSG "open output" );
 		exit( EXIT_FAILURE );
 	} // if
-	(*os)->file = t;
+	os->file = file;
+	sepOff( os );
+	sepSet( os, " " );
 } // open
 
 void close( ofstream * os ) {
-	if ( os->file == stdout || os->file == stderr ) return;
+	if ( (FILE *)(os->file) == stdout || (FILE *)(os->file) == stderr ) return;
 
-	if ( fclose( os->file ) == EOF ) {
+	if ( fclose( (FILE *)(os->file) ) == EOF ) {
 		perror( IO_MSG "close output" );
 	} // if 
 } // close
 
-ofstream * write( ofstream * os, const char * data, streamsize_type size ) {
+ofstream * write( ofstream * os, const char * data, unsigned long int size ) {
 	if ( fail( os ) ) {
 		fprintf( stderr, "attempt write I/O on failed stream\n" );
@@ -58,5 +71,5 @@
 	} // if
 
-	if ( fwrite( data, 1, size, os->file ) != size ) {
+	if ( fwrite( data, 1, size, (FILE *)(os->file) ) != size ) {
 		perror( IO_MSG "write" );
 		exit( EXIT_FAILURE );
@@ -65,34 +78,55 @@
 } // write
 
-static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_) };
+int prtfmt( ofstream * os, const char fmt[], ... ) {
+    va_list args;
+
+    va_start( args, fmt );
+    int len = vfprintf( (FILE *)(os->file), fmt, args );
+	if ( len == EOF ) {
+		if ( ferror( (FILE *)(os->file) ) ) {
+			fprintf( stderr, "invalid write\n" );
+			exit( EXIT_FAILURE );
+		} // if
+	} // if
+    va_end( args );
+	return len;
+} // prtfmt
+
+
+static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 0, { ' ', '\0' } };
 ofstream *sout = &soutFile;
-static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_) };
+static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 0, { ' ', '\0' } };
 ofstream *serr = &serrFile;
+
 
 //---------------------------------------
 
-struct ifstream {
-	FILE *file;
-};
 
 int fail( ifstream * is ) {
-	return ferror( is->file );
+	return ferror( (FILE *)(is->file) );
 } // fail
 
 int eof( ifstream * is ) {
-	return feof( is->file );
+	return feof( (FILE *)(is->file) );
 } // eof
 
-ifstream * get( ifstream * is, int * data ) {
-	if ( fscanf( is->file, "%d", data ) == EOF ) {
-		if ( ferror( is->file ) ) {
-			fprintf( stderr, "invalid int read\n" );
-			exit( EXIT_FAILURE );
-		} // if
+void open( ifstream * is, const char * name, const char * mode ) {
+	FILE *t = fopen( name, mode );
+	if ( t == 0 ) {										// do not change unless successful
+		perror( IO_MSG "open input" );
+		exit( EXIT_FAILURE );
 	} // if
-	return is;
-} // read
+	is->file = t;
+} // open
 
-ifstream * read( ifstream * is, char * data, streamsize_type size ) {
+void close( ifstream * is ) {
+	if ( (FILE *)(is->file) == stdin ) return;
+
+	if ( fclose( (FILE *)(is->file) ) == EOF ) {
+		perror( IO_MSG "close input" );
+	} // if 
+} // close
+
+ifstream * read( ifstream * is, char * data, unsigned long int size ) {
 	if ( fail( is ) ) {
 		fprintf( stderr, "attempt read I/O on failed stream\n" );
@@ -100,5 +134,5 @@
 	} // if
 
-	if ( fread( data, size, 1, is->file ) == 0 ) {
+	if ( fread( data, size, 1, (FILE *)(is->file) ) == 0 ) {
 		perror( IO_MSG "read" );
 		exit( EXIT_FAILURE );
@@ -113,5 +147,5 @@
 	} // if
 
-	if ( ungetc( c, is->file ) == EOF ) {
+	if ( ungetc( c, (FILE *)(is->file) ) == EOF ) {
 		perror( IO_MSG "ungetc" );
 		exit( EXIT_FAILURE );
@@ -120,20 +154,19 @@
 } // ungetc
 
-void open( ifstream ** is, const char * name, const char * mode ) {
-	FILE *t = fopen( name, mode );
-	if ( t == 0 ) {										// do not change unless successful
-		perror( IO_MSG "open input" );
-		exit( EXIT_FAILURE );
+int scanfmt( ifstream * is, const char fmt[], ... ) {
+    va_list args;
+
+    va_start( args, fmt );
+    int len = vfscanf( (FILE *)(is->file), fmt, args );
+	if ( len == EOF ) {
+		if ( ferror( (FILE *)(is->file) ) ) {
+			fprintf( stderr, "invalid read\n" );
+			exit( EXIT_FAILURE );
+		} // if
 	} // if
-	(*is)->file = t;
-} // open
+    va_end( args );
+	return len;
+} // prtfmt
 
-void close( ifstream * is ) {
-	if ( is->file == stdin ) return;
-
-	if ( fclose( is->file ) == EOF ) {
-		perror( IO_MSG "close input" );
-	} // if 
-} // close
 
 static ifstream sinFile = { (FILE *)(&_IO_2_1_stdin_) };
