diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-09-27 09:52:03 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-09-27 09:52:03 +0000 |
commit | 22990a6595fdff840010aa6df9a60ada61331b5e (patch) | |
tree | 48fa49a39ca8ba91652d9e5bbdcc7a942462c183 /client.c | |
parent | 3fa8f1636486420b9f27b129dbd0f36015d4c24b (diff) |
New session selection rules:
- find by name if given
- otherwise try current index from $TMUX
- otherwise if only one session, use it
- otherwise error
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.5 2007-09-26 19:09:30 nicm Exp $ */ +/* $Id: client.c,v 1.6 2007-09-27 09:52:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -197,6 +197,36 @@ local_dead: } void +client_fill_sessid(struct sessid *sid, char name[MAXNAMELEN]) +{ + char *env, *ptr, buf[256]; + const char *errstr; + long long ll; + + strlcpy(sid->name, name, sizeof sid->name); + + sid->pid = -1; + if ((env = getenv("TMUX")) == NULL) + return; + if ((ptr = strchr(env, ',')) == NULL) + return; + if ((size_t) (ptr - env) > sizeof buf) + return; + memcpy(buf, env, ptr - env); + buf[ptr - env] = '\0'; + + ll = strtonum(ptr + 1, 0, UINT_MAX, &errstr); + if (errstr != NULL) + return; + sid->idx = ll; + + ll = strtonum(buf, 0, LLONG_MAX, &errstr); + if (errstr != NULL) + return; + sid->pid = ll; +} + +void client_write_server( struct client_ctx *cctx, enum hdrtype type, void *buf, size_t len) { |