X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fivac.git;a=blobdiff_plain;f=src%2Fivac.c;h=e3e206013aee7ba74ef556cb7ec53bbf1df44418;hp=56a687fb6603443236966a3d32763c68a1d07abf;hb=44d1396bcdd42a518855981fc8aa0b0fbc665231;hpb=c0de1cff899325f9a4a058d7544ddbef3a5c50b1 diff --git a/src/ivac.c b/src/ivac.c index 56a687f..e3e2060 100644 --- a/src/ivac.c +++ b/src/ivac.c @@ -58,16 +58,16 @@ int main(int argc,char **argv) { switch(argv[i][1]) { case 'h': usage(); - break; + return SUCCESS; case 'n': - strncpy(ivac.username,argv[i+1],CHAR_USERNAME); + strncpy(ivac.username,argv[++i],CHAR_USERNAME); break; case 'p': - ivac.net.l_port=atoi(argv[i+1]); + ivac.net.l_port=atoi(argv[++i]); break; default: usage(); - break; + return ERROR; } } else usage(); @@ -229,7 +229,7 @@ int ivac_receive_info(int channel,t_ivac *ivac) { } } - return SUCCESS; + return length; } int ivac_event_cb(t_event *event,void *ptr) { @@ -263,7 +263,12 @@ int ivac_event_cb(t_event *event,void *ptr) { if(ivac->net.connection[channel].status&C_ESTABL) { /* remote is sending info */ if(FD_ISSET(ivac->net.connection[channel].fd,&(event->rfds))) { - ivac_receive_info(channel,ivac); + if(ivac_receive_info(channel,ivac)==0) { + event_math(ivac->net.connection[channel].fd,event,READ,REMOVE); + network_close(&(ivac->net),channel); + sprintf(c_str,"channel %02d: broken pipe - disconnected",channel); + ivac_add_to_monitor(ivac,c_str); + } ivac_display_content(ivac); } }