]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cgi-bin/help.c
Import CUPS v1.7.1
[thirdparty/cups.git] / cgi-bin / help.c
index 0d554de71108bdf4395f1e5a00891add16127ece..75f70d9c46000dea2a471a35746b74e82e998868 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id$"
+ * "$Id: help.c 10996 2013-05-29 11:51:34Z msweet $"
  *
- *   On-line help CGI for the Common UNIX Printing System (CUPS).
+ *   Online help CGI for CUPS.
  *
+ *   Copyright 2007-2011 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:
  *
@@ -48,7 +39,8 @@ main(int  argc,                               /* I - Number of command-line arguments */
   const char   *query;                 /* Search query */
   const char   *cache_dir;             /* CUPS_CACHEDIR environment variable */
   const char   *docroot;               /* CUPS_DOCROOT environment variable */
-  const char   *helpfile;              /* Current help file */
+  const char   *helpfile,              /* Current help file */
+               *helptitle = NULL;      /* Current help title */
   const char   *topic;                 /* Current topic */
   char         topic_data[1024];       /* Topic form data */
   const char   *section;               /* Current section */
@@ -72,6 +64,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
   */
 
   cgiSetVariable("SECTION", "help");
+  cgiSetVariable("REFRESH_PAGE", "");
 
  /*
   * Load the help index...
@@ -95,8 +88,8 @@ main(int  argc,                               /* I - Number of command-line arguments */
   {
     perror(filename);
 
-    cgiStartHTML(cgiText(_("Help")));
-    cgiSetVariable("ERROR", "Unable to load help index!");
+    cgiStartHTML(cgiText(_("Online Help")));
+    cgiSetVariable("ERROR", cgiText(_("Unable to load help index.")));
     cgiCopyTemplateLang("error.tmpl");
     cgiEndHTML();
 
@@ -111,7 +104,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
   */
 
   for (i = 0; i < argc; i ++)
-    fprintf(stderr, "argv[%d]=\"%s\"\n", i, argv[i]);
+    fprintf(stderr, "DEBUG: argv[%d]=\"%s\"\n", i, argv[i]);
 
   if ((helpfile = getenv("PATH_INFO")) != NULL)
   {
@@ -136,8 +129,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
     {
       perror(filename);
 
-      cgiStartHTML(cgiText(_("Help")));
-      cgiSetVariable("ERROR", "Unable to access help file!");
+      cgiStartHTML(cgiText(_("Online Help")));
+      cgiSetVariable("ERROR", cgiText(_("Unable to access help file.")));
       cgiCopyTemplateLang("error.tmpl");
       cgiEndHTML();
 
@@ -146,8 +139,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
     if ((n = helpFindNode(hi, helpfile, NULL)) == NULL)
     {
-      cgiStartHTML(cgiText(_("Help")));
-      cgiSetVariable("ERROR", "Help file not in index!");
+      cgiStartHTML(cgiText(_("Online Help")));
+      cgiSetVariable("ERROR", cgiText(_("Help file not in index.")));
       cgiCopyTemplateLang("error.tmpl");
       cgiEndHTML();
 
@@ -155,11 +148,11 @@ main(int  argc,                           /* I - Number of command-line arguments */
     }
 
    /*
-    * Set the page title and save the help file...
+    * Save the page title and help file...
     */
 
-    cgiSetVariable("HELPFILE", helpfile);
-    cgiSetVariable("HELPTITLE", n->text);
+    helptitle = n->text;
+    topic     = n->section;
 
    /*
     * Send a standard page header...
@@ -176,17 +169,31 @@ main(int  argc,                           /* I - Number of command-line arguments */
     * Send a standard page header...
     */
 
-    cgiStartHTML(cgiText(_("Help")));
+    cgiStartHTML(cgiText(_("Online Help")));
+
+    topic = cgiGetVariable("TOPIC");
   }
 
  /*
   * Do a search as needed...
   */
 
+  if (cgiGetVariable("CLEAR"))
+    cgiSetVariable("QUERY", "");
+
   query = cgiGetVariable("QUERY");
-  topic = cgiGetVariable("TOPIC");
   si    = helpSearchIndex(hi, query, topic, helpfile);
 
+  cgiClearVariables();
+  if (query)
+    cgiSetVariable("QUERY", query);
+  if (topic)
+    cgiSetVariable("TOPIC", topic);
+  if (helpfile)
+    cgiSetVariable("HELPFILE", helpfile);
+  if (helptitle)
+    cgiSetVariable("HELPTITLE", helptitle);
+
   fprintf(stderr, "DEBUG: query=\"%s\", topic=\"%s\"\n",
           query ? query : "(null)", topic ? topic : "(null)");
 
@@ -340,12 +347,12 @@ main(int  argc,                           /* I - Number of command-line arguments */
       {
         if (inbody)
        {
-         if (!strncasecmp(line, "</BODY>", 7))
+         if (!_cups_strncasecmp(line, "</BODY>", 7))
            break;
 
          printf("%s\n", line);
         }
-       else if (!strncasecmp(line, "<BODY", 5))
+       else if (!_cups_strncasecmp(line, "<BODY", 5))
          inbody = 1;
       }
 
@@ -354,7 +361,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
     else
     {
       perror(filename);
-      cgiSetVariable("ERROR", "Unable to open help file.");
+      cgiSetVariable("ERROR", cgiText(_("Unable to open help file.")));
       cgiCopyTemplateLang("error.tmpl");
     }
   }
@@ -364,7 +371,10 @@ main(int  argc,                            /* I - Number of command-line arguments */
   */
 
   if (!printable)
+  {
+    cgiCopyTemplateLang("help-trailer.tmpl");
     cgiEndHTML();
+  }
   else
     puts("</BODY>\n</HTML>");
 
@@ -383,5 +393,5 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id$".
+ * End of "$Id: help.c 10996 2013-05-29 11:51:34Z msweet $".
  */