summaryrefslogtreecommitdiff
path: root/server/common.c
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@1ts.org>2013-01-19 19:43:37 -0500
committerGravatar Karl Ramm <kcr@1ts.org>2013-03-16 23:57:54 -0700
commit9e361ec4b0fbf61fc743bae78ab1b6e30c4a2742 (patch)
treef00a4a69a9c942c8c593dbc2049212265be55f2c /server/common.c
parentc88af26f7f05d532ab46ab8b2ff22e20d05fa13d (diff)
rearrange so that most of the server code can be linked without main.c
Move global variables and one function out of main.c so that the rest of the server can be linked with a test harness.
Diffstat (limited to 'server/common.c')
-rw-r--r--server/common.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/server/common.c b/server/common.c
index 4af40c7..1666ec4 100644
--- a/server/common.c
+++ b/server/common.c
@@ -112,3 +112,19 @@ notice_extract_address(ZNotice_t *notice, struct sockaddr_in *addr)
addr->sin_port = notice->z_port;
addr->sin_family = AF_INET;
}
+
+
+int
+packets_waiting(void)
+{
+ fd_set readable, initial;
+ struct timeval tv;
+
+ if (msgs_queued())
+ return 1;
+ FD_ZERO(&initial);
+ FD_SET(srv_socket, &initial);
+ readable = initial;
+ tv.tv_sec = tv.tv_usec = 0;
+ return (select(srv_socket + 1, &readable, NULL, NULL, &tv) > 0);
+}