File: shpcommon.h

package info (click to toggle)
postgis 2.3.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 58,660 kB
  • ctags: 10,181
  • sloc: ansic: 132,858; sql: 131,148; xml: 46,460; sh: 4,832; perl: 4,476; makefile: 2,749; python: 1,198; yacc: 442; lex: 131
file content (108 lines) | stat: -rw-r--r-- 2,569 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**********************************************************************
 *
 * PostGIS - Spatial Types for PostgreSQL
 * http://postgis.net
 *
 * Copyright (C) 2014 Sandro Santilli <strk@kbt.io>
 * Copyright (C) 2010 Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU General Public Licence. See the COPYING file.
 *
 **********************************************************************/

#ifndef SHPCOMMON_H
#define SHPCOMMON_H

/* For internationalization */
#ifdef ENABLE_NLS
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
#define PACKAGE "shp2pgsql"
#else
#define _(String) String
#endif



typedef struct shp_connection_state
{
	/* PgSQL username to log in with */
	char *username;

	/* PgSQL password to log in with */
	char *password;

	/* PgSQL database to connect to */
	char *database;

	/* PgSQL port to connect to */
	char *port;

	/* PgSQL server to connect to */
	char *host;

} SHPCONNECTIONCONFIG;

/* External shared functions */
char *escape_connection_string(char *str);

/* Column map between pgsql and dbf */
typedef struct colmap_t {

	/* Column map pgfieldnames */
	char **pgfieldnames;

	/* Column map dbffieldnames */
	char **dbffieldnames;

	/* Number of entries within column map */
	int size;

} colmap;

/**
 * Read the content of filename into a symbol map
 *
 * The content of the file is lines of two names separated by
 * white space and no trailing or leading space:
 *
 *    COLUMNNAME DBFFIELD1
 *    AVERYLONGCOLUMNNAME DBFFIELD2
 *
 *    etc.
 *
 * It is the reponsibility of the caller to reclaim the allocated space
 * as follows:
 *
 * free(map->colmap_pgfieldnames[]) to free the column names
 * free(map->colmap_dbffieldnames[]) to free the dbf field names
 *
 * TODO: provide a clean_colmap()
 *
 * @param filename name of the mapping file
 *
 * @param map container of colmap where the malloc'd
 *            symbol map will be stored.
 *
 * @param errbuf buffer to write error messages to
 *
 * @param errbuflen length of buffer to write error messages to
 *
 * @return 1 on success, 0 on error (and errbuf would be filled)
 */
int colmap_read(const char *fname, colmap *map, char *ebuf, size_t ebuflen);

void colmap_init(colmap *map);

void colmap_clean(colmap *map);

const char *colmap_dbf_by_pg(colmap *map, const char *pgname);

const char *colmap_pg_by_dbf(colmap *map, const char *dbfname);

char *codepage2encoding(const char *cpg);
char *encoding2codepage(const char *encoding);

#endif