Darren Tucker | 3804903 | 2005-02-26 10:07:37 +1100 | [diff] [blame] | 1 | /* $Id: bsd-misc.h,v 1.18 2005/02/25 23:07:38 dtucker Exp $ */ |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 2 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 3 | /* |
Damien Miller | 98225c2 | 2004-02-17 16:49:41 +1100 | [diff] [blame] | 4 | * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org> |
Damien Miller | 040f383 | 2000-04-03 14:50:43 +1000 | [diff] [blame] | 5 | * |
Damien Miller | 98225c2 | 2004-02-17 16:49:41 +1100 | [diff] [blame] | 6 | * Permission to use, copy, modify, and distribute this software for any |
| 7 | * purpose with or without fee is hereby granted, provided that the above |
| 8 | * copyright notice and this permission notice appear in all copies. |
Damien Miller | 040f383 | 2000-04-03 14:50:43 +1000 | [diff] [blame] | 9 | * |
Damien Miller | 98225c2 | 2004-02-17 16:49:41 +1100 | [diff] [blame] | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Damien Miller | 040f383 | 2000-04-03 14:50:43 +1000 | [diff] [blame] | 17 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 18 | |
Damien Miller | 753331e | 1999-12-30 01:29:35 +1100 | [diff] [blame] | 19 | #ifndef _BSD_MISC_H |
| 20 | #define _BSD_MISC_H |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 21 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 22 | #include "includes.h" |
Damien Miller | e413cba | 1999-10-28 14:12:54 +1000 | [diff] [blame] | 23 | |
Damien Miller | 59d3d5b | 2003-08-22 09:34:41 +1000 | [diff] [blame] | 24 | char *ssh_get_progname(char *); |
Ben Lindstrom | 49a79c0 | 2000-11-17 03:47:20 +0000 | [diff] [blame] | 25 | |
Ben Lindstrom | 67e21e1 | 2000-11-05 09:08:45 +0000 | [diff] [blame] | 26 | #ifndef HAVE_SETSID |
| 27 | #define setsid() setpgrp(0, getpid()) |
| 28 | #endif /* !HAVE_SETSID */ |
| 29 | |
Damien Miller | d770252 | 1999-11-22 16:11:05 +1100 | [diff] [blame] | 30 | #ifndef HAVE_SETENV |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 31 | int setenv(const char *, const char *, int); |
Damien Miller | d770252 | 1999-11-22 16:11:05 +1100 | [diff] [blame] | 32 | #endif /* !HAVE_SETENV */ |
| 33 | |
Damien Miller | e72b7af | 1999-12-30 15:08:44 +1100 | [diff] [blame] | 34 | #ifndef HAVE_SETLOGIN |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 35 | int setlogin(const char *); |
Damien Miller | e72b7af | 1999-12-30 15:08:44 +1100 | [diff] [blame] | 36 | #endif /* !HAVE_SETLOGIN */ |
| 37 | |
| 38 | #ifndef HAVE_INNETGR |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 39 | int innetgr(const char *, const char *, const char *, const char *); |
Damien Miller | e72b7af | 1999-12-30 15:08:44 +1100 | [diff] [blame] | 40 | #endif /* HAVE_INNETGR */ |
| 41 | |
| 42 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 43 | int seteuid(uid_t); |
Damien Miller | e72b7af | 1999-12-30 15:08:44 +1100 | [diff] [blame] | 44 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ |
| 45 | |
Kevin Steves | cb17e99 | 2001-04-09 14:50:52 +0000 | [diff] [blame] | 46 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 47 | int setegid(uid_t); |
Kevin Steves | cb17e99 | 2001-04-09 14:50:52 +0000 | [diff] [blame] | 48 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ |
| 49 | |
Damien Miller | 11fa2cc | 2000-08-16 10:35:58 +1000 | [diff] [blame] | 50 | #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 51 | const char *strerror(int); |
Damien Miller | 11fa2cc | 2000-08-16 10:35:58 +1000 | [diff] [blame] | 52 | #endif |
Damien Miller | ecbb26d | 2000-07-15 14:59:14 +1000 | [diff] [blame] | 53 | |
Ben Lindstrom | 42202bc | 2001-01-15 02:34:37 +0000 | [diff] [blame] | 54 | |
| 55 | #ifndef HAVE_UTIMES |
| 56 | #ifndef HAVE_STRUCT_TIMEVAL |
| 57 | struct timeval { |
| 58 | long tv_sec; |
| 59 | long tv_usec; |
| 60 | } |
| 61 | #endif /* HAVE_STRUCT_TIMEVAL */ |
| 62 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 63 | int utimes(char *, struct timeval *); |
Ben Lindstrom | 42202bc | 2001-01-15 02:34:37 +0000 | [diff] [blame] | 64 | #endif /* HAVE_UTIMES */ |
| 65 | |
Tim Rice | 4bd2a19 | 2002-05-07 19:51:31 -0700 | [diff] [blame] | 66 | #ifndef HAVE_TRUNCATE |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 67 | int truncate (const char *, off_t); |
Tim Rice | 4bd2a19 | 2002-05-07 19:51:31 -0700 | [diff] [blame] | 68 | #endif /* HAVE_TRUNCATE */ |
Ben Lindstrom | 42202bc | 2001-01-15 02:34:37 +0000 | [diff] [blame] | 69 | |
Tim Rice | 4e4dc56 | 2003-03-18 10:21:40 -0800 | [diff] [blame] | 70 | #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) |
| 71 | #ifndef HAVE_STRUCT_TIMESPEC |
| 72 | struct timespec { |
| 73 | time_t tv_sec; |
| 74 | long tv_nsec; |
| 75 | }; |
| 76 | #endif |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 77 | int nanosleep(const struct timespec *, struct timespec *); |
Tim Rice | 4e4dc56 | 2003-03-18 10:21:40 -0800 | [diff] [blame] | 78 | #endif |
Ben Lindstrom | 837461b | 2002-06-12 16:57:14 +0000 | [diff] [blame] | 79 | |
Darren Tucker | 2e9c9cf | 2003-08-02 23:31:42 +1000 | [diff] [blame] | 80 | #ifndef HAVE_TCGETPGRP |
| 81 | pid_t tcgetpgrp(int); |
Darren Tucker | f38ea77 | 2003-08-13 20:48:07 +1000 | [diff] [blame] | 82 | #endif |
| 83 | |
| 84 | #ifndef HAVE_TCSENDBREAK |
| 85 | int tcsendbreak(int, int); |
| 86 | #endif |
Darren Tucker | 2e9c9cf | 2003-08-02 23:31:42 +1000 | [diff] [blame] | 87 | |
Darren Tucker | 86c093d | 2004-03-08 22:59:03 +1100 | [diff] [blame] | 88 | #ifndef HAVE_UNSETENV |
| 89 | void unsetenv(const char *); |
| 90 | #endif |
| 91 | |
Ben Lindstrom | 5ade9ab | 2003-08-25 01:16:21 +0000 | [diff] [blame] | 92 | /* wrapper for signal interface */ |
| 93 | typedef void (*mysig_t)(int); |
| 94 | mysig_t mysignal(int sig, mysig_t act); |
| 95 | |
| 96 | #define signal(a,b) mysignal(a,b) |
| 97 | |
Damien Miller | 753331e | 1999-12-30 01:29:35 +1100 | [diff] [blame] | 98 | #endif /* _BSD_MISC_H */ |