~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to base/gsparamx.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-15 16:49:55 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715164955-uga6qibao6kez05c
Tags: 9.04~dfsg~20110715-0ubuntu1
* New upstream release
   - GIT snapshot from Jult, 12 2011.
* debian/patches/020110406~a54df2d.patch,
  debian/patches/020110408~0791cc8.patch,
  debian/patches/020110408~507cbee.patch,
  debian/patches/020110411~4509a49.patch,
  debian/patches/020110412~78bb9a6.patch,
  debian/patches/020110418~a05ab8a.patch,
  debian/patches/020110420~20b6c78.patch,
  debian/patches/020110420~4ddefa2.patch: Removed upstream patches.
* debian/rules: Generate ABI version number (variable "abi") correctly,
  cutting off repackaging and pre-release parts.
* debian/rules: Added ./lcms2/ directory to DEB_UPSTREAM_REPACKAGE_EXCLUDES.
* debian/copyright: Added lcms2/* to the list of excluded files.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
2
   All Rights Reserved.
3
 
  
 
3
 
4
4
   This software is provided AS-IS with no warranty, either express or
5
5
   implied.
6
6
 
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: gsparamx.c 8022 2007-06-05 22:23:38Z giles $ */
 
14
/* $Id$ */
15
15
/* Extended parameter dictionary utilities */
16
16
#include "string_.h"
17
17
#include "gserror.h"
26
26
gs_param_string_eq(const gs_param_string * pcs, const char *str)
27
27
{
28
28
    return (strlen(str) == pcs->size &&
29
 
            !strncmp(str, (const char *)pcs->data, pcs->size));
 
29
            !strncmp(str, (const char *)pcs->data, pcs->size));
30
30
}
31
31
 
32
32
/* Put an enumerated value. */
33
33
int
34
34
param_put_enum(gs_param_list * plist, gs_param_name param_name,
35
 
               int *pvalue, const char *const pnames[], int ecode)
 
35
               int *pvalue, const char *const pnames[], int ecode)
36
36
{
37
37
    gs_param_string ens;
38
38
    int code = param_read_name(plist, param_name, &ens);
39
39
 
40
40
    switch (code) {
41
 
        case 1:
42
 
            return ecode;
43
 
        case 0:
44
 
            {
45
 
                int i;
 
41
        case 1:
 
42
            return ecode;
 
43
        case 0:
 
44
            {
 
45
                int i;
46
46
 
47
 
                for (i = 0; pnames[i] != 0; ++i)
48
 
                    if (gs_param_string_eq(&ens, pnames[i])) {
49
 
                        *pvalue = i;
50
 
                        return 0;
51
 
                    }
52
 
            }
53
 
            code = gs_error_rangecheck;
54
 
        default:
55
 
            ecode = code;
56
 
            param_signal_error(plist, param_name, code);
 
47
                for (i = 0; pnames[i] != 0; ++i)
 
48
                    if (gs_param_string_eq(&ens, pnames[i])) {
 
49
                        *pvalue = i;
 
50
                        return 0;
 
51
                    }
 
52
            }
 
53
            code = gs_error_rangecheck;
 
54
        default:
 
55
            ecode = code;
 
56
            param_signal_error(plist, param_name, code);
57
57
    }
58
58
    return code;
59
59
}
61
61
/* Put a Boolean value. */
62
62
int
63
63
param_put_bool(gs_param_list * plist, gs_param_name param_name,
64
 
               bool * pval, int ecode)
 
64
               bool * pval, int ecode)
65
65
{
66
66
    int code;
67
67
 
68
68
    switch (code = param_read_bool(plist, param_name, pval)) {
69
 
        default:
70
 
            ecode = code;
71
 
            param_signal_error(plist, param_name, ecode);
72
 
        case 0:
73
 
        case 1:
74
 
            break;
 
69
        default:
 
70
            ecode = code;
 
71
            param_signal_error(plist, param_name, ecode);
 
72
        case 0:
 
73
        case 1:
 
74
            break;
75
75
    }
76
76
    return ecode;
77
77
}
79
79
/* Put an integer value. */
80
80
int
81
81
param_put_int(gs_param_list * plist, gs_param_name param_name,
82
 
              int *pval, int ecode)
 
82
              int *pval, int ecode)
83
83
{
84
84
    int code;
85
85
 
86
86
    switch (code = param_read_int(plist, param_name, pval)) {
87
 
        default:
88
 
            ecode = code;
89
 
            param_signal_error(plist, param_name, ecode);
90
 
        case 0:
91
 
        case 1:
92
 
            break;
 
87
        default:
 
88
            ecode = code;
 
89
            param_signal_error(plist, param_name, ecode);
 
90
        case 0:
 
91
        case 1:
 
92
            break;
93
93
    }
94
94
    return ecode;
95
95
}
97
97
/* Put a long value. */
98
98
int
99
99
param_put_long(gs_param_list * plist, gs_param_name param_name,
100
 
               long *pval, int ecode)
 
100
               long *pval, int ecode)
101
101
{
102
102
    int code;
103
103
 
104
104
    switch (code = param_read_long(plist, param_name, pval)) {
105
 
        default:
106
 
            ecode = code;
107
 
            param_signal_error(plist, param_name, ecode);
108
 
        case 0:
109
 
        case 1:
110
 
            break;
 
105
        default:
 
106
            ecode = code;
 
107
            param_signal_error(plist, param_name, ecode);
 
108
        case 0:
 
109
        case 1:
 
110
            break;
111
111
    }
112
112
    return ecode;
113
113
}
127
127
 
