aboutsummaryrefslogtreecommitdiff
path: root/server-client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2020-05-05 15:42:20 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2020-05-05 15:42:20 +0100
commit2f89d2e7d816918e152aacfee85fab45ee2057b9 (patch)
tree98f86226f36a6bf5e1a88bef8ca1d6cdb02612b8 /server-client.c
parentdeacfedc65e6de6b3f84348d6723ae6f14d097df (diff)
downloadrtmux-2f89d2e7d816918e152aacfee85fab45ee2057b9.tar.gz
rtmux-2f89d2e7d816918e152aacfee85fab45ee2057b9.tar.bz2
rtmux-2f89d2e7d816918e152aacfee85fab45ee2057b9.zip
Change the existing client flags for control mode to apply for any client, use
the same mechanism for the read-only flag and add an ignore-size flag. refresh-client -F has become -f (-F stays for backwards compatibility) and attach-session and switch-client now have -f flags also. A new format "client_flags" lists the flags and is shown by list-clients by default. This separates the read-only flag from "ignore size" behaviour (new ignore-size) flag - both behaviours are useful in different circumstances. attach -r and switchc -r remain and set or toggle both flags together.
Diffstat (limited to 'server-client.c')
-rw-r--r--server-client.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/server-client.c b/server-client.c
index a9762c56..6de6e97d 100644
--- a/server-client.c
+++ b/server-client.c
@@ -2255,3 +2255,61 @@ server_client_get_cwd(struct client *c, struct session *s)
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);
+}