home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 170_01 / isamprv.c < prev    next >
Text File  |  1979-12-31  |  1KB  |  40 lines

  1. /*
  2. **                 ISAMC - Written by John M. Dashner
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <ctype.h>
  7.  
  8. #include <isam.h>
  9.  
  10. /*
  11. **                  GET PREVIOUS - Sequential Index Traverse
  12. */
  13.  
  14. isamprv(hdr)
  15. struct isam *hdr;
  16. {
  17.     char buf[MAXKEY + 2];
  18.     long lrec;
  19.     struct rec3 *r3;
  20.     r3 = (struct rec3 *) buf;
  21.  
  22.     hdr->q4 -= 1;       /* decrement current record */
  23.     if (hdr->q4 == 1)
  24.     {
  25.         isam_err = 2;   /* boundary limit */
  26.         return ERROR;
  27.     }
  28.     lrec = hdr->q4 * (hdr->q6 + 2);
  29.     lseek(hdr->q7, lrec, 0);
  30.     if (read(hdr->q7, buf, hdr->q6 + 2) == ERROR)
  31.     {
  32.         isam_err = 8;
  33.         return ERROR;
  34.     }
  35.     if (r3->idx_key[0] == 255)
  36.         return(isamprv(hdr));   /* recurse on deleted record */
  37.     return r3->rec_ptr;
  38. }
  39.  
  40.