]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cgi-bin/classes.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / cgi-bin / classes.c
index 2685e66a3e14762fcd7a25579a2b6eb52d0f3d13..78ef08e22f1ab2ecbb08c5f81cd1c4da0d5ce415 100644 (file)
@@ -1,16 +1,10 @@
 /*
- * "$Id$"
- *
  * 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.
  */
 
 /*
@@ -299,8 +293,7 @@ show_all_classes(http_t     *http,  /* I - Connection to server */
                        *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 */
@@ -372,25 +365,10 @@ show_all_classes(http_t     *http,        /* I - Connection to server */
     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...
@@ -410,6 +388,12 @@ show_all_classes(http_t     *http, /* I - Connection to server */
       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...
     */
@@ -543,8 +527,3 @@ show_class(http_t     *http,                /* I - Connection to server */
 
    cgiEndHTML();
 }
-
-
-/*
- * End of "$Id$".
- */