diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-03-12 10:35:45 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-03-12 10:35:45 +0100 |
commit | 4af143a85531a5635d441a201b259fbd45a23660 (patch) | |
tree | d7af44657f04d7866eeb9a246969b373dc8d2ca5 | |
parent | fdf76352c3c6d440e692fff3dba582e9a589b536 (diff) | |
download | econ-4af143a85531a5635d441a201b259fbd45a23660.tar.gz econ-4af143a85531a5635d441a201b259fbd45a23660.tar.bz2 econ-4af143a85531a5635d441a201b259fbd45a23660.zip |
econfind: Put clientinfo parsing into subfunction
-rw-r--r-- | econfind.c | 35 |
1 files changed, 20 insertions, 15 deletions
@@ -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); |