summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-12-03 00:23:14 +0000
committerTim Potter <tpot@samba.org>2001-12-03 00:23:14 +0000
commit303b3a35951211775a4e87bcca47cc21236aa422 (patch)
treea395fb2b6babaa93f5a409f7ffa766e7e0a61889
parent21a366afbe9dc5f4878f97bb03525452bbbc4e41 (diff)
downloadsamba-303b3a35951211775a4e87bcca47cc21236aa422.tar.gz
samba-303b3a35951211775a4e87bcca47cc21236aa422.tar.xz
samba-303b3a35951211775a4e87bcca47cc21236aa422.zip
Updated definition of fstring.
print_asc(): Don't try to print a trailing NULL character print_key(), print_rec(): Display key in ASCII
-rw-r--r--source/tdb/tdbtool.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/tdb/tdbtool.c b/source/tdb/tdbtool.c
index 4e674664b79..4198d124189 100644
--- a/source/tdb/tdbtool.c
+++ b/source/tdb/tdbtool.c
@@ -37,7 +37,7 @@
/* a tdb tool for manipulating a tdb database */
-#define FSTRING_LEN 128
+#define FSTRING_LEN 256
typedef char fstring[FSTRING_LEN];
typedef struct connections_key {
@@ -65,6 +65,13 @@ static int print_rec(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
static void print_asc(unsigned char *buf,int len)
{
int i;
+
+ /* We're probably printing ASCII strings so don't try to display
+ the trailing NULL character. */
+
+ if (buf[len - 1] == 0)
+ len--;
+
for (i=0;i<len;i++)
printf("%c",isprint(buf[i])?buf[i]:'.');
}
@@ -299,7 +306,7 @@ static int print_rec(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
return 0;
#else
printf("\nkey %d bytes\n", key.dsize);
- print_data(key.dptr, key.dsize);
+ print_asc(key.dptr, key.dsize);
printf("data %d bytes\n", dbuf.dsize);
print_data(dbuf.dptr, dbuf.dsize);
return 0;
@@ -308,8 +315,8 @@ static int print_rec(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
static int print_key(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
{
- printf("\nkey %d bytes\n", key.dsize);
- print_data(key.dptr, key.dsize);
+ print_asc(key.dptr, key.dsize);
+ printf("\n");
return 0;
}