*
*/
-// #define USE_NCURSES
-/* dont care about ncurses .. go for gtk(2)! */
-#define USE_GTK
+// #define USE_GTK
#include "ivac.h"
puts("-h \t\t show this help");
puts("-n <name> \t specify your name");
puts("-p <port> \t specify port to listen for incoming connections");
+ puts("-d <device> \t specify audio device");
puts("");
return SUCCESS;
/* 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;i<argc;i++) {
switch(argv[i][1]) {
case 'h':
usage();
- break;
+ return SUCCESS;
case 'n':
strncpy(ivac.username,argv[++i],CHAR_USERNAME);
break;
case 'p':
ivac.net.l_port=atoi(argv[++i]);
break;
+ case 'd':
+ strncpy(ivac.audio.dsp_dev,argv[++i],MAX_CHAR_DEVICE);
+ break;
default:
usage();
- break;
+ return ERROR;
}
}
else usage();
event_math(ivac.net.l_fd,&(ivac.event),READ,ADD);
event_math(0,&(ivac.event),READ,ADD);
-#ifdef USE_NCURSES
/* display init */
display_init(&(ivac.display));
-#endif
+
+ /* use hardcoded audio settings by now */
+ ivac.audio.fmt=BIT_8;
+ ivac.audio.channels=MONO;
+ ivac.audio.speed=8000;
+ /* audio init */
+ audio_init(&(ivac.audio));
/* display */
ivac_display(&(ivac.display));
network_shutdown(&(ivac->net));
input_shutdown(&(ivac->input));
event_stop(&(ivac->event));
-#ifdef USE_NCURSES
+ audio_shutdown(&(ivac->audio));
display_shutdown(&(ivac->display));
-#endif
return SUCCESS;
}
int ivac_display_head(t_display *display) {
-#ifdef USE_NCURSES
- int x,y;
-
- move(0,0);
- for(x=0;x<display->max_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;x<display->max_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;y<display->max_y-IVAC_PROMPT_LEN;y++) {
- mvaddch(y,0,'#');
- mvaddch(y,display->max_x-1,'#');
- }
-#endif
-
return SUCCESS;
}
if(ivac->challenger[channel].name[0]==0)
strcpy(ivac->challenger[channel].name,"<empty>");
-#ifdef USE_NCURSES
-#else
- for(channel=0;channel<MAX_CONNECTIONS;channel++) {
- if(ivac->net.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;x<display->max_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;y<IVAC_CONSOLE_LEN;y++) {
- len=strlen(ivac->console[y]);
- move(ivac->display.max_y-IVAC_CONSOLE_LEN-IVAC_PROMPT_LEN+y,2);
- for(x=0;x<len;x++)
- addch(((ivac->console[y][x]>' ')||(ivac->console[y][x]<='~'))
- ?ivac->console[y][x]:' ');
- for(x=len;x<IVAC_CONSOLE_STRING_LEN-4;x++) addch(' ');
- }
- refresh();
-#else
int i;
for(i=0;i<IVAC_CONSOLE_LEN;i++)
printf("[ivac] console line %d: %s\n",i,ivac->console[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;x<display->max_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;x<display->max_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;x<ivac->display.max_x-1;x++) addch(' ');
- }
-
- for(x=0;x<ivac->input.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;
}