/*
* Class status CGI for CUPS.
*
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2016 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/".
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
/*
*response; /* IPP response */
cups_array_t *classes; /* Array of class objects */
ipp_attribute_t *pclass; /* Class object */
- int ascending, /* Order of classes (0 = descending) */
- first, /* First class to show */
+ int first, /* First class to show */
count; /* Number of classes */
const char *var; /* Form variable */
void *search; /* Search data */
sprintf(val, "%d", count);
cgiSetVariable("TOTAL", val);
- if ((var = cgiGetVariable("ORDER")) != NULL && *var)
- ascending = !_cups_strcasecmp(var, "asc");
- else
- ascending = 1;
-
- if (ascending)
- {
- for (i = 0, pclass = (ipp_attribute_t *)cupsArrayIndex(classes, first);
- i < CUPS_PAGE_MAX && pclass;
- i ++, pclass = (ipp_attribute_t *)cupsArrayNext(classes))
- cgiSetIPPObjectVars(pclass, NULL, i);
- }
- else
- {
- for (i = 0, pclass = (ipp_attribute_t *)cupsArrayIndex(classes, count - first - 1);
- i < CUPS_PAGE_MAX && pclass;
- i ++, pclass = (ipp_attribute_t *)cupsArrayPrev(classes))
- cgiSetIPPObjectVars(pclass, NULL, i);
- }
+ for (i = 0, pclass = (ipp_attribute_t *)cupsArrayIndex(classes, first);
+ i < CUPS_PAGE_MAX && pclass;
+ i ++, pclass = (ipp_attribute_t *)cupsArrayNext(classes))
+ cgiSetIPPObjectVars(pclass, 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...
*/