002-termios.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. /* Exit after resetting terminal settings */
  23. void ext(long xtc) {
  24. - ioctl(1, TCSETA, &cons);
  25. + ioctl(1, TCSETS, &cons);
  26. exit(xtc);
  27. }
  28. @@ -920,24 +920,24 @@ BOOL getonoroff(void) {
  29. void setcom(void) {
  30. stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
  31. stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits );
  32. - if (ioctl(comfd, TCSETA, &stbuf) < 0) {
  33. + if (ioctl(comfd, TCSETS, &stbuf) < 0) {
  34. serror("Can't ioctl set device",1);
  35. }
  36. }
  37. void doset(void) {
  38. - struct termio console;
  39. + struct termios console;
  40. int a,b;
  41. gettoken();
  42. if(strcmp(token,"echo")==0) {
  43. a=0;
  44. if(getonoroff()) a=ECHO|ECHOE;
  45. - if(ioctl(0, TCGETA, &console)<0) {
  46. + if(ioctl(0, TCGETS, &console)<0) {
  47. serror("Can't ioctl FD zero!\n",2);
  48. }
  49. console.c_lflag &= ~(ECHO | ECHOE);
  50. console.c_lflag |= a;
  51. - ioctl(0, TCSETA, &console);
  52. + ioctl(0, TCSETS, &console);
  53. }
  54. else if(strcmp(token,"senddelay")==0) {
  55. senddelay=10000L*getdvalue();
  56. @@ -1224,7 +1224,7 @@ void doclose(void) {
  57. if(strcmp(token,"hardcom")==0) {
  58. if(comfd== -1) serror("Com device not open",1);
  59. vmsg("Closing device");
  60. - if (ioctl(comfd, TCSETA, &svbuf) < 0) {
  61. + if (ioctl(comfd, TCSETS, &svbuf) < 0) {
  62. sprintf(msg,"Can't ioctl set device %s.\n",device);
  63. serror(msg,1);
  64. }
  65. @@ -1266,12 +1266,12 @@ void opengt(void) {
  66. ext(1);
  67. }
  68. }
  69. - if (ioctl (comfd, TCGETA, &svbuf) < 0) {
  70. + if (ioctl (comfd, TCGETS, &svbuf) < 0) {
  71. sprintf(msg,"Can't control %s, please try again.\n",device);
  72. serror(msg,1);
  73. }
  74. setenv("COMGTDEVICE",device,1);
  75. - ioctl(comfd, TCGETA, &stbuf);
  76. + ioctl(comfd, TCGETS, &stbuf);
  77. speed=stbuf.c_cflag & CBAUD;
  78. if (high_speed == 0) strcpy(cspeed,"115200");
  79. else strcpy(cspeed,"57600");
  80. @@ -1303,11 +1303,11 @@ void opendevice(void) {
  81. }
  82. else comfd=0;
  83. - if (ioctl (comfd, TCGETA, &svbuf) < 0) {
  84. + if (ioctl (comfd, TCGETS, &svbuf) < 0) {
  85. sprintf(msg,"Can't ioctl get device %s.\n",device);
  86. serror(msg,1);
  87. }
  88. - ioctl(comfd, TCGETA, &stbuf);
  89. + ioctl(comfd, TCGETS, &stbuf);
  90. speed=stbuf.c_cflag & CBAUD;
  91. switch(speed) {
  92. case B0: strcpy(cspeed,"0");break;
  93. @@ -1553,7 +1553,7 @@ int main(int argc,char **argv) {
  94. skip_default=0;
  95. filep=NULL;
  96. scriptspace=4096;
  97. - ioctl(1, TCGETA, &cons);
  98. + ioctl(1, TCGETS, &cons);
  99. if((script=( char *)malloc(scriptspace))==NULL) {
  100. serror("Could not malloc()",3);
  101. }