diff options
author | Volker Lendecke <vl@samba.org> | 2010-11-28 13:14:38 +0100 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2010-11-28 15:03:26 +0100 |
commit | c69b1edcb9a4b41055f82007d223ef18dc04a1d2 (patch) | |
tree | 43430c45890b2d1300e683963dc6ea134265b0c6 /source3/utils | |
parent | 1a91fe90b6a1f50c641ce4d778f49ce4c121b9dd (diff) | |
download | samba-c69b1edcb9a4b41055f82007d223ef18dc04a1d2.tar.gz samba-c69b1edcb9a4b41055f82007d223ef18dc04a1d2.tar.bz2 samba-c69b1edcb9a4b41055f82007d223ef18dc04a1d2.zip |
s3: Properly print binary values "net cache"
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Sun Nov 28 15:03:26 CET 2010 on sn-devel-104
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_cache.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c index 4339094489..88aff4e16e 100644 --- a/source3/utils/net_cache.c +++ b/source3/utils/net_cache.c @@ -33,11 +33,13 @@ * (print_cache_entry) and to flush it (delete_cache_entry). * Both of them are defined by first arg of gencache_iterate() routine. */ -static void print_cache_entry(const char* keystr, const char* datastr, +static void print_cache_entry(const char* keystr, DATA_BLOB value, const time_t timeout, void* dptr) { char *timeout_str; char *alloc_str = NULL; + const char *datastr; + char *datastr_free = NULL; time_t now_t = time(NULL); struct tm timeout_tm, now_tm; struct tm *ptimeout_tm, *pnow_tm; @@ -69,6 +71,18 @@ static void print_cache_entry(const char* keystr, const char* datastr, timeout_str = alloc_str; } + datastr = (char *)value.data; + + if ((value.length > 0) && (value.data[value.length-1] != '\0')) { + datastr_free = talloc_asprintf( + talloc_tos(), "<binary length %d>", + (int)value.length); + datastr = datastr_free; + if (datastr == NULL) { + datastr = "<binary>"; + } + } + d_printf(_("Key: %s\t Timeout: %s\t Value: %s %s\n"), keystr, timeout_str, datastr, timeout > now_t ? "": _("(expired)")); @@ -218,7 +232,7 @@ static int net_cache_del(struct net_context *c, int argc, const char **argv) static int net_cache_get(struct net_context *c, int argc, const char **argv) { const char* keystr = argv[0]; - char* valuestr = NULL; + DATA_BLOB value; time_t timeout; if (argc < 1 || c->display_usage) { @@ -228,9 +242,9 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv) return -1; } - if (gencache_get(keystr, &valuestr, &timeout)) { - print_cache_entry(keystr, valuestr, timeout, NULL); - SAFE_FREE(valuestr); + if (gencache_get_data_blob(keystr, &value, &timeout, NULL)) { + print_cache_entry(keystr, value, timeout, NULL); + SAFE_FREE(value.data); return 0; } @@ -258,7 +272,7 @@ static int net_cache_search(struct net_context *c, int argc, const char **argv) } pattern = argv[0]; - gencache_iterate(print_cache_entry, NULL, pattern); + gencache_iterate_blobs(print_cache_entry, NULL, pattern); return 0; } @@ -282,7 +296,7 @@ static int net_cache_list(struct net_context *c, int argc, const char **argv) _("List all cache entries.")); return 0; } - gencache_iterate(print_cache_entry, NULL, pattern); + gencache_iterate_blobs(print_cache_entry, NULL, pattern); return 0; } |