CoCalc -- Collaborative Calculation in the Cloud
Sharedwww / onhand / fton-0.3.patchOpen in CoCalc
diff -ru fton-0.3.orig/fton.c fton-0.3/fton.c
--- fton-0.3.orig/fton.c	Fri Jul 16 22:45:42 2004
+++ fton-0.3/fton.c	Fri Oct 28 02:33:59 2005
@@ -74,7 +74,13 @@
 #include "rupcommand.h"
 #include "rupserial.h"
 
-static char	rup_line[FILENAME_MAX] = {"/dev/ttyS0"};
+#if defined(__linux__)
+#define RUP_LINE "/dev/ttyS0"
+#elif defined(__FreeBSD__)
+#define RUP_LINE "/dev/cuaa0"
+#endif
+
+static char	rup_line[FILENAME_MAX] = {RUP_LINE};
 static char	rup_cwd[64] = {"B:\\"};
 static char	rup_cwdA[64] = {"A:\\"};
 static char	rup_cwdB[64] = {"B:\\"};
@@ -239,7 +245,8 @@
   char * ret_str;
    ret_str = malloc (sizeof(char) * 1024);
   printf("%s", txt);
-  gets(ret_str);
+  fgets(ret_str, 1024, stdin);
+  ret_str[strlen(ret_str)-1] = 0;
  return ret_str;
 }
 
@@ -485,13 +492,13 @@
 /* list explanations*/
 fprintf(stderr, "Where:\n");
 fprintf(stderr, "  -v/-V - small version info / big info\n");
-fprintf(stderr, "  -l - specifies the device, e.g. -l /dev/ttyS0\
- (first com port)\n");
+fprintf(stderr, "  -l - specifies the device, e.g. -l %s\
+ (first com port)\n", RUP_LINE);
 fprintf(stderr, "  -b  - specifies the baud rate\n");
 fprintf(stderr, "   valid rates are: 19200, 38400 (default), 57600\n");
 fprintf(stderr, "  commands - list of commands to then then quit\n");
 fprintf(stderr, "              e.g. %s put test.exf\n\n", cmd_name);
-fprintf(stderr, "Default is to open COM1 (/dev/ttyS0) with OnHand baud rate (38400)\n\n");
+fprintf(stderr, "Default is to open COM1 (%s) with OnHand baud rate (38400)\n\n", RUP_LINE);
 }
 
 int
@@ -503,6 +510,7 @@
      char       connect_speed[20] = {"38400"};
      int        show_usage = 0;
      char       *tmp_envvar;
+     int	exit_loop;
 
      tmp_envvar = getenv("FTON_SERIALPORT");
      if (tmp_envvar != NULL ) strcpy (rup_line,tmp_envvar);
@@ -516,6 +524,7 @@
 	  if (*name == '-') {
 	       opts++;
 	       for (name++; *name != '\0'; name++) {
+		       exit_loop = 0;
 		    argv[i] = NULL;
 		    if (c == i )
 			 c++;
@@ -536,10 +545,10 @@
 			      argv[i] = NULL;
 			      if (c == i)
 				   c++;
-			      goto exit_loop;
+			      exit_loop = 1;
 			 } else {
 			      strcpy(rup_line, name);
-			      goto exit_loop;
+			      exit_loop = 1;
 			 }
 			 break;
                     case 'b':
@@ -550,10 +559,10 @@
                               argv[i] = NULL;
                               if (c == i)
                                    c++;
-                              goto exit_loop;
+                              exit_loop = 1;
                          } else {
                               strcpy(rup_line, name);
-                              goto exit_loop;
+                              exit_loop = 1;
                          }
                          break;
 		    default:
@@ -561,9 +570,9 @@
                          show_usage = 1;
 			 break;
 		    }
-		      
+		    if(exit_loop)
+			    break;
 	       }
-	  exit_loop:
 	  }
      }
 
diff -ru fton-0.3.orig/rupserial.c fton-0.3/rupserial.c
--- fton-0.3.orig/rupserial.c	Tue Jul 20 00:36:32 2004
+++ fton-0.3/rupserial.c	Fri Oct 28 02:25:52 2005
@@ -116,7 +116,7 @@
 		       IXON | IXOFF | INPCK | ISTRIP);
      term.c_iflag |= BRKINT | IGNPAR;
      term.c_oflag &= ~OPOST;
-     term.c_lflag = ~(ICANON | ISIG | ECHO | ECHONL | ECHOE | ECHOK);
+     term.c_lflag = ~(ICANON | ISIG | ECHO | ECHONL | ECHOE | ECHOK | IEXTEN);
 	 term.c_cflag |= CS8 | CREAD;
 #else
 	 /* 8 Bit Words, Receivers on, Don't mind Flow Control, Ignore status lines */
@@ -383,7 +383,7 @@
 	  ;
      if (((~sum) & 0xff) == (*b & 0xff))
 	  return 0;
-     if (dat) {
+     if (dat->data) {
 	  free(dat->data);
      }
      return -1;