home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / I4TOP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  867 b   |  38 lines

  1.  
  2. /* i4top.c   (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3.  
  4.    Moves the index file pointer to the top position.
  5. */
  6.  
  7. #include "d4all.h"
  8.  
  9. extern   BLOCK   *v4block ;
  10. extern   INDEX   *v4index ;
  11. extern   int      v4lock_wait ;
  12.  
  13. i4top( int index_ref )
  14. {
  15.    int     rc, cur_block ;
  16.  
  17.    if ( (rc = i4lock( index_ref, v4lock_wait)) < 0 )  return rc ;
  18.  
  19.    if ( v4index[index_ref].block_ref >= 0 )
  20.    {
  21.       while( (cur_block = b4up( index_ref )) >= 0 )  ;
  22.       b4skip( index_ref, -9999L) ;
  23.    }
  24.  
  25.    cur_block = 0 ;
  26.    while ( cur_block >= 0 )
  27.    {
  28.       cur_block =  b4down( index_ref, -1 ) ;
  29.       if (cur_block <= -2)  return( -1 ) ;  /* Error */
  30.    }
  31.  
  32.    /* cur_block is the current block reference number */
  33.    if ( v4block[ v4index[index_ref].block_ref ].num_keys == 0 )
  34.     return( 3) ;
  35.  
  36.    return( 0 ) ;
  37. }
  38.