#define STRINGIFY(x) STRINGIFY2(x)
#define STRINGIFY2(x) #x
+
+static inline int nwho_pkt_size(struct nwho_pkt *pkt)
+{
+ return sizeof(struct nwho_pkt) - (MAX_USERS - ntohl(pkt->num_users))*sizeof(struct userinfo);
+}
{
now = time(NULL);
make_pkt(&pkt);
- if (send(sock, &pkt, sizeof(pkt) - (MAX_USERS - ntohl(pkt.num_users))*sizeof(struct userinfo), 0) < 0)
+ if (send(sock, &pkt, nwho_pkt_size(&pkt), 0) < 0)
syslog(LOG_ERR, "sendmsg: %m");
sleep(DEFAULT_SEND_TIME);
}