bsd-misc.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. #ifndef _BSD_MISC_H
  17. #define _BSD_MISC_H
  18. #include "includes.h"
  19. char *ssh_get_progname(char *);
  20. #ifndef HAVE_SETSID
  21. #define setsid() setpgrp(0, getpid())
  22. #endif /* !HAVE_SETSID */
  23. #ifndef HAVE_SETENV
  24. int setenv(const char *, const char *, int);
  25. #endif /* !HAVE_SETENV */
  26. #ifndef HAVE_SETLOGIN
  27. int setlogin(const char *);
  28. #endif /* !HAVE_SETLOGIN */
  29. #ifndef HAVE_INNETGR
  30. int innetgr(const char *, const char *, const char *, const char *);
  31. #endif /* HAVE_INNETGR */
  32. #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
  33. int seteuid(uid_t);
  34. #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */
  35. #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID)
  36. int setegid(uid_t);
  37. #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */
  38. #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
  39. const char *strerror(int);
  40. #endif
  41. #if !defined(HAVE_SETLINEBUF)
  42. #define setlinebuf(a) (setvbuf((a), NULL, _IOLBF, 0))
  43. #endif
  44. #ifndef HAVE_UTIMES
  45. #ifndef HAVE_STRUCT_TIMEVAL
  46. struct timeval {
  47. long tv_sec;
  48. long tv_usec;
  49. }
  50. #endif /* HAVE_STRUCT_TIMEVAL */
  51. int utimes(char *, struct timeval *);
  52. #endif /* HAVE_UTIMES */
  53. #ifndef AT_FDCWD
  54. # define AT_FDCWD (-2)
  55. #endif
  56. #ifndef HAVE_FCHMODAT
  57. int fchmodat(int, const char *, mode_t, int);
  58. #endif
  59. #ifndef HAVE_FCHOWNAT
  60. int fchownat(int, const char *, uid_t, gid_t, int);
  61. #endif
  62. #ifndef HAVE_TRUNCATE
  63. int truncate (const char *, off_t);
  64. #endif /* HAVE_TRUNCATE */
  65. #ifndef HAVE_STRUCT_TIMESPEC
  66. struct timespec {
  67. time_t tv_sec;
  68. long tv_nsec;
  69. };
  70. #endif /* !HAVE_STRUCT_TIMESPEC */
  71. #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
  72. # include <time.h>
  73. int nanosleep(const struct timespec *, struct timespec *);
  74. #endif
  75. #ifndef HAVE_UTIMENSAT
  76. # include <time.h>
  77. /* start with the high bits and work down to minimise risk of overlap */
  78. # ifndef AT_SYMLINK_NOFOLLOW
  79. # define AT_SYMLINK_NOFOLLOW 0x80000000
  80. # endif
  81. int utimensat(int, const char *, const struct timespec[2], int);
  82. #endif /* !HAVE_UTIMENSAT */
  83. #ifndef HAVE_USLEEP
  84. int usleep(unsigned int useconds);
  85. #endif
  86. #ifndef HAVE_TCGETPGRP
  87. pid_t tcgetpgrp(int);
  88. #endif
  89. #ifndef HAVE_TCSENDBREAK
  90. int tcsendbreak(int, int);
  91. #endif
  92. #ifndef HAVE_UNSETENV
  93. int unsetenv(const char *);
  94. #endif
  95. #ifndef HAVE_ISBLANK
  96. int isblank(int);
  97. #endif
  98. #ifndef HAVE_GETPGID
  99. pid_t getpgid(pid_t);
  100. #endif
  101. #ifndef HAVE_ENDGRENT
  102. # define endgrent() do { } while(0)
  103. #endif
  104. #ifndef HAVE_KRB5_GET_ERROR_MESSAGE
  105. # define krb5_get_error_message krb5_get_err_text
  106. #endif
  107. #ifndef HAVE_KRB5_FREE_ERROR_MESSAGE
  108. # define krb5_free_error_message(a,b) do { } while(0)
  109. #endif
  110. #ifndef HAVE_PLEDGE
  111. int pledge(const char *promises, const char *paths[]);
  112. #endif
  113. /* bsd-err.h */
  114. #ifndef HAVE_ERR
  115. void err(int, const char *, ...) __attribute__((format(printf, 2, 3)));
  116. #endif
  117. #ifndef HAVE_ERRX
  118. void errx(int, const char *, ...) __attribute__((format(printf, 2, 3)));
  119. #endif
  120. #ifndef HAVE_WARN
  121. void warn(const char *, ...) __attribute__((format(printf, 1, 2)));
  122. #endif
  123. #ifndef HAVE_LLABS
  124. long long llabs(long long);
  125. #endif
  126. #if defined(HAVE_DECL_BZERO) && HAVE_DECL_BZERO == 0
  127. void bzero(void *, size_t);
  128. #endif
  129. #ifndef HAVE_RAISE
  130. int raise(int);
  131. #endif
  132. #ifndef HAVE_GETSID
  133. pid_t getsid(pid_t);
  134. #endif
  135. #ifndef HAVE_FLOCK
  136. # define LOCK_SH 0x01
  137. # define LOCK_EX 0x02
  138. # define LOCK_NB 0x04
  139. # define LOCK_UN 0x08
  140. int flock(int, int);
  141. #endif
  142. #ifdef FFLUSH_NULL_BUG
  143. # define fflush(x) (_ssh_compat_fflush(x))
  144. #endif
  145. #ifndef HAVE_LOCALTIME_R
  146. struct tm *localtime_r(const time_t *, struct tm *);
  147. #endif
  148. #ifndef HAVE_REALPATH
  149. #define realpath(x, y) (sftp_realpath((x), (y)))
  150. #endif
  151. #endif /* _BSD_MISC_H */