summaryrefslogtreecommitdiff
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
commit317106452176da6e6ef36bb4189be609e0638a11 (patch)
tree2b0e604ae997498376d7a92ff03ba8d76005ba0d
parent61f68bde8242b454881cb73a7d52c2020e5dbaf2 (diff)
downloadsamba-317106452176da6e6ef36bb4189be609e0638a11.tar.gz
samba-317106452176da6e6ef36bb4189be609e0638a11.tar.bz2
samba-317106452176da6e6ef36bb4189be609e0638a11.zip
Updated definition of fstring.
print_asc(): Don't try to print a trailing NULL character print_key(), print_rec(): Display key in ASCII (This used to be commit 303b3a35951211775a4e87bcca47cc21236aa422)
-rw-r--r--source3/tdb/tdbtool.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source3/tdb/tdbtool.c b/source3/tdb/tdbtool.c
index 4e674664b7..4198d12418 100644
--- a/source3/tdb/tdbtool.c
+++ b/source3/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;
}