Sharedwww / onhand / fton-0.3.patchOpen in CoCalc
Author: William A. Stein
1
diff -ru fton-0.3.orig/fton.c fton-0.3/fton.c
2
--- fton-0.3.orig/fton.c Fri Jul 16 22:45:42 2004
3
+++ fton-0.3/fton.c Fri Oct 28 02:33:59 2005
4
@@ -74,7 +74,13 @@
5
#include "rupcommand.h"
6
#include "rupserial.h"
7
8
-static char rup_line[FILENAME_MAX] = {"/dev/ttyS0"};
9
+#if defined(__linux__)
10
+#define RUP_LINE "/dev/ttyS0"
11
+#elif defined(__FreeBSD__)
12
+#define RUP_LINE "/dev/cuaa0"
13
+#endif
14
+
15
+static char rup_line[FILENAME_MAX] = {RUP_LINE};
16
static char rup_cwd[64] = {"B:\\"};
17
static char rup_cwdA[64] = {"A:\\"};
18
static char rup_cwdB[64] = {"B:\\"};
19
@@ -239,7 +245,8 @@
20
char * ret_str;
21
ret_str = malloc (sizeof(char) * 1024);
22
printf("%s", txt);
23
- gets(ret_str);
24
+ fgets(ret_str, 1024, stdin);
25
+ ret_str[strlen(ret_str)-1] = 0;
26
return ret_str;
27
}
28
29
@@ -485,13 +492,13 @@
30
/* list explanations*/
31
fprintf(stderr, "Where:\n");
32
fprintf(stderr, " -v/-V - small version info / big info\n");
33
-fprintf(stderr, " -l - specifies the device, e.g. -l /dev/ttyS0\
34
- (first com port)\n");
35
+fprintf(stderr, " -l - specifies the device, e.g. -l %s\
36
+ (first com port)\n", RUP_LINE);
37
fprintf(stderr, " -b - specifies the baud rate\n");
38
fprintf(stderr, " valid rates are: 19200, 38400 (default), 57600\n");
39
fprintf(stderr, " commands - list of commands to then then quit\n");
40
fprintf(stderr, " e.g. %s put test.exf\n\n", cmd_name);
41
-fprintf(stderr, "Default is to open COM1 (/dev/ttyS0) with OnHand baud rate (38400)\n\n");
42
+fprintf(stderr, "Default is to open COM1 (%s) with OnHand baud rate (38400)\n\n", RUP_LINE);
43
}
44
45
int
46
@@ -503,6 +510,7 @@
47
char connect_speed[20] = {"38400"};
48
int show_usage = 0;
49
char *tmp_envvar;
50
+ int exit_loop;
51
52
tmp_envvar = getenv("FTON_SERIALPORT");
53
if (tmp_envvar != NULL ) strcpy (rup_line,tmp_envvar);
54
@@ -516,6 +524,7 @@
55
if (*name == '-') {
56
opts++;
57
for (name++; *name != '\0'; name++) {
58
+ exit_loop = 0;
59
argv[i] = NULL;
60
if (c == i )
61
c++;
62
@@ -536,10 +545,10 @@
63
argv[i] = NULL;
64
if (c == i)
65
c++;
66
- goto exit_loop;
67
+ exit_loop = 1;
68
} else {
69
strcpy(rup_line, name);
70
- goto exit_loop;
71
+ exit_loop = 1;
72
}
73
break;
74
case 'b':
75
@@ -550,10 +559,10 @@
76
argv[i] = NULL;
77
if (c == i)
78
c++;
79
- goto exit_loop;
80
+ exit_loop = 1;
81
} else {
82
strcpy(rup_line, name);
83
- goto exit_loop;
84
+ exit_loop = 1;
85
}
86
break;
87
default:
88
@@ -561,9 +570,9 @@
89
show_usage = 1;
90
break;
91
}
92
-
93
+ if(exit_loop)
94
+ break;
95
}
96
- exit_loop:
97
}
98
}
99
100
diff -ru fton-0.3.orig/rupserial.c fton-0.3/rupserial.c
101
--- fton-0.3.orig/rupserial.c Tue Jul 20 00:36:32 2004
102
+++ fton-0.3/rupserial.c Fri Oct 28 02:25:52 2005
103
@@ -116,7 +116,7 @@
104
IXON | IXOFF | INPCK | ISTRIP);
105
term.c_iflag |= BRKINT | IGNPAR;
106
term.c_oflag &= ~OPOST;
107
- term.c_lflag = ~(ICANON | ISIG | ECHO | ECHONL | ECHOE | ECHOK);
108
+ term.c_lflag = ~(ICANON | ISIG | ECHO | ECHONL | ECHOE | ECHOK | IEXTEN);
109
term.c_cflag |= CS8 | CREAD;
110
#else
111
/* 8 Bit Words, Receivers on, Don't mind Flow Control, Ignore status lines */
112
@@ -383,7 +383,7 @@
113
;
114
if (((~sum) & 0xff) == (*b & 0xff))
115
return 0;
116
- if (dat) {
117
+ if (dat->data) {
118
free(dat->data);
119
}
120
return -1;
121