From 653ee721df4b0464803d6cba46376b4fcbd09b82 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sat, 29 Sep 2007 13:22:15 +0000 Subject: Write error messages for rename. Also tweak some error outputs, and fix -i. --- server-msg.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'server-msg.c') diff --git a/server-msg.c b/server-msg.c index 6ec36e8e..0ffa0ede 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.8 2007-09-28 22:47:21 nicm Exp $ */ +/* $Id: server-msg.c,v 1.9 2007-09-29 13:22:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -155,7 +155,7 @@ server_msg_fn_attach(struct hdr *hdr, struct client *c) c->sy = 25; if ((c->session = server_find_sessid(&data.sid, &cause)) == NULL) { - server_write_client(c, MSG_ERROR, cause, strlen(cause)); + server_write_error(c, "%s", cause); xfree(cause); return (0); } @@ -353,7 +353,7 @@ server_msg_fn_windows(struct hdr *hdr, struct client *c) buffer_read(c->in, &data, hdr->size); if ((s = server_find_sessid(&data.sid, &cause)) == NULL) { - server_write_client(c, MSG_ERROR, cause, strlen(cause)); + server_write_error(c, "%s", cause); xfree(cause); return (0); } @@ -396,26 +396,28 @@ server_msg_fn_rename(struct hdr *hdr, struct client *c) buffer_read(c->in, &data, hdr->size); data.newname[(sizeof data.newname) - 1] = '\0'; - if ((s = server_find_sessid(&data.sid, &cause)) == NULL) { - /* XXX: Send message to client */ + server_write_error(c, "%s", cause); + xfree(cause); return (0); } - if (data.idx == -1) + if (data.idx == -1) w = s->window; - else + else { + if (data.idx < 0) + fatalx("bad window index"); w = window_at(&s->windows, data.idx); - - if (w == NULL) { - /* XXX: Send message to client */ - return (0); + if (w == NULL) { + server_write_error(c, "window not found: %d", data.idx); + return (0); + } } strlcpy(w->name, data.newname, sizeof w->name); + server_write_client(c, MSG_DONE, NULL, 0); return (0); - } /* Last window message from client */ -- cgit v1.2.3