]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cgi-bin/classes.c
Load cups into easysw/current.
[thirdparty/cups.git] / cgi-bin / classes.c
index fbea241992d95b4795a90654dc396eea72d7f955..51c07337f90536e6f5b6c30993bd8d98aa514b94 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id: classes.c 5023 2006-01-29 14:39:44Z mike $"
+ * "$Id: classes.c 6649 2007-07-11 21:46:42Z mike $"
  *
  *   Class status CGI for the Common UNIX Printing System (CUPS).
  *
+ *   Copyright 2007 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:
  *
@@ -83,17 +74,19 @@ main(int  argc,                             /* I - Number of command-line arguments */
   * See if we are displaying a printer or all classes...
   */
 
-  if (!strcmp(argv[0], "/") || strstr(argv[0], "classes.cgi"))
-    pclass = NULL;
-  else
-    pclass = argv[0];
+  if ((pclass = getenv("PATH_INFO")) != NULL)
+  {
+    pclass ++;
+
+    if (!*pclass)
+      pclass = NULL;
+  }
 
  /*
   * See who is logged in...
   */
 
-  if ((user = getenv("REMOTE_USER")) == NULL)
-    user = "guest";
+  user = getenv("REMOTE_USER");
 
  /*
   * Connect to the HTTP server...
@@ -184,7 +177,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
 void
 show_all_classes(http_t     *http,     /* I - Connection to server */
-                  const char *user)    /* I - Username */
+                 const char *user)     /* I - Username */
 {
   int                  i;              /* Looping var */
   ipp_t                        *request,       /* IPP request */
@@ -218,8 +211,9 @@ show_all_classes(http_t     *http,  /* I - Connection to server */
 
   request = ippNewRequest(CUPS_GET_CLASSES);
 
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
-               "requesting-user-name", NULL, user);
+  if (user)
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+                "requesting-user-name", NULL, user);
 
   cgiGetAttributes(request, "classes.tmpl");
 
@@ -344,6 +338,7 @@ show_all_classes(http_t     *http,  /* I - Connection to server */
     * Delete the response...
     */
 
+    cupsArrayDelete(classes);
     ippDelete(response);
   }
   else
@@ -415,7 +410,7 @@ show_class(http_t     *http,                /* I - Connection to server */
       */
 
       cgiFormEncode(uri, pclass, sizeof(uri));
-      snprintf(refresh, sizeof(refresh), "10;/classes/%s", uri);
+      snprintf(refresh, sizeof(refresh), "10;URL=/classes/%s", uri);
       cgiSetVariable("refresh_page", refresh);
     }
 
@@ -459,5 +454,5 @@ show_class(http_t     *http,                /* I - Connection to server */
 
 
 /*
- * End of "$Id: classes.c 5023 2006-01-29 14:39:44Z mike $".
+ * End of "$Id: classes.c 6649 2007-07-11 21:46:42Z mike $".
  */