summaryrefslogtreecommitdiffstats
path: root/server-fn.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-04-25 10:02:46 +0000
committerThomas Adam <thomas@xteddy.org>2015-04-25 10:02:46 +0000
commit56e1132db485aeb0730ce7782533ca441e63afef (patch)
tree310f172893f10f8f2f3a249ee88fed51b03b39cc /server-fn.c
parent0a88377086329786c438d4973365fdb21186f4e4 (diff)
parentaeedb464a6ee038289ddcfefae437928ab020cb1 (diff)
Merge branch 'obsd-master'
Diffstat (limited to 'server-fn.c')
-rw-r--r--server-fn.c62
1 files changed, 17 insertions, 45 deletions
diff --git a/server-fn.c b/server-fn.c
index f2b2e269..043463fd 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -77,12 +77,8 @@ server_write_session(struct session *s, enum msgtype type, const void *buf,
size_t len)
{
struct client *c;
- u_int i;
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session == NULL)
- continue;
+ TAILQ_FOREACH(c, &clients, entry) {
if (c->session == s)
server_write_client(c, type, buf, len);
}
@@ -104,12 +100,8 @@ void
server_redraw_session(struct session *s)
{
struct client *c;
- u_int i;
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session == NULL)
- continue;
+ TAILQ_FOREACH(c, &clients, entry) {
if (c->session == s)
server_redraw_client(c);
}
@@ -132,12 +124,8 @@ void
server_status_session(struct session *s)
{
struct client *c;
- u_int i;
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session == NULL)
- continue;
+ TAILQ_FOREACH(c, &clients, entry) {
if (c->session == s)
server_status_client(c);
}
@@ -160,13 +148,9 @@ void
server_redraw_window(struct window *w)
{
struct client *c;
- u_int i;
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session == NULL)
- continue;
- if (c->session->curw->window == w)
+ TAILQ_FOREACH(c, &clients, entry) {
+ if (c->session != NULL && c->session->curw->window == w)
server_redraw_client(c);
}
w->flags |= WINDOW_REDRAW;
@@ -176,13 +160,9 @@ void
server_redraw_window_borders(struct window *w)
{
struct client *c;
- u_int i;
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session == NULL)
- continue;
- if (c->session->curw->window == w)
+ TAILQ_FOREACH(c, &clients, entry) {
+ if (c->session != NULL && c->session->curw->window == w)
c->flags |= CLIENT_BORDERS;
}
}
@@ -199,7 +179,7 @@ server_status_window(struct window *w)
*/
RB_FOREACH(s, sessions, &sessions) {
- if (session_has(s, w) != NULL)
+ if (session_has(s, w))
server_status_session(s);
}
}
@@ -208,13 +188,10 @@ void
server_lock(void)
{
struct client *c;
- u_int i;
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session == NULL)
- continue;
- server_lock_client(c);
+ TAILQ_FOREACH(c, &clients, entry) {
+ if (c->session != NULL)
+ server_lock_client(c);
}
}
@@ -222,13 +199,10 @@ void
server_lock_session(struct session *s)
{
struct client *c;
- u_int i;
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session == NULL || c->session != s)
- continue;
- server_lock_client(c);
+ TAILQ_FOREACH(c, &clients, entry) {
+ if (c->session == s)
+ server_lock_client(c);
}
}
@@ -268,7 +242,7 @@ server_kill_window(struct window *w)
s = next_s;
next_s = RB_NEXT(sessions, &sessions, s);
- if (session_has(s, w) == NULL)
+ if (!session_has(s, w))
continue;
server_unzoom_window(w);
while ((wl = winlink_find_by_window(&s->windows, w)) != NULL) {
@@ -433,16 +407,14 @@ server_destroy_session(struct session *s)
{
struct client *c;
struct session *s_new;
- u_int i;
if (!options_get_number(&s->options, "detach-on-destroy"))
s_new = server_next_session(s);
else
s_new = NULL;
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session != s)
+ TAILQ_FOREACH(c, &clients, entry) {
+ if (c->session != s)
continue;
if (s_new == NULL) {
c->session = NULL;