Coverage Report

Created: 2025-06-10 06:56

/src/ghostpdl/base/gscparam.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
17
/* Default implementation of parameter lists */
18
#include "memory_.h"
19
#include "string_.h"
20
#include "gx.h"
21
#include "gserrors.h"
22
#include "gsparam.h"
23
#include "gsstruct.h"
24
25
/* Forward references */
26
typedef union c_param_value_s {
27
    GS_PARAM_VALUE_UNION(gs_c_param_list);
28
} gs_c_param_value;
29
/*typedef struct gs_c_param_s gs_c_param; *//* in gsparam.h */
30
31
/* Define the GC type for a parameter list. */
32
private_st_c_param_list();
33
34
/* Lengths corresponding to various gs_param_type_xxx types */
35
const byte gs_param_type_sizes[] = {
36
    GS_PARAM_TYPE_SIZES(sizeof(gs_c_param_list))
37
};
38
39
/* Lengths of *actual* data-containing type pointed to or contained by gs_param_type_xxx's */
40
const byte gs_param_type_base_sizes[] = {
41
    GS_PARAM_TYPE_BASE_SIZES(0)
42
};
43
44
/*
45
 * Define a parameter list element.  We use gs_param_type_any to identify
46
 * elements that have been requested but not yet written.  The reading
47
 * procedures must recognize such elements as undefined, and ignore them.
48
 */
49
struct gs_c_param_s {
50
    gs_c_param *next;
51
    gs_param_key_t key;
52
    bool free_key;
53
    gs_c_param_value value;
54
    gs_param_type type;
55
    void *alternate_typed_data;
56
    int error;
57
};
58
59
/* GC descriptor and procedures */
60
gs_private_st_composite(st_c_param, gs_c_param, "gs_c_param",
61
                        c_param_enum_ptrs, c_param_reloc_ptrs);
62
304k
ENUM_PTRS_WITH(c_param_enum_ptrs, gs_c_param *param) {
63
121k
    index -= 3;
64
121k
    switch (param->type) {
65
        /* Only the aggregate types are handled specially. */
66
0
    case gs_param_type_dict:
67
0
    case gs_param_type_dict_int_keys:
68
0
    case gs_param_type_array:
69
0
        return ENUM_USING(st_c_param_list, &param->value.d,
70
0
                          sizeof(param->value.d), index);
71
121k
    default: {
72
121k
        gs_param_typed_value value;
73
74
121k
        value.value = *(const gs_param_value *)&param->value;
75
121k
        value.type = param->type;
76
121k
        return gs_param_typed_value_enum_ptrs(mem, &value, sizeof(value), index,
77
121k
                                              pep, NULL, gcst);
78
0
    }
79
121k
    }
80
121k
}
81
60.8k
case 0: return ENUM_OBJ(param->next);
82
60.8k
case 1: return ENUM_OBJ(param->alternate_typed_data);
83
60.8k
case 2:
84
60.8k
    if (!param->key.persistent) {
85
60.8k
        gs_const_string key;
86
87
60.8k
        key.data = param->key.data;
88
60.8k
        key.size = param->key.size;
89
60.8k
        return ENUM_STRING(&key);
90
60.8k
    } else
91
0
        return ENUM_OBJ(0);  /* keep going */
