home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 170_01 / isamdel.c < prev    next >
Text File  |  1979-12-31  |  1KB  |  45 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. **                  DELETE - Mark Index Record Deleted
  12. */
  13.  
  14. isamdel(hdr)
  15. struct isam *hdr;
  16. {
  17.     char buf[MAXKEY + 2];
  18.     long lrecl;
  19.     struct rec3 *r3;
  20.     r3 = (struct rec3 *) buf;
  21.  
  22.     if ((hdr->q4 < 2) || (hdr->q4 >= hdr->q3))
  23.     {
  24.         isam_err = 2;
  25.         return ERROR;
  26.     }
  27.     lrecl = hdr->q4 * (hdr->q6 + 2);
  28.     lseek(hdr->q7, lrecl, 0);
  29.     if (read(hdr->q7, buf, hdr->q6 + 2) == ERROR)
  30.     {
  31.         isam_err = 8;
  32.         return ERROR;
  33.     }
  34.     r3->idx_key[0] = 255;       /* post as deleted */
  35.     lseek(hdr->q7, lrecl, 0);
  36.     if (write(hdr->q7, buf, hdr->q6 + 2) == ERROR)
  37.     {
  38.         isam_err = 8;
  39.         return ERROR;
  40.     }
  41.     hdr->q2 += 1;               /* bump delete count */
  42.     return NULL;
  43. }
  44.  
  45.