From 1638ed6202b77b521214128189dc4aacdb5fe098 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 13 May 2013 06:27:44 +0000 Subject: Handle structured key and content data in gdbmtool. * src/datconv.c: New file. * src/Makefile.am (gdbmtool_SOURCES): Add datconv.c. * src/gdbmtool.h (slist, kvpair): New structures. (gdbmarg): Keep various types of data depending on the value of the type member. (slist_new, slist_free) (kvpair_string, kvpair_list): New protos. (gdbmarg_new): Remove. (gdbmarg_string, gdbmarg_datum) (gdbmarg_kvpair, gdbmarg_free) (gdbmarg_destroy): New protos. (xd_expand, xd_store, datadef_locate): New protos. (field, dsegm): New structs. (dsegm_new, dsegm_new_field, dsegm_free_list): New protos. * src/gdbmtool.c: Rewrite. * src/gram.y: Change grammar to allow for defining key and content structure and for supplying structured data as arguments to fetch, store and similar functions. * src/lex.l: Handle new token types. * tests/dtload.c (main): Fix parser. * tests/gtload.c: Likewise. --- tests/dtload.c | 7 ++++--- tests/gtload.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/dtload.c b/tests/dtload.c index 6ebd638..a02b36c 100644 --- a/tests/dtload.c +++ b/tests/dtload.c @@ -134,11 +134,12 @@ main (int argc, char **argv) progname, line); continue; } - + buf[j] = 0; + key.dptr = buf; key.dsize = j + data_z; - data.dptr = buf + j + 1; - data.dsize = strlen (buf + j + 1) + data_z; + data.dptr = buf + i + 1; + data.dsize = strlen (data.dptr) + data_z; if (store (key, data) != 0) { fprintf (stderr, "%s: %d: item not inserted\n", diff --git a/tests/gtload.c b/tests/gtload.c index b89ae1f..2920463 100644 --- a/tests/gtload.c +++ b/tests/gtload.c @@ -157,11 +157,12 @@ main (int argc, char **argv) progname, line); continue; } - + buf[j] = 0; + key.dptr = buf; key.dsize = j + data_z; - data.dptr = buf + j + 1; - data.dsize = strlen (buf + j + 1) + data_z; + data.dptr = buf + i + 1; + data.dsize = strlen (data.dptr) + data_z; if (gdbm_store (dbf, key, data, replace) != 0) { fprintf (stderr, "%s: %d: item not inserted\n", -- cgit v1.2.1