xref: /freebsd/crypto/openssh/openbsd-compat/bsd-misc.h (revision 3fc36ee018bb836bd1796067cf4ef8683f166ebc)
1 /* $Id: bsd-misc.h,v 1.25 2013/08/04 11:48:41 dtucker Exp $ */
2 
3 /*
4  * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org>
5  *
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.
9  *
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.
17  */
18 
19 #ifndef _BSD_MISC_H
20 #define _BSD_MISC_H
21 
22 #include "includes.h"
23 
24 char *ssh_get_progname(char *);
25 
26 #ifndef HAVE_SETSID
27 #define setsid() setpgrp(0, getpid())
28 #endif /* !HAVE_SETSID */
29 
30 #ifndef HAVE_SETENV
31 int setenv(const char *, const char *, int);
32 #endif /* !HAVE_SETENV */
33 
34 #ifndef HAVE_SETLOGIN
35 int setlogin(const char *);
36 #endif /* !HAVE_SETLOGIN */
37 
38 #ifndef HAVE_INNETGR
39 int innetgr(const char *, const char *, const char *, const char *);
40 #endif /* HAVE_INNETGR */
41 
42 #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
43 int seteuid(uid_t);
44 #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */
45 
46 #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID)
47 int setegid(uid_t);
48 #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */
49 
50 #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
51 const char *strerror(int);
52 #endif
53 
54 #if !defined(HAVE_SETLINEBUF)
55 #define setlinebuf(a)	(setvbuf((a), NULL, _IOLBF, 0))
56 #endif
57 
58 #ifndef HAVE_UTIMES
59 #ifndef HAVE_STRUCT_TIMEVAL
60 struct timeval {
61 	long tv_sec;
62 	long tv_usec;
63 }
64 #endif /* HAVE_STRUCT_TIMEVAL */
65 
66 int utimes(char *, struct timeval *);
67 #endif /* HAVE_UTIMES */
68 
69 #ifndef HAVE_TRUNCATE
70 int truncate (const char *, off_t);
71 #endif /* HAVE_TRUNCATE */
72 
73 #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
74 #ifndef HAVE_STRUCT_TIMESPEC
75 struct timespec {
76 	time_t	tv_sec;
77 	long	tv_nsec;
78 };
79 #endif
80 int nanosleep(const struct timespec *, struct timespec *);
81 #endif
82 
83 #ifndef HAVE_USLEEP
84 int usleep(unsigned int useconds);
85 #endif
86 
87 #ifndef HAVE_TCGETPGRP
88 pid_t tcgetpgrp(int);
89 #endif
90 
91 #ifndef HAVE_TCSENDBREAK
92 int tcsendbreak(int, int);
93 #endif
94 
95 #ifndef HAVE_UNSETENV
96 int unsetenv(const char *);
97 #endif
98 
99 /* wrapper for signal interface */
100 typedef void (*mysig_t)(int);
101 mysig_t mysignal(int sig, mysig_t act);
102 
103 #define signal(a,b) mysignal(a,b)
104 
105 #ifndef HAVE_ISBLANK
106 int	isblank(int);
107 #endif
108 
109 #ifndef HAVE_GETPGID
110 pid_t getpgid(pid_t);
111 #endif
112 
113 #ifndef HAVE_ENDGRENT
114 # define endgrent() do { } while(0)
115 #endif
116 
117 #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) do { } while(0)
123 #endif
124 
125 #ifndef HAVE_PLEDGE
126 int pledge(const char *promises, const char *paths[]);
127 #endif
128 
129 #endif /* _BSD_MISC_H */
130