]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/ppd-custom.c
5f5272ce3338547f0c6b1b44ad55674c647505f7
[thirdparty/cups.git] / cups / ppd-custom.c
1 /*
2 * "$Id$"
3 *
4 * PPD custom option routines for CUPS.
5 *
6 * Copyright 2007-2015 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
14 *
15 * PostScript is a trademark of Adobe Systems, Inc.
16 *
17 * This code and any derivative of it may be used and distributed
18 * freely under the terms of the GNU General Public License when
19 * used with GNU Ghostscript or its derivatives. Use of the code
20 * (or any derivative of it) with software other than GNU
21 * GhostScript (or its derivatives) is governed by the CUPS license
22 * agreement.
23 *
24 * This file is subject to the Apple OS-Developed Software exception.
25 */
26
27 /*
28 * Include necessary headers.
29 */
30
31 #include "cups-private.h"
32 #include "ppd-private.h"
33
34
35 /*
36 * 'ppdFindCustomOption()' - Find a custom option.
37 *
38 * @since CUPS 1.2/OS X 10.5@
39 */
40
41 ppd_coption_t * /* O - Custom option or NULL */
42 ppdFindCustomOption(ppd_file_t *ppd, /* I - PPD file */
43 const char *keyword)/* I - Custom option name */
44 {
45 ppd_coption_t key; /* Custom option search key */
46
47
48 if (!ppd)
49 return (NULL);
50
51 strlcpy(key.keyword, keyword, sizeof(key.keyword));
52 return ((ppd_coption_t *)cupsArrayFind(ppd->coptions, &key));
53 }
54
55
56 /*
57 * 'ppdFindCustomParam()' - Find a parameter for a custom option.
58 *
59 * @since CUPS 1.2/OS X 10.5@
60 */
61
62 ppd_cparam_t * /* O - Custom parameter or NULL */
63 ppdFindCustomParam(ppd_coption_t *opt, /* I - Custom option */
64 const char *name) /* I - Parameter name */
65 {
66 ppd_cparam_t *param; /* Current custom parameter */
67
68
69 if (!opt)
70 return (NULL);
71
72 for (param = (ppd_cparam_t *)cupsArrayFirst(opt->params);
73 param;
74 param = (ppd_cparam_t *)cupsArrayNext(opt->params))
75 if (!_cups_strcasecmp(param->name, name))
76 break;
77
78 return (param);
79 }
80
81
82 /*
83 * 'ppdFirstCustomParam()' - Return the first parameter for a custom option.
84 *
85 * @since CUPS 1.2/OS X 10.5@
86 */
87
88 ppd_cparam_t * /* O - Custom parameter or NULL */
89 ppdFirstCustomParam(ppd_coption_t *opt) /* I - Custom option */
90 {
91 if (!opt)
92 return (NULL);
93
94 return ((ppd_cparam_t *)cupsArrayFirst(opt->params));
95 }
96
97
98 /*
99 * 'ppdNextCustomParam()' - Return the next parameter for a custom option.
100 *
101 * @since CUPS 1.2/OS X 10.5@
102 */
103
104 ppd_cparam_t * /* O - Custom parameter or NULL */
105 ppdNextCustomParam(ppd_coption_t *opt) /* I - Custom option */
106 {
107 if (!opt)
108 return (NULL);
109
110 return ((ppd_cparam_t *)cupsArrayNext(opt->params));
111 }
112
113
114 /*
115 * End of "$Id$".
116 */