1 /* 2 * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org> 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 24 #ifndef HAVE_SETSID 25 #define setsid() setpgrp(0, getpid()) 26 #endif /* !HAVE_SETSID */ 27 28 #ifndef HAVE_SETENV 29 int setenv(const char *, const char *, int); 30 #endif /* !HAVE_SETENV */ 31 32 #ifndef HAVE_SETLOGIN 33 int setlogin(const char *); 34 #endif /* !HAVE_SETLOGIN */ 35 36 #ifndef HAVE_INNETGR 37 int innetgr(const char *, const char *, const char *, const char *); 38 #endif /* HAVE_INNETGR */ 39 40 #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) 41 int seteuid(uid_t); 42 #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ 43 44 #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) 45 int setegid(uid_t); 46 #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ 47 48 #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) 49 const char *strerror(int); 50 #endif 51 52 #if !defined(HAVE_SETLINEBUF) 53 #define setlinebuf(a) (setvbuf((a), NULL, _IOLBF, 0)) 54 #endif 55 56 #ifndef HAVE_UTIMES 57 #ifndef HAVE_STRUCT_TIMEVAL 58 struct timeval { 59 long tv_sec; 60 long tv_usec; 61 } 62 #endif /* HAVE_STRUCT_TIMEVAL */ 63 64 int utimes(char *, struct timeval *); 65 #endif /* HAVE_UTIMES */ 66 67 #ifndef HAVE_TRUNCATE 68 int truncate (const char *, off_t); 69 #endif /* HAVE_TRUNCATE */ 70 71 #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) 72 #ifndef HAVE_STRUCT_TIMESPEC 73 struct timespec { 74 time_t tv_sec; 75 long tv_nsec; 76 }; 77 #endif 78 int nanosleep(const struct timespec *, struct timespec *); 79 #endif 80 81 #ifndef HAVE_USLEEP 82 int usleep(unsigned int useconds); 83 #endif 84 85 #ifndef HAVE_TCGETPGRP 86 pid_t tcgetpgrp(int); 87 #endif 88 89 #ifndef HAVE_TCSENDBREAK 90 int tcsendbreak(int, int); 91 #endif 92 93 #ifndef HAVE_UNSETENV 94 int unsetenv(const char *); 95 #endif 96 97 /* wrapper for signal interface */ 98 typedef void (*mysig_t)(int); 99 mysig_t mysignal(int sig, mysig_t act); 100 101 #define signal(a,b) mysignal(a,b) 102 103 #ifndef HAVE_ISBLANK 104 int isblank(int); 105 #endif 106 107 #ifndef HAVE_GETPGID 108 pid_t getpgid(pid_t); 109 #endif 110 111 #ifndef HAVE_ENDGRENT 112 # define endgrent() do { } while(0) 113 #endif 114 115 #ifndef HAVE_KRB5_GET_ERROR_MESSAGE 116 # define krb5_get_error_message krb5_get_err_text 117 #endif 118 119 #ifndef HAVE_KRB5_FREE_ERROR_MESSAGE 120 # define krb5_free_error_message(a,b) do { } while(0) 121 #endif 122 123 #ifndef HAVE_PLEDGE 124 int pledge(const char *promises, const char *paths[]); 125 #endif 126 127 /* bsd-err.h */ 128 #ifndef HAVE_ERR 129 void err(int, const char *, ...) __attribute__((format(printf, 2, 3))); 130 #endif 131 #ifndef HAVE_ERRX 132 void errx(int, const char *, ...) __attribute__((format(printf, 2, 3))); 133 #endif 134 #ifndef HAVE_WARN 135 void warn(const char *, ...) __attribute__((format(printf, 1, 2))); 136 #endif 137 138 #endif /* _BSD_MISC_H */ 139