Grid Community Toolkit  6.2.1705709074 (tag: v6.2.20240202)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bsd-misc.h
1 /*
2  * Copyright (c) 1999-2004 Damien Miller <[email protected]>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _BSD_MISC_H
18 #define _BSD_MISC_H
19 
20 #include "includes.h"
21 
22 char *ssh_get_progname(char *);
23 int seed_from_prngd(unsigned char *, size_t);
24 
25 #ifndef HAVE_SETSID
26 #define setsid() setpgrp(0, getpid())
27 #endif /* !HAVE_SETSID */
28 
29 #ifndef HAVE_SETENV
30 int setenv(const char *, const char *, int);
31 #endif /* !HAVE_SETENV */
32 
33 #ifndef HAVE_SETLOGIN
34 int setlogin(const char *);
35 #endif /* !HAVE_SETLOGIN */
36 
37 #ifndef HAVE_INNETGR
38 int innetgr(const char *, const char *, const char *, const char *);
39 #endif /* HAVE_INNETGR */
40 
41 #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
42 int seteuid(uid_t);
43 #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */
44 
45 #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID)
46 int setegid(uid_t);
47 #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */
48 
49 #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
50 const char *strerror(int);
51 #endif
52 
53 #if !defined(HAVE_SETLINEBUF)
54 #define setlinebuf(a) (setvbuf((a), NULL, _IOLBF, 0))
55 #endif
56 
57 #ifndef HAVE_UTIMES
58 #ifndef HAVE_STRUCT_TIMEVAL
59 struct timeval {
60  long tv_sec;
61  long tv_usec;
62 }
63 #endif /* HAVE_STRUCT_TIMEVAL */
64 
65 int utimes(const char *, struct timeval *);
66 #endif /* HAVE_UTIMES */
67 
68 #ifndef AT_FDCWD
69 # define AT_FDCWD (-2)
70 #endif
71 
72 #ifndef HAVE_FCHMODAT
73 int fchmodat(int, const char *, mode_t, int);
74 #endif
75 
76 #ifndef HAVE_FCHOWNAT
77 int fchownat(int, const char *, uid_t, gid_t, int);
78 #endif
79 
80 #ifndef HAVE_TRUNCATE
81 int truncate (const char *, off_t);
82 #endif /* HAVE_TRUNCATE */
83 
84 #ifndef HAVE_STRUCT_TIMESPEC
85 struct timespec {
86  time_t tv_sec;
87  long tv_nsec;
88 };
89 #endif /* !HAVE_STRUCT_TIMESPEC */
90 
91 #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
92 # include <time.h>
93 int nanosleep(const struct timespec *, struct timespec *);
94 #endif
95 
96 #ifndef HAVE_UTIMENSAT
97 # include <time.h>
98 /* start with the high bits and work down to minimise risk of overlap */
99 # ifndef AT_SYMLINK_NOFOLLOW
100 # define AT_SYMLINK_NOFOLLOW 0x80000000
101 # endif
102 int utimensat(int, const char *, const struct timespec[2], int);
103 #endif /* !HAVE_UTIMENSAT */
104 
105 #ifndef HAVE_USLEEP
106 int usleep(unsigned int useconds);
107 #endif
108 
109 #ifndef HAVE_TCGETPGRP
110 pid_t tcgetpgrp(int);
111 #endif
112 
113 #ifndef HAVE_TCSENDBREAK
114 int tcsendbreak(int, int);
115 #endif
116 
117 #ifndef HAVE_UNSETENV
118 int unsetenv(const char *);
119 #endif
120 
121 #ifndef HAVE_ISBLANK
122 int isblank(int);
123 #endif
124 
125 #ifndef HAVE_GETPGID
126 pid_t getpgid(pid_t);
127 #endif
128 
129 #ifndef HAVE_PSELECT
130 int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
131  const sigset_t *);
132 #endif
133 
134 #ifndef HAVE_ENDGRENT
135 # define endgrent() do { } while(0)
136 #endif
137 
138 #ifndef HAVE_KRB5_GET_ERROR_MESSAGE
139 # define krb5_get_error_message krb5_get_err_text
140 #endif
141 
142 #ifndef HAVE_KRB5_FREE_ERROR_MESSAGE
143 # define krb5_free_error_message(a,b) do { } while(0)
144 #endif
145 
146 #ifndef HAVE_PLEDGE
147 int pledge(const char *promises, const char *paths[]);
148 #endif
149 
150 /* bsd-err.h */
151 #ifndef HAVE_ERR
152 void err(int, const char *, ...) __attribute__((format(printf, 2, 3)));
153 #endif
154 #ifndef HAVE_ERRX
155 void errx(int, const char *, ...) __attribute__((format(printf, 2, 3)));
156 #endif
157 #ifndef HAVE_WARN
158 void warn(const char *, ...) __attribute__((format(printf, 1, 2)));
159 #endif
160 
161 #ifndef HAVE_LLABS
162 long long llabs(long long);
163 #endif
164 
165 #if defined(HAVE_DECL_BZERO) && HAVE_DECL_BZERO == 0
166 void bzero(void *, size_t);
167 #endif
168 
169 #ifndef HAVE_RAISE
170 int raise(int);
171 #endif
172 
173 #ifndef HAVE_GETSID
174 pid_t getsid(pid_t);
175 #endif
176 
177 #ifndef HAVE_FLOCK
178 # define LOCK_SH 0x01
179 # define LOCK_EX 0x02
180 # define LOCK_NB 0x04
181 # define LOCK_UN 0x08
182 int flock(int, int);
183 #endif
184 
185 #ifdef FFLUSH_NULL_BUG
186 # define fflush(x) (_ssh_compat_fflush(x))
187 #endif
188 
189 #ifndef HAVE_LOCALTIME_R
190 struct tm *localtime_r(const time_t *, struct tm *);
191 #endif
192 
193 #ifndef HAVE_REALPATH
194 #define realpath(x, y) (sftp_realpath((x), (y)))
195 #endif
196 
197 #endif /* _BSD_MISC_H */