int main( int argc, char *argv[] ) { #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( EXIT_FAILURE ); } #endif /*** Initialize ***/ strcpy( ProgramName, strlwr( argv[0] ) ); /* store filename */ /*** Test various safe functions ***/ TestMove_s(); TestError_s(); /*** Print a pass/fail message and quit ***/ if( NumErrors != 0 ) { printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); return( EXIT_FAILURE ); } printf( "Tests completed (%s).\n", ProgramName ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", ProgramName ); fclose( my_stdout ); _dwShutDown(); #endif return( EXIT_SUCCESS ); }
int main( int argc, char **argv ) { #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( -1 ); } #endif OutputFloatSeries(); putchar('\n'); OutputDoubleSeries(); #ifdef _LONG_DOUBLE_ putchar('\n'); OutputLongDoubleSeries(); #endif printf( "Tests completed (%s).\n", strlwr( argv[0] ) ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", strlwr( argv[0] ) ); fclose( my_stdout ); _dwShutDown(); #endif return 0; }
void main( int argc, char *argv[] ) { int exitcode; /*** Initialize ***/ #ifdef __SW_BW FILE * my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( -1 ); } #endif strcpy( ProgramName, strlwr(argv[0]) ); /* store executable filename */ if( _setmbcp( 932 ) != 0 ) { printf( "Cannot initialize code page.\n\n" ); exit( EXIT_FAILURE ); } /***********************************************************************/ /* set constraint-handler */ /***********************************************************************/ set_constraint_handler_s( my_constraint_handler ); /*** Test various functions ***/ TestToWide(); /* conversion to wide chars */ TestFromWide(); /* conversion from wide chars */ TestAddendum(); /* Normative Addendum stuff */ /*** Print a pass/fail message and quit ***/ if( NumErrors == 0 ) { printf( "%s: SUCCESS.\n", ProgramName ); #ifdef __SW_BW fprintf( stderr, "%s: SUCCESS.\n", ProgramName ); #endif exitcode = EXIT_SUCCESS; } else { printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); #ifdef __SW_BW fprintf( stderr, "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); #endif exitcode = EXIT_FAILURE; } #ifdef __SW_BW fclose( my_stdout ); _dwShutDown(); #endif exit( exitcode ); }
int main( int argc, char **argv ) { FILE *my_stdout; strcpy( ProgramName, strlwr( argv[0] ) ); /* store filename */ my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( EXIT_FAILURE ); } printf( "Tests completed (%s).\n", ProgramName ); fprintf( stderr, "Tests completed (%s).\n", ProgramName ); fclose( my_stdout ); _dwShutDown(); return( EXIT_SUCCESS ); }
int main( int argc, char *argv[] ) { #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( -1 ); } #endif /*** Initialize ***/ strcpy( ProgramName, strlwr( argv[0] ) ); /* store filename */ /*** Test various functions ***/ TestCompare(); /* compare stuff */ TestMove(); /* moving data about */ TestCase(); /* upper/lowercase stuff */ TestSearch(); /* searching stuff */ TestSubstring(); /* substring stuff */ TestToken(); /* tokenizing stuff */ TestLocale(); /* locale stuff */ TestError(); /* error string stuff */ TestFormatted(); /* formatted I/O stuff */ TestBounded(); /* bounded string stuff */ #ifdef __X86__ TestCompareF(); TestMoveF(); TestCaseF(); TestSearchF(); TestSubstringF(); TestTokenF(); #endif /*** Print a pass/fail message and quit ***/ if( NumErrors != 0 ) { printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); return( EXIT_FAILURE ); } printf( "Tests completed (%s).\n", strlwr( argv[0] ) ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", strlwr( argv[0] ) ); fclose( my_stdout ); _dwShutDown(); #endif return( 0 ); }
int main( int argc, char *argv[] ) /********************************/ { #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( -1 ); } #endif /*** Initialize ***/ strcpy( ProgramName, strlwr( argv[0] ) ); /* store filename */ /****************************/ /* set constraint-handler */ /****************************/ set_constraint_handler_s( my_constraint_handler ); /******************/ /* Start of tests */ /******************/ Test_scan_wide(); Test_print_wide(); /****************/ /* End of tests */ /****************/ /*** Print a pass/fail message and quit ***/ if( NumErrors != 0 ) { printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); return( EXIT_FAILURE ); } wprintf( L"Tests completed (%hs).\n", strlwr( argv[0] ) ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", strlwr( argv[0] ) ); fclose( my_stdout ); _dwShutDown(); #endif return( 0 ); }
int main( int argc, char * const argv[] ) { #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( EXIT_FAILURE ); } #endif ( void )argc; /* Unused */ /*** Initialize ***/ strcpy( ProgramName, argv[0] ); /* store filename */ strlwr( ProgramName ); /* and lower case it */ strcpy( myfile, __FILE__ ); strlwr( myfile ); /***************************************************************************/ /* Test Safer C Library time routines */ /***************************************************************************/ /***********************************************************************/ /* set constraint-handler */ /***********************************************************************/ set_constraint_handler_s( my_constraint_handler ); testtime_s(); /*** Print a pass/fail message and quit ***/ if( NumErrors != 0 ) { printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); return( EXIT_FAILURE ); } printf( "Tests completed (%s).\n", ProgramName ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", ProgramName ); fclose( my_stdout ); _dwShutDown(); #endif return( EXIT_SUCCESS ); }
int main( int argc, char *argv[] ) /********************************/ { #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( -1 ); } #endif /*** Initialize ***/ strcpy( ProgramName, strlwr( argv[0] ) ); /* store filename */ /**** Start of Tests ****/ /***********************************************************************/ /* set constraint-handler */ /***********************************************************************/ set_constraint_handler_s( my_constraint_handler ); test_bsearch_s(); test_qsort_s(); /**** End of Tests ****/ //Status_Print( ); printf( "Tests completed (%s).\n", ProgramName ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", ProgramName ); fclose( my_stdout ); _dwShutDown(); #endif return( 0 ); }
int __F_NAME( main, wmain )( int argc, const CHAR_TYPE * const * const argv ) { #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); return( EXIT_FAILURE ); } #endif // Initialize (void) __F_NAME( strcpy, wcscpy )( ProgramName, argv[0] ); // store filename (void) __F_NAME( strlwr, _wcslwr )( ProgramName ); // and lower case it (void) strcpy( SrcFILE, __FILE__ ), (void) strlwr( SrcFILE ); // lowered __FILE__ (void) argc; // Unused // This was causing a crash in the multi-threaded 16-bit OS/2 runtime. // This test program relies far too much on clib internals but probably // isn't worth "fixing" properly. // __F_NAME( __Fini_Argv, __wFini_Argv )(); // Release allocated data // tryanalysis( __LINE__, 0, 0, 0 ); // Fails as _Lp* can't be NULL // Program name and no arguments tryanalysis( __LINE__, 0, TAGSTR( "hello" ), TAGSTR( "" ), 1); // one argument tryanalysis( __LINE__, 0, TAGSTR( "hello" ), TAGSTR( "world" ), 2, TAGSTR( "world" ) ); // argument-enclosing whitespace is ignored tryanalysis( __LINE__, 0, TAGSTR( "2 params" ), TAGSTR( " \thello \tworld \t" ), 3, TAGSTR( "hello" ), TAGSTR( "world" ) ); // quotes at both ends tryanalysis( __LINE__, 0, TAGSTR( "1 arg" ), TAGSTR( "\"hello world\"" ), 2, TAGSTR( "hello world" ) ); // Lost closing quote ignored tryanalysis( __LINE__, 0, TAGSTR( "1 arg" ), TAGSTR( "\"hello world" ), 2, TAGSTR( "hello world" ) ); // opening quote not at start tryanalysis( __LINE__, 0, TAGSTR( "1 arg" ), TAGSTR( "hell\"o world" ), 2, TAGSTR( "hello world" ) ); // quotes away from both ends tryanalysis( __LINE__, 0, TAGSTR( "1 arg" ), TAGSTR( "hell\"o w\"orld" ), 2, TAGSTR( "hello world" ) ); // Check historical behaviour // quotes at both ends tryanalysis( __LINE__, 1, TAGSTR( "1 arg" ), TAGSTR( "\"hello world\"" ), 2, TAGSTR( "hello world" ) ); // Lost closing quote ignored tryanalysis( __LINE__, 1, TAGSTR( "1 arg" ), TAGSTR( "\"hello world" ), 2, TAGSTR( "hello world" ) ); // opening quote not at start tryanalysis( __LINE__, 1, TAGSTR( "1 arg" ), TAGSTR( "hell\"o world" ), 3, TAGSTR( "hell\"o" ), TAGSTR( "world" ) ); // quotes away from both ends tryanalysis( __LINE__, 1, TAGSTR( "2 args" ), TAGSTR( "hell\"o w\"orld" ), 3, TAGSTR( "hell\"o" ), TAGSTR( "w\"orld" ) ); // backslash usage tryanalysis( __LINE__, 0, TAGSTR( "2 args" ), TAGSTR( "hell\\\"o w\\o\"rld wars" ), 3, TAGSTR( "hell\"o" ), TAGSTR( "w\\orld wars" ) ); tryanalysis( __LINE__, 1, TAGSTR( "3 args" ), TAGSTR( "hell\\\"o w\\o\"rld wars" ), 4, TAGSTR( "hell\"o" ), TAGSTR( "w\\o\"rld" ), TAGSTR( "wars" ) ); test_long_jump( __LINE__ ); /*** Print a pass/fail message and quit ***/ if( NumErrors != 0 ) { printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); return( EXIT_FAILURE ); } printf( "Tests completed (%s).\n", ProgramName ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", ProgramName ); fclose( my_stdout ); _dwShutDown(); #endif return( EXIT_SUCCESS ); }
void main( int argc, char *argv[] ) { CHAR_TYPE *cwd; CHAR_TYPE buffer[256], buffer2[256]; int ctr; FILE *fp; _tDIR *dirp; struct dirent *direntp; unsigned checkbits = 0; unsigned save_checkbits; #ifdef __SW_BW FILE *my_stdout; my_stdout = __F_NAME(freopen,_wfreopen)( STRING( "tmp.log" ), STRING( "a" ), stdout ); VERIFY( my_stdout != NULL ); #endif /*** Convert multi-byte name to wide char name ***/ #ifdef MBYTE_NAMES mbstowcs( TmpDir, "_TMP\x90\x92\x90\x90", 9 ); mbstowcs( TmpFilePrefix, "TMP_\x90\x90\x90\x92", 9 ); #endif VERIFY( ( cwd = __F_NAME(getcwd,_wgetcwd)( NULL, 0 ) ) != NULL ); VERIFY( __F_NAME(getcwd,_wgetcwd)( buffer, 256 ) != NULL ); VERIFY( __F_NAME(strcmp,wcscmp)( buffer, cwd ) == 0 ); free( cwd ); #ifdef __UNIX__ #else VERIFY( __F_NAME(mkdir,_wmkdir)( TMPDIR ) == 0 ); #endif VERIFY( __F_NAME(chdir,_wchdir)( TMPDIR ) == 0 ); VERIFY( ( cwd = __F_NAME(getcwd,_wgetcwd)( NULL, 0 ) ) != NULL ); if( buffer[__F_NAME(strlen,wcslen)(buffer)-1] != '\\' ) { __F_NAME(strcat,wcscat)( buffer, STRING( "\\" ) ); } __F_NAME(strcat,wcscat)( buffer, TMPDIR ); VERIFY( __F_NAME(strcmp,wcscmp)( buffer, cwd ) == 0 ); free( cwd ); for( ctr = 0; ctr < NUM_OPEN; ++ctr ) { __F_NAME(strcpy,wcscpy)( buffer, TMPFILEPREFIX ); __F_NAME(strcat,wcscat)( buffer, STRING( "." ) ); __F_NAME(itoa,_witoa)( ctr, buffer2, 10 ); __F_NAME(strcat,wcscat)( buffer, buffer2 ); fp = __F_NAME(fopen,_wfopen)( buffer, STRING( "w" ) ); if( fp == NULL ) { __F_NAME(printf,wprintf)( STRING( "INTERNAL: fopen failed\n" ) ); abort(); } checkbits |= ( 1 << ctr ); fclose( fp ); } VERIFY( __F_NAME(chdir,_wchdir)( STRING( ".." ) ) == 0 ); __F_NAME(strcpy,wcscpy)( buffer, TMPDIR ); __F_NAME(strcat,wcscat)( buffer, "\\" ); __F_NAME(strcat,wcscat)( buffer, TMPFILEPREFIX ); __F_NAME(strcat,wcscat)( buffer, ".*" ); save_checkbits = checkbits; /* Open the directory using a wildcard pattern. */ VERIFY( ( dirp = __F_NAME(opendir,_wopendir)( buffer ) ) != NULL ); for( ctr = 0;; ++ctr ) { direntp = __F_NAME(readdir,_wreaddir)( dirp ); if( direntp == NULL ) break; __F_NAME(strcpy,wcscpy)( buffer, TMPFILEPREFIX ); __F_NAME(strcat,wcscat)( buffer, STRING( "." ) ); __F_NAME(itoa,_witoa)( ctr, buffer2, 10 ); __F_NAME(strcat,wcscat)( buffer, buffer2 ); VERIFY( __F_NAME(strcmp,wcscmp)(buffer,direntp->d_name) == 0 ); checkbits &= ~( 1 << ctr ); } VERIFY( checkbits == 0 ); // If not, readdir() didn't report all files __F_NAME(rewinddir,_wrewinddir)( dirp ); checkbits = save_checkbits; for( ctr = 0;; ++ctr ) { direntp = __F_NAME(readdir,_wreaddir)( dirp ); if( direntp == NULL ) break; __F_NAME(strcpy,wcscpy)( buffer, TMPFILEPREFIX ); __F_NAME(strcat,wcscat)( buffer, STRING( "." ) ); __F_NAME(itoa,_witoa)( ctr, buffer2, 10 ); __F_NAME(strcat,wcscat)( buffer, buffer2 ); VERIFY( __F_NAME(strcmp,wcscmp)(buffer,direntp->d_name) == 0 ); checkbits &= ~( 1 << ctr ); } VERIFY( checkbits == 0 ); // If not, readdir() didn't report all files VERIFY( __F_NAME(closedir,_wclosedir)( dirp ) == 0 ); /* Open the directory itself, no pattern. */ VERIFY( ( dirp = __F_NAME(opendir,_wopendir)( TMPDIR ) ) != NULL ); checkbits = save_checkbits; ctr = 0; direntp = __F_NAME(readdir,_wreaddir)( dirp ); while( direntp ) { /* Skip '.' and '..' entries. */ if( direntp->d_name[0] != '.' ) { __F_NAME(strcpy,wcscpy)( buffer, TMPFILEPREFIX ); __F_NAME(strcat,wcscat)( buffer, STRING( "." ) ); __F_NAME(itoa,_witoa)( ctr, buffer2, 10 ); __F_NAME(strcat,wcscat)( buffer, buffer2 ); VERIFY( __F_NAME(strcmp,wcscmp)(buffer,direntp->d_name) == 0 ); checkbits &= ~( 1 << ctr ); ++ctr; } direntp = __F_NAME(readdir,_wreaddir)( dirp ); } VERIFY( checkbits == 0 ); // If not, readdir() didn't report all files VERIFY( __F_NAME(closedir,_wclosedir)( dirp ) == 0 ); VERIFY( __F_NAME(rmdir,_wrmdir)( TMPDIR ) == -1 ); // Should == -1; TMPDIR non-empty VERIFY( __F_NAME(chdir,_wchdir)( TMPDIR ) == 0 ); for( ctr = 0; ctr < NUM_OPEN; ++ctr ) { __F_NAME(strcpy,wcscpy)( buffer, TMPFILEPREFIX ); __F_NAME(strcat,wcscat)( buffer, STRING( "." ) ); __F_NAME(itoa,_witoa)( ctr, buffer2, 10 ); __F_NAME(strcat,wcscat)( buffer, buffer2 ); if( __F_NAME(remove,_wremove)( buffer ) != 0 ) { __F_NAME(printf,wprintf)( STRING( "INTERNAL: remove() failed\n" ) ); abort(); } } VERIFY( __F_NAME(chdir,_wchdir)( STRING( ".." ) ) == 0 ); VERIFY( __F_NAME(rmdir,_wrmdir)( TMPDIR ) == 0 ); VERIFY( __F_NAME(chdir,_wchdir)( TMPDIR ) != 0 ); printf( "Tests completed (%s).\n", strlwr( argv[0] ) ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", strlwr( argv[0] ) ); fclose( my_stdout ); _dwShutDown(); #endif exit( 0 ); }
intstar4 __fortran DWFSHUTDOWN( void ) { //=========================================== return( _dwShutDown() ); }
void main( int argc, char *argv[] ) { char filename[NUM_FILES][L_tmpnam_s]; FILE *fp; int ctr, ctr2; struct stat info; errno_t rc; int violations = NumViolations; #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( -1 ); } #endif argc=argc; /*** Initialize ***/ strcpy( ProgramName, strlwr( argv[0] ) ); /* store filename */ /***********************************************************************/ /* set constraint-handler */ /***********************************************************************/ set_constraint_handler_s( my_constraint_handler ); /* test runtime constraints */ rc = tmpnam_s( NULL, sizeof( filename[0] ) ); VERIFYS( rc != 0 ); VERIFYS( NumViolations == ++violations ); filename[0][0] = 'x'; rc = tmpnam_s( filename[0], 0 ); VERIFYS( rc != 0 ); VERIFYS( filename[0][0] == 'x' ); VERIFYS( NumViolations == ++violations ); rc = tmpnam_s( filename[0], 4 ); /* only space for .aaa */ VERIFYS( rc != 0 ); VERIFYS( filename[0][0] == '\0' ); VERIFYS( NumViolations == ++violations ); for( ctr = 0; ctr < NUM_FILES; ++ctr ) { rc = tmpnam_s( filename[ctr], sizeof( filename[0] ) ); VERIFYS( rc == 0 ); VERIFY( remove( filename[ctr] ) != 0 ); // remove should fail VERIFY( errno == ENOENT ); for( ctr2 = 0; ctr2 < ctr; ++ctr2 ) { VERIFY( strcmp( filename[ctr], filename[ctr2] ) != 0 ); // Make sure all tmpfiles are unique } } VERIFY( utime( filename[0], NULL ) == -1 ); EXPECT( errno == ENOENT ); for( ctr = 0; ctr < 2; ++ctr ) { if( ( fp = fopen( filename[ctr], "w" ) ) == NULL ) { fprintf( stderr, "Internal: fopen() failed\n" ); perror( filename[ctr] ); exit( -1 ); } fclose( fp ); } #ifndef __UNIX__ // rename is allowed VERIFY( rename( filename[0], filename[1] ) != 0 ); // rename should fail EXPECT( (errno == EACCES)||(errno == EEXIST) ); #endif VERIFY( rename( filename[0], filename[2] ) == 0 ); VERIFY( remove( filename[0] ) != 0 ); // filename[0] was renamed -> DNE EXPECT( errno == ENOENT ); VERIFY( remove( filename[2] ) == 0 ); VERIFY( access( filename[2], F_OK ) == -1 );// filename[2] was removed EXPECT( errno == ENOENT ); VERIFY( access( filename[1], F_OK ) == 0 ); // filename[1] is still here VERIFY( access( filename[1], R_OK ) == 0 ); // read permission VERIFY( access( filename[1], W_OK ) == 0 ); // write permission VERIFY( access( argv[0], X_OK ) == 0 ); // execute permission VERIFY( chmod( filename[1], S_IRUSR | S_IRGRP ) == 0 ); // filename[1] is now read-only VERIFY( access( filename[1], W_OK ) == -1 ); EXPECT( errno == EACCES ); #if !defined( __UNIX__ ) && !defined( __RDOS__ ) // remove would succeed VERIFY( remove( filename[1] ) != 0 ); EXPECT( errno == EACCES ); #endif VERIFY( chmod( filename[1], S_IRWXU | S_IRWXG ) == 0 ); VERIFY( stat( filename[1], &info ) == 0 ); #ifndef __UNIX__ EXPECT( 0 <= info.st_dev && info.st_dev < 26 ); #endif VERIFY( utime( filename[1], NULL ) == 0 ); VERIFY( remove( filename[1] ) == 0 ); printf( "Tests completed (%s).\n", strlwr( argv[0] ) ); if( warnings ) { printf( "Total number of warning(s) = %d.\n", warnings ); exit( -1 ); } #ifdef __SW_BW { fprintf( stderr, "Tests completed (%s).\n", strlwr( argv[0] ) ); fclose( my_stdout ); _dwShutDown(); } #endif exit( 0 ); }