home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CODE4-1.ZIP / SOURCE.ZIP / I4TOP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-14  |  886 b   |  43 lines

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