From f642ab98f1a9aef168f9a1a565016707e8a76758 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 19 Dec 2003 18:55:46 +0000 Subject: [PATCH] substituted setenv() calls with putenv() for Solaris support git-svn-id: http://svn.osgeo.org/postgis/trunk@413 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/pgsql2shp.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c index fa57623c8..b2c181a75 100644 --- a/loader/pgsql2shp.c +++ b/loader/pgsql2shp.c @@ -10,6 +10,9 @@ * ********************************************************************** * $Log$ + * Revision 1.39 2003/12/19 18:55:46 strk + * substituted setenv() calls with putenv() for Solaris support + * * Revision 1.38 2003/12/04 19:11:56 strk * code cleanup (removed useless and leaking malloc calls) * @@ -2095,6 +2098,9 @@ usage(status) int parse_commandline(int ARGC, char **ARGV) { int c, curindex; + char buf[256]; + + buf[255] = '\0'; // just in case... /* Parse command line */ while ((c = getopt(ARGC, ARGV, "bf:h:du:p:P:g:")) != EOF){ @@ -2106,19 +2112,27 @@ int parse_commandline(int ARGC, char **ARGV) shp_file = optarg; break; case 'h': - setenv("PGHOST", optarg, 1); + //setenv("PGHOST", optarg, 1); + snprintf(buf, 255, "PGHOST=%s", optarg); + putenv(strdup(buf)); break; case 'd': is3d = 1; break; case 'u': - setenv("PGUSER", optarg, 1); + //setenv("PGUSER", optarg, 1); + snprintf(buf, 255, "PGUSER=%s", optarg); + putenv(strdup(buf)); break; case 'p': - setenv("PGPORT", optarg, 1); + //setenv("PGPORT", optarg, 1); + snprintf(buf, 255, "PGPORT=%s", optarg); + putenv(strdup(buf)); break; case 'P': - setenv("PGPASSWORD", optarg, 1); + //setenv("PGPASSWORD", optarg, 1); + snprintf(buf, 255, "PGPASSWORD=%s", optarg); + putenv(strdup(buf)); break; case 'g': geo_col_name = optarg; @@ -2133,7 +2147,9 @@ int parse_commandline(int ARGC, char **ARGV) curindex=0; for ( ; optind < ARGC; optind++){ if(curindex ==0){ - setenv("PGDATABASE", ARGV[optind], 1); + //setenv("PGDATABASE", ARGV[optind], 1); + snprintf(buf, 255, "PGDATABASE=%s", ARGV[optind]); + putenv(strdup(buf)); }else if(curindex == 1){ table = ARGV[optind]; } -- 2.40.0