92
304k
ENUM_PTRS_END
93
60.8k
RELOC_PTRS_WITH(c_param_reloc_ptrs, gs_c_param *param) {
94
60.8k
    RELOC_VAR(param->next);
95
60.8k
    RELOC_VAR(param->alternate_typed_data);
96
60.8k
    if (!param->key.persistent) {
97
60.8k
        gs_const_string key;
98
99
60.8k
        key.data = param->key.data;
100
60.8k
        key.size = param->key.size;
101
60.8k
        RELOC_CONST_STRING_VAR(key);
102
60.8k
        param->key.data = key.data;
103
60.8k
    }
104
60.8k
    switch (param->type) {
105
        /* Only the aggregate types are handled specially. */
106
0
    case gs_param_type_dict:
107
0
    case gs_param_type_dict_int_keys:
108
0
    case gs_param_type_array:
109
0
        RELOC_USING(st_c_param_list, &param->value.d, sizeof(param->value.d));
110
0
        break;
111
60.8k
    default: {
112
60.8k
        gs_param_typed_value value;
113
114
60.8k
        value.value = *(gs_param_value *)&param->value;
115
60.8k
        value.type = param->type;
116
60.8k
        gs_param_typed_value_reloc_ptrs(&value, sizeof(value), NULL, gcst);
117
60.8k
        *(gs_param_value *)&param->value = value.value;
118
60.8k
    }
119
60.8k
    }
120
60.8k
}
121
60.8k
RELOC_PTRS_END
122
123
/* ---------------- Utilities ---------------- */
124
125
gs_c_param_list *
126
gs_c_param_list_alloc(gs_memory_t *mem, client_name_t cname)
127
8.92k
{
128
8.92k
    return gs_alloc_struct(mem, gs_c_param_list, &st_c_param_list, cname);
129
8.92k
}
130
131
void gs_c_param_list_free(gs_memory_t *mem, gs_c_param_list *plist, client_name_t cname)
132
0
{
133
0
    if (plist == NULL)
134
0
        return;
135
0
    gs_c_param_list_release(plist);
136
0
    gs_free_object(mem, plist, cname);
137
0
}
138
139
static gs_c_param *
140
c_param_find(const gs_c_param_list *plist, gs_param_name pkey, bool any)
141
0
{
142
0
    gs_c_param *pparam = plist->head;
143
0
    uint len = strlen(pkey);
144
145
0
    for (; pparam != 0; pparam = pparam->next)
146
0
        if (pparam->key.size == len && !memcmp(pparam->key.data, pkey, len))
147
0
            return (pparam->type != gs_param_type_any || any ? pparam : 0);
148
0
    return 0;
149
0
}
150
151
/* ---------------- Writing parameters to a list ---------------- */
152
153
static param_proc_begin_xmit_collection(c_param_begin_write_collection);
154
static param_proc_end_xmit_collection(c_param_end_write_collection);
155
static param_proc_xmit_typed(c_param_write_typed);
156
static param_proc_request(c_param_request);
157
static param_proc_requested(c_param_requested);
158
static const gs_param_list_procs c_write_procs =
159
{
160
    c_param_write_typed,
161
    c_param_begin_write_collection,
162
    c_param_end_write_collection,
163
    NULL,     /* get_next_key */
164
    c_param_request,
165
    c_param_requested
166
};
167
168
/* Initialize a list for writing. */
169
void
170
gs_c_param_list_write(gs_c_param_list * plist, gs_memory_t * mem)
171
30.6k
{
172
30.6k
    plist->memory = mem;
173
30.6k
    plist->head = 0;
174
30.6k
    plist->target = 0;    /* not used for writing */
175
30.6k
    plist->count = 0;
176
30.6k
    plist->any_requested = false;
177
30.6k
    plist->persistent_keys = true;
178
30.6k
    gs_c_param_list_write_more(plist);
179
30.6k
}
180
181
/* Set the target of a list.  Only relevant for reading. */
182
void
183
gs_c_param_list_set_target(gs_c_param_list *plist, gs_param_list *target)
184
0
{
185
0
    plist->target = target;
186
0
}
187
188
/* Re-enable a list for writing, without clearing it. */
189
/* gs_c_param_list_write must have been called previously. */
190
void
191
gs_c_param_list_write_more(gs_c_param_list * plist)
192
30.6k
{
193
30.6k
    plist->procs = &c_write_procs;
194
30.6k
    plist->coll_type = gs_param_collection_dict_any;
195
30.6k
}
196
197
/* Release a list. */
198
void
199
gs_c_param_list_release(gs_c_param_list * plist)
200
23.4k
{
201
23.4k
    gs_memory_t *mem = plist->memory;
202
23.4k
    gs_c_param *pparam;
203
204
23.4k
    while ((pparam = plist->head) != 0) {
205
0
        gs_c_param *next = pparam->next;
206
207
0
        switch (pparam->type) {
208
0
            case gs_param_type_dict:
209
0
            case gs_param_type_dict_int_keys:
210
0
            case gs_param_type_array:
211
0
                gs_c_param_list_release(&pparam->value.d);
212
0
                break;
213
0
            case gs_param_type_string:
214
0
            case gs_param_type_name:
215
0
            case gs_param_type_int_array:
216
0
            case gs_param_type_float_array:
217
0
            case gs_param_type_string_array:
218
0
            case gs_param_type_name_array:
219
0
                if (!pparam->value.s.persistent)
220
0
                    gs_free_const_object(mem, pparam->value.s.data,
221
0
                                         "gs_c_param_list_release data");
222
0
                break;
223
0
            default:
224
0
                break;
225
0
        }
226
0
        if (pparam->free_key) {
227
            /* We allocated this, so we must free it. */
228
0
            gs_free_const_string(mem, pparam->key.data, pparam->key.size,
229
0
                                 "gs_c_param_list_release key");
230
0
        }
231
0
        gs_free_object(mem, pparam->alternate_typed_data,
232
0
                       "gs_c_param_list_release alternate data");
233
0
        gs_free_object(mem, pparam,
234
0
                       "gs_c_param_list_release entry");
235
0
        plist->head = next;
236
0
        plist->count--;
237
0
    }
238
23.4k
}
239
240
/* Add an entry to a list.  Doesn't set: value, type, plist->head. */
241
static gs_c_param *
242
c_param_add(gs_c_param_list * plist, gs_param_name pkey)
243
30.3k
{
244
30.3k
    gs_c_param *pparam =
245
30.3k
        gs_alloc_struct(plist->memory, gs_c_param, &st_c_param,
246
30.3k
                        "c_param_add entry");
247
30.3k
    uint len;
248
249
30.3k
    if ((pparam == NULL) || (pkey == NULL))
250
0
        return NULL;
251
252
30.3k
    len = strlen(pkey);
253
30.3k
    pparam->next = plist->head;
254
30.3k
    if (!plist->persistent_keys) {
255
        /* We must copy the key. */
256
30.3k
        byte *str = gs_alloc_string(plist->memory, len, "c_param_add key");
257
258
30.3k
        if (str == 0) {
259
0
            gs_free_object(plist->memory, pparam, "c_param_add entry");
260
0
            return 0;
261
0
        }
262
30.3k
        memcpy(str, pkey, len);
263
30.3k
        pparam->key.data = str;
264
30.3k
        pparam->key.persistent = false; /* we will free it */
265
30.3k
        pparam->free_key = true;
266
30.3k
    } else {
267
0
        pparam->key.data = (const byte *)pkey;
268
0
        pparam->key.persistent = true;
269
0
        pparam->free_key = false;
270
0
    }
271
30.3k
    pparam->key.size = len;
272
30.3k
    pparam->alternate_typed_data = 0;
273
30.3k
    pparam->error = 0;
274
30.3k
    return pparam;
275
30.3k
}
276
277
/*  Write a dynamically typed parameter to a list. */
278
static int
279
c_param_write(gs_c_param_list * plist, gs_param_name pkey, void *pvalue,
280
              gs_param_type type)
