• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * PPD custom option routines for CUPS.
3  *
4  * Copyright © 2020-2024 by OpenPrinting.
5  * Copyright 2007-2015 by Apple Inc.
6  * Copyright 1997-2006 by Easy Software Products, all rights reserved.
7  *
8  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
9  * information.
10  *
11  * PostScript is a trademark of Adobe Systems, Inc.
12  */
13 
14 /*
15  * Include necessary headers.
16  */
17 
18 #include "cups-private.h"
19 #include "ppd-private.h"
20 #include "debug-internal.h"
21 
22 
23 /*
24  * 'ppdFindCustomOption()' - Find a custom option.
25  *
26  * @since CUPS 1.2/macOS 10.5@
27  */
28 
29 ppd_coption_t *				/* O - Custom option or NULL */
ppdFindCustomOption(ppd_file_t * ppd,const char * keyword)30 ppdFindCustomOption(ppd_file_t *ppd,	/* I - PPD file */
31                     const char *keyword)/* I - Custom option name */
32 {
33   ppd_coption_t	key;			/* Custom option search key */
34 
35 
36   if (!ppd)
37     return (NULL);
38 
39   strlcpy(key.keyword, keyword, sizeof(key.keyword));
40   return ((ppd_coption_t *)cupsArrayFind(ppd->coptions, &key));
41 }
42 
43 
44 /*
45  * 'ppdFindCustomParam()' - Find a parameter for a custom option.
46  *
47  * @since CUPS 1.2/macOS 10.5@
48  */
49 
50 ppd_cparam_t *				/* O - Custom parameter or NULL */
ppdFindCustomParam(ppd_coption_t * opt,const char * name)51 ppdFindCustomParam(ppd_coption_t *opt,	/* I - Custom option */
52                    const char    *name)	/* I - Parameter name */
53 {
54   ppd_cparam_t	*param;			/* Current custom parameter */
55 
56 
57   if (!opt)
58     return (NULL);
59 
60   for (param = (ppd_cparam_t *)cupsArrayFirst(opt->params);
61        param;
62        param = (ppd_cparam_t *)cupsArrayNext(opt->params))
63     if (!_cups_strcasecmp(param->name, name))
64       break;
65 
66   return (param);
67 }
68 
69 
70 /*
71  * 'ppdFirstCustomParam()' - Return the first parameter for a custom option.
72  *
73  * @since CUPS 1.2/macOS 10.5@
74  */
75 
76 ppd_cparam_t *				/* O - Custom parameter or NULL */
ppdFirstCustomParam(ppd_coption_t * opt)77 ppdFirstCustomParam(ppd_coption_t *opt)	/* I - Custom option */
78 {
79   if (!opt)
80     return (NULL);
81 
82   return ((ppd_cparam_t *)cupsArrayFirst(opt->params));
83 }
84 
85 
86 /*
87  * 'ppdNextCustomParam()' - Return the next parameter for a custom option.
88  *
89  * @since CUPS 1.2/macOS 10.5@
90  */
91 
92 ppd_cparam_t *				/* O - Custom parameter or NULL */
ppdNextCustomParam(ppd_coption_t * opt)93 ppdNextCustomParam(ppd_coption_t *opt)	/* I - Custom option */
94 {
95   if (!opt)
96     return (NULL);
97 
98   return ((ppd_cparam_t *)cupsArrayNext(opt->params));
99 }
100