diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2019-10-15 12:24:12 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2020-08-13 11:26:55 +0200 |
commit | e088156d5b620e5e639580dacf85c6dc13823c74 (patch) | |
tree | 57f5c025e203279944da512166c20bc0521d8ccd /psi/zfunc0.c | |
download | ghostscript-gpl-patches-e088156d5b620e5e639580dacf85c6dc13823c74.tar.gz ghostscript-gpl-patches-e088156d5b620e5e639580dacf85c6dc13823c74.tar.bz2 ghostscript-gpl-patches-e088156d5b620e5e639580dacf85c6dc13823c74.zip |
Import Ghostscript 9.50ghostscript-9.50
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'psi/zfunc0.c')
-rw-r--r-- | psi/zfunc0.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/psi/zfunc0.c b/psi/zfunc0.c new file mode 100644 index 00000000..e9a9b4b9 --- /dev/null +++ b/psi/zfunc0.c @@ -0,0 +1,94 @@ +/* Copyright (C) 2001-2019 Artifex Software, Inc. + All Rights Reserved. + + This software is provided AS-IS with no warranty, either express or + implied. + + This software is distributed under license and may not be copied, + modified or distributed except as expressly authorized under the terms + of the license contained in the file LICENSE in this distribution. + + Refer to licensing information at http://www.artifex.com or contact + Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, + CA 94945, U.S.A., +1(415)492-9861, for further information. +*/ + + +/* PostScript language interface to FunctionType 0 (Sampled) Functions */ +#include "memory_.h" +#include "ghost.h" +#include "oper.h" +#include "gsdsrc.h" +#include "gsfunc.h" +#include "gsfunc0.h" +#include "stream.h" /* for files.h */ +#include "files.h" +#include "ialloc.h" +#include "idict.h" +#include "idparam.h" +#include "ifunc.h" + +/* Check prototype */ +build_function_proc(gs_build_function_0); + +/* Finish building a FunctionType 0 (Sampled) function. */ +int +gs_build_function_0(i_ctx_t *i_ctx_p, const ref *op, const gs_function_params_t * mnDR, + int depth, gs_function_t ** ppfn, gs_memory_t *mem) +{ + gs_function_Sd_params_t params; + ref *pDataSource; + int code; + + *(gs_function_params_t *) & params = *mnDR; + params.Encode = params.Decode = NULL; + params.pole = NULL; + params.Size = params.array_step = params.stream_step = NULL; + if ((code = dict_find_string(op, "DataSource", &pDataSource)) <= 0) + return (code < 0 ? code : gs_note_error(gs_error_rangecheck)); + switch (r_type(pDataSource)) { + case t_string: + data_source_init_string2(¶ms.DataSource, + pDataSource->value.const_bytes, + r_size(pDataSource)); + break; + case t_file: { + stream *s; + + check_read_known_file_else(s, pDataSource, return_error, + return_error(gs_error_invalidfileaccess)); + if (!(s->modes & s_mode_seek)) + return_error(gs_error_ioerror); + data_source_init_stream(¶ms.DataSource, s); + break; + } + default: + return_error(gs_error_rangecheck); + } + if ((code = dict_int_param(op, "Order", 1, 3, 1, ¶ms.Order)) < 0 || + (code = dict_int_param(op, "BitsPerSample", 1, 32, 0, + ¶ms.BitsPerSample)) < 0 || + ((code = fn_build_float_array(op, "Encode", false, true, ¶ms.Encode, mem)) != 2 * params.m && (code != 0 || params.Encode != 0)) || + ((code = fn_build_float_array(op, "Decode", false, true, ¶ms.Decode, mem)) != 2 * params.n && (code != 0 || params.Decode != 0)) + ) { + goto fail; + } { + int *ptr = (int *) + gs_alloc_byte_array(mem, params.m, sizeof(int), "Size"); + + if (ptr == 0) { + code = gs_note_error(gs_error_VMerror); + goto fail; + } + params.Size = ptr; + code = dict_ints_param(mem, op, "Size", params.m, ptr); + if (code != params.m) + goto fail; + } + code = gs_function_Sd_init(ppfn, ¶ms, mem); + if (code >= 0) + return 0; +fail: + gs_function_Sd_free_params(¶ms, mem); + return (code < 0 ? code : gs_note_error(gs_error_rangecheck)); +} |