/*
- * "$Id: printers.c 5571 2006-05-22 18:46:55Z mike $"
+ * "$Id: printers.c 6889 2007-08-29 22:23:35Z mike $"
*
* Printer status CGI for the Common UNIX Printing System (CUPS).
*
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products 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 missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * 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:
*
* Get the default printer...
*/
- if (!op)
+ if (!op || !cgiIsPOST())
{
/*
* Get the default destination...
snprintf(refresh, sizeof(refresh), "2;URL=%s", uri);
cgiSetVariable("refresh_page", refresh);
}
+ else if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ {
+ puts("Status: 401\n");
+ exit(0);
+ }
cgiStartHTML(cgiText(_("Printer Maintenance")));
count; /* Number of printers */
const char *var; /* Form variable */
void *search; /* Search data */
- char url[1024], /* URL for prev/next/this */
- *urlptr, /* Position in URL */
- *urlend; /* End of URL */
+ char val[1024]; /* Form variable */
fprintf(stderr, "DEBUG: show_all_printers(http=%p, user=\"%s\")\n",
* Get a list of matching job objects.
*/
- if ((var = cgiGetVariable("QUERY")) != NULL)
+ if ((var = cgiGetVariable("QUERY")) != NULL &&
+ !cgiGetVariable("CLEAR"))
search = cgiCompileSearch(var);
else
search = NULL;
if (first < 0)
first = 0;
- sprintf(url, "%d", count);
- cgiSetVariable("TOTAL", url);
+ sprintf(val, "%d", count);
+ cgiSetVariable("TOTAL", val);
if ((var = cgiGetVariable("ORDER")) != NULL)
ascending = !strcasecmp(var, "asc");
* Save navigation URLs...
*/
- urlend = url + sizeof(url);
-
- if ((var = cgiGetVariable("QUERY")) != NULL)
- {
- strlcpy(url, "/printers/?QUERY=", sizeof(url));
- urlptr = url + strlen(url);
-
- cgiFormEncode(urlptr, var, urlend - urlptr);
- urlptr += strlen(urlptr);
-
- strlcpy(urlptr, "&", urlend - urlptr);
- urlptr += strlen(urlptr);
- }
- else
- {
- strlcpy(url, "/printers/?", sizeof(url));
- urlptr = url + strlen(url);
- }
-
- snprintf(urlptr, urlend - urlptr, "FIRST=%d", first);
- cgiSetVariable("THISURL", url);
+ cgiSetVariable("THISURL", "/printers/");
if (first > 0)
{
- snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
- first - CUPS_PAGE_MAX, ascending ? "asc" : "dec");
- cgiSetVariable("PREVURL", url);
+ sprintf(val, "%d", first - CUPS_PAGE_MAX);
+ cgiSetVariable("PREV", val);
}
if ((first + CUPS_PAGE_MAX) < count)
{
- snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
- first + CUPS_PAGE_MAX, ascending ? "asc" : "dec");
- cgiSetVariable("NEXTURL", url);
+ sprintf(val, "%d", first + CUPS_PAGE_MAX);
+ cgiSetVariable("NEXT", val);
}
/*
/*
- * End of "$Id: printers.c 5571 2006-05-22 18:46:55Z mike $".
+ * End of "$Id: printers.c 6889 2007-08-29 22:23:35Z mike $".
*/