]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/ppd-custom.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / cups / ppd-custom.c
1 /*
2 * PPD custom option routines for CUPS.
3 *
4 * Copyright 2007-2015 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
6 *
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
8 *
9 * PostScript is a trademark of Adobe Systems, Inc.
10 *
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.
17 */
18
19 /*
20 * Include necessary headers.
21 */
22
23 #include "cups-private.h"
24 #include "ppd-private.h"
25
26
27 /*
28 * 'ppdFindCustomOption()' - Find a custom option.
29 *
30 * @since CUPS 1.2/macOS 10.5@
31 */
32
33 ppd_coption_t * /* O - Custom option or NULL */
34 ppdFindCustomOption(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.
50 *
51 * @since CUPS 1.2/macOS 10.5@
52 */
53
54 ppd_cparam_t * /* O - Custom parameter or NULL */
55 ppdFindCustomParam(ppd_coption_t *opt, /* I - Custom option */
56 const char *name) /* I - Parameter name */
57 {
58 ppd_cparam_t *param; /* Current custom parameter */
59
60
61 if (!opt)
62 return (NULL);
63
64 for (param = (ppd_cparam_t *)cupsArrayFirst(opt->params);
65 param;
66 param = (ppd_cparam_t *)cupsArrayNext(opt->params))
67 if (!_cups_strcasecmp(param->name, name))
68 break;
69
70 return (param);
71 }
72
73
74 /*
75 * 'ppdFirstCustomParam()' - Return the first parameter for a custom option.
76 *
77 * @since CUPS 1.2/macOS 10.5@
78 */
79
80 ppd_cparam_t * /* O - Custom parameter or NULL */
81 ppdFirstCustomParam(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.
92 *
93 * @since CUPS 1.2/macOS 10.5@
94 */
95
96 ppd_cparam_t * /* O - Custom parameter or NULL */
97 ppdNextCustomParam(ppd_coption_t *opt) /* I - Custom option */
98 {
99 if (!opt)
100 return (NULL);
101
102 return ((ppd_cparam_t *)cupsArrayNext(opt->params));
103 }