]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/ppd-custom.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / cups / ppd-custom.c
CommitLineData
fa73b229 1/*
f787e1e3 2 * PPD custom option routines for CUPS.
fa73b229 3 *
f787e1e3
MS
4 * Copyright 2007-2015 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
fa73b229 6 *
e3101897 7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
fa73b229 8 *
f787e1e3 9 * PostScript is a trademark of Adobe Systems, Inc.
fa73b229 10 *
f787e1e3
MS
11 * This code and any derivative of it may be used and distributed
12 * freely under the terms of the GNU General Public License when
13 * used with GNU Ghostscript or its derivatives. Use of the code
14 * (or any derivative of it) with software other than GNU
15 * GhostScript (or its derivatives) is governed by the CUPS license
16 * agreement.
fa73b229 17 */
18
19/*
20 * Include necessary headers.
21 */
22
71e16022 23#include "cups-private.h"
f787e1e3 24#include "ppd-private.h"
fa73b229 25
26
27/*
28 * 'ppdFindCustomOption()' - Find a custom option.
89d46774 29 *
8072030b 30 * @since CUPS 1.2/macOS 10.5@
fa73b229 31 */
32
33ppd_coption_t * /* O - Custom option or NULL */
34ppdFindCustomOption(ppd_file_t *ppd, /* I - PPD file */
35 const char *keyword)/* I - Custom option name */
36{
37 ppd_coption_t key; /* Custom option search key */
38
39
40 if (!ppd)
41 return (NULL);
42
43 strlcpy(key.keyword, keyword, sizeof(key.keyword));
44 return ((ppd_coption_t *)cupsArrayFind(ppd->coptions, &key));
45}
46
47
48/*
49 * 'ppdFindCustomParam()' - Find a parameter for a custom option.
89d46774 50 *
8072030b 51 * @since CUPS 1.2/macOS 10.5@
fa73b229 52 */
53
54ppd_cparam_t * /* O - Custom parameter or NULL */
55ppdFindCustomParam(ppd_coption_t *opt, /* I - Custom option */
56 const char *name) /* I - Parameter name */
57{
0268488e 58 ppd_cparam_t *param; /* Current custom parameter */
fa73b229 59
60
61 if (!opt)
62 return (NULL);
63
0268488e
MS
64 for (param = (ppd_cparam_t *)cupsArrayFirst(opt->params);
65 param;
66 param = (ppd_cparam_t *)cupsArrayNext(opt->params))
88f9aafc 67 if (!_cups_strcasecmp(param->name, name))
0268488e
MS
68 break;
69
70 return (param);
fa73b229 71}
72
73
74/*
75 * 'ppdFirstCustomParam()' - Return the first parameter for a custom option.
89d46774 76 *
8072030b 77 * @since CUPS 1.2/macOS 10.5@
fa73b229 78 */
79
80ppd_cparam_t * /* O - Custom parameter or NULL */
81ppdFirstCustomParam(ppd_coption_t *opt) /* I - Custom option */
82{
83 if (!opt)
84 return (NULL);
85
86 return ((ppd_cparam_t *)cupsArrayFirst(opt->params));
87}
88
89
90/*
91 * 'ppdNextCustomParam()' - Return the next parameter for a custom option.
89d46774 92 *
8072030b 93 * @since CUPS 1.2/macOS 10.5@
fa73b229 94 */
95
96ppd_cparam_t * /* O - Custom parameter or NULL */
97ppdNextCustomParam(ppd_coption_t *opt) /* I - Custom option */
98{
99 if (!opt)
100 return (NULL);
101
102 return ((ppd_cparam_t *)cupsArrayNext(opt->params));
103}