Changeset 2513

Show
Ignore:
Timestamp:
10/14/06 07:22:10 (6 years ago)
Author:
mschaber
Message:

sanitized usage info output on loader/dumper

Location:
trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/CHANGES

    r2512 r2513  
    55        - Include the Version.config in loader/dumper USAGE messages 
    66        - Replace hand-made, fragile JDBC version parser with Properties 
     7        - Sanitized usage output of loader/dumper. 
    78 
    89 
  • trunk/doc/man/pgsql2shp.1

    r2503 r2513  
    6767\fB\-k\fR 
    6868Keep idendifiers case (don't uppercase field names).  
     69.TP  
     70\fB\-?\fR 
     71Display version and usage information. 
    6972 
    7073.SH "INSTALLATION" 
  • trunk/doc/man/shp2pgsql.1

    r2503 r2513  
    8989\fB\-N\fR <\fIpolicy\fR> 
    9090Specify NULL geometries handling policy (insert,skip,abort). 
     91.TP  
     92\fB\-?\fR 
     93Display version and usage information. 
    9194 
    9295.SH "INSTALLATION" 
  • trunk/loader/pgsql2shp.c

    r2512 r2513  
    9494int getMaxFieldSize(PGconn *conn, char *schema, char *table, char *fname); 
    9595int parse_commandline(int ARGC, char **ARGV); 
    96 void usage(int exitstatus); 
     96void usage(char* me, int exitstatus, FILE* out); 
    9797char *getTableOID(char *schema, char *table); 
    9898int addRecord(PGresult *res, int residx, int row); 
     
    195195        if ( getenv("ROWBUFLEN") ) rowbuflen=atoi(getenv("ROWBUFLEN")); 
    196196 
    197         if ( ARGC == 1 ) { 
    198                 usage(0); 
    199         } 
    200  
    201197        /* 
    202198         * Make sure dates are returned in ISO 
     
    210206        if ( ! parse_commandline(ARGC, ARGV) ) { 
    211207                printf("\n**ERROR** invalid option or command parameters\n\n"); 
    212                 usage(2); 
     208                usage(ARGV[0], 2, stderr); 
    213209        } 
    214210 
     
    23092305 
    23102306void 
    2311 usage(int status) 
    2312 { 
    2313         printf("RCSID: %s RELEASE: %s\n", rcsid, POSTGIS_VERSION); 
    2314         printf("USAGE: pgsql2shp [<options>] <database> [<schema>.]<table>\n"); 
    2315         printf("       pgsql2shp [<options>] <database> <query>\n"); 
    2316         printf("\n"); 
    2317         printf("OPTIONS:\n"); 
    2318         printf("  -f <filename>  Use this option to specify the name of the file\n"); 
    2319         printf("     to create.\n"); 
    2320         printf("  -h <host>  Allows you to specify connection to a database on a\n"); 
    2321         printf("     machine other than the default.\n"); 
    2322         printf("  -p <port>  Allows you to specify a database port other than the default.\n"); 
    2323         printf("  -P <password>  Connect to the database with the specified password.\n"); 
    2324         printf("  -u <user>  Connect to the database as the specified user.\n"); 
    2325         printf("  -g <geometry_column> Specify the geometry column to be exported.\n"); 
    2326         printf("  -b Use a binary cursor.\n"); 
    2327         printf("  -r Raw mode. Do not assume table has been created by \n"); 
    2328         printf("     the loader. This would not unescape attribute names\n"); 
    2329         printf("     and will not skip the 'gid' attribute.\n"); 
    2330         printf("  -k Keep postgresql identifiers case.\n"); 
    2331         printf("\n"); 
     2307usage(char* me, int status, FILE* out) 
     2308{ 
     2309        fprintf(out,"RCSID: %s RELEASE: %s\n", rcsid, POSTGIS_VERSION); 
     2310        fprintf(out,"USAGE: %s [<options>] <database> [<schema>.]<table>\n", me); 
     2311        fprintf(out,"       %s [<options>] <database> <query>\n", me); 
     2312        fprintf(out,"\n"); 
     2313        fprintf(out,"OPTIONS:\n"); 
     2314        fprintf(out,"  -f <filename>  Use this option to specify the name of the file\n"); 
     2315        fprintf(out,"     to create.\n"); 
     2316        fprintf(out,"  -h <host>  Allows you to specify connection to a database on a\n"); 
     2317        fprintf(out,"     machine other than the default.\n"); 
     2318        fprintf(out,"  -p <port>  Allows you to specify a database port other than the default.\n"); 
     2319        fprintf(out,"  -P <password>  Connect to the database with the specified password.\n"); 
     2320        fprintf(out,"  -u <user>  Connect to the database as the specified user.\n"); 
     2321        fprintf(out,"  -g <geometry_column> Specify the geometry column to be exported.\n"); 
     2322        fprintf(out,"  -b Use a binary cursor.\n"); 
     2323        fprintf(out,"  -r Raw mode. Do not assume table has been created by \n"); 
     2324        fprintf(out,"     the loader. This would not unescape attribute names\n"); 
     2325        fprintf(out,"     and will not skip the 'gid' attribute.\n"); 
     2326        fprintf(out,"  -k Keep postgresql identifiers case.\n"); 
     2327        fprintf(out,"  -? Display this help screen.\n"); 
     2328        fprintf(out,"\n"); 
    23322329        exit (status); 
    23332330} 
     
    23372334parse_commandline(int ARGC, char **ARGV) 
    23382335{ 
     2336        if ( ARGC == 1 ) { 
     2337                usage(ARGV[0], 0, stdout); 
     2338        } 
     2339 
    23392340        int c, curindex; 
    23402341        char buf[1024]; 
     
    23862387                                break; 
    23872388                        case '?': 
     2389                                usage(ARGV[0], 0, stdout); 
    23882390                        default: 
    23892391                                return 0; 
  • trunk/loader/README.pgsql2shp

    r2503 r2513  
    6666       -k     Keep idendifiers case (don't uppercase field names). 
    6767 
     68       -?     Display version and usage information. 
     69 
    6870 
    6971INSTALLATION 
  • trunk/loader/README.shp2pgsql

    r2503 r2513  
    8989              Specify NULL geometries handling policy (insert,skip,abort). 
    9090 
     91       -?     Display version and usage information. 
     92 
    9193 
    9294INSTALLATION 
  • trunk/loader/shp2pgsql.c

    r2512 r2513  
    107107void CreateTable(void); 
    108108void CreateIndex(void); 
    109 void usage(char *me, int exitcode); 
     109void usage(char *me, int exitcode, FILE* out); 
    110110void InsertPoint(void); 
    111111void InsertPointWKT(void); 
     
    382382         * Parse command line 
    383383         */ 
    384         if ( ! ParseCmdline(ARGC, ARGV) ) usage(ARGV[0], 2); 
     384        if ( ! ParseCmdline(ARGC, ARGV) ) usage(ARGV[0], 2, stderr); 
    385385 
    386386        /* 
     
    732732 
    733733void 
    734 usage(char *me, int exitcode) 
    735 { 
    736         fprintf(stderr, "RCSID: %s RELEASE: %s\n", rcsid, POSTGIS_VERSION); 
    737         fprintf(stderr, "USAGE: %s [<options>] <shapefile> [<schema>.]<table>\n", me); 
    738         fprintf(stderr, "\n"); 
    739         fprintf(stderr, "OPTIONS:\n"); 
    740         fprintf(stderr, "  -s <srid>  Set the SRID field. If not specified it defaults to -1.\n"); 
    741         fprintf(stderr, "\n"); 
    742         fprintf(stderr, "  (-d|a|c|p) These are mutually exclusive options:\n"); 
    743         fprintf(stderr, "      -d  Drops the table, then recreates it and populates\n"); 
    744         fprintf(stderr, "          it with current shape file data.\n"); 
    745         fprintf(stderr, "      -a  Appends shape file into current table, must be\n"); 
    746         fprintf(stderr, "          exactly the same table schema.\n"); 
    747         fprintf(stderr, "      -c  Creates a new table and populates it, this is the\n"); 
    748         fprintf(stderr, "          default if you do not specify any options.\n"); 
    749         fprintf(stderr, "      -p  Prepare mode, only creates the table\n"); 
    750         fprintf(stderr, "\n"); 
    751         fprintf(stderr, "  -g <geometry_column> Specify the name of the geometry column\n"); 
    752         fprintf(stderr, "     (mostly useful in append mode).\n"); 
    753         fprintf(stderr, "\n"); 
    754         fprintf(stderr, "  -D  Use postgresql dump format (defaults to sql insert\n"); 
    755         fprintf(stderr, "      statments.\n"); 
    756         fprintf(stderr, "\n"); 
    757         fprintf(stderr, "  -k  Keep postgresql identifiers case.\n"); 
    758         fprintf(stderr, "\n"); 
    759         fprintf(stderr, "  -i  Use int4 type for all integer dbf fields.\n"); 
    760         fprintf(stderr, "\n"); 
    761         fprintf(stderr, "  -I  Create a GiST index on the geometry column.\n"); 
    762         fprintf(stderr, "\n"); 
    763         fprintf(stderr, "  -S  Generate simple geometries instead of MULTI geometries.\n"); 
    764         fprintf(stderr, "\n"); 
    765         fprintf(stderr, "  -w  Use wkt format (for postgis-0.x support - drops M - drifts coordinates).\n"); 
     734usage(char *me, int exitcode, FILE* out) 
     735{ 
     736        fprintf(out, "RCSID: %s RELEASE: %s\n", rcsid, POSTGIS_VERSION); 
     737        fprintf(out, "USAGE: %s [<options>] <shapefile> [<schema>.]<table>\n", me); 
     738        fprintf(out, "OPTIONS:\n"); 
     739        fprintf(out, "  -s <srid>  Set the SRID field. If not specified it defaults to -1.\n"); 
     740        fprintf(out, "  (-d|a|c|p) These are mutually exclusive options:\n"); 
     741        fprintf(out, "      -d  Drops the table, then recreates it and populates\n"); 
     742        fprintf(out, "          it with current shape file data.\n"); 
     743        fprintf(out, "      -a  Appends shape file into current table, must be\n"); 
     744        fprintf(out, "          exactly the same table schema.\n"); 
     745        fprintf(out, "      -c  Creates a new table and populates it, this is the\n"); 
     746        fprintf(out, "          default if you do not specify any options.\n"); 
     747        fprintf(out, "      -p  Prepare mode, only creates the table.\n"); 
     748        fprintf(out, "  -g <geometry_column> Specify the name of the geometry column\n"); 
     749        fprintf(out, "     (mostly useful in append mode).\n"); 
     750        fprintf(out, "  -D  Use postgresql dump format (defaults to sql insert statments.\n"); 
     751        fprintf(out, "  -k  Keep postgresql identifiers case.\n"); 
     752        fprintf(out, "  -i  Use int4 type for all integer dbf fields.\n"); 
     753        fprintf(out, "  -I  Create a GiST index on the geometry column.\n"); 
     754        fprintf(out, "  -S  Generate simple geometries instead of MULTI geometries.\n"); 
     755        fprintf(out, "  -w  Use wkt format (for postgis-0.x support - drops M - drifts coordinates).\n"); 
    766756#ifdef USE_ICONV 
    767         fprintf(stderr, "\n"); 
    768         fprintf(stderr, "  -W <encoding> Specify the character encoding of Shape's\n"); 
    769         fprintf(stderr, "     attribute column. (default : \"ASCII\")\n"); 
     757        fprintf(out, "  -W <encoding> Specify the character encoding of Shape's\n"); 
     758        fprintf(out, "     attribute column. (default : \"ASCII\")\n"); 
    770759#endif 
    771         fprintf(stderr, "\n"); 
    772         fprintf(stderr, "  -N <policy> Specify NULL geometries handling policy (insert,skip,abort)\n"); 
     760        fprintf(out, "  -N <policy> Specify NULL geometries handling policy (insert,skip,abort)\n"); 
     761        fprintf(out, "  -? Display this help screen\n"); 
    773762        exit (exitcode); 
    774763} 
     
    12791268        extern char *optarg; 
    12801269        extern int optind; 
     1270 
     1271        if ( ARGC == 1 ) { 
     1272                usage(ARGV[0], 0, stdout); 
     1273        } 
    12811274 
    12821275        while ((c = getopt(ARGC, ARGV, "kcdapDs:Sg:iW:wIN:")) != EOF){ 
     
    13551348                    break; 
    13561349               case '?': 
     1350                    usage(ARGV[0], 0, stdout);  
    13571351               default:               
    13581352                return 0;