281
30.3k
{
282
30.3k
    unsigned top_level_sizeof = 0;
283
30.3k
    unsigned second_level_sizeof = 0;
284
30.3k
    gs_c_param *pparam = c_param_add(plist, pkey);
285
286
30.3k
    if (pparam == 0)
287
0
        return_error(gs_error_VMerror);
288
30.3k
    memcpy(&pparam->value, pvalue, gs_param_type_sizes[(int)type]);
289
30.3k
    pparam->type = type;
290
291
    /* Need deeper copies of data if it's not persistent */
292
30.3k
    switch (type) {
293
0
            gs_param_string const *curr_string;
294
0
            gs_param_string const *end_string;
295
296
0
        case gs_param_type_string_array:
297
0
        case gs_param_type_name_array:
298
            /* Determine how much mem needed to hold actual string data */
299
0
            curr_string = pparam->value.sa.data;
300
0
            end_string = curr_string + pparam->value.sa.size;
301
0
            for (; curr_string < end_string; ++curr_string)
302
0
                if (!curr_string->persistent)
303
0
                    second_level_sizeof += curr_string->size;
304
            /* fall thru */
305
306
0
        case gs_param_type_string:
307
0
        case gs_param_type_name:
308
14.2k
        case gs_param_type_int_array:
309
14.2k
        case gs_param_type_float_array:
310
14.2k
            if (!pparam->value.s.persistent) { /* Allocate & copy object pointed to by array or string */
311
14.2k
                byte *top_level_memory = NULL;
312
313
14.2k
                top_level_sizeof =
314
14.2k
                    pparam->value.s.size * gs_param_type_base_sizes[type];
315
14.2k
                if (top_level_sizeof + second_level_sizeof > 0) {
316
14.2k
                    top_level_memory =
317
14.2k
                        gs_alloc_bytes_immovable(plist->memory,
318
14.2k
                                     top_level_sizeof + second_level_sizeof,
319
14.2k
                                             "c_param_write data");
320
14.2k
                    if (top_level_memory == 0) {
321
0
                        if (pparam->key.persistent == false) {
322
0
                            gs_free_string(plist->memory, (byte *)(pparam->key.data),
323
0
                                strlen((const char *)(pparam->key.data)), "c_param_add key");
324
0
                        }
325
0
                        gs_free_object(plist->memory, pparam, "c_param_write entry");
326
0
                        return_error(gs_error_VMerror);
327
0
                    }
328
14.2k
                    memcpy(top_level_memory, pparam->value.s.data, top_level_sizeof);
329
14.2k
                }
330
14.2k
                pparam->value.s.data = top_level_memory;
331
332
                /* String/name arrays need to copy actual str data */
333
334
14.2k
                if (second_level_sizeof > 0) {
335
0
                    byte *second_level_memory =
336
0
                    top_level_memory + top_level_sizeof;
337
338
0
                    curr_string = pparam->value.sa.data;
339
0
                    end_string = curr_string + pparam->value.sa.size;
340
0
                    for (; curr_string < end_string; ++curr_string)
341
0
                        if (!curr_string->persistent) {
342
0
                            memcpy(second_level_memory,
343
0
                                   curr_string->data, curr_string->size);
344
0
                            ((gs_param_string *) curr_string)->data
345
0
                                = second_level_memory;
346
0
                            second_level_memory += curr_string->size;
347
0
                        }
348
0
                }
349
14.2k
            }
350
14.2k
            break;
351
16.0k
        default:
352
16.0k
            break;
353
30.3k
    }
354
355
30.3k
    plist->head = pparam;
356
30.3k
    plist->count++;
357
30.3k
    return 0;
358
30.3k
}
359
360
/* Individual writing routines. */
361
static int
362
c_param_begin_write_collection(gs_param_list * plist, gs_param_name pkey,
363
               gs_param_dict * pvalue, gs_param_collection_type_t coll_type)
