summaryrefslogtreecommitdiff
path: root/examples/c/csv
diff options
context:
space:
mode:
Diffstat (limited to 'examples/c/csv')
-rw-r--r--examples/c/csv/DbRecord.c2
-rw-r--r--examples/c/csv/README2
-rw-r--r--examples/c/csv/code.c13
-rw-r--r--examples/c/csv/csv.h2
-rw-r--r--examples/c/csv/csv_extern.h8
-rw-r--r--examples/c/csv/db.c12
-rw-r--r--examples/c/csv/load.c2
-rw-r--r--examples/c/csv/load_main.c18
-rw-r--r--examples/c/csv/query.c2
-rw-r--r--examples/c/csv/query_main.c2
-rw-r--r--examples/c/csv/util.c14
11 files changed, 44 insertions, 33 deletions
diff --git a/examples/c/csv/DbRecord.c b/examples/c/csv/DbRecord.c
index b25aeadc..d3c975b4 100644
--- a/examples/c/csv/DbRecord.c
+++ b/examples/c/csv/DbRecord.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$
*/
diff --git a/examples/c/csv/README b/examples/c/csv/README
index 6d5eb878..1da48a36 100644
--- a/examples/c/csv/README
+++ b/examples/c/csv/README
@@ -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$
*/
diff --git a/examples/c/csv/code.c b/examples/c/csv/code.c
index 24aaac81..85c6c792 100644
--- a/examples/c/csv/code.c
+++ b/examples/c/csv/code.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$
*/
@@ -26,7 +26,8 @@ int usage(void);
* Globals
*/
FILE *cfp; /* C source file */
-FILE *hfp; /* C source file */
+FILE *ffp; /* CSV file */
+FILE *hfp; /* C header file */
char *progname; /* Program name */
int verbose; /* Verbose flag */
@@ -45,6 +46,8 @@ main(int argc, char *argv[])
else
++progname;
+ ffp = NULL;
+
/* Initialize arguments. */
cfile = "csv_local.c"; /* Default header/source files */
hfile = "csv_local.h";
@@ -55,8 +58,8 @@ main(int argc, char *argv[])
case 'c':
cfile = optarg;
break;
- 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, strerror(errno));
return (EXIT_FAILURE);
@@ -75,7 +78,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (*argv != NULL)
+ if (*argv != NULL || ffp == NULL)
return (usage());
/* Load records from the input file. */
diff --git a/examples/c/csv/csv.h b/examples/c/csv/csv.h
index ac9fac2a..beb67cbc 100644
--- a/examples/c/csv/csv.h
+++ b/examples/c/csv/csv.h
@@ -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$
*/
diff --git a/examples/c/csv/csv_extern.h b/examples/c/csv/csv_extern.h
index a541bb5c..59b468f0 100644
--- a/examples/c/csv/csv_extern.h
+++ b/examples/c/csv/csv_extern.h
@@ -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$
*/
@@ -17,9 +17,9 @@ extern void DbRecord_print(DbRecord *, FILE *);
extern int DbRecord_read(u_long, DbRecord *);
extern int DbRecord_search_field_name(char *, char *, OPERATOR);
extern int DbRecord_search_field_number(u_int, char *, OPERATOR);
-extern int compare_double(DB *, const DBT *, const DBT *);
-extern int compare_string(DB *, const DBT *, const DBT *);
-extern int compare_ulong(DB *, const DBT *, const DBT *);
+extern int compare_double(DB *, const DBT *, const DBT *, size_t *);
+extern int compare_string(DB *, const DBT *, const DBT *, size_t *);
+extern int compare_ulong(DB *, const DBT *, const DBT *, size_t *);
extern int csv_env_close(void);
extern int csv_env_open(const char *, int);
extern int csv_secondary_close(void);
diff --git a/examples/c/csv/db.c b/examples/c/csv/db.c
index dc72f0d8..e138d5b8 100644
--- a/examples/c/csv/db.c
+++ b/examples/c/csv/db.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$
*/
@@ -10,7 +10,7 @@
#include "csv_local.h"
#include "csv_extern.h"
-static int compare_uint32(DB *, const DBT *, const DBT *);
+static int compare_uint32(DB *, const DBT *, const DBT *, size_t *);
/*
* csv_env_init --
@@ -138,7 +138,7 @@ csv_secondary_open()
{
DB *sdb;
DbField *f;
- int ret, (*fcmp)(DB *, const DBT *, const DBT *);
+ int ret, (*fcmp)(DB *, const DBT *, const DBT *, size_t *);
/*
* Create secondary database handles.
@@ -232,11 +232,13 @@ csv_secondary_close()
* Compare two keys.
*/
static int
-compare_uint32(DB *db_arg, const DBT *a_arg, const DBT *b_arg)
+compare_uint32(DB *db_arg, const DBT *a_arg, const DBT *b_arg, size_t *locp)
{
u_int32_t a, b;
- db_arg = db_arg; /* Quiet compiler. */
+ /* Quiet compiler. */
+ db_arg = db_arg;
+ locp = NULL;
memcpy(&a, a_arg->data, sizeof(u_int32_t));
memcpy(&b, b_arg->data, sizeof(u_int32_t));
diff --git a/examples/c/csv/load.c b/examples/c/csv/load.c
index 74fadfe0..708fd0ea 100644
--- a/examples/c/csv/load.c
+++ b/examples/c/csv/load.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$
*/
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());
/*
diff --git a/examples/c/csv/query.c b/examples/c/csv/query.c
index f41dc560..e2c4e223 100644
--- a/examples/c/csv/query.c
+++ b/examples/c/csv/query.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$
*/
diff --git a/examples/c/csv/query_main.c b/examples/c/csv/query_main.c
index ed22283e..eb156367 100644
--- a/examples/c/csv/query_main.c
+++ b/examples/c/csv/query_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$
*/
diff --git a/examples/c/csv/util.c b/examples/c/csv/util.c
index c8cfa6c0..bcc280cc 100644
--- a/examples/c/csv/util.c
+++ b/examples/c/csv/util.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$
*/
@@ -156,11 +156,13 @@ secondary_callback(DB *db_arg, const DBT *key, const DBT *data, DBT *result)
* Compare two keys.
*/
int
-compare_double(DB *db_arg, const DBT *a_arg, const DBT *b_arg)
+compare_double(DB *db_arg, const DBT *a_arg, const DBT *b_arg, size_t *locp)
{
double a, b;
- db_arg = db_arg; /* Quiet compiler. */
+ /* Quiet compiler. */
+ db_arg = db_arg;
+ locp = NULL;
memcpy(&a, a_arg->data, sizeof(double));
memcpy(&b, b_arg->data, sizeof(double));
@@ -172,11 +174,13 @@ compare_double(DB *db_arg, const DBT *a_arg, const DBT *b_arg)
* Compare two keys.
*/
int
-compare_ulong(DB *db_arg, const DBT *a_arg, const DBT *b_arg)
+compare_ulong(DB *db_arg, const DBT *a_arg, const DBT *b_arg, size_t *locp)
{
u_long a, b;
- db_arg = db_arg; /* Quiet compiler. */
+ /* Quiet compiler. */
+ db_arg = db_arg;
+ locp = NULL;
memcpy(&a, a_arg->data, sizeof(u_long));
memcpy(&b, b_arg->data, sizeof(u_long));