X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fivac.git;a=blobdiff_plain;f=src%2Fivac.c;h=49fc97d1b262104e5ffbe8ec8f1eecc877c6071a;hp=3aad5998c56104ef3a7a598d26ba7c54d61ab3e7;hb=dce17a68190aa256fcc9ccee5059f659ae37a3a9;hpb=c19ed5019b55ed603dc10ff6f8ea47bf25058589 diff --git a/src/ivac.c b/src/ivac.c index 3aad599..49fc97d 100644 --- a/src/ivac.c +++ b/src/ivac.c @@ -22,6 +22,8 @@ */ // #define USE_NCURSES +/* dont care about ncurses .. go for gtk(2)! */ +#define USE_GTK #include "ivac.h" @@ -58,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(); @@ -180,6 +182,7 @@ int ivac_send_quit(int channel,t_ivac *ivac) { int ivac_receive_info(int channel,t_ivac *ivac) { char data[SEND_N_MAX]; + char c_str[IVAC_CONSOLE_STRING_LEN]; int count,length; count=0; @@ -208,20 +211,25 @@ int ivac_receive_info(int channel,t_ivac *ivac) { break; case IVAC_SEND_QUIT: if(!(strncmp(data+count+2,"quit",data[1]))) + sprintf(c_str,"channel %02d: connection closed by remote host", + channel); event_math(ivac->net.connection[channel].fd,&(ivac->event), READ,REMOVE); network_close(&(ivac->net),channel); memset(&(ivac->challenger[channel]),0,sizeof(t_challenger)); + ivac_add_to_monitor(ivac,c_str); count+=6; + break; default: - printf("[ivac] ivac_receive_info, unknown character: (%c,%02x\n", + sprintf(c_str,"ivac_receive_info, unknown character: 0x%02x\n", data[count]); + ivac_add_to_monitor(ivac,c_str); return ERROR; break; } } - return SUCCESS; + return length; } int ivac_event_cb(t_event *event,void *ptr) { @@ -254,9 +262,15 @@ int ivac_event_cb(t_event *event,void *ptr) { for(channel=0;channelnet.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(FD_ISSET(ivac->net.connection[channel].fd,&(event->rfds))) { + 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); + } } }