183d2307dSDag-Erling Smørgrav /*
2d95e11bfSDag-Erling Smørgrav * Copyright (c) 2000,2001 Ben Lindstrom. All rights reserved.
3d95e11bfSDag-Erling Smørgrav *
483d2307dSDag-Erling Smørgrav * Redistribution and use in source and binary forms, with or without
583d2307dSDag-Erling Smørgrav * modification, are permitted provided that the following conditions
683d2307dSDag-Erling Smørgrav * are met:
783d2307dSDag-Erling Smørgrav * 1. Redistributions of source code must retain the above copyright
883d2307dSDag-Erling Smørgrav * notice, this list of conditions and the following disclaimer.
983d2307dSDag-Erling Smørgrav * 2. Redistributions in binary form must reproduce the above copyright
1083d2307dSDag-Erling Smørgrav * notice, this list of conditions and the following disclaimer in the
1183d2307dSDag-Erling Smørgrav * documentation and/or other materials provided with the distribution.
1283d2307dSDag-Erling Smørgrav *
1383d2307dSDag-Erling Smørgrav * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1483d2307dSDag-Erling Smørgrav * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1583d2307dSDag-Erling Smørgrav * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1683d2307dSDag-Erling Smørgrav * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1783d2307dSDag-Erling Smørgrav * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1883d2307dSDag-Erling Smørgrav * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1983d2307dSDag-Erling Smørgrav * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2083d2307dSDag-Erling Smørgrav * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2183d2307dSDag-Erling Smørgrav * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2283d2307dSDag-Erling Smørgrav * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2383d2307dSDag-Erling Smørgrav */
2483d2307dSDag-Erling Smørgrav
2583d2307dSDag-Erling Smørgrav #include "includes.h"
2683d2307dSDag-Erling Smørgrav
2783d2307dSDag-Erling Smørgrav #ifdef HAVE_NEXT
2883d2307dSDag-Erling Smørgrav #include <errno.h>
2983d2307dSDag-Erling Smørgrav #include <sys/wait.h>
3083d2307dSDag-Erling Smørgrav #include "bsd-nextstep.h"
3183d2307dSDag-Erling Smørgrav
3283d2307dSDag-Erling Smørgrav pid_t
posix_wait(int * status)3383d2307dSDag-Erling Smørgrav posix_wait(int *status)
3483d2307dSDag-Erling Smørgrav {
3583d2307dSDag-Erling Smørgrav union wait statusp;
3683d2307dSDag-Erling Smørgrav pid_t wait_pid;
3783d2307dSDag-Erling Smørgrav
3883d2307dSDag-Erling Smørgrav #undef wait /* Use NeXT's wait() function */
3983d2307dSDag-Erling Smørgrav wait_pid = wait(&statusp);
4083d2307dSDag-Erling Smørgrav if (status)
4183d2307dSDag-Erling Smørgrav *status = (int) statusp.w_status;
4283d2307dSDag-Erling Smørgrav
43d95e11bfSDag-Erling Smørgrav return (wait_pid);
4483d2307dSDag-Erling Smørgrav }
4583d2307dSDag-Erling Smørgrav
4683d2307dSDag-Erling Smørgrav int
tcgetattr(int fd,struct termios * t)4783d2307dSDag-Erling Smørgrav tcgetattr(int fd, struct termios *t)
4883d2307dSDag-Erling Smørgrav {
4983d2307dSDag-Erling Smørgrav return (ioctl(fd, TIOCGETA, t));
5083d2307dSDag-Erling Smørgrav }
5183d2307dSDag-Erling Smørgrav
5283d2307dSDag-Erling Smørgrav int
tcsetattr(int fd,int opt,const struct termios * t)5383d2307dSDag-Erling Smørgrav tcsetattr(int fd, int opt, const struct termios *t)
5483d2307dSDag-Erling Smørgrav {
5583d2307dSDag-Erling Smørgrav struct termios localterm;
5683d2307dSDag-Erling Smørgrav
5783d2307dSDag-Erling Smørgrav if (opt & TCSASOFT) {
5883d2307dSDag-Erling Smørgrav localterm = *t;
5983d2307dSDag-Erling Smørgrav localterm.c_cflag |= CIGNORE;
6083d2307dSDag-Erling Smørgrav t = &localterm;
6183d2307dSDag-Erling Smørgrav }
6283d2307dSDag-Erling Smørgrav switch (opt & ~TCSASOFT) {
6383d2307dSDag-Erling Smørgrav case TCSANOW:
6483d2307dSDag-Erling Smørgrav return (ioctl(fd, TIOCSETA, t));
6583d2307dSDag-Erling Smørgrav case TCSADRAIN:
6683d2307dSDag-Erling Smørgrav return (ioctl(fd, TIOCSETAW, t));
6783d2307dSDag-Erling Smørgrav case TCSAFLUSH:
6883d2307dSDag-Erling Smørgrav return (ioctl(fd, TIOCSETAF, t));
6983d2307dSDag-Erling Smørgrav default:
7083d2307dSDag-Erling Smørgrav errno = EINVAL;
7183d2307dSDag-Erling Smørgrav return (-1);
7283d2307dSDag-Erling Smørgrav }
7383d2307dSDag-Erling Smørgrav }
7483d2307dSDag-Erling Smørgrav
tcsetpgrp(int fd,pid_t pgrp)7583d2307dSDag-Erling Smørgrav int tcsetpgrp(int fd, pid_t pgrp)
7683d2307dSDag-Erling Smørgrav {
7783d2307dSDag-Erling Smørgrav return (ioctl(fd, TIOCSPGRP, &pgrp));
7883d2307dSDag-Erling Smørgrav }
7983d2307dSDag-Erling Smørgrav
cfgetospeed(const struct termios * t)8083d2307dSDag-Erling Smørgrav speed_t cfgetospeed(const struct termios *t)
8183d2307dSDag-Erling Smørgrav {
8283d2307dSDag-Erling Smørgrav return (t->c_ospeed);
8383d2307dSDag-Erling Smørgrav }
8483d2307dSDag-Erling Smørgrav
cfgetispeed(const struct termios * t)8583d2307dSDag-Erling Smørgrav speed_t cfgetispeed(const struct termios *t)
8683d2307dSDag-Erling Smørgrav {
8783d2307dSDag-Erling Smørgrav return (t->c_ispeed);
8883d2307dSDag-Erling Smørgrav }
8983d2307dSDag-Erling Smørgrav
9083d2307dSDag-Erling Smørgrav int
cfsetospeed(struct termios * t,int speed)9183d2307dSDag-Erling Smørgrav cfsetospeed(struct termios *t,int speed)
9283d2307dSDag-Erling Smørgrav {
9383d2307dSDag-Erling Smørgrav t->c_ospeed = speed;
9483d2307dSDag-Erling Smørgrav return (0);
9583d2307dSDag-Erling Smørgrav }
9683d2307dSDag-Erling Smørgrav
9783d2307dSDag-Erling Smørgrav int
cfsetispeed(struct termios * t,int speed)9883d2307dSDag-Erling Smørgrav cfsetispeed(struct termios *t, int speed)
9983d2307dSDag-Erling Smørgrav {
10083d2307dSDag-Erling Smørgrav t->c_ispeed = speed;
10183d2307dSDag-Erling Smørgrav return (0);
10283d2307dSDag-Erling Smørgrav }
10383d2307dSDag-Erling Smørgrav #endif /* HAVE_NEXT */
104