]>
git.ipfire.org Git - thirdparty/cups.git/blob - driver/attr.c
4 * PPD attribute lookup routine for CUPS.
6 * Copyright 2007-2010 by Apple Inc.
7 * Copyright 1993-2005 by Easy Software Products.
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/".
17 * cupsFindAttr() - Find a PPD attribute based on the colormodel,
18 * media, and resolution.
22 * Include necessary headers.
26 #include <cups/string-private.h>
30 * 'cupsFindAttr()' - Find a PPD attribute based on the colormodel,
31 * media, and resolution.
34 ppd_attr_t
* /* O - Matching attribute or NULL */
35 cupsFindAttr(ppd_file_t
*ppd
, /* I - PPD file */
36 const char *name
, /* I - Attribute name */
37 const char *colormodel
, /* I - Color model */
38 const char *media
, /* I - Media type */
39 const char *resolution
, /* I - Resolution */
40 char *spec
, /* O - Final selection string */
41 int specsize
) /* I - Size of string buffer */
43 ppd_attr_t
*attr
; /* Attribute */
47 * Range check input...
50 if (!ppd
|| !name
|| !colormodel
|| !media
|| !resolution
|| !spec
||
51 specsize
< PPD_MAX_NAME
)
55 * Look for the attribute with the following keywords:
57 * ColorModel.MediaType.Resolution
58 * ColorModel.Resolution
60 * MediaType.Resolution
66 snprintf(spec
, specsize
, "%s.%s.%s", colormodel
, media
, resolution
);
67 fprintf(stderr
, "DEBUG2: Looking for \"*%s %s\"...\n", name
, spec
);
68 if ((attr
= ppdFindAttr(ppd
, name
, spec
)) != NULL
&& attr
->value
!= NULL
)
71 snprintf(spec
, specsize
, "%s.%s", colormodel
, resolution
);
72 fprintf(stderr
, "DEBUG2: Looking for \"*%s %s\"...\n", name
, spec
);
73 if ((attr
= ppdFindAttr(ppd
, name
, spec
)) != NULL
&& attr
->value
!= NULL
)
76 strlcpy(spec
, colormodel
, specsize
);
77 fprintf(stderr
, "DEBUG2: Looking for \"*%s %s\"...\n", name
, spec
);
78 if ((attr
= ppdFindAttr(ppd
, name
, spec
)) != NULL
&& attr
->value
!= NULL
)
81 snprintf(spec
, specsize
, "%s.%s", media
, resolution
);
82 fprintf(stderr
, "DEBUG2: Looking for \"*%s %s\"...\n", name
, spec
);
83 if ((attr
= ppdFindAttr(ppd
, name
, spec
)) != NULL
&& attr
->value
!= NULL
)
86 strlcpy(spec
, media
, specsize
);
87 fprintf(stderr
, "DEBUG2: Looking for \"*%s %s\"...\n", name
, spec
);
88 if ((attr
= ppdFindAttr(ppd
, name
, spec
)) != NULL
&& attr
->value
!= NULL
)
91 strlcpy(spec
, resolution
, specsize
);
92 fprintf(stderr
, "DEBUG2: Looking for \"*%s %s\"...\n", name
, spec
);
93 if ((attr
= ppdFindAttr(ppd
, name
, spec
)) != NULL
&& attr
->value
!= NULL
)
97 fprintf(stderr
, "DEBUG2: Looking for \"*%s\"...\n", name
);
98 if ((attr
= ppdFindAttr(ppd
, name
, spec
)) != NULL
&& attr
->value
!= NULL
)
101 fprintf(stderr
, "DEBUG2: No instance of \"*%s\" found...\n", name
);