]> git.openstreetmap.org Git - nominatim.git/blob - nominatim/postgresql.h
Merge pull request #1126 from lonvia/improve-country-reverse
[nominatim.git] / nominatim / postgresql.h
1 /*
2 */
3
4 #ifndef POSTGRESQL_H
5 #define POSTGRESQL_H
6
7 #define PG_OID_INT8                     20
8 #define PG_OID_INT4                     23
9
10 #if HAVE_BYTESWAP
11 #include <byteswap.h>
12 #define PG_BSWAP32(x) bswap_32(x)
13 #define PG_BSWAP64(x) bswap_64(x)
14 #elif HAVE_SYS_ENDIAN
15 #include <sys/endian.h>
16 #define PG_BSWAP32(x) bswap32(x)
17 #define PG_BSWAP64(x) bswap64(x)
18 #else
19 #error "No appropriate byteswap found for your system."
20 #endif
21
22 #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
23 #define PGint32(x)      (x)
24 #define PGint64(x)      (x)
25 #elif defined(__BYTE_ORDER__) &&  (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
26 #define PGint32(x)      PG_BSWAP32(x)
27 #define PGint64(x)      PG_BSWAP64(x)
28 #elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)
29 #define PGint32(x)      (x)
30 #define PGint64(x)      (x)
31 #elif defined(_BYTE_ORDER) &&  (_BYTE_ORDER == _LITTLE_ENDIAN)
32 #define PGint32(x)      PG_BSWAP32(x)
33 #define PGint64(x)      PG_BSWAP64(x)
34 #else
35 #error "Cannot determine byte order."
36 #endif
37
38 const char *build_conninfo(const char *db, const char *username, const char *password, const char *host, const char *port);
39
40 #endif