home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / ltroff / part02 / ansic.h next >
Encoding:
C/C++ Source or Header  |  1993-07-15  |  9.1 KB  |  559 lines

  1. #ifndef ANSIC_H
  2.  
  3. #define ANSIC_H
  4.  
  5. /*
  6. ** ID
  7. */
  8.  
  9. #ifndef ID
  10. #ifndef lint
  11. #ifndef NOID
  12. #define ID(name, value)    static char    (name)[] = value;
  13. #endif /* !defined NOID */
  14. #endif /* !defined lint */
  15. #ifndef ID
  16. #define ID(name, value)    /* static char    (name)[] = value; */
  17. #endif /* !defined ID */
  18. #endif /* !defined ID */
  19.  
  20. #ifndef ELSIEID
  21. #define ELSIEID(value)    ID(elsieid, (value))
  22. #endif /* !defined ELSIEID */
  23.  
  24. ID(ansichid, "@(#)ansic.h    4.1")
  25.  
  26. /*
  27. ** Cover for stupid IBM PC/RT compilers (pcc and hc);
  28. ** they fib about being __STDC__ when they lack standard header files
  29. ** ("locale.h" for one).
  30. */
  31.  
  32. #ifdef ibm032
  33. #undef __STDC__
  34. #define VOID_OK
  35. #endif /* defined ibm032 */
  36.  
  37. #ifdef sgi
  38. #define STDIO_H    <stdio.h>
  39. #define MATH_H    <math.h>
  40. #define remove    unlink
  41. #endif /* defined sgi */
  42.  
  43. /*
  44. ** const
  45. */
  46.  
  47. #ifndef const
  48.  
  49. #ifndef CONST_OK
  50. #ifndef CONST_NO
  51. #ifdef __convexc__
  52. /*
  53. ** Workaround for Convex CC bug that muffs
  54. **    func(int * const * const p){}
  55. */
  56. #define CONST_NO
  57. #endif /* defined __convexc__ */
  58. #endif /* !defined CONST_NO */
  59. #endif /* !defined CONST_OK */
  60.  
  61. #ifndef CONST_OK
  62. #ifndef CONST_NO
  63. #ifdef __STDC__
  64. #define CONST_OK
  65. #endif /* defined __STDC__ */
  66. #endif /* !defined CONST_NO */
  67. #endif /* !defined CONST_OK */
  68.  
  69. #ifndef CONST_OK
  70. #define const
  71. #endif /* !defined CONST_OK */
  72.  
  73. #endif /* !defined const */
  74.  
  75. /*
  76. ** void
  77. */
  78.  
  79. #ifndef void
  80.  
  81. #ifndef VOID_NO
  82. #ifndef VOID_OK
  83.  
  84. #ifdef __STDC__
  85. #define VOID_OK
  86. #endif /* defined __STDC__ */
  87.  
  88. #ifdef sun
  89. #define VOID_OK
  90. #endif /* defined sun */
  91.  
  92. #ifdef __convexc__
  93. #define VOID_OK
  94. #endif /* defined __convexc__ */
  95.  
  96. #endif /* !defined VOID_OK */
  97. #endif /* !defined VOID_NO */
  98.  
  99. #ifndef VOID_OK
  100. #define void char
  101. #endif /* !defined VOID_OK */
  102.  
  103. #endif /* !defined void */
  104.  
  105. /*
  106. ** P((args))
  107. */
  108.  
  109. #ifndef P
  110.  
  111. #ifndef PROTO_OK
  112. #ifndef PROTO_NO
  113. #ifdef __STDC__
  114. #define PROTO_OK
  115. #endif /* defined __STDC__ */
  116. #endif /* !defined PROTO_NO */
  117. #endif /* !defined PROTO_OK */
  118.  
  119. #ifdef PROTO_OK
  120. #define P(x)    x
  121. #endif /* defined PROTO_OK */
  122.  
  123. #ifndef PROTO_OK
  124. #define P(x)    ()
  125. #endif /* !defined PROTO_OK */
  126.  
  127. #endif /* !defined P */
  128.  
  129. /*
  130. ** Includes.  First the ones we expect to show up on all systems.
  131. */
  132.  
  133. /*
  134. ** <assert.h>
  135. */
  136.  
  137. #ifdef ASSERT_H
  138. #include ASSERT_H
  139. #endif /* defined ASSERT_H */
  140.  
  141. #ifndef ASSERT_H
  142. #include "assert.h"
  143. #endif /* !defined ASSERT_H */
  144.  
  145. /*
  146. ** <ctype.h>
  147. */
  148.  
  149. #ifdef CTYPE_H
  150. #include CTYPE_H
  151. #endif /* defined CTYPE_H */
  152.  
  153. #ifndef CTYPE_H
  154. #include "ctype.h"
  155. #ifdef sun
  156. #ifndef tolower
  157. extern int    tolower P((
  158.             int /*c*/
  159.             ));
  160. extern int    toupper P((
  161.             int /*c*/
  162.             ));
  163. #endif /* !defined tolower */
  164. #endif /* defined sun */
  165. #endif /* !defined CTYPE_H */
  166.  
  167. /*
  168. ** <errno.h>
  169. */
  170.  
  171. #ifdef ERRNO_H
  172. #include ERRNO_H
  173. #endif /* defined ERRNO_H */
  174.  
  175. #ifndef ERRNO_H
  176. #include "errno.h"
  177. #ifndef errno
  178. extern int    errno;
  179. #endif /* !defined errno */
  180. #endif /* !defined ERRNO_H */
  181.  
  182. /*
  183. ** <math.h>
  184. */
  185.  
  186. #ifdef MATH_H
  187. #include MATH_H
  188. #endif /* defined MATH_H */
  189.  
  190. #ifndef MATH_H
  191. #include "math.h"
  192. #ifndef __STDC__
  193. #ifndef mips
  194. /*
  195. ** This declaration is missing in the 4.1BSD math.h;
  196. ** we'll play it safe.
  197. */
  198. extern double    erf();
  199. #endif /* !defined mips */
  200. #endif  /* !defined __STDC__ */
  201. #endif /* !defined MATH_H */
  202.  
  203. /*
  204. ** <setjmp.h>
  205. */
  206.  
  207. #ifdef SETJMP_H
  208. #include SETJMP_H
  209. #endif /* defined SETJMP_H */
  210.  
  211. #ifndef SETJMP_H
  212. #include "setjmp.h"
  213. #endif /* !defined SETJMP_H */
  214.  
  215. /*
  216. ** <signal.h>
  217. */
  218.  
  219. #ifdef SIGNAL_H
  220. #include SIGNAL_H
  221. #endif /* defined SIGNAL_H */
  222.  
  223. #ifndef SIGNAL_H
  224. #include "signal.h"
  225. #ifdef mips
  226. /*
  227. ** For the benefit of MIPS boxes, where signal isn't declared.
  228. */
  229. extern void (*    signal P((
  230.             int /*sig*/,
  231.             void (* /*func*/)()
  232.             )))();
  233. #endif /* defined mips */
  234. #endif /* !defined SIGNAL_H */
  235.  
  236. /*
  237. ** <stdio.h>
  238. */
  239.  
  240. #ifdef STDIO_H
  241. #include STDIO_H
  242. #endif /* defined STDIO_H */
  243.  
  244. #ifndef STDIO_H
  245. #include "stdio.h"
  246.  
  247. /*
  248. ** We get to do stdio prototypes if we are not __STDC__ or we are __GNUC__
  249. */
  250.  
  251. #ifndef DO_STDIO_PROTOS
  252. #ifdef __GNUC__
  253. #define DO_STDIO_PROTOS
  254. #endif /* defined __GNUC__ */
  255. #endif /* !defined DO_STDIO_PROTOS */
  256.  
  257. #ifndef DO_STDIO_PROTOS
  258. #ifndef __STDC__
  259. #ifndef __convexc__
  260. #define DO_STDIO_PROTOS
  261. #endif /* !defined __convexc__ */
  262. #endif /* !defined __STDC__ */
  263. #endif /* !defined DO_STDIO_PROTOS */
  264.  
  265. #ifdef DO_STDIO_PROTOS
  266. extern int    fclose P((
  267.             FILE * /*stream*/
  268.             ));
  269. extern int    fflush P((
  270.             FILE * /*stream*/
  271.             ));
  272. extern int    fprintf P((
  273.             FILE * /*stream*/,
  274.             const char * /*format*/,
  275.             ...
  276.             ));
  277. extern int    fputc P((
  278.             int /*c*/,
  279.             FILE * /*stream*/
  280.             ));
  281. extern int    fputs P((
  282.             const char * /*s*/,
  283.             FILE * /*stream*/
  284.             ));
  285. extern int    fread P((
  286.             void * /*p*/,
  287.             int /*s*/,
  288.             int /*n*/,
  289.             FILE * /*stream*/
  290.             ));
  291. extern int    fscanf P((
  292.             FILE * /*stream*/,
  293.             const char * /*format*/,
  294.             ...
  295.             ));
  296. extern int    fseek P((
  297.             FILE * /*stream*/,
  298.             long int /*offset*/,
  299.             int /*whence*/
  300.             ));
  301. extern int    fwrite P((
  302.             const void * /*p*/,
  303.             int /*s*/,
  304.             int /*n*/,
  305.             FILE * /*stream*/
  306.             ));
  307. extern int    printf P((
  308.             const char * /*format*/,
  309.             ...
  310.             ));
  311. extern int    scanf P((
  312.             const char * /*format*/,
  313.             ...
  314.             ));
  315. extern int    sscanf P((
  316.             const char * /*string*/,
  317.             const char * /*format*/,
  318.             ...
  319.             ));
  320. extern char *    tmpnam P((
  321.             const char * /*name*/
  322.             ));
  323. extern int    ungetc P((
  324.             int /*c*/,
  325.             FILE * /*stream*/
  326.             ));
  327. /*
  328. ** To prevent gcc squawks when in "prototypes required" mode. . .
  329. */
  330. extern int    _filbuf P((
  331.             FILE * /*stream*/
  332.             ));
  333. extern int    _flsbuf P((
  334.             unsigned char /*c*/,
  335.             FILE * /*stream*/
  336.             ));
  337.  
  338. /*
  339. ** And last but not least among the common stuff. . .
  340. */
  341. #ifndef remove
  342. extern int    unlink P((
  343.             const char * /*filename*/
  344.             ));
  345. #define remove    unlink
  346. #endif /* !defined remove */
  347.  
  348. #ifdef USG
  349. extern void    rewind P((
  350.             FILE * /*stream*/
  351.             ));
  352. #ifndef sun
  353. extern int    sprintf P((
  354.             char * /*string*/,
  355.             const char * /*format*/,
  356.             ...
  357.             ));
  358. #endif /* !defined sun */
  359. #endif /* defined USG */
  360. #ifndef USG
  361. extern int    rewind P((
  362.             FILE * /*stream*/
  363.             ));
  364. #ifndef sun
  365. extern char *    sprintf P((
  366.             char * /*string*/,
  367.             const char * /*format*/,
  368.             ...
  369.             ));
  370. #endif /* !defined sun */
  371. #endif /* !defined USG */
  372.  
  373. #endif /* defined DO_STDIO_PROTOS */
  374.  
  375. #endif /* !defined STDIO_H */
  376.  
  377. /*
  378. ** <string.h>
  379. */
  380.  
  381. #ifdef STRING_H
  382. #include STRING_H
  383. #endif /* defined STRING_H */
  384.  
  385. #ifndef STRING_H
  386. #include "string.h"
  387. #ifdef sun
  388. #include "memory.h"
  389. #endif /* defined sun */
  390. #endif /* !defined STRING_H */
  391.  
  392. /*
  393. ** <time.h>
  394. */
  395.  
  396. #ifdef TIME_H
  397. #include TIME_H
  398. #endif /* defined TIME_H */
  399.  
  400. #ifndef TIME_H
  401. #include "time.h"
  402. #endif /* !defined TIME_H */
  403.  
  404. /*
  405. ** ANSI inventions--float, limits, locale, stdarg, stddef, and stdlib.
  406. ** GCC 1.28 comes with stddef.h, but using it causes clashes if you
  407. ** also (directly or indirectly) include <sys/types.h>.  So we don't
  408. ** use it here.
  409. */
  410.  
  411. #ifdef __STDC__
  412.  
  413. #ifndef LIMITS_H
  414. #define LIMITS_H    "limits.h"
  415. #endif /* !defined LIMITS_H */
  416.  
  417. #ifndef __GNUC__
  418.  
  419. #ifndef STDARG_H
  420. #define STDARG_H    "stdarg.h"
  421. #endif /* !defined STDARG_H */
  422.  
  423. #ifndef FLOAT_H
  424. #define FLOAT_H        "float.h"
  425. #endif /* !defined FLOAT_H */
  426.  
  427. #ifndef LOCALE_H
  428. #define LOCALE_H    "locale.h"
  429. #endif /* !defined LOCALE_H */
  430.  
  431. #ifndef STDDEF_H
  432. #define STDDEF_H    "stddef.h"
  433. #endif /* !defined STDDEF_H */
  434.  
  435. #ifndef STDLIB_H
  436. #define STDLIB_H    "stdlib.h"
  437. #endif /* !defined STDLIB_H */
  438.  
  439. #endif /* !defined __GNUC__ */
  440. #endif /* defined __STDC__ */
  441.  
  442. #ifdef FLOAT_H
  443. #include FLOAT_H
  444. #endif /* defined FLOAT_H */
  445.  
  446. #ifdef LIMITS_H
  447. #include LIMITS_H
  448. #endif /* defined LIMITS_H */
  449.  
  450. #ifndef CHAR_BIT
  451. #define CHAR_BIT    8
  452. #endif /* !defined CHAR_BIT */
  453.  
  454. #ifndef USHRT_MAX
  455. #define USHRT_MAX    ((unsigned short) ~0)
  456. #endif /* !defined USHRT_MAX */
  457.  
  458. #ifdef LOCALE_H
  459. #include LOCALE_H
  460. #endif /* defined LOCALE_H */
  461.  
  462. #ifdef STDARG_H
  463. #include STDARG_H
  464. #endif /* defined STDARG_H */
  465.  
  466. #ifdef STDDEF_H
  467. #include STDDEF_H
  468. #endif /* defined STDDEF_H */
  469.  
  470. #ifdef STDLIB_H
  471. #include STDLIB_H
  472. #endif /* defined STDLIB_H */
  473.  
  474. #ifndef STDLIB_H
  475. extern int    atoi P((
  476.             const char * /*nptr*/
  477.             ));
  478. extern char *    getenv P((
  479.             const char * /*name*/
  480.             ));
  481. extern char *    malloc P((
  482.             unsigned /*size*/
  483.             ));
  484. extern char *    calloc P((
  485.             unsigned /*nelem*/,
  486.             unsigned /*elsize*/
  487.             ));
  488. extern char *    realloc P((
  489.             void * /*pointer*/,
  490.             unsigned /*size*/
  491.             ));
  492. extern int    system P((
  493.             const char * /*command*/
  494.             ));
  495. extern int    abs P((
  496.             int /*j*/
  497.             ));
  498.  
  499. #ifdef USG
  500. extern void    exit P((
  501.             int /*status*/
  502.             ));
  503. extern void    free P((
  504.             void * /*pointer*/
  505.             ));
  506. extern void    qsort P((
  507.             void * /*base*/,
  508.             unsigned /*nmemb*/,
  509.             unsigned /*size*/,
  510.             int (*/*compar*/)(
  511.                 const void * /*left*/,
  512.                 const void * /*right*/
  513.                 )
  514.             ));
  515. #endif /* defined USG */
  516. #ifndef USG
  517. #ifdef sun
  518. extern void    exit P((
  519.             int /*status*/
  520.             ));
  521. #endif /* defined sun */
  522. #ifndef sun
  523. extern int    exit P((
  524.             int /*status*/
  525.             ));
  526. #endif /* !defined sun */
  527. extern int    free P((
  528.             void * /*pointer*/
  529.             ));
  530. extern int    qsort P((
  531.             void * /*base*/,
  532.             unsigned /*nmemb*/,
  533.             unsigned /*size*/,
  534.             int (*/*compar*/)(
  535.                 const void * /*left*/,
  536.                 const void * /*right*/
  537.                 )
  538.             ));
  539. #endif /* !defined USG */
  540. #endif /* !defined STDLIB_H */
  541.  
  542. #ifndef EXIT_FAILURE
  543. #define EXIT_FAILURE    1
  544. #endif /* !defined EXIT_FAILURE */
  545.  
  546. #ifndef EXIT_SUCCESS
  547. #define EXIT_SUCCESS    0
  548. #endif /* !defined EXIT_SUCCESS */
  549.  
  550. /*
  551. ** One last bit of business. . .
  552. */
  553.  
  554. #ifndef isascii
  555. #define isascii(a_r_g)    (((unsigned) (a_r_g)) <= 127)
  556. #endif /* !defined isascii */
  557.  
  558. #endif /* !defined ANSIC_H */
  559.