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

  1.  
  2. /*  d4reccount.c   (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3.  
  4.     Returns
  5.        >= 0  The number of records in the database.
  6.      -1  Error
  7. */
  8.  
  9. #include "p4misc.h"
  10. #include "d4base.h"
  11. #include "u4error.h"
  12.  
  13. #ifndef UNIX
  14. #include <io.h>
  15. #endif
  16.  
  17. extern  BASE   *v4base ;
  18. extern  int     v4cur_base ;
  19.  
  20.  
  21. long d4reccount()
  22. {
  23.    BASE  *base_ptr ;
  24.    long   len, count ;
  25.  
  26.    if ( v4cur_base < 0 )  return -1L ;
  27.  
  28.    base_ptr =  v4base+ v4cur_base ;
  29.    if ( base_ptr->num_recs >= 0L )  return( base_ptr->num_recs ) ;
  30.  
  31.    if ( (len =  filelength(base_ptr->file_hand)) < 0L)
  32.    {
  33.       u4error( E_INTERNAL, (char *) 0 ) ;
  34.       return -1L ;
  35.    }
  36.  
  37.    count =  (len-base_ptr->header_len)/ base_ptr->buffer_len ;
  38.    if ( base_ptr->file_lock >= 0 )
  39.       base_ptr->num_recs =  count ;
  40.  
  41.    return count ;
  42. }
  43.