summaryrefslogtreecommitdiffstats
path: root/status.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-11-04 21:04:43 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-11-04 21:04:43 +0000
commit4d6091379b4486b624070492d45ad390e7442382 (patch)
treee22d1b401b804b13a9cafe71d459a55fdbf376dc /status.c
parentea8c8c5f33e0dcbf563dc54615a6c172aea70518 (diff)
Switch jobs over to use a bufferevent.
Diffstat (limited to 'status.c')
-rw-r--r--status.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/status.c b/status.c
index 21ca31a2..4b0c81fb 100644
--- a/status.c
+++ b/status.c
@@ -486,23 +486,26 @@ status_job(struct client *c, char **iptr)
void
status_job_callback(struct job *job)
{
- char *buf;
+ char *line, *buf;
size_t len;
- len = BUFFER_USED(job->out);
- buf = xmalloc(len + 1);
- if (len != 0)
- buffer_read(job->out, buf, len);
- buf[len] = '\0';
- buf[strcspn(buf, "\n")] = '\0';
+ buf = NULL;
+ if ((line = evbuffer_readline(job->event->input)) == NULL) {
+ len = EVBUFFER_LENGTH(job->event->input);
+ buf = xmalloc(len + 1);
+ if (len != 0)
+ memcpy(buf, EVBUFFER_DATA(job->event->input), len);
+ buf[len] = '\0';
+ }
if (job->data != NULL)
xfree(job->data);
else
server_redraw_client(job->client);
- job->data = xstrdup(buf);
+ job->data = xstrdup(line);
- xfree(buf);
+ if (buf != NULL)
+ xfree(buf);
}
size_t