~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to src/zusparam.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: zusparam.c 8022 2007-06-05 22:23:38Z giles $ */
 
14
/* $Id: zusparam.c 8329 2007-10-28 17:17:47Z alexcher $ */
15
15
/* User and system parameter operators */
16
16
#include "memory_.h"
17
17
#include "string_.h"
86
86
} param_set;
87
87
 
88
88
/* Forward references */
89
 
private int setparams(i_ctx_t *, gs_param_list *, const param_set *);
90
 
private int currentparams(i_ctx_t *, const param_set *);
91
 
private int currentparam1(i_ctx_t *, const param_set *);
 
89
static int setparams(i_ctx_t *, gs_param_list *, const param_set *);
 
90
static int currentparams(i_ctx_t *, const param_set *);
 
91
static int currentparam1(i_ctx_t *, const param_set *);
92
92
 
93
93
/* ------ Passwords ------ */
94
94
 
95
95
/* <string|int> .checkpassword <0|1|2> */
96
 
private int
 
96
static int
97
97
zcheckpassword(i_ctx_t *i_ctx_p)
98
98
{
99
99
    os_ptr op = osp;
124
124
/* ------ System parameters ------ */
125
125
 
126
126
/* Integer values */
127
 
private long
 
127
static long
128
128
current_BuildTime(i_ctx_t *i_ctx_p)
129
129
{
130
130
    return gs_buildtime;
131
131
}
132
 
private long
 
132
static long
133
133
current_MaxFontCache(i_ctx_t *i_ctx_p)
134
134
{
135
135
    return gs_currentcachesize(ifont_dir);
136
136
}
137
 
private int
 
137
static int
138
138
set_MaxFontCache(i_ctx_t *i_ctx_p, long val)
139
139
{
140
140
    return gs_setcachesize(ifont_dir,
141
141
                           (uint)(val < 0 ? 0 : val > max_uint ? max_uint :
142
142
                                   val));
143
143
}
144
 
private long
 
144
static long
145
145
current_CurFontCache(i_ctx_t *i_ctx_p)
146
146
{
147
147
    uint cstat[7];
149
149
    gs_cachestatus(ifont_dir, cstat);
150
150
    return cstat[0];
151
151
}
152
 
private long
 
152
static long
153
153
current_MaxGlobalVM(i_ctx_t *i_ctx_p)
154
154
{
155
155
    gs_memory_gc_status_t stat;
157
157
    gs_memory_gc_status(iimemory_global, &stat);
158
158
    return stat.max_vm;
159
159
}
160
 
private int
 
160
static int
161
161
set_MaxGlobalVM(i_ctx_t *i_ctx_p, long val)
162
162
{
163
163
    gs_memory_gc_status_t stat;
167
167
    gs_memory_set_gc_status(iimemory_global, &stat);
168
168
    return 0;
169
169
}
170
 
private long
 
170
static long
171
171
current_Revision(i_ctx_t *i_ctx_p)
172
172
{
173
173
    return gs_revision;
174
174
}
175
 
private const long_param_def_t system_long_params[] =
 
175
static const long_param_def_t system_long_params[] =
176
176
{
177
177
    {"BuildTime", min_long, max_long, current_BuildTime, NULL},
178
178
{"MaxFontCache", 0, MAX_UINT_PARAM, current_MaxFontCache, set_MaxFontCache},
183
183
};
184
184
 
185
185
/* Boolean values */
186
 
private bool
 
186
static bool
187
187
current_ByteOrder(i_ctx_t *i_ctx_p)
188
188
{
189
189
    return !arch_is_big_endian;
190
190
}
191
 
private const bool_param_def_t system_bool_params[] =
 
191
static const bool_param_def_t system_bool_params[] =
192
192
{
193
193
    {"ByteOrder", current_ByteOrder, NULL}
194
194
};
195
195
 
196
196
/* String values */
197
 
private void
 
197
static void
198
198
current_RealFormat(i_ctx_t *i_ctx_p, gs_param_string * pval)
199
199
{
200
200
#if ARCH_FLOATS_ARE_IEEE
207
207
    pval->size = strlen(rfs);
208
208
    pval->persistent = true;
209
209
}
210
 
private const string_param_def_t system_string_params[] =
 
210
static const string_param_def_t system_string_params[] =
211
211
{
212
212
    {"RealFormat", current_RealFormat, NULL}
213
213
};
214
214
 
215
215
/* The system parameter set */
216
 
private const param_set system_param_set =
 
216
static const param_set system_param_set =
217
217
{
218
218
    system_long_params, countof(system_long_params),
219
219
    system_bool_params, countof(system_bool_params),
221
221
};
222
222
 
223
223
/* <dict> .setsystemparams - */
224
 
private int
 
224
static int
225
225
zsetsystemparams(i_ctx_t *i_ctx_p)
226
226
{
227
227
    os_ptr op = osp;
286
286
}
287
287
 
288
288
/* - .currentsystemparams <name1> <value1> ... */
289
 
private int
 
289
static int
290
290
zcurrentsystemparams(i_ctx_t *i_ctx_p)
291
291
{
292
292
    return currentparams(i_ctx_p, &system_param_set);
293
293
}
294
294
 
295
295
/* <name> .getsystemparam <value> */
296
 
private int
 
296
static int
297
297
zgetsystemparam(i_ctx_t *i_ctx_p)
298
298
{
299
299
    return currentparam1(i_ctx_p, &system_param_set);
302
302
/* ------ User parameters ------ */
303
303
 
304
304
/* Integer values */
305
 
private long
 
305
static long
306
306
current_JobTimeout(i_ctx_t *i_ctx_p)
307
307
{
308
308
    return 0;
309
309
}
310
 
private int
 
310
static int
311
311
set_JobTimeout(i_ctx_t *i_ctx_p, long val)
312
312
{
313
313
    return 0;
314
314
}
315
 
private long
 
315
static long
316
316
current_MaxFontItem(i_ctx_t *i_ctx_p)
317
317
{
318
318
    return gs_currentcacheupper(ifont_dir);
319
319
}
320
 
private int
 
320
static int
321
321
set_MaxFontItem(i_ctx_t *i_ctx_p, long val)
322
322
{
323
323
    return gs_setcacheupper(ifont_dir, val);
324
324
}
325
 
private long
 
325
static long
326
326
current_MinFontCompress(i_ctx_t *i_ctx_p)
327
327
{
328
328
    return gs_currentcachelower(ifont_dir);
329
329
}
330
 
private int
 
330
static int
331
331
set_MinFontCompress(i_ctx_t *i_ctx_p, long val)
332
332
{
333
333
    return gs_setcachelower(ifont_dir, val);
334
334
}
335
 
private long
 
335
static long
336
336
current_MaxOpStack(i_ctx_t *i_ctx_p)
337
337
{
338
338
    return ref_stack_max_count(&o_stack);
339
339
}
340
 
private int
 
340
static int
341
341
set_MaxOpStack(i_ctx_t *i_ctx_p, long val)
342
342
{
343
343
    return ref_stack_set_max_count(&o_stack, val);
344
344
}
345
 
private long
 
345
static long
346
346
current_MaxDictStack(i_ctx_t *i_ctx_p)
347
347
{
348
348
    return ref_stack_max_count(&d_stack);
349
349
}
350
 
private int
 
350
static int
351
351
set_MaxDictStack(i_ctx_t *i_ctx_p, long val)
352
352
{
353
353
    return ref_stack_set_max_count(&d_stack, val);
354
354
}
355
 
private long
 
355
static long
356
356
current_MaxExecStack(i_ctx_t *i_ctx_p)
357
357
{
358
358
    return ref_stack_max_count(&e_stack);
359
359
}
360
 
private int
 
360
static int
361
361
set_MaxExecStack(i_ctx_t *i_ctx_p, long val)
362
362
{
363
363
    return ref_stack_set_max_count(&e_stack, val);
364
364
}
365
 
private long
 
365
static long
366
366
current_MaxLocalVM(i_ctx_t *i_ctx_p)
367
367
{
368
368
    gs_memory_gc_status_t stat;
370
370
    gs_memory_gc_status(iimemory_local, &stat);
371
371
    return stat.max_vm;
372
372
}
373
 
private int
 
373
static int
374
374
set_MaxLocalVM(i_ctx_t *i_ctx_p, long val)
375
375
{
376
376
    gs_memory_gc_status_t stat;
380
380
    gs_memory_set_gc_status(iimemory_local, &stat);
381
381
    return 0;
382
382
}
383
 
private long
 
383
static long
384
384
current_VMReclaim(i_ctx_t *i_ctx_p)
385
385
{
386
386
    gs_memory_gc_status_t gstat, lstat;
389
389
    gs_memory_gc_status(iimemory_local, &lstat);
390
390
    return (!gstat.enabled ? -2 : !lstat.enabled ? -1 : 0);
391
391
}
392
 
private long
 
392
static long
393
393
current_VMThreshold(i_ctx_t *i_ctx_p)
394
394
{
395
395
    gs_memory_gc_status_t stat;
397
397
    gs_memory_gc_status(iimemory_local, &stat);
398
398
    return stat.vm_threshold;
399
399
}
400
 
private long
 
400
static long
401
401
current_WaitTimeout(i_ctx_t *i_ctx_p)
402
402
{
403
403
    return 0;
404
404
}
405
 
private int
 
405
static int
406
406
set_WaitTimeout(i_ctx_t *i_ctx_p, long val)
407
407
{
408
408
    return 0;
409
409
}
410
 
private long
 
410
static long
411
411
current_MinScreenLevels(i_ctx_t *i_ctx_p)
412
412
{
413
413
    return gs_currentminscreenlevels();
414
414
}
415
 
private int
 
415
static int
416
416
set_MinScreenLevels(i_ctx_t *i_ctx_p, long val)
417
417
{
418
418
    gs_setminscreenlevels((uint) val);
419
419
    return 0;
420
420
}
421
 
private long
 
421
static long
422
422
current_AlignToPixels(i_ctx_t *i_ctx_p)
423
423
{
424
424
    return gs_currentaligntopixels(ifont_dir);
425
425
}
426
 
private int
 
426
static int
427
427
set_AlignToPixels(i_ctx_t *i_ctx_p, long val)
428
428
{
429
429
    gs_setaligntopixels(ifont_dir, (uint)val);
430
430
    return 0;
431
431
}
432
 
private long
 
432
static long
433
433
current_GridFitTT(i_ctx_t *i_ctx_p)
434
434
{
435
435
    return gs_currentgridfittt(ifont_dir);
436
436
}
437
 
private int
 
437
static int
438
438
set_GridFitTT(i_ctx_t *i_ctx_p, long val)
439
439
{
440
440
    gs_setgridfittt(ifont_dir, (uint)val);
441
441
    return 0;
442
442
}
443
 
private const long_param_def_t user_long_params[] =
 
443
static const long_param_def_t user_long_params[] =
444
444
{
445
445
    {"JobTimeout", 0, MAX_UINT_PARAM,
446
446
     current_JobTimeout, set_JobTimeout},
472
472
};
473
473
 
474
474
/* Boolean values */
475
 
private bool
 
475
static bool
476
476
current_AccurateScreens(i_ctx_t *i_ctx_p)
477
477
{
478
478
    return gs_currentaccuratescreens();
479
479
}
480
 
private int
 
480
static int
481
481
set_AccurateScreens(i_ctx_t *i_ctx_p, bool val)
482
482
{
483
483
    gs_setaccuratescreens(val);
484
484
    return 0;
485
485
}
486
486
/* Boolean values */
487
 
private bool
 
487
static bool
488
488
current_UseWTS(i_ctx_t *i_ctx_p)
489
489
{
490
490
    return gs_currentusewts();
491
491
}
492
 
private int
 
492
static int
493
493
set_UseWTS(i_ctx_t *i_ctx_p, bool val)
494
494
{
495
495
    gs_setusewts(val);
496
496
    return 0;
497
497
}
498
 
private bool
 
498
static bool
499
499
current_LockFilePermissions(i_ctx_t *i_ctx_p)
500
500
{
501
501
    return i_ctx_p->LockFilePermissions;
502
502
}
503
 
private int
 
503
static int
504
504
set_LockFilePermissions(i_ctx_t *i_ctx_p, bool val)
505
505
{
506
506
    /* allow locking even if already locked */
509
509
    i_ctx_p->LockFilePermissions = val;
510
510
    return 0;
511
511
}
512
 
private const bool_param_def_t user_bool_params[] =
 
512
static const bool_param_def_t user_bool_params[] =
513
513
{
514
514
    {"AccurateScreens", current_AccurateScreens, set_AccurateScreens},
515
515
    {"UseWTS", current_UseWTS, set_UseWTS},
517
517
};
518
518
 
519
519
/* The user parameter set */
520
 
private const param_set user_param_set =
 
520
static const param_set user_param_set =
521
521
{
522
522
    user_long_params, countof(user_long_params),
523
523
    user_bool_params, countof(user_bool_params),
540
540
    iparam_list_release(&list);
541
541
    return code;
542
542
}
543
 
private int
 
543
static int
544
544
zsetuserparams(i_ctx_t *i_ctx_p)
545
545
{
546
546
    os_ptr op = osp;
556
556
}
557
557
 
558
558
/* - .currentuserparams <name1> <value1> ... */
559
 
private int
 
559
static int
560
560
zcurrentuserparams(i_ctx_t *i_ctx_p)
561
561
{
562
562
    return currentparams(i_ctx_p, &user_param_set);
563
563
}
564
564
 
565
565
/* <name> .getuserparam <value> */
566
 
private int
 
566
static int
567
567
zgetuserparam(i_ctx_t *i_ctx_p)
568
568
{
569
569
    return currentparam1(i_ctx_p, &user_param_set);
591
591
 
592
592
/* Set the values of a parameter set from a parameter list. */
593
593
/* We don't attempt to back out if anything fails. */
594
 
private int
 
594
static int
595
595
setparams(i_ctx_t *i_ctx_p, gs_param_list * plist, const param_set * pset)
596
596
{
597
597
    int i, code;
633
633
}
634
634
 
635
635
/* Get the current values of a parameter set to the stack. */
636
 
private bool
 
636
static bool
637
637
pname_matches(const char *pname, const ref * psref)
638
638
{
639
639
    return
641
641
         !bytes_compare((const byte *)pname, strlen(pname),
642
642
                        psref->value.const_bytes, r_size(psref)));
643
643
}
644
 
private int
 
644
static int
645
645
current_param_list(i_ctx_t *i_ctx_p, const param_set * pset,
646
646
                   const ref * psref /*t_string */ )
647
647
{
684
684
                return code;
685
685
        }
686
686
    }
 
687
    if (psref) {
 
688
        /*
 
689
         * Scanner options can be read, but only individually by .getuserparam.
 
690
         * This avoids putting them into userparams, and being affected by save/restore.
 
691
         */
 
692
        const char *pname;
 
693
        bool val;
 
694
        int code;
 
695
 
 
696
        switch (ztoken_get_scanner_option(psref, i_ctx_p->scanner_options, &pname)) {
 
697
            case 0:
 
698
                code = param_write_null(plist, pname);
 
699
                break;
 
700
            case 1:
 
701
                val = true;
 
702
                code = param_write_bool(plist, pname, &val);
 
703
                break;
 
704
            default:
 
705
                code = 0;
 
706
                break;
 
707
        }
 
708
        if (code < 0)
 
709
            return code;
 
710
    }
687
711
#if ENABLE_CUSTOM_COLOR_CALLBACK
688
712
    if (pset == &system_param_set) {
689
713
        /* The custom_color callback pointer */
695
719
}
696
720
 
697
721
/* Get the current values of a parameter set to the stack. */
698
 
private int
 
722
static int
699
723
currentparams(i_ctx_t *i_ctx_p, const param_set * pset)
700
724
{
701
725
    return current_param_list(i_ctx_p, pset, NULL);
702
726
}
703
727
 
704
728
/* Get the value of a single parameter to the stack, or signal an error. */
705
 
private int
 
729
static int
706
730
currentparam1(i_ctx_t *i_ctx_p, const param_set * pset)
707
731
{
708
732
    os_ptr op = osp;