bsd-nextstep.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2000,2001 Ben Lindstrom. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  14. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  16. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  17. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  18. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  19. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  20. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #include "includes.h"
  25. #ifdef HAVE_NEXT
  26. #include <errno.h>
  27. #include <sys/wait.h>
  28. #include "bsd-nextstep.h"
  29. pid_t
  30. posix_wait(int *status)
  31. {
  32. union wait statusp;
  33. pid_t wait_pid;
  34. #undef wait /* Use NeXT's wait() function */
  35. wait_pid = wait(&statusp);
  36. if (status)
  37. *status = (int) statusp.w_status;
  38. return (wait_pid);
  39. }
  40. int
  41. tcgetattr(int fd, struct termios *t)
  42. {
  43. return (ioctl(fd, TIOCGETA, t));
  44. }
  45. int
  46. tcsetattr(int fd, int opt, const struct termios *t)
  47. {
  48. struct termios localterm;
  49. if (opt & TCSASOFT) {
  50. localterm = *t;
  51. localterm.c_cflag |= CIGNORE;
  52. t = &localterm;
  53. }
  54. switch (opt & ~TCSASOFT) {
  55. case TCSANOW:
  56. return (ioctl(fd, TIOCSETA, t));
  57. case TCSADRAIN:
  58. return (ioctl(fd, TIOCSETAW, t));
  59. case TCSAFLUSH:
  60. return (ioctl(fd, TIOCSETAF, t));
  61. default:
  62. errno = EINVAL;
  63. return (-1);
  64. }
  65. }
  66. int tcsetpgrp(int fd, pid_t pgrp)
  67. {
  68. return (ioctl(fd, TIOCSPGRP, &pgrp));
  69. }
  70. speed_t cfgetospeed(const struct termios *t)
  71. {
  72. return (t->c_ospeed);
  73. }
  74. speed_t cfgetispeed(const struct termios *t)
  75. {
  76. return (t->c_ispeed);
  77. }
  78. int
  79. cfsetospeed(struct termios *t,int speed)
  80. {
  81. t->c_ospeed = speed;
  82. return (0);
  83. }
  84. int
  85. cfsetispeed(struct termios *t, int speed)
  86. {
  87. t->c_ispeed = speed;
  88. return (0);
  89. }
  90. #endif /* HAVE_NEXT */