summaryrefslogtreecommitdiffstats
path: root/paste.c
diff options
context:
space:
mode:
authornicm <nicm>2019-04-02 09:03:39 +0000
committernicm <nicm>2019-04-02 09:03:39 +0000
commit7bcc0d16f24506bed6568ba36bcd278cfc06d069 (patch)
tree0dcb8ee612b7bb545bc7140b759e172628e9bbe8 /paste.c
parentffa4d489676f40582b63c1791d3bf5d3b75d8421 (diff)
Add an argument to copy commands to set the prefix for the buffer name,
allows buffers for different sessions to be named separately.
Diffstat (limited to 'paste.c')
-rw-r--r--paste.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/paste.c b/paste.c
index c76c52e5..0c9bc7b5 100644
--- a/paste.c
+++ b/paste.c
@@ -158,11 +158,14 @@ paste_free(struct paste_buffer *pb)
* that the caller is responsible for allocating data.
*/
void
-paste_add(char *data, size_t size)
+paste_add(const char *prefix, char *data, size_t size)
{
struct paste_buffer *pb, *pb1;
u_int limit;
+ if (prefix == NULL)
+ prefix = "buffer";
+
if (size == 0) {
free(data);
return;
@@ -181,7 +184,7 @@ paste_add(char *data, size_t size)
pb->name = NULL;
do {
free(pb->name);
- xasprintf(&pb->name, "buffer%04u", paste_next_index);
+ xasprintf(&pb->name, "%s%u", prefix, paste_next_index);
paste_next_index++;
} while (paste_get_name(pb->name) != NULL);
@@ -263,7 +266,7 @@ paste_set(char *data, size_t size, const char *name, char **cause)
return (0);
}
if (name == NULL) {
- paste_add(data, size);
+ paste_add(NULL, data, size);
return (0);
}