Damien Miller | 0f91b4e | 2000-06-18 15:43:25 +1000 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #ifdef HAVE_NEXT |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <string.h> |
| 7 | #include <errno.h> |
| 8 | #include <unistd.h> |
| 9 | |
| 10 | #include <sys/types.h> |
| 11 | #include <sys/stat.h> |
| 12 | #include <fcntl.h> |
| 13 | |
| 14 | #include <sys/fcntl.h> |
| 15 | #include <sys/ioctl.h> |
| 16 | #include <sys/time.h> |
| 17 | #include <sys/file.h> |
| 18 | #include <errno.h> |
| 19 | #include <termios.h> |
| 20 | #include <sys/wait.h> |
| 21 | #ifdef HAVE_STDDEF_H |
| 22 | #include <stddef.h> |
| 23 | #endif |
| 24 | |
| 25 | #include "xmalloc.h" |
| 26 | #include "ssh.h" |
| 27 | #include "next-posix.h" |
| 28 | |
| 29 | int |
| 30 | waitpid(int pid, int *stat_loc, int options) |
| 31 | { |
| 32 | if (pid <= 0) { |
| 33 | if (pid != -1) { |
| 34 | errno = EINVAL; |
| 35 | return -1; |
| 36 | } |
| 37 | pid = 0; /* wait4() expects pid=0 for indiscriminate wait. */ |
| 38 | } |
| 39 | return wait4(pid, (union wait *)stat_loc, options, NULL); |
| 40 | } |
| 41 | |
| 42 | pid_t setsid(void) |
| 43 | { |
| 44 | return setpgrp(0, getpid()); |
| 45 | } |
| 46 | |
| 47 | int |
| 48 | tcgetattr(int fd, struct termios *t) |
| 49 | { |
| 50 | return (ioctl(fd, TIOCGETA, t)); |
| 51 | } |
| 52 | |
| 53 | int |
| 54 | tcsetattr(int fd, int opt, const struct termios *t) |
| 55 | { |
| 56 | struct termios localterm; |
| 57 | |
| 58 | if (opt & TCSASOFT) { |
| 59 | localterm = *t; |
| 60 | localterm.c_cflag |= CIGNORE; |
| 61 | t = &localterm; |
| 62 | } |
| 63 | switch (opt & ~TCSASOFT) { |
| 64 | case TCSANOW: |
| 65 | return (ioctl(fd, TIOCSETA, t)); |
| 66 | case TCSADRAIN: |
| 67 | return (ioctl(fd, TIOCSETAW, t)); |
| 68 | case TCSAFLUSH: |
| 69 | return (ioctl(fd, TIOCSETAF, t)); |
| 70 | default: |
| 71 | errno = EINVAL; |
| 72 | return (-1); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | int tcsetpgrp(int fd, pid_t pgrp) |
| 77 | { |
| 78 | int s; |
| 79 | |
| 80 | s = pgrp; |
| 81 | return (ioctl(fd, TIOCSPGRP, &s)); |
| 82 | } |
| 83 | |
| 84 | speed_t cfgetospeed(const struct termios *t) |
| 85 | { |
| 86 | return (t->c_ospeed); |
| 87 | } |
| 88 | |
| 89 | speed_t cfgetispeed(const struct termios *t) |
| 90 | { |
| 91 | return (t->c_ispeed); |
| 92 | } |
| 93 | |
| 94 | int |
| 95 | cfsetospeed(struct termios *t,int speed) |
| 96 | { |
| 97 | t->c_ospeed = speed; |
| 98 | return (0); |
| 99 | } |
| 100 | |
| 101 | int |
| 102 | cfsetispeed(struct termios *t, speed_t speed) |
| 103 | { |
| 104 | t->c_ispeed = speed; |
| 105 | return (0); |
| 106 | } |
| 107 | |
| 108 | #if 0 |
| 109 | |
| 110 | /*define sigset_t int*/ |
| 111 | |
| 112 | /* This whole thing is insane. It's purely wrong, but it's a first |
| 113 | go a it. -bl */ |
| 114 | |
| 115 | int sigemptyset(sigset_t *set) |
| 116 | { |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | int sigaddset(sigset_t *set, int signum) |
| 121 | { |
| 122 | *set |= (1 << (signum - 1)); |
| 123 | return set; |
| 124 | } |
| 125 | |
| 126 | int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) |
| 127 | { |
| 128 | switch(how) { |
| 129 | case SIG_BLOCK: |
| 130 | return 0; |
| 131 | case SIG_UNBLOCK: |
| 132 | return ( 0 & ~ *set); |
| 133 | default: |
| 134 | return 0; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | int sigsuspend(const sigset_t *mask) |
| 139 | { |
| 140 | } |
| 141 | |
| 142 | int sigaction(int signum,const struct sigaction *act, struct sigaction *oldact) |
| 143 | { |
| 144 | } |
| 145 | |
| 146 | #endif /* 0 */ |
| 147 | |
| 148 | #endif /* HAVE_NEXT */ |