From 3d1d7c577b1490403dcaa7567dac0f098a053cac Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 16 May 2005 08:03:29 +0000 Subject: [PATCH] Back-ported -k patch git-svn-id: http://svn.osgeo.org/postgis/branches/pgis_1_0@1705 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/pgsql2shp.c | 113 +++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 50 deletions(-) diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c index 1d5e9a3cb..38848a39a 100644 --- a/loader/pgsql2shp.c +++ b/loader/pgsql2shp.c @@ -73,6 +73,7 @@ int dswitchprovided; int includegid; int unescapedattrs; int binary; +int keep_fieldname_case; SHPObject * (*shape_creator)(byte *, int); int big_endian = 0; int pgis_major_version; @@ -166,6 +167,7 @@ main(int ARGC, char **ARGV) includegid=0; unescapedattrs=0; binary = 0; + keep_fieldname_case = 0; #ifdef DEBUG FILE *debug; #endif @@ -2272,7 +2274,8 @@ usage(int status) printf(" -b Use a binary cursor.\n"); printf(" -r Raw mode. Do not assume table has been created by \n"); printf(" the loader. This would not unescape attribute names\n"); - printf(" and will not skip the 'gid' attribute."); + printf(" and will not skip the 'gid' attribute.\n"); + printf(" -k Keep postgresql identifiers case.\n"); printf("\n"); exit (status); } @@ -2287,50 +2290,52 @@ parse_commandline(int ARGC, char **ARGV) buf[1023] = '\0'; // just in case... /* Parse command line */ - while ((c = getopt(ARGC, ARGV, "bf:h:du:p:P:g:r")) != EOF){ - switch (c) { - case 'b': - binary = 1; - break; - case 'f': - shp_file = optarg; - break; - case 'h': - //setenv("PGHOST", optarg, 1); - snprintf(buf, 255, "PGHOST=%s", optarg); - putenv(strdup(buf)); - break; - case 'd': - dswitchprovided = 1; - outtype = 'z'; - break; - case 'r': - includegid = 1; - unescapedattrs = 1; - break; - case 'u': - //setenv("PGUSER", optarg, 1); - snprintf(buf, 255, "PGUSER=%s", optarg); - putenv(strdup(buf)); - break; - case 'p': - //setenv("PGPORT", optarg, 1); - snprintf(buf, 255, "PGPORT=%s", optarg); - putenv(strdup(buf)); - break; - case 'P': - //setenv("PGPASSWORD", optarg, 1); - snprintf(buf, 255, "PGPASSWORD=%s", optarg); - putenv(strdup(buf)); - break; - case 'g': - geo_col_name = optarg; - break; - case '?': - return 0; - default: - return 0; - } + while ((c = getopt(ARGC, ARGV, "bf:h:du:p:P:g:rk")) != EOF){ + switch (c) { + case 'b': + binary = 1; + break; + case 'f': + shp_file = optarg; + break; + case 'h': + //setenv("PGHOST", optarg, 1); + snprintf(buf, 255, "PGHOST=%s", optarg); + putenv(strdup(buf)); + break; + case 'd': + dswitchprovided = 1; + outtype = 'z'; + break; + case 'r': + includegid = 1; + unescapedattrs = 1; + break; + case 'u': + //setenv("PGUSER", optarg, 1); + snprintf(buf, 255, "PGUSER=%s", optarg); + putenv(strdup(buf)); + break; + case 'p': + //setenv("PGPORT", optarg, 1); + snprintf(buf, 255, "PGPORT=%s", optarg); + putenv(strdup(buf)); + break; + case 'P': + //setenv("PGPASSWORD", optarg, 1); + snprintf(buf, 255, "PGPASSWORD=%s", optarg); + putenv(strdup(buf)); + break; + case 'g': + geo_col_name = optarg; + break; + case 'k': + keep_fieldname_case = 1; + break; + case '?': + default: + return 0; + } } curindex=0; @@ -2547,16 +2552,21 @@ initialize(void) } - /* make UPPERCASE */ - for(j=0; j < strlen(field_name); j++) - field_name[j] = toupper(field_name[j]); + /* make UPPERCASE if keep_fieldname_case = 0 */ + if (keep_fieldname_case == 0) + for(j=0; j