diff options
Diffstat (limited to 'examples/c/csv/load_main.c')
-rw-r--r-- | examples/c/csv/load_main.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/c/csv/load_main.c b/examples/c/csv/load_main.c index 1caeda00..5e42e406 100644 --- a/examples/c/csv/load_main.c +++ b/examples/c/csv/load_main.c @@ -1,7 +1,7 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ @@ -15,11 +15,12 @@ static int usage(void); /* * Globals */ -DB_ENV *dbenv; /* Database environment */ -DB *db; /* Primary database */ +DB_ENV *dbenv; /* Database environment */ +DB *db; /* Primary database */ DB **secondary; /* Secondaries */ -int verbose; /* Program verbosity */ -char *progname; /* Program name */ +int verbose; /* Program verbosity */ +char *progname; /* Program name */ +FILE *ffp; /* CSV file */ int main(int argc, char *argv[]) @@ -37,6 +38,7 @@ main(int argc, char *argv[]) else ++progname; verbose = 0; + ffp = NULL; /* Initialize arguments. */ home = NULL; @@ -46,8 +48,8 @@ main(int argc, char *argv[]) /* Process arguments. */ while ((ch = getopt(argc, argv, "F:f:h:V:v")) != EOF) switch (ch) { - case 'f': - if (freopen(optarg, "r", stdin) == NULL) { + case 'f': /* Required argument */ + if ((ffp = freopen(optarg, "r", stdin)) == NULL) { fprintf(stderr, "%s: %s\n", optarg, db_strerror(errno)); return (EXIT_FAILURE); @@ -76,7 +78,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (*argv != NULL) + if (*argv != NULL || ffp == NULL) return (usage()); /* |