364
0
{
365
0
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
366
0
    gs_c_param_list *dlist =
367
0
        gs_c_param_list_alloc(cplist->memory,
368
0
                              "c_param_begin_write_collection");
369
370
0
    if (dlist == 0)
371
0
        return_error(gs_error_VMerror);
372
0
    gs_c_param_list_write(dlist, cplist->memory);
373
0
    dlist->coll_type = coll_type;
374
0
    pvalue->list = (gs_param_list *) dlist;
375
0
    return 0;
376
0
}
377
static int
378
c_param_end_write_collection(gs_param_list * plist, gs_param_name pkey,
379
                             gs_param_dict * pvalue)
380
0
{
381
0
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
382
0
    gs_c_param_list *dlist = (gs_c_param_list *) pvalue->list;
383
0
    int code;
384
385
0
    code = c_param_write(cplist, pkey, pvalue->list,
386
0
                    (dlist->coll_type == gs_param_collection_dict_int_keys ?
387
0
                     gs_param_type_dict_int_keys :
388
0
                     dlist->coll_type == gs_param_collection_array ?
389
0
                     gs_param_type_array : gs_param_type_dict));
390
391
0
    gs_free_object(plist->memory, pvalue->list, "c_param_end_write_collection");
392
0
    pvalue->list = 0;
393
0
    return code;
394
0
}
395
static int
396
c_param_write_typed(gs_param_list * plist, gs_param_name pkey,
397
                    gs_param_typed_value * pvalue)
