home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / printing / ghostscrip / source / _gs / h / std < prev    next >
Encoding:
Text File  |  1991-11-22  |  9.1 KB  |  266 lines

  1. /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* std.h */
  21. /* Standard definitions for Aladdin Enterprises code */
  22.  
  23. #ifdef ARC
  24. /* We must include wimpc here, since it maps all the things like printf and
  25.    fread onto the WimpPlus library equivalents. */
  26. #include "wimpc.h"
  27.  
  28. /* A bug in the Acorn C compiler prevents me using make to get thess defines in */
  29. #define GS_LIB_DEFAULT "<GS$Dir>."
  30. #define GS_INIT "<GS$Dir>.ps.gs_init"
  31. #endif
  32.  
  33. /*
  34.  * Here we deal with the vagaries of various C compilers.  We assume that:
  35.  *    ANSI-standard Unix compilers define __STDC__.
  36.  *    Turbo C defines __MSDOS__.
  37.  *    Microsoft C defines MSDOS.
  38.  * Also, not used much here, but used in other header files, we assume:
  39.  *    Unix System V environments define USG or SYSV.
  40.  *      (GNU software uses the former, non-GNU tends to use the latter.)
  41.  *    VMS systems define VMS.
  42.  *    bsd 4.2 or 4.3 systems define BSD4_2.
  43.  *    POSIX-compliant environments define _POSIX_SOURCE.
  44.  *    Motorola 88K BCS/OCS systems defined m88k.
  45.  *
  46.  * We make fairly heroic efforts to confine all uses of these flags to
  47.  * header files, and never to use them in code.
  48.  */
  49.  
  50. #ifdef __STDC__
  51. #  define STDC_OR_MSDOS /* */
  52. #endif
  53. #ifdef __MSDOS__
  54. #  define STDC_OR_MSDOS /* */
  55. #endif
  56.  
  57. /* Recognize USG and SYSV as synonyms.  GNU software uses the former, */
  58. /* non-GNU tends to use the latter.  We use the latter. */
  59. #ifdef USG
  60. #  define SYSV /* */
  61. #endif
  62.  
  63. /* Define dummy values for __FILE__ and __LINE__ if the compiler */
  64. /* doesn't provide these.  Note that places that use __FILE__ */
  65. /* must check explicitly for a null pointer. */
  66. #ifndef __FILE__
  67. #  define __FILE__ NULL
  68. #endif
  69. #ifndef __LINE__
  70. #  define __LINE__ 0
  71. #endif
  72.  
  73. /* Disable 'const' if the compiler can't handle it. */
  74. #ifndef STDC_OR_MSDOS
  75. #  define const /* */
  76. #endif
  77.  
  78. /* Disable MS-DOS specialized pointer types on non-MS-DOS systems. */
  79. #ifndef __MSDOS__
  80. #  define near /* */
  81. #  define far /* */
  82. #  define huge /* */
  83. #  define _cs /* */
  84. #  define _ds /* */
  85. /* _es is never safe to use */
  86. #  define _ss /* */
  87. #endif
  88.  
  89. /* Miscellaneous types */
  90. typedef unsigned char byte;
  91. typedef unsigned char uchar;
  92. #ifndef m88k    /* 88k systems seem to define these things in sys/types.h. */
  93. typedef unsigned short ushort;
  94. typedef unsigned int uint;
  95. typedef unsigned long ulong;
  96. #else                    /* ifdef m88k */
  97. #  include <sys/types.h>
  98. #endif                    /* m88k */
  99.  
  100. /* Maximum values for the unsigned types. */
  101. /* The "+0" is to get around apparent bugs in the UTek compiler. */
  102. #define max_uchar ((uchar)0xff + (uchar)0)
  103. #define max_ushort ((ushort)0xffff + (ushort)0)
  104. #define max_uint ((uint)0xffffffff + (uint)0)
  105. #define max_ulong ((ulong)0xffffffffL + (ulong)0)
  106.  
  107. /* Define a reliable arithmetic right shift. */
  108. #if (-2 >> 1) == -1
  109. #  define arith_rshift(x,n) ((x) >> (n))
  110. #else
  111. #  define arith_rshift(x,n) ((x) < 0 ? ~(~(x) >> (n)) : (x) >> (n))
  112. #endif
  113.  
  114. /* The type to be used for comparing pointers for order (<, >=, etc.). */
  115. /* Turbo C large model doesn't compare pointers per se correctly. */
  116. #ifdef __MSDOS__
  117. typedef unsigned long ptr_ord_t;
  118. #else
  119. typedef char *ptr_ord_t;
  120. #endif
  121.  
  122. /* In case stdio.h doesn't have these: */
  123. #ifndef min
  124. #  define min(a, b) ((a) < (b) ? (a) : (b))
  125. #endif
  126. #ifndef max
  127. #  define max(a, b) ((a) > (b) ? (a) : (b))
  128. #endif
  129.  
  130. /* VMS doesn't have the unlink system call.  Use delete instead. */
  131. #ifdef VMS
  132. #  define unlink(fname) delete(fname)
  133. #endif
  134.  
  135. /* K&R specifies that float parameters get converted to double. */
  136. /* However, if we pass a float to a function that has been declared */
  137. /* with a prototype, and the parameter has been declared as float, */
  138. /* the ANSI standard specifies that the parameter is left as float. */
  139. /* To avoid problems when mixing ANSI and non-ANSI compilation, */
  140. /* we declare all float parameters as double. */
  141. typedef double floatp;
  142.  
  143. /* If we are debugging, make all static variables and procedures public */
  144. /* so they get passed through the linker. */
  145. #ifdef NOPRIVATE
  146. # define private /* */
  147. #else
  148. # define private static
  149. #endif
  150.  
  151. /* Macros for argument templates.  ANSI has these, as does Turbo C, */
  152. /* but most Unix compilers don't. */
  153.  
  154. #ifdef STDC_OR_MSDOS
  155. # define P0() void
  156. # define P1(t1) t1
  157. # define P2(t1,t2) t1,t2
  158. # define P3(t1,t2,t3) t1,t2,t3
  159. # define P4(t1,t2,t3,t4) t1,t2,t3,t4
  160. # define P5(t1,t2,t3,t4,t5) t1,t2,t3,t4,t5
  161. # define P6(t1,t2,t3,t4,t5,t6) t1,t2,t3,t4,t5,t6
  162. # define P7(t1,t2,t3,t4,t5,t6,t7) t1,t2,t3,t4,t5,t6,t7
  163. # define P8(t1,t2,t3,t4,t5,t6,t7,t8) t1,t2,t3,t4,t5,t6,t7,t8
  164. # define P9(t1,t2,t3,t4,t5,t6,t7,t8,t9) t1,t2,t3,t4,t5,t6,t7,t8,t9
  165. # define P10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10)\
  166.    t1,t2,t3,t4,t5,t6,t7,t8,t9,t10
  167. # define P11(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11)\
  168.    t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11
  169. # define P12(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12)\
  170.    t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12
  171. #else
  172. # define P0() /* */
  173. # define P1(t1) /* */
  174. # define P2(t1,t2) /* */
  175. # define P3(t1,t2,t3) /* */
  176. # define P4(t1,t2,t3,t4) /* */
  177. # define P5(t1,t2,t3,t4,t5) /* */
  178. # define P6(t1,t2,t3,t4,t5,t6) /* */
  179. # define P7(t1,t2,t3,t4,t5,t6,t7) /* */
  180. # define P8(t1,t2,t3,t4,t5,t6,t7,t8) /* */
  181. # define P9(t1,t2,t3,t4,t5,t6,t7,t8,t9) /* */
  182. # define P10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10) /* */
  183. # define P11(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11) /* */
  184. # define P12(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12) /* */
  185. #endif
  186.  
  187. /* Types for client-supplied allocate and free procedures. */
  188. /* For accountability, debugging, and error messages, */
  189. /* we pass an identifying string to alloc and free. */
  190. /* Note that the arguments are like calloc, not like malloc, */
  191. /* but an alloc procedure doesn't clear the block. */
  192. typedef char *(*proc_alloc_t)(P3(unsigned num_elements, unsigned element_size, char *client_name));
  193. typedef void (*proc_free_t)(P4(char *data, unsigned num_elements, unsigned element_size, char *client_name));
  194.  
  195. /* Standard error printing macros. */
  196. /* Use dprintf for messages that just go to dstderr, */
  197. /* eprintf for error messages to estderr that include the program name, */
  198. /* lprintf for debugging messages that should include line number info. */
  199.  
  200. /* dstderr and estderr may be redefined. */
  201. #define dstderr stderr
  202. #define estderr stderr
  203.  
  204. #define dputc(chr) fputc(chr, dstderr)
  205. #define dputs(str) fputs(str, dstderr)
  206. #define dprintf(str)\
  207.   fprintf(dstderr, str)
  208. #define dprintf1(str,arg1)\
  209.   fprintf(dstderr, str, arg1)
  210. #define dprintf2(str,arg1,arg2)\
  211.   fprintf(dstderr, str, arg1, arg2)
  212. #define dprintf3(str,arg1,arg2,arg3)\
  213.   fprintf(dstderr, str, arg1, arg2, arg3)
  214. #define dprintf4(str,arg1,arg2,arg3,arg4)\
  215.   fprintf(dstderr, str, arg1, arg2, arg3, arg4)
  216. #define dprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  217.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5)
  218. #define dprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  219.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6)
  220. #define dprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
  221.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
  222. #define dprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
  223.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  224.  
  225. #ifdef PROGRAM_NAME
  226. #  define _epn fprintf(estderr, PROGRAM_NAME),
  227. #else
  228. #  define _epn /* */
  229. #endif
  230.  
  231. #define eprintf(str)\
  232.   (_epn fprintf(estderr, str))
  233. #define eprintf1(str,arg1)\
  234.   (_epn fprintf(estderr, str, arg1))
  235. #define eprintf2(str,arg1,arg2)\
  236.   (_epn fprintf(estderr, str, arg1, arg2))
  237. #define eprintf3(str,arg1,arg2,arg3)\
  238.   (_epn fprintf(estderr, str, arg1, arg2, arg3))
  239. #define eprintf4(str,arg1,arg2,arg3,arg4)\
  240.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4))
  241. #define eprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  242.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5))
  243. #define eprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  244.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6))
  245.  
  246. #if __LINE__                /* compiler provides it */
  247. #  define _epl _epn fprintf(stderr, "%s(%d): ", __FILE__, __LINE__),
  248. #else
  249. #  define _epl _epn
  250. #endif
  251.  
  252. #define lprintf(str)\
  253.   (_epl fprintf(estderr, str))
  254. #define lprintf1(str,arg1)\
  255.   (_epl fprintf(estderr, str, arg1))
  256. #define lprintf2(str,arg1,arg2)\
  257.   (_epl fprintf(estderr, str, arg1, arg2))
  258. #define lprintf3(str,arg1,arg2,arg3)\
  259.   (_epl fprintf(estderr, str, arg1, arg2, arg3))
  260. #define lprintf4(str,arg1,arg2,arg3,arg4)\
  261.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4))
  262. #define lprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  263.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5))
  264. #define lprintf6(str,arg1,arg2,arg3,arg4,arg6)\
  265.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6))
  266.