/*
- * "$Id: printers.c 7940 2008-09-16 00:45:16Z mike $"
+ * Printer status CGI for CUPS.
*
- * Printer status CGI for CUPS.
+ * Copyright 2007-2016 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry for CGI.
- * do_printer_op() - Do a printer operation.
- * show_all_printers() - Show all printers...
- * show_printer() - Show a single printer.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
/*
*/
int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+main(void)
{
const char *printer; /* Printer name */
const char *user; /* Username */
do_printer_op(http, printer, CUPS_ACCEPT_JOBS, cgiText(_("Accept Jobs")));
else if (!strcmp(op, "reject-jobs"))
do_printer_op(http, printer, CUPS_REJECT_JOBS, cgiText(_("Reject Jobs")));
- else if (!strcmp(op, "purge-jobs"))
- do_printer_op(http, printer, IPP_PURGE_JOBS, cgiText(_("Purge Jobs")));
- else if (!strcasecmp(op, "print-self-test-page"))
+ else if (!strcmp(op, "cancel-jobs"))
+ do_printer_op(http, printer, IPP_OP_CANCEL_JOBS, cgiText(_("Cancel Jobs")));
+ else if (!_cups_strcasecmp(op, "print-self-test-page"))
cgiPrintCommand(http, printer, "PrintSelfTestPage",
cgiText(_("Print Self-Test Page")));
- else if (!strcasecmp(op, "clean-print-heads"))
+ else if (!_cups_strcasecmp(op, "clean-print-heads"))
cgiPrintCommand(http, printer, "Clean all",
cgiText(_("Clean Print Heads")));
- else if (!strcasecmp(op, "print-test-page"))
+ else if (!_cups_strcasecmp(op, "print-test-page"))
cgiPrintTestPage(http, printer);
- else if (!strcasecmp(op, "move-jobs"))
+ else if (!_cups_strcasecmp(op, "move-jobs"))
cgiMoveJobs(http, printer, 0);
else
{
else if (cupsLastError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
- cgiShowIPPError(_("Unable to do maintenance command:"));
+ cgiShowIPPError(_("Unable to do maintenance command"));
}
else
{
cgiCopyTemplateLang("printer-accept.tmpl");
else if (op == CUPS_REJECT_JOBS)
cgiCopyTemplateLang("printer-reject.tmpl");
- else if (op == IPP_PURGE_JOBS)
- cgiCopyTemplateLang("printer-purge.tmpl");
+ else if (op == IPP_OP_CANCEL_JOBS)
+ cgiCopyTemplateLang("printer-cancel-jobs.tmpl");
}
cgiEndHTML();
*response; /* IPP response */
cups_array_t *printers; /* Array of printer objects */
ipp_attribute_t *printer; /* Printer object */
- int ascending, /* Order of printers (0 = descending) */
- first, /* First printer to show */
+ int first, /* First printer to show */
count; /* Number of printers */
const char *var; /* Form variable */
void *search; /* Search data */
sprintf(val, "%d", count);
cgiSetVariable("TOTAL", val);
- if ((var = cgiGetVariable("ORDER")) != NULL)
- ascending = !strcasecmp(var, "asc");
- else
- ascending = 1;
-
- if (ascending)
- {
- for (i = 0, printer = (ipp_attribute_t *)cupsArrayIndex(printers, first);
- i < CUPS_PAGE_MAX && printer;
- i ++, printer = (ipp_attribute_t *)cupsArrayNext(printers))
- cgiSetIPPObjectVars(printer, NULL, i);
- }
- else
- {
- for (i = 0, printer = (ipp_attribute_t *)cupsArrayIndex(printers, count - first - 1);
- i < CUPS_PAGE_MAX && printer;
- i ++, printer = (ipp_attribute_t *)cupsArrayPrev(printers))
- cgiSetIPPObjectVars(printer, NULL, i);
- }
+ for (i = 0, printer = (ipp_attribute_t *)cupsArrayIndex(printers, first);
+ i < CUPS_PAGE_MAX && printer;
+ i ++, printer = (ipp_attribute_t *)cupsArrayNext(printers))
+ cgiSetIPPObjectVars(printer, NULL, i);
/*
* Save navigation URLs...
cgiSetVariable("NEXT", val);
}
+ if (count > CUPS_PAGE_MAX)
+ {
+ snprintf(val, sizeof(val), "%d", CUPS_PAGE_MAX * (count / CUPS_PAGE_MAX));
+ cgiSetVariable("LAST", val);
+ }
+
/*
* Then show everything...
*/
* Show the error...
*/
- cgiShowIPPError(_("Unable to get printer list:"));
+ cgiShowIPPError(_("Unable to get printer list"));
}
cgiEndHTML();
*/
cgiStartHTML(printer);
- cgiShowIPPError(_("Unable to get printer status:"));
+ cgiShowIPPError(_("Unable to get printer status"));
}
cgiEndHTML();
}
-
-
-/*
- * End of "$Id: printers.c 7940 2008-09-16 00:45:16Z mike $".
- */