summaryrefslogtreecommitdiffstats
path: root/cmd-rename-session.c
authorRaghavendra D Prabhu <[email protected]>2011-01-23 11:59:16 (GMT)
committer Raghavendra D Prabhu <[email protected]>2011-01-23 11:59:16 (GMT)
commit0426ab2b383afd38af7274759c3a8d017bc88f00 (patch) (side-by-side diff)
tree2cc4bf1da4062c9ef91f2e94a9625f2423f57102 /cmd-rename-session.c
parent4e4aed43dc2b40b36f1b31cd3af9f874b78fa454 (diff)
parentb67bfd382d3401de572bb3487b1af3382a9cbeda (diff)
downloadtmux-old-master.zip
tmux-old-master.tar.gz
tmux-old-master.tar.bz2
merged new changesmaster
Diffstat (limited to 'cmd-rename-session.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cmd-rename-session.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/cmd-rename-session.c b/cmd-rename-session.c
index 6baded1..bbd7c8e 100644
--- a/cmd-rename-session.c
+++ b/cmd-rename-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-rename-session.c,v 1.20 2010/08/11 22:19:03 tcunha Exp $ */
+/* $Id: cmd-rename-session.c,v 1.22 2011/01/07 14:45:34 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <[email protected]>
@@ -30,31 +30,34 @@ int cmd_rename_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_rename_session_entry = {
"rename-session", "rename",
+ "t:", 1, 1,
CMD_TARGET_SESSION_USAGE " new-name",
- CMD_ARG1, "",
- cmd_target_init,
- cmd_target_parse,
- cmd_rename_session_exec,
- cmd_target_free,
- cmd_target_print
+ 0,
+ NULL,
+ NULL,
+ cmd_rename_session_exec
};
int
cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
{
- struct cmd_target_data *data = self->data;
- struct session *s;
+ struct args *args = self->args;
+ struct session *s;
+ const char *newname;
- if (data->arg != NULL && session_find(data->arg) != NULL) {
- ctx->error(ctx, "duplicate session: %s", data->arg);
+ newname = args->argv[0];
+ if (session_find(newname) != NULL) {
+ ctx->error(ctx, "duplicate session: %s", newname);
return (-1);
}
- if ((s = cmd_find_session(ctx, data->target)) == NULL)
+ if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
return (-1);
+ RB_REMOVE(sessions, &sessions, s);
xfree(s->name);
- s->name = xstrdup(data->arg);
+ s->name = xstrdup(newname);
+ RB_INSERT(sessions, &sessions, s);
server_status_session(s);