]> pd.if.org Git - pdclib/blobdiff - functions/_PDCLIB/filemode.c
PDCLIB-15 PDCLIB-16:
[pdclib] / functions / _PDCLIB / filemode.c
index 0e293aba2cfc55a6a4f1487b569b20efb8cd70c7..c6066f899b13552edc46173bfbceb032b8e26e32 100644 (file)
@@ -8,12 +8,16 @@
 
 #include <stddef.h>
 
+#ifndef REGTEST
+#include <_PDCLIB_io.h>
 /* Helper function that parses the C-style mode string passed to fopen() into
    the PDCLib flags FREAD, FWRITE, FAPPEND, FRW (read-write) and FBIN (binary
    mode).
 */
 unsigned int _PDCLIB_filemode( char const * const mode )
 {
+    if(!mode) return 0;
+
     unsigned rc = 0;
     switch ( mode[0] )
     {
@@ -53,12 +57,14 @@ unsigned int _PDCLIB_filemode( char const * const mode )
     /* Longer than three chars - invalid. */
     return 0;
 }
+#endif
 
 #ifdef TEST
 #include <_PDCLIB_test.h>
 
 int main( void )
 {
+#ifndef REGTEST
     TESTCASE( _PDCLIB_filemode( "r" ) == _PDCLIB_FREAD );
     TESTCASE( _PDCLIB_filemode( "w" ) == _PDCLIB_FWRITE );
     TESTCASE( _PDCLIB_filemode( "a" ) == ( _PDCLIB_FAPPEND | _PDCLIB_FWRITE ) );
@@ -78,6 +84,7 @@ int main( void )
     TESTCASE( _PDCLIB_filemode( "r++" ) == 0 );
     TESTCASE( _PDCLIB_filemode( "wbb" ) == 0 );
     TESTCASE( _PDCLIB_filemode( "a+bx" ) == 0 );
+#endif
     return TEST_RESULTS;
 }