From: hackbard Date: Wed, 12 May 2004 16:52:10 +0000 (+0000) Subject: fixed parsing error & detect broken pipes X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fivac.git;a=commitdiff_plain;h=dce17a68190aa256fcc9ccee5059f659ae37a3a9 fixed parsing error & detect broken pipes --- diff --git a/src/ivac.c b/src/ivac.c index 56a687f..49fc97d 100644 --- a/src/ivac.c +++ b/src/ivac.c @@ -60,10 +60,10 @@ int main(int argc,char **argv) { usage(); break; 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(); @@ -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); } }