aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-06-20 19:01:59 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-06-20 19:01:59 +0000
commit487c65ebe7140dec3bd27417826f53012d1acce6 (patch)
tree3cf4fe1dced390e4798271702a06a984d898ff9a
parentba0502958c676a3dbb42c89eda8627ff2eef9708 (diff)
downloadrtmux-487c65ebe7140dec3bd27417826f53012d1acce6.tar.gz
rtmux-487c65ebe7140dec3bd27417826f53012d1acce6.tar.bz2
rtmux-487c65ebe7140dec3bd27417826f53012d1acce6.zip
Don't show creation time, show more of buffer.
-rw-r--r--cmd-list-buffers.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/cmd-list-buffers.c b/cmd-list-buffers.c
index 0e5bb1b7..fea3f2a5 100644
--- a/cmd-list-buffers.c
+++ b/cmd-list-buffers.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-buffers.c,v 1.1 2008-06-20 17:31:48 nicm Exp $ */
+/* $Id: cmd-list-buffers.c,v 1.2 2008-06-20 19:01:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -48,33 +48,44 @@ cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
struct session *s;
struct paste_buffer *pb;
u_int idx;
- char tmp[16], *tim;
- size_t in, out;
+ char *tmp;
+ size_t size, in, out;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return;
+ if (s->sx > 35) {
+ size = s->sx - 35;
+ tmp = xmalloc(size + 1);
+ } else {
+ size = 0;
+ tmp = NULL;
+ }
+
idx = 0;
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
- in = out = 0;
- while (out < (sizeof tmp) - 1 && pb->data[in] != '\0') {
- if (pb->data[in] > 31 && pb->data[in] != 127)
- tmp[out++] = pb->data[in];
- in++;
- }
- tmp[out] = '\0';
- if (out == (sizeof tmp) - 1) {
- tmp[out - 1] = '.';
- tmp[out - 2] = '.';
- }
-
- tim = ctime(&pb->ts.tv_sec);
- *strchr(tim, '\n') = '\0';
+ if (tmp != NULL) {
+ in = out = 0;
+ while (out < size && pb->data[in] != '\0') {
+ if (pb->data[in] > 31 && pb->data[in] != 127)
+ tmp[out++] = pb->data[in];
+ in++;
+ }
+ tmp[out] = '\0';
+ if (out == size) {
+ tmp[out - 1] = '.';
+ tmp[out - 2] = '.';
+ }
- ctx->print(ctx, "%d: %zu bytes "
- "(created %s): \"%s\"", idx, strlen(pb->data), tim, tmp);
+ ctx->print(ctx, "%d: "
+ "%zu bytes: \"%s\"", idx, strlen(pb->data), tmp);
+ } else
+ ctx->print(ctx, "%d: %zu bytes", idx, strlen(pb->data));
}
+ if (tmp != NULL)
+ xfree(tmp);
+
if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}