From: hackbard Date: Sun, 9 May 2004 10:14:55 +0000 (+0000) Subject: more display + 1st network connection tries X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f7a9e08cad9caa3aa593eba18e6a22f763ecc37;p=my-code%2Fivac.git more display + 1st network connection tries --- diff --git a/src/ivac.c b/src/ivac.c index 1018192..9645c33 100644 --- a/src/ivac.c +++ b/src/ivac.c @@ -39,6 +39,10 @@ int main(int argc,char **argv) { /* set username */ strncpy(ivac.username,argv[1],CHAR_USERNAME); + /* clear challenger struct */ + for(i=0;inet)); input_shutdown(&(ivac->input)); event_stop(&(ivac->event)); -#ifdef USE_NCURSES - display_shutdown(&(ivac->display)); -#endif + // display_shutdown(&(ivac->display)); return SUCCESS; } @@ -175,9 +177,10 @@ int ivac_event_cb(t_event *event,void *ptr) { if(FD_ISSET(ivac->net.l_fd,&(event->rfds))) { /* manage incoming + send info */ - channel=network_manage_incoming(&(ivac->net)); - event_math(ivac->net.connection[channel].fd,event,READ,ADD); - ivac_send_info(channel,ivac); + if((channel=network_manage_incoming(&(ivac->net)))!=N_ERROR) { + event_math(ivac->net.connection[channel].fd,event,READ,ADD); + ivac_send_info(channel,ivac); + } } /* receive info */ @@ -191,9 +194,7 @@ int ivac_event_cb(t_event *event,void *ptr) { input_get_event(&(ivac->input),ivac_parse_command,ivac); /* display ivac gui */ -#ifdef USE_NCURSES - ivac_display_content(ivac); -#endif + // ivac_display_content(ivac); return SUCCESS; } @@ -219,11 +220,10 @@ int ivac_parse_command(t_input *input,void *ptr) { data=input->content; valid=0; - printf("%c",data[input->c_count-1]); - fflush(NULL); + /* refresh prompt content only! */ + ivac_display_prompt_content(ivac); /* parse command routines */ - if(data[input->c_count-1]=='\n') { /* delete console string + args */ @@ -231,7 +231,6 @@ int ivac_parse_command(t_input *input,void *ptr) { for(j=0;jnet.connection[channel].ip, ivac->net.connection[channel].port); + ivac->net.connection[channel].status|=C_IN_USE; } } } @@ -340,8 +340,14 @@ int ivac_parse_command(t_input *input,void *ptr) { if(!valid) snprintf(c_str,IVAC_CONSOLE_STRING_LEN,"unknown command: '%s'",arg[0]); + /* call network functions */ + network_manage_connection(&(ivac->net)); + + /* add console string to console buffer */ ivac_add_to_monitor(ivac,c_str); - + + /* refresh whole display content */ + ivac_display_content(ivac); /* delete content buffer + reset counter */ memset(input->content,0,input->c_count-1); @@ -390,22 +396,43 @@ int ivac_display_box(t_display *display) { int ivac_display_box_content(t_ivac *ivac) { + int channel; + + /* prepare challenger names */ + for(channel=0;channelchallenger[channel].name[0]==0) + strcpy(ivac->challenger[channel].name,""); + +#ifdef USE_NCURSES +#else + for(channel=0;channelnet.connection[channel].status&C_INFO_A) + printf("channel %02d: ip:%s port:%d status: %02x - name: %s\n",channel, + ivac->net.connection[channel].ip, + ivac->net.connection[channel].port, + ivac->net.connection[channel].status, + ivac->challenger[channel].name); + } +#endif return SUCCESS; } int ivac_display_console(t_display *display) { - + +#ifdef USE_NCURSES int x,y; move(display->max_y-IVAC_CONSOLE_LEN-IVAC_PROMPT_LEN-1,0); - for(x=0;xmax_x;x++) addch('#'); + for(x=0;xmax_x;x++) addch('#'); +#endif return SUCCESS; } int ivac_display_console_content(t_ivac *ivac) { +#ifdef USE_NCURSES int x,y; int len; @@ -418,12 +445,19 @@ int ivac_display_console_content(t_ivac *ivac) { for(x=len;xconsole[i]); +#endif return SUCCESS; } int ivac_display_prompt(t_display *display) { +#ifdef USE_NCURSES int x,y; move(display->max_y-3,0); @@ -433,12 +467,14 @@ int ivac_display_prompt(t_display *display) { move(display->max_y-1,0); for(x=0;xmax_x;x++) addch('#'); refresh(); +#endif return SUCCESS; } int ivac_display_prompt_content(t_ivac *ivac) { +#ifdef USE_NCURSES int x,y; /* delete old command */ @@ -450,6 +486,10 @@ int ivac_display_prompt_content(t_ivac *ivac) { for(x=0;xinput.c_count;x++) mvaddch(ivac->display.max_y-2,x+12,ivac->input.content[x]); refresh(); +#else + printf("%c",ivac->input.content[ivac->input.c_count-1]); + fflush(NULL); +#endif return SUCCESS; } @@ -495,11 +535,5 @@ int ivac_add_to_monitor(t_ivac *ivac,char *msg) { memcpy(ivac->console[i],ivac->console[i+1],IVAC_CONSOLE_STRING_LEN); memcpy(ivac->console[IVAC_CONSOLE_LEN-1],msg,IVAC_CONSOLE_STRING_LEN); - for(i=0;iconsole[i]); -#ifdef USE_NCURSES - ivac_display_console_content(ivac); -#endif - return SUCCESS; }