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 / D4GO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-12  |  1.3 KB  |  64 lines

  1.  
  2. /*
  3.     d4go( ref_base, rec_num )
  4.     (c)Copyright Sequiter Software Inc., 1987, 1988, 1989.  All rights reserved.
  5.  
  6.     - reads the specified record into the 'new_buf'
  7.     - the deletion status byte is in first character position
  8. */
  9.  
  10.  
  11. #include "d4base.h"
  12. #include "u4error.h"
  13.  
  14. #include <string.h>
  15. #ifndef UNIX
  16.    #include <io.h>
  17. #endif
  18. #include <stdlib.h>
  19.  
  20. extern long  lseek( int, long, int) ;
  21. extern BASE *v4base ;
  22. extern int   v4cur_base ;
  23.  
  24.  
  25. int d4go( rec_num )
  26. long  rec_num ;
  27. {
  28.    BASE *base_ptr   ;
  29.    char  buffer[34] ;
  30.  
  31.    if ( v4cur_base < 0 )
  32.    {
  33.       u4error( E_D_MISSING, (char *) 0 ) ;
  34.       return( -1 ) ;
  35.    }
  36.  
  37.    base_ptr =  v4base +  v4cur_base ;
  38.  
  39.    if ( rec_num <= 0L )  
  40.    {
  41.       memset( base_ptr->buffer, (int) ' ', base_ptr->buffer_len) ;
  42.       return(1) ;
  43.    }
  44.  
  45.    base_ptr->rec_num =    rec_num ;
  46.  
  47.    if ( d4lock( rec_num, 1 ) < 0 )  return( -1) ;
  48.  
  49.    lseek( base_ptr->dos_file,
  50.       base_ptr->header_len+ (rec_num-1)* base_ptr->buffer_len, 0) ;
  51.    if ( read ( base_ptr->dos_file, base_ptr->buffer, base_ptr->buffer_len)
  52.     ==  base_ptr->buffer_len  )
  53.    {
  54.       return( 0 ) ;
  55.    }
  56.    else
  57.    {
  58.       ltoa( rec_num, buffer, 10) ;
  59.       u4error( E_READ, base_ptr->name, "Record: ", buffer, (char *) 0) ;
  60.       return( -1) ;
  61.    }
  62. }
  63.  
  64.