home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 228_01 / isamprv.c < prev    next >
Text File  |  1987-07-31  |  1KB  |  53 lines

  1. /*
  2. HEADER:         CUGXXX;
  3. TITLE:          Get previous record (of ISAM system);
  4. DATE:           3-31-86;
  5. DESCRIPTION:    Part of ISAM Library;
  6. KEYWORDS:       ISAM;
  7. FILENAME:       ISAMPRV.C;
  8. WARNINGS:       None;
  9. AUTHORS:        John M. Dashner;
  10. COMPILER:       Lattice C;
  11. REFERENCES:     US-DISK 1310;
  12. ENDREF
  13. */
  14. /*
  15. **                 ISAMC - Written by John M. Dashner
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <ctype.h>
  20.  
  21. #include <isam.h>
  22.  
  23. /*
  24. **                  GET PREVIOUS - Sequential Index Traverse
  25. */
  26.  
  27. isamprv(hdr)
  28. struct isam *hdr;
  29. {
  30.     char buf[MAXKEY + 2];
  31.     long lrec;
  32.     struct rec3 *r3;
  33.     r3 = (struct rec3 *) buf;
  34.  
  35.     hdr->q4 -= 1;       /* decrement current record */
  36.     if (hdr->q4 == 1)
  37.     {
  38.         isam_err = 2;   /* boundary limit */
  39.         return ERROR;
  40.     }
  41.     lrec = hdr->q4 * (hdr->q6 + 2);
  42.     lseek(hdr->q7, lrec, 0);
  43.     if (read(hdr->q7, buf, hdr->q6 + 2) == ERROR)
  44.     {
  45.         isam_err = 8;
  46.         return ERROR;
  47.     }
  48.     if (r3->idx_key[0] == 255)
  49.         return(isamprv(hdr));   /* recurse on deleted record */
  50.     return r3->rec_ptr;
  51. }
  52.  
  53.