blob: 65c18ec2f061556b9d6750dc9778b1079aedb2f9 [file] [log] [blame]
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10001/* $Id: bsd-misc.h,v 1.25 2013/08/04 11:48:41 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
Darren Tucker34f702a2012-07-04 08:50:09 +100054#if !defined(HAVE_SETLINEBUF)
55#define setlinebuf(a) (setvbuf((a), NULL, _IOLBF, 0))
56#endif
Ben Lindstrom42202bc2001-01-15 02:34:37 +000057
58#ifndef HAVE_UTIMES
59#ifndef HAVE_STRUCT_TIMEVAL
60struct timeval {
61 long tv_sec;
62 long tv_usec;
63}
64#endif /* HAVE_STRUCT_TIMEVAL */
65
Damien Miller31741252003-05-19 00:13:38 +100066int utimes(char *, struct timeval *);
Ben Lindstrom42202bc2001-01-15 02:34:37 +000067#endif /* HAVE_UTIMES */
68
Tim Rice4bd2a192002-05-07 19:51:31 -070069#ifndef HAVE_TRUNCATE
Damien Miller31741252003-05-19 00:13:38 +100070int truncate (const char *, off_t);
Tim Rice4bd2a192002-05-07 19:51:31 -070071#endif /* HAVE_TRUNCATE */
Ben Lindstrom42202bc2001-01-15 02:34:37 +000072
Tim Rice4e4dc562003-03-18 10:21:40 -080073#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
74#ifndef HAVE_STRUCT_TIMESPEC
75struct timespec {
76 time_t tv_sec;
77 long tv_nsec;
78};
79#endif
Damien Miller31741252003-05-19 00:13:38 +100080int nanosleep(const struct timespec *, struct timespec *);
Tim Rice4e4dc562003-03-18 10:21:40 -080081#endif
Ben Lindstrom837461b2002-06-12 16:57:14 +000082
Damien Millerf4db77d2013-03-15 10:34:25 +110083#ifndef HAVE_USLEEP
84int usleep(unsigned int useconds);
85#endif
86
Darren Tucker2e9c9cf2003-08-02 23:31:42 +100087#ifndef HAVE_TCGETPGRP
88pid_t tcgetpgrp(int);
Darren Tuckerf38ea772003-08-13 20:48:07 +100089#endif
90
91#ifndef HAVE_TCSENDBREAK
92int tcsendbreak(int, int);
93#endif
Darren Tucker2e9c9cf2003-08-02 23:31:42 +100094
Darren Tucker86c093d2004-03-08 22:59:03 +110095#ifndef HAVE_UNSETENV
Tim Ricee3609c92012-02-14 10:03:30 -080096int unsetenv(const char *);
Darren Tucker86c093d2004-03-08 22:59:03 +110097#endif
98
Ben Lindstrom5ade9ab2003-08-25 01:16:21 +000099/* wrapper for signal interface */
100typedef void (*mysig_t)(int);
101mysig_t mysignal(int sig, mysig_t act);
102
103#define signal(a,b) mysignal(a,b)
104
Tim Ricec7a8af02010-11-08 14:26:23 -0800105#ifndef HAVE_ISBLANK
106int isblank(int);
107#endif
108
Darren Tucker3c4a24c2013-02-15 11:41:35 +1100109#ifndef HAVE_GETPGID
110pid_t getpgid(pid_t);
111#endif
112
Darren Tuckerefdf5342013-05-30 08:29:08 +1000113#ifndef HAVE_ENDGRENT
114# define endgrent() {}
115#endif
116
Darren Tuckerf3ab2c52013-08-04 21:48:41 +1000117#ifndef HAVE_KRB5_GET_ERROR_MESSAGE
118# define krb5_get_error_message krb5_get_err_text
119#endif
120
121#ifndef HAVE_KRB5_FREE_ERROR_MESSAGE
122# define krb5_free_error_message(a,b) while(0)
123#endif
124
Damien Miller753331e1999-12-30 01:29:35 +1100125#endif /* _BSD_MISC_H */