X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fivac.git;a=blobdiff_plain;f=src%2Fivac.c;fp=src%2Fivac.c;h=98fc8c2a3f7633875b48be8da234dc7c4c2c1efd;hp=e3e206013aee7ba74ef556cb7ec53bbf1df44418;hb=51804c822aba850ad3d1589b4dc3dc2709d980f5;hpb=16b3789b687a3002b80a38f58c07b7a46ac89c6c diff --git a/src/ivac.c b/src/ivac.c index e3e2060..98fc8c2 100644 --- a/src/ivac.c +++ b/src/ivac.c @@ -21,9 +21,7 @@ * */ -// #define USE_NCURSES -/* dont care about ncurses .. go for gtk(2)! */ -#define USE_GTK +// #define USE_GTK #include "ivac.h" @@ -36,6 +34,7 @@ int usage(void) { puts("-h \t\t show this help"); puts("-n \t specify your name"); puts("-p \t specify port to listen for incoming connections"); + puts("-d \t specify audio device"); puts(""); return SUCCESS; @@ -51,6 +50,7 @@ int main(int argc,char **argv) { /* default values */ strcpy(ivac.username,"ivac"); ivac.net.l_port=IVAC_LISTEN_PORT; + strcpy(ivac.audio.dsp_dev,SOUND_DEVICE); /* parse argv and change default values */ for(i=1;inet)); input_shutdown(&(ivac->input)); event_stop(&(ivac->event)); -#ifdef USE_NCURSES + audio_shutdown(&(ivac->audio)); display_shutdown(&(ivac->display)); -#endif return SUCCESS; } @@ -448,37 +455,15 @@ 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); - for(x=0;xmax_x;x++) addch('#'); - mvaddstr(1,0,"##"); - mvaddstr(1,(display->max_x-4)/2-4,"- ivac -"); - mvaddstr(1,(display->max_x-2),"##"); - 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; } @@ -491,93 +476,33 @@ int ivac_display_box_content(t_ivac *ivac) { if(ivac->challenger[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('#'); -#endif - return SUCCESS; } int ivac_display_console_content(t_ivac *ivac) { -#ifdef USE_NCURSES - int x,y; - int len; - - for(y=0;yconsole[y]); - move(ivac->display.max_y-IVAC_CONSOLE_LEN-IVAC_PROMPT_LEN+y,2); - for(x=0;xconsole[y][x]>' ')||(ivac->console[y][x]<='~')) - ?ivac->console[y][x]:' '); - 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); - for(x=0;xmax_x;x++) addch('#'); - mvaddstr(display->max_y-2,0,"## command: "); - mvaddstr(display->max_y-2,display->max_x-2,"##"); - 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 */ - if(ivac->input.c_count==0) { - move(ivac->display.max_y-2,12); - for(x=12;xdisplay.max_x-1;x++) addch(' '); - } - - 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; }