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

  1.  
  2. /* (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
  3.  
  4.    d4buf_unit.c  
  5. */
  6.  
  7. #include  "d4all.h"
  8.  
  9. extern int  v4cur_base ;
  10.  
  11.  
  12. int  d4buf_unit( long n_recs )
  13. {
  14.    BASE  *base_ptr ;
  15.  
  16.    base_ptr =  d4ptr() ;
  17.  
  18.    if ( base_ptr->bufs == (BASE_BUF *) 0  || base_ptr->max_bufs <= 0 || 
  19.         base_ptr->buf_ptr == (char H_PTR) 0)
  20.       return 1 ;
  21.  
  22.    if ( base_ptr->n_bufs > 0 )
  23.       if ( d4buf_clear_base(v4cur_base) < 0 )  return -1 ;
  24.  
  25.    if ( n_recs > base_ptr->rec_tot )  return 1 ;
  26.    if ( (base_ptr->bytes_per_buf = n_recs * f4record_width()) > 0xFFF0L )
  27.       return 1 ;
  28.  
  29.    base_ptr->rec_per_buf =  n_recs ;
  30.  
  31.    base_ptr->n_bufs =  (int) (base_ptr->rec_tot/ n_recs) ;
  32.    if ( base_ptr->n_bufs > base_ptr->max_bufs )
  33.       base_ptr->n_bufs =  base_ptr->max_bufs ;
  34.  
  35.    if ( base_ptr->n_bufs > 0 )
  36.       base_ptr->buf_status =  2 ;
  37.  
  38.    return 0 ;
  39. }
  40.  
  41.  
  42.  
  43.