version 1.5, 2009/07/07 17:24:32 |
version 1.6, 2009/07/23 21:19:11 |
|
|
|
|
#include "tmux.h" |
#include "tmux.h" |
|
|
int server_msg_fn_command(struct hdr *, struct client *); |
void server_msg_fn_command(struct hdr *, struct client *); |
int server_msg_fn_identify(struct hdr *, struct client *); |
void server_msg_fn_identify(struct hdr *, struct client *); |
int server_msg_fn_resize(struct hdr *, struct client *); |
void server_msg_fn_resize(struct hdr *, struct client *); |
int server_msg_fn_exiting(struct hdr *, struct client *); |
void server_msg_fn_exiting(struct hdr *, struct client *); |
int server_msg_fn_unlock(struct hdr *, struct client *); |
void server_msg_fn_unlock(struct hdr *, struct client *); |
int server_msg_fn_wakeup(struct hdr *, struct client *); |
void server_msg_fn_wakeup(struct hdr *, struct client *); |
|
|
void printflike2 server_msg_fn_command_error( |
void printflike2 server_msg_fn_command_error( |
struct cmd_ctx *, const char *, ...); |
struct cmd_ctx *, const char *, ...); |
|
|
|
|
struct server_msg { |
struct server_msg { |
enum hdrtype type; |
enum hdrtype type; |
int (*fn)(struct hdr *, struct client *); |
void (*fn)(struct hdr *, struct client *); |
}; |
}; |
const struct server_msg server_msg_table[] = { |
const struct server_msg server_msg_table[] = { |
{ MSG_IDENTIFY, server_msg_fn_identify }, |
{ MSG_IDENTIFY, server_msg_fn_identify }, |
|
|
struct hdr hdr; |
struct hdr hdr; |
const struct server_msg *msg; |
const struct server_msg *msg; |
u_int i; |
u_int i; |
int n; |
|
|
|
for (;;) { |
for (;;) { |
if (BUFFER_USED(c->in) < sizeof hdr) |
if (BUFFER_USED(c->in) < sizeof hdr) |
|
|
for (i = 0; i < nitems(server_msg_table); i++) { |
for (i = 0; i < nitems(server_msg_table); i++) { |
msg = server_msg_table + i; |
msg = server_msg_table + i; |
if (msg->type == hdr.type) { |
if (msg->type == hdr.type) { |
if ((n = msg->fn(&hdr, c)) != 0) |
msg->fn(&hdr, c); |
return (n); |
|
break; |
break; |
} |
} |
} |
} |
|
|
xfree(msg); |
xfree(msg); |
} |
} |
|
|
int |
void |
server_msg_fn_command(struct hdr *hdr, struct client *c) |
server_msg_fn_command(struct hdr *hdr, struct client *c) |
{ |
{ |
struct msg_command_data data; |
struct msg_command_data data; |
|
|
"unset $TMUX to force"); |
"unset $TMUX to force"); |
cmd_list_free(cmdlist); |
cmd_list_free(cmdlist); |
server_write_client(c, MSG_EXIT, NULL, 0); |
server_write_client(c, MSG_EXIT, NULL, 0); |
return (0); |
return; |
} |
} |
} |
} |
} |
} |
|
|
if (cmd_list_exec(cmdlist, &ctx) != 1) |
if (cmd_list_exec(cmdlist, &ctx) != 1) |
server_write_client(c, MSG_EXIT, NULL, 0); |
server_write_client(c, MSG_EXIT, NULL, 0); |
cmd_list_free(cmdlist); |
cmd_list_free(cmdlist); |
return (0); |
|
} |
} |
|
|
int |
void |
server_msg_fn_identify(struct hdr *hdr, struct client *c) |
server_msg_fn_identify(struct hdr *hdr, struct client *c) |
{ |
{ |
struct msg_identify_data data; |
struct msg_identify_data data; |
|
|
server_write_client(c, MSG_ERROR, MSG, (sizeof MSG) - 1); |
server_write_client(c, MSG_ERROR, MSG, (sizeof MSG) - 1); |
#undef MSG |
#undef MSG |
server_write_client(c, MSG_EXIT, NULL, 0); |
server_write_client(c, MSG_EXIT, NULL, 0); |
return (0); |
return; |
} |
} |
|
|
c->tty.sx = data.sx; |
c->tty.sx = data.sx; |
|
|
xfree(term); |
xfree(term); |
|
|
c->flags |= CLIENT_TERMINAL; |
c->flags |= CLIENT_TERMINAL; |
|
|
return (0); |
|
} |
} |
|
|
int |
void |
server_msg_fn_resize(struct hdr *hdr, struct client *c) |
server_msg_fn_resize(struct hdr *hdr, struct client *c) |
{ |
{ |
struct msg_resize_data data; |
struct msg_resize_data data; |
|
|
|
|
/* Always redraw this client. */ |
/* Always redraw this client. */ |
server_redraw_client(c); |
server_redraw_client(c); |
|
|
return (0); |
|
} |
} |
|
|
int |
void |
server_msg_fn_exiting(struct hdr *hdr, struct client *c) |
server_msg_fn_exiting(struct hdr *hdr, struct client *c) |
{ |
{ |
if (hdr->size != 0) |
if (hdr->size != 0) |
|
|
tty_close(&c->tty, c->flags & CLIENT_SUSPENDED); |
tty_close(&c->tty, c->flags & CLIENT_SUSPENDED); |
|
|
server_write_client(c, MSG_EXITED, NULL, 0); |
server_write_client(c, MSG_EXITED, NULL, 0); |
|
|
return (0); |
|
} |
} |
|
|
int |
void |
server_msg_fn_unlock(struct hdr *hdr, struct client *c) |
server_msg_fn_unlock(struct hdr *hdr, struct client *c) |
{ |
{ |
char *pass; |
char *pass; |
|
|
|
|
memset(pass, 0, strlen(pass)); |
memset(pass, 0, strlen(pass)); |
xfree(pass); |
xfree(pass); |
|
|
return (0); |
|
} |
} |
|
|
int |
void |
server_msg_fn_wakeup(struct hdr *hdr, struct client *c) |
server_msg_fn_wakeup(struct hdr *hdr, struct client *c) |
{ |
{ |
if (hdr->size != 0) |
if (hdr->size != 0) |
|
|
c->flags &= ~CLIENT_SUSPENDED; |
c->flags &= ~CLIENT_SUSPENDED; |
tty_start_tty(&c->tty); |
tty_start_tty(&c->tty); |
server_redraw_client(c); |
server_redraw_client(c); |
|
|
return (0); |
|
} |
} |