diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-03-11 13:09:12 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-03-11 13:09:12 +0100 |
commit | 3c13aefb2aec3a2db7768579261bd0a1721dc4be (patch) | |
tree | cc9a4a392f800b8250aeb57fd945535edd3d5a3d | |
parent | aacef166dae47d580bfffad5d272c5212cc48555 (diff) | |
download | econ-3c13aefb2aec3a2db7768579261bd0a1721dc4be.tar.gz econ-3c13aefb2aec3a2db7768579261bd0a1721dc4be.tar.bz2 econ-3c13aefb2aec3a2db7768579261bd0a1721dc4be.zip |
econproxy: Move econ initialization into own function
-rw-r--r-- | econproxy.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/econproxy.c b/econproxy.c index 58d3413..554dc9f 100644 --- a/econproxy.c +++ b/econproxy.c @@ -251,12 +251,12 @@ vnes_ntoh(rfbServerInitMsg *vnes1, rfbServerInitMsg *vnes2) } static int -ep_reqconnect(struct ep *ep, rfbServerInitMsg *vnes) +ep_reqconnect(struct ep *ep) { init_packet(ep, E_CMD_REQCONNECT); ep->ehdr.datasize = sizeof ep->ecmd + sizeof ep->erec; - vnes_ntoh(vnes, &ep->ecmd.command.reqconnect.vnesInitMsg); + vnes_ntoh(&ep->vnesInitMsg, &ep->ecmd.command.reqconnect.vnesInitMsg); set_ip(ep->ecmd.command.reqconnect.subnetMask, sock_get_netmask(ep->ec_fd)); @@ -682,6 +682,29 @@ rfb_init(struct ep *ep) return 0; } +static int +econ_init(struct ep *ep, const char *beamer) +{ + if (create_beamer_sockets(ep, beamer) < 0) + return -1; + + if (ep_get_clientinfo(ep) < 0) + return -1; + + if (ep_reqconnect(ep) < 0) + return -1; + + if (create_data_sockets(ep, beamer) < 0) + return -1; + + ep_keepalive(ep); + + if (ep_read_ack(ep) < 0) + return -1; + + return 0; +} + int main(int argc, char *argv[]) { @@ -699,21 +722,7 @@ main(int argc, char *argv[]) if (rfb_init(&ep) < 0) exit(EXIT_FAILURE); - if (create_beamer_sockets(&ep, beamer) < 0) - exit(EXIT_FAILURE); - - if (ep_get_clientinfo(&ep) < 0) - exit(EXIT_FAILURE); - - if (ep_reqconnect(&ep, &ep.vnesInitMsg) < 0) - exit(EXIT_FAILURE); - - if (create_data_sockets(&ep, beamer) < 0) - exit(EXIT_FAILURE); - - ep_keepalive(&ep); - - if (ep_read_ack(&ep) < 0) + if (econ_init(&ep, beamer) < 0) exit(EXIT_FAILURE); while (1) { |