pg_local_proto.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef __PG_LOCAL_PROTO_H__
  2. #define __PG_LOCAL_PROTO_H__
  3. #include <grass/vector.h>
  4. #ifdef HAVE_POSTGRES
  5. #include <libpq-fe.h>
  6. #define CURSOR_PAGE 500
  7. #define FID_COLUMN "fid"
  8. #define GEOMETRY_COLUMN "geom"
  9. #define SWAP32(x) \
  10. ((unsigned int)( \
  11. (((unsigned int)(x) & (unsigned int)0x000000ffUL) << 24) | \
  12. (((unsigned int)(x) & (unsigned int)0x0000ff00UL) << 8) | \
  13. (((unsigned int)(x) & (unsigned int)0x00ff0000UL) >> 8) | \
  14. (((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24) ))
  15. #define SWAPDOUBLE(x) \
  16. { \
  17. unsigned char temp, *data = (unsigned char *) (x); \
  18. \
  19. temp = data[0]; \
  20. data[0] = data[7]; \
  21. data[7] = temp; \
  22. temp = data[1]; \
  23. data[1] = data[6]; \
  24. data[6] = temp; \
  25. temp = data[2]; \
  26. data[2] = data[5]; \
  27. data[5] = temp; \
  28. temp = data[3]; \
  29. data[3] = data[4]; \
  30. data[4] = temp; \
  31. }
  32. #define LSBWORD32(x) (x)
  33. #define MSBWORD32(x) SWAP32(x)
  34. /* used for building pseudo-topology (requires some extra information
  35. * about lines in cache) */
  36. struct feat_parts
  37. {
  38. int a_parts; /* number of allocated items */
  39. int n_parts; /* number of parts which forms given feature */
  40. SF_FeatureType *ftype; /* simple feature type */
  41. int *nlines; /* number of lines used in cache */
  42. int *idx; /* index in cache where to start */
  43. };
  44. /* functions used in *_pg.c files */
  45. int execute(PGconn *, const char *);
  46. SF_FeatureType cache_feature(const char *, int, int,
  47. struct Format_info_cache *,
  48. struct feat_parts *);
  49. int set_initial_query(struct Format_info_pg *, int);
  50. int load_plus(struct Map_info *, int);
  51. #endif /* HAVE_POSTGRES */
  52. #endif /* __PG_LOCAL_PROTO_H__ */