gconf.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* Copyright (C) 1989, 1995, 1996, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
  2. This software is provided AS-IS with no warranty, either express or
  3. implied.
  4. This software is distributed under license and may not be copied,
  5. modified or distributed except as expressly authorized under the terms
  6. of the license contained in the file LICENSE in this distribution.
  7. For more information about licensing, please refer to
  8. http://www.ghostscript.com/licensing/. For information on
  9. commercial licensing, go to http://www.artifex.com/licensing/ or
  10. contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. */
  13. /* $Id: gconf.c,v 1.6 2002/08/22 07:12:28 henrys Exp $ */
  14. /* Configuration tables */
  15. #include "memory_.h"
  16. #include "gx.h"
  17. #include "gscdefs.h" /* interface */
  18. #include "gconf.h" /* for #defines */
  19. #include "gxdevice.h"
  20. #include "gxdhtres.h"
  21. #include "gxiclass.h"
  22. #include "gxiodev.h"
  23. #include "gxiparam.h"
  24. #include "gxcomp.h"
  25. /*
  26. * The makefile generates the file gconfig.h, which consists of
  27. * lines of the form
  28. * device_(gs_xxx_device)
  29. * or
  30. * device2_(gs_xxx_device)
  31. * for each installed device;
  32. * emulator_("emulator", strlen("emulator"))
  33. * for each known emulator;
  34. * function_type_(xxx, gs_function_type_xxx)
  35. * for each known function type;
  36. * halftone_(gs_dht_xxx)
  37. * for each known (device) halftone;
  38. * image_class_(gs_image_class_xxx)
  39. * for each known image class;
  40. * image_type_(xxx, gs_image_type_xxx)
  41. * for each known image type;
  42. * init_(gs_xxx_init)
  43. * for each initialization procedure;
  44. * io_device_(gs_iodev_xxx)
  45. * for each known IODevice;
  46. * oper_(xxx_op_defs)
  47. * for each operator option;
  48. * psfile_("gs_xxxx.ps", strlen("gs_xxxx.ps"))
  49. * for each optional initialization file.
  50. * plug_(gs_xxx_init)
  51. * for each plugin;
  52. *
  53. * We include this file multiple times to generate various different
  54. * source structures. (It's a hack, but we haven't come up with anything
  55. * more satisfactory.)
  56. */
  57. /* ---------------- Resources (devices, inits, IODevices) ---------------- */
  58. /* Declare devices, image types, init procedures, and IODevices as extern. */
  59. #define compositor_(comp_type) extern gs_composite_type_t comp_type;
  60. #define device_(dev) extern gx_device dev;
  61. #define device2_(dev) extern const gx_device dev;
  62. #define halftone_(dht) extern DEVICE_HALFTONE_RESOURCE_PROC(dht);
  63. #define image_class_(cls) extern iclass_proc(cls);
  64. #define image_type_(i,type) extern const gx_image_type_t type;
  65. #define init_(proc) extern init_proc(proc);
  66. #define io_device_(iodev) extern const gx_io_device iodev;
  67. #include "gconf.h"
  68. #undef io_device_
  69. #undef init_
  70. #undef image_type_
  71. #undef image_class_
  72. #undef halftone_
  73. #undef device2_
  74. #undef device_
  75. #undef compositor_
  76. /* Set up compositor type table. */
  77. #define compositor_(comp_type) &comp_type,
  78. private const gs_composite_type_t *const gx_compositor_list[] = {
  79. #include "gconf.h"
  80. 0
  81. };
  82. #undef compositor_
  83. /* Set up the device table. */
  84. #define device_(dev) (const gx_device *)&dev,
  85. #define device2_(dev) &dev,
  86. private const gx_device *const gx_device_list[] = {
  87. #include "gconf.h"
  88. 0
  89. };
  90. #undef device2_
  91. #undef device_
  92. /* Set up the (device) halftone table. */
  93. extern_gx_device_halftone_list();
  94. #define halftone_(dht) dht,
  95. const gx_dht_proc gx_device_halftone_list[] = {
  96. #include "gconf.h"
  97. 0
  98. };
  99. #undef halftone_
  100. /* Set up the image class table. */
  101. extern_gx_image_class_table();
  102. #define image_class_(cls) cls,
  103. const gx_image_class_t gx_image_class_table[] = {
  104. #include "gconf.h"
  105. 0
  106. };
  107. #undef image_class_
  108. /* We must use unsigned here, not uint. See gscdefs.h. */
  109. const unsigned gx_image_class_table_count = countof(gx_image_class_table) - 1;
  110. /* Set up the image type table. */
  111. extern_gx_image_type_table();
  112. #define image_type_(i,type) &type,
  113. const gx_image_type_t *const gx_image_type_table[] = {
  114. #include "gconf.h"
  115. 0
  116. };
  117. #undef image_type_
  118. /* We must use unsigned here, not uint. See gscdefs.h. */
  119. const unsigned gx_image_type_table_count = countof(gx_image_type_table) - 1;
  120. /* Set up the initialization procedure table. */
  121. extern_gx_init_table();
  122. #define init_(proc) proc,
  123. const gx_init_proc gx_init_table[] = {
  124. #include "gconf.h"
  125. 0
  126. };
  127. #undef init_
  128. /* Set up the IODevice table. The first entry must be %os%, */
  129. /* since it is the default for files with no explicit device specified. */
  130. extern_gx_io_device_table();
  131. extern gx_io_device gs_iodev_os;
  132. #define io_device_(iodev) &iodev,
  133. const gx_io_device *const gx_io_device_table[] = {
  134. &gs_iodev_os,
  135. #include "gconf.h"
  136. 0
  137. };
  138. #undef io_device_
  139. /* We must use unsigned here, not uint. See gscdefs.h. */
  140. const unsigned gx_io_device_table_count = countof(gx_io_device_table) - 1;
  141. /* Find a compositor by name. */
  142. extern_gs_find_compositor();
  143. const gs_composite_type_t *
  144. gs_find_compositor(int comp_id)
  145. {
  146. const gs_composite_type_t *const * ppcomp = gx_compositor_list;
  147. const gs_composite_type_t * pcomp;
  148. while ((pcomp = *ppcomp++) != 0 && pcomp->comp_id != comp_id)
  149. ;
  150. return pcomp;
  151. }
  152. /* Return the list of device prototypes, a NULL list of their structure */
  153. /* descriptors (no longer used), and (as the value) the length of the lists. */
  154. extern_gs_lib_device_list();
  155. int
  156. gs_lib_device_list(const gx_device * const **plist,
  157. gs_memory_struct_type_t ** pst)
  158. {
  159. if (plist != 0)
  160. *plist = gx_device_list;
  161. if (pst != 0)
  162. *pst = NULL;
  163. return countof(gx_device_list) - 1;
  164. }