home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / db_frm_c.zip / D_GETFLD.C < prev    next >
Text File  |  1987-06-14  |  1KB  |  43 lines

  1. /* 
  2. **        file:        d_getfld.c
  3. **        purpose:    routine to fill a buffer with field data from a dbiii file
  4. **                    opened with d_open and accessed with d_getrec.    the data from the
  5. **                    record is copied into the buffer and terminated with '\0'
  6. **        usage:    d = (struct DBF *)malloc(sizeof(struct DBF));
  7. **                    strcpy(d->filename,"filename.dbf");
  8. **                    d_open(d);
  9. **                    d_getrec(d,(long)recordno);
  10. **                    d_getfld(d,fieldno,buffer);
  11. **                    ... use field data ...
  12. **                    d_close(d);
  13. **                    free(d);
  14. **        notes:    compile with "tcc -c d_getfld".    include this file in dbf.li
  15. **                    see dbf.h for structure of DBF
  16. **        returns:    field type  if successful
  17. **                    null if not
  18. **        author:    Mark Sadler
  19. **        revised:    6/14/87
  20. */ 
  21.         
  22. #include <stdio.h>
  23. #include <mem.h>
  24. #include "dbf.h"
  25.  
  26. char d_getfld(struct DBF *d,int f,char *buff)
  27. {
  28.     struct FIELD_RECORD *fp;
  29.     if(f > 0 && f <= d->num_fields)
  30.         {
  31.         fp = d->fields_ptr + (f - 1);
  32.         memcpy(buff,fp->field_data_address,fp->len);
  33.         buff[fp->len] = '\0';
  34.         return(fp->typ);
  35.         }
  36.     else
  37.         {
  38.         buff[0]='\0';
  39.         return('\0');
  40.         }
  41. }
  42.  
  43.