valid=0;
/* refresh prompt content only */
+#ifdef DEBUG
+ sprintf(debug_string,"-> %02x c_count = %d",input->content[input->c_count-1],
+ input->c_count);
+ ivac_add_to_monitor(ivac,debug_string);
+#endif
ivac_display_prompt_content(ivac);
ivac_display_draw(ivac);
/* get args */
len=0;
- while(data[len]!='\n'||data[len]!='\r') len++;
+ while(data[len]!='\n'&&data[len]!='\r') len++;
+#ifdef DEBUG
+ sprintf(debug_string,"len = %d\n",len);
+ ivac_add_to_monitor(ivac,debug_string);
+#endif
i=0; j=0;
while((i<len) && (j<IVAC_ARG_COUNT)) {
k=0;
- while((data[i+k]!=' ')&&(data[i+k]!='\n'||data[i+k]!='\r')) {
+ while(data[i+k]==' ') i++;
+ while(data[i+k]!=' '&&data[i+k]!='\n'&&data[i+k]!='\r') {
arg[j][k]=data[i+k];
k++;
}
arg[j][k]='\0';
j++;
- /* skip all ' ' */
- while(data[i+k]==' ') k++;
i+=k;
}
sprintf(c_str,"channel %02d: connection in use",channel);
else if(i==N_E_NO_INFO)
sprintf(c_str,"channel %02d: channel not configured",channel);
- else {
+ else if(i==N_SUCCESS) {
sprintf(c_str,"channel %02d: connected to %s:%d",channel,
ivac->net.connection[channel].ip,
ivac->net.connection[channel].port);
event_math(ivac->net.connection[channel].fd,&(ivac->event),READ,ADD);
ivac_send_info(channel,ivac);
}
+ else if(i==N_E_CONNECT)
+ sprintf(c_str,"channel %02d: connection error - %s",
+ channel,sys_errlist[errno]);
}
else sprintf(c_str,"invalid argument: '%s'",arg[1]);
}
/* add console string to console buffer */
ivac_add_to_monitor(ivac,c_str);
- /* refresh whole display content */
- ivac_display_content(ivac);
- ivac_display_draw(ivac);
-
/* delete input content buffer + reset counter */
memset(input->content,0,input->c_count-1);
input->c_count=0;
+ /* refresh whole display content */
+ ivac_display_content(ivac);
+ ivac_display_draw(ivac);
}
return SUCCESS;
int ivac_display_console_content(t_ivac *ivac) {
- int i;
+ int i,size;
char string[IVAC_CONSOLE_STRING_LEN];
for(i=0;i<IVAC_CONSOLE_LEN;i++) {
- snprintf(string,IVAC_CONSOLE_STRING_LEN,"%s\n",ivac->console[i]);
+ size=strlen(ivac->console[i]);
+ size=(size<IVAC_CONSOLE_STRING_LEN)?size:IVAC_CONSOLE_STRING_LEN;
+ memcpy(string,ivac->console[i],size);
+ memset(string+size,' ',IVAC_CONSOLE_STRING_LEN-size);
display_string(&(ivac->display),
0,ivac->display.max_y-IVAC_PROMPT_LEN-IVAC_CONSOLE_LEN+1+i,
- string,strlen(string));
+ string,IVAC_CONSOLE_STRING_LEN);
}
return SUCCESS;
char string[IVAC_CONSOLE_STRING_LEN];
int count;
-#ifdef DEBUG
- char debug_string[IVAC_CONSOLE_STRING_LEN];
-#endif
for(count=0;count<ivac->input.c_count;count++)
string[count]=ivac->input.content[count];
for(count=ivac->input.c_count;count<IVAC_CONSOLE_STRING_LEN-8;count++)
string[count]=' ';
display_string(&(ivac->display),8,ivac->display.max_y-1,
- string,ivac->display.max_x);
+ string,IVAC_CONSOLE_STRING_LEN-8);
-#ifdef DEBUG
- sprintf(debug_string,"%02x %02x %02x %02x ...",ivac->input.content[0],
- ivac->input.content[1],
- ivac->input.content[2],
- ivac->input.content[3]);
- ivac_add_to_monitor(ivac,debug_string);
-#endif
-
return SUCCESS;
}