[patches] ABI cleanup

Nirgal <[email protected]> Thu, 25 Aug 2011 08:00:58 +0000
Newsgroups gmane.comp.db.mdb-tools.devel
Message-ID <[email protected]>
Here's a bunch of patches for cleaning up ABI, that exported symbols not stating with mdb_

nosanitize.diff removes the column name sanitizing options.
Now that all backends properly quote names, this is no longer necessary.
It is my feeling that it causes more problems that it solve.
It tried mdbtools on a Chinese database and got all my tables named "__" for example.
sanitize_name was not matching the mdb_* list of exported symbols.

prop_abi.diff simply renames kkd_to_props into mdb_kkd_to_props

bufferdump.diff simply renames buffer_dump into mdb_buffer_dump


These patches apply to git master after one-off-index.diff already posted to the list.

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev

_______________________________________________
mdbtools-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mdbtools-dev
nosanitize.diff (text/x-patch, 13.2 KB)
Index: mdbtools-0.6pre1/include/mdbtools.h
===================================================================
--- mdbtools-0.6pre1.orig/include/mdbtools.h
+++ mdbtools-0.6pre1/include/mdbtools.h
@@ -161,8 +161,7 @@
 	MDB_SHEXP_COMMENTS = 1<<3, /* export comments on columns & tables */
 	MDB_SHEXP_DEFVALUES = 1<<4, /* export default values */
 	MDB_SHEXP_INDEXES = 1<<5, /* export indices */
-	MDB_SHEXP_RELATIONS = 1<<6, /* export relation (foreign keys) */
-	MDB_SHEXP_SANITIZE = 1<<7 /* clean up names */
+	MDB_SHEXP_RELATIONS = 1<<6 /* export relation (foreign keys) */
 };
 #define MDB_SHEXP_DEFAULT (MDB_SHEXP_CST_NOTNULL | MDB_SHEXP_COMMENTS | MDB_SHEXP_INDEXES | MDB_SHEXP_RELATIONS)
 
@@ -483,7 +482,6 @@
 extern void buffer_dump(const void *buf, int start, size_t len);
 
 /* backend.c */
-extern char* sanitize_name(const char* name);
 extern char* mdb_get_coltype_string(MdbBackend *backend, int col_type); /* obsolete */
 extern int mdb_coltype_takes_length(MdbBackend *backend, int col_type); /* obsolete */
 extern const MdbBackendType* mdb_get_colbacktype(const MdbColumn *col);
Index: mdbtools-0.6pre1/src/libmdb/libmdb.map
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/libmdb.map
+++ mdbtools-0.6pre1/src/libmdb/libmdb.map
@@ -5,7 +5,6 @@
 # LIBMDB_2.0 {
 global:
 	mdb_*;
-	sanitize_name;
 	kkd_to_props;
 	_mdb_put_int16;
 	_mdb_put_int32;
Index: mdbtools-0.6pre1/src/util/mdb-export.c
===================================================================
--- mdbtools-0.6pre1.orig/src/util/mdb-export.c
+++ mdbtools-0.6pre1/src/util/mdb-export.c
@@ -84,13 +84,12 @@
 	char header_row = 1;
 	char quote_text = 1;
 	char *insert_dialect = NULL;
-	char sanitize = 0;
 	char *namespace = "";
 	int  opt;
 	char *value;
 	size_t length;
 
