You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.2 KiB

  1. /*
  2. * Copyright (c) 1991, 1992, 1993 Brad Eacker,
  3. * (Music, Intuition, Software, and Computers)
  4. * All Rights Reserved
  5. */
  6. /*
  7. * dbf header structure on disk (pc dbase III)
  8. *
  9. * Basic info taken from:
  10. * "File Formats for Popular PC Software"
  11. * Jeff Walden
  12. * (c) 1986 John Wiley & Sons, Inc.
  13. */
  14. #ifndef DBF_H_
  15. #define DBF_H_
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #ifdef WIN32
  19. #include <io.h>
  20. #else
  21. #include <unistd.h>
  22. #endif
  23. /* So we can use O_BINARY on non-Win32 systems. */
  24. #if !defined(O_BINARY) && !defined(WIN32)
  25. #define O_BINARY (0)
  26. #endif
  27. struct dbf_dhead {
  28. char dbh_dbt; /* memo (dbt) file present */
  29. char dbh_date[3]; /* last update YY, MM, DD */
  30. char dbh_records[4]; /* number of records LE */
  31. char dbh_hlen[2]; /* header length LE */
  32. char dbh_rlen[2]; /* record length LE */
  33. char dbh_res[20]; /* padding */
  34. };
  35. #define DBH_DATE_YEAR 0 /* byte offset for year in dbh_date */
  36. #define DBH_DATE_MONTH 1
  37. #define DBH_DATE_DAY 2
  38. /*
  39. * field description on disk
  40. */
  41. #define DBF_NAMELEN 11
  42. struct dbf_dfield {
  43. char dbf_name[DBF_NAMELEN]; /* name of field */
  44. char dbf_type; /* type of field */
  45. char dbf_fda[4]; /* something for dbase III */
  46. char dbf_flen[2]; /* field length [and decimal if N] */
  47. char dbf_res[14]; /* padding */
  48. };
  49. struct db_field {
  50. char db_fname[DBF_NAMELEN+1]; /* 0 terminated */
  51. char db_type; /* type of field */
  52. int db_flen; /* length of field */
  53. int db_fdc; /* number of decimals in field */
  54. char *db_format; /* format for printing %s etc */
  55. int db_foffset; /* offset within record */
  56. };
  57. typedef struct db_field dbfield_t;
  58. struct db_head {
  59. int db_fd;
  60. unsigned char db_dbt; /* dbt present */
  61. char db_date[9]; /* date of last update in db format */
  62. long db_records; /* number of records */
  63. int db_hlen; /* header length */
  64. int db_rlen; /* record length */
  65. int db_nfields; /* number of fields */
  66. dbfield_t *db_fields; /* field info */
  67. char *db_name; /* name of dbf file */
  68. int db_cur_rec; /* current record */
  69. };
  70. typedef struct db_head dbhead_t;
  71. #define DBH_TYPE_NORMAL 0x03
  72. #define DBH_TYPE_MEMO 0x83
  73. #define VALID_RECORD ' '
  74. #define DELETED_RECORD '*'
  75. #include "dbf_head.h"
  76. #include "dbf_misc.h"
  77. #include "dbf_rec.h"
  78. #endif /* DBF_H_ */