]> hackdaworld.org Git - my-code/ivac.git/commitdiff
fixed parsing error & detect broken pipes
authorhackbard <hackbard>
Wed, 12 May 2004 16:52:10 +0000 (16:52 +0000)
committerhackbard <hackbard>
Wed, 12 May 2004 16:52:10 +0000 (16:52 +0000)
src/ivac.c

index 56a687fb6603443236966a3d32763c68a1d07abf..49fc97d1b262104e5ffbe8ec8f1eecc877c6071a 100644 (file)
@@ -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);
       }
     }