diff options
author | Darren Tucker <dtucker@zip.com.au> | 2003-08-13 20:48:07 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2003-08-13 20:48:07 +1000 |
commit | f38ea77c03a5473ec43fe07ec24cfb1ca7f27034 (patch) | |
tree | 9f7f70786068993c2cbe450f110863b841c6b454 /openbsd-compat | |
parent | 1c52ee3e6f2653a474c8a31aafa5a7e595dd8081 (diff) |
- (dtucker) [configure.ac openbsd-compat/bsd-misc.c openbsd-compat/bsd-misc.h]
Add a tcsendbreak function for platforms that don't have one, based on the
one from OpenBSD.
Any more of these and I'll split them out into bsd-termio.[ch].
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/bsd-misc.c | 22 | ||||
-rw-r--r-- | openbsd-compat/bsd-misc.h | 8 |
2 files changed, 27 insertions, 3 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index da8f77046..d4c793724 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | #include "xmalloc.h" | 26 | #include "xmalloc.h" |
27 | 27 | ||
28 | RCSID("$Id: bsd-misc.c,v 1.16 2003/08/02 14:36:16 dtucker Exp $"); | 28 | RCSID("$Id: bsd-misc.c,v 1.17 2003/08/13 10:48:07 dtucker Exp $"); |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * NB. duplicate __progname in case it is an alias for argv[0] | 31 | * NB. duplicate __progname in case it is an alias for argv[0] |
@@ -180,3 +180,23 @@ tcgetpgrp(int fd) | |||
180 | } | 180 | } |
181 | #endif /* HAVE_TCGETPGRP */ | 181 | #endif /* HAVE_TCGETPGRP */ |
182 | 182 | ||
183 | #ifndef HAVE_TCSENDBREAK | ||
184 | int | ||
185 | tcsendbreak(int fd, int duration) | ||
186 | { | ||
187 | # if defined(TIOCSBRK) && defined(TIOCCBRK) | ||
188 | struct timeval sleepytime; | ||
189 | |||
190 | sleepytime.tv_sec = 0; | ||
191 | sleepytime.tv_usec = 400000; | ||
192 | if (ioctl(fd, TIOCSBRK, 0) == -1) | ||
193 | return (-1); | ||
194 | (void)select(0, 0, 0, 0, &sleepytime); | ||
195 | if (ioctl(fd, TIOCCBRK, 0) == -1) | ||
196 | return (-1); | ||
197 | return (0); | ||
198 | # else | ||
199 | return -1; | ||
200 | # endif | ||
201 | } | ||
202 | #endif /* HAVE_TCSENDBREAK */ | ||
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index 03a1f3af0..f2fbdc2e3 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h | |||
@@ -22,7 +22,7 @@ | |||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* $Id: bsd-misc.h,v 1.9 2003/08/02 13:31:42 dtucker Exp $ */ | 25 | /* $Id: bsd-misc.h,v 1.10 2003/08/13 10:48:07 dtucker Exp $ */ |
26 | 26 | ||
27 | #ifndef _BSD_MISC_H | 27 | #ifndef _BSD_MISC_H |
28 | #define _BSD_MISC_H | 28 | #define _BSD_MISC_H |
@@ -91,6 +91,10 @@ int nanosleep(const struct timespec *, struct timespec *); | |||
91 | 91 | ||
92 | #ifndef HAVE_TCGETPGRP | 92 | #ifndef HAVE_TCGETPGRP |
93 | pid_t tcgetpgrp(int); | 93 | pid_t tcgetpgrp(int); |
94 | #endif /* HAVE_TCGETPGRP */ | 94 | #endif |
95 | |||
96 | #ifndef HAVE_TCSENDBREAK | ||
97 | int tcsendbreak(int, int); | ||
98 | #endif | ||
95 | 99 | ||
96 | #endif /* _BSD_MISC_H */ | 100 | #endif /* _BSD_MISC_H */ |