comgt: Use TCGETS and TCSETS ioctls for struct termios
[openwrt/svn-archive/archive.git] / package / network / utils / comgt / patches / 002-termios.patch
1 --- a/comgt.c
2 +++ b/comgt.c
3 @@ -30,7 +30,7 @@
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <signal.h>
7 -#include <termio.h>
8 +#include <termios.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <string.h>
12 @@ -81,7 +81,7 @@ char token[MAXTOKEN]; /* For gettoken(
13 char scriptfile[MAXPATH]; /* Script file name */
14 char scriptfilepath[MAXPATH]; /* temp storage for full path */
15 BOOL verbose=0; /* Log actions */
16 -struct termio cons, stbuf, svbuf; /* termios: svbuf=before, stbuf=while */
17 +struct termios cons, stbuf, svbuf; /* termios: svbuf=before, stbuf=while */
18 int comfd=0; /* Communication file descriptor. Defaults to stdin. */
19 char msg[STRINGL]; /* Massage messages here */
20 int preturn,returns[MAXGOSUBS];
21 @@ -172,7 +172,7 @@ void dotestkey(void) {
22
23 /* Exit after resetting terminal settings */
24 void ext(long xtc) {
25 - ioctl(1, TCSETA, &cons);
26 + ioctl(1, TCSETS, &cons);
27 exit(xtc);
28 }
29
30 @@ -920,24 +920,24 @@ BOOL getonoroff(void) {
31 void setcom(void) {
32 stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
33 stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits );
34 - if (ioctl(comfd, TCSETA, &stbuf) < 0) {
35 + if (ioctl(comfd, TCSETS, &stbuf) < 0) {
36 serror("Can't ioctl set device",1);
37 }
38 }
39
40 void doset(void) {
41 - struct termio console;
42 + struct termios console;
43 int a,b;
44 gettoken();
45 if(strcmp(token,"echo")==0) {
46 a=0;
47 if(getonoroff()) a=ECHO|ECHOE;
48 - if(ioctl(0, TCGETA, &console)<0) {
49 + if(ioctl(0, TCGETS, &console)<0) {
50 serror("Can't ioctl FD zero!\n",2);
51 }
52 console.c_lflag &= ~(ECHO | ECHOE);
53 console.c_lflag |= a;
54 - ioctl(0, TCSETA, &console);
55 + ioctl(0, TCSETS, &console);
56 }
57 else if(strcmp(token,"senddelay")==0) {
58 senddelay=10000L*getdvalue();
59 @@ -1224,7 +1224,7 @@ void doclose(void) {
60 if(strcmp(token,"hardcom")==0) {
61 if(comfd== -1) serror("Com device not open",1);
62 vmsg("Closing device");
63 - if (ioctl(comfd, TCSETA, &svbuf) < 0) {
64 + if (ioctl(comfd, TCSETS, &svbuf) < 0) {
65 sprintf(msg,"Can't ioctl set device %s.\n",device);
66 serror(msg,1);
67 }
68 @@ -1266,12 +1266,12 @@ void opengt(void) {
69 ext(1);
70 }
71 }
72 - if (ioctl (comfd, TCGETA, &svbuf) < 0) {
73 + if (ioctl (comfd, TCGETS, &svbuf) < 0) {
74 sprintf(msg,"Can't control %s, please try again.\n",device);
75 serror(msg,1);
76 }
77 setenv("COMGTDEVICE",device,1);
78 - ioctl(comfd, TCGETA, &stbuf);
79 + ioctl(comfd, TCGETS, &stbuf);
80 speed=stbuf.c_cflag & CBAUD;
81 if (high_speed == 0) strcpy(cspeed,"115200");
82 else strcpy(cspeed,"57600");
83 @@ -1303,11 +1303,11 @@ void opendevice(void) {
84 }
85 else comfd=0;
86
87 - if (ioctl (comfd, TCGETA, &svbuf) < 0) {
88 + if (ioctl (comfd, TCGETS, &svbuf) < 0) {
89 sprintf(msg,"Can't ioctl get device %s.\n",device);
90 serror(msg,1);
91 }
92 - ioctl(comfd, TCGETA, &stbuf);
93 + ioctl(comfd, TCGETS, &stbuf);
94 speed=stbuf.c_cflag & CBAUD;
95 switch(speed) {
96 case B0: strcpy(cspeed,"0");break;
97 @@ -1553,7 +1553,7 @@ int main(int argc,char **argv) {
98 skip_default=0;
99 filep=NULL;
100 scriptspace=4096;
101 - ioctl(1, TCGETA, &cons);
102 + ioctl(1, TCGETS, &cons);
103 if((script=( char *)malloc(scriptspace))==NULL) {
104 serror("Could not malloc()",3);
105 }