aboutsummaryrefslogtreecommitdiff
path: root/client-msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'client-msg.c')
-rw-r--r--client-msg.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/client-msg.c b/client-msg.c
index dbedf563..bf6080c5 100644
--- a/client-msg.c
+++ b/client-msg.c
@@ -1,4 +1,4 @@
-/* $Id: client-msg.c,v 1.20 2009-07-22 17:38:11 tcunha Exp $ */
+/* $Id: client-msg.c,v 1.21 2009-07-23 23:42:59 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -25,16 +25,16 @@
#include "tmux.h"
-int client_msg_fn_detach(struct hdr *, struct client_ctx *, char **);
-int client_msg_fn_error(struct hdr *, struct client_ctx *, char **);
-int client_msg_fn_shutdown(struct hdr *, struct client_ctx *, char **);
-int client_msg_fn_exit(struct hdr *, struct client_ctx *, char **);
-int client_msg_fn_exited(struct hdr *, struct client_ctx *, char **);
-int client_msg_fn_suspend(struct hdr *, struct client_ctx *, char **);
+int client_msg_fn_detach(struct hdr *, struct client_ctx *);
+int client_msg_fn_error(struct hdr *, struct client_ctx *);
+int client_msg_fn_shutdown(struct hdr *, struct client_ctx *);
+int client_msg_fn_exit(struct hdr *, struct client_ctx *);
+int client_msg_fn_exited(struct hdr *, struct client_ctx *);
+int client_msg_fn_suspend(struct hdr *, struct client_ctx *);
struct client_msg {
enum hdrtype type;
- int (*fn)(struct hdr *, struct client_ctx *, char **);
+ int (*fn)(struct hdr *, struct client_ctx *);
};
struct client_msg client_msg_table[] = {
{ MSG_DETACH, client_msg_fn_detach },
@@ -46,7 +46,7 @@ struct client_msg client_msg_table[] = {
};
int
-client_msg_dispatch(struct client_ctx *cctx, char **error)
+client_msg_dispatch(struct client_ctx *cctx)
{
struct hdr hdr;
struct client_msg *msg;
@@ -61,70 +61,67 @@ client_msg_dispatch(struct client_ctx *cctx, char **error)
for (i = 0; i < nitems(client_msg_table); i++) {
msg = client_msg_table + i;
- if (msg->type == hdr.type) {
- if (msg->fn(&hdr, cctx, error) != 0)
- return (-1);
- return (0);
- }
+ if (msg->type == hdr.type)
+ return (msg->fn(&hdr, cctx));
}
fatalx("unexpected message");
}
int
-client_msg_fn_error(struct hdr *hdr, struct client_ctx *cctx, char **error)
+client_msg_fn_error(struct hdr *hdr, struct client_ctx *cctx)
{
+ char *errstr;
+
if (hdr->size == SIZE_MAX)
fatalx("bad MSG_ERROR size");
- *error = xmalloc(hdr->size + 1);
- buffer_read(cctx->srv_in, *error, hdr->size);
- (*error)[hdr->size] = '\0';
+ errstr = xmalloc(hdr->size + 1);
+ buffer_read(cctx->srv_in, errstr, hdr->size);
+ errstr[hdr->size] = '\0';
+ cctx->errstr = errstr;
return (-1);
}
int
-client_msg_fn_detach(
- struct hdr *hdr, struct client_ctx *cctx, unused char **error)
+client_msg_fn_detach(struct hdr *hdr, struct client_ctx *cctx)
{
if (hdr->size != 0)
fatalx("bad MSG_DETACH size");
client_write_server(cctx, MSG_EXITING, NULL, 0);
- cctx->flags |= CCTX_DETACH;
+ cctx->exittype = CCTX_DETACH;
return (0);
}
int
client_msg_fn_shutdown(
- struct hdr *hdr, struct client_ctx *cctx, unused char **error)
+ struct hdr *hdr, struct client_ctx *cctx)
{
if (hdr->size != 0)
fatalx("bad MSG_SHUTDOWN size");
client_write_server(cctx, MSG_EXITING, NULL, 0);
- cctx->flags |= CCTX_SHUTDOWN;
+ cctx->exittype = CCTX_SHUTDOWN;
return (0);
}
int
-client_msg_fn_exit(
- struct hdr *hdr, struct client_ctx *cctx, unused char **error)
+client_msg_fn_exit(struct hdr *hdr, struct client_ctx *cctx)
{
if (hdr->size != 0)
fatalx("bad MSG_EXIT size");
client_write_server(cctx, MSG_EXITING, NULL, 0);
- cctx->flags |= CCTX_EXIT;
+ cctx->exittype = CCTX_EXIT;
return (0);
}
int
-client_msg_fn_exited(
- struct hdr *hdr, unused struct client_ctx *cctx, unused char **error)
+client_msg_fn_exited(struct hdr *hdr, unused struct client_ctx *cctx)
{
if (hdr->size != 0)
fatalx("bad MSG_EXITED size");
@@ -133,8 +130,7 @@ client_msg_fn_exited(
}
int
-client_msg_fn_suspend(
- struct hdr *hdr, unused struct client_ctx *cctx, unused char **error)
+client_msg_fn_suspend(struct hdr *hdr, unused struct client_ctx *cctx)
{
struct sigaction act;