#define ZMFLAG(x) (((x)&((WKBZOFFSET)+(WKBMOFFSET)))>>30)
-static void exit_nicely(PGconn *conn){
+static void exit_nicely(PGconn *conn, int code)
+{
PQfinish(conn);
- exit(1);
+ exit(code);
}
int
conn = PQconnectdb("");
if (PQstatus(conn) == CONNECTION_BAD) {
printf( "%s", PQerrorMessage(conn));
- exit_nicely(conn);
+ exit_nicely(conn, 1);
}
/* Create temporary table for user query */
/* Initialize shapefile and database infos */
fprintf(stdout, "Initializing... "); fflush(stdout);
- if ( ! initialize() ) exit_nicely(conn);
+ if ( ! initialize() ) exit_nicely(conn, 1);
fprintf(stdout, "Done (postgis major version: %d).\n",
pgis_major_version);
res=PQexec(conn, "BEGIN");
if ( ! res || PQresultStatus(res) != PGRES_COMMAND_OK ) {
printf( "%s", PQerrorMessage(conn));
- exit_nicely(conn);
+ exit_nicely(conn, 1);
}
PQclear(res);
free(query);
if ( ! res || PQresultStatus(res) != PGRES_COMMAND_OK ) {
printf( "MainScanQuery: %s", PQerrorMessage(conn));
- exit_nicely(conn);
+ exit_nicely(conn, 1);
}
PQclear(res);
if ( ! res || PQresultStatus(res) != PGRES_TUPLES_OK ) {
printf( "RecordFetch: %s",
PQerrorMessage(conn));
- exit_nicely(conn);
+ exit_nicely(conn, 1);
}
/* No more rows, break the loop */
for(i=0; i<PQntuples(res); i++)
{
/* Add record in all output files */
- if ( ! addRecord(res, i, row) ) exit_nicely(conn);
+ if ( ! addRecord(res, i, row) ) exit_nicely(conn, 1);
row++;
}
if (dbf) DBFClose(dbf);
if (shp) SHPClose(shp);
- exit_nicely(conn);
#ifdef DEBUG
fclose(debug);
#endif /* DEBUG */
+ exit_nicely(conn, 0);
return 0;
}
free(query);
if ( ! res3 || PQresultStatus(res3) != PGRES_TUPLES_OK ) {
printf( "TableOID: %s", PQerrorMessage(conn));
- exit_nicely(conn);
+ exit_nicely(conn, 1);
}
if(PQntuples(res3) == 1 ){
ret = strdup(PQgetvalue(res3, 0, 0));
/**********************************************************************
* $Log$
+ * Revision 1.85 2006/06/16 14:12:16 strk
+ * - BUGFIX in pgsql2shp successful return code.
+ * - BUGFIX in shp2pgsql handling of MultiLine WKT.
+ *
* Revision 1.84 2006/04/18 14:09:28 strk
* Limited text field size to 255 (bug #84) [will eventually provide a switch to support wider fields ]
*
for ( vi=vs; vi<ve; vi++)
{
- if ( vi ) printf(",");
+ if ( vi > vs ) printf(",");
printf("%.15g %.15g",
obj->padfX[vi],
obj->padfY[vi]);
/**********************************************************************
* $Log$
+ * Revision 1.108 2006/06/16 14:12:17 strk
+ * - BUGFIX in pgsql2shp successful return code.
+ * - BUGFIX in shp2pgsql handling of MultiLine WKT.
+ *
* Revision 1.107 2006/04/18 09:16:26 strk
* Substituted bzero() use with memset()
*