segment.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef GRASS_SEGMENT_H
  2. #define GRASS_SEGMENT_H
  3. #include <grass/gis.h>
  4. #ifdef HAVE_UNISTD_H
  5. #include <unistd.h>
  6. #endif
  7. #ifdef HAVE_SYS_TYPES_H
  8. #include <sys/types.h>
  9. #endif
  10. struct aq { /* age queue */
  11. int cur; /* segment number */
  12. struct aq *younger, *older; /* pointer to next younger and next older */
  13. } ;
  14. typedef struct
  15. {
  16. int open; /* open flag */
  17. off_t nrows; /* rows in original data */
  18. off_t ncols; /* cols in original data */
  19. int len; /* bytes per data value */
  20. int srows; /* rows in segments */
  21. int scols; /* cols in segments */
  22. int srowscols; /* rows x cols in segments */
  23. int size; /* size in bytes of a segment */
  24. int spr; /* segments per row */
  25. int spill; /* cols in last segment in row */
  26. /* fast mode */
  27. int fast_adrs; /* toggles fast address mode */
  28. off_t scolbits; /* column bitshift */
  29. off_t srowbits; /* row bitshift */
  30. off_t segbits; /* segment bitshift */
  31. int fast_seek; /* toggles fast seek mode */
  32. int lenbits; /* data size bitshift */
  33. int sizebits; /* segment size bitshift */
  34. int (*address)();
  35. int (*seek)();
  36. char *fname; /* segment file name */
  37. int fd; /* file descriptor to read/write segment */
  38. struct scb /* control blocks */
  39. {
  40. char *buf; /* data buffer */
  41. char dirty; /* dirty flag */
  42. struct aq *age; /* pointer to position in age queue */
  43. int n; /* segment number */
  44. } *scb;
  45. int *load_idx; /* index of loaded segments */
  46. int nfreeslots; /* number of free slots */
  47. int *freeslot; /* array of free slots */
  48. struct aq *agequeue, /* queue of age for order of access */
  49. *youngest, /* youngest in age queue */
  50. *oldest; /* oldest in age queue */
  51. int nseg; /* number of segments in memory */
  52. int cur; /* last accessed segment */
  53. int offset; /* offset of data past header */
  54. char *cache; /* all in memory cache */
  55. } SEGMENT;
  56. #include <grass/defs/segment.h>
  57. #endif /* GRASS_SEGMENT_H */