home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / MN321SRC.ZIP / os.h < prev    next >
C/C++ Source or Header  |  2004-07-19  |  4KB  |  151 lines

  1. /* $Id: os.h,v 1.6 2004/07/18 10:51:37 ozzmosis Exp $ */
  2.  
  3. #ifndef _OS_H
  4. #define _OS_H
  5.  
  6. /* Operating system and compiler dependant functions */
  7. /* Definitions for:                                               */
  8. /* __GNUC__     GNU C Compiler                                    */
  9. /* __EMX__      emx for DOS/OS2                                   */
  10. /* __WATCOMC__  Watcom C Compiler 10.0b under DOS, OS/2 and Win32 */
  11. /* __TURBOC__   Turbo C 2.00 and above, Borland C, under DOS      */
  12.  
  13. /* Operating systems/memory model:
  14.    __FLAT__   32-bit flat memory model
  15.    __SMALL__  DOS small memory model
  16.    __MSDOS__  DOS 16 or 32-bit
  17.    __DOS16__  DOS 16-bit
  18.    __DOS32__  DOS 32-bit (currently: dos4gw for Watcom)
  19.    __EMX__    emx+gcc (32-bit dual executable DOS/OS2)
  20.    __OS2__    OS/2 2.0 and above
  21.    __W32__    Win32 (Win9x/NT)
  22.  */
  23.  
  24. #ifdef __GNUC__
  25. #define __FLAT__                /* flat memory model, min. 32-bit */
  26. #endif
  27.  
  28. #ifndef max
  29. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  30. #endif
  31. #ifndef min
  32. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  33. #endif
  34.  
  35. /* Defaults for overwriteable functions */
  36. #define OSAPS "osgenaps.c"
  37. #define OSRMS "osgenrms.c"
  38. #define OSCAN "osgencan.c"
  39. #define OSDSL "osgendsl.c"
  40. #define OSEXC "osgenexc.c"
  41. #define OSFF "osgenff.c"
  42. #define OSFLD "osgenfld.c"
  43. #define OSGTN "osgengtn.c"
  44.  
  45.  
  46. /* GNU C/EMX for DOS & OS/2 */
  47. #if defined(__GNUC__) && defined(__EMX__)
  48. #include "osgnuemx.h"
  49.  
  50. /* GNU C/Linux */
  51. #elif defined(__GNUC__) && defined(__linux__)
  52. #include "osgnulnx.h"
  53.  
  54. /* GNU C/FreeBSD */
  55. #elif defined(__GNUC__) && defined(__FreeBSD__)
  56. /* we'll use the Linux ones */
  57. #include "osgnulnx.h"
  58.  
  59. /* GNU C/DJGPP 2.0 for DOS */
  60. #elif defined(__GNUC__) && defined(__MSDOS__)
  61. #include "osgnudjg.h"
  62.  
  63. /* GNU C/Dev-C++ for Windows */
  64. #elif defined(__GNUC__) && defined(__MINGW32__)
  65. /* use Microsoft Visual C++ headers */
  66. #include "osmscwin.h"
  67.  
  68. /* Borland Turbo C++ 1.0, Borland C++ 3.1 & 4.0, etc. for DOS */
  69. #elif defined(__TURBOC__) && defined(__MSDOS__)
  70. #include "ostbcdos.h"
  71.  
  72. /* Watcom C/C++ for DOS, OS/2 & Windows */
  73. #elif defined(__WATCOMC__)
  74. #include "oswatxxx.h"
  75.  
  76. /* Microsoft Visual C++ for Windows */
  77. #elif defined(_MSC_VER) && defined(WIN32)
  78. #include "osmscwin.h"
  79.  
  80. #else
  81. #error "It seems to me that you are using an unknown compiler!"
  82. #endif
  83.  
  84.  
  85. #ifndef STR_DIRSEPARATOR
  86. #error "No one defined STR_DIRSEPARATOR!"
  87. #else
  88. #define CHAR_DIRSEPARATOR STR_DIRSEPARATOR[0]
  89. #endif
  90.  
  91. /* ------------------------------------------------------------------------- */
  92. /* os-independant global function declarations                               */
  93.  
  94. char *os_findfirst(struct _filefind *pff, const char *path,
  95.                    const char *mask);
  96. char *os_findnext(struct _filefind *pff);
  97. void os_findclose(struct _filefind *pff);
  98. char *os_findfile(struct _filefind *pff, const char *path,
  99.                   const char *mask);
  100.  
  101. char *os_file_getname(const char *path);
  102. int os_fullpath(char *dst, const char *src, size_t bufsiz);
  103. int os_fulldir(char *dst, const char *src, size_t bufsiz);
  104. char *os_getcwd(char *buffer, int size);
  105. char *os_append_slash(char *path);
  106. char *os_remove_slash(char *path);
  107. char *os_deslashify(char *name);
  108. char *os_filecanonify(char *s);
  109.  
  110. int os_spawn(const char *command, const char *cmdline);
  111.  
  112. #ifndef USE_OWN_GETCWD
  113. #define os_getcwd getcwd
  114. #endif
  115.  
  116.  
  117. #ifdef USE_OWN_FGETS
  118. #include <stdio.h>
  119. char *os_fgets(char *buf, size_t len, FILE * f);
  120. #define fgets os_fgets
  121.  
  122. #endif
  123.  
  124. #ifndef HAVE_STRUPR
  125. char *strupr(char *string);
  126. #endif
  127.  
  128.  
  129. /* some sanity checks for compiler defines */
  130.  
  131. /* The GNUC-Check was thrown out. There can be GNU C with MSDOS, OS/2 or
  132.    WIN32... */
  133.  
  134. #if defined(__FLAT__) && defined(__SMALL__)
  135. #error "Both __FLAT__ and __SMALL__ defined!"
  136. #endif
  137.  
  138. #if defined(__DOS16__) && defined(__FLAT__)
  139. #error "Both __DOS16__ and __FLAT defined!"
  140. #endif
  141.  
  142. #if defined(__DOS16__) && defined(__DOS32__)
  143. #error "Both __DOS16__ and __DOS32__ defined!"
  144. #endif
  145.  
  146. #if defined(__MSDOS__) + defined(__OS2__) + defined(__W32__) > 1
  147. #error "Ambigous OS specification"
  148. #endif
  149.  
  150. #endif
  151.