src/files.c
int stream_open(FILE **stream, FILE *default_stream, 
		char *filename, char *mode) {
	if ( filename == NULL ) {
		*stream = default_stream;
	} else {
		debug("Opening %s with mode %s.\n", filename, mode);
		*stream = fopen(filename, mode);

		if ( *stream == NULL ) {
			error("Could not open %s with mode %s.\n", filename, mode);
			return(-1);
		}
	}

	return(0);
}
/* 
 * In each program, files must be opened and closed, either as references to
 * a file in the system or as stdin/stdout. By default, stdin/stdout are used,
 * so we put the logic to check whether we are opening a file or stream here.
 */
In each program, files must be opened and closed, either as references to
a file in the system or as stdin/stdout. By default, stdin/stdout are used,
so we put the logic to check whether we are opening a file or stream here.
In each program files must be opened and closed either as references to a file in the system or as stdin / stdout . By default stdin / stdout are used so we put the logic to check whether we are opening a file or stream here .
int stream_open(FILE **stream, FILE *default_stream, 
		char *filename, char *mode) {
	if ( filename == NULL ) {
		*stream = default_stream;
	} else {
		debug("Opening %s with mode %s.\n", filename, mode);
		*stream = fopen(filename, mode);
		if ( *stream == NULL ) {
			error("Could not open %s with mode %s.\n", filename, mode);
			return(-1);
		}
	}
	return(0);
}
int stream_open ( FILE * * stream , FILE * default_stream , char * filename , char * mode ) { if ( filename == NULL ) { * stream = default_stream ; } else { debug ( " \n " , filename , mode ) ; * stream = fopen ( filename , mode ) ; if ( * stream == NULL ) { error ( " \n " , filename , mode ) ; return ( -1 ) ; } } return ( 0 ) ; }
In each program, files must be opened and closed, either as references to
 a file in the system or as stdin/stdout.
In each program files must be opened and closed either as references to a file in the system or as stdin / stdout .