unixcompat.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /** \file unixcompat.h
  2. * \brief Header: collects differences between the various Unix
  3. *
  4. * This header file collects differences between the various Unix
  5. * variants that are supported by the Midnight Commander and provides
  6. * replacement routines if they are not natively available.
  7. * The major/minor macros are not specified in SUSv3, so we can only hope
  8. * they are provided by the operating system or emulate it.
  9. */
  10. #ifndef MC_UNIXCOMPAT_H
  11. #define MC_UNIXCOMPAT_H
  12. #include <fcntl.h> /* O_* macros */
  13. #include <signal.h> /* sig_atomic_t */
  14. #include <unistd.h>
  15. #include <sys/types.h> /* BSD */
  16. #ifdef MAJOR_IN_MKDEV
  17. #include <sys/mkdev.h>
  18. #elif defined MAJOR_IN_SYSMACROS
  19. #include <sys/sysmacros.h>
  20. #endif
  21. #if defined(HAVE_STRING_H)
  22. #include <string.h>
  23. /* An ANSI string.h and pre-ANSI memory.h might conflict */
  24. #elif defined(HAVE_MEMORY_H)
  25. #include <memory.h>
  26. #else
  27. #include <strings.h>
  28. /* memory and strings.h conflict on other systems */
  29. #endif /* !STDC_HEADERS & !HAVE_STRING_H */
  30. #if defined(__QNX__) && !defined(__QNXNTO__)
  31. /* exec*() from <process.h> */
  32. #include <unix.h>
  33. #endif
  34. /*** typedefs(not structures) and defined constants **********************************************/
  35. #ifndef major
  36. #warning major() is undefined. Device numbers will not be shown correctly.
  37. #define major(devnum) (((devnum) >> 8) & 0xff)
  38. #endif
  39. #ifndef minor
  40. #warning minor() is undefined. Device numbers will not be shown correctly.
  41. #define minor(devnum) (((devnum) & 0xff))
  42. #endif
  43. #ifndef makedev
  44. #warning makedev() is undefined. Device numbers will not be shown correctly.
  45. #define makedev(major, minor) ((((major) & 0xff) << 8) | ((minor) & 0xff))
  46. #endif
  47. #ifndef STDIN_FILENO
  48. #define STDIN_FILENO 0
  49. #endif
  50. #ifndef STDOUT_FILENO
  51. #define STDOUT_FILENO 1
  52. #endif
  53. #ifndef STDERR_FILENO
  54. #define STDERR_FILENO 2
  55. #endif
  56. /* The O_BINARY definition was taken from gettext */
  57. #if !defined O_BINARY && defined _O_BINARY
  58. /* For MSC-compatible compilers. */
  59. #define O_BINARY _O_BINARY
  60. #endif
  61. #ifdef __BEOS__
  62. /* BeOS 5 has O_BINARY, but it has no effect. */
  63. #undef O_BINARY
  64. #endif
  65. /* On reasonable systems, binary I/O is the default. */
  66. #ifndef O_BINARY
  67. #define O_BINARY 0
  68. #endif
  69. /* Replacement for O_NONBLOCK */
  70. #ifndef O_NONBLOCK
  71. #ifdef O_NDELAY /* SYSV */
  72. #define O_NONBLOCK O_NDELAY
  73. #else /* BSD */
  74. #define O_NONBLOCK FNDELAY
  75. #endif /* !O_NDELAY */
  76. #endif /* !O_NONBLOCK */
  77. /* Solaris9 doesn't have PRIXMAX */
  78. #ifndef PRIXMAX
  79. #define PRIXMAX PRIxMAX
  80. #endif
  81. /* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
  82. #ifdef ESC_CHAR
  83. #undef ESC_CHAR
  84. #endif
  85. /* AIX compiler doesn't understand '\e' */
  86. #define ESC_CHAR '\033'
  87. #define ESC_STR "\033"
  88. /* OS specific defines */
  89. #define PATH_SEP '/'
  90. #define PATH_SEP_STR "/"
  91. #define IS_PATH_SEP(c) ((c) == PATH_SEP)
  92. #define PATH_ENV_SEP ':'
  93. #define TMPDIR_DEFAULT "/tmp"
  94. #define SCRIPT_SUFFIX ""
  95. #define get_default_editor() "vi"
  96. #define OS_SORT_CASE_SENSITIVE_DEFAULT TRUE
  97. /*** enums ***************************************************************************************/
  98. /*** structures declarations (and typedefs of structures)*****************************************/
  99. /*** global variables defined in .c file *********************************************************/
  100. /*** declarations of public functions ************************************************************/
  101. /*** inline functions ****************************************************************************/
  102. #endif