~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/gsnamecl.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2001-2006 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, modified
8
 
   or distributed except as expressly authorized under the terms of that
9
 
   license.  Refer to licensing information at http://www.artifex.com/
10
 
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11
 
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
 
*/
13
 
/* $Id: gsnamecl.c 8764 2008-05-21 18:27:42Z mvrhel $ */
14
 
/* Callback mechanism for handling color spaces containing named colors. */
15
 
 
16
 
/*
17
 
 * This module has been created to provide a callback mechanism for special
18
 
 * processing of DeviceN and Separation color spaces.  One possible application
19
 
 * of this callback mechanism is to provide a means for special handling of
20
 
 * PANTONE or SWOP colors.
21
 
 *
22
 
 * This implementation consists of four routines.  There are a pair of
23
 
 * routines for both Separation and DeviceN color spaces.  Each pair consists
24
 
 * of a routine that is called when the color space is installed and a
25
 
 * second routine that is called to transform colors in that color space
26
 
 * into device colorant values.  The routines named_color_install_Separation
27
 
 * and named_color_install_DeviceN are called when a Separation or DeviceN
28
 
 * color space is installed.  These routines determine if the given color space
29
 
 * meets some criteria decided by the client.  These routines return true if the
30
 
 * colors in the color space should be processed via the second routine.
31
 
 */
32
 
 
33
 
#include "stdpre.h"
34
 
#include "math_.h"
35
 
#include "memory_.h"
36
 
#include "gx.h"
37
 
#include "gserrors.h"
38
 
#include "gscdefs.h"
39
 
#include "gscspace.h"
40
 
#include "gxdevice.h"
41
 
#include "gzstate.h"
42
 
#include "gsutil.h"
43
 
#include "gsnamecl.h"  /* Custom color call back define */
44
 
 
45
 
#if ENABLE_CUSTOM_COLOR_CALLBACK        /* Defined in src/gsnamecl.h */
46
 
  
47
 
/*
48
 
 * Check if we want to use the callback color processing logic for the given
49
 
 * Separation color space.
50
 
 */
51
 
bool
52
 
custom_color_callback_install_Separation(gs_color_space * pcs, gs_state * pgs)
53
 
{
54
 
        client_custom_color_params_t * pcb =
55
 
        (client_custom_color_params_t *) pgs->memory->gs_lib_ctx->custom_color_callback;
56
 
 
57
 
    return (pcb == NULL) ? false
58
 
                         : pcb->client_procs->install_Separation(pcb, pcs, pgs);
59
 
}
60
 
 
61
 
/*
62
 
 * Check if we want to use the callback color processing logic for the given
63
 
 * DeviceN color space.
64
 
 */
65
 
bool
66
 
custom_color_callback_install_DeviceN(gs_color_space * pcs, gs_state * pgs)
67
 
{
68
 
    client_custom_color_params_t * pcb =
69
 
        (client_custom_color_params_t *) pgs->memory->gs_lib_ctx->custom_color_callback;
70
 
  
71
 
    return (pcb == NULL) ? false
72
 
                         : pcb->client_procs->install_DeviceN(pcb, pcs, pgs);
73
 
  }
74
 
  
75
 
/*
76
 
 * Convert a Separation color using the 'custom color' callback into
77
 
 * device color.
78
 
*/
79
 
int
80
 
gx_remap_concrete_custom_color_Separation(const frac * pconc,
81
 
        const gs_color_space * pcs, gx_device_color * pdc,
82
 
                const gs_imager_state * pis, gx_device * dev, gs_color_select_t select)
83
 
{
84
 
    client_custom_color_params_t * pcb =
85
 
        (client_custom_color_params_t *) pis->memory->gs_lib_ctx->custom_color_callback;
86
 
  
87
 
      if (pcb == NULL) {
88
 
        return_error(gs_error_rangecheck);
89
 
    }
90
 
    else
91
 
        return pcb->client_procs->remap_Separation(pcb, pconc,
92
 
                                        pcs, pdc, pis, dev, select);
93
 
}
94
 
 
95
 
/*
96
 
 * Convert a DeviceN color using the 'custom color' callback into device
97
 
 * color.
98
 
 */
99
 
int
100
 
gx_remap_concrete_custom_color_DeviceN(const frac * pconc,
101
 
        const gs_color_space * pcs, gx_device_color * pdc,
102
 
        const gs_imager_state * pis, gx_device * dev, gs_color_select_t select)
103
 
{
104
 
    client_custom_color_params_t * pcb =
105
 
        (client_custom_color_params_t *) pis->memory->gs_lib_ctx->custom_color_callback;
106
 
  
107
 
        if (pcb == NULL) {
108
 
                return_error(gs_error_rangecheck);
109
 
    }
110
 
    else
111
 
                return pcb->client_procs->remap_DeviceN(pcb, pconc,
112
 
                                        pcs, pdc, pis, dev, select);
113
 
}
114
 
 
115
 
