bsd-misc.h revision 323129
1255767Sdes/* $Id: bsd-misc.h,v 1.25 2013/08/04 11:48:41 dtucker Exp $ */
2124208Sdes
398937Sdes/*
4126274Sdes * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org>
598937Sdes *
6126274Sdes * Permission to use, copy, modify, and distribute this software for any
7126274Sdes * purpose with or without fee is hereby granted, provided that the above
8126274Sdes * copyright notice and this permission notice appear in all copies.
998937Sdes *
10126274Sdes * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11126274Sdes * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12126274Sdes * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13126274Sdes * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14126274Sdes * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15126274Sdes * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16126274Sdes * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1798937Sdes */
1898937Sdes
1998937Sdes#ifndef _BSD_MISC_H
2098937Sdes#define _BSD_MISC_H
2198937Sdes
22124208Sdes#include "includes.h"
2398937Sdes
24124208Sdeschar *ssh_get_progname(char *);
2598937Sdes
2698937Sdes#ifndef HAVE_SETSID
2798937Sdes#define setsid() setpgrp(0, getpid())
2898937Sdes#endif /* !HAVE_SETSID */
2998937Sdes
3098937Sdes#ifndef HAVE_SETENV
31124208Sdesint setenv(const char *, const char *, int);
3298937Sdes#endif /* !HAVE_SETENV */
3398937Sdes
3498937Sdes#ifndef HAVE_SETLOGIN
35124208Sdesint setlogin(const char *);
3698937Sdes#endif /* !HAVE_SETLOGIN */
3798937Sdes
3898937Sdes#ifndef HAVE_INNETGR
39124208Sdesint innetgr(const char *, const char *, const char *, const char *);
4098937Sdes#endif /* HAVE_INNETGR */
4198937Sdes
4298937Sdes#if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
43124208Sdesint seteuid(uid_t);
4498937Sdes#endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */
4598937Sdes
4698937Sdes#if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID)
47124208Sdesint setegid(uid_t);
4898937Sdes#endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */
4998937Sdes
5098937Sdes#if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
51124208Sdesconst char *strerror(int);
5298937Sdes#endif
5398937Sdes
54240075Sdes#if !defined(HAVE_SETLINEBUF)
55240075Sdes#define setlinebuf(a)	(setvbuf((a), NULL, _IOLBF, 0))
56240075Sdes#endif
5798937Sdes
5898937Sdes#ifndef HAVE_UTIMES
5998937Sdes#ifndef HAVE_STRUCT_TIMEVAL
6098937Sdesstruct timeval {
6198937Sdes	long tv_sec;
6298937Sdes	long tv_usec;
6398937Sdes}
6498937Sdes#endif /* HAVE_STRUCT_TIMEVAL */
6598937Sdes
66124208Sdesint utimes(char *, struct timeval *);
6798937Sdes#endif /* HAVE_UTIMES */
6898937Sdes
6998937Sdes#ifndef HAVE_TRUNCATE
70124208Sdesint truncate (const char *, off_t);
7198937Sdes#endif /* HAVE_TRUNCATE */
7298937Sdes
73113908Sdes#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
74113908Sdes#ifndef HAVE_STRUCT_TIMESPEC
75113908Sdesstruct timespec {
76113908Sdes	time_t	tv_sec;
77113908Sdes	long	tv_nsec;
78113908Sdes};
79113908Sdes#endif
80124208Sdesint nanosleep(const struct timespec *, struct timespec *);
81113908Sdes#endif
8298937Sdes
83248619Sdes#ifndef HAVE_USLEEP
84248619Sdesint usleep(unsigned int useconds);
85248619Sdes#endif
86248619Sdes
87124208Sdes#ifndef HAVE_TCGETPGRP
88124208Sdespid_t tcgetpgrp(int);
89124208Sdes#endif
90124208Sdes
91124208Sdes#ifndef HAVE_TCSENDBREAK
92124208Sdesint tcsendbreak(int, int);
93124208Sdes#endif
94124208Sdes
95128456Sdes#ifndef HAVE_UNSETENV
96240075Sdesint unsetenv(const char *);
97128456Sdes#endif
98128456Sdes
99124208Sdes/* wrapper for signal interface */
100124208Sdestypedef void (*mysig_t)(int);
101124208Sdesmysig_t mysignal(int sig, mysig_t act);
102124208Sdes
103124208Sdes#define signal(a,b) mysignal(a,b)
104124208Sdes
105221420Sdes#ifndef HAVE_ISBLANK
106221420Sdesint	isblank(int);
107221420Sdes#endif
108221420Sdes
109248619Sdes#ifndef HAVE_GETPGID
110248619Sdespid_t getpgid(pid_t);
111248619Sdes#endif
112248619Sdes
113255767Sdes#ifndef HAVE_ENDGRENT
114294336Sdes# define endgrent() do { } while(0)
115255767Sdes#endif
116255767Sdes
117255767Sdes#ifndef HAVE_KRB5_GET_ERROR_MESSAGE
118255767Sdes# define krb5_get_error_message krb5_get_err_text
119255767Sdes#endif
120255767Sdes
121255767Sdes#ifndef HAVE_KRB5_FREE_ERROR_MESSAGE
122255767Sdes# define krb5_free_error_message(a,b) do { } while(0)
123255767Sdes#endif
124255767Sdes
125296633Sdes#ifndef HAVE_PLEDGE
126296633Sdesint pledge(const char *promises, const char *paths[]);
127296633Sdes#endif
128296633Sdes
129323129Sdes/* bsd-err.h */
130323129Sdes#ifndef HAVE_ERR
131323129Sdesvoid err(int, const char *, ...) __attribute__((format(printf, 2, 3)));
132323129Sdes#endif
133323129Sdes#ifndef HAVE_ERRX
134323129Sdesvoid errx(int, const char *, ...) __attribute__((format(printf, 2, 3)));
135323129Sdes#endif
136323129Sdes#ifndef HAVE_WARN
137323129Sdesvoid warn(const char *, ...) __attribute__((format(printf, 1, 2)));
138323129Sdes#endif
139323129Sdes
14098937Sdes#endif /* _BSD_MISC_H */
141