blob: b61ec42449352e204add4369acdd188961ff656c [file] [log] [blame]
Darren Tucker38049032005-02-26 10:07:37 +11001/* $Id: bsd-misc.h,v 1.18 2005/02/25 23:07:38 dtucker Exp $ */
Ben Lindstrom515d0f92003-08-29 16:59:52 +00002
Damien Millerd4a8b7e1999-10-27 13:42:43 +10003/*
Damien Miller98225c22004-02-17 16:49:41 +11004 * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org>
Damien Miller040f3832000-04-03 14:50:43 +10005 *
Damien Miller98225c22004-02-17 16:49:41 +11006 * 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 Miller040f3832000-04-03 14:50:43 +10009 *
Damien Miller98225c22004-02-17 16:49:41 +110010 * 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 Miller040f3832000-04-03 14:50:43 +100017 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100018
Damien Miller753331e1999-12-30 01:29:35 +110019#ifndef _BSD_MISC_H
20#define _BSD_MISC_H
Damien Millerd4a8b7e1999-10-27 13:42:43 +100021
Ben Lindstrom515d0f92003-08-29 16:59:52 +000022#include "includes.h"
Damien Millere413cba1999-10-28 14:12:54 +100023
Damien Miller59d3d5b2003-08-22 09:34:41 +100024char *ssh_get_progname(char *);
Ben Lindstrom49a79c02000-11-17 03:47:20 +000025
Ben Lindstrom67e21e12000-11-05 09:08:45 +000026#ifndef HAVE_SETSID
27#define setsid() setpgrp(0, getpid())
28#endif /* !HAVE_SETSID */
29
Damien Millerd7702521999-11-22 16:11:05 +110030#ifndef HAVE_SETENV
Damien Miller31741252003-05-19 00:13:38 +100031int setenv(const char *, const char *, int);
Damien Millerd7702521999-11-22 16:11:05 +110032#endif /* !HAVE_SETENV */
33
Damien Millere72b7af1999-12-30 15:08:44 +110034#ifndef HAVE_SETLOGIN
Damien Miller31741252003-05-19 00:13:38 +100035int setlogin(const char *);
Damien Millere72b7af1999-12-30 15:08:44 +110036#endif /* !HAVE_SETLOGIN */
37
38#ifndef HAVE_INNETGR
Damien Miller31741252003-05-19 00:13:38 +100039int innetgr(const char *, const char *, const char *, const char *);
Damien Millere72b7af1999-12-30 15:08:44 +110040#endif /* HAVE_INNETGR */
41
42#if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
Damien Miller31741252003-05-19 00:13:38 +100043int seteuid(uid_t);
Damien Millere72b7af1999-12-30 15:08:44 +110044#endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */
45
Kevin Stevescb17e992001-04-09 14:50:52 +000046#if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID)
Damien Miller31741252003-05-19 00:13:38 +100047int setegid(uid_t);
Kevin Stevescb17e992001-04-09 14:50:52 +000048#endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */
49
Damien Miller11fa2cc2000-08-16 10:35:58 +100050#if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
Damien Miller31741252003-05-19 00:13:38 +100051const char *strerror(int);
Damien Miller11fa2cc2000-08-16 10:35:58 +100052#endif
Damien Millerecbb26d2000-07-15 14:59:14 +100053
Ben Lindstrom42202bc2001-01-15 02:34:37 +000054
55#ifndef HAVE_UTIMES
56#ifndef HAVE_STRUCT_TIMEVAL
57struct timeval {
58 long tv_sec;
59 long tv_usec;
60}
61#endif /* HAVE_STRUCT_TIMEVAL */
62
Damien Miller31741252003-05-19 00:13:38 +100063int utimes(char *, struct timeval *);
Ben Lindstrom42202bc2001-01-15 02:34:37 +000064#endif /* HAVE_UTIMES */
65
Tim Rice4bd2a192002-05-07 19:51:31 -070066#ifndef HAVE_TRUNCATE
Damien Miller31741252003-05-19 00:13:38 +100067int truncate (const char *, off_t);
Tim Rice4bd2a192002-05-07 19:51:31 -070068#endif /* HAVE_TRUNCATE */
Ben Lindstrom42202bc2001-01-15 02:34:37 +000069
Tim Rice4e4dc562003-03-18 10:21:40 -080070#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
71#ifndef HAVE_STRUCT_TIMESPEC
72struct timespec {
73 time_t tv_sec;
74 long tv_nsec;
75};
76#endif
Damien Miller31741252003-05-19 00:13:38 +100077int nanosleep(const struct timespec *, struct timespec *);
Tim Rice4e4dc562003-03-18 10:21:40 -080078#endif
Ben Lindstrom837461b2002-06-12 16:57:14 +000079
Darren Tucker2e9c9cf2003-08-02 23:31:42 +100080#ifndef HAVE_TCGETPGRP
81pid_t tcgetpgrp(int);
Darren Tuckerf38ea772003-08-13 20:48:07 +100082#endif
83
84#ifndef HAVE_TCSENDBREAK
85int tcsendbreak(int, int);
86#endif
Darren Tucker2e9c9cf2003-08-02 23:31:42 +100087
Darren Tucker86c093d2004-03-08 22:59:03 +110088#ifndef HAVE_UNSETENV
89void unsetenv(const char *);
90#endif
91
Ben Lindstrom5ade9ab2003-08-25 01:16:21 +000092/* wrapper for signal interface */
93typedef void (*mysig_t)(int);
94mysig_t mysignal(int sig, mysig_t act);
95
96#define signal(a,b) mysignal(a,b)
97
Damien Miller753331e1999-12-30 01:29:35 +110098#endif /* _BSD_MISC_H */