From: hackbard Date: Sun, 9 May 2004 00:42:32 +0000 (+0000) Subject: bugfixed command parsing, DISPLAY -> USE_NCURSES X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4abb6416b40e9d47386e1c9dd9400c3185d5bf06;p=my-code%2Fivac.git bugfixed command parsing, DISPLAY -> USE_NCURSES --- diff --git a/src/ivac.c b/src/ivac.c index 8b8acbc..1018192 100644 --- a/src/ivac.c +++ b/src/ivac.c @@ -21,7 +21,7 @@ * */ -// #define DISPLAY +// #define USE_NCURSES #include "ivac.h" @@ -32,8 +32,13 @@ int main(int argc,char **argv) { t_ivac ivac; int i; - /* set username (futur: read from config or entered later) */ - strcpy(ivac.username,"hackbard"); + if(argc!=2) { + printf("\nusage: %s \n\n",argv[0]); + return ERROR; + } + + /* set username */ + strncpy(ivac.username,argv[1],CHAR_USERNAME); for(i=0;inet)); input_shutdown(&(ivac->input)); event_stop(&(ivac->event)); -#ifdef DISPLAY +#ifdef USE_NCURSES display_shutdown(&(ivac->display)); #endif @@ -190,7 +191,7 @@ int ivac_event_cb(t_event *event,void *ptr) { input_get_event(&(ivac->input),ivac_parse_command,ivac); /* display ivac gui */ -#ifdef DISPLAY +#ifdef USE_NCURSES ivac_display_content(ivac); #endif @@ -279,7 +280,7 @@ int ivac_parse_command(t_input *input,void *ptr) { if((arg[1][0]>='0')&&(arg[1][0]<='9')) channel=atoi(arg[1]); else channel=-1; if((channel>=0)&&(channelnet.connection[channel].status&C_INFO_A) + if(!(ivac->net.connection[channel].status&C_INFO_A)) sprintf(c_str,"channel %02d: channel not configured",channel); else { if(ivac->net.connection[channel].status&C_IN_USE) @@ -298,7 +299,7 @@ int ivac_parse_command(t_input *input,void *ptr) { if((arg[1][0]>='0')&&(arg[1][0]<='9')) channel=atoi(arg[1]); else channel=-1; if((channel>=0)&&(channelnet.connection[channel].status&C_ESTABL) + if(!(ivac->net.connection[channel].status&C_ESTABL)) sprintf(c_str,"channel %02d: no active connection",channel); else { ivac->net.connection[channel].status|=C_HANGUP; @@ -353,6 +354,7 @@ int ivac_parse_command(t_input *input,void *ptr) { int ivac_display_head(t_display *display) { +#ifdef USE_NCURSES int x,y; move(0,0); @@ -363,18 +365,25 @@ int ivac_display_head(t_display *display) { move(2,0); for(x=0;xmax_x;x++) addch('#'); refresh(); +#else + puts("#########################################################"); + puts("##### ivac - - Copyright (C) 2004 Frank Zirkelbach #####"); + puts("#########################################################"); +#endif return SUCCESS; } int ivac_display_box(t_display *display) { - + +#ifdef USE_NCURSES int x,y; for(y=IVAC_PROMPT_LEN;ymax_y-IVAC_PROMPT_LEN;y++) { mvaddch(y,0,'#'); mvaddch(y,display->max_x-1,'#'); } +#endif return SUCCESS; } @@ -488,7 +497,7 @@ int ivac_add_to_monitor(t_ivac *ivac,char *msg) { for(i=0;iconsole[i]); -#ifdef DISPLAY +#ifdef USE_NCURSES ivac_display_console_content(ivac); #endif