You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.0 KiB

  1. --- a/sc.c
  2. +++ b/sc.c
  3. @@ -34,6 +34,7 @@ static const char __rcsid[] =
  4. #include <sysexits.h>
  5. #include <termios.h>
  6. #include <unistd.h>
  7. +#include <time.h>
  8. #if !defined(SC_VERSION)
  9. @@ -344,7 +345,7 @@ loop(int sfd, int escchr, int msdelay)
  10. FD_SET(STDIN_FILENO, fds+1);
  11. FD_SET(sfd, fds+1);
  12. while (scrunning) {
  13. - bcopy(fds+1, fds, sizeof(*fds));
  14. + memcpy(fds, fds+1, sizeof(*fds));
  15. if ((i = select(sfd+1, fds, NULL, NULL, NULL)) < 0
  16. && errno != EINTR) {
  17. warn("select()");
  18. @@ -353,7 +354,7 @@ loop(int sfd, int escchr, int msdelay)
  19. #else
  20. struct pollfd pfds[2];
  21. - bzero(pfds, sizeof(pfds));
  22. + memset(pfds, 0, sizeof(pfds));
  23. pfds[0].fd = STDIN_FILENO;
  24. pfds[0].events = POLLIN;
  25. pfds[1].fd = sfd;
  26. @@ -453,8 +454,10 @@ loop(int sfd, int escchr, int msdelay)
  27. continue;
  28. }
  29. i = write(sfd, &c, 1);
  30. - if(c == '\n' && msdelay > 0)
  31. - usleep(msdelay*1000);
  32. + if(c == '\n' && msdelay > 0) {\
  33. + struct timespec d = {msdelay / 1000, (msdelay % 1000 ) * 1000 * 1000};
  34. + nanosleep(&d, NULL);
  35. + }
  36. }
  37. if (i < 0) {
  38. warn("read/write");
  39. @@ -603,8 +606,8 @@ main(int argc, char **argv)
  40. if (strlen(path_dev) + strlen(tty) > PATH_MAX) {
  41. errx(EX_USAGE, "Device name \"%s\" is too long.", tty);
  42. }
  43. - bcopy(path_dev, buffer, strlen(path_dev)+1);
  44. - bcopy(tty, buffer+strlen(path_dev), strlen(tty)+1);
  45. + memcpy(buffer, path_dev, strlen(path_dev)+1);
  46. + memcpy(buffer+strlen(path_dev), tty, strlen(tty)+1);
  47. tty = buffer;
  48. }
  49. sfd = open(tty, O_RDWR);
  50. @@ -622,7 +625,7 @@ main(int argc, char **argv)
  51. err(EX_OSERR, "tcgetattr(%s)", tty);
  52. }
  53. /* configure serial port */
  54. - bcopy(&serialti, &tempti, sizeof(tempti));
  55. + memcpy(&tempti, &serialti, sizeof(tempti));
  56. cfmakeraw(&tempti);
  57. tempti.c_cc[VMIN] = 1;
  58. tempti.c_cc[VTIME] = 0;
  59. @@ -660,7 +663,7 @@ main(int argc, char **argv)
  60. close(sfd);
  61. err(EX_OSERR, "fcntl() tty");
  62. }
  63. - bcopy(&consoleti, &tempti, sizeof(tempti));
  64. + memcpy(&tempti, &consoleti, sizeof(tempti));
  65. cfmakeraw(&tempti);
  66. if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &tempti)) {
  67. ec = EX_OSERR;