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 14:39:05 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, "  -b  - specifies the baud rate\n");
-fprintf(stderr, "   valid rates are: 19200, 38400 (default), 57600\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, "             e.g. %s put test.exf\n\n", cmd_name);
+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,20 +559,23 @@
                               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 'h':
+			 usage_message(argv[0]);
+			 return 0;
 		    default:
 			 fprintf(stderr, "Invalid option letter %c\n", *name);
                          show_usage = 1;
 			 break;
 		    }
-		      
+		    if(exit_loop)
+			    break;
 	       }
-	  exit_loop:
 	  }
      }
 
@@ -894,6 +906,7 @@
 		    strcpy(rup_cwdB, rde.path);
 	  }
      }
+     command_chdir(rup_cwd);
      return 0;
 }
 /*_____ ¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤òÉ½¼¨ ______________________________________________*/
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 14:38:19 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;
