198937Sdes/* 2124208Sdes * Copyright (c) 2000,2001 Ben Lindstrom. All rights reserved. 3124208Sdes * 498937Sdes * Redistribution and use in source and binary forms, with or without 598937Sdes * modification, are permitted provided that the following conditions 698937Sdes * are met: 798937Sdes * 1. Redistributions of source code must retain the above copyright 898937Sdes * notice, this list of conditions and the following disclaimer. 998937Sdes * 2. Redistributions in binary form must reproduce the above copyright 1098937Sdes * notice, this list of conditions and the following disclaimer in the 1198937Sdes * documentation and/or other materials provided with the distribution. 1298937Sdes * 1398937Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1498937Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1598937Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1698937Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1798937Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1898937Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1998937Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2098937Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2198937Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2298937Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2398937Sdes */ 2498937Sdes 2598937Sdes#include "includes.h" 2698937Sdes 2798937Sdes#ifdef HAVE_NEXT 2898937Sdes#include <errno.h> 2998937Sdes#include <sys/wait.h> 3098937Sdes#include "bsd-nextstep.h" 3198937Sdes 32323134Sdespid_t 3398937Sdesposix_wait(int *status) 3498937Sdes{ 3598937Sdes union wait statusp; 3698937Sdes pid_t wait_pid; 3798937Sdes 3898937Sdes #undef wait /* Use NeXT's wait() function */ 3998937Sdes wait_pid = wait(&statusp); 4098937Sdes if (status) 4198937Sdes *status = (int) statusp.w_status; 4298937Sdes 43124208Sdes return (wait_pid); 4498937Sdes} 4598937Sdes 4698937Sdesint 4798937Sdestcgetattr(int fd, struct termios *t) 4898937Sdes{ 4998937Sdes return (ioctl(fd, TIOCGETA, t)); 5098937Sdes} 5198937Sdes 5298937Sdesint 5398937Sdestcsetattr(int fd, int opt, const struct termios *t) 5498937Sdes{ 5598937Sdes struct termios localterm; 5698937Sdes 5798937Sdes if (opt & TCSASOFT) { 5898937Sdes localterm = *t; 5998937Sdes localterm.c_cflag |= CIGNORE; 6098937Sdes t = &localterm; 6198937Sdes } 6298937Sdes switch (opt & ~TCSASOFT) { 6398937Sdes case TCSANOW: 6498937Sdes return (ioctl(fd, TIOCSETA, t)); 6598937Sdes case TCSADRAIN: 6698937Sdes return (ioctl(fd, TIOCSETAW, t)); 6798937Sdes case TCSAFLUSH: 6898937Sdes return (ioctl(fd, TIOCSETAF, t)); 6998937Sdes default: 7098937Sdes errno = EINVAL; 7198937Sdes return (-1); 7298937Sdes } 7398937Sdes} 7498937Sdes 7598937Sdesint tcsetpgrp(int fd, pid_t pgrp) 7698937Sdes{ 7798937Sdes return (ioctl(fd, TIOCSPGRP, &pgrp)); 7898937Sdes} 7998937Sdes 8098937Sdesspeed_t cfgetospeed(const struct termios *t) 8198937Sdes{ 8298937Sdes return (t->c_ospeed); 8398937Sdes} 8498937Sdes 8598937Sdesspeed_t cfgetispeed(const struct termios *t) 8698937Sdes{ 8798937Sdes return (t->c_ispeed); 8898937Sdes} 8998937Sdes 9098937Sdesint 9198937Sdescfsetospeed(struct termios *t,int speed) 9298937Sdes{ 9398937Sdes t->c_ospeed = speed; 9498937Sdes return (0); 9598937Sdes} 9698937Sdes 9798937Sdesint 9898937Sdescfsetispeed(struct termios *t, int speed) 9998937Sdes{ 10098937Sdes t->c_ispeed = speed; 10198937Sdes return (0); 10298937Sdes} 10398937Sdes#endif /* HAVE_NEXT */ 104