398
30.3k
{
399
30.3k
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
400
30.3k
    gs_param_collection_type_t coll_type;
401
402
30.3k
    switch (pvalue->type) {
403
0
        case gs_param_type_dict:
404
0
            coll_type = gs_param_collection_dict_any;
405
0
            break;
406
0
        case gs_param_type_dict_int_keys:
407
0
            coll_type = gs_param_collection_dict_int_keys;
408
0
            break;
409
0
        case gs_param_type_array:
410
0
            coll_type = gs_param_collection_array;
411
0
            break;
412
30.3k
        default:
413
30.3k
            return c_param_write(cplist, pkey, &pvalue->value, pvalue->type);
414
30.3k
    }
415
0
    return c_param_begin_write_collection
416
0
        (plist, pkey, &pvalue->value.d, coll_type);
417
30.3k
}
418
419
/* Other procedures */
420
421
static int
422
c_param_request(gs_param_list * plist, gs_param_name pkey)
423
0
{
424
0
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
425
0
    gs_c_param *pparam;
426
427
0
    cplist->any_requested = true;
428
0
    if (c_param_find(cplist, pkey, true))
429
0
        return 0;
430
0
    pparam = c_param_add(cplist, pkey);
431
0
    if (pparam == 0)
432
0
        return_error(gs_error_VMerror);
433
0
    pparam->type = gs_param_type_any; /* mark as undefined */
434
0
    cplist->head = pparam;
435
0
    return 0;
436
0
}
437
438
static int
439
c_param_requested(const gs_param_list * plist, gs_param_name pkey)
440
0
{
441
0
    const gs_c_param_list *const cplist = (const gs_c_param_list *)plist;
442
0
    gs_param_list *target = cplist->target;
443
0
    int code;
444
445
0
    if (!cplist->any_requested)
446
0
        return (target ? param_requested(target, pkey) : -1);
447
0
    if (c_param_find(cplist, pkey, true) != 0)
448
0
        return 1;
449
0
    if (!target)
450
0
        return 0;
451
0
    code = param_requested(target, pkey);
452
0
    return (code < 0 ? 0 : 1);
453
0
}
454
455
/* ---------------- Reading from a list to parameters ---------------- */
456
457
static param_proc_begin_xmit_collection(c_param_begin_read_collection);
458
static param_proc_end_xmit_collection(c_param_end_read_collection);
459
static param_proc_xmit_typed(c_param_read_typed);
460
static param_proc_next_key(c_param_get_next_key);
461
static param_proc_get_policy(c_param_read_get_policy);
462
static param_proc_signal_error(c_param_read_signal_error);
463
static param_proc_read_signalled_error(c_param_read_signalled_error);
464
static param_proc_commit(c_param_read_commit);
465
static const gs_param_list_procs c_read_procs =
466
{
467
    c_param_read_typed,
468
    c_param_begin_read_collection,
469
    c_param_end_read_collection,
470
    c_param_get_next_key,
471
    NULL,     /* request, N/A */
472
    NULL,     /* requested, N/A */
473
    c_param_read_get_policy,
474
    c_param_read_signal_error,
475
    c_param_read_commit,
476
    c_param_read_signalled_error
477
};
478
479
/* Switch a list from writing to reading. */
480
void
481
gs_c_param_list_read(gs_c_param_list * plist)
482
0
{
483
0
    plist->procs = &c_read_procs;
484
0
}
485
486
/* Generic routine for reading a parameter from a list. */
487
488
static int
489
c_param_read_typed(gs_param_list * plist, gs_param_name pkey,
490
                   gs_param_typed_value * pvalue)
