diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-08-29 09:25:01 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-08-29 09:25:01 +0000 |
commit | 9d332c354ae9609d0c3cbcc30db4f3b4081c8039 (patch) | |
tree | 6e68eacef434ef71bd807b284486d5812d273e53 /usr.bin/tmux/paste.c | |
parent | d943c4eeadbe6211663e830081ced8e72fb2ca8a (diff) |
Move struct paste_buffer out of tmux.h.
Diffstat (limited to 'usr.bin/tmux/paste.c')
-rw-r--r-- | usr.bin/tmux/paste.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c index 2cf1678f3ef..62e6b10eed6 100644 --- a/usr.bin/tmux/paste.c +++ b/usr.bin/tmux/paste.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paste.c,v 1.27 2015/04/07 13:06:22 nicm Exp $ */ +/* $OpenBSD: paste.c,v 1.28 2015/08/29 09:25:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,6 +30,18 @@ * string! */ +struct paste_buffer { + char *data; + size_t size; + + char *name; + int automatic; + u_int order; + + RB_ENTRY(paste_buffer) name_entry; + RB_ENTRY(paste_buffer) time_entry; +}; + u_int paste_next_index; u_int paste_next_order; u_int paste_num_automatic; @@ -60,6 +72,22 @@ paste_cmp_times(const struct paste_buffer *a, const struct paste_buffer *b) return (0); } +/* Get paste buffer name. */ +const char * +paste_buffer_name(struct paste_buffer *pb) +{ + return (pb->name); +} + +/* Get paste buffer data. */ +const char * +paste_buffer_data(struct paste_buffer *pb, size_t *size) +{ + if (size != NULL) + *size = pb->size; + return (pb->data); +} + /* Walk paste buffers by name. */ struct paste_buffer * paste_walk(struct paste_buffer *pb) @@ -71,13 +99,15 @@ paste_walk(struct paste_buffer *pb) /* Get the most recent automatic buffer. */ struct paste_buffer * -paste_get_top(void) +paste_get_top(const char **name) { struct paste_buffer *pb; pb = RB_MIN(paste_time_tree, &paste_by_time); if (pb == NULL) return (NULL); + if (name != NULL) + *name = pb->name; return (pb); } @@ -87,7 +117,7 @@ paste_free_top(void) { struct paste_buffer *pb; - pb = paste_get_top(); + pb = paste_get_top(NULL); if (pb == NULL) return (-1); return (paste_free_name(pb->name)); |