/*
116
 
 * Get the 'custom color' client callback parameter block pointer.  This value
117
 
 * is passed as a string type device paramter.  A string is being used since
118
 
 * PostScript does not support pointers as a type.  Note:  An integer type
119
 
 * is not being used since PS intergers are nominally 32 bits.  Thus there
120
 
 * would be a problem using integers to pass pointer values on 64 bit systems.
121
 
 */
122
 
int
123
 
custom_color_callback_get_params(gs_state * pgs, gs_param_list * plist)
124
 
{
125
 
    /* Convert our pointer to a PostScript hex string */
126
 
    char buf[64] = "16#";
127
 
    int buf_pos = 3;
128
 
    gs_param_string custom_color_param;
129
 
    int idx;
130
 
    int val;
131
 
    size_t iptr;
132
 
 
133
 
    idx = ((int)sizeof(size_t)) * 8 - 4;
134
 
    iptr = (size_t)(pgs->memory->gs_lib_ctx->custom_color_callback);
135
 
    while (idx >= 0) {
136
 
        val = (int)(iptr >> idx) & 0xf;
137
 
    if (val <= 9)
138
 
                buf[buf_pos++] = '0' + val;
139
 
        else
140
 
            buf[buf_pos++] = 'a' - 10 + val;
141
 
        idx -= 4;
142
 
    }
143
 
    param_string_from_transient_string(custom_color_param, buf);
144
 
 
145
 
    return param_write_string(plist, CustomColorCallbackParamName,
146
 
                                         &custom_color_param);
147
 
}
148
 
 
149
 
/*
150
 
 * Put the 'custom color' client callback parameter block pointer.  This value
151
 
 * is passed as a string type device paramter.  A string is being used since
152
 
 * PostScript does not support pointers as a type.  Note:  An integer type
153
 
 * is not being used since PS integers are nominally 32 bits.  Thus there
154
 
 * would be a problem using integers to pass pointer values on 64 bit systems.
155
 
 */
156
 
int
157
 
custom_color_callback_put_params(gs_state * pgs, gs_param_list * plist)
158
 
{
159
 
    int code;
160
 
    size_t iptr = (size_t)(pgs->memory->gs_lib_ctx->custom_color_callback);
161
 
    gs_param_string dh = { 0 };
162
 
 
163
 
    switch (code = param_read_string(plist, CustomColorCallbackParamName, &dh)) {
164
 
        case 0:
165
 
        {
166
 
       /* 
167
 
        * Convert from a string to a pointer.  
168
 
        * It is assumed that size_t has the same size as a pointer.
169
 
        * Allow formats (1234), (10#1234) or (16#04d2).
170
 
        */
171
 
                uint i;
172
 
                int base = 10;
173
 
                int val;
174
 
                code = 0;
175
 
                for (i = 0; i < dh.size; i++) {
176
 
                        val = dh.data[i];
177
 
                        if ((val >= '0') && (val <= '9'))
178
 
                                val = val - '0';
179
 
                        else if ((val >= 'A') && (val <= 'F'))
180
 
                        val = val - 'A' + 10;
181
 
                        else if ((val >= 'a') && (val <= 'f'))
182
 
                        val = val - 'a' + 10;
183
 
                        else if (val == '#' && ((iptr == 10) || (iptr == 16))) {
184
 
                        base = (int) iptr;
185
 
                        iptr = 0;
186
 
                        continue;
187
 
                        }
188
 
                        else {
189
 
                        code = gs_error_rangecheck;
190
 
                        break;
191
 
                        }
192
 
                        iptr = iptr * base + val;
193
 
                }
194
 
        }
195
 
        break;
196
 
        default:
197
 
        case 1:
198
 
            dh.data = 0;
199
 
            break;
200
 
    }
201
 
    if (code < 0) {
202
 
        param_signal_error(plist, "CustomColorCallback", code);
203
 
    }
204
 
    else if (pgs->memory->gs_lib_ctx->custom_color_callback != (void *)iptr) {
205
 
        pgs->memory->gs_lib_ctx->custom_color_callback = (void *)iptr;
206
 
        /*
207
 
         * Custom color processing can depend upon the type of object
208
 
         * being imaged so we enable object type tagging.
209
 
         */
210
 
    gs_enable_object_tagging();
211
 
    }
212
 
 
213
 
    return 0;
214
 
}
215
 
 
216
 
#endif                  /* ENABLE_CUSTOM_COLOR_CALLBACK */