From: nicm Date: Mon, 29 May 2017 20:37:30 +0000 (+0000) Subject: Function to count clients. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9a34dfc50f957925f74f9b2a14b5dfe3d7eac1df;p=openbsd Function to count clients. --- 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 @@ -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 @@ -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 *);