Coverage Report

Created: 2026-01-09 06:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cups/cups/ppd-custom.c
Line
Count
Source
1
/*
2
 * PPD custom option routines for CUPS.
3
 *
4
 * Copyright © 2020-2025 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
#include "cups-private.h"
15
#include "ppd-private.h"
16
#include "debug-internal.h"
17
18
19
/*
20
 * 'ppdFindCustomOption()' - Find a custom option.
21
 *
22
 * @since CUPS 1.2@
23
 */
24
25
ppd_coption_t *       /* O - Custom option or NULL */
26
ppdFindCustomOption(ppd_file_t *ppd,  /* I - PPD file */
27
                    const char *keyword)/* I - Custom option name */
28
65.0k
{
29
65.0k
  ppd_coption_t key;      /* Custom option search key */
30
31
32
65.0k
  if (!ppd)
33
0
    return (NULL);
34
35
65.0k
  cupsCopyString(key.keyword, keyword, sizeof(key.keyword));
36
65.0k
  return ((ppd_coption_t *)cupsArrayFind(ppd->coptions, &key));
37
65.0k
}
38
39
40
/*
41
 * 'ppdFindCustomParam()' - Find a parameter for a custom option.
42
 *
43
 * @since CUPS 1.2@
44
 */
45
46
ppd_cparam_t *        /* O - Custom parameter or NULL */
47
ppdFindCustomParam(ppd_coption_t *opt,  /* I - Custom option */
48
                   const char    *name) /* I - Parameter name */
49
674
{
50
674
  ppd_cparam_t  *param;     /* Current custom parameter */
51
52
53
674
  if (!opt)
54
0
    return (NULL);
55
56
674
  for (param = (ppd_cparam_t *)cupsArrayFirst(opt->params);
57
941
       param;
58
674
       param = (ppd_cparam_t *)cupsArrayNext(opt->params))
59
276
    if (!_cups_strcasecmp(param->name, name))
60
9
      break;
61
62
674
  return (param);
63
674
}
64
65
66
/*
67
 * 'ppdFirstCustomParam()' - Return the first parameter for a custom option.
68
 *
69
 * @since CUPS 1.2@
70
 */
71
72
ppd_cparam_t *        /* O - Custom parameter or NULL */
73
ppdFirstCustomParam(ppd_coption_t *opt) /* I - Custom option */
74
0
{
75
0
  if (!opt)
76
0
    return (NULL);
77
78
0
  return ((ppd_cparam_t *)cupsArrayFirst(opt->params));
79
0
}
80
81
82
/*
83
 * 'ppdNextCustomParam()' - Return the next parameter for a custom option.
84
 *
85
 * @since CUPS 1.2@
86
 */
87
88
ppd_cparam_t *        /* O - Custom parameter or NULL */
89
ppdNextCustomParam(ppd_coption_t *opt)  /* I - Custom option */
90
0
{
91
0
  if (!opt)
92
0
    return (NULL);
93
94
0
  return ((ppd_cparam_t *)cupsArrayNext(opt->params));
95
0
}