pg_local_proto.h 2.3 KB

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