which included commits to RCS files with non-trunk default branches. git-svn-id: svn://10.65.10.50/trunk@976 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			1211 lines
		
	
	
		
			28 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1211 lines
		
	
	
		
			28 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
/* t4data.c   (c)Copyright Sequiter Software Inc., 1990-1994.  All rights reserved. */
 | 
						|
/* Test data file and field routines */
 | 
						|
 | 
						|
#include "d4all.h"
 | 
						|
#ifndef S4UNIX
 | 
						|
#include <conio.h>
 | 
						|
#endif
 | 
						|
#ifdef __TURBOC__
 | 
						|
#pragma hdrstop
 | 
						|
#endif
 | 
						|
 | 
						|
#include "t4test.h"
 | 
						|
 | 
						|
CODE4 cb ;
 | 
						|
DATA4 *test, *test2 ;
 | 
						|
FIELD4 *name, *num, *num2, *flt, *dt, *logic ;
 | 
						|
 | 
						|
#ifndef S4WINDOWS
 | 
						|
void d4low_test(void) ;
 | 
						|
#endif
 | 
						|
 | 
						|
static FIELD4INFO field_info[] =
 | 
						|
{
 | 
						|
{ "NAME",  'C', 20, 0 },
 | 
						|
{ "NUM",   'N',  5, 2 },
 | 
						|
{ "NUM2",  'N',  1, 0 },
 | 
						|
{ "FLT",   'F', 17, 0 },
 | 
						|
{ "DT",    'D',  8, 0 },
 | 
						|
{ "LOGIC",   'L',  1, 0 },
 | 
						|
{ 0, 0, 0, 0 },
 | 
						|
} ;
 | 
						|
 | 
						|
static int check_record( D4DISPLAY *display, DATA4 *data )
 | 
						|
{
 | 
						|
  double d ;
 | 
						|
  long l ;
 | 
						|
 | 
						|
  if ( d4display_quit( display ) )
 | 
						|
    return 1 ;
 | 
						|
 | 
						|
  name = d4field( data,  "NAME" ) ;
 | 
						|
  num = d4field( data, "NUM" ) ;
 | 
						|
  num2 = d4field( data, "NUM2" ) ;
 | 
						|
  flt = d4field( data, "FLT"  ) ;
 | 
						|
  dt  = d4field( data, "DT" ) ;
 | 
						|
  logic = d4field( data,  "LOGIC" ) ;
 | 
						|
 | 
						|
  if ( name == 0 || num == 0 || num2 == 0 || flt == 0 || dt == 0 || logic == 0 )
 | 
						|
    t4severe( t4err_field, "01" ) ;
 | 
						|
 | 
						|
  if ( memcmp( f4str(name), "Test Name           ", 20) )
 | 
						|
    t4severe( t4err_field, "02" ) ;
 | 
						|
 | 
						|
  f4double2( num, &d ) ;
 | 
						|
  if ( d != 14.3 )
 | 
						|
    t4severe( t4err_field, "03" ) ;
 | 
						|
 | 
						|
  l = f4long( num2 ) ;
 | 
						|
  if ( l != 1L )
 | 
						|
    t4severe( t4err_field, "04" ) ;
 | 
						|
 | 
						|
  l = f4long( flt ) ;
 | 
						|
  if ( l != 182L )
 | 
						|
    t4severe( t4err_field, "05" ) ;
 | 
						|
 | 
						|
  if ( memcmp( f4str( dt ), "19901012", 8 ) )
 | 
						|
    t4severe( t4err_field, "06" ) ;
 | 
						|
 | 
						|
  if ( ! f4true( logic ) )
 | 
						|
    t4severe( t4err_field, "07" ) ;
 | 
						|
 | 
						|
  return 0 ;
 | 
						|
}
 | 
						|
 | 
						|
static void check_count( DATA4 *data, long count )
 | 
						|
{
 | 
						|
  if ( d4reccount( data ) != count )
 | 
						|
    t4severe( t4err_count, "08" ) ;
 | 
						|
}
 | 
						|
 | 
						|