-	while ((opt=getopt(argc, argv, "HQq:X:d:D:R:I:N:S"))!=-1) {
+	while ((opt=getopt(argc, argv, "HQq:X:d:D:R:I:N:"))!=-1) {
 		switch (opt) {
 		case 'H':
 			header_row = 0;
@@ -111,9 +110,6 @@
 			insert_dialect = (char*) g_strdup(optarg);
 			header_row = 0;
 		break;
-		case 'S':
-			sanitize = 1;
-		break;
 		case 'D':
 			mdb_set_date_fmt(optarg);
 		break;
@@ -150,7 +146,6 @@
 		fprintf(stderr,"  -R <delimiter> specify a row delimiter\n");
 		fprintf(stderr,"  -I <backend>   INSERT statements (instead of CSV)\n");
 		fprintf(stderr,"  -D <format>    set the date format (see strftime(3) for details)\n");
-		fprintf(stderr,"  -S             Sanitize names (replace spaces etc. with underscore)\n");
 		fprintf(stderr,"  -q <char>      Use <char> to wrap text-like fields. Default is \".\n");
 		fprintf(stderr,"  -X <char>      Use <char> to escape quoted characters within a field. Default is doubling.\n");
 		fprintf(stderr,"  -N <namespace> Prefix identifiers with namespace\n");
@@ -206,7 +201,7 @@
 			col=g_ptr_array_index(table->columns,j);
 			if (j)
 				fputs(delimiter, stdout);
-			fputs(sanitize ? sanitize_name(col->name) : col->name, stdout);
+			fputs(col->name, stdout);
 		}
 		fputs("\n", stdout);
 	}
@@ -215,19 +210,13 @@
 
 		if (insert_dialect) {
 			char *quoted_name;
-			if (sanitize)
-				quoted_name = sanitize_name(argv[optind + 1]);
-			else
-				quoted_name = mdb->default_backend->quote_schema_name(NULL, argv[optind + 1]);
+			quoted_name = mdb->default_backend->quote_schema_name(NULL, argv[optind + 1]);
 			fprintf(stdout, "INSERT INTO %s%s (", namespace, quoted_name);
 			free(quoted_name);
 			for (j=0;j<table->num_cols;j++) {
 				if (j>0) fputs(", ", stdout);
 				col=g_ptr_array_index(table->columns,j);
-				if (sanitize)
-					quoted_name = sanitize_name(col->name);
-				else
-					quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
+				quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
 				fputs(quoted_name, stdout);
 				free(quoted_name);
 			} 
Index: mdbtools-0.6pre1/src/util/mdb-schema.c
===================================================================
--- mdbtools-0.6pre1.orig/src/util/mdb-schema.c
+++ mdbtools-0.6pre1/src/util/mdb-schema.c
@@ -39,7 +39,6 @@
 		fprintf (stderr, "where options are:\n");
 		fprintf (stderr, "  -T <table>     Only create schema for named table\n");
 		fprintf (stderr, "  -N <namespace> Prefix identifiers with namespace\n");
-		fprintf (stderr, "  -S             Sanitize names (replace spaces etc. with underscore)\n");
 		exit (1);
 	}
 
@@ -64,11 +63,9 @@
 			{"no-indexes", 0, NULL, 0},
 			{"relations", 0, NULL, 0},
 			{"no-relations", 0, NULL, 0},
-			{"sanitize", 0, NULL, 'S'},
-			{"no-sanitize", 0, NULL, 0},
 			{NULL, 0, NULL, 0},
 		};
-		opt = getopt_long(argc, argv, "T:N:S", long_options, &option_index);
+		opt = getopt_long(argc, argv, "T:N:", long_options, &option_index);
 		if (opt == -1)
 			break;
 
@@ -130,10 +127,6 @@
 				export_options &= ~MDB_SHEXP_RELATIONS;
 				break;
 			}
-			if (!strcmp(long_options[option_index].name, "no-sanitize")) {
-				export_options &= ~MDB_SHEXP_SANITIZE;
-				break;
-			}
 			fprintf(stderr, "unimplemented option %s", long_options[option_index].name);
 			if (optarg)
 				fprintf(stderr, " with arg %s", optarg);
@@ -148,10 +141,6 @@
 		case 'N':
 			namespace = (char *) g_strdup(optarg);
 			break;
-
-		case 'S':
-			export_options |= MDB_SHEXP_SANITIZE;
-			break;
 		}
 	}
  
Index: mdbtools-0.6pre1/doc/mdb-export.txt
===================================================================
--- mdbtools-0.6pre1.orig/doc/mdb-export.txt
+++ mdbtools-0.6pre1/doc/mdb-export.txt
@@ -1,7 +1,7 @@
 NAME
   mdb-export - Export data in an MDB database table to CSV format.
 SYNOPSIS
-  mdb-export [-H] [-d <delimiter>] [-R <row delim>] [[-Q] || [-q <quote> [-X <escape>]]] [-I] [-D <format>] [-S] <database> <table>
+  mdb-export [-H] [-d <delimiter>] [-R <row delim>] [[-Q] || [-q <quote> [-X <escape>]]] [-I] [-D <format>] <database> <table>
 
 DESCRIPTION
   mdb-export is a utility program distributed with MDB Tools. 
@@ -15,7 +15,6 @@
   -R            Specify a row delimiter
   -I            INSERT statements (instead of CSV). You must specify the SQL dialect.
   -D            Set the date format (see strftime(3) for details)
-  -S            Sanitize names (replace spaces etc. with underscore)
   -q            Use to wrap text-like fields. Default is ".
   -X            Use to escape quoted characters within a field.  Default is doubling.
 
Index: mdbtools-0.6pre1/doc/mdb-schema.txt
===================================================================
--- mdbtools-0.6pre1.orig/doc/mdb-schema.txt
+++ mdbtools-0.6pre1/doc/mdb-schema.txt
@@ -22,8 +22,6 @@
   --no-indexes        Don't export INDEXes.
   --relations         Export foreign keys constraints. This is the default.
   --no-relations      Don't export foreign keys constraints.
