summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-03-12 10:35:45 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-03-12 10:35:45 +0100
commit4af143a85531a5635d441a201b259fbd45a23660 (patch)
treed7af44657f04d7866eeb9a246969b373dc8d2ca5
parentfdf76352c3c6d440e692fff3dba582e9a589b536 (diff)
downloadecon-4af143a85531a5635d441a201b259fbd45a23660.tar.gz
econ-4af143a85531a5635d441a201b259fbd45a23660.tar.bz2
econ-4af143a85531a5635d441a201b259fbd45a23660.zip
econfind: Put clientinfo parsing into subfunction
-rw-r--r--econfind.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/econfind.c b/econfind.c
index fdda71e..0abde0f 100644
--- a/econfind.c
+++ b/econfind.c
@@ -27,6 +27,24 @@
#include "econproto.h"
#include "econpacket.h"
+static void
+parse_clientinfo(struct econ_packet *pkt)
+{
+ struct in_addr beamer;
+
+ beamer.s_addr = *(uint32_t*)pkt->hdr.IPaddress;
+ printf("%s", inet_ntoa(beamer));
+ if (pkt->hdr.datasize > 0) {
+ char *name = pkt->cmd.command.clientinfo.projName;
+ int state = pkt->cmd.command.clientinfo.projState;
+
+ name[ECON_PROJNAME_MAXLEN-1] = '\0';
+ printf(" - %s: %s", name,
+ state == E_PSTAT_NOUSE ? "no use" : "in use");
+ }
+ printf("\n");
+}
+
int
main(int argc, char *argv[])
{
@@ -54,21 +72,8 @@ main(int argc, char *argv[])
if (epkt_read(sfd, &pkt) < 0)
exit(EXIT_FAILURE);
- if (pkt.hdr.commandID == E_CMD_CLIENTINFO) {
- struct in_addr beamer;
-
- beamer.s_addr = *(uint32_t*)pkt.hdr.IPaddress;
- printf("%s", inet_ntoa(beamer));
- if (pkt.hdr.datasize > 0) {
- char *name = pkt.cmd.command.clientinfo.projName;
- int state = pkt.cmd.command.clientinfo.projState;
-
- name[ECON_PROJNAME_MAXLEN-1] = '\0';
- printf(" - %s: %s", name,
- state == E_PSTAT_NOUSE ? "no use" : "in use");
- }
- printf("\n");
- }
+ if (pkt.hdr.commandID == E_CMD_CLIENTINFO)
+ parse_clientinfo(&pkt);
close(cfd);
close(sfd);