diff options
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) { |