-  -S, --sanitize      Replace non alphanumric characters by underscore.
-  --no-sanitize       Don't replace non alphanumric characters by underscore. This is the default.
 
   backend	Specifies target DDL dialect. Supported values are access, sybase, oracle, postgres, and mysql. If not specified the generated DDL will be in access format.
 
Index: mdbtools-0.6pre1/src/libmdb/backend.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/backend.c
+++ mdbtools-0.6pre1/src/libmdb/backend.c
@@ -154,29 +154,6 @@
 #ifndef JAVA
 static gboolean mdb_drop_backend(gpointer key, gpointer value, gpointer data);
 
-char* sanitize_name(const char* str)
-{
-	char *result = malloc(256);
-	char *p = result;
-
-	if (*str) {
-		*p = isalpha(*str) ? *str : '_';
-		p++;
-        if (!isdigit(*str))  /* if it was a digit, keep it */
-		str++;
-	}
-
-	while (*str) {
-		*p = isalnum(*str) ? *str : '_';
-		p++;
-		str++;
-	}
-
-	*p = 0;
-
-	return result;
-}
-
 static gchar*
 quote_generic(const gchar *value, gchar quote_char, gchar escape_char) {
 	gchar *result, *pr;
@@ -338,7 +315,7 @@
 	mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
 
 	mdb_register_backend("access",
-		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
+		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_DEFVALUES,
 		mdb_access_types, NULL, NULL,
 		"Date()", "Date()",
 		"-- That file uses encoding %s\n",
@@ -348,7 +325,7 @@
 		NULL,
 		quote_schema_name_bracket_merge);
 	mdb_register_backend("sybase",
-		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
+		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES,
 		mdb_sybase_types, &mdb_sybase_shortdate_type, NULL,
 		"getdate()", "getdate()",
 		"-- That file uses encoding %s\n",
@@ -358,7 +335,7 @@
 		"COMMENT ON TABLE %s IS %s;\n",
 		quote_schema_name_dquote);
 	mdb_register_backend("oracle",
-		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_COMMENTS|MDB_SHEXP_INDEXES|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
+		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_COMMENTS|MDB_SHEXP_INDEXES|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES,
 		mdb_oracle_types, &mdb_oracle_shortdate_type, NULL,
 		"current_date", "sysdate",
 		"-- That file uses encoding %s\n",
@@ -368,7 +345,7 @@
 		"COMMENT ON TABLE %s IS %s;\n",
 		quote_schema_name_dquote);
 	mdb_register_backend("postgres",
-		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_INDEXES|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
+		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_INDEXES|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES,
 		mdb_postgres_types, &mdb_postgres_shortdate_type, &mdb_postgres_serial_type,
 		"current_date", "now()",
 		"SET client_encoding = '%s';\n",
@@ -378,7 +355,7 @@
 		"COMMENT ON TABLE %s IS %s;\n",
 		quote_schema_name_dquote);
 	mdb_register_backend("mysql",
-		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
+		MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES,
 		mdb_mysql_types, &mdb_mysql_shortdate_type, NULL,
 		"current_date", "now()",
 		"-- That file uses encoding %s\n",
@@ -453,7 +430,7 @@
  * @table: Table to process
  */
 static void
-mdb_print_indexes(FILE* outfile, MdbTableDef *table, char *namespace, int sanitize)
+mdb_print_indexes(FILE* outfile, MdbTableDef *table, char *namespace)
 {
 	unsigned int i, j;
 	char* quoted_table_name;
@@ -473,10 +450,7 @@
 
 	fprintf (outfile, "-- CREATE INDEXES ...\n");
 
-	if (sanitize)
-		quoted_table_name = sanitize_name(table->name);
-	else
-		quoted_table_name = mdb->default_backend->quote_schema_name(namespace, table->name);
+	quoted_table_name = mdb->default_backend->quote_schema_name(namespace, table->name);
 
 	for (i=0;i<table->num_idxs;i++) {
 		idx = g_ptr_array_index (table->indices, i);
@@ -492,10 +466,7 @@
 			strcat(index_name, idx->name);
 			strcat(index_name, "_idx");
 		}
-		if (sanitize)
-			quoted_name = sanitize_name(index_name);
-		else
-			quoted_name = mdb->default_backend->quote_schema_name(namespace, index_name);
+		quoted_name = mdb->default_backend->quote_schema_name(namespace, index_name);
 		if (idx->index_type==1) {
 			fprintf (outfile, "ALTER TABLE %s ADD CONSTRAINT %s PRIMARY KEY (", quoted_table_name, quoted_name);
 		} else {
@@ -511,10 +482,7 @@
 			if (j)
 				fprintf(outfile, ", ");
 			col=g_ptr_array_index(table->columns,idx->key_col_num[j]-1);
-			if (sanitize)
-				quoted_name = sanitize_name(col->name);
-			else
-				quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
+			quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
 			fprintf (outfile, "%s", quoted_name);
 			if (idx->index_type!=1 && idx->key_col_order[j])
 				/* no DESC for primary keys */
@@ -667,14 +635,10 @@
 	unsigned int i;
 	char* quoted_table_name;
 	char* quoted_name;
-	int sanitize = export_options & MDB_SHEXP_SANITIZE;
 	MdbProperties *props;
 	const char *prop_value;
 
-	if (sanitize)
-		quoted_table_name = sanitize_name(entry->object_name);
-	else
-		quoted_table_name = mdb->default_backend->quote_schema_name(namespace, entry->object_name);
+	quoted_table_name = mdb->default_backend->quote_schema_name(namespace, entry->object_name);
 
 	/* drop the table if it exists */
 	if (export_options & MDB_SHEXP_DROPTABLE)
@@ -693,10 +657,7 @@
 	for (i = 0; i < table->num_cols; i++) {
 		col = g_ptr_array_index (table->columns, i);
 
-		if (sanitize)
-			quoted_name = sanitize_name(col->name);
-		else
-			quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
+		quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
 		fprintf (outfile, "\t%s\t\t\t%s", quoted_name,
 			mdb_get_colbacktype_string (col));
 		free(quoted_name);
@@ -773,10 +734,7 @@
 		if (!props)
 			continue;
 
-		if (sanitize)
-			quoted_name = sanitize_name(col->name);
-		else
-			quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
+		quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
 
 		if (export_options & MDB_SHEXP_CST_NOTEMPTY) {
 			prop_value = mdb_col_get_prop(col, "AllowZeroLength");
@@ -816,7 +774,7 @@
 
 	if (export_options & MDB_SHEXP_INDEXES)
 		// prints all the indexes of that table
-		mdb_print_indexes(outfile, table, namespace, sanitize);
+		mdb_print_indexes(outfile, table, namespace);
 
 	free(quoted_table_name);
prop_abi.diff (text/x-patch, 3.9 KB)
Index: mdbtools-0.6pre1/src/libmdb/props.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/props.c
+++ mdbtools-0.6pre1/src/libmdb/props.c
@@ -147,8 +147,13 @@
 		fputc('\n', outfile);
 }
 
+/*
+ * That function takes a raw KKD/MR2 binary buffer,
+ * typically read from LvProp in table MSysbjects
+ * and returns a GPtrArray of MdbProps*
+ */
 GArray*
-kkd_to_props(MdbHandle *mdb, void *kkd, size_t len) {
+mdb_kkd_to_props(MdbHandle *mdb, void *buffer, size_t len) {
 	guint32 record_len;
 	guint16 record_type;
 	size_t pos;
@@ -156,12 +161,12 @@
 	MdbProperties *props;
 
 #if MDB_DEBUG
-	buffer_dump(kkd, 0, len);
+	buffer_dump(buffer, 0, len);
 #endif
-	mdb_debug(MDB_DEBUG_PROPS,"starting prop parsing of type %s", kkd);
-	if (strcmp("KKD", kkd) && strcmp("MR2", kkd)) {
+	mdb_debug(MDB_DEBUG_PROPS,"starting prop parsing of type %s", buffer);
+	if (strcmp("KKD", buffer) && strcmp("MR2", buffer)) {
 		fprintf(stderr, "Unrecognized format.\n");
-		buffer_dump(kkd, 0, len);
+		buffer_dump(buffer, 0, len);
 		return NULL;
 	}
 
@@ -169,14 +174,14 @@
 
 	pos = 4;
 	while (pos < len) {
-		record_len = mdb_get_int32(kkd, pos);
-		record_type = mdb_get_int16(kkd, pos + 4);
+		record_len = mdb_get_int32(buffer, pos);
+		record_type = mdb_get_int16(buffer, pos + 4);
 		mdb_debug(MDB_DEBUG_PROPS,"prop chunk type:0x%04x len:%d", record_type, record_len);
-		//buffer_dump(kkd, pos+4, record_len);
+		//buffer_dump(buffer, pos+4, record_len);
 		switch (record_type) {
 			case 0x80:
 				if (names) free_names(names);
-				names = mdb_read_props_list(mdb, kkd+pos+6, record_len - 6);
+				names = mdb_read_props_list(mdb, buffer+pos+6, record_len - 6);
 				break;
 			case 0x00:
 			case 0x01:
@@ -184,7 +189,7 @@
 					fprintf(stderr,"sequence error!\n");
 					break;
 				}
-				props = mdb_read_props(mdb, names, kkd+pos+6, record_len - 6);
+				props = mdb_read_props(mdb, names, buffer+pos+6, record_len - 6);
 				g_array_append_val(result, props);
 				//mdb_dump_props(props, stderr, 1);
 				break;
Index: mdbtools-0.6pre1/src/libmdb/catalog.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/catalog.c
+++ mdbtools-0.6pre1/src/libmdb/catalog.c
@@ -117,7 +117,7 @@
 				size_t kkd_len;
 				void *kkd = mdb_ole_read_full(mdb, col_props, &kkd_len);
 				//buffer_dump(kkd, 0, kkd_len);
-				entry->props = kkd_to_props(mdb, kkd, kkd_len);
+				entry->props = mdb_kkd_to_props(mdb, kkd, kkd_len);
 				free(kkd);
 			}
 		}
Index: mdbtools-0.6pre1/src/libmdb/libmdb.map
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/libmdb.map
+++ mdbtools-0.6pre1/src/libmdb/libmdb.map
@@ -5,7 +5,6 @@
 # LIBMDB_2.0 {
 global:
 	mdb_*;
-	kkd_to_props;
 	_mdb_put_int16;
 	_mdb_put_int32;
 	buffer_dump;
Index: mdbtools-0.6pre1/src/util/mdb-prop.c
===================================================================
--- mdbtools-0.6pre1.orig/src/util/mdb-prop.c
+++ mdbtools-0.6pre1/src/util/mdb-prop.c
@@ -96,8 +96,10 @@
 }
 void dump_kkd(MdbHandle *mdb, void *kkd, size_t len)
 {
-	GArray *aprops = kkd_to_props(mdb, kkd, len);
+	GArray *aprops = mdb_kkd_to_props(mdb, kkd, len);
 	int i;
+	if (!aprops)
+		return;
 	for (i=0; i<aprops->len; ++i) {
 		MdbProperties *props = g_array_index(aprops, MdbProperties*, i);
 		mdb_dump_props(props, stdout, 1);
Index: mdbtools-0.6pre1/include/mdbtools.h
===================================================================
--- mdbtools-0.6pre1.orig/include/mdbtools.h
+++ mdbtools-0.6pre1/include/mdbtools.h
@@ -544,7 +544,7 @@
 /* props.c */
 extern void mdb_free_props(MdbProperties *props);
 extern void mdb_dump_props(MdbProperties *props, FILE *outfile, int show_name);
-extern GArray* kkd_to_props(MdbHandle *mdb, void *kkd, size_t len);
+extern GArray* mdb_kkd_to_props(MdbHandle *mdb, void *kkd, size_t len);
 
 
 /* worktable.c */
bufferdump.diff (text/x-patch, 11.2 KB)
Index: mdbtools-0.6pre1/include/mdbtools.h
===================================================================
--- mdbtools-0.6pre1.orig/include/mdbtools.h
+++ mdbtools-0.6pre1/include/mdbtools.h
@@ -479,7 +479,7 @@
 extern int mdb_read_row(MdbTableDef *table, unsigned int row);
 
 /* dump.c */
-extern void buffer_dump(const void *buf, int start, size_t len);
+extern void mdb_buffer_dump(const void *buf, int start, size_t len);
 
 /* backend.c */
 extern char* mdb_get_coltype_string(MdbBackend *backend, int col_type); /* obsolete */
Index: mdbtools-0.6pre1/src/libmdb/catalog.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/catalog.c
+++ mdbtools-0.6pre1/src/libmdb/catalog.c
@@ -116,7 +116,7 @@
 			if (kkd_size_ole) {
 				size_t kkd_len;
 				void *kkd = mdb_ole_read_full(mdb, col_props, &kkd_len);
-				//buffer_dump(kkd, 0, kkd_len);
+				//mdb_buffer_dump(kkd, 0, kkd_len);
 				entry->props = mdb_kkd_to_props(mdb, kkd, kkd_len);
 				free(kkd);
 			}
Index: mdbtools-0.6pre1/src/libmdb/data.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/data.c
+++ mdbtools-0.6pre1/src/libmdb/data.c
@@ -283,7 +283,7 @@
 #endif 
 
 #if MDB_DEBUG
-	buffer_dump(mdb->pg_buf, row_start, row_size);
+	mdb_buffer_dump(mdb->pg_buf, row_start, row_size);
 #endif
 
 	/* take advantage of mdb_crack_row() to clean up binding */
@@ -546,7 +546,7 @@
 		if (col->bind_ptr) {
 			memcpy(col->bind_ptr, buf + row_start, len);
 			if (mdb_get_option(MDB_DEBUG_OLE))
-				buffer_dump(col->bind_ptr, 0, 16);
+				mdb_buffer_dump(col->bind_ptr, 0, 16);
 		}
 		return len;
 	} else if ((ole_len & 0xff000000) == 0) {
@@ -683,7 +683,7 @@
 	} 
 
 #if MDB_DEBUG
-	buffer_dump(pg_buf, start, MDB_MEMO_OVERHEAD);
+	mdb_buffer_dump(pg_buf, start, MDB_MEMO_OVERHEAD);
 #endif
 
 	/* The 32 bit integer at offset 0 is the length of the memo field
@@ -710,7 +710,7 @@
 #if MDB_DEBUG
 		printf("row num %d start %d len %d\n",
 			pg_row & 0xff, row_start, len);
-		buffer_dump(buf, row_start, len);
+		mdb_buffer_dump(buf, row_start, len);
 #endif
 		mdb_unicode2ascii(mdb, buf + row_start, len, text, MDB_BIND_SIZE);
 		return text;
Index: mdbtools-0.6pre1/src/libmdb/dump.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/dump.c
+++ mdbtools-0.6pre1/src/libmdb/dump.c
@@ -6,7 +6,7 @@
 #include "dmalloc.h"
 #endif
 
-void buffer_dump(const void* buf, int start, size_t len)
+void mdb_buffer_dump(const void* buf, int start, size_t len)
 {
 	char asc[20];
 	int j, k;
Index: mdbtools-0.6pre1/src/libmdb/index.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/index.c
+++ mdbtools-0.6pre1/src/libmdb/index.c
@@ -645,9 +645,9 @@
 		/* handle compressed indexes, single key indexes only? */
 		if (idx->num_keys==1 && idx_sz>0 && ipg->len - 4 < idx_sz) {
 			//printf("short index found\n");
-			//buffer_dump(ipg->cache_value, 0, idx_sz);
+			//mdb_buffer_dump(ipg->cache_value, 0, idx_sz);
 			memcpy(&ipg->cache_value[idx_sz - (ipg->len - 4)], &mdb->pg_buf[ipg->offset], ipg->len);
-			//buffer_dump(ipg->cache_value, 0, idx_sz);
+			//mdb_buffer_dump(ipg->cache_value, 0, idx_sz);
 		} else {
 			idx_start = ipg->offset + (ipg->len - 4 - idx_sz);
 			memcpy(ipg->cache_value, &mdb->pg_buf[idx_start], idx_sz);
@@ -660,7 +660,7 @@
 	} while (!passed);
 
 	//fprintf(stdout,"len = %d pos %d\n", ipg->len, ipg->mask_pos);
-	//buffer_dump(mdb->pg_buf, ipg->offset, ipg->len);
+	//mdb_buffer_dump(mdb->pg_buf, ipg->offset, ipg->len);
 
 	return ipg->len;
 }
Index: mdbtools-0.6pre1/src/libmdb/props.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/props.c
+++ mdbtools-0.6pre1/src/libmdb/props.c
@@ -31,7 +31,7 @@
 	names = g_ptr_array_new();
 	int i=0;
 #if MDB_DEBUG
-	buffer_dump(kkd, 0, len);
+	mdb_buffer_dump(kkd, 0, len);
 #endif
 	pos = 0;
 	while (pos < len) {
@@ -39,7 +39,7 @@
 		pos += 2;
 		if (mdb_get_option(MDB_DEBUG_PROPS)) {
 			fprintf(stderr, "%02d ",i++);
-			buffer_dump(kkd, pos - 2, record_len + 2);
+			mdb_buffer_dump(kkd, pos - 2, record_len + 2);
 		}
 		name = g_malloc(3*record_len + 1); /* worst case scenario is 3 bytes out per byte in */
 		mdb_unicode2ascii(mdb, &kkd[pos], record_len, name, 3*record_len);
@@ -86,7 +86,7 @@
 	int i=0;
 
 #if MDB_DEBUG
-	buffer_dump(kkd, 0, len);
+	mdb_buffer_dump(kkd, 0, len);
 #endif
 	pos = 0;
 
@@ -116,7 +116,7 @@
 		if (mdb_get_option(MDB_DEBUG_PROPS)) {
 			fprintf(stderr, "%02d ",i++);
 			mdb_debug(MDB_DEBUG_PROPS,"elem %d (%s) dsize %d dtype %d", elem, name, dsize, dtype);
-			buffer_dump(value, 0, dsize);
+			mdb_buffer_dump(value, 0, dsize);
 		}
 		if (dtype == MDB_MEMO) dtype = MDB_TEXT;
 		if (dtype == MDB_BOOL) {
@@ -161,12 +161,12 @@
 	MdbProperties *props;
 
 #if MDB_DEBUG
-	buffer_dump(buffer, 0, len);
+	mdb_buffer_dump(buffer, 0, len);
 #endif
 	mdb_debug(MDB_DEBUG_PROPS,"starting prop parsing of type %s", buffer);
 	if (strcmp("KKD", buffer) && strcmp("MR2", buffer)) {
 		fprintf(stderr, "Unrecognized format.\n");
-		buffer_dump(buffer, 0, len);
+		mdb_buffer_dump(buffer, 0, len);
 		return NULL;
 	}
 
@@ -177,7 +177,7 @@
 		record_len = mdb_get_int32(buffer, pos);
 		record_type = mdb_get_int16(buffer, pos + 4);
 		mdb_debug(MDB_DEBUG_PROPS,"prop chunk type:0x%04x len:%d", record_type, record_len);
-		//buffer_dump(buffer, pos+4, record_len);
+		//mdb_buffer_dump(buffer, pos+4, record_len);
 		switch (record_type) {
 			case 0x80:
 				if (names) free_names(names);
Index: mdbtools-0.6pre1/src/libmdb/table.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/table.c
+++ mdbtools-0.6pre1/src/libmdb/table.c
@@ -98,7 +98,7 @@
 	mdb_find_pg_row(mdb, pg_row, &buf, &row_start, &(table->map_sz));
 	table->usage_map = g_memdup(buf + row_start, table->map_sz);
 	if (mdb_get_option(MDB_DEBUG_USAGE)) 
-		buffer_dump(buf, row_start, table->map_sz);
+		mdb_buffer_dump(buf, row_start, table->map_sz);
 	mdb_debug(MDB_DEBUG_USAGE,"usage map found on page %ld row %d start %d len %d",
 		pg_row >> 8, pg_row & 0xff, row_start, table->map_sz);
 
@@ -232,7 +232,7 @@
 	for (i=0;i<table->num_cols;i++) {
 #ifdef MDB_DEBUG
 	/* printf("column %d\n", i);
-	buffer_dump(mdb->pg_buf, cur_pos, fmt->tab_col_entry_size); */
+	mdb_buffer_dump(mdb->pg_buf, cur_pos, fmt->tab_col_entry_size); */
 #endif
 		read_pg_if_n(mdb, col, &cur_pos, fmt->tab_col_entry_size);
 		pcol = (MdbColumn *) g_malloc0(sizeof(MdbColumn));
Index: mdbtools-0.6pre1/src/libmdb/write.c
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/write.c
+++ mdbtools-0.6pre1/src/libmdb/write.c
@@ -158,7 +158,7 @@
 	unsigned int i;
 
 	if (mdb_get_option(MDB_DEBUG_ROW)) {
-		buffer_dump(pg_buf, row_start, row_end - row_start + 1);
+		mdb_buffer_dump(pg_buf, row_start, row_end - row_start + 1);
 	}
 
 	if (IS_JET4(mdb)) {
@@ -539,7 +539,7 @@
 	}
 	new_row_size = mdb_pack_row(table, row_buffer, num_fields, fields);
 	if (mdb_get_option(MDB_DEBUG_WRITE)) {
-		buffer_dump(row_buffer, 0, new_row_size);
+		mdb_buffer_dump(row_buffer, 0, new_row_size);
 	}
 	pgnum = mdb_map_find_next_freepage(table, new_row_size);
 	if (!pgnum) {
@@ -550,8 +550,8 @@
 	rownum = mdb_add_row_to_pg(table, row_buffer, new_row_size);
 
 	if (mdb_get_option(MDB_DEBUG_WRITE)) {
-		buffer_dump(mdb->pg_buf, 0, 40);
-		buffer_dump(mdb->pg_buf, fmt->pg_size - 160, 160);
+		mdb_buffer_dump(mdb->pg_buf, 0, 40);
+		mdb_buffer_dump(mdb->pg_buf, fmt->pg_size - 160, 160);
 	}
 	mdb_debug(MDB_DEBUG_WRITE, "writing page %d", pgnum);
 	if (!mdb_write_pg(mdb, pgnum)) {
@@ -653,7 +653,7 @@
 
 	mdb_debug(MDB_DEBUG_WRITE,"page %lu row %d start %d end %d", (unsigned long) table->cur_phys_pg, table->cur_row-1, row_start, row_end);
 	if (mdb_get_option(MDB_DEBUG_LIKE))
-		buffer_dump(mdb->pg_buf, row_start, old_row_size);
+		mdb_buffer_dump(mdb->pg_buf, row_start, old_row_size);
 
 	for (i=0;i<table->num_cols;i++) {
 		col = g_ptr_array_index(table->columns,i);
@@ -679,7 +679,7 @@
 
 	new_row_size = mdb_pack_row(table, row_buffer, num_fields, fields);
 	if (mdb_get_option(MDB_DEBUG_WRITE)) 
-		buffer_dump(row_buffer, 0, new_row_size);
+		mdb_buffer_dump(row_buffer, 0, new_row_size);
 	if (new_row_size > (old_row_size + mdb_pg_get_freespace(mdb))) {
 		fprintf(stderr, "No space left on this page, update will not occur\n");
 		return 0;
@@ -702,8 +702,8 @@
 int i, pos;
 
 	if (mdb_get_option(MDB_DEBUG_WRITE)) {
-		buffer_dump(mdb->pg_buf, 0, 40);
-		buffer_dump(mdb->pg_buf, pg_size - 160, 160);
+		mdb_buffer_dump(mdb->pg_buf, 0, 40);
+		mdb_buffer_dump(mdb->pg_buf, pg_size - 160, 160);
 	}
 	mdb_debug(MDB_DEBUG_WRITE,"updating row %d on page %lu", row, (unsigned long) table->cur_phys_pg);
 	new_pg = mdb_new_data_pg(entry);
@@ -741,8 +741,8 @@
 
 	_mdb_put_int16(mdb->pg_buf, 2, mdb_pg_get_freespace(mdb));
 	if (mdb_get_option(MDB_DEBUG_WRITE)) {
-		buffer_dump(mdb->pg_buf, 0, 40);
-		buffer_dump(mdb->pg_buf, pg_size - 160, 160);
+		mdb_buffer_dump(mdb->pg_buf, 0, 40);
+		mdb_buffer_dump(mdb->pg_buf, pg_size - 160, 160);
 	}
 	/* drum roll, please */
 	if (!mdb_write_pg(mdb, table->cur_phys_pg)) {
@@ -803,9 +803,9 @@
 		key_hash[col->col_size - 1] &= 0x7f;
 
 		if (mdb_get_option(MDB_DEBUG_WRITE)) {
-			buffer_dump(mdb->pg_buf, ipg->offset, ipg->len);
-			buffer_dump(mdb->pg_buf, ipg->offset + 1, col->col_size);
-			buffer_dump(key_hash, 0, col->col_size);
+			mdb_buffer_dump(mdb->pg_buf, ipg->offset, ipg->len);
+			mdb_buffer_dump(mdb->pg_buf, ipg->offset + 1, col->col_size);
+			mdb_buffer_dump(key_hash, 0, col->col_size);
 		}
 
 		memcpy(new_pg + ipg->offset, mdb->pg_buf + ipg->offset, ipg->len);
@@ -823,8 +823,8 @@
 	key_hash[0] |= 0x080;
 	if (mdb_get_option(MDB_DEBUG_WRITE)) {
 		printf("key_hash\n");
-		buffer_dump(idx_fields[0].value, 0, col->col_size);
-		buffer_dump(key_hash, 0, col->col_size);
+		mdb_buffer_dump(idx_fields[0].value, 0, col->col_size);
+		mdb_buffer_dump(key_hash, 0, col->col_size);
 		printf("--------\n");
 	}
 	((char *)new_pg)[ipg->offset] = 0x7f;
@@ -834,12 +834,12 @@
 	ipg->idx_starts[row++] = ipg->offset + ipg->len;
 	//ipg->idx_starts[row] = ipg->offset + ipg->len;
 	if (mdb_get_option(MDB_DEBUG_WRITE)) {
-		buffer_dump(mdb->pg_buf, 0, mdb->fmt->pg_size);
+		mdb_buffer_dump(mdb->pg_buf, 0, mdb->fmt->pg_size);
 	}
 	memcpy(mdb->pg_buf, new_pg, mdb->fmt->pg_size);
 	mdb_index_pack_bitmap(mdb, ipg);
 	if (mdb_get_option(MDB_DEBUG_WRITE)) {
-		buffer_dump(mdb->pg_buf, 0, mdb->fmt->pg_size);
+		mdb_buffer_dump(mdb->pg_buf, 0, mdb->fmt->pg_size);
 	}
 	g_free(new_pg);
 
Index: mdbtools-0.6pre1/src/util/prole.c
===================================================================
--- mdbtools-0.6pre1.orig/src/util/prole.c
+++ mdbtools-0.6pre1/src/util/prole.c
@@ -84,7 +84,7 @@
 
         mdb_rewind_table(table);
 	while (mdb_fetch_row(table)) {
-		buffer_dump(ole_data, 0, len);
+		mdb_buffer_dump(ole_data, 0, len);
 		printf("---\n");
 	}
 
Index: mdbtools-0.6pre1/src/libmdb/libmdb.map
===================================================================
--- mdbtools-0.6pre1.orig/src/libmdb/libmdb.map
+++ mdbtools-0.6pre1/src/libmdb/libmdb.map
@@ -7,7 +7,6 @@
 	mdb_*;
 	_mdb_put_int16;
 	_mdb_put_int32;
-	buffer_dump;
 
 local:
 	*;