static void check_data( D4DISPLAY *display, DATA4 *data )
 | 
						|
{
 | 
						|
  long count, r ;
 | 
						|
 | 
						|
  count = d4reccount( data ) ;
 | 
						|
 | 
						|
  for ( r = 1L ; r <= count ; r++ )
 | 
						|
  {
 | 
						|
    if ( d4go( data, (long)r ) != 0 )
 | 
						|
      t4severe( t4err_go, "09" ) ;
 | 
						|
    check_record( display, data ) ;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
static int test_data( D4DISPLAY *display, int do_open )
 | 
						|
{
 | 
						|
  cb.safety = 0 ;
 | 
						|
  cb.auto_open = 0 ;
 | 
						|
 | 
						|
  if (do_open)
 | 
						|
  {
 | 
						|
    d4display_str( display,  "        Opening T4DATA.  ", 1 ) ;
 | 
						|
    test = d4open( &cb, "T4Data" ) ;
 | 
						|
    if ( d4zap( test, 1L, d4reccount( test ) ) != 0 )
 | 
						|
      t4severe( t4err_count, "10" ) ;
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    d4display_str( display,  "        Creating T4DATA.  ", 1 ) ;
 | 
						|
    test = d4create( &cb, "T4Data", field_info, 0 ) ;
 | 
						|
  }
 | 
						|
  
 | 
						|
  if ( test == 0 )
 | 
						|
    t4severe( t4err_data, "11" ) ;
 | 
						|
 | 
						|
  d4close( test ) ;
 | 
						|
  test = d4open( &cb, "T4Data" ) ;
 | 
						|
  if ( test == 0 )
 | 
						|
    t4severe( t4err_data, "11B" ) ;
 | 
						|
 | 
						|
  d4opt_start( &cb ) ;
 | 
						|
 | 
						|
  name = d4field( test,  "NAME" ) ;
 | 
						|
  num = d4field( test, "NUM" ) ;
 | 
						|
  num2 = d4field( test, "NUM2" ) ;
 | 
						|
  flt = d4field( test, "FLT"  ) ;
 | 
						|
  dt = d4field( test, "DT" ) ;
 | 
						|
  logic  = d4field( test,  "LOGIC" ) ;
 | 
						|
  if ( name == 0 || num == 0 || num2 == 0 || flt == 0 || dt == 0 || logic == 0 )
 | 
						|
    t4severe( t4err_field, "12" ) ;
 | 
						|
 | 
						|
  if ( d4append_blank( test ) != 0 )
 | 
						|
    t4severe( t4err_append_blank, "13" ) ;
 | 
						|
  f4assign( name , "Test Name" ) ;
 | 
						|
  f4assign_double( num , 14.3 ) ;
 | 
						|
  f4assign_int( num2, 1 ) ;
 | 
						|
  f4assign_double( flt, 182.0 ) ;
 | 
						|
  f4assign( dt, "19901012" ) ;
 | 
						|
  f4assign_char( logic , 'Y' ) ;
 | 
						|
 | 
						|
  if ( check_record( display, test ) )
 | 
						|
    return 1 ;
 | 
						|
  check_count( test, 1L ) ;
 | 
						|
  if ( d4write( test, 1L ) != 0 )
 | 
						|
    t4severe( t4err_write, "14" ) ;
 | 
						|
  if ( d4close( test ) != 0 )
 | 
						|
    t4severe( t4err_close, "15" ) ;
 | 
						|
 | 
						|
  test = d4open( &cb, "T4Data" ) ;
 | 
						|
  check_count( test, 1L ) ;
 | 
						|
  if ( d4go( test, 1L ) != 0 )
 | 
						|
    t4severe( t4err_go, "16" ) ;
 | 
						|
  if ( check_record( display, test ) )
 | 
						|
    return 1 ;
 | 
						|
 | 
						|
  if ( d4write( test,  1L ) != 0 )
 | 
						|
    t4severe( t4err_write, "17" ) ;
 | 
						|
  check_count( test, 1L ) ;
 | 
						|
  if ( check_record( display, test ) )
 | 
						|
    return 1 ;
 | 
						|
 | 
						|
  d4display_str( display,  "        Appending Records.  ", 1 ) ;
 | 
						|
 | 
						|
  if ( d4lock_append( test ) != 0 )
 | 
						|
    t4severe( t4err_lock, "18" ) ;
 | 
						|
  if ( d4append_data( test ) != 0 )
 | 
						|
    t4severe( t4err_append, "19" ) ;
 | 
						|
  d4update_header( test, 1, 1 ) ;  /* update reccount */
 | 
						|
  if ( d4append_data( test ) != 0 )
 | 
						|
    t4severe( t4err_append, "20" ) ;
 | 
						|
  d4update_header( test, 1, 1 ) ;  /* update reccount */
 | 
						|
  if ( d4append_data( test ) != 0 )
 | 
						|
    t4severe( t4err_append, "21" ) ;
 | 
						|
  d4update_header( test, 1, 1 ) ;  /* update reccount */
 | 
						|
  if ( d4append_data( test ) != 0 )
 | 
						|
    t4severe( t4err_append, "22" ) ;
 | 
						|
  d4update_header( test, 1, 1 ) ;  /* update reccount */
 | 
						|
  if ( d4unlock_append( test ) != 0 )
 | 
						|
    t4severe( t4err_unlock, "23" ) ;
 | 
						|
  check_count( test, 5L ) ;
 | 
						|
  check_data( display, test ) ;
 | 
						|
 | 
						|
  if ( d4close( test ) != 0 )
 | 
						|
    t4severe( t4err_close, "24" ) ;
 | 
						|
  test = d4open( &cb, "T4Data" ) ;
 | 
						|
 | 
						|
  if ( test == 0 )
 | 
						|
    t4severe( t4err_data, "25" ) ;
 | 
						|
 | 
						|
  check_count( test, 5L ) ;
 | 
						|
  check_data( display, test ) ;
 | 
						|
 | 
						|
  if ( d4go( test, 1L ) != 0 )
 | 
						|
    t4severe( t4err_go, "26" ) ;
 | 
						|
  d4delete( test ) ;
 | 
						|
  if ( d4write( test, 1L ) != 0 )
 | 
						|
    t4severe( t4err_write, "27" ) ;
 | 
						|
 | 
						|
  if ( d4go( test, 3L ) != 0 )
 | 
						|
    t4severe( t4err_go, "28" ) ;
 | 
						|
  d4delete( test ) ;
 | 
						|
  if ( d4write( test, 3L ) != 0 )
 | 
						|
    t4severe( t4err_write, "29" ) ;
 | 
						|
 | 
						|
  if ( d4go( test, 5L ) != 0 )
 | 
						|
    t4severe( t4err_go, "30" ) ;
 | 
						|
  d4delete( test ) ;
 | 
						|
  if ( d4write( test, 5L ) != 0 )
 | 
						|
    t4severe( t4err_write, "31" ) ;
 | 
						|
  if ( d4recno( test ) != 5L )
 | 
						|
    t4severe( t4err_recno, "32" ) ;
 | 
						|
 | 
						|
  if ( d4go( test, 3L ) != 0 )
 | 
						|
    t4severe( t4err_go, "33" ) ;
 | 
						|
  if ( ! d4deleted( test ) )
 | 
						|
    t4severe( t4err_deleted, "34" ) ;
 | 
						|
  d4recall( test ) ;
 | 
						|
  if ( d4deleted( test ) )
 | 
						|
    t4severe( t4err_deleted, "35" ) ;
 | 
						|
  if ( d4write( test, 3L ) != 0 )
 | 
						|
    t4severe( t4err_write, "36" ) ;
 | 
						|
 | 
						|
  if ( d4pack( test ) !=0 )
 | 
						|
    t4severe( t4err_pack, "37" ) ;
 | 
						|
  check_count( test, 3L ) ;
 | 
						|
  check_data( display, test ) ;
 | 
						|
 | 
						|
  if ( d4close( test ) != 0 )
 | 
						|
    t4severe( t4err_close, "38" ) ;
 | 
						|
  test = d4open( &cb, "T4Data" ) ;
 | 
						|
  if ( test == 0 ) 
 | 
						|
    t4severe( t4err_data, "39" ) ;
 | 
						|
  check_count( test, 3L ) ;
 | 
						|
  check_data( display, test ) ;
 | 
						|
 | 
						|
  if ( d4go( test, 1L ) != 0 )
 | 
						|
    t4severe( t4err_go, "40" ) ;
 | 
						|
  if ( d4lock_append( test ) != 0 )
 | 
						|
    t4severe( t4err_lock, "41" ) ;
 | 
						|
  if ( d4append_data( test ) != 0 )
 | 
						|
    t4severe( t4err_append, "42" ) ;
 | 
						|
  d4update_header( test, 1, 1 ) ;  /* update reccount */
 | 
						|
  if ( d4unlock_append( test ) != 0 )
 | 
						|
    t4severe( t4err_unlock, "43" ) ;
 | 
						|
 | 
						|
  if ( d4display_quit( display ) )
 | 
						|
    return 1 ;
 | 
						|
  if ( d4zap( test, 2L, 2L ) != 0 )
 | 
						|
    t4severe( t4err_zap, "44" ) ;
 | 
						|
  check_count( test, 3L ) ;
 | 
						|
  check_data( display, test ) ;
 | 
						|
 | 
						|
  if ( d4num_fields( test ) != 6 )
 | 
						|
    t4severe( t4err_n_fields, "45" ) ;
 | 
						|
 | 
						|
#ifdef S4UNIX
 | 
						|
  if ( memcmp( test->file.name, "T4Data.dbf", sizeof("T4Data.DBF") ) )
 | 
						|
    t4severe( t4err_name, "46" ) ;
 | 
						|
  
 | 
						|
  if ( memcmp(test->alias, "T4Data", sizeof("T4Data") ) )
 | 
						|
    t4severe( t4err_name, "47" ) ;
 | 
						|
#else
 | 
						|
  if ( memcmp( test->file.name, "T4DATA.DBF", sizeof("T4DATA.DBF") ) )
 | 
						|
    t4severe( t4err_name, "46" ) ;
 | 
						|
  
 | 
						|
  if ( memcmp(test->alias, "T4DATA", sizeof("T4DATA") ) )
 | 
						|
    t4severe( t4err_name, "47" ) ;
 | 
						|
#endif
 | 
						|
 | 
						|
  if ( d4display_quit( display ) )
 | 
						|
    return 1 ;
 | 
						|
  d4display_str( display,  "        Creating t4DATA2.  ", 1 ) ;
 | 
						|
 | 
						|
#ifdef S4OPEN_FILE
 | 
						|
  test2 = d4open( &cb, "t4DATA2" ) ;
 | 
						|
#else
 | 
						|
  test2 = d4create( &cb, "t4DATA2", field_info, 0 ) ;
 | 
						|
#endif
 | 
						|
 | 
						|
  if ( test2 == 0 )
 | 
						|
    t4severe( t4err_data, "48" ) ;
 | 
						|
  d4close( test2 ) ;
 | 
						|
  test2 = d4open( &cb, "t4DATA2" ) ;
 | 
						|
  if ( test2 == 0 )
 | 
						|
    t4severe( t4err_data, "49" ) ;
 | 
						|
 | 
						|
  d4alias_set( test2, "aliAs_nAME" ) ;
 | 
						|
 | 
						|
  if ( d4data( &cb, "aliAs_nAME") != test2 )
 | 
						|
    t4severe( t4err_name, "50" ) ;
 | 
						|
 | 
						|
  if ( d4data( &cb, "t4DATA2") == test2 )
 | 
						|
    t4severe( t4err_name, "51" ) ;
 | 
						|
 | 
						|
  if ( d4close_all( &cb ) != 0 )
 | 
						|
    t4severe( t4err_close, "52" ) ;
 | 
						|
  return 0 ;
 | 
						|
}
 | 
						|
 | 
						|
static int test_with_mem_check( D4DISPLAY *display )
 | 
						|
{
 | 
						|
  d4init( &cb ) ;
 | 
						|
 | 
						|
  cb.hWnd = (unsigned) display->hWnd ;
 | 
						|
#ifdef S4DLL
 | 
						|
  cb.hInst = (unsigned) display->hInst ;
 | 
						|
#endif
 | 
						|
 | 
						|
  if ( test_data( display, 0 ) )
 | 
						|
    return 1 ;
 | 
						|
  if ( test_data( display, 1 ) )
 | 
						|
    return 1 ;
 | 
						|
 | 
						|
#ifndef S4TEST_KEEP_FILES
 | 
						|
  u4remove( "T4Data.dbf" ) ;
 | 
						|
  u4remove( "t4DATA2.dbf" ) ;
 | 
						|
#endif
 | 
						|
 | 
						|
  d4init_undo( &cb ) ;
 | 
						|
  mem4reset() ;
 | 
						|
 | 
						|
#ifdef S4DEBUG
 | 
						|
  mem4check_memory() ;
 | 
						|
#ifndef S4DLL
 | 
						|
  if ( mem4free_check(100) != 0 )
 | 
						|
    t4severe( t4err_memory, "53" ) ;
 | 
						|
#endif
 | 
						|
#endif
 | 
						|
 | 
						|
  return 0 ;
 | 
						|
}
 | 
						|
 | 
						|
int S4FUNCTION t4test( D4DISPLAY *display )
 | 
						|
{
 | 
						|
  d4display_str( display,  "T4DATA Test  ", 1 ) ;
 | 
						|
  d4display_str( display,  " ", 1 ) ;
 | 
						|
 | 
						|
#ifndef S4WINDOWS
 | 
						|
  d4low_test() ;
 | 
						|
#endif
 | 
						|
 | 
						|
  if ( test_with_mem_check( display ) )
 | 
						|
    t4severe( t4err_general, "54" ) ;
 | 
						|
  if ( test_with_mem_check( display ) )
 | 
						|
    t4severe( t4err_general, "55" ) ;
 | 
						|
 | 
						|
  display->y += 2 ;
 | 
						|
  d4display_str( display, "T4DATA:   SUCCESS", 1 ) ;
 | 
						|
  d4display_str( display, "", 1 ) ;
 | 
						|
  return 1 ;
 | 
						|
}
 | 
						|
 | 
						|
#ifndef S4WINDOWS
 | 
						|
/*********************************************************************
 | 
						|
  d4low.c   (c)Copyright Sequiter Software Inc., 1990-1994.
 | 
						|
  All rights reserved.
 | 
						|
 | 
						|
  This example test program tests low-level CodeBase functions.  
 | 
						|
 | 
						|
  *********************************************************************/
 | 
						|
 | 
						|
#define T4LOCK_POS 1000000000L 
 | 
						|
/* #define S4TEST_HANDLES */ /* test for the maximum # of allowable file handles */
 | 
						|
 | 
						|
#ifdef S4FOX
 | 
						|
void t4dbl_to_fox( char *, double ) ;
 | 
						|
#endif
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef S4SINGLE
 | 
						|
#ifndef S4MACINTOSH
 | 
						|
#ifdef S4UNIX
 | 
						|
#ifdef S4LOCKF
 | 
						|
#include <unistd.h>
 | 
						|
#else
 | 
						|
#ifndef S4MACINTOSH
 | 
						|
#include <sys/locking.h>
 | 
						|
#endif
 | 
						|
#endif
 | 
						|
#else
 | 
						|
#ifndef __TURBOC__
 | 
						|
#ifndef __IBMC__
 | 
						|
#include <sys\locking.h>
 | 
						|
#define S4LOCKING
 | 
						|
#endif
 | 
						|
#endif
 | 
						|
#ifdef __ZTC__
 | 
						|
extern int  errno ;
 | 
						|
#endif
 | 
						|
#ifdef _MSC_VER
 | 
						|
#include <sys\types.h>
 | 
						|
#endif
 | 
						|
#ifdef __TURBOC__
 | 
						|
/*      extern int cdecl errno ; */
 | 
						|
#include <sys\locking.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#include <sys\stat.h>
 | 
						|
#include <share.h>
 | 
						|
#endif
 | 
						|
#endif
 | 
						|
#endif
 | 
						|
 | 
						|
#include <fcntl.h>
 | 
						|
#include <errno.h>
 | 
						|
 | 
						|
#ifdef S4DO_ERRNO
 | 
						|
extern int errno ;
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef S4WINDOWS
 | 
						|
 | 
						|
void d4low_test()
 | 
						|
{
 | 
						|
  CODE4   cb ;                          /* initialize global variables */
 | 
						|
  FILE4 file ;
 | 
						|
  char  buffer[100] ;
 | 
						|
  long len ;
 | 
						|
  unsigned char test_buf[5] ;
 | 
						|
  unsigned char control_buf[5] ;
 | 
						|
  int is_error = 0 ;
 | 
						|
 | 
						|
  int  rc ;
 | 
						|
  char ch ;
 | 
						|
 | 
						|
#ifdef S4FOX
 | 
						|
  char result[8] ;
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef S4TEST_HANDLES
 | 
						|
  char ptr[20] ;
 | 
						|
#endif
 | 
						|
 | 
						|
  d4init( &cb ) ;
 | 
						|
  cb.safety = 0 ;        /* will create new database, regardless of */
 | 
						|
  /* it's current existence  */
 | 
						|
 | 
						|
 | 
						|
#ifdef S4TEST_HANDLES
 | 
						|
  for ( rc = 1; 1 ; rc++ )
 | 
						|
  {
 | 
						|
    c4ltoa45( rc, ptr, 10 ) ; 
 | 
						|
    file4create( &file, &cb, ptr, 0 ) ; 
 | 
						|
    if ( file.hand >= 0 )
 | 
						|
      printf(" FILE HANDLE # %ld. TOTAL NUMBER: %ld\n", file.hand, rc ) ;
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf(" MAXIMUM FILE HANDLES REACHED: %ld\n", rc ) ;
 | 
						|
      exit(1) ;
 | 
						|
    }
 | 
						|
  }
 | 
						|
#endif
 | 
						|
 | 
						|
  printf("Testing byte ordering . . .") ;
 | 
						|
 | 
						|
  len = 0x01020408 ;
 | 
						|
  memcpy( test_buf, (void *)&len, 4 ) ;
 | 
						|
 | 
						|
#ifdef S4BYTEORDER_3210
 | 
						|
  memcpy( control_buf, "\001\002\004\010", 4 ) ;
 | 
						|
#else
 | 
						|
#ifdef S4BYTEORDER_2301
 | 
						|
  memcpy( control_buf, "\002\001\010\004", 4 ) ;
 | 
						|
#else  /* default */
 | 
						|
  memcpy( control_buf, "\010\004\002\001", 4 ) ;
 | 
						|
#endif
 | 
						|
#endif
 | 
						|
 | 
						|
  if ( memcmp( control_buf , test_buf, 4 ) )
 | 
						|
  {
 | 
						|
    printf("\nERROR: byte ordering is incorrect \n" ) ;
 | 
						|
    printf("\nUse S4BYTEORDER_3210 or S4BYTEORDER_2301\n" ) ;
 | 
						|
    printf("\nThis is documented in Multi-Platform Manual\n" ) ;
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
 | 
						|
  printf("Testing memcmp() . . .") ;
 | 
						|
 | 
						|
#ifdef S4MEMCMP
 | 
						|
  rc = c4memcmp( "\320", "\120", 1 ) ;
 | 
						|
#else
 | 
						|
  rc = memcmp( "\320", "\120", 1 ) ;
 | 
						|
#endif
 | 
						|
  if (rc <= 0)   /* memcmp assumes signed bytes -- not usable */
 | 
						|
  {
 | 
						|
    printf("\nERROR: memcmp() assumes signed bytes\n" ) ;
 | 
						|
    printf("\nUse S4MEMCMP\n" ) ;
 | 
						|
    printf("\nThis is documented in Multi-Platform Manual\n" ) ;
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
 | 
						|
  printf("Testing for signed byte usage . . .") ;
 | 
						|
 | 
						|
  ch = -5 ;
 | 
						|
  if ( ch != -5 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: compiled using unsigned byte default\n" ) ;
 | 
						|
    printf("\nSee your compiler documentation for\n" ) ;
 | 
						|
    printf("\n'signed byte compilation' information.\n" ) ;
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
 | 
						|
  printf("Creating File: file4create() . . .") ;
 | 
						|
 | 
						|
  rc = file4create( &file, &cb, "TEST.FIL", 0 ) ;
 | 
						|
  if ( rc < 0 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4create() \n" ) ;
 | 
						|
    rc = open( "test.fil", O_CREAT | O_TRUNC | O_RDWR , 0666 ) ;
 | 
						|
    if ( rc < 0 )
 | 
						|
    {
 | 
						|
      printf("Function open() is failing with 'O_CREAT | O_TRUNC | O_RDWR'\n" );
 | 
						|
      printf("   and mode set to 0666\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EACCES :
 | 
						|
        printf("ERRNO == EACCES: Permission denied\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EINVAL :
 | 
						|
        printf("ERRNO == EINVAL: Invalid mode and permission setting\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EEXIST :
 | 
						|
        printf("ERRNO == EEXIST: O_CREAT and O_EXCL specified but file already exists\n" );
 | 
						|
        break ;
 | 
						|
      case EMFILE :
 | 
						|
        printf("ERRNO == EMFILE: No more file handles available\n" ) ;
 | 
						|
        break ;
 | 
						|
      case ENOENT :
 | 
						|
        printf("ERRNO == ENOENT: File not found or directory not present\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function open() succeeds but file4open() fails (create) \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
 | 
						|
  printf("Writing To File: file4write() . . .") ;
 | 
						|
 | 
						|
  rc = file4write( &file, 10, "Some Information", 17 ) ;
 | 
						|
  if ( rc < 0 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4write() \n" ) ;
 | 
						|
    rc = (int) lseek( file.hand, 10, 0 ) ;
 | 
						|
    if ( rc != 10 )
 | 
						|
    {
 | 
						|
      printf("Function lseek() is failing to seek past EOF\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EINVAL :
 | 
						|
        printf("ERRNO == EINVAL: Invalid mode and permission setting\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    rc = write( file.hand, "Some Information", 17 ) ;
 | 
						|
    if ( rc != 17 )
 | 
						|
    {
 | 
						|
      printf("Function write() is failing to write past EOF\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      case ENOSPC :
 | 
						|
        printf("ERRNO == ENOSPC: system out of disk space\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function write() succeeds but file4write() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
  
 | 
						|
 | 
						|
  printf("Checking File Flushing: file4low_flush() . . .") ;
 | 
						|
 | 
						|
  rc = file4low_flush( &file, 1 ) ;
 | 
						|
  if ( rc != 0 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4low_flush() \n" ) ;
 | 
						|
    printf("Function file4low_flush() is failing\n" );
 | 
						|
    printf("See S4USE_DUP or S4USE_EBX usage\n" );
 | 
						|
    printf("Investigate further" );
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
 | 
						|
  printf("Checking File Size: file4len() . . .") ;
 | 
						|
 | 
						|
  len = file4len( &file ) ;
 | 
						|
  if ( len != 27 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4len() \n" ) ;
 | 
						|
    len = filelength( file.hand ) ;
 | 
						|
    if ( len != 27 )
 | 
						|
    {
 | 
						|
      printf("Function filelength() is returning bad filelength\n" );
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function filelength() succeeds but file4len() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
  printf("Reading From File: file4read() . . .") ;
 | 
						|
 | 
						|
  rc = (int) file4read( &file, 10L, buffer, 17 ) ;
 | 
						|
  if ( rc != 17 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4read() \n" ) ;
 | 
						|
    rc = (int) lseek( file.hand, 10, 0 ) ;
 | 
						|
    if ( rc != 10 )
 | 
						|
    {
 | 
						|
      printf("Function lseek() is failing to seek past EOF\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EINVAL :
 | 
						|
        printf("ERRNO == EINVAL: Invalid mode and permission setting\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    rc = read( file.hand, buffer, 17 ) ;
 | 
						|
    if ( rc != 17 )
 | 
						|
    {
 | 
						|
      printf("Function write() is failing to write past EOF\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function read() succeeds but file4read() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
  {
 | 
						|
    if ( memcmp( "Some Information", buffer, 17 ) )
 | 
						|
    {
 | 
						|
      printf("\nERROR: file4read() \n" ) ;
 | 
						|
      printf("Information read is incorrect \n" );
 | 
						|
      printf("MEMCMP: 'Some Information' vs '%s'\n", buffer ) ;
 | 
						|
      is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
      getchar() ;
 | 
						|
#else
 | 
						|
      getch() ;
 | 
						|
#endif
 | 
						|
    }
 | 
						|
    else  
 | 
						|
      printf("OK\n" ) ;
 | 
						|
  }
 | 
						|
 | 
						|
  printf("Closing File: file4close() . . .") ;
 | 
						|
 | 
						|
  rc = file4close( &file ) ;
 | 
						|
  if ( rc < 0 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4close() \n" ) ;
 | 
						|
    rc = close( file.hand ) ;
 | 
						|
    if ( rc < 0 )
 | 
						|
    {
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function close() succeeds but file4close() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
 | 
						|
  printf("Opening File: file4open() . . .") ;
 | 
						|
 | 
						|
  rc = file4open( &file, &cb, "TEST.FIL", 0 ) ;
 | 
						|
  if ( rc < 0 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4open() \n" ) ;
 | 
						|
    rc = open( "test.fil", O_RDWR , 0666 ) ;
 | 
						|
    if ( rc < 0 )
 | 
						|
    {
 | 
						|
      printf("Function open() is failing with 'O_RDWR'\n" );
 | 
						|
      printf("   and mode set to 0666\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EACCES :
 | 
						|
        printf("ERRNO == EACCES: Permission denied\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EINVAL :
 | 
						|
        printf("ERRNO == EINVAL: Invalid mode and permission setting\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EEXIST :
 | 
						|
        printf("ERRNO == EEXIST: O_CREAT and O_EXCL specified but file already exists\n" );
 | 
						|
        break ;
 | 
						|
      case EMFILE :
 | 
						|
        printf("ERRNO == EMFILE: No more file handles available\n" ) ;
 | 
						|
        break ;
 | 
						|
      case ENOENT :
 | 
						|
        printf("ERRNO == ENOENT: File not found or directory not present\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function open() succeeds but file4open() fails (open) \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
  printf("Checking File Size(2): file4len() . . .") ;
 | 
						|
 | 
						|
  len = file4len( &file ) ;
 | 
						|
  if ( len != 27 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4len() \n" ) ;
 | 
						|
    len = filelength( file.hand ) ;
 | 
						|
    if ( len != 27 )
 | 
						|
    {
 | 
						|
      printf("Function filelength() is returning bad filelength\n" );
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function filelength() succeeds but file4len() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
  printf("Changing File Size: file4len_set() . . .") ;
 | 
						|
 | 
						|
  len = file4len_set( &file, 22 ) ;
 | 
						|
  if ( len < 0 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4len_set() \n" ) ;
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
  printf("Checking File Size(3): file4len() . . .") ;
 | 
						|
 | 
						|
  len = file4len( &file ) ;
 | 
						|
  if ( len != 22 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4len() \n" ) ;
 | 
						|
    len = filelength( file.hand ) ;
 | 
						|
    if ( len != 22 )
 | 
						|
    {
 | 
						|
      printf("Function filelength() is returning bad filelength\n" );
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function filelength() succeeds but file4len() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
#ifndef S4SINGLE
 | 
						|
#ifndef S4MACINTOSH
 | 
						|
#ifndef S4LOCKING
 | 
						|
 | 
						|
  printf("Locking File: file4lock() . . .") ;
 | 
						|
 | 
						|
  rc = file4lock( &file, T4LOCK_POS, 1 ) ;
 | 
						|
  if ( rc == r4locked )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4lock() \n" ) ;
 | 
						|
    printf("file locked by another user\n" ) ;
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
 | 
						|
  if ( rc < 0 ) 
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4lock() \n" ) ;
 | 
						|
    len = lseek( file.hand, T4LOCK_POS, 0 ) ;
 | 
						|
    if ( len != T4LOCK_POS )
 | 
						|
    {
 | 
						|
      printf("Function lseek() is failing to seek past EOF\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EINVAL :
 | 
						|
        printf("ERRNO == EINVAL: Invalid mode and permission setting\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
 | 
						|
#ifdef S4LOCKF 
 | 
						|
    rc = lockf( file.hand, F_TLOCK, 1 ) ; 
 | 
						|
#else
 | 
						|
    rc = locking( file.hand, LK_NBLCK, 1 ) ;
 | 
						|
#endif
 | 
						|
    if ( rc < 0 )
 | 
						|
    {
 | 
						|
      printf("Function lock() is failing to lock past EOF\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EINVAL :
 | 
						|
        printf("ERRNO == EINVAL: Invalid mode and permission setting\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function lock() succeeds but file4lock() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
  printf("Unlocking File: file4unlock() . . .") ;
 | 
						|
 | 
						|
  rc = file4unlock( &file, T4LOCK_POS, 1 ) ;
 | 
						|
  if ( rc < 0 ) 
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4unlock() \n" ) ;
 | 
						|
    len = lseek( file.hand, T4LOCK_POS, 0 ) ;
 | 
						|
    if ( len != T4LOCK_POS )
 | 
						|
    {
 | 
						|
      printf("Function lseek() is failing to seek past EOF\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EINVAL :
 | 
						|
        printf("ERRNO == EINVAL: Invalid mode and permission setting\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
 | 
						|
#ifdef S4LOCKF 
 | 
						|
    rc = lockf( file.hand, F_ULOCK, 1 ) ; 
 | 
						|
#else
 | 
						|
    rc = locking( file.hand, LK_UNLCK, 1 ) ;
 | 
						|
#endif
 | 
						|
    if ( rc < 0 )
 | 
						|
    {
 | 
						|
      printf("Function unlock() is failing to unlock file\n" );
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      case EINVAL :
 | 
						|
        printf("ERRNO == EINVAL: Invalid mode and permission setting\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function unlock() succeeds but file4unlock() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
#endif  /* ifdef S4LOCKING */
 | 
						|
#endif  /* ifndef S4MACINTOSH */
 | 
						|
#endif  /* ifndef S4SINGLE */
 | 
						|
 | 
						|
 | 
						|
  printf("Closing File: file4close() . . .") ;
 | 
						|
 | 
						|
  rc = file4close( &file ) ;
 | 
						|
  if ( rc < 0 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: file4close() \n" ) ;
 | 
						|
    rc = close( file.hand ) ;
 | 
						|
    if ( rc < 0 )
 | 
						|
    {
 | 
						|
      switch ( (int) errno )
 | 
						|
      {
 | 
						|
      case EBADF :
 | 
						|
        printf("ERRNO == EBADF: file handle is invalid\n" ) ;
 | 
						|
        break ;
 | 
						|
      default:
 | 
						|
        printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      printf("Function close() succeeds but file4close() fails \n" );
 | 
						|
      printf("Investigate further" );
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
  printf("Removing NEW_TEST.FIL (if exists) . . .") ;
 | 
						|
 | 
						|
  rc = u4remove( "NEW_TEST.FIL" ) ;
 | 
						|
  if ( (rc < 0) && ((int) errno != ENOENT) )
 | 
						|
  {
 | 
						|
    printf("\nERROR: u4move() \n" ) ;
 | 
						|
    switch ( (int) errno )
 | 
						|
    {
 | 
						|
    case EACCES :
 | 
						|
      printf("ERRNO == EACCES: Permission denied\n" ) ;
 | 
						|
      break ;
 | 
						|
    default:
 | 
						|
      printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
  printf("Renaming TEST.FIL to NEW_TEST.FIL . . .") ;
 | 
						|
 | 
						|
  rc = u4rename( "TEST.FIL", "NEW_TEST.FIL" ) ;
 | 
						|
  if ( rc < 0 )
 | 
						|
  {
 | 
						|
    printf("\nERROR: u4rename() \n" ) ;
 | 
						|
    switch ( (int) errno )
 | 
						|
    {
 | 
						|
    case EACCES :
 | 
						|
      printf("ERRNO == EACCES: Permission denied\n" ) ;
 | 
						|
      break ;
 | 
						|
    case ENOENT :
 | 
						|
      printf("ERRNO == ENOENT: No such file or directory\n" ) ;
 | 
						|
      break ;
 | 
						|
    default:
 | 
						|
      printf("ERRNO VALUE NOT RECOGNIZED\n" ) ;
 | 
						|
    }
 | 
						|
    is_error = 1 ;
 | 
						|
#ifdef S4UNIX
 | 
						|
    getchar() ;
 | 
						|
#else
 | 
						|
    getch() ;
 | 
						|
#endif
 | 
						|
  }
 | 
						|
  else  
 | 
						|
    printf("OK\n" ) ;
 | 
						|
 | 
						|
  printf("\n\nLOW LEVEL FILE TESTS SUCCESSFUL\n") ;
 | 
						|
 | 
						|
#ifdef S4FOX
 | 
						|
  printf("\n\nS4FOX COMPATIBILITY TESTING . . .\n") ;
 | 
						|
 | 
						|
  /* suppress 'possible incorrect assignment' warning */   
 | 
						|
#ifdef __TURBOC__       
 | 
						|
#pragma warn -pia
 | 
						|
#endif
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 1.0 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\277\360\000\000\000\000\000\000", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 22.34 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\300\066\127\012\075\160\243\327", 8 ) ) 
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 1191.575675 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\300\222\236\115\175\277\110\200", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 0.0 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\200\000\000\000\000\000\000\000", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 9999.000 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\300\303\207\200\000\000\000\000", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 0.000001 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\276\260\306\367\240\265\355\215", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 0.990001 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\277\357\256\026\223\300\073\305", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 1.00000 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\277\360\000\000\000\000\000\000", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 3.0 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\300\010\000\000\000\000\000\000", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, 12345678.90 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\301\147\214\051\334\314\314\315", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, .000000 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\200\000\000\000\000\000\000\000", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -1.0 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\100\017\377\377\377\377\377\377", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -22.34 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\077\311\250\365\302\217\134\050", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -1191.575675 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\077\155\141\262\202\100\267\177", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -9999.000 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\077\074\170\177\377\377\377\377", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -0.000001 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\101\117\071\010\137\112\022\162", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -0.990001 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\100\020\121\351\154\077\304\072", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -1.00000 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\100\017\377\377\377\377\377\377", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -3.0 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\077\367\377\377\377\377\377\377", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
  t4dbl_to_fox( result, -12345678.90 ) ;
 | 
						|
  if ( is_error=memcmp( result, "\076\230\163\326\043\063\063\062", 8 ) )
 | 
						|
    printf("ERROR: t4dbl_to_fox %f\n", *(double *)result ) ;
 | 
						|
 | 
						|
#ifdef __TURBOC__       
 | 
						|
#pragma warn .pia
 | 
						|
#endif
 | 
						|
 | 
						|
  if ( is_error )
 | 
						|
    printf("\n\nS4FOX TESTS: ERROR(S) FOUND\n") ;
 | 
						|
  else
 | 
						|
    printf("\n\nS4FOX TESTS: SUCCESSFUL\n") ;
 | 
						|
 | 
						|
#endif
 | 
						|
 | 
						|
  if ( is_error )
 | 
						|
    printf("\n\nD4LOW: ERROR(S) FOUND\n") ;
 | 
						|
  else
 | 
						|
    printf("\n\nD4LOW: SUCCESSFUL\n") ;
 | 
						|
}
 | 
						|
#endif
 |