bsd-misc.h revision 263691
1/* $Id: bsd-misc.h,v 1.25 2013/08/04 11:48:41 dtucker Exp $ */
2/* $FreeBSD: head/crypto/openssh/openbsd-compat/bsd-misc.h 263691 2014-03-24 19:15:13Z des $ */
3
4/*
5 * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef _BSD_MISC_H
21#define _BSD_MISC_H
22
23#include "includes.h"
24__RCSID("$FreeBSD: head/crypto/openssh/openbsd-compat/bsd-misc.h 263691 2014-03-24 19:15:13Z des $");
25
26char *ssh_get_progname(char *);
27
28#ifndef HAVE_SETSID
29#define setsid() setpgrp(0, getpid())
30#endif /* !HAVE_SETSID */
31
32#ifndef HAVE_SETENV
33int setenv(const char *, const char *, int);
34#endif /* !HAVE_SETENV */
35
36#ifndef HAVE_SETLOGIN
37int setlogin(const char *);
38#endif /* !HAVE_SETLOGIN */
39
40#ifndef HAVE_INNETGR
41int innetgr(const char *, const char *, const char *, const char *);
42#endif /* HAVE_INNETGR */
43
44#if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
45int seteuid(uid_t);
46#endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */
47
48#if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID)
49int setegid(uid_t);
50#endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */
51
52#if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
53const char *strerror(int);
54#endif
55
56#if !defined(HAVE_SETLINEBUF)
57#define setlinebuf(a)	(setvbuf((a), NULL, _IOLBF, 0))
58#endif
59
60#ifndef HAVE_UTIMES
61#ifndef HAVE_STRUCT_TIMEVAL
62struct timeval {
63	long tv_sec;
64	long tv_usec;
65}
66#endif /* HAVE_STRUCT_TIMEVAL */
67
68int utimes(char *, struct timeval *);
69#endif /* HAVE_UTIMES */
70
71#ifndef HAVE_TRUNCATE
72int truncate (const char *, off_t);
73#endif /* HAVE_TRUNCATE */
74
75#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
76#ifndef HAVE_STRUCT_TIMESPEC
77struct timespec {
78	time_t	tv_sec;
79	long	tv_nsec;
80};
81#endif
82int nanosleep(const struct timespec *, struct timespec *);
83#endif
84
85#ifndef HAVE_USLEEP
86int usleep(unsigned int useconds);
87#endif
88
89#ifndef HAVE_TCGETPGRP
90pid_t tcgetpgrp(int);
91#endif
92
93#ifndef HAVE_TCSENDBREAK
94int tcsendbreak(int, int);
95#endif
96
97#ifndef HAVE_UNSETENV
98int unsetenv(const char *);
99#endif
100
101/* wrapper for signal interface */
102typedef void (*mysig_t)(int);
103mysig_t mysignal(int sig, mysig_t act);
104
105#define signal(a,b) mysignal(a,b)
106
107#ifndef HAVE_ISBLANK
108int	isblank(int);
109#endif
110
111#ifndef HAVE_GETPGID
112pid_t getpgid(pid_t);
113#endif
114
115#ifndef HAVE_ENDGRENT
116# define endgrent() do { } while (0)
117#endif
118
119#ifndef HAVE_KRB5_GET_ERROR_MESSAGE
120# define krb5_get_error_message krb5_get_err_text
121#endif
122
123#ifndef HAVE_KRB5_FREE_ERROR_MESSAGE
124# define krb5_free_error_message(a,b) do { } while(0)
125#endif
126
127#endif /* _BSD_MISC_H */
128