*
*/
-// #define DISPLAY
+// #define USE_NCURSES
#include "ivac.h"
t_ivac ivac;
int i;
- /* set username (futur: read from config or entered later) */
- strcpy(ivac.username,"hackbard");
+ if(argc!=2) {
+ printf("\nusage: %s <username>\n\n",argv[0]);
+ return ERROR;
+ }
+
+ /* set username */
+ strncpy(ivac.username,argv[1],CHAR_USERNAME);
for(i=0;i<IVAC_CONSOLE_LEN;i++)
memset(ivac.console[i],0,IVAC_CONSOLE_STRING_LEN);
event_math(0,&(ivac.event),READ,ADD);
/* display init */
-#ifdef DISPLAY
display_init(&(ivac.display));
-#endif
/* display */
-#ifdef DISPLAY
ivac_display(&(ivac.display));
-#endif
/* start event system - callbacks used: ivac_event_cb + ivac_regular_cb */
event_start(&(ivac.event),(void *)&ivac,ivac_event_cb,ivac_regular_cb);
network_shutdown(&(ivac->net));
input_shutdown(&(ivac->input));
event_stop(&(ivac->event));
-#ifdef DISPLAY
+#ifdef USE_NCURSES
display_shutdown(&(ivac->display));
#endif
input_get_event(&(ivac->input),ivac_parse_command,ivac);
/* display ivac gui */
-#ifdef DISPLAY
+#ifdef USE_NCURSES
ivac_display_content(ivac);
#endif
if((arg[1][0]>='0')&&(arg[1][0]<='9')) channel=atoi(arg[1]);
else channel=-1;
if((channel>=0)&&(channel<MAX_CONNECTIONS)) {
- if(!ivac->net.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)
if((arg[1][0]>='0')&&(arg[1][0]<='9')) channel=atoi(arg[1]);
else channel=-1;
if((channel>=0)&&(channel<MAX_CONNECTIONS)) {
- if(!ivac->net.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;
int ivac_display_head(t_display *display) {
+#ifdef USE_NCURSES
int x,y;
move(0,0);
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;
}
for(i=0;i<IVAC_CONSOLE_LEN;i++)
printf("[ivac] console line %d: %s\n",i,ivac->console[i]);
-#ifdef DISPLAY
+#ifdef USE_NCURSES
ivac_display_console_content(ivac);
#endif