]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - ppdc/ppdhtml.cxx
Merge pull request #5677 from reddevillg/patch-2
[thirdparty/cups.git] / ppdc / ppdhtml.cxx
index bcbb81e9403f1b31015043b70bd6aee71eef683a..506e6616620ba08be8458e54983049adc58b8f03 100644 (file)
@@ -1,21 +1,10 @@
 //
-// "$Id$"
+// PPD to HTML utility for the CUPS PPD Compiler.
 //
-//   PPD to HTML utility for the CUPS PPD Compiler.
+// Copyright 2007-2015 by Apple Inc.
+// Copyright 2002-2005 by Easy Software Products.
 //
-//   Copyright 2007-2008 by Apple Inc.
-//   Copyright 2002-2005 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/".
-//
-// Contents:
-//
-//   main()  - Main entry for the PPD to HTML utility.
-//   usage() - Show usage and exit.
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
 //
 
 //
@@ -58,7 +47,7 @@ main(int  argc,                               // I - Number of command-line arguments
   _cupsSetLocale(argv);
 
   // Scan the command-line...
-  src = 0;
+  src = new ppdcSource();
 
   for (i = 1; i < argc; i ++)
     if (argv[i][0] == '-')
@@ -97,65 +86,75 @@ main(int  argc,                             // I - Number of command-line arguments
     else
     {
       // Open and load the driver info file...
-      src = new ppdcSource(argv[i]);
-
-      // Create a composite group with all of the features from the
-      // drivers in the info file...
-      composite = new ppdcGroup("", "");
-
-      for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next())
-        for (g = (ppdcGroup *)d->groups->first(); g; g = (ppdcGroup *)d->groups->next())
-         for (o = (ppdcOption *)g->options->first(); o; o = (ppdcOption *)g->options->next())
-         {
-           if ((compo = composite->find_option(o->name->value)) == NULL)
-             composite->add_option(new ppdcOption(o));
-         }
-
-      puts("<html>");
-      printf("<head><title>Driver Summary for %s</title></head>\n", argv[i]);
-      printf("<body><h1>Driver Summary for %s</h1>\n", argv[i]);
-      printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
-      for (compo = (ppdcOption *)composite->options->first(); compo; compo = (ppdcOption *)composite->options->next())
-        printf("<th>%s</th>", compo->text->value);
-      puts("</tr></thead><tbody>");
-
-      // Write HTML summary...
-      for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next())
-      {
-        // Write the summary for this driver...
-       printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d->model_name->value);
-       for (size = (ppdcMediaSize *)d->sizes->first(); size;
-            size = (ppdcMediaSize *)d->sizes->next())
-          printf("%s<br>", size->text->value);
-        printf("</td>");
-
-        for (compo = (ppdcOption *)composite->options->first(); compo;
-            compo = (ppdcOption *)composite->options->next())
-         if ((o = d->find_option(compo->name->value)) != NULL)
-         {
-           printf("<td nowrap>");
-           for (c = (ppdcChoice *)o->choices->first(); c;
-                c = (ppdcChoice *)o->choices->next())
-             printf("%s<br>", c->text->value);
-           printf("</td>");
-         }
-         else
-           printf("<td>N/A</td>");
-
-        puts("</tr>");
-      }
-
-      puts("</tbody></table></p>");
-      puts("</body>");
-      puts("</html>");
-      // Delete the printer driver information...
-      composite->release();
-      src->release();
+      src->read_file(argv[i]);
+    }
+
+  if ((d = (ppdcDriver *)src->drivers->first()) != NULL)
+  {
+    // Create a composite group with all of the features from the
+    // drivers in the info file...
+    composite = new ppdcGroup("", "");
+
+    while (d != NULL)
+    {
+      for (g = (ppdcGroup *)d->groups->first(); g; g = (ppdcGroup *)d->groups->next())
+       for (o = (ppdcOption *)g->options->first(); o; o = (ppdcOption *)g->options->next())
+       {
+         if ((compo = composite->find_option(o->name->value)) == NULL)
+           composite->add_option(new ppdcOption(o));
+       }
+
+      d = (ppdcDriver *)src->drivers->next();
     }
 
-  // If no drivers have been loaded, display the program usage message.
-  if (!src)
+    puts("<html>");
+    printf("<head><title>Driver Summary for %s</title></head>\n", argv[i]);
+    printf("<body><h1>Driver Summary for %s</h1>\n", argv[i]);
+    printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
+    for (compo = (ppdcOption *)composite->options->first(); compo; compo = (ppdcOption *)composite->options->next())
+      printf("<th>%s</th>", compo->text->value);
+    puts("</tr></thead><tbody>");
+
+    // Write HTML summary...
+    for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next())
+    {
+      // Write the summary for this driver...
+      printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d->model_name->value);
+      for (size = (ppdcMediaSize *)d->sizes->first(); size;
+          size = (ppdcMediaSize *)d->sizes->next())
+       printf("%s<br>", size->text->value);
+      printf("</td>");
+
+      for (compo = (ppdcOption *)composite->options->first(); compo;
+          compo = (ppdcOption *)composite->options->next())
+       if ((o = d->find_option(compo->name->value)) != NULL)
+       {
+         printf("<td nowrap>");
+         for (c = (ppdcChoice *)o->choices->first(); c;
+              c = (ppdcChoice *)o->choices->next())
+           printf("%s<br>", c->text->value);
+         printf("</td>");
+       }
+       else
+         printf("<td>N/A</td>");
+
+      puts("</tr>");
+    }
+
+    puts("</tbody></table></p>");
+    puts("</body>");
+    puts("</html>");
+
+    // Delete the printer driver information...
+    composite->release();
+  }
+  else
+  {
+    // If no drivers have been loaded, display the program usage message.
     usage();
+  }
+
+  src->release();
 
   // Return with no errors.
   return (0);
@@ -169,17 +168,13 @@ main(int  argc,                           // I - Number of command-line arguments
 static void
 usage(void)
 {
-  _cupsLangPuts(stdout,
-                _("Usage: ppdhtml [options] filename.drv >filename.html\n"
-                 "  -D name=value        Set named variable to value.\n"
-                 "Options:\n"
-                 "  -I include-dir    Add include directory to search "
-                 "path.\n"));
+  _cupsLangPuts(stdout, _("Usage: ppdhtml [options] filename.drv "
+                          ">filename.html"));
+  _cupsLangPuts(stdout, _("Options:"));
+  _cupsLangPuts(stdout, _("  -D name=value           Set named variable to "
+                          "value."));
+  _cupsLangPuts(stdout, _("  -I include-dir          Add include directory "
+                          "to search path."));
 
   exit(1);
 }
-
-
-//
-// End of "$Id$".
-//