{
ipp_t *request; /* IPP Request */
const char *ppdfile; /* PPD filename */
- int ppdchanged; /* PPD changed? */
+ int ppdchanged = 0; /* PPD changed? */
ppd_file_t *ppd; /* PPD file */
ppd_choice_t *choice; /* Marked choice */
char uri[HTTP_MAX_URI], /* URI for printer/class */
tempfile[1024]; /* Temporary filename */
cups_file_t *in, /* PPD file */
*out; /* Temporary file */
- const char *protocol, /* Old protocol option */
+ const char *ppdname, /* ppd-name value */
+ *protocol, /* Old protocol option */
*customval, /* Custom option value */
*boolval; /* Boolean value */
int wrote_ipp_supplies = 0, /* Wrote cupsIPPSupplies keyword? */
- wrote_snmp_supplies = 0;/* Wrote cupsSNMPSupplies keyword? */
+ wrote_snmp_supplies = 0,/* Wrote cupsSNMPSupplies keyword? */
+ copied_options = 0; /* Copied options? */
DEBUG_printf(("set_printer_options(http=%p, printer=\"%s\", num_options=%d, "
if (file)
ppdfile = file;
+ else if ((ppdname = cupsGetOption("ppd-name", num_options, options)) != NULL && strcmp(ppdname, "raw") && num_options > 1)
+ {
+ if ((ppdfile = cupsGetServerPPD(http, ppdname)) != NULL)
+ {
+ /*
+ * Copy options array and remove ppd-name from it...
+ */
+
+ cups_option_t *temp = NULL, *optr;
+ int i, num_temp = 0;
+ for (i = num_options, optr = options; i > 0; i --, optr ++)
+ if (strcmp(optr->name, "ppd-name"))
+ num_temp = cupsAddOption(optr->name, optr->value, num_temp, &temp);
+
+ copied_options = 1;
+ ppdchanged = 1;
+ num_options = num_temp;
+ options = temp;
+ }
+ }
else if (request->request.op.operation_id == IPP_OP_CUPS_ADD_MODIFY_PRINTER)
ppdfile = cupsGetPPD(printer);
else
* Set default options in the PPD file...
*/
- ppd = ppdOpenFile(ppdfile);
+ if ((ppd = ppdOpenFile(ppdfile)) == NULL)
+ {
+ int linenum; /* Line number of error */
+ ppd_status_t status = ppdLastError(&linenum);
+ /* Status code */
+
+ _cupsLangPrintf(stderr, _("lpadmin: Unable to open PPD \"%s\": %s on line %d."), ppdfile, ppdErrorString(status), linenum);
+ }
+
ppdMarkDefaults(ppd);
cupsMarkOptions(ppd, num_options, options);
ippDelete(request);
if (ppdfile != file)
unlink(ppdfile);
+ if (copied_options)
+ cupsFreeOptions(num_options, options);
return (1);
}
ippDelete(request);
if (ppdfile != file)
unlink(ppdfile);
+ if (copied_options)
+ cupsFreeOptions(num_options, options);
cupsFileClose(out);
unlink(tempfile);
return (1);
}
- ppdchanged = 0;
-
while (cupsFileGets(in, line, sizeof(line)))
{
if (!strncmp(line, "*cupsIPPSupplies:", 17) &&
ippDelete(cupsDoRequest(http, request, "/admin/"));
}
+ if (copied_options)
+ cupsFreeOptions(num_options, options);
+
/*
* Check the response...
*/
# Perform the complete set of IPP compliance tests specified in the
# CUPS Software Test Plan.
#
-# Copyright 2007-2014 by Apple Inc.
+# Copyright 2007-2015 by Apple Inc.
# Copyright 1997-2007 by Easy Software Products, all rights reserved.
#
# These coded instructions, statements, and computer programs are the
# Requests logged
count=`wc -l $BASE/log/access_log | awk '{print $1}'`
-expected=`expr 37 + 18 + 29 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
+expected=`expr 37 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
if test $count != $expected; then
echo "FAIL: $count requests logged, expected $expected."
echo "<P>FAIL: $count requests logged, expected $expected.</P>" >>$strfile