# All header files of the project
HDRFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.h")
# All .c files in functions/_PDCLIB that do not have a regression test driver
-INTFILES := _Exit atomax digits open print scan remove rename seed stdinit strtox_main strtox_prelim filemode eol errno seek prepread prepwrite allocpages tmpfilename
+INTFILES := _Exit atomax digits open print scan remove rename seed stdinit strtox_main strtox_prelim filemode eol errno seek prepread prepwrite allocpages tmpfilename closeall
# All object files in the library
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
# All test drivers (.t)
--- /dev/null
+/* $Id$ */
+
+/* _PDCLIB_closeall( void )
+
+ This file is part of the Public Domain C Library (PDCLib).
+ Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#include <stdio.h>
+
+extern struct _PDCLIB_file_t * _PDCLIB_filelist;
+
+void _PDCLIB_closeall( void )
+{
+ struct _PDCLIB_file_t * stream = _PDCLIB_filelist;
+ struct _PDCLIB_file_t * next;
+ while ( stream != NULL )
+ {
+ next = stream->next;
+ fclose( stream );
+ stream = next;
+ }
+}
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+ TESTCASE( NO_TESTDRIVER );
+ return TEST_RESULTS;
+}
+
+#endif
+
*/
#define NUMBER_OF_SLOTS 40
-void (*_PDCLIB_regstack[ NUMBER_OF_SLOTS ])( void );
+void (*_PDCLIB_regstack[ NUMBER_OF_SLOTS ])( void ) = { _PDCLIB_closeall };
size_t _PDCLIB_regptr = NUMBER_OF_SLOTS;
void exit( int status )
*/
int _PDCLIB_prepwrite( struct _PDCLIB_file_t * stream );
+/* Closing all streams on program exit */
+void _PDCLIB_closeall( void );
+
/* -------------------------------------------------------------------------- */
/* errno */
/* -------------------------------------------------------------------------- */