]> hackdaworld.org Git - my-code/ivac.git/commitdiff
major bugfixes, still need clean up + improvements, not to mention speex and video... master origin
authorhackbard <hackbard>
Thu, 8 Jul 2004 12:06:19 +0000 (12:06 +0000)
committerhackbard <hackbard>
Thu, 8 Jul 2004 12:06:19 +0000 (12:06 +0000)
src/Makefile
src/ivac.c
src/start_ivac [new file with mode: 0755]

index 1b567dbb17a9ec22925869e73bf850350c30bf7b..ca8d2e437a2c1562321c20ee9ad4b52237eaa482 100644 (file)
@@ -2,7 +2,7 @@
 
 INCLUDEDIR = /usr/include
 
-CFLAGS = -DDISPLAY -DDEBUG -O3 -Wall
+CFLAGS = -O3 -Wall
 LIBS = -lncurses
 
 OBJS = network.o event.o input.o display.o audio.o
index f6a11180a4e6b6e763944368da85ebeba08c83b9..12e5f5961f2251ec7a2b16b7f195568323b8c47a 100644 (file)
@@ -342,6 +342,11 @@ int ivac_parse_command(t_input *input,void *ptr) {
   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);
 
@@ -359,18 +364,21 @@ int ivac_parse_command(t_input *input,void *ptr) {
 
     /* 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;
     }
 
@@ -418,13 +426,16 @@ int ivac_parse_command(t_input *input,void *ptr) {
           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]);
     } 
@@ -484,14 +495,13 @@ int ivac_parse_command(t_input *input,void *ptr) {
     /* 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;
@@ -561,14 +571,17 @@ int ivac_display_console(t_ivac *ivac) {
 
 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;
@@ -585,25 +598,14 @@ int ivac_display_prompt_content(t_ivac *ivac) {
 
   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;
 }
 
diff --git a/src/start_ivac b/src/start_ivac
new file mode 100755 (executable)
index 0000000..426d436
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+KEEPLOG=1
+
+# ivac start script
+if [ ! -d ~/.ivac ] ; then
+       echo "creating .ivac directory ..."
+       mkdir ~/.ivac
+fi
+
+IVAC=`type -p ivac`
+[ -z "$IVAC" ] && IVAC="./ivac"
+
+if [ ! -e $IVAC ] ; then
+       echo "ivac executable not found :("
+else
+       echo "running $IVAC ..."
+       $IVAC $@ 2> ~/.ivac/log
+       if [ -z  "`echo $@ | grep -- -h`" ] ; then
+               reset
+               clear
+       fi
+fi
+
+[ "$KEEPLOG" = "0" ] && rm -f ~/.ivac/log