491
0
{
492
0
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
493
0
    gs_param_type req_type = pvalue->type;
494
0
    gs_c_param *pparam = c_param_find(cplist, pkey, false);
495
0
    int code;
496
497
0
    if (pparam == 0)
498
0
        return (cplist->target ?
499
0
                param_read_typed(cplist->target, pkey, pvalue) : 1);
500
0
    pvalue->type = pparam->type;
501
0
    switch (pvalue->type) {
502
0
        case gs_param_type_dict:
503
0
        case gs_param_type_dict_int_keys:
504
0
        case gs_param_type_array:
505
0
            gs_c_param_list_read(&pparam->value.d);
506
0
            pvalue->value.d.list = (gs_param_list *) & pparam->value.d;
507
0
            pvalue->value.d.size = pparam->value.d.count;
508
0
            return 0;
509
0
        default:
510
0
            break;
511
0
    }
512
0
    memcpy(&pvalue->value, &pparam->value,
513
0
           gs_param_type_sizes[(int)pparam->type]);
514
0
    code = param_coerce_typed(pvalue, req_type, NULL);
515
/****** SHOULD LET param_coerce_typed DO THIS ******/
516
0
    if (code == gs_error_typecheck &&
517
0
        req_type == gs_param_type_float_array &&
518
0
        pvalue->type == gs_param_type_int_array
519
0
        ) {
520
        /* Convert int array to float dest */
521
0
        gs_param_float_array fa;
522
0
        int element;
523
524
0
        fa.size = pparam->value.ia.size;
525
0
        fa.persistent = false;
526
527
0
        if (pparam->alternate_typed_data == 0) {
528
0
            if ((pparam->alternate_typed_data
529
0
                 = (void *)gs_alloc_bytes_immovable(cplist->memory,
530
0
                                                    fa.size * sizeof(float),
531
0
                             "gs_c_param_read alternate float array")) == 0)
532
0
                      return_error(gs_error_VMerror);
533
534
0
            for (element = 0; element < fa.size; ++element)
535
0
                ((float *)(pparam->alternate_typed_data))[element]
536
0
                    = (float)pparam->value.ia.data[element];
537
0
        }
538
0
        fa.data = (float *)pparam->alternate_typed_data;
539
540
0
        pvalue->value.fa = fa;
541
0
        pvalue->type = req_type;
542
0
        return 0;
543
0
    }
544
0
    return code;
545
0
}
546
547
/* Individual reading routines. */
548
static int
549
c_param_begin_read_collection(gs_param_list * plist, gs_param_name pkey,
550
               gs_param_dict * pvalue, gs_param_collection_type_t coll_type)
551
0
{
552
0
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
553
0
    gs_c_param *pparam = c_param_find(cplist, pkey, false);
554
555
0
    if (pparam == 0)
556
0
        return
557
0
            (cplist->target ?
558
0
             param_begin_read_collection(cplist->target,
559
0
                                         pkey, pvalue, coll_type) :
560
0
             1);
561
0
    switch (pparam->type) {
562
0
        case gs_param_type_dict:
563
0
            if (coll_type != gs_param_collection_dict_any)
564
0
                return_error(gs_error_typecheck);
565
0
            break;
566
0
        case gs_param_type_dict_int_keys:
567
0
            if (coll_type == gs_param_collection_array)
568
0
                return_error(gs_error_typecheck);
569
0
            break;
570
0
        case gs_param_type_array:
571
0
            break;
572
0
        default:
573
0
            return_error(gs_error_typecheck);
574
0
    }
575
0
    gs_c_param_list_read(&pparam->value.d);
576
0
    pvalue->list = (gs_param_list *) & pparam->value.d;
577
0
    pvalue->size = pparam->value.d.count;
578
0
    return 0;
579
0
}
580
static int
581
c_param_end_read_collection(gs_param_list * plist, gs_param_name pkey,
582
                            gs_param_dict * pvalue)
583
0
{
584
0
    return 0;
585
0
}
586
587
/* Other procedures */
588
static int      /* ret 0 ok, 1 if EOF, or -ve err */
589
c_param_get_next_key(gs_param_list * plist, gs_param_enumerator_t * penum,
590
                     gs_param_key_t * key)
591
0
{
592
0
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
593
0
    gs_c_param *pparam =
594
0
    (penum->pvoid ? ((gs_c_param *) (penum->pvoid))->next :
595
0
     cplist->head);
596
597
0
    if (pparam == 0)
598
0
        return 1;
599
0
    penum->pvoid = pparam;
600
0
    *key = pparam->key;
601
0
    return 0;
602
0
}
603
static int
604
c_param_read_get_policy(gs_param_list * plist, gs_param_name pkey)
605
0
{
606
0
    return gs_param_policy_ignore;
607
0
}
608
static int
609
c_param_read_signal_error(gs_param_list * plist, gs_param_name pkey, int code)
610
0
{
611
0
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
612
0
    gs_c_param *pparam = c_param_find(cplist, pkey, false);
613
614
0
    if (pparam)
615
0
        pparam->error = code;
616
617
0
    return 0;
618
0
}
619
static int
620
c_param_read_commit(gs_param_list * plist)
621
0
{
622
0
    return 0;
623
0
}
624
static int
625
c_param_read_signalled_error(gs_param_list * plist, gs_param_name pkey)
626
0
{
627
0
    gs_c_param_list *const cplist = (gs_c_param_list *)plist;
628
0
    gs_c_param *pparam = c_param_find(cplist, pkey, false);
629
630
0
    return (pparam ? pparam->error : 0);
631
0
}