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 / I4BOTTOM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-14  |  993 b   |  49 lines

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