Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/obj/gconfig.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
/* Configuration tables */
17
#include "memory_.h"
18
#include "gx.h"
19
#include "gscdefs.h"    /* interface */
20
#include "gconf.h"    /* for #defines */
21
#include "gxdevice.h"
22
#include "gxdhtres.h"
23
#include "gxiclass.h"
24
#include "gxiodev.h"
25
#include "gxiparam.h"
26
#include "gxcomp.h"
27
#include "gxfapi.h"
28
29
/*
30
 * The makefile generates the file gconfig.h, which consists of
31
 * lines of the form
32
 *      device_(gs_xxx_device)
33
 * or
34
 *      device2_(gs_xxx_device)
35
 * for each installed device;
36
 *      emulator_("emulator", strlen("emulator"))
37
 * for each known emulator;
38
 *  function_type_(xxx, gs_function_type_xxx)
39
 * for each known function type;
40
 *  halftone_(gs_dht_xxx)
41
 * for each known (device) halftone;
42
 *  image_class_(gs_image_class_xxx)
43
 * for each known image class;
44
 *  image_type_(xxx, gs_image_type_xxx)
45
 * for each known image type;
46
 *      init_(gs_xxx_init)
47
 * for each initialization procedure;
48
 *      io_device_(gs_iodev_xxx)
49
 * for each known IODevice;
50
 *      oper_(xxx_op_defs)
51
 * for each operator option;
52
 *      psfile_("gs_xxxx.ps", strlen("gs_xxxx.ps"))
53
 * for each optional initialization file.
54
 *      plug_(gs_xxx_init)
55
 * for each plugin;
56
 *
57
 * We include this file multiple times to generate various different
58
 * source structures.  (It's a hack, but we haven't come up with anything
59
 * more satisfactory.)
60
 */
61
62
/* ---------------- Resources (devices, inits, IODevices) ---------------- */
63
64
/* Declare devices, image types, init procedures, and IODevices as extern. */
65
#define compositor_(comp_type) extern gs_composite_type_t comp_type;
66
#define device_(dev) extern gx_device dev;
67
#define device2_(dev) extern const gx_device dev;
68
#define halftone_(dht) extern DEVICE_HALFTONE_RESOURCE_PROC(dht);
69
#define image_class_(cls) extern iclass_proc(cls);
70
#define image_type_(i,type) extern const gx_image_type_t type;
71
#define init_(proc) extern init_proc(proc);
72
#define io_device_(iodev) extern const gx_io_device iodev;
73
#include "gconf.h"
74
#undef io_device_
75
#undef init_
76
#undef image_type_
77
#undef image_class_
78
#undef halftone_
79
#undef device2_
80
#undef device_
81
#undef compositor_
82
83
/* Set up compositor type table. */
84
#define compositor_(comp_type) &comp_type,
85
static const gs_composite_type_t *const gx_compositor_list[] = {
86
#include "gconf.h"
87
    0
88
};
89
#undef compositor_
90
91
/* Set up the device table. */
92
#define device_(dev) (const gx_device *)&dev,
93
#define device2_(dev) &dev,
94
static const gx_device *gx_device_list[1024] = {
95
  /* as shared library are adding drivers here, so removed constness */
96
#include "gconf.h"
97
         0
98
};
99
#undef device2_
100
#undef device_
101
102
/* Set up the (device) halftone table. */
103
extern_gx_device_halftone_list();
104
#define halftone_(dht) dht,
105
const gx_dht_proc gx_device_halftone_list[] = {
106
#include "gconf.h"
107
    0
108
};
109
#undef halftone_
110
111
/* Set up the image class table. */
112
extern_gx_image_class_table();
113
#define image_class_(cls) cls,
114
const gx_image_class_t gx_image_class_table[] = {
115
#include "gconf.h"
116
    0
117
};
118
#undef image_class_
119
/* We must use unsigned here, not uint.  See gscdefs.h. */
120
const unsigned gx_image_class_table_count = countof(gx_image_class_table) - 1;
121
122
/* Set up the image type table. */
123
extern_gx_image_type_table();
124
#define image_type_(i,type) &type,
125
const gx_image_type_t *const gx_image_type_table[] = {
126
#include "gconf.h"
127
    0
128
};
129
#undef image_type_
130
/* We must use unsigned here, not uint.  See gscdefs.h. */
131
const unsigned gx_image_type_table_count = countof(gx_image_type_table) - 1;
132
133
/* Set up the initialization procedure table. */
134
extern_gx_init_table();
135
#define init_(proc) proc,
136
const gx_init_proc gx_init_table[] = {
137
#include "gconf.h"
138
    0
139
};
140
#undef init_
141
142
/* Set up the IODevice table.  The first entry must be %os%, */
143
/* since it is the default for files with no explicit device specified. */
144
extern_gx_io_device_table();
145
extern gx_io_device gs_iodev_os;
146
#define io_device_(iodev) &iodev,
147
const gx_io_device *const gx_io_device_table[] = {
148
    &gs_iodev_os,
149
#include "gconf.h"
150
    0
151
};
152
#undef io_device_
153
/* We must use unsigned here, not uint.  See gscdefs.h. */
154
const unsigned gx_io_device_table_count = countof(gx_io_device_table) - 1;
155
156
/* Find a compositor by name. */
157
extern_gs_find_compositor();
158
const gs_composite_type_t *
159
gs_find_compositor(int comp_id)
160
266M
{
161
266M
    const gs_composite_type_t *const * ppcomp = gx_compositor_list;
162
266M
    const gs_composite_type_t *  pcomp;
163
164
343M
    while ((pcomp = *ppcomp++) != 0 && pcomp->comp_id != comp_id)
165
76.8M
        ;
166
266M
    return pcomp;
167
266M
}
168
169
/* Return the list of device prototypes, a NULL list of their structure */
170
/* descriptors (no longer used), and (as the value) the length of the lists. */
171
extern_gs_lib_device_list();
172
int
173
gs_lib_device_list(const gx_device * const **plist,
174
                   gs_memory_struct_type_t ** pst)
175
7.14M
{
176
7.14M
    int i;
177
178
7.14M
    if (plist != 0)
179
7.14M
        *plist = gx_device_list;
180
7.14M
    if (pst != 0)
181
0
        *pst = NULL;
182
183
157M
    for (i = 0; i < countof(gx_device_list) - 1; ++i)
184
157M
      if (!gx_device_list[i])
185
7.14M
        break;
186
7.14M
    return i;
187
7.14M
}
188
189
/* Font API support  */
190
#define fapi_(func) extern fapi_init_func(func);
191
#include "gconf.h"
192
#undef fapi_
193
194
gs_fapi_server_init_func gs_fapi_server_inits[] = {
195
#define fapi_(init_func) init_func,
196
#include "gconf.h"
197
#undef fapi_
198
  NULL
199
};
200
201
extern_gs_get_fapi_server_inits();
202
203
const gs_fapi_server_init_func *
204
gs_get_fapi_server_inits(void)
205
162k
{
206
162k
    return(gs_fapi_server_inits);
207
162k
}
208
209
#ifdef GS_DEVS_SHARED
210
void
211
gs_lib_register_device(const gx_device *dev)
212
{
213
  int i;
214
215
  for (i = 0; i < countof(gx_device_list) - 1; ++i)
216
    if (!gx_device_list[i]) {
217
      gx_device_list[i] = dev;
218
      return;
219
    }
220
}
221
#endif