home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / CONTRIB / MBASE / MBASE50.TAR / mbase / src / stdinc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-25  |  5.0 KB  |  279 lines

  1. /*
  2.  * METALBASE 5.0
  3.  *
  4.  * Released October 1st, 1992 by Huan-Ti [ richid@owlnet.rice.edu ]
  5.  *                                       [ t-richj@microsoft.com ]
  6.  */
  7.  
  8. #ifndef STDINC_H
  9. #define STDINC_H
  10.  
  11. #ifndef XENIX
  12. #ifdef M_V7
  13. #define XENIX
  14. #else
  15. #ifdef M_SYS3
  16. #define XENIX
  17. #else
  18. #ifdef M_SYS5
  19. #define XENIX
  20. #endif
  21. #endif /* M_SYS3 */
  22. #endif /* M_V7 */
  23. #endif /* XENIX */
  24.  
  25. #ifdef applec
  26. #define NON_ANSI  /* Define to skip vt100 codes in output      */
  27. #endif
  28.  
  29. #ifdef MSDOS
  30. #include <io.h>
  31. #include <stdlib.h>
  32. #include <process.h>
  33. #ifndef ANSI_CODES
  34. #define NON_ANSI  /* Define to skip vt100 codes in output */
  35. #endif
  36. #endif /* MSDOS */
  37.  
  38. #ifdef COHERENT
  39. #define SYS_FCNTL
  40. #endif
  41.  
  42. #ifdef SYS_FCNTL
  43. #include <sys/fcntl.h>
  44. #else
  45. #include <fcntl.h>
  46. #endif
  47.  
  48. #include <stdio.h>
  49. #include <ctype.h>
  50. #include <sys/types.h>
  51. #include <string.h>    /* May need to change to <strings.h> on some systems */
  52. #include <time.h>      /* May need to change to whatever on other systems   */
  53. #include <sys/stat.h>
  54.  
  55. #ifdef NeXT
  56. #include <dir.h>
  57. #endif
  58.  
  59. #ifdef COHERENT   /* Another great thing--isdigit() under COHERENT doesn't */
  60. #ifdef isdigit    /* work right: it keeps returning 8.  Odd.  Oh well.  :) */
  61. #undef isdigit
  62. #endif
  63. #define isdigit(x) ((x) >= '0' && (x) <= '9')
  64. #endif /* COHERENT */
  65.  
  66. #ifdef MSDOS
  67. #define SNGCR    "\r\n"
  68. #define DUBCR    "\r\n\r\n"
  69. #define NUMCR    2
  70. #define DIRSEP   '\\'
  71. #else
  72. #define SNGCR    "\n"
  73. #define DUBCR    "\n\n"
  74. #define NUMCR    1
  75. #define DIRSEP   '/'
  76. #endif
  77.  
  78. #ifdef ESC
  79. #undef ESC
  80. #endif
  81.  
  82. #define CTRL_A (char)1
  83. #define CTRL_B (char)2
  84. #define CTRL_C (char)3
  85. #define CTRL_D (char)4
  86. #define CTRL_E (char)5
  87. #define CTRL_F (char)6
  88. #define CTRL_G (char)7
  89. #define CTRL_H (char)8
  90. #define CTRL_I (char)9
  91. #define CTRL_J (char)10
  92. #define CTRL_K (char)11
  93. #define CTRL_L (char)12
  94. #define CTRL_M (char)13
  95. #define CTRL_N (char)14
  96. #define CTRL_O (char)15
  97. #define CTRL_P (char)16
  98. #define CTRL_Q (char)17
  99. #define CTRL_R (char)18
  100. #define CTRL_S (char)19
  101. #define CTRL_T (char)20
  102. #define CTRL_U (char)21
  103. #define CTRL_V (char)22
  104. #define CTRL_W (char)23
  105. #define CTRL_X (char)24
  106. #define CTRL_Y (char)25
  107. #define CTRL_Z (char)26
  108. #define ESC    (char)27
  109.  
  110. #ifdef CHAR_IS_UNS
  111.    typedef char uchar;
  112. #else
  113.    typedef unsigned char uchar;
  114. #endif
  115.  
  116. typedef char * charptr;
  117.  
  118. /*
  119.  * STANDARD SYSTEM DEPENDENCIES
  120.  *
  121.  */
  122.  
  123. #ifdef COHERENT
  124. #ifndef NOVOIDPTR
  125. #define NOVOIDPTR
  126. #endif
  127. #ifndef NEED_USHORT
  128. #define NEED_USHORT
  129. #endif
  130. #ifndef NEED_ULONG
  131. #define NEED_ULONG
  132. #endif
  133. #endif
  134.  
  135. #ifdef applec
  136. #ifndef NEED_USHORT
  137. #define NEED_USHORT
  138. #endif
  139. #endif
  140.  
  141. #ifdef sgi
  142. #ifdef NEED_ULONG
  143. #undef NEED_ULONG
  144. #endif
  145. #endif
  146.  
  147. #ifdef MSDOS
  148. #ifndef LONGARGS
  149. #define LONGARGS
  150. #endif
  151. #ifndef NEED_ULONG
  152. #define NEED_ULONG
  153. #endif
  154. #ifndef NEED_USHORT
  155. #define NEED_USHORT
  156. #endif
  157. #endif
  158.  
  159. /*
  160.  *
  161.  */
  162.  
  163. #ifdef NOVOIDPTR
  164.    typedef char *dataptr;
  165. #else
  166.    typedef void *dataptr;
  167. #endif
  168.  
  169. #ifdef NEED_ULONG
  170.    typedef unsigned long ulong;
  171. #endif
  172.  
  173. #ifdef NEED_USHORT
  174.    typedef unsigned short ushort;
  175. #endif
  176.  
  177. #ifdef AMIGA
  178. #define CLS  "\014"            /* amiga std */
  179. #else
  180.  
  181. #ifdef COHERENT
  182. #define CLS  "\033[2O\033[1;1H"  /* I prefer this one myself */
  183. #undef LONGARGS
  184. #else
  185.  
  186. #define CLS  "\033[2J\033[1;1H"  /* ansi std */
  187.  
  188. #ifndef MSDOS
  189. #ifndef applec
  190. #define UNIX
  191.  
  192. #include <stdlib.h>
  193. #include <unistd.h>
  194.  
  195. #endif /* applec */
  196. #endif /* UNIX */
  197.  
  198. #endif /* COHERENT */
  199. #endif /* AMIGA */
  200.  
  201. #ifdef NON_ANSI
  202. #define ANSI ""
  203. #define NORM ""
  204. #define BOLD ""
  205. #define SUBD ""
  206. #define ITAL ""
  207. #define UNDR ""
  208. #define INVR ""
  209. #else
  210. #define ANSI "\033["
  211. #define NORM "\033[0m"
  212. #define BOLD "\033[1m"
  213. #define SUBD "\033[2m"
  214. #define ITAL "\033[3m"
  215. #define UNDR "\033[4m"  /* These are so common, I won't even bother with */
  216. #define INVR "\033[7m"  /* tgetstr.  Sorry, non-VT users.  :-)           */
  217. #endif
  218.  
  219. #define sendchar(x) putchar ((char)(x))
  220. #define until(x)    while (!(x))
  221.  
  222. #define New(x) (x *)malloc (sizeof(x))  /* Borrowed from C++.  So sue me. */
  223.  
  224. #ifdef LONGARGS
  225.    extern time_t time(time_t *);
  226. #else
  227.    extern time_t time();
  228. #endif
  229.  
  230. #ifndef min
  231. #define min(a,b) ((a)<(b)?(a):(b))
  232. #endif
  233. #ifndef max
  234. #define max(a,b) ((a)>(b)?(a):(b))
  235. #endif
  236.  
  237. #ifdef tolower  /* Strange to think, but on most systems, tolower() and */
  238. #undef tolower  /* toupper() just don't work as you'd expect.  Humph.   */
  239. #endif
  240. #ifdef toupper
  241. #undef toupper
  242. #endif
  243. #define tolower(x)  (char)(((x)>='A' && (x)<='Z')?((x)+('a'-'A')):(x))
  244. #define toupper(x)  (char)(((x)>='a' && (x)<='z')?((x)+('A'-'a')):(x))
  245.  
  246. /*
  247.  * Generic, portable low-level file operations --------------------------------
  248.  *
  249.  */
  250.  
  251. #define readx(f,b,n) read  (f, (char *)b, n)  /* DO NOT use buffered I/O!!! */
  252. #define writx(f,b,n) write (f, (char *)b, n)  /* DO NOT use buffered I/O!!! */
  253. #define modex(f,n)   chmod (f, n)
  254.  
  255. #ifndef S_IWRITE
  256. #undef modex
  257. #define modex(f,n)
  258. #endif
  259.  
  260. #ifdef applec
  261. #define creatx(x) creat(x)
  262. #else
  263. #define creatx(x) creat(x,0666)
  264. #endif
  265.  
  266. #ifdef MSDOS
  267. #define OPENMODE O_RDWR|O_BINARY
  268. #define READMODE O_RDONLY|O_BINARY
  269. #include <share.h>
  270. #define openx(f,m)  sopen (f, m, SH_DENYNO, S_IREAD|S_IWRITE)
  271. #else
  272. #define OPENMODE O_RDWR
  273. #define READMODE O_RDONLY
  274. #define openx(f,m)  open (f, m)
  275. #endif  /* MSDOS */
  276.  
  277. #endif
  278.  
  279.