128
128
    param_init_enumerator(&key_enum);
129
129
    while ((code = param_get_next_key(plfrom, &key_enum, &key)) == 0) {
130
 
        char string_key[256];   /* big enough for any reasonable key */
131
 
        gs_param_typed_value value;
132
 
        gs_param_collection_type_t coll_type;
133
 
        gs_param_typed_value copy;
 
130
        char string_key[256];   /* big enough for any reasonable key */
 
131
        gs_param_typed_value value;
 
132
        gs_param_collection_type_t coll_type;
 
133
        gs_param_typed_value copy;
134
134
 
135
 
        if (key.size > sizeof(string_key) - 1) {
136
 
            code = gs_note_error(gs_error_rangecheck);
137
 
            break;
138
 
        }
139
 
        memcpy(string_key, key.data, key.size);
140
 
        string_key[key.size] = 0;
141
 
        if ((code = param_read_typed(plfrom, string_key, &value)) != 0) {
142
 
            code = (code > 0 ? gs_note_error(gs_error_unknownerror) : code);
143
 
            break;
144
 
        }
145
 
        gs_param_list_set_persistent_keys(plto, key.persistent);
146
 
        switch (value.type) {
147
 
        case gs_param_type_dict:
148
 
            coll_type = gs_param_collection_dict_any;
149
 
            goto cc;
150
 
        case gs_param_type_dict_int_keys:
151
 
            coll_type = gs_param_collection_dict_int_keys;
152
 
            goto cc;
153
 
        case gs_param_type_array:
154
 
            coll_type = gs_param_collection_array;
155
 
        cc:
156
 
            copy.value.d.size = value.value.d.size;
157
 
            if ((code = param_begin_write_collection(plto, string_key,
158
 
                                                     &copy.value.d,
159
 
                                                     coll_type)) < 0 ||
160
 
                (code = param_list_copy(copy.value.d.list,
161
 
                                        value.value.d.list)) < 0 ||
162
 
                (code = param_end_write_collection(plto, string_key,
163
 
                                                   &copy.value.d)) < 0)
164
 
                break;
165
 
            code = param_end_read_collection(plfrom, string_key,
166
 
                                             &value.value.d);
167
 
            break;
168
 
        case gs_param_type_string:
169
 
            value.value.s.persistent &= copy_persists; goto ca;
170
 
        case gs_param_type_name:
171
 
            value.value.n.persistent &= copy_persists; goto ca;
172
 
        case gs_param_type_int_array:
173
 
            value.value.ia.persistent &= copy_persists; goto ca;
174
 
        case gs_param_type_float_array:
175
 
            value.value.fa.persistent &= copy_persists; goto ca;
176
 
        case gs_param_type_string_array:
177
 
            value.value.sa.persistent &= copy_persists;
178
 
        ca:
179
 
        default:
180
 
            code = param_write_typed(plto, string_key, &value);
181
 
        }
182
 
        if (code < 0)
183
 
            break;
 
135
        if (key.size > sizeof(string_key) - 1) {
 
136
            code = gs_note_error(gs_error_rangecheck);
 
137
            break;
 
138
        }
 
139
        memcpy(string_key, key.data, key.size);
 
140
        string_key[key.size] = 0;
 
141
        if ((code = param_read_typed(plfrom, string_key, &value)) != 0) {
 
142
            code = (code > 0 ? gs_note_error(gs_error_unknownerror) : code);
 
143
            break;
 
144
        }
 
145
        gs_param_list_set_persistent_keys(plto, key.persistent);
 
146
        switch (value.type) {
 
147
        case gs_param_type_dict:
 
148
            coll_type = gs_param_collection_dict_any;
 
149
            goto cc;
 
150
        case gs_param_type_dict_int_keys:
 
151
            coll_type = gs_param_collection_dict_int_keys;
 
152
            goto cc;
 
153
        case gs_param_type_array:
 
154
            coll_type = gs_param_collection_array;
 
155
        cc:
 
156
            copy.value.d.size = value.value.d.size;
 
157
            if ((code = param_begin_write_collection(plto, string_key,
 
158
                                                     &copy.value.d,
 
159
                                                     coll_type)) < 0 ||
 
160
                (code = param_list_copy(copy.value.d.list,
 
161
                                        value.value.d.list)) < 0 ||
 
162
                (code = param_end_write_collection(plto, string_key,
 
163
                                                   &copy.value.d)) < 0)
 
164
                break;
 
165
            code = param_end_read_collection(plfrom, string_key,
 
166
                                             &value.value.d);
 
167
            break;
 
168
        case gs_param_type_string:
 
169
            value.value.s.persistent &= copy_persists; goto ca;
 
170
        case gs_param_type_name:
 
171
            value.value.n.persistent &= copy_persists; goto ca;
 
172
        case gs_param_type_int_array:
 
173
            value.value.ia.persistent &= copy_persists; goto ca;
 
174
        case gs_param_type_float_array:
 
175
            value.value.fa.persistent &= copy_persists; goto ca;
 
176
        case gs_param_type_string_array:
 
177
            value.value.sa.persistent &= copy_persists;
 
178
        ca:
 
179
        default:
 
180
            code = param_write_typed(plto, string_key, &value);
 
181
        }
 
182
        if (code < 0)
 
183
            break;
184
184
    }
185
185
    return code;
186
186
}