=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.336 retrieving revision 1.337 diff -c -r1.336 -r1.337 *** src/usr.bin/tmux/server-client.c 2020/05/16 15:34:08 1.336 --- src/usr.bin/tmux/server-client.c 2020/05/16 15:45:29 1.337 *************** *** 1,4 **** ! /* $OpenBSD: server-client.c,v 1.336 2020/05/16 15:34:08 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server-client.c,v 1.337 2020/05/16 15:45:29 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 2252,2255 **** --- 2252,2313 ---- if ((home = find_home()) != NULL) return (home); return ("/"); + } + + /* Set client flags. */ + void + server_client_set_flags(struct client *c, const char *flags) + { + char *s, *copy, *next; + int flag, not; + + s = copy = xstrdup (flags); + while ((next = strsep(&s, ",")) != NULL) { + not = (*next == '!'); + if (not) + next++; + + if (strcmp(next, "no-output") == 0) + flag = CLIENT_CONTROL_NOOUTPUT; + else if (strcmp(next, "read-only") == 0) + flag = CLIENT_READONLY; + else if (strcmp(next, "ignore-size") == 0) + flag = CLIENT_IGNORESIZE; + else + continue; + + log_debug("client %s set flag %s", c->name, next); + if (not) + c->flags &= ~flag; + else + c->flags |= flag; + } + free(copy); + + } + + /*Get client flags. This is only flags useful to show to users. */ + const char * + server_client_get_flags(struct client *c) + { + static char s[256]; + + *s = '\0'; + if (c->flags & CLIENT_ATTACHED) + strlcat(s, "attached,", sizeof s); + if (c->flags & CLIENT_CONTROL) + strlcat(s, "control-mode,", sizeof s); + if (c->flags & CLIENT_IGNORESIZE) + strlcat(s, "ignore-size,", sizeof s); + if (c->flags & CLIENT_CONTROL_NOOUTPUT) + strlcat(s, "no-output,", sizeof s); + if (c->flags & CLIENT_READONLY) + strlcat(s, "read-only,", sizeof s); + if (c->flags & CLIENT_SUSPENDED) + strlcat(s, "suspended,", sizeof s); + if (c->flags & CLIENT_UTF8) + strlcat(s, "UTF-8,", sizeof s); + if (*s != '\0') + s[strlen(s) - 1] = '\0'; + return (s); }