summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-05-29 20:37:31 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-05-29 20:37:31 +0000
commit6d44e003a7a13ac2d07c530013c8cfe193d0d064 (patch)
treeafacd5f549196eb852527ed5b70dda472d40bea0 /usr.bin
parent5ab3a1c5d51a308ea3523b9a2ff8a66cdcd1644f (diff)
Function to count clients.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/server-client.c17
-rw-r--r--usr.bin/tmux/tmux.h3
2 files changed, 18 insertions, 2 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 9e409bafad3..81218e893dd 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.232 2017/05/16 12:57:26 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.233 2017/05/29 20:37:30 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -49,6 +49,21 @@ static void server_client_dispatch_command(struct client *, struct imsg *);
static void server_client_dispatch_identify(struct client *, struct imsg *);
static void server_client_dispatch_shell(struct client *);
+/* Number of attached clients. */
+u_int
+server_client_how_many(void)
+{
+ struct client *c;
+ u_int n;
+
+ n = 0;
+ TAILQ_FOREACH(c, &clients, entry) {
+ if (c->session != NULL && (~c->flags & CLIENT_DETACHING))
+ n++;
+ }
+ return (n);
+}
+
/* Identify mode callback. */
static void
server_client_callback_identify(__unused int fd, __unused short events,
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 2cc405588bf..7316d3f6711 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.771 2017/05/29 18:06:34 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.772 2017/05/29 20:37:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1836,6 +1836,7 @@ void server_update_socket(void);
void server_add_accept(int);
/* server-client.c */
+u_int server_client_how_many(void);
void server_client_set_identify(struct client *);
void server_client_clear_identify(struct client *, struct window_pane *);
void server_client_set_key_table(struct client *, const char *);