]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Code clean-up for code of libcupsfilters
authorTill Kamppeter <till.kamppeter@gmail.com>
Thu, 29 Sep 2022 22:41:46 +0000 (00:41 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 29 Sep 2022 22:41:46 +0000 (00:41 +0200)
Cleaned up the second bunch of source code files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding style rules in the DEVELOPING.md file of the CUPS source code.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions rteceived during more than a
decade, even before the start of the cups-filters project.

14 files changed:
cupsfilters/ghostscript.c
cupsfilters/ieee1284.c
cupsfilters/ieee1284.h
cupsfilters/image-bmp.c [deleted file]
cupsfilters/image-colorspace.c
cupsfilters/image-jpeg.c
cupsfilters/image-png.c
cupsfilters/image-private.h
cupsfilters/image-tiff.c
cupsfilters/image-zoom.c
cupsfilters/image.c
cupsfilters/image.h
cupsfilters/imagetopdf.c
cupsfilters/imagetoraster.c

index 6f1e9a5a86c5922f220e68a3efa5cb55d92bb96d..065f2549fe1bcb8b39fd63c92062f6bde657a260 100644 (file)
@@ -1,15 +1,15 @@
-/*
- * Ghostscript filter function for cups-filters.
- *
- * Used for PostScript -> PDF, PDF -> Raster, PDF -> PCL-XL
- *
- * Copyright (c) 2008-2020, Till Kamppeter
- * Copyright (c) 2011, Tim Waugh
- * Copyright (c) 2011-2013, Richard Hughes
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
+//
+// Ghostscript filter function for cups-filters.
+//
+// Used for PostScript -> PDF, PDF -> Raster, PDF -> PCL-XL
+//
+// Copyright (c) 2008-2020, Till Kamppeter
+// Copyright (c) 2011, Tim Waugh
+// Copyright (c) 2011-2013, Richard Hughes
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #include <config.h>
 #include <cups/cups.h>
@@ -32,7 +32,8 @@
 
 #define PDF_MAX_CHECK_COMMENT_LINES    20
 
-typedef enum gs_doc_e {
+typedef enum gs_doc_e
+{
   GS_DOC_TYPE_PDF,
   GS_DOC_TYPE_PS,
   GS_DOC_TYPE_EMPTY,
@@ -43,7 +44,7 @@ typedef enum gs_doc_e {
 typedef cups_page_header2_t gs_page_header;
 #else
 typedef cups_page_header_t gs_page_header;
-#endif /* CUPS_RASTER_SYNCv1 */
+#endif // CUPS_RASTER_SYNCv1
 
 static gs_doc_t
 parse_doc_type(FILE *fp)
@@ -52,96 +53,115 @@ parse_doc_type(FILE *fp)
   int is_empty = 1;
   gs_doc_t type = GS_DOC_TYPE_UNKNOWN;
 
-  /* get the first few bytes of the file */
+  // get the first few bytes of the file
   rewind(fp);
-  /* skip until PDF/PS start header */
-  while (fgets(buf,sizeof(buf),fp) != 0) {
-    if (is_empty && buf[0] != '\n') is_empty = 0;
-    if (strncmp(buf,"%PDF",4) == 0) type = GS_DOC_TYPE_PDF;
-    if (strncmp(buf,"%!",2) == 0) type = GS_DOC_TYPE_PS;
-    if (type != GS_DOC_TYPE_UNKNOWN) break;
+  // skip until PDF/PS start header
+  while (fgets(buf, sizeof(buf), fp) != 0)
+  {
+    if (is_empty && buf[0] != '\n')
+      is_empty = 0;
+    if (strncmp(buf ,"%PDF", 4) == 0)
+      type = GS_DOC_TYPE_PDF;
+    if (strncmp(buf, "%!", 2) == 0)
+      type = GS_DOC_TYPE_PS;
+    if (type != GS_DOC_TYPE_UNKNOWN)
+      break;
   }
-  if (is_empty) type = GS_DOC_TYPE_EMPTY;
+  if (is_empty)
+    type = GS_DOC_TYPE_EMPTY;
   rewind(fp);
-  return type;
+  return (type);
 }
 
 static void
-parse_pdf_header_options(FILE *fp, gs_page_header *h)
+parse_pdf_header_options(FILE *fp,
+                        gs_page_header *h)
 {
   char buf[4096];
   int i;
 
   rewind(fp);
-  /* skip until PDF start header */
-  while (fgets(buf,sizeof(buf),fp) != 0) {
-    if (strncmp(buf,"%PDF",4) == 0) {
+  // skip until PDF start header
+  while (fgets(buf, sizeof(buf), fp) != 0)
+    if (strncmp(buf, "%PDF", 4) == 0)
       break;
-    }
-  }
-  for (i = 0;i < PDF_MAX_CHECK_COMMENT_LINES;i++) {
-    if (fgets(buf,sizeof(buf),fp) == 0) break;
-    if (strncmp(buf,"%%PDFTOPDFNumCopies",19) == 0) {
+  for (i = 0; i < PDF_MAX_CHECK_COMMENT_LINES; i++)
+  {
+    if (fgets(buf, sizeof(buf), fp) == 0)
+      break;
+    if (strncmp(buf, "%%PDFTOPDFNumCopies", 19) == 0)
+    {
       char *p;
 
-      p = strchr(buf+19,':');
-      h->NumCopies = atoi(p+1);
-    } else if (strncmp(buf,"%%PDFTOPDFCollate",17) == 0) {
+      p = strchr(buf + 19, ':');
+      h->NumCopies = atoi(p + 1);
+    }
+    else if (strncmp(buf, "%%PDFTOPDFCollate", 17) == 0)
+    {
       char *p;
 
-      p = strchr(buf+17,':');
-      while (*p == ' ' || *p == '\t') p++;
-      if (strncasecmp(p,"true",4) == 0) {
+      p = strchr(buf + 17, ':');
+      while (*p == ' ' || *p == '\t')
+       p ++;
+      if (strncasecmp(p, "true", 4) == 0)
         h->Collate = CUPS_TRUE;
-      } else {
+      else
         h->Collate = CUPS_FALSE;
-      }
     }
   }
 }
 
 static void
-header_to_gs_args(gs_page_header *h, cups_array_t *gs_args,
-                 cf_filter_out_format_t outformat, int pxlcolor)
+header_to_gs_args(gs_page_header *h,
+                 cups_array_t *gs_args,
+                 cf_filter_out_format_t outformat,
+                 int pxlcolor)
 {
   int i;
   char tmpstr[1024];
 
-  /* Simple boolean, enumerated choice, numerical, and string parameters */
+  // Simple boolean, enumerated choice, numerical, and string parameters
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER) {
+      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
+  {
     if (outformat != CF_FILTER_OUT_FORMAT_APPLE_RASTER &&
-       (h->MediaClass[0] |= '\0')) {
+       (h->MediaClass[0] |= '\0'))
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-sMediaClass=%s", h->MediaClass);
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->MediaColor[0] |= '\0') {
+    if (h->MediaColor[0] |= '\0')
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-sMediaColor=%s", h->MediaColor);
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->MediaType[0] |= '\0') {
+    if (h->MediaType[0] |= '\0')
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-sMediaType=%s", h->MediaType);
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->OutputType[0] |= '\0') {
+    if (h->OutputType[0] |= '\0')
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-sOutputType=%s", h->OutputType);
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->AdvanceDistance) {
+    if (h->AdvanceDistance)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dAdvanceDistance=%d",
               (unsigned)(h->AdvanceDistance));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->AdvanceMedia) {
+    if (h->AdvanceMedia)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dAdvanceMedia=%d",
               (unsigned)(h->AdvanceMedia));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->Collate) {
+    if (h->Collate)
       cupsArrayAdd(gs_args, strdup("-dCollate"));
-    }
-    if (h->CutMedia) {
+    if (h->CutMedia)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dCutMedia=%d",
               (unsigned)(h->CutMedia));
       cupsArrayAdd(gs_args, strdup(tmpstr));
@@ -150,75 +170,80 @@ header_to_gs_args(gs_page_header *h, cups_array_t *gs_args,
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_PXL) {
-    /* PDF output is only for turning PostScript input data into PDF
-       not for sending PDF to a PDF printer (this is done by pdftopdf)
-       therefore we do not apply duplex/tumble here. */
-    if (h->Duplex) {
+      outformat == CF_FILTER_OUT_FORMAT_PXL)
+  {
+    // PDF output is only for turning PostScript input data into PDF
+    // not for sending PDF to a PDF printer (this is done by pdftopdf)
+    // therefore we do not apply duplex/tumble here.
+    if (h->Duplex)
       cupsArrayAdd(gs_args, strdup("-dDuplex"));
-    }
   }
-  if (outformat != CF_FILTER_OUT_FORMAT_PCLM) {
-    /* In PCLM we have our own method to generate the needed
-       resolution, to respect the printer's supported resolutions for
-       PCLm, so this is only for non-PCLm output formats */
+  if (outformat != CF_FILTER_OUT_FORMAT_PCLM)
+  {
+    // In PCLM we have our own method to generate the needed
+    // resolution, to respect the printer's supported resolutions for
+    // PCLm, so this is only for non-PCLm output formats
     snprintf(tmpstr, sizeof(tmpstr), "-r%dx%d",
             h->HWResolution[0], h->HWResolution[1]);
     cupsArrayAdd(gs_args, strdup(tmpstr));
   }
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER) {
-    if (h->InsertSheet) {
+      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
+  {
+    if (h->InsertSheet)
       cupsArrayAdd(gs_args, strdup("-dInsertSheet"));
-    }
-    if (h->Jog) {
+    if (h->Jog)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dJog=%d",
               (unsigned)(h->Jog));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->LeadingEdge) {
+    if (h->LeadingEdge)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dLeadingEdge=%d",
               (unsigned)(h->LeadingEdge));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->ManualFeed) {
+    if (h->ManualFeed)
       cupsArrayAdd(gs_args, strdup("-dManualFeed"));
-    }
   }
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_PXL) {
-    if (h->MediaPosition) {
+      outformat == CF_FILTER_OUT_FORMAT_PXL)
+  {
+    if (h->MediaPosition)
+    {
       int mediapos;
-      if (outformat == CF_FILTER_OUT_FORMAT_PXL) {
-       /* Convert PWG MediaPosition values to PXL-ones */
-       if (h->MediaPosition == 1) /* Main */
+      if (outformat == CF_FILTER_OUT_FORMAT_PXL)
+      {
+       // Convert PWG MediaPosition values to PXL-ones
+       if (h->MediaPosition == 1) // Main
          mediapos = 4;
-       else if (h->MediaPosition == 2) /* Alternate */
+       else if (h->MediaPosition == 2) // Alternate
          mediapos = 5;
-       else if (h->MediaPosition == 3) /* Large Capacity */
+       else if (h->MediaPosition == 3) // Large Capacity
          mediapos = 7;
-       else if (h->MediaPosition == 4) /* Manual */
+       else if (h->MediaPosition == 4) // Manual
          mediapos = 2;
-       else if (h->MediaPosition == 5) /* Envelope */
+       else if (h->MediaPosition == 5) // Envelope
          mediapos = 6;
-       else if (h->MediaPosition == 11) /* Top */
+       else if (h->MediaPosition == 11) // Top
          mediapos = 4;
-       else if (h->MediaPosition == 12) /* Middle */
+       else if (h->MediaPosition == 12) // Middle
          mediapos = 5;
-       else if (h->MediaPosition == 13) /* Bottom */
+       else if (h->MediaPosition == 13) // Bottom
          mediapos = 7;
-       else if (h->MediaPosition == 19) /* Bypass */
+       else if (h->MediaPosition == 19) // Bypass
          mediapos = 3;
-       else if (h->MediaPosition == 20) /* Tray 1 */
+       else if (h->MediaPosition == 20) // Tray 1
          mediapos = 3;
-       else if (h->MediaPosition == 21) /* Tray 2 */
+       else if (h->MediaPosition == 21) // Tray 2
          mediapos = 4;
-       else if (h->MediaPosition == 22) /* Tray 3 */
+       else if (h->MediaPosition == 22) // Tray 3
          mediapos = 5;
-       else if (h->MediaPosition == 23) /* Tray 4 */
+       else if (h->MediaPosition == 23) // Tray 4
          mediapos = 7;
        else
          mediapos = 0;
@@ -231,61 +256,63 @@ header_to_gs_args(gs_page_header *h, cups_array_t *gs_args,
   }
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER) {
-    if (h->MediaWeight) {
+      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
+  {
+    if (h->MediaWeight)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dMediaWeight=%d",
               (unsigned)(h->MediaWeight));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->MirrorPrint) {
+    if (h->MirrorPrint)
       cupsArrayAdd(gs_args, strdup("-dMirrorPrint"));
-    }
-    if (h->NegativePrint) {
+    if (h->NegativePrint)
       cupsArrayAdd(gs_args, strdup("-dNegativePrint"));
-    }
-    if (h->NumCopies != 1) {
+    if (h->NumCopies != 1)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dNumCopies=%d",
               (unsigned)(h->NumCopies));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->Orientation) {
+    if (h->Orientation)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dOrientation=%d",
               (unsigned)(h->Orientation));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->OutputFaceUp) {
+    if (h->OutputFaceUp)
       cupsArrayAdd(gs_args, strdup("-dOutputFaceUp"));
-    }
   }
-  snprintf(tmpstr, sizeof(tmpstr), "-dDEVICEWIDTHPOINTS=%d",h->PageSize[0]);
+  snprintf(tmpstr, sizeof(tmpstr), "-dDEVICEWIDTHPOINTS=%d", h->PageSize[0]);
   cupsArrayAdd(gs_args, strdup(tmpstr));
-  snprintf(tmpstr, sizeof(tmpstr), "-dDEVICEHEIGHTPOINTS=%d",h->PageSize[1]);
+  snprintf(tmpstr, sizeof(tmpstr), "-dDEVICEHEIGHTPOINTS=%d", h->PageSize[1]);
   cupsArrayAdd(gs_args, strdup(tmpstr));
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER) {
-    if (h->Separations) {
+      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
+  {
+    if (h->Separations)
       cupsArrayAdd(gs_args, strdup("-dSeparations"));
-    }
-    if (h->TraySwitch) {
+    if (h->TraySwitch)
       cupsArrayAdd(gs_args, strdup("-dTraySwitch"));
-    }
   }
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_PXL) {
-    /* PDF output is only for turning PostScript input data into PDF
-       not for sending PDF to a PDF printer (this is done by pdftopdf)
-       therefore we do not apply duplex/tumble here. */
-    if (h->Tumble) {
+      outformat == CF_FILTER_OUT_FORMAT_PXL)
+  {
+    // PDF output is only for turning PostScript input data into PDF
+    // not for sending PDF to a PDF printer (this is done by pdftopdf)
+    // therefore we do not apply duplex/tumble here.
+    if (h->Tumble)
       cupsArrayAdd(gs_args, strdup("-dTumble"));
-    }
   }
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER) {
-    if (h->cupsMediaType) {
+      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
+  {
+    if (h->cupsMediaType)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dcupsMediaType=%d",
               (unsigned)(h->cupsMediaType));
       cupsArrayAdd(gs_args, strdup(tmpstr));
@@ -299,7 +326,8 @@ header_to_gs_args(gs_page_header *h, cups_array_t *gs_args,
     cupsArrayAdd(gs_args, strdup(tmpstr));
   }
   
-  if (outformat == CF_FILTER_OUT_FORMAT_PXL) {
+  if (outformat == CF_FILTER_OUT_FORMAT_PXL)
+  {
     if (h->cupsColorSpace == CUPS_CSPACE_W ||
        h->cupsColorSpace == CUPS_CSPACE_K ||
        h->cupsColorSpace == CUPS_CSPACE_WHITE ||
@@ -308,7 +336,7 @@ header_to_gs_args(gs_page_header *h, cups_array_t *gs_args,
        h->cupsColorSpace == CUPS_CSPACE_SW ||
        h->cupsColorSpace == CUPS_CSPACE_ICC1 ||
        h->cupsColorSpace == CUPS_CSPACE_DEVICE1)
-      /* Monochrome color spaces -> use "pxlmono" device */
+      // Monochrome color spaces -> use "pxlmono" device
       pxlcolor = 0;
     if (pxlcolor == 1)
       cupsArrayAdd(gs_args, strdup("-sDEVICE=pxlcolor"));
@@ -317,23 +345,28 @@ header_to_gs_args(gs_page_header *h, cups_array_t *gs_args,
   }
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER) {
-    if (h->cupsCompression) {
+      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
+  {
+    if (h->cupsCompression)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dcupsCompression=%d",
               (unsigned)(h->cupsCompression));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->cupsRowCount) {
+    if (h->cupsRowCount)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dcupsRowCount=%d",
               (unsigned)(h->cupsRowCount));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->cupsRowFeed) {
+    if (h->cupsRowFeed)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dcupsRowFeed=%d",
               (unsigned)(h->cupsRowFeed));
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->cupsRowStep) {
+    if (h->cupsRowStep)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dcupsRowStep=%d",
               (unsigned)(h->cupsRowStep));
       cupsArrayAdd(gs_args, strdup(tmpstr));
@@ -342,47 +375,55 @@ header_to_gs_args(gs_page_header *h, cups_array_t *gs_args,
 #ifdef CUPS_RASTER_SYNCv1
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
-      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER) {
-    if (h->cupsBorderlessScalingFactor != 1.0f) {
+      outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
+  {
+    if (h->cupsBorderlessScalingFactor != 1.0f)
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-dcupsBorderlessScalingFactor=%.4f",
               h->cupsBorderlessScalingFactor);
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
     for (i=0; i <= 15; i ++)
-      if (h->cupsInteger[i]) {
+      if (h->cupsInteger[i])
+      {
        snprintf(tmpstr, sizeof(tmpstr), "-dcupsInteger%d=%d",
                 i, (unsigned)(h->cupsInteger[i]));
        cupsArrayAdd(gs_args, strdup(tmpstr));
       }
     for (i=0; i <= 15; i ++)
-      if (h->cupsReal[i]) {
+      if (h->cupsReal[i])
+      {
        snprintf(tmpstr, sizeof(tmpstr), "-dcupsReal%d=%.4f",
                 i, h->cupsReal[i]);
        cupsArrayAdd(gs_args, strdup(tmpstr));
       }
     for (i=0; i <= 15; i ++)
-      if (h->cupsString[i][0] != '\0') {
+      if (h->cupsString[i][0] != '\0')
+      {
        snprintf(tmpstr, sizeof(tmpstr), "-scupsString%d=%s",
                 i, h->cupsString[i]);
        cupsArrayAdd(gs_args, strdup(tmpstr));
       }
-    if (h->cupsMarkerType[0] != '\0') {
+    if (h->cupsMarkerType[0] != '\0')
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-scupsMarkerType=%s",
               h->cupsMarkerType);
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->cupsRenderingIntent[0] != '\0') {
+    if (h->cupsRenderingIntent[0] != '\0')
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-scupsRenderingIntent=%s",
               h->cupsRenderingIntent);
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
-    if (h->cupsPageSizeName[0] != '\0') {
+    if (h->cupsPageSizeName[0] != '\0')
+    {
       snprintf(tmpstr, sizeof(tmpstr), "-scupsPageSizeName=%s",
               h->cupsPageSizeName);
       cupsArrayAdd(gs_args, strdup(tmpstr));
     }
   }
-#endif /* CUPS_RASTER_SYNCv1 */
+#endif // CUPS_RASTER_SYNCv1
 }
 
 static int
@@ -411,22 +452,23 @@ gs_spawn (const char *filename,
   int status = 65536;
   int wstatus;
 
-  /* Put Ghostscript command line argument into an array for the "exec()"
-     call */
+  // Put Ghostscript command line argument into an array for the "exec()"
+  // call
   numargs = cupsArrayCount(gs_args);
   gsargv = calloc(numargs + 1, sizeof(char *));
   for (argument = (char *)cupsArrayFirst(gs_args), i = 0; argument;
-       argument = (char *)cupsArrayNext(gs_args), i++) {
+       argument = (char *)cupsArrayNext(gs_args), i++)
     gsargv[i] = argument;
-  }
   gsargv[i] = NULL;
 
-  if (log) {
-    /* Debug output: Full Ghostscript command line and environment variables */
+  if (log)
+  {
+    // Debug output: Full Ghostscript command line and environment variables
     snprintf(buf, sizeof(buf),
             "cfFilterGhostscript: Ghostscript command line:");
-    for (i = 0; gsargv[i]; i ++) {
-      if ((strchr(gsargv[i],' ')) || (strchr(gsargv[i],'\t')))
+    for (i = 0; gsargv[i]; i ++)
+    {
+      if ((strchr(gsargv[i],' ')) || (strchr(gsargv[i], '\t')))
        apos = "'";
       else
        apos = "";
@@ -440,7 +482,7 @@ gs_spawn (const char *filename,
          "cfFilterGhostscript: envp[%d]=\"%s\"", i, envp[i]);
   }
 
-  /* Create a pipe for feeding the job into Ghostscript */
+  // Create a pipe for feeding the job into Ghostscript
   if (pipe(infds))
   {
     infds[0] = -1;
@@ -450,7 +492,7 @@ gs_spawn (const char *filename,
     goto out;
   }
 
-  /* Create a pipe for stderr output of Ghostscript */
+  // Create a pipe for stderr output of Ghostscript
   if (pipe(errfds))
   {
     errfds[0] = -1;
@@ -460,7 +502,7 @@ gs_spawn (const char *filename,
     goto out;
   }
 
-  /* Set the "close on exec" flag on each end of the pipes... */
+  // Set the "close on exec" flag on each end of the pipes...
   if (fcntl(infds[0], F_SETFD, fcntl(infds[0], F_GETFD) | FD_CLOEXEC))
   {
     close(infds[0]);
@@ -500,10 +542,13 @@ gs_spawn (const char *filename,
 
   if ((gspid = fork()) == 0)
   {
-    /* Couple infds pipe with stdin of Ghostscript process */
-    if (infds[0] >= 0) {
-      if (infds[0] != 0) {
-       if (dup2(infds[0], 0) < 0) {
+    // Couple infds pipe with stdin of Ghostscript process
+    if (infds[0] >= 0)
+    {
+      if (infds[0] != 0)
+      {
+       if (dup2(infds[0], 0) < 0)
+       {
          if (log) log(ld, CF_LOGLEVEL_ERROR,
                       "cfFilterGhostscript: Unable to couple pipe with stdin of Ghostscript process");
          exit(1);
@@ -511,16 +556,21 @@ gs_spawn (const char *filename,
        close(infds[0]);
       }
       close(infds[1]);
-    } else {
+    }
+    else
+    {
       if (log) log(ld, CF_LOGLEVEL_ERROR,
                   "cfFilterGhostscript: invalid pipe file descriptor to couple with stdin of Ghostscript process");
       exit(1);
     }
 
-    /* Couple errfds pipe with stdin of Ghostscript process */
-    if (errfds[1] >= 2) {
-      if (errfds[1] != 2) {
-       if (dup2(errfds[1], 2) < 0) {
+    // Couple errfds pipe with stdin of Ghostscript process
+    if (errfds[1] >= 2)
+    {
+      if (errfds[1] != 2)
+      {
+       if (dup2(errfds[1], 2) < 0)
+       {
          if (log) log(ld, CF_LOGLEVEL_ERROR,
                       "cfFilterGhostscript: Unable to couple pipe with stderr of Ghostscript process");
          exit(1);
@@ -528,29 +578,36 @@ gs_spawn (const char *filename,
        close(errfds[1]);
       }
       close(errfds[0]);
-    } else {
+    }
+    else
+    {
       if (log) log(ld, CF_LOGLEVEL_ERROR,
                   "cfFilterGhostscript: invalid pipe file descriptor to couple with stderr of Ghostscript process");
       exit(1);
     }
 
-    /* Couple stdout of Ghostscript process */
-    if (outputfd >= 1) {
-      if (outputfd != 1) {
-       if (dup2(outputfd, 1) < 0) {
+    // Couple stdout of Ghostscript process
+    if (outputfd >= 1)
+    {
+      if (outputfd != 1)
+      {
+       if (dup2(outputfd, 1) < 0)
+       {
          if (log) log(ld, CF_LOGLEVEL_ERROR,
                       "cfFilterGhostscript: Unable to couple stdout of Ghostscript process");
          exit(1);
        }
        close(outputfd);
       }
-    } else {
+    }
+    else
+    {
       if (log) log(ld, CF_LOGLEVEL_ERROR,
                   "cfFilterGhostscript: Invalid file descriptor to couple with stdout of Ghostscript process");
       exit(1);
     }
 
-    /* Execute Ghostscript command line ... */
+    // Execute Ghostscript command line ...
     execvpe(filename, gsargv, envp);
     if (log) log(ld, CF_LOGLEVEL_ERROR,
                 "cfFilterGhostscript: Unable to launch Ghostscript: %s: %s",
@@ -568,32 +625,46 @@ gs_spawn (const char *filename,
     close(infds[1]);
     logfp = cupsFileOpenFd(errfds[0], "r");
     while (cupsFileGets(logfp, buf, sizeof(buf)))
-      if (log) {
-       if (strncmp(buf, "DEBUG: ", 7) == 0) {
+      if (log)
+      {
+       if (strncmp(buf, "DEBUG: ", 7) == 0)
+       {
          log_level = CF_LOGLEVEL_DEBUG;
          msg = buf + 7;
-       } else if (strncmp(buf, "DEBUG2: ", 8) == 0) {
+       }
+       else if (strncmp(buf, "DEBUG2: ", 8) == 0)
+       {
          log_level = CF_LOGLEVEL_DEBUG;
          msg = buf + 8;
-       } else if (strncmp(buf, "INFO: ", 6) == 0) {
+       }
+       else if (strncmp(buf, "INFO: ", 6) == 0)
+       {
          log_level = CF_LOGLEVEL_INFO;
          msg = buf + 6;
-       } else if (strncmp(buf, "WARNING: ", 9) == 0) {
+       }
+       else if (strncmp(buf, "WARNING: ", 9) == 0)
+       {
          log_level = CF_LOGLEVEL_WARN;
          msg = buf + 9;
-       } else if (strncmp(buf, "ERROR: ", 7) == 0) {
+       }
+       else if (strncmp(buf, "ERROR: ", 7) == 0)
+       {
          log_level = CF_LOGLEVEL_ERROR;
          msg = buf + 7;
-       } else {
+       }
+       else
+       {
          log_level = CF_LOGLEVEL_DEBUG;
          msg = buf;
        }
        log(ld, log_level, "cfFilterGhostscript: %s", msg);
       }
+
     cupsFileClose(logfp);
-    /* No need to close the fd errfds[0], as cupsFileClose(fp) does this
-       already */
-    /* Ignore errors of the logging process */
+
+    // No need to close the fd errfds[0], as cupsFileClose(fp) does this
+    // already
+    // Ignore errors of the logging process
     exit(0);
   }
   if (log) log(ld, CF_LOGLEVEL_DEBUG,
@@ -601,14 +672,17 @@ gs_spawn (const char *filename,
 
   close(errfds[0]);
 
-  /* Feed job data into Ghostscript */
+  // Feed job data into Ghostscript
   while ((!iscanceled || !iscanceled(icd)) &&
-        (n = fread(buf, 1, BUFSIZ, fp)) > 0) {
+        (n = fread(buf, 1, BUFSIZ, fp)) > 0)
+  {
     int count;
   retry_write:
     count = write(infds[1], buf, n);
-    if (count != n) {
-      if (count == -1) {
+    if (count != n)
+    {
+      if (count == -1)
+      {
         if (errno == EINTR)
           goto retry_write;
        if (log) log(ld, CF_LOGLEVEL_ERROR,
@@ -623,9 +697,12 @@ gs_spawn (const char *filename,
   if (log) log(ld, CF_LOGLEVEL_DEBUG,
               "cfFilterGhostscript: Input data feed completed");
 
-  while (gspid > 0 || errpid > 0) {
-    if ((pid = wait(&wstatus)) < 0) {
-      if (errno == EINTR && iscanceled && iscanceled(icd)) {
+  while (gspid > 0 || errpid > 0)
+  {
+    if ((pid = wait(&wstatus)) < 0)
+    {
+      if (errno == EINTR && iscanceled && iscanceled(icd))
+      {
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterGhostscript: Job canceled, killing Ghostscript ...");
        kill(gspid, SIGTERM);
@@ -633,28 +710,35 @@ gs_spawn (const char *filename,
        kill(errpid, SIGTERM);
        errpid = -1;
        break;
-      } else
+      }
+      else
        continue;
     }
 
-    /* How did the filter terminate */
-    if (wstatus) {
-      if (WIFEXITED(wstatus)) {
-       /* Via exit() anywhere or return() in the main() function */
+    // How did the filter terminate
+    if (wstatus)
+    {
+      if (WIFEXITED(wstatus))
+      {
+       // Via exit() anywhere or return() in the main() function
        if (log) log(ld, CF_LOGLEVEL_ERROR,
                     "cfFilterGhostscript: %s (PID %d) stopped with status %d",
                     (pid == gspid ? "Ghostscript" : "Logging"), pid,
                     WEXITSTATUS(wstatus));
        status = WEXITSTATUS(wstatus);
-      } else {
-       /* Via signal */
+      }
+      else
+      {
+       // Via signal
        if (log) log(ld, CF_LOGLEVEL_ERROR,
                     "cfFilterGhostscript: %s (PID %d) crashed on signal %d",
                     (pid == gspid ? "Ghostscript" : "Logging"), pid,
                     WTERMSIG(wstatus));
        status = 256 * WTERMSIG(wstatus);
       }
-    } else {
+    }
+    else
+    {
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterGhostscript: %s (PID %d) exited with no errors.",
                   (pid == gspid ? "Ghostscript" : "Logging"), pid);
@@ -662,28 +746,29 @@ gs_spawn (const char *filename,
     }
     if (pid == gspid)
       gspid = -1;
-    else  if (pid == errpid)
+    else if (pid == errpid)
       errpid = -1;
   }
 
-out:
+ out:
   free(gsargv);
-  return status;
+
+  return (status);
 }
 
-/*
- * 'cfFilterGhostscript()' - Filter function to use Ghostscript for print
- *                           data conversions
- */
-
-int                                         /* O - Error status */
-cfFilterGhostscript(int inputfd,            /* I - File descriptor input
-                                                  stream */
-                   int outputfd,           /* I - File descriptor output
-                                                  stream */
-                   int inputseekable,      /* I - Is input stream seekable? */
-                   cf_filter_data_t *data, /* I - Job and printer data */
-                   void *parameters)       /* I - Filter-specific parameters */
+//
+// 'cfFilterGhostscript()' - Filter function to use Ghostscript for print
+//                           data conversions
+//
+
+int                                         // O - Error status
+cfFilterGhostscript(int inputfd,            // I - File descriptor input
+                                           //     stream
+                   int outputfd,           // I - File descriptor output
+                                           //     stream
+                   int inputseekable,      // I - Is input stream seekable?
+                   cf_filter_data_t *data, // I - Job and printer data
+                   void *parameters)       // I - Filter-specific parameters
 {
   cf_filter_out_format_t outformat;
   char buf[BUFSIZ];
@@ -711,7 +796,7 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
   ipp_t *job_attrs = data->job_attrs;
   struct sigaction sa;
   cf_cm_calibration_t cm_calibrate;
-  int pxlcolor = 0; /* 1 if printer is color printer otherwise 0. */
+  int pxlcolor = 0; // 1 if printer is color printer otherwise 0.
   ipp_attribute_t *ipp_attr;
   cf_logfunc_t log = data->logfunc;
   void          *ld = data->logdata;
@@ -753,14 +838,16 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
       outformat = CF_FILTER_OUT_FORMAT_CUPS_RASTER;
   }
 
-  /* Note: With the CF_FILTER_OUT_FORMAT_APPLE_RASTER selection and a
-     Ghostscript version without "appleraster" output device (9.55.x
-     and older) the output is actually CUPS Raster but information
-     about available color spaces and depths is taken from the
-     urf-supported printer IPP attribute. This mode is for further
-     processing with rastertopwg. With Ghostscript supporting Apple
-     Raster output (9.56.0 and newer), we actually produce Apple
-     Raster and no further filter is required. */
+  //
+  // Note: With the CF_FILTER_OUT_FORMAT_APPLE_RASTER selection and a
+  // Ghostscript version without "appleraster" output device (9.55.x
+  // and older) the output is actually CUPS Raster but information
+  // about available color spaces and depths is taken from the
+  // urf-supported printer IPP attribute. This mode is for further
+  // processing with rastertopwg. With Ghostscript supporting Apple
+  // Raster output (9.56.0 and newer), we actually produce Apple
+  // Raster and no further filter is required.
+  //
 
   if (log) log(ld, CF_LOGLEVEL_DEBUG,
               "cfFilterGhostscript: Output format: %s",
@@ -775,20 +862,20 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
                     "PCL XL")))))));
   
   memset(&sa, 0, sizeof(sa));
-  /* Ignore SIGPIPE and have write return an error instead */
+  // Ignore SIGPIPE and have write return an error instead
   sa.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &sa, NULL);
 
- /*
-  * CUPS option list
-  */
+  //
+  // CUPS option list
+  //
 
   num_options = data->num_options;
   options = data->options;
 
- /*
-  * Environment variables for Ghostscript call ...
-  */
+  //
+  // Environment variables for Ghostscript call ...
+  // 
 
   if ((t = getenv("LD_LIBRARY_PATH")) != NULL)
   {
@@ -806,9 +893,9 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
 
   envp[num_env] = NULL;
 
- /*
-  * Open the input data stream specified by the inputfd ...
-  */
+  //
+  // Open the input data stream specified by the inputfd ...
+  //
 
   if ((fp = fdopen(inputfd, "r")) == NULL)
   {
@@ -821,9 +908,9 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
     return (1);
   }
 
- /*
-  * Streaming mode without pre-checking input format or zero-page jobs
-  */
+  //
+  // Streaming mode without pre-checking input format or zero-page jobs
+  //
 
   if ((t = cupsGetOption("filter-streaming-mode", num_options, options)) ==
        NULL ||
@@ -831,24 +918,26 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
        !strcasecmp(t, "no")))
   {
 
-   /*
-    * Find out file type ...
-    */
+    //
+    // Find out file type ...
+    //
 
     if (inputseekable)
       doc_type = parse_doc_type(fp);
 
-   /*
-    * Copy input into temporary file if needed ...
-    * (If the input is not seekable or if it is PostScript, to be able
-    *  to count the pages)
-    */
+    //
+    // Copy input into temporary file if needed ...
+    // (If the input is not seekable or if it is PostScript, to be able
+    //  to count the pages)
+    //
 
-    if (!inputseekable || doc_type == GS_DOC_TYPE_PS) {
+    if (!inputseekable || doc_type == GS_DOC_TYPE_PS)
+    {
       if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
       {
        if (log) log(ld, CF_LOGLEVEL_ERROR,
-                    "cfFilterGhostscript: Unable to copy PDF file: %s", strerror(errno));
+                    "cfFilterGhostscript: Unable to copy PDF file: %s",
+                    strerror(errno));
        fclose(fp);
        return (1);
       }
@@ -865,9 +954,9 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
 
       filename = tempfile;
 
-     /*
-      * Open the temporary file to read it instead of the original input ...
-      */
+      //
+      // Open the temporary file to read it instead of the original input ...
+      //
 
       if ((fp = fopen(filename, "r")) == NULL)
       {
@@ -885,7 +974,8 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
     if (!inputseekable)
       doc_type = parse_doc_type(fp);
 
-    if (doc_type == GS_DOC_TYPE_EMPTY) {
+    if (doc_type == GS_DOC_TYPE_EMPTY)
+    {
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterGhostscript: Input is empty, outputting empty file.");
       status = 0;
@@ -894,16 +984,20 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
          outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
        if (write(outputfd, "RaS2", 4)) {};
       goto out;
-    } if (doc_type == GS_DOC_TYPE_UNKNOWN) {
+    }
+    if (doc_type == GS_DOC_TYPE_UNKNOWN)
+    {
       if (log) log(ld, CF_LOGLEVEL_ERROR,
                   "cfFilterGhostscript: Can't detect file type");
       goto out;
     }
 
-    if (doc_type == GS_DOC_TYPE_PDF) {
+    if (doc_type == GS_DOC_TYPE_PDF)
+    {
       int pages = cfPDFPagesFP(fp);
 
-      if (pages == 0) {
+      if (pages == 0)
+      {
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterGhostscript: No pages left, outputting empty file.");
        status = 0;
@@ -913,24 +1007,28 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
          if (write(outputfd, "RaS2", 4)) {};
        goto out;
       }
-      if (pages < 0) {
+      if (pages < 0)
+      {
        if (log) log(ld, CF_LOGLEVEL_ERROR,
                     "cfFilterGhostscript: Unexpected page count");
        goto out;
       }
-    } else {
+    }
+    else
+    {
       char gscommand[65536];
       char output[31] = "";
       int pagecount;
       size_t bytes;
-      /* Ghostscript runs too long on files converted from djvu files */
-      /* Using -dDEVICEWIDTHPOINTS -dDEVICEHEIGHTPOINTS params solves the
-        problem */
+      // Ghostscript runs too long on files converted from djvu files
+      // Using -dDEVICEWIDTHPOINTS -dDEVICEHEIGHTPOINTS params solves the
+      // problem
       snprintf(gscommand, 65536, "%s -q -dNOPAUSE -dBATCH -sDEVICE=bbox -dDEVICEWIDTHPOINTS=1 -dDEVICEHEIGHTPOINTS=1 %s 2>&1 | grep -c HiResBoundingBox",
               CUPS_GHOSTSCRIPT, filename);
     
       FILE *pd = popen(gscommand, "r");
-      if (!pd) {
+      if (!pd)
+      {
        if (log) log(ld, CF_LOGLEVEL_ERROR,
                     "cfFilterGhostscript: Failed to execute ghostscript to determine "
                     "number of input pages!");
@@ -943,7 +1041,8 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
       if (bytes <= 0 || sscanf(output, "%d", &pagecount) < 1)
        pagecount = -1;
 
-      if (pagecount == 0) {
+      if (pagecount == 0)
+      {
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterGhostscript: No pages left, outputting empty file.");
        status = 0;
@@ -953,15 +1052,17 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
          if (write(outputfd, "RaS2", 4)) {};
        goto out;
       }
-      if (pagecount < 0) {
+      if (pagecount < 0)
+      {
        if (log) log(ld, CF_LOGLEVEL_ERROR,
                     "cfFilterGhostscript: Unexpected page count");
        goto out;
       }
     }
 
-    if (filename) {
-      /* Remove name of temp file*/
+    if (filename)
+    {
+      // Remove name of temp file
       unlink(filename);
       filename = NULL;
     }
@@ -982,20 +1083,21 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
                 "cfFilterGhostscript: Streaming mode, no checks for input format, zero-page input, instructions from previous filter");
   }
 
-  /* Ghostscript parameters */
+  // Ghostscript parameters
   gs_args = cupsArrayNew(NULL, NULL);
-  if (!gs_args) {
+  if (!gs_args)
+  {
     if (log) log(ld, CF_LOGLEVEL_ERROR,
                 "cfFilterGhostscript: Unable to allocate memory for Ghostscript arguments array");
     goto out;
   }
 
-  /* Part of Ghostscript command line which is not dependent on the job and/or
-     the driver */
+  // Part of Ghostscript command line which is not dependent on the job and/or
+  // the driver
   snprintf(tmpstr, sizeof(tmpstr), "%s", CUPS_GHOSTSCRIPT);
   cupsArrayAdd(gs_args, strdup(tmpstr));
   cupsArrayAdd(gs_args, strdup("-dQUIET"));
-  /*cupsArrayAdd(gs_args, strdup("-dDEBUG"));*/
+  //cupsArrayAdd(gs_args, strdup("-dDEBUG"));
   cupsArrayAdd(gs_args, strdup("-dSAFER"));
   cupsArrayAdd(gs_args, strdup("-dNOPAUSE"));
   cupsArrayAdd(gs_args, strdup("-dBATCH"));
@@ -1008,7 +1110,7 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
   cupsArrayAdd(gs_args, strdup("-sstdout=%stderr"));
   cupsArrayAdd(gs_args, strdup("-sOutputFile=%stdout"));
 
-  /* Ghostscript output device */
+  // Ghostscript output device
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
       outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER)
     cupsArrayAdd(gs_args, strdup("-sDEVICE=cups"));
@@ -1016,39 +1118,43 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
     cupsArrayAdd(gs_args, strdup("-sDEVICE=appleraster"));
   else if (outformat == CF_FILTER_OUT_FORMAT_PDF)
     cupsArrayAdd(gs_args, strdup("-sDEVICE=pdfwrite"));
-  /* In case of PCL XL, raster-obly PDF, or PCLm output we determine
-     the exact output device later */
-
-  /* Special Ghostscript options for PDF output */
-  if (outformat == CF_FILTER_OUT_FORMAT_PDF) {
-    /* If we output PDF we are running as a PostScript-to-PDF filter
-       for incoming PostScript jobs. If the client embeds a command
-       for multiple copies in the PostScript job instead of using the
-       CUPS argument for the number of copies, we need to run
-       Ghostscript with the "-dDoNumCopies" option so that it respects
-       the embedded command for the number of copies.
-
-       We always supply this option if the number of copies CUPS got
-       told about is 1, as this is the case if a client sets the
-       number of copies as embedded PostScript command, and it is also
-       not doing the wrong thing if the command is missing when the
-       client only wants a single copy, independent how the client
-       actually triggers multiple copies. If the CUPS arguments tells
-       us that the clients wants more than one copy we do not supply
-       "-dDoNumCopies" as the client does the right, modern CUPS way,
-       and if the client got a "dirty" PostScript file with an
-       embedded multi-copy setting, he does not get unwished copies.
-       also a buggy client supplying the number of copies both via
-       PostScript and CUPS will not cause an unwished number of copies
-       this way.
-
-       See https://github.com/OpenPrinting/cups-filters/issues/255
-
-       This was already correctly implemented in the former pdftops
-       shell-script-based filter but overlooked when the filter's
-       functionality got folded into this gstoraster.c filter. It was
-       not seen for long time as clients sending PostScript jobs with
-       embedded number of copies are rare. */
+  // In case of PCL XL, raster-obly PDF, or PCLm output we determine
+  // the exact output device later
+
+  // Special Ghostscript options for PDF output
+  if (outformat == CF_FILTER_OUT_FORMAT_PDF)
+  {
+    //
+    // If we output PDF we are running as a PostScript-to-PDF filter
+    // for incoming PostScript jobs. If the client embeds a command
+    // for multiple copies in the PostScript job instead of using the
+    // CUPS argument for the number of copies, we need to run
+    // Ghostscript with the "-dDoNumCopies" option so that it respects
+    // the embedded command for the number of copies.
+    //
+    // We always supply this option if the number of copies CUPS got
+    // told about is 1, as this is the case if a client sets the
+    // number of copies as embedded PostScript command, and it is also
+    // not doing the wrong thing if the command is missing when the
+    // client only wants a single copy, independent how the client
+    // actually triggers multiple copies. If the CUPS arguments tells
+    // us that the clients wants more than one copy we do not supply
+    // "-dDoNumCopies" as the client does the right, modern CUPS way,
+    // and if the client got a "dirty" PostScript file with an
+    // embedded multi-copy setting, he does not get unwished copies.
+    // also a buggy client supplying the number of copies both via
+    // PostScript and CUPS will not cause an unwished number of copies
+    // this way.
+    //
+    // See https://github.com/OpenPrinting/cups-filters/issues/255
+    //
+    // This was already correctly implemented in the former pdftops
+    // shell-script-based filter but overlooked when the filter's
+    // functionality got folded into this gstoraster.c filter. It was
+    // not seen for long time as clients sending PostScript jobs with
+    // embedded number of copies are rare.
+    //
+
     if (data->copies <= 1)
       cupsArrayAdd(gs_args, strdup("-dDoNumCopies"));
 
@@ -1063,32 +1169,34 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
                 strdup("-dColorConversionStrategy=/LeaveColorUnchanged"));
   }
 
-  /* Generate a pseudo Raster header to collect all data from the
-     printer and job attributes and also from the options which is
-     relevant for the Raster output. The header is not actually
-     inserted into the output Raster stream, but instead, converted to
-     command line options for Ghostscript by the header_to_gs_args()
-     function. Then Ghostscript generates the actual headers by
-     itself.
-
-     Ghostscript especially uses the sizes of each input page as
-     output page sizes and not the page size requested on the call of
-     this filter function. This means, for avoiding to send pages of
-     unsupported size to the printer, to pass the input data through
-     cfFilterPDFToPDF() before applying the cfFilterGhostscript()
-     filter function. */
+  //
+  // Generate a pseudo Raster header to collect all data from the
+  // printer and job attributes and also from the options which is
+  // relevant for the Raster output. The header is not actually
+  // inserted into the output Raster stream, but instead, converted to
+  // command line options for Ghostscript by the header_to_gs_args()
+  // function. Then Ghostscript generates the actual headers by
+  // itself.
+  //
+  // Ghostscript especially uses the sizes of each input page as
+  // output page sizes and not the page size requested on the call of
+  // this filter function. This means, for avoiding to send pages of
+  // unsupported size to the printer, to pass the input data through
+  // cfFilterPDFToPDF() before applying the cfFilterGhostscript()
+  // filter function.
+  //
 
   cspace = -1;
   cfRasterPrepareHeader(&h, data, outformat, outformat, 0, &cspace);
 
-  /* Find print-rendering-intent */
+  // Find print-rendering-intent
   h.cupsRenderingIntent[0] = '\0';
   cfGetPrintRenderIntent(data, h.cupsRenderingIntent,
                         sizeof(h.cupsRenderingIntent));
   if(log) log(ld, CF_LOGLEVEL_DEBUG,
              "Print rendering intent = %s", h.cupsRenderingIntent);
 
-  /* Check status of color management in CUPS */
+  // Check status of color management in CUPS
   cm_calibrate = cfCmGetCupsColorCalibrateMode(data);
 
   if (cm_calibrate == CF_CM_CALIBRATION_ENABLED)
@@ -1101,15 +1209,16 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
                             h.MediaType, h.HWResolution[0], h.HWResolution[1],
                             &icc_profile);
 
-  /* Special Ghostscript options for raster-only PDF output */
+  // Special Ghostscript options for raster-only PDF output
 
-  /* We use PCLm instead of general raster PDF here if the printer
-     supports it, as PCLm can get streamed by the printer */
+  // We use PCLm instead of general raster PDF here if the printer
+  // supports it, as PCLm can get streamed by the printer
 
-  /* Note that these output formats require Ghostscript 9.55.0 or later */
+  // Note that these output formats require Ghostscript 9.55.0 or later
 
   if (outformat == CF_FILTER_OUT_FORMAT_PDF_IMAGE ||
-      outformat == CF_FILTER_OUT_FORMAT_PCLM) {
+      outformat == CF_FILTER_OUT_FORMAT_PCLM)
+  {
     int res_x, res_y,
         sup_res_x, sup_res_y,
         best_res_x = 0, best_res_y = 0,
@@ -1120,40 +1229,47 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
     char c;
 
     ipp_attr = NULL;
-    if (outformat == CF_FILTER_OUT_FORMAT_PCLM || /* PCLm forced */
-       /* PCLm supported according to printer IPP attributes */
+    if (outformat == CF_FILTER_OUT_FORMAT_PCLM || // PCLm forced
+       // PCLm supported according to printer IPP attributes
        (printer_attrs &&
         (ipp_attr =
          ippFindAttribute(printer_attrs, "pclm-source-resolution-supported",
-                          IPP_TAG_ZERO)) != NULL)) {
-
+                          IPP_TAG_ZERO)) != NULL))
+    {
       outformat = CF_FILTER_OUT_FORMAT_PCLM;
 
-      /* Resolution */
+      // Resolution
 
-      /* Check whether the job's resolution is supported pn PCLm mode and
-         correct if needed */
+      // Check whether the job's resolution is supported pn PCLm mode and
+      // correct if needed
       res_x = h.HWResolution[0];
       res_y = h.HWResolution[1];
-      if (ipp_attr) {
+      if (ipp_attr)
+      {
        ippAttributeString(ipp_attr, tmpstr, sizeof(tmpstr));
        res_str = tmpstr;
       }
       if (res_str)
        while ((n = sscanf(res_str, "%d%c%d",
-                          &sup_res_x, &c, &sup_res_y)) > 0) {
+                          &sup_res_x, &c, &sup_res_y)) > 0)
+       {
          if (n < 3 || (c != 'x' && c != 'X'))
            sup_res_y = sup_res_x;
-         if (sup_res_x > 0 && sup_res_y > 0) {
-           if (res_x == sup_res_x && res_y == sup_res_y) {
+         if (sup_res_x > 0 && sup_res_y > 0)
+         {
+           if (res_x == sup_res_x && res_y == sup_res_y)
+           {
              best_res_x = res_x;
              best_res_y = res_y;
              break;
-           } else {
+           }
+           else
+           {
              res_diff = (res_x * res_y) / (sup_res_x * sup_res_y);
              if (res_diff < 1)
                res_diff = (sup_res_x * sup_res_y) / (res_x * res_y);
-             if (res_diff <= best_res_diff) {
+             if (res_diff <= best_res_diff)
+             {
                best_res_x = sup_res_x;
                best_res_y = sup_res_y;
              }
@@ -1163,39 +1279,45 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
          if (res_str == NULL)
            break;
        }
-      if (best_res_x > 0 && best_res_y > 0) {
+      if (best_res_x > 0 && best_res_y > 0)
+      {
        snprintf(tmpstr, sizeof(tmpstr), "-r%dx%d", best_res_x, best_res_y);
        cupsArrayAdd(gs_args, strdup(tmpstr));
-      } else if (printer_attrs &&
-                (ipp_attr =
-                 ippFindAttribute(printer_attrs,
-                                  "pclm-source-resolution-default",
-                                  IPP_TAG_ZERO)) != NULL) {
+      }
+      else if (printer_attrs &&
+              (ipp_attr =
+               ippFindAttribute(printer_attrs,
+                                "pclm-source-resolution-default",
+                                IPP_TAG_ZERO)) != NULL)
+      {
        ippAttributeString(ipp_attr, tmpstr, sizeof(tmpstr));
        if ((n = sscanf(tmpstr, "%d%c%d",
-                       &best_res_x, &c, &best_res_y)) > 0) {
+                       &best_res_x, &c, &best_res_y)) > 0)
+       {
          if (n < 3 || (c != 'x' && c != 'X'))
            best_res_y = best_res_x;
-         if (best_res_x > 0 && best_res_y > 0) {
+         if (best_res_x > 0 && best_res_y > 0)
+         {
            snprintf(tmpstr, sizeof(tmpstr), "-r%dx%d",
                     best_res_x, best_res_y);
            cupsArrayAdd(gs_args, strdup(tmpstr));
          }
        }
       }
-      if (best_res_x <= 0 || best_res_y <= 0) {
+      if (best_res_x <= 0 || best_res_y <= 0)
+      {
        snprintf(tmpstr, sizeof(tmpstr), "-r%dx%d", res_x, res_y);
        cupsArrayAdd(gs_args, strdup(tmpstr));
       }
 
-      /* Ghostscript output device */
+      // Ghostscript output device
 
       if (h.cupsColorSpace == CUPS_CSPACE_SW)
        cupsArrayAdd(gs_args, strdup("-sDEVICE=pclm8"));
       else
        cupsArrayAdd(gs_args, strdup("-sDEVICE=pclm"));
 
-      /* Strip/Band Height */
+      // Strip/Band Height
 
       n = 0;
       if (printer_attrs &&
@@ -1204,19 +1326,21 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
                            "pclm-strip-height-preferred",
                            IPP_TAG_ZERO)) != NULL)
        n = ippGetInteger(ipp_attr, 0);
-      if (n <= 0) n = 16;
+      if (n <= 0)
+       n = 16;
       snprintf(tmpstr, sizeof(tmpstr), "-dStripHeight=%d", n);
       cupsArrayAdd(gs_args, strdup(tmpstr));
 
-      /* Back side orientation for Duplex not (yet) supported by Ghostscript */
+      // Back side orientation for Duplex not (yet) supported by Ghostscript
 
-      /* Compression method */
+      // Compression method
 
       if (printer_attrs &&
          (ipp_attr =
           ippFindAttribute(printer_attrs,
                            "pclm-compression-method-preferred",
-                           IPP_TAG_ZERO)) != NULL) {
+                           IPP_TAG_ZERO)) != NULL)
+      {
        ippAttributeString(ipp_attr, tmpstr, sizeof(tmpstr));
        if (strcasestr(tmpstr, "flate"))
          cupsArrayAdd(gs_args, strdup("-sCompression=Flate"));
@@ -1226,34 +1350,37 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
          cupsArrayAdd(gs_args, strdup("-sCompression=JPEG"));
        else
          cupsArrayAdd(gs_args, strdup("-sCompression=Flate"));
-      } else
+      }
+      else
        cupsArrayAdd(gs_args, strdup("-sCompression=Flate"));
-    } else {
-      /* No PCLm supported or requested, use general raster PDF */
+    }
+    else
+    {
+      // No PCLm supported or requested, use general raster PDF
 
-      /* Ghostscript output device and color/gray */
+      // Ghostscript output device and color/gray
 
       n = 0;
-      if (printer_attrs) {
+      if (printer_attrs)
+      {
        if ((ipp_attr =
             ippFindAttribute(printer_attrs,
                              "color-supported", IPP_TAG_ZERO)) != NULL &&
-           ippGetBoolean(ipp_attr, 0)) {
-         /* Color printer, according to printer attributes */
+           ippGetBoolean(ipp_attr, 0))
+         // Color printer, according to printer attributes
          n = 1;
-       }
       }
       if (n == 1 && h.cupsNumColors > 1)
        cupsArrayAdd(gs_args, strdup("-sDEVICE=pdfimage24"));
       else
        cupsArrayAdd(gs_args, strdup("-sDEVICE=pdfimage8"));
 
-      /* Compression method */
+      // Compression method
 
       cupsArrayAdd(gs_args, strdup("-sCompression=Flate"));
     }
 
-    /* Common option: Downscaling factor */
+    // Common option: Downscaling factor
 
     cupsArrayAdd(gs_args, strdup("-dDownScaleFactor=1"));
   }
@@ -1265,10 +1392,9 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
       if ((ipp_attr =
           ippFindAttribute(printer_attrs,
                            "color-supported", IPP_TAG_BOOLEAN)) != NULL &&
-         ippGetBoolean(ipp_attr, 0)) {
-        /* Color PCL XL printer, according to printer attributes */
+         ippGetBoolean(ipp_attr, 0))
+        // Color PCL XL printer, according to printer attributes
         pxlcolor = 1;
-      }
     }
 
     if (job_attrs)
@@ -1287,7 +1413,7 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
           ippFindAttribute(job_attrs, "output-mode", IPP_TAG_ZERO)) != NULL)
       {
         ippAttributeString(ipp_attr, buf, sizeof(buf));
-        if (!strncasecmp(buf, "AdobeRgb", 8)     ||
+        if (!strncasecmp(buf, "AdobeRgb", 8)      ||
            !strncasecmp(buf, "adobe-rgb", 9)     ||
            !strcasecmp(buf, "color")             ||
            !strncasecmp(buf,"Cmyk", 4)           ||
@@ -1296,37 +1422,35 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
            !strncasecmp(buf, "Rgbw", 4)          ||
            !strcasecmp(buf, "auto")              ||
            !strncasecmp(buf, "Rgb", 3))
-        {
           pxlcolor = 1;
-        }
         else if(!strncasecmp(buf, "Device", 6))
         {
-          char* ptr = buf+6;
-          if (strtol(ptr, (char **)&ptr, 10) > 1) { /* If printer seems to
-                                                      support more than 1
-                                                      color  */
+          char* ptr = buf + 6;
+          if (strtol(ptr, (char **)&ptr, 10) > 1) // If printer seems to
+                                                 // support more than 1
+                                                 // color 
             pxlcolor = 1;
-          }
         }
       }
     }
 
-    if (pxlcolor == 0)   /*  Still printer seems to be mono */
+    if (pxlcolor == 0)   //  Still printer seems to be mono
     {
       const char* val;
       if ((val = cupsGetOption("pwg-raster-document-type", num_options,
-                          options)) != NULL ||
-      (val = cupsGetOption("PwgRasterDocumentType", num_options,
-                          options)) != NULL ||
-      (val = cupsGetOption("color-space", num_options, options)) != NULL ||
-      (val = cupsGetOption("ColorSpace", num_options, options)) != NULL ||
-      (val = cupsGetOption("color-model", num_options, options)) != NULL ||
-      (val = cupsGetOption("ColorModel", num_options, options)) != NULL ||
-      (val = cupsGetOption("print-color-mode", num_options, options)) != NULL ||
-      (val = cupsGetOption("output-mode", num_options, options)) != NULL ||
-      (val = cupsGetOption("OutputMode", num_options, options)) != NULL)
+                              options)) != NULL ||
+         (val = cupsGetOption("PwgRasterDocumentType", num_options,
+                              options)) != NULL ||
+         (val = cupsGetOption("color-space", num_options, options)) != NULL ||
+         (val = cupsGetOption("ColorSpace", num_options, options)) != NULL ||
+         (val = cupsGetOption("color-model", num_options, options)) != NULL ||
+         (val = cupsGetOption("ColorModel", num_options, options)) != NULL ||
+         (val = cupsGetOption("print-color-mode", num_options, options)) !=
+         NULL ||
+         (val = cupsGetOption("output-mode", num_options, options)) != NULL ||
+         (val = cupsGetOption("OutputMode", num_options, options)) != NULL)
       {
-        if(!strncasecmp(val, "AdobeRgb", 8) ||
+        if(!strncasecmp(val, "AdobeRgb", 8)  ||
           !strncasecmp(val, "adobe-rgb", 9) ||
           !strcasecmp(val, "color")         ||
           !strncasecmp(val, "Cmyk", 4)      ||
@@ -1339,28 +1463,27 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
         else if(!strncasecmp(val, "Device", 6))
         {
           const char *ptr = val + 6;
-          if(strtol(ptr, (char **)&ptr, 10)>1)  /* Printer seems to support
-                                                  more then 1 color  */
+          if (strtol(ptr, (char **)&ptr, 10) > 1) // Printer seems to support
+                                                 // more then 1 color 
             pxlcolor = 1;
         }
       }
     } 
   }
 
-  /* set PDF-specific options */
-  if (doc_type == GS_DOC_TYPE_PDF) {
+  // set PDF-specific options
+  if (doc_type == GS_DOC_TYPE_PDF)
     parse_pdf_header_options(fp, &h);
-  }
 
-  /* fixed other values that pdftopdf handles */
+  // fixed other values that pdftopdf handles
   h.MirrorPrint = CUPS_FALSE;
   h.Orientation = CUPS_ORIENT_0;
 
-  /* get all the data from the header and pass it to ghostscript */
+  // get all the data from the header and pass it to ghostscript
   header_to_gs_args(&h, gs_args, outformat, pxlcolor);
 
-  /* CUPS Raster versions: 2 = compressed; 3 = uncompressed */
-  /* Requires Ghostscript 9.57 or later */
+  // CUPS Raster versions: 2 = compressed; 3 = uncompressed
+  // Requires Ghostscript 9.57 or later
   if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER &&
       (t = cupsGetOption("cups-raster-version",
                           num_options, options)) != NULL &&
@@ -1370,15 +1493,15 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
     cupsArrayAdd(gs_args, strdup(tmpstr));
   }
 
-  /* Back side orientation for duplex printing: Normal, ManualTumble,
-     Rotated, Flipped */
-  /* When printing duplex, margins on the back side meeds to get swapped? */
-  /* Requires Ghostscript 9.57 or later */
+  // Back side orientation for duplex printing: Normal, ManualTumble,
+  // Rotated, Flipped
+  // When printing duplex, margins on the back side meeds to get swapped?
+  // Requires Ghostscript 9.57 or later
   if (h.Duplex)
   {
     int backside;
-    /* analyze options relevant to Duplex */
-    /* APDuplexRequiresFlippedMargin */
+    // analyze options relevant to Duplex
+    // APDuplexRequiresFlippedMargin
     enum {
       FM_NO,
       FM_FALSE,
@@ -1417,15 +1540,15 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
       cupsArrayAdd(gs_args, strdup("-dcupsBackSideFlipMargins"));
   }
 
-  /* Manual Copies needed (no device copies functionality available) */
-  /* Requires Ghostscript 9.57 or later */
+  // Manual Copies needed (no device copies functionality available)
+  // Requires Ghostscript 9.57 or later
   if ((t = cupsGetOption("hardware-copies",
                         num_options, options)) != NULL &&
       (!strcasecmp(t, "false") || !strcasecmp(t, "off") ||
        !strcasecmp(t, "no")))
     cupsArrayAdd(gs_args, strdup("-dcupsManualCopies"));
 
-  /* CUPS font path */
+  // CUPS font path
   if ((t = cupsGetOption("cups-fontpath",
                         num_options, options)) != NULL &&
       t[0] != '\0')
@@ -1434,45 +1557,52 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
     cupsArrayAdd(gs_args, strdup(tmpstr));
   }
 
-  /* Set the device output ICC profile */
-  if (icc_profile != NULL && icc_profile[0] != '\0') {
+  // Set the device output ICC profile
+  if (icc_profile != NULL && icc_profile[0] != '\0')
+  {
     snprintf(tmpstr, sizeof(tmpstr), "-sOutputICCProfile=%s", icc_profile);
     cupsArrayAdd(gs_args, strdup(tmpstr));
-  } else if (!cm_disabled &&
-            (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
-             outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
-             outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)) {
-    /* Set standard output ICC profile sGray/sRGB/AdobeRGB */
+  }
+  else if (!cm_disabled &&
+          (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
+           outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
+           outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER))
+  {
+    // Set standard output ICC profile sGray/sRGB/AdobeRGB
     if (h.cupsColorSpace == CUPS_CSPACE_SW)
       cupsArrayAdd(gs_args, strdup("-sOutputICCProfile=sgray.icc"));
     else if (h.cupsColorSpace == CUPS_CSPACE_SRGB)
       cupsArrayAdd(gs_args, strdup("-sOutputICCProfile=srgb.icc"));
     else if (h.cupsColorSpace == CUPS_CSPACE_ADOBERGB)
       cupsArrayAdd(gs_args, strdup("-sOutputICCProfile=a98.icc"));
-  } else if (!cm_disabled &&
-            outformat == CF_FILTER_OUT_FORMAT_PCLM) {
-    /* Set standard output ICC profile sGray/sRGB */
+  }
+  else if (!cm_disabled &&
+          outformat == CF_FILTER_OUT_FORMAT_PCLM)
+  {
+    // Set standard output ICC profile sGray/sRGB
     if (h.cupsColorSpace == CUPS_CSPACE_SW)
       cupsArrayAdd(gs_args, strdup("-sOutputICCProfile=sgray.icc"));
     else if (h.cupsColorSpace == CUPS_CSPACE_SRGB)
       cupsArrayAdd(gs_args, strdup("-sOutputICCProfile=srgb.icc"));
   }
   else if (!cm_disabled)
-  {
     cupsArrayAdd(gs_args, strdup("-sOutputICCProfile=srgb.icc"));
-  }
 
-  /* Switch to taking PostScript commands on the Ghostscript command line */
+  // Switch to taking PostScript commands on the Ghostscript command line
   cupsArrayAdd(gs_args, strdup("-c"));
 
-  /* Set margins if we have a bounding box defined and output format
-     is not PDF, as PDF output we have only in the PostScript-to-PDF
-     filtering case which happens for converting PostScript input
-     files before pdftopdf so margins will be handled later, whereas
-     the other output formats for PDF-to-something filtering after
-     cfFilterPDFToPDF, to format the pages for the printer, so margins are
-     important. */
-  if (h.cupsImagingBBox[3] > 0.0 && outformat != CF_FILTER_OUT_FORMAT_PDF) {
+  //
+  // Set margins if we have a bounding box defined and output format
+  // is not PDF, as PDF output we have only in the PostScript-to-PDF
+  // filtering case which happens for converting PostScript input
+  // files before pdftopdf so margins will be handled later, whereas
+  // the other output formats for PDF-to-something filtering after
+  // cfFilterPDFToPDF, to format the pages for the printer, so margins are
+  // important.
+  //
+
+  if (h.cupsImagingBBox[3] > 0.0 && outformat != CF_FILTER_OUT_FORMAT_PDF)
+  {
     snprintf(tmpstr, sizeof(tmpstr),
             "<</.HWMargins[%f %f %f %f] /Margins[0 0]>>setpagedevice",
             h.cupsImagingBBox[0], h.cupsImagingBBox[1],
@@ -1482,63 +1612,72 @@ cfFilterGhostscript(int inputfd,            /* I - File descriptor input
   }
 
   if (!cm_disabled &&
-      (t = cupsGetOption("profile", num_options, options)) != NULL) {
+      (t = cupsGetOption("profile", num_options, options)) != NULL)
+  {
     snprintf(tmpstr, sizeof(tmpstr), "<</cupsProfile(%s)>>setpagedevice", t);
     cupsArrayAdd(gs_args, strdup(tmpstr));
   }
 
-  /* Do we have a "center-of-pixel" or "CenterOfPixel" command line
-     option set to "true"? In this case let Ghostscript use the
-     center-of-pixel rule instead of the PostScript-standard
-     any-part-of-pixel rule when filling a path. This improves the
-     accuracy of graphics (like bar codes for example) on
-     low-resolution printers (like label printers with typically 203
-     dpi). See
-     https://bugs.linuxfoundation.org/show_bug.cgi?id=1373 */
+  //
+  // Do we have a "center-of-pixel" or "CenterOfPixel" command line
+  // option set to "true"? In this case let Ghostscript use the
+  // center-of-pixel rule instead of the PostScript-standard
+  // any-part-of-pixel rule when filling a path. This improves the
+  // accuracy of graphics (like bar codes for example) on
+  // low-resolution printers (like label printers with typically 203
+  // dpi). See
+  // https://bugs.linuxfoundation.org/show_bug.cgi?id=1373
+  //
+
   if (((t = cupsGetOption("CenterOfPixel", num_options, options)) != NULL ||
        (t = cupsGetOption("center-of-pixel", num_options, options)) != NULL) &&
       (!strcasecmp(t, "true") || !strcasecmp(t, "on") ||
-       !strcasecmp(t, "yes"))) {
+       !strcasecmp(t, "yes")))
+  {
     if (log) log(ld, CF_LOGLEVEL_DEBUG,
                 "cfFilterGhostscript: Ghostscript using Center-of-Pixel method to "
                 "fill paths.");
     cupsArrayAdd(gs_args, strdup("0 0 .setfilladjust2"));
-  } else
+  }
+  else
     if (log) log(ld, CF_LOGLEVEL_DEBUG,
                 "cfFilterGhostscript: Ghostscript using Any-Part-of-Pixel method to "
                 "fill paths.");
 
-  /* Mark the end of PostScript commands supplied on the Ghostscript command
-     line (with the "-c" option), so that we can supply the input file name */
+  // Mark the end of PostScript commands supplied on the Ghostscript command
+  // line (with the "-c" option), so that we can supply the input file name
   cupsArrayAdd(gs_args, strdup("-f"));
 
-  /* Let Ghostscript read from stdin */
+  // Let Ghostscript read from stdin
   cupsArrayAdd(gs_args, strdup("-_"));
 
-  /* Execute Ghostscript command line ... */
+  // Execute Ghostscript command line ...
   snprintf(tmpstr, sizeof(tmpstr), "%s", CUPS_GHOSTSCRIPT);
 
-  /* call Ghostscript */
+  // call Ghostscript
   rewind(fp);
   status = gs_spawn (tmpstr, gs_args, envp, fp, outputfd, log, ld,
                     iscanceled, icd);
-  if (status != 0) status = 1;
+  if (status != 0)
+    status = 1;
 out:
   for (i = 0; envp[i]; i ++)
     free(envp[i]);
   if (fp)
     fclose(fp);
   if (filename)
-    /* Remove name of temp file*/
+    // Remove name of temp file
     unlink(filename);
-  if (gs_args) {
-    while ((tmp = cupsArrayFirst(gs_args)) != NULL) {
-      cupsArrayRemove(gs_args,tmp);
+  if (gs_args)
+  {
+    while ((tmp = cupsArrayFirst(gs_args)) != NULL)
+    {
+      cupsArrayRemove(gs_args, tmp);
       free(tmp);
     }
     cupsArrayDelete(gs_args);
   }
   free(icc_profile);
   close(outputfd);
-  return status;
+  return (status);
 }
index be3ce826b7e1394ee35fc1785bee1bcde6a39d71..dae22e999f01b6c9c7f7092088985a8200e58029 100644 (file)
@@ -1,28 +1,28 @@
-/*
- *   IEEE-1284 Device ID support functions for OpenPrinting CUPS Filters.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
- *
- *   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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   cfIEEE1284GetDeviceID()           - Get the IEEE-1284 device ID string and
- *                                     corresponding URI.
- *   cfIEEE1284GetMakeModel()          - Get the make and model string from the 
- *                                     device ID.
- *   cfIEEE1284GetValues()             - Get 1284 device ID keys and values.
- *   cfIEEE1284NormalizeMakeModel() - Normalize a product/make-and-model
- *                                     string.
- */
-
-/*
- * Include necessary headers.
- */
+//
+//   IEEE-1284 Device ID support functions for OpenPrinting CUPS Filters.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+//
+//   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 "COPYING"
+//   which should have been included with this file.
+//
+// Contents:
+//
+//   cfIEEE1284GetDeviceID()           - Get the IEEE-1284 device ID string and
+//                                       corresponding URI.
+//   cfIEEE1284GetMakeModel()          - Get the make and model string from the
+//                                       device ID.
+//   cfIEEE1284GetValues()             - Get 1284 device ID keys and values.
+//   cfIEEE1284NormalizeMakeModel()    - Normalize a product/make-and-model
+//                                       string.
+
+
+//
+// Include necessary headers.
+//
 
 #include <config.h>
 #include "ieee1284.h"
 #include <stdio.h>
 
 
-/*
- * 'cfIEEE1284GetDeviceID()' - Get the IEEE-1284 device ID string and
- *                           corresponding URI.
- */
+//
+// 'cfIEEE1284GetDeviceID()' - Get the IEEE-1284 device ID string and
+//                             corresponding URI.
+//
 
-int                                    /* O - 0 on success, -1 on failure */
+int                                    // O - 0 on success, -1 on failure
 cfIEEE1284GetDeviceID(
-    int        fd,                     /* I - File descriptor */
-    char       *device_id,             /* O - 1284 device ID */
-    int        device_id_size,         /* I - Size of buffer */
-    char       *make_model,            /* O - Make/model */
-    int        make_model_size,                /* I - Size of buffer */
-    const char *scheme,                        /* I - URI scheme */
-    char       *uri,                   /* O - Device URI */
-    int        uri_size)               /* I - Size of buffer */
+    int        fd,                     // I - File descriptor
+    char       *device_id,             // O - 1284 device ID
+    int        device_id_size,         // I - Size of buffer
+    char       *make_model,            // O - Make/model
+    int        make_model_size,                // I - Size of buffer
+    const char *scheme,                        // I - URI scheme
+    char       *uri,                   // O - Device URI
+    int        uri_size)               // I - Size of buffer
 {
-#ifdef __APPLE__ /* This function is a no-op */
+#ifdef __APPLE__ // This function is a no-op
   (void)fd;
   (void)device_id;
   (void)device_id_size;
@@ -61,15 +61,15 @@ cfIEEE1284GetDeviceID(
 
   return (-1);
 
-#else /* Get the device ID from the specified file descriptor... */
+#else // Get the device ID from the specified file descriptor...
 #  ifdef __linux
-  int  length;                         /* Length of device ID info */
+  int  length;                         // Length of device ID info
   int   got_id = 0;
-#  endif /* __linux */
+#  endif // __linux
 #  if defined(__sun) && defined(ECPPIOC_GETDEVID)
-  struct ecpp_device_id did;           /* Device ID buffer */
-#  endif /* __sun && ECPPIOC_GETDEVID */
-  char *ptr;                           /* Pointer into device ID */
+  struct ecpp_device_id did;           // Device ID buffer
+#  endif // __sun && ECPPIOC_GETDEVID
+  char *ptr;                           // Pointer into device ID
 
 
   DEBUG_printf(("cfIEEE1284GetDeviceID(fd=%d, device_id=%p, device_id_size=%d, "
@@ -78,9 +78,9 @@ cfIEEE1284GetDeviceID(
                make_model, make_model_size, scheme ? scheme : "(null)",
                uri, uri_size));
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (!device_id || device_id_size < 32)
   {
@@ -93,44 +93,44 @@ cfIEEE1284GetDeviceID(
 
   if (fd >= 0)
   {
-   /*
-    * Get the device ID string...
-    */
+    //
+    // Get the device ID string...
+    //
 
     *device_id = '\0';
 
 #  ifdef __linux
     if (ioctl(fd, LPIOC_GET_DEVICE_ID(device_id_size), device_id))
     {
-     /*
-      * Linux has to implement things differently for every device it seems.
-      * Since the standard parallel port driver does not provide a simple
-      * ioctl() to get the 1284 device ID, we have to open the "raw" parallel
-      * device corresponding to this port and do some negotiation trickery
-      * to get the current device ID.
-      */
+      //
+      // Linux has to implement things differently for every device it seems.
+      // Since the standard parallel port driver does not provide a simple
+      // ioctl() to get the 1284 device ID, we have to open the "raw" parallel
+      // device corresponding to this port and do some negotiation trickery
+      // to get the current device ID.
+      //
 
       if (uri && !strncmp(uri, "parallel:/dev/", 14))
       {
-       char    devparport[16];         /* /dev/parportN */
-       int     devparportfd,           /* File descriptor for raw device */
-                 mode;                 /* Port mode */
+       char    devparport[16];         // /dev/parportN
+       int     devparportfd,           // File descriptor for raw device
+               mode;                   // Port mode
 
 
-       /*
-       * Since the Linux parallel backend only supports 4 parallel port
-       * devices, just grab the trailing digit and use it to construct a
-       * /dev/parportN filename...
-       */
+       //
+       // Since the Linux parallel backend only supports 4 parallel port
+       // devices, just grab the trailing digit and use it to construct a
+       // /dev/parportN filename...
+       //
 
        snprintf(devparport, sizeof(devparport), "/dev/parport%s",
                 uri + strlen(uri) - 1);
 
        if ((devparportfd = open(devparport, O_RDWR | O_NOCTTY)) != -1)
        {
-        /*
-         * Claim the device...
-         */
+         //
+         // Claim the device...
+         //
 
          if (!ioctl(devparportfd, PPCLAIM))
          {
@@ -140,17 +140,17 @@ cfIEEE1284GetDeviceID(
 
            if (!ioctl(devparportfd, PPNEGOT, &mode))
            {
-            /*
-             * Put the device into Device ID mode...
-             */
+             //
+             // Put the device into Device ID mode...
+             //
 
              mode = IEEE1284_MODE_NIBBLE | IEEE1284_DEVICEID;
 
              if (!ioctl(devparportfd, PPNEGOT, &mode))
              {
-              /*
-               * Read the 1284 device ID...
-               */
+               //
+               // Read the 1284 device ID...
+               //
 
                if ((length = read(devparportfd, device_id,
                                   device_id_size - 1)) >= 2)
@@ -161,9 +161,9 @@ cfIEEE1284GetDeviceID(
              }
            }
 
-          /*
-           * Release the device...
-           */
+           //
+           // Release the device...
+           //
 
            ioctl(devparportfd, PPRELEASE);
          }
@@ -177,19 +177,19 @@ cfIEEE1284GetDeviceID(
 
     if (got_id)
     {
-     /*
-      * Extract the length of the device ID string from the first two
-      * bytes.  The 1284 spec says the length is stored MSB first...
-      */
+      //
+      // Extract the length of the device ID string from the first two
+      // bytes.  The 1284 spec says the length is stored MSB first...
+      //
 
       length = (((unsigned)device_id[0] & 255) << 8) +
               ((unsigned)device_id[1] & 255);
 
-     /*
-      * Check to see if the length is larger than our buffer; first
-      * assume that the vendor incorrectly implemented the 1284 spec,
-      * and then limit the length to the size of our buffer...
-      */
+      //
+      // Check to see if the length is larger than our buffer; first
+      // assume that the vendor incorrectly implemented the 1284 spec,
+      // and then limit the length to the size of our buffer...
+      //
 
       if (length > device_id_size || length < 14)
        length = (((unsigned)device_id[1] & 255) << 8) +
@@ -198,30 +198,30 @@ cfIEEE1284GetDeviceID(
       if (length > device_id_size)
        length = device_id_size;
 
-     /*
-      * The length field counts the number of bytes in the string
-      * including the length field itself (2 bytes).  The minimum
-      * length for a valid/usable device ID is 14 bytes:
-      *
-      *     <LENGTH> MFG: <MFG> ;MDL: <MDL> ;
-      *        2  +   4  +  1  +  5 +  1 +  1
-      */
+      //
+      // The length field counts the number of bytes in the string
+      // including the length field itself (2 bytes).  The minimum
+      // length for a valid/usable device ID is 14 bytes:
+      //
+      //     <LENGTH> MFG: <MFG> ;MDL: <MDL> ;
+      //        2  +   4  +  1  +  5 +  1 +  1
+      //
 
       if (length < 14)
       {
-       /*
-       * Can't use this device ID, so don't try to copy it...
-       */
+       //
+       // Can't use this device ID, so don't try to copy it...
+       //
 
        device_id[0] = '\0';
        got_id       = 0;
       }
       else
       {
-       /*
-       * Copy the device ID text to the beginning of the buffer and
-       * nul-terminate.
-       */
+       //
+       // Copy the device ID text to the beginning of the buffer and
+       // nul-terminate.
+       //
 
        length -= 2;
 
@@ -235,7 +235,7 @@ cfIEEE1284GetDeviceID(
                     strerror(errno)));
       *device_id = '\0';
     }
-#  endif /* __linux */
+#  endif // __linux
 
 #   if defined(__sun) && defined(ECPPIOC_GETDEVID)
     did.mode = ECPP_CENTRONICS;
@@ -245,9 +245,9 @@ cfIEEE1284GetDeviceID(
 
     if (!ioctl(fd, ECPPIOC_GETDEVID, &did))
     {
-     /*
-      * Nul-terminate the device ID text.
-      */
+      //
+      // Nul-terminate the device ID text.
+      //
 
       if (did.rlen < (device_id_size - 1))
        device_id[did.rlen] = '\0';
@@ -258,14 +258,14 @@ cfIEEE1284GetDeviceID(
     else
       DEBUG_printf(("cfIEEE1284GetDeviceID: ioctl failed - %s\n",
                     strerror(errno)));
-#    endif /* DEBUG */
-#  endif /* __sun && ECPPIOC_GETDEVID */
+#    endif // DEBUG
+#  endif // __sun && ECPPIOC_GETDEVID
   }
 
- /*
-  * Check whether device ID is valid. Turn line breaks and tabs to spaces and
-  * reject device IDs with non-printable characters.
-  */
+  //
+  // Check whether device ID is valid. Turn line breaks and tabs to spaces and
+  // reject device IDs with non-printable characters.
+  //
 
   for (ptr = device_id; *ptr; ptr ++)
     if (isspace(*ptr))
@@ -286,31 +286,31 @@ cfIEEE1284GetDeviceID(
   if (!*device_id)
     return (-1);
 
- /*
-  * Get the make and model...
-  */
+  //
+  // Get the make and model...
+  //
 
   if (make_model)
     cfIEEE1284GetMakeModel(device_id, make_model, make_model_size);
 
- /*
-  * Then generate a device URI...
-  */
+  //
+  // Then generate a device URI...
+  //
 
   if (scheme && uri && uri_size > 32)
   {
-    int                        num_values;     /* Number of keys and values */
-    cups_option_t      *values;        /* Keys and values in device ID */
-    const char         *mfg,           /* Manufacturer */
-                       *mdl,           /* Model */
-                       *sern;          /* Serial number */
-    char               temp[256],      /* Temporary manufacturer string */
-                       *tempptr;       /* Pointer into temp string */
+    int                        num_values;     // Number of keys and values
+    cups_option_t      *values;        // Keys and values in device ID
+    const char         *mfg,           // Manufacturer
+                       *mdl,           // Model
+                       *sern;          // Serial number
+    char               temp[256],      // Temporary manufacturer string
+                       *tempptr;       // Pointer into temp string
 
 
-   /*
-    * Get the make, model, and serial numbers...
-    */
+    //
+    // Get the make, model, and serial numbers...
+    //
 
     num_values = cfIEEE1284GetValues(device_id, &values);
 
@@ -353,10 +353,10 @@ cfIEEE1284GetDeviceID(
         mdl ++;
     }
 
-   /*
-    * Generate the device URI from the manufacturer, make_model, and
-    * serial number strings.
-    */
+    //
+    // Generate the device URI from the manufacturer, make_model, and
+    // serial number strings.
+    //
 
     httpAssembleURIf(HTTP_URI_CODING_ALL, uri, uri_size, scheme, NULL, mfg, 0,
                      "/%s%s%s", mdl, sern ? "?serial=" : "", sern ? sern : "");
@@ -365,34 +365,35 @@ cfIEEE1284GetDeviceID(
   }
 
   return (0);
-#endif /* __APPLE__ */
+#endif // __APPLE__
 }
 
 
-/*
- * 'cfIEEE1284GetMakeModel()' - Get the make and model string from the device ID.
- */
+//
+// 'cfIEEE1284GetMakeModel()' - Get the make and model string from the
+//                              device ID.
+//
 
-int                                    /* O - 0 on success, -1 on failure */
+int                                    // O - 0 on success, -1 on failure
 cfIEEE1284GetMakeModel(
-    const char *device_id,             /* O - 1284 device ID */
-    char       *make_model,            /* O - Make/model */
-    int        make_model_size)                /* I - Size of buffer */
+    const char *device_id,             // O - 1284 device ID
+    char       *make_model,            // O - Make/model
+    int        make_model_size)                // I - Size of buffer
 {
-  int          num_values;             /* Number of keys and values */
-  cups_option_t        *values;                /* Keys and values */
-  const char   *mfg,                   /* Manufacturer string */
-               *mdl,                   /* Model string */
-               *des;                   /* Description string */
+  int          num_values;             // Number of keys and values
+  cups_option_t        *values;                // Keys and values
+  const char   *mfg,                   // Manufacturer string
+               *mdl,                   // Model string
+               *des;                   // Description string
 
 
   DEBUG_printf(("cfIEEE1284GetMakeModel(device_id=\"%s\", "
                 "make_model=%p, make_model_size=%d)\n", device_id,
                make_model, make_model_size));
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (!device_id || !*device_id || !make_model || make_model_size < 32)
   {
@@ -402,9 +403,9 @@ cfIEEE1284GetMakeModel(
 
   *make_model = '\0';
 
- /*
-  * Look for the description field...
-  */
+  //
+  // Look for the description field...
+  //
 
   num_values = cfIEEE1284GetValues(device_id, &values);
 
@@ -413,55 +414,55 @@ cfIEEE1284GetMakeModel(
 
   if (mdl)
   {
-   /*
-    * Build a make-model string from the manufacturer and model attributes...
-    */
+    //
+    // Build a make-model string from the manufacturer and model attributes...
+    //
 
     if ((mfg = cupsGetOption("MANUFACTURER", num_values, values)) == NULL)
       mfg = cupsGetOption("MFG", num_values, values);
 
     if (!mfg || !strncasecmp(mdl, mfg, strlen(mfg)))
     {
-     /*
-      * Just copy the model string, since it has the manufacturer...
-      */
+      //
+      // Just copy the model string, since it has the manufacturer...
+      //
 
       cfIEEE1284NormalizeMakeModel(mdl, NULL, CF_IEEE1284_NORMALIZE_HUMAN, NULL,
-                                   make_model, make_model_size, NULL, NULL,
-                                   NULL);
+                                  make_model, make_model_size, NULL, NULL,
+                                  NULL);
     }
     else
     {
-     /*
-      * Concatenate the make and model...
-      */
+      //
+      // Concatenate the make and model...
+      //
 
-      char     temp[1024];             /* Temporary make and model */
+      char     temp[1024];             // Temporary make and model
 
       snprintf(temp, sizeof(temp), "%s %s", mfg, mdl);
 
-      cfIEEE1284NormalizeMakeModel(temp, NULL, CF_IEEE1284_NORMALIZE_HUMAN, NULL,
-                                   make_model, make_model_size, NULL, NULL,
-                                   NULL);
+      cfIEEE1284NormalizeMakeModel(temp, NULL, CF_IEEE1284_NORMALIZE_HUMAN,
+                                  NULL, make_model, make_model_size, NULL,
+                                  NULL, NULL);
     }
   }
   else if ((des = cupsGetOption("DESCRIPTION", num_values, values)) != NULL ||
            (des = cupsGetOption("DES", num_values, values)) != NULL)
   {
-   /*
-    * Make sure the description contains something useful, since some
-    * printer manufacturers (HP) apparently don't follow the standards
-    * they helped to define...
-    *
-    * Here we require the description to be 8 or more characters in length,
-    * containing at least one space and one letter.
-    */
+    //
+    // Make sure the description contains something useful, since some
+    // printer manufacturers (HP) apparently don't follow the standards
+    // they helped to define...
+    //
+    // Here we require the description to be 8 or more characters in length,
+    // containing at least one space and one letter.
+    //
 
     if (strlen(des) >= 8)
     {
-      const char       *ptr;           /* Pointer into description */
-      int              letters,        /* Number of letters seen */
-                       spaces;         /* Number of spaces seen */
+      const char       *ptr;           // Pointer into description
+      int              letters,        // Number of letters seen
+                       spaces;         // Number of spaces seen
 
 
       for (ptr = des, letters = 0, spaces = 0; *ptr; ptr ++)
@@ -476,17 +477,17 @@ cfIEEE1284GetMakeModel(
       }
 
       if (spaces && letters)
-        cfIEEE1284NormalizeMakeModel(des, NULL, CF_IEEE1284_NORMALIZE_HUMAN, NULL,
-                                     make_model, make_model_size, NULL, NULL,
-                                     NULL);
+        cfIEEE1284NormalizeMakeModel(des, NULL, CF_IEEE1284_NORMALIZE_HUMAN,
+                                    NULL, make_model, make_model_size, NULL,
+                                    NULL, NULL);
     }
   }
 
   if (!make_model[0])
   {
-   /*
-    * Use "Unknown" as the printer make and model...
-    */
+    //
+    // Use "Unknown" as the printer make and model...
+    //
 
     strncpy(make_model, "Unknown", make_model_size - 1);
     make_model[make_model_size - 1] = '\0';
@@ -498,27 +499,27 @@ cfIEEE1284GetMakeModel(
 }
 
 
-/*
- * 'cfIEEE1284GetValues()' - Get 1284 device ID keys and values.
- *
- * The returned dictionary is a CUPS option array that can be queried with
- * cupsGetOption and freed with cupsFreeOptions.
- */
+//
+// 'cfIEEE1284GetValues()' - Get 1284 device ID keys and values.
+//
+// The returned dictionary is a CUPS option array that can be queried with
+// cupsGetOption and freed with cupsFreeOptions.
+//
 
-int                                    /* O - Number of key/value pairs */
+int                                    // O - Number of key/value pairs
 cfIEEE1284GetValues(
-    const char *device_id,             /* I - IEEE-1284 device ID string */
-    cups_option_t **values)            /* O - Array of key/value pairs */
+    const char *device_id,             // I - IEEE-1284 device ID string
+    cups_option_t **values)            // O - Array of key/value pairs
 {
-  int          num_values;             /* Number of values */
-  char         key[256],               /* Key string */
-               value[256],             /* Value string */
-               *ptr;                   /* Pointer into key/value */
+  int          num_values;             // Number of values
+  char         key[256],               // Key string
+               value[256],             // Value string
+               *ptr;                   // Pointer into key/value
 
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (values)
     *values = NULL;
@@ -526,12 +527,12 @@ cfIEEE1284GetValues(
   if (!device_id || !values)
     return (0);
 
- /*
-  * Parse the 1284 device ID value into keys and values.  The format is
-  * repeating sequences of:
-  *
-  *   [whitespace]key:value[whitespace];
-  */
+  //
+  // Parse the 1284 device ID value into keys and values.  The format is
+  // repeating sequences of:
+  //
+  //   [whitespace]key:value[whitespace];
+  //
 
   num_values = 0;
   while (*device_id)
@@ -580,21 +581,21 @@ cfIEEE1284GetValues(
   return (num_values);
 }
 
-/*
- * 'move_right_part()' - Mark a start position in a string buffer and
- *                     move all characters beginning from there by
- *                     a given amount of characters. Characters will
- *                     get lost when moving to the left, there will
- *                     be undefined character positions when moving
- *                     to the right.
- */
+//
+// 'move_right_part()' - Mark a start position in a string buffer and
+//                       move all characters beginning from there by
+//                       a given amount of characters. Characters will
+//                       get lost when moving to the left, there will
+//                       be undefined character positions when moving
+//                       to the right.
+//
 
 static void
 move_right_part(
-    char       *buffer,             /* I/O - String buffer */
-    size_t     bufsize,             /* I   - Size of string buffer */
-    char       *start_pos,   /* I   - Start of part to be moved */
-    int        num_chars)    /* I   - Move by how many characters? */
+    char       *buffer,             // I/O - String buffer
+    size_t     bufsize,             // I   - Size of string buffer
+    char       *start_pos,   // I   - Start of part to be moved
+    int        num_chars)    // I   - Move by how many characters?
 {
   int bytes_to_be_moved,
       buf_space_available;
@@ -618,73 +619,73 @@ move_right_part(
   }
 }
 
-/*
- * 'cfIEEE1284NormalizeMakeModel()' - Normalize a product/make-and-model
- *                                     string.
- *
- * This function tries to undo the mistakes made by many printer manufacturers
- * to produce a clean make-and-model string we can use.
- */
+//
+// 'cfIEEE1284NormalizeMakeModel()' - Normalize a product/make-and-model
+//                                    string.
+//
+// This function tries to undo the mistakes made by many printer manufacturers
+// to produce a clean make-and-model string we can use.
+//
 
-char *                                 /* O - Normalized make-and-model string
-                                           or NULL on error */
+char *                                 // O - Normalized make-and-model string
+                                        //     or NULL on error
 cfIEEE1284NormalizeMakeModel(
-    const char *make_and_model,                /* I - Original make-and-model string
-                                              or device ID */
-    const char *make,                   /* I - Manufacturer name as hint for
-                                              correct separation of
-                                              make_and_model or adding
-                                              make, or pointer into input
-                                              string where model name starts
-                                              or NULL,
-                                              ignored on device ID with "MFG"
-                                              field or for NO_MAKE_MODEL */
-    cf_ieee1284_normalize_modes_t mode,        /* I - Bit field to describe how to
-                                              normalize */
-    regex_t    *extra_regex,            /* I - Compiled regex to determine
-                                              where the extra info after
-                                              the driver name starts, also
-                                              mark with parentheses which
-                                              sub string should be the
-                                              driver name */
-    char       *buffer,                        /* O - String buffer, to hold the
-                                              normalized input string, plus,
-                                              after the terminating zero, the
-                                              driver name if an appropriate
-                                              extra_regex is supplied 
-                                              (*drvname will point to it) */
-    size_t     bufsize,                        /* O - Size of string buffer */
-    char       **model,                 /* O - Pointer to where model name
-                                              starts in buffer or NULL */
-    char       **extra,                 /* O - Pointer to where extra info
-                                              starts in buffer (after comma,
-                                              semicolon, parenthese, or
-                                              start of extra_regex
-                                              match) or NULL */
-    char       **drvname)               /* O - Driver name, string of the first
-                                              matching parenthese expression
-                                              in the extra_regex */
+    const char *make_and_model,                // I - Original make-and-model string
+                                       //     or device ID
+    const char *make,                   // I - Manufacturer name as hint for
+                                        //     correct separation of
+                                       //     make_and_model or adding
+                                       //     make, or pointer into input
+                                       //     string where model name starts
+                                       //     or NULL,
+                                       //     ignored on device ID with "MFG"
+                                       //     field or for NO_MAKE_MODEL
+    cf_ieee1284_normalize_modes_t mode,        // I - Bit field to describe how to
+                                       //     normalize
+    regex_t    *extra_regex,            // I - Compiled regex to determine
+                                       //     where the extra info after
+                                       //     the driver name starts, also
+                                       //     mark with parentheses which
+                                       //     sub string should be the
+                                       //     driver name
+    char       *buffer,                        // O - String buffer, to hold the
+                                       //     normalized input string, plus,
+                                       //     after the terminating zero, the
+                                       //     driver name if an appropriate
+                                       //     extra_regex is supplied
+                                       //     (*drvname will point to it)
+    size_t     bufsize,                        // O - Size of string buffer
+    char       **model,                 // O - Pointer to where model name
+                                       //     starts in buffer or NULL
+    char       **extra,                 // O - Pointer to where extra info
+                                       //     starts in buffer (after comma,
+                                       //     semicolon, parenthese, or
+                                       //     start of extra_regex
+                                       //     match) or NULL
+    char       **drvname)               // O - Driver name, string of the first
+                                        //     matching parenthese expression
+                                        //     in the extra_regex
 {
   int   i;
-  char *bufptr;                        /* Pointer into buffer */
-  char  sepchr = ' ';                   /* Word separator character */
-  int   compare = 0,                    /* Format for comparing */
-        human = 0,                      /* Format for human-readable string */
-        lower = 0,                      /* All letters lowercase */
-        upper = 0,                      /* All letters uppercase */
-        pad = 0,                        /* Zero-pad numbers to 6 digits */
-        separate = 0,                   /* Separate components with '\0' */
-        nomakemodel = 0;                /* No make/model/extra separation */
-  char  *makeptr = NULL,                /* Manufacturer name in buffer */
-        *modelptr = NULL,               /* Model name in buffer */
-        *extraptr = NULL,               /* Extra info in buffer */
-        *drvptr = NULL;                 /* Driver name in buffer */
+  char *bufptr;                        // Pointer into buffer
+  char  sepchr = ' ';                   // Word separator character
+  int   compare = 0,                    // Format for comparing
+        human = 0,                      // Format for human-readable string
+        lower = 0,                      // All letters lowercase
+        upper = 0,                      // All letters uppercase
+        pad = 0,                        // Zero-pad numbers to 6 digits
+        separate = 0,                   // Separate components with '\0'
+        nomakemodel = 0;                // No make/model/extra separation
+  char  *makeptr = NULL,                // Manufacturer name in buffer
+        *modelptr = NULL,               // Model name in buffer
+        *extraptr = NULL,               // Extra info in buffer
+        *drvptr = NULL;                 // Driver name in buffer
   int   numdigits = 0,
         rightsidemoved = 0;
-  regmatch_t re_matches[10];            /* Regular expression matches,
-                                          first entry for the whole regex,
-                                          following entries for each
-                                          parenthese pair */
+  regmatch_t re_matches[10];            // Regular expression matches,
+                                       // first entry for the whole regex,
+                                        // following entries for each
+                                        // parenthese pair
 
   if (!make_and_model || !buffer || bufsize < 1)
   {
@@ -694,9 +695,9 @@ cfIEEE1284NormalizeMakeModel(
     return (NULL);
   }
 
- /*
-  * Check formatting mode...
-  */
+  //
+  // Check formatting mode...
+  //
 
   if (!mode)
     mode = CF_IEEE1284_NORMALIZE_HUMAN;
@@ -747,16 +748,16 @@ cfIEEE1284NormalizeMakeModel(
   else if (mode & CF_IEEE1284_NORMALIZE_HUMAN)
     human = 1;
 
- /*
-  * Skip leading whitespace...
-  */
+  //
+  // Skip leading whitespace...
+  //
 
   while (isspace(*make_and_model))
     make_and_model ++;
 
- /*
-  * Remove parentheses...
-  */
+  //
+  // Remove parentheses...
+  //
 
   if (make_and_model[0] == '(')
   {
@@ -767,9 +768,9 @@ cfIEEE1284NormalizeMakeModel(
       *bufptr = '\0';
   }
 
- /*
-  * Determine format of input string
-  */
+  //
+  // Determine format of input string
+  //
 
   if ((((makeptr = strstr(make_and_model, "MFG:")) != NULL &&
        (makeptr == make_and_model || *(makeptr - 1) == ';')) ||
@@ -780,9 +781,9 @@ cfIEEE1284NormalizeMakeModel(
        ((modelptr = strstr(make_and_model, "MODEL:")) != NULL &&
        (modelptr == make_and_model || *(modelptr - 1) == ';'))))
   {
-   /*
-    * Input is device ID
-    */
+    //
+    // Input is device ID
+    //
 
     bufptr = buffer;
     while (*makeptr != ':') makeptr ++;
@@ -824,10 +825,10 @@ cfIEEE1284NormalizeMakeModel(
   }
   else
   {
-   /*
-    * Input is string of type "MAKE MODEL", "MAKE MODEL, EXTRA", or
-    * "MAKE MODEL (EXTRA)"
-    */
+    //
+    // Input is string of type "MAKE MODEL", "MAKE MODEL, EXTRA", or
+    // "MAKE MODEL (EXTRA)"
+    //
 
     modelptr = NULL;
     extraptr = NULL;
@@ -841,76 +842,76 @@ cfIEEE1284NormalizeMakeModel(
       {
        if (make >= make_and_model &&
            make < make_and_model + strlen(make_and_model))
-         /*
-          * User-supplied pointer where model name starts
-          */
+         //
+         // User-supplied pointer where model name starts
+         //
 
          modelptr = buffer + (make - make_and_model);
        else if (!strncasecmp(buffer, make, strlen(make)) &&
                 isspace(buffer[strlen(make)]))
-         /*
-         * User-supplied make string matches start of input
-         */
+         //
+         // User-supplied make string matches start of input
+         //
 
          modelptr = buffer + strlen(make) + 1;
        else
        {
-         /*
-         * Add user-supplied make string at start of input
-         */
+         //
+         // Add user-supplied make string at start of input
+         //
 
          snprintf(buffer, bufsize, "%s %s", make, make_and_model);
          modelptr = buffer + strlen(make) + 1;
        }
       }
 
-     /*
-      * Add manufacturers as needed...
-      */
+      //
+      // Add manufacturers as needed...
+      //
 
       if (modelptr == NULL)
       {
        if (!strncasecmp(make_and_model, "XPrint", 6))
        {
-        /*
-         * Xerox XPrint...
-         */
+         //
+         // Xerox XPrint...
+         //
 
          snprintf(buffer, bufsize, "Xerox %s", make_and_model);
          modelptr = buffer + 6;
        }
        else if (!strncasecmp(make_and_model, "Eastman", 7))
         {
-         /*
-         * Kodak...
-         */
+         //
+         // Kodak...
+         //
 
          snprintf(buffer, bufsize, "Kodak %s", make_and_model + 7);
          modelptr = buffer + 6;
        }
        else if (!strncasecmp(make_and_model, "laserwriter", 11))
        {
-         /*
-         * Apple LaserWriter...
-         */
+         //
+         // Apple LaserWriter...
+         //
 
          snprintf(buffer, bufsize, "Apple LaserWriter%s", make_and_model + 11);
          modelptr = buffer + 6;
        }
        else if (!strncasecmp(make_and_model, "colorpoint", 10))
         {
-         /*
-         * Seiko...
-         */
+         //
+         // Seiko...
+         //
 
          snprintf(buffer, bufsize, "Seiko %s", make_and_model);
          modelptr = buffer + 6;
        }
        else if (!strncasecmp(make_and_model, "fiery", 5))
         {
-         /*
-         * EFI...
-         */
+         //
+         // EFI...
+         //
 
          snprintf(buffer, bufsize, "EFI %s", make_and_model);
          modelptr = buffer + 4;
@@ -918,18 +919,18 @@ cfIEEE1284NormalizeMakeModel(
        else if (!strncasecmp(make_and_model, "ps ", 3) ||
                 !strncasecmp(make_and_model, "colorpass", 9))
         {
-         /*
-         * Canon...
-         */
+         //
+         // Canon...
+         //
 
          snprintf(buffer, bufsize, "Canon %s", make_and_model);
          modelptr = buffer + 6;
        }
        else if (!strncasecmp(make_and_model, "primera", 7))
         {
-         /*
-         * Fargo...
-         */
+         //
+         // Fargo...
+         //
 
          snprintf(buffer, bufsize, "Fargo %s", make_and_model);
          modelptr = buffer + 6;
@@ -939,26 +940,26 @@ cfIEEE1284NormalizeMakeModel(
                 !strncasecmp(make_and_model, "laserjet", 8) ||
                 !strncasecmp(make_and_model, "officejet", 9))
         {
-         /*
-         * HP...
-         */
+         //
+         // HP...
+         //
 
          snprintf(buffer, bufsize, "HP %s", make_and_model);
          modelptr = buffer + 3;
        }
        else if (!strncasecmp(make_and_model, "ecosys", 6))
         {
-         /*
-         * Kyocera...
-         */
+         //
+         // Kyocera...
+         //
 
          snprintf(buffer, bufsize, "Kyocera %s", make_and_model);
          modelptr = buffer + 8;
        }
 
-       /*
-       * Known make names with space
-       */
+       //
+       // Known make names with space
+       //
 
         else if (strncasecmp(buffer, "konica minolta", 14) &&
                 isspace(buffer[14]))
@@ -973,9 +974,9 @@ cfIEEE1284NormalizeMakeModel(
                 isspace(buffer[12]))
          modelptr = buffer + 13;
 
-       /*
-       * Consider the first space as separation between make and model
-       */
+       //
+       // Consider the first space as separation between make and model
+       //
 
        else
        {
@@ -985,9 +986,9 @@ cfIEEE1284NormalizeMakeModel(
        }
       }
 
-     /*
-      * Adjust modelptr to the actual start of the model name
-      */
+      //
+      // Adjust modelptr to the actual start of the model name
+      //
 
       if (modelptr)
        while (!isalnum(*modelptr) && *modelptr != '\0')
@@ -997,18 +998,18 @@ cfIEEE1284NormalizeMakeModel(
 
   if (!nomakemodel)
   {
-   /*
-    * Clean up the make...
-    */
+    //
+    // Clean up the make...
+    //
 
     bufptr = buffer;
     while ((bufptr = strcasestr(bufptr, "agfa")) != NULL &&
           (bufptr == buffer || !isalnum(*(bufptr - 1))) &&
           !isalnum(*(bufptr + 4)))
     {
-     /*
-      * Replace with AGFA (all uppercase)...
-      */
+      //
+      // Replace with AGFA (all uppercase)...
+      //
 
       bufptr[0] = 'A';
       bufptr[1] = 'G';
@@ -1020,9 +1021,9 @@ cfIEEE1284NormalizeMakeModel(
     bufptr = buffer;
     while ((bufptr = strcasestr(bufptr, "Hewlett-Packard")) != NULL)
     {
-     /*
-      * Replace with "HP"...
-      */
+      //
+      // Replace with "HP"...
+      //
 
       bufptr[0] = 'H';
       bufptr[1] = 'P';
@@ -1037,9 +1038,9 @@ cfIEEE1284NormalizeMakeModel(
           (bufptr == buffer || !isalnum(*(bufptr - 1))) &&
           !isalnum(*(bufptr + 21)))
     {
-     /*
-      * Replace with Kodak...
-      */
+      //
+      // Replace with Kodak...
+      //
 
       bufptr[0] = 'K';
       bufptr[1] = 'o';
@@ -1055,9 +1056,9 @@ cfIEEE1284NormalizeMakeModel(
     bufptr = buffer;
     while ((bufptr = strcasestr(bufptr, "Lexmark International")) != NULL)
     {
-     /*
-      * Strip "International"...
-      */
+      //
+      // Strip "International"...
+      //
 
       move_right_part(buffer, bufsize, bufptr + 7, -14);
       if (modelptr >= bufptr + 21)
@@ -1070,9 +1071,9 @@ cfIEEE1284NormalizeMakeModel(
           (bufptr == buffer || !isalnum(*(bufptr - 1))) &&
           !isalnum(*(bufptr + 4)))
     {
-     /*
-      * Replace with LHAG...
-      */
+      //
+      // Replace with LHAG...
+      //
 
       bufptr[0] = 'L';
       bufptr[1] = 'H';
@@ -1086,9 +1087,9 @@ cfIEEE1284NormalizeMakeModel(
           (bufptr == buffer || !isalnum(*(bufptr - 1))) &&
           !isalnum(*(bufptr + 8)))
     {
-     /*
-      * Replace with LHAG...
-      */
+      //
+      // Replace with LHAG...
+      //
 
       bufptr[0] = 'L';
       bufptr[1] = 'H';
@@ -1103,9 +1104,9 @@ cfIEEE1284NormalizeMakeModel(
     bufptr = buffer;
     while ((bufptr = strcasestr(bufptr, "TOSHIBA TEC Corp.")) != NULL)
     {
-     /*
-      * Strip "TEC Corp."...
-      */
+      //
+      // Strip "TEC Corp."...
+      //
 
       move_right_part(buffer, bufsize, bufptr + 7, -10);
       if (modelptr >= bufptr + 17)
@@ -1113,37 +1114,40 @@ cfIEEE1284NormalizeMakeModel(
       bufptr += 7;
     }
 
-   /*
-    * Remove repeated manufacturer names...
-    */
+    //
+    // Remove repeated manufacturer names...
+    //
 
     while (strncasecmp(buffer, modelptr, modelptr - buffer) == 0)
       move_right_part(buffer, bufsize, modelptr, buffer - modelptr);
 
-   /*
-    * Clean up the model name...
-    */
+    //
+    // Clean up the model name...
+    //
 
     bufptr = modelptr;
     while ((bufptr = strcasestr(bufptr, " series")) != NULL)
     {
-     /*
-      * Strip "series"...
-      */
+      //
+      // Strip "series"...
+      //
 
       move_right_part(buffer, bufsize, bufptr, -7);
     }
 
-   /*
-    * Find extra info...
-    */
+    //
+    // Find extra info...
+    //
+
+    //
+    // If an appropriate regular expression is supplied we consider
+    // the end of the model name where the match of the whole regular
+    // expression begins. The rest of the string is considered extra
+    // info. To extract a driver name from it, the regular expression
+    // can contain parantheses, where the content of the first
+    // matching parenthese pair is considered the driver name
+    //
 
-    /* If an appropriate regular expression is supplied we consider
-       the end of the model name where the match of the whole regular
-       expression begins. The rest of the string is considered extra
-       info. To extract a driver name from it, the regular expression
-       can contain parantheses, where the content of the first
-       matching parenthese pair is considered the driver name */
     if (extra_regex)
     {
       if (!regexec(extra_regex, buffer,
@@ -1157,11 +1161,11 @@ cfIEEE1284NormalizeMakeModel(
               i ++)
            if (re_matches[i].rm_so >= 0 && re_matches[i].rm_eo >= 0)
            {
-             /* We have a driver name (matching parentheses). Copy
-                the driver name to the end of the output buffer, so
-                it does not interfere with the output string and does
-                not need to get moved when the length of the output
-                string changes. Point drvptr to it for easy access */
+             // We have a driver name (matching parentheses). Copy
+             // the driver name to the end of the output buffer, so
+             // it does not interfere with the output string and does
+             // not need to get moved when the length of the output
+             // string changes. Point drvptr to it for easy access
              drvptr = buffer + bufsize - 1;
              *drvptr = '\0';
              drvptr --;
@@ -1180,10 +1184,10 @@ cfIEEE1284NormalizeMakeModel(
     }
     else
     {
-      /* Not having a regular expression we consider comma, semicolon,
-        isolated dash, or parenthese as the end of the model name and
-        the rest of the string as extra info. So we set a pointer to
-        this extra info if we find such a character */
+      // Not having a regular expression we consider comma, semicolon,
+      // isolated dash, or parenthese as the end of the model name and
+      // the rest of the string as extra info. So we set a pointer to
+      // this extra info if we find such a character
       if ((extraptr = strchr(buffer, ',')) == NULL)
        if ((extraptr = strchr(buffer, ';')) == NULL)
          if ((extraptr = strstr(buffer, " - ")) == NULL)
@@ -1191,13 +1195,13 @@ cfIEEE1284NormalizeMakeModel(
       if (extraptr)
       {
        if (human)
-         /* Include separator characters between model and extra info, pointer
-            will be on first character after model */
+         // Include separator characters between model and extra info, pointer
+         // will be on first character after model
          while (extraptr > buffer && isspace(*(extraptr - 1)))
            extraptr --;
        else
        {
-         /* Let extra info start at first alphanumeric character */
+         // Let extra info start at first alphanumeric character
          while(!isalnum(*extraptr) && *extraptr != '\0')
            extraptr ++;
        }
@@ -1205,9 +1209,9 @@ cfIEEE1284NormalizeMakeModel(
     }
   }
 
- /*
-  * Remove trailing whitespace...
-  */
+  //
+  // Remove trailing whitespace...
+  //
 
   for (bufptr = buffer + strlen(buffer) - 1;
        bufptr >= buffer && isspace(*bufptr);
@@ -1215,35 +1219,35 @@ cfIEEE1284NormalizeMakeModel(
 
   bufptr[1] = '\0';
 
- /*
-  * Convert string into desired format
-  */
+  //
+  // Convert string into desired format
+  //
 
-  /* Word and component separation, number padding */
+  // Word and component separation, number padding
   bufptr = buffer;
   while (*bufptr)
   {
     rightsidemoved = 0;
-    if (compare) /* Comparison-optimized format */
+    if (compare) // Comparison-optimized format
     {
       if (bufptr > buffer &&
-         ((isdigit(*bufptr) && isalpha(*(bufptr - 1))) || /* a0 boundary */
-          (isalpha(*bufptr) && isdigit(*(bufptr - 1))) || /* 0a boundary */
+         ((isdigit(*bufptr) && isalpha(*(bufptr - 1))) || // a0 boundary
+          (isalpha(*bufptr) && isdigit(*(bufptr - 1))) || // 0a boundary
           (!separate && modelptr && bufptr == modelptr &&
-           bufptr >= buffer + 2 && /* 2 separator char between make/model */
+           bufptr >= buffer + 2 && // 2 separator char between make/model
            isalnum(*(bufptr - 2)) && !isalnum(*(bufptr - 1))) || 
           (!separate && extraptr && bufptr == extraptr &&
-           bufptr >= buffer + 2 && /* 2 separator char between model/extra */
+           bufptr >= buffer + 2 && // 2 separator char between model/extra
            isalnum(*(bufptr - 2)) && !isalnum(*(bufptr - 1)))))
       {
-       /* Insert single separator */
+       // Insert single separator
        move_right_part(buffer, bufsize, bufptr, 1);
        *bufptr = sepchr;
        rightsidemoved += 1;
       }
-      else if (*bufptr == '+') /* Model names sometimes differ only by a '+' */
+      else if (*bufptr == '+') // Model names sometimes differ only by a '+'
       {
-       /* Replace with the word "plus" */
+       // Replace with the word "plus"
        move_right_part(buffer, bufsize, bufptr, 3);
        *bufptr = 'p';
        *(bufptr + 1) = 'l';
@@ -1251,16 +1255,16 @@ cfIEEE1284NormalizeMakeModel(
        *(bufptr + 3) = 's';
        rightsidemoved += 3;
       }
-      else if (!isalnum(*bufptr)) /* Space or punctuation character */
+      else if (!isalnum(*bufptr)) // Space or punctuation character
       {
        if (bufptr == buffer || !isalnum(*(bufptr - 1)))
        {
-         /* The previous is already a separator, remove this one */
+         // The previous is already a separator, remove this one
          move_right_part(buffer, bufsize, bufptr, -1);
          rightsidemoved -= 1;
        }
        else
-         /* Turn to standard separator character */
+         // Turn to standard separator character
          *bufptr = sepchr;
       }
       if (pad)
@@ -1283,22 +1287,22 @@ cfIEEE1284NormalizeMakeModel(
        }
       }
     }
-    else if (human) /* Human-readable format */
+    else if (human) // Human-readable format
     {
-      if (isspace(*bufptr)) /* White space */
+      if (isspace(*bufptr)) // White space
       {
        if (bufptr == buffer || isspace(*(bufptr - 1)))
        {
-         /* The previous is already white space, remove this one */
+         // The previous is already white space, remove this one
          move_right_part(buffer, bufsize, bufptr, -1);
          rightsidemoved -= 1;
        }
        else
-         /* Turn to standard separator character */
+         // Turn to standard separator character
          *bufptr = sepchr;
       }
     }
-    /* Separate component strings with '\0' if requested */
+    // Separate component strings with '\0' if requested
     if (separate && bufptr > buffer)
     {
       if (modelptr && bufptr == modelptr)
@@ -1306,20 +1310,20 @@ cfIEEE1284NormalizeMakeModel(
       if (extraptr && bufptr == extraptr)
        *(bufptr - 1) = '\0';
     }
-    /* Correct component start pointers */
+    // Correct component start pointers
     if (modelptr && modelptr >= bufptr)
       modelptr += rightsidemoved;
     if (extraptr && extraptr >= bufptr)
       extraptr += rightsidemoved;
-    /* Advance to next character */
+    // Advance to next character
     bufptr += (rightsidemoved > 0 ? rightsidemoved :
               (rightsidemoved < 0 ? 0 : 1));
   }
-  /* Remove separator at the end of the string */
+  // Remove separator at the end of the string
   if (bufptr > buffer && *(bufptr - 1) == sepchr)
     *(bufptr - 1) = '\0'; 
 
-  /* Adjustment of upper/lowercase */
+  // Adjustment of upper/lowercase
   if (lower == 1 || upper == 1)
   {
     bufptr = buffer;
@@ -1331,9 +1335,9 @@ cfIEEE1284NormalizeMakeModel(
     }
   }
 
- /*
-  * Return resulting string and pointers
-  */
+  //
+  // Return resulting string and pointers
+  //
 
   if (drvptr <= buffer + strlen(buffer) + 1)
     drvptr = NULL;
index 6a56b27b52599a15b87b56d38bb669d2b383f9fe..295e43839b6444670962eb0ad5ef3ed91bcffe97 100644 (file)
@@ -1,22 +1,22 @@
-/*
- *   IEEE1284 Device ID support definitions for OpenPrinting CUPS Filters.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
- *
- *   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 "COPYING"
- *   which should have been included with this file.
- */
+//
+//   IEEE1284 Device ID support definitions for OpenPrinting CUPS Filters.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+//
+//   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 "COPYING"
+//   which should have been included with this file.
+//
 
 #ifndef _CUPSFILTERS_IEEE1284_H_
 #  define _CUPSFILTERS_IEEE1284_H_
 
 
-/*
- * Include necessary headers.
- */
+//
+// Include necessary headers.
+//
 
 #  include <cups/cups.h>
 #  include <cups/backend.h>
@@ -36,7 +36,7 @@
 #    define LPIOC_GET_DEVICE_ID(len)   _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
 #    include <linux/parport.h>
 #    include <linux/ppdev.h>
-#  endif /* __linux */
+#  endif // __linux
 
 #  ifdef __sun
 #    ifdef __sparc
 #    else
 #      include <sys/ioccom.h>
 #      include <sys/ecppsys.h>
-#    endif /* __sparc */
-#  endif /* __sun */
+#    endif // __sparc
+#  endif // __sun
 
 
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
 
 #  ifdef __cplusplus
 extern "C" {
-#  endif /* __cplusplus */
+#  endif // __cplusplus
 
 
-/*
- * Types...
- */
+//
+// Types...
+//
 
-/* Bit field to describe how to normalize make/model/device ID strings */
+// Bit field to describe how to normalize make/model/device ID strings
 enum cf_ieee1284_normalize_modes_e
 {
- CF_IEEE1284_NORMALIZE_COMPARE = 0x01,        /* Optimized for comparing,
-                                                replacing any sequence of
-                                                non-alpha-numeric characters
-                                                by a single separator char,
-                                                at any letter-number boundary
-                                                and any camel-case boundary
-                                                add a single separator char,
-                                                2 separator chars between
-                                                make/model/extra,
-                                                make all letters lowercase (or
-                                                uppercase) */ 
- CF_IEEE1284_NORMALIZE_IPP = 0x02,            /* Only chars allowed in
-                                                IPP keywords */
- CF_IEEE1284_NORMALIZE_ENV = 0x04,            /* Environment variable format
-                                                upparcaser and underscore */
- CF_IEEE1284_NORMALIZE_HUMAN = 0x08,          /* Human-readable, conserves
-                                                spaces and special characters
-                                                but does some clean-up */
- CF_IEEE1284_NORMALIZE_LOWERCASE = 0x10,      /* All letters lowercase */
- CF_IEEE1284_NORMALIZE_UPPERCASE = 0x20,      /* All letters uppercase */
- CF_IEEE1284_NORMALIZE_SEPARATOR_SPACE = 0x40,/* Separator char is ' ' */
- CF_IEEE1284_NORMALIZE_SEPARATOR_DASH = 0x80, /* Separator char is '-' */
- CF_IEEE1284_NORMALIZE_SEPARATOR_UNDERSCORE = 0x100,/* Separator char is '_' */
- CF_IEEE1284_NORMALIZE_PAD_NUMBERS = 0x200,   /* Zero-pad numbers in stings
-                                                to get better list sorting
-                                                results */
- CF_IEEE1284_NORMALIZE_SEPARATE_COMPONENTS = 0x400,/* In the output buffer put
-                                                 '\0' bytes between make,
-                                                model, and extra, to use
-                                                as separate strings */
- CF_IEEE1284_NORMALIZE_NO_MAKE_MODEL = 0x800, /* No make/model/extra separation,
-                                                do not try to identify, add,
-                                                or clean up manufacturer
-                                                name */
+ CF_IEEE1284_NORMALIZE_COMPARE = 0x01,        // Optimized for comparing,
+                                              // replacing any sequence of
+                                              // non-alpha-numeric characters
+                                              // by a single separator char,
+                                              // at any letter-number boundary
+                                              // and any camel-case boundary
+                                              // add a single separator char,
+                                              // 2 separator chars between
+                                              // make/model/extra,
+                                              // make all letters lowercase (or
+                                              // uppercase)
+ CF_IEEE1284_NORMALIZE_IPP = 0x02,            // Only chars allowed in
+                                              // IPP keywords
+ CF_IEEE1284_NORMALIZE_ENV = 0x04,            // Environment variable format
+                                              // upparcase and underscore
+ CF_IEEE1284_NORMALIZE_HUMAN = 0x08,          // Human-readable, conserves
+                                              // spaces and special characters
+                                              // but does some clean-up
+ CF_IEEE1284_NORMALIZE_LOWERCASE = 0x10,      // All letters lowercase
+ CF_IEEE1284_NORMALIZE_UPPERCASE = 0x20,      // All letters uppercase
+ CF_IEEE1284_NORMALIZE_SEPARATOR_SPACE = 0x40,// Separator char is ' '
+ CF_IEEE1284_NORMALIZE_SEPARATOR_DASH = 0x80, // Separator char is '-'
+ CF_IEEE1284_NORMALIZE_SEPARATOR_UNDERSCORE = 0x100,// Separator char is '_'
+ CF_IEEE1284_NORMALIZE_PAD_NUMBERS = 0x200,   // Zero-pad numbers in strings
+                                              // to get better list sorting
+                                              // results
+ CF_IEEE1284_NORMALIZE_SEPARATE_COMPONENTS = 0x400,// In the output buffer put
+                                              // '\0' bytes between make,
+                                              // model, and extra, to use
+                                              // as separate strings
+ CF_IEEE1284_NORMALIZE_NO_MAKE_MODEL = 0x800, // No make/model/extra separation,
+                                              // do not try to identify, add,
+                                              // or clean up manufacturer
+                                              // name
 };
 typedef unsigned cf_ieee1284_normalize_modes_t;
 
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
 
 extern int    cfIEEE1284GetDeviceID(int fd, char *device_id,
                                    int device_id_size,
@@ -127,5 +127,5 @@ extern char   *cfIEEE1284NormalizeMakeModel(const char *make_and_model,
 
 #  ifdef __cplusplus
 }
-#  endif /* __cplusplus */
-#endif /* !_CUPSFILTERS_IEEE1284_H_ */
+#  endif // __cplusplus
+#endif // !_CUPSFILTERS_IEEE1284_H_
diff --git a/cupsfilters/image-bmp.c b/cupsfilters/image-bmp.c
deleted file mode 100644 (file)
index cda2557..0000000
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- *   BMP image routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadBMP() - Read a BMP image file.
- *   read_word()         - Read a 16-bit unsigned integer.
- *   read_dword()        - Read a 32-bit unsigned integer.
- *   read_long()         - Read a 32-bit signed integer.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "image-private.h"
-
-
-/*
- * Constants for the bitmap compression...
- */
-
-#  define BI_RGB       0               /* No compression - straight BGR data */
-#  define BI_RLE8      1               /* 8-bit run-length compression */
-#  define BI_RLE4      2               /* 4-bit run-length compression */
-#  define BI_BITFIELDS 3               /* RGB bitmap with RGB masks */
-
-
-/*
- * Local functions...
- */
-
-static unsigned short  read_word(FILE *fp);
-static unsigned int    read_dword(FILE *fp);
-static int             read_long(FILE *fp);
-
-
-/*
- * '_cfImageReadBMP()' - Read a BMP image file.
- */
-
-int                                    /* O - Read status */
-_cfImageReadBMP(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
-{
-  int          offset,                 /* Offset to bitmap data */
-               info_size,              /* Size of info header */
-               planes,                 /* Number of planes (always 1) */
-               depth,                  /* Depth of image (bits) */
-               compression,            /* Type of compression */
-               image_size,             /* Size of image in bytes */
-               colors_used,            /* Number of colors used */
-               colors_important,       /* Number of important colors */
-               bpp,                    /* Bytes per pixel */
-               x, y,                   /* Looping vars */
-               color,                  /* Color of RLE pixel */
-               count,                  /* Number of times to repeat */
-               temp,                   /* Temporary color */
-               align;                  /* Alignment bytes */
-  cf_ib_t      bit,                    /* Bit in image */
-               byte;                   /* Byte in image */
-  cf_ib_t      *in,                    /* Input pixels */
-               *out,                   /* Output pixels */
-               *ptr;                   /* Pointer into pixels */
-  cf_ib_t      colormap[256][4];       /* Colormap */
-
-
-  (void)secondary;
-
-  (void)planes;
-  (void)image_size;
-  (void)colors_important;
-
- /*
-  * Get the header...
-  */
-
-  getc(fp);            /* Skip "BM" sync chars */
-  getc(fp);
-  read_dword(fp);      /* Skip size */
-  read_word(fp);       /* Skip reserved stuff */
-  read_word(fp);
-  offset = read_dword(fp);
-
-  DEBUG_printf(("DEBUG: offset = %d\n", offset));
-
-  if (offset < 0)
-  {
-    DEBUG_printf(("DEBUG: Bad BMP offset %d\n", offset));
-    fclose(fp);
-    return (1);
-  }
-
- /*
-  * Then the bitmap information...
-  */
-
-  info_size        = read_dword(fp);
-  img->xsize       = read_long(fp);
-  img->ysize       = read_long(fp);
-  planes           = read_word(fp);
-  depth            = read_word(fp);
-  compression      = read_dword(fp);
-  image_size       = read_dword(fp);
-  img->xppi        = read_long(fp) * 0.0254 + 0.5;
-  img->yppi        = read_long(fp) * 0.0254 + 0.5;
-  colors_used      = read_dword(fp);
-  colors_important = read_dword(fp);
-
-  if (img->xsize == 0 || img->xsize > CF_IMAGE_MAX_WIDTH ||
-      img->ysize == 0 || img->ysize > CF_IMAGE_MAX_HEIGHT ||
-      (depth != 1 && depth != 4 && depth != 8 && depth != 24))
-  {
-    DEBUG_printf(("DEBUG: Bad BMP dimensions %ux%ux%d\n",
-                 img->xsize, img->ysize, depth));
-    fclose(fp);
-    return (1);
-  }
-
-  if (colors_used < 0 || colors_used > 256)
-  {
-    DEBUG_printf(("DEBUG: Bad BMP colormap size %d\n", colors_used));
-    fclose(fp);
-    return (1);
-  }
-
-  if (img->xppi == 0 || img->yppi == 0)
-  {
-    DEBUG_printf(("DEBUG: Bad BMP resolution %dx%d PPI.\n",
-                 img->xppi, img->yppi));
-    img->xppi = img->yppi = 200;
-  }
-
- /*
-  * Make sure the resolution info is valid...
-  */
-
-  DEBUG_printf(("info_size = %d, xsize = %d, ysize = %d, planes = %d, depth = %d\n",
-               info_size, img->xsize, img->ysize, planes, depth));
-  DEBUG_printf(("compression = %d, image_size = %d, xppi = %d, yppi = %d\n",
-               compression, image_size, img->xppi, img->yppi));
-  DEBUG_printf(("colors_used = %d, colors_important = %d\n", colors_used,
-               colors_important));
-
-  if (info_size > 40)
-    for (info_size -= 40; info_size > 0; info_size --)
-      getc(fp);
-
- /*
-  * Get colormap...
-  */
-
-  if (colors_used == 0 && depth <= 8)
-    colors_used = 1 << depth;
-
-  if (colors_used > 0) {
-    if (fread(colormap, colors_used, 4, fp) == 0 && ferror(fp))
-      DEBUG_printf(("Error reading file!"));
-  } else
-    memset(colormap, 0, sizeof(colormap));
-
- /*
-  * Setup image and buffers...
-  */
-
-  img->colorspace = (primary == CF_IMAGE_RGB_CMYK) ? CF_IMAGE_RGB : primary;
-
-  cfImageSetMaxTiles(img, 0);
-
-  bpp = cfImageGetDepth(img);
-
-  if ((in = malloc(img->xsize * 3)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    return (1);
-  }
-
-  if ((out = malloc(img->xsize * bpp)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    free(in);
-    fclose(fp);
-    return (1);
-  }
-
- /*
-  * Read the image data...
-  */
-
-  color = 0;
-  count = 0;
-  align = 0;
-
-  for (y = img->ysize - 1; y >= 0; y --)
-  {
-    ptr = in;
-
-    switch (depth)
-    {
-      case 1 : /* Bitmap */
-          for (x = img->xsize, bit = 128, byte = 0; x > 0; x --)
-         {
-           if (bit == 128)
-             byte = getc(fp);
-
-           if (byte & bit)
-           {
-             *ptr++ = colormap[1][2];
-             *ptr++ = colormap[1][1];
-             *ptr++ = colormap[1][0];
-           }
-           else
-           {
-             *ptr++ = colormap[0][2];
-             *ptr++ = colormap[0][1];
-             *ptr++ = colormap[0][0];
-           }
-
-           if (bit > 1)
-             bit >>= 1;
-           else
-             bit = 128;
-         }
-
-         /*
-         * Read remaining bytes to align to 32 bits...
-         */
-
-         for (temp = (img->xsize + 7) / 8; temp & 3; temp ++)
-           getc(fp);
-          break;
-
-      case 4 : /* 16-color */
-          for (x = img->xsize, bit = 0xf0, temp = 0; x > 0; x --)
-         {
-          /*
-           * Get a new count as needed...
-           */
-
-            if (compression != BI_RLE4 && count == 0)
-           {
-             count = 2;
-             color = -1;
-            }
-
-           if (count == 0)
-           {
-             while (align > 0)
-             {
-               align --;
-               getc(fp);
-              }
-
-             if ((count = getc(fp)) == 0)
-             {
-               if ((count = getc(fp)) == 0)
-               {
-                /*
-                 * End of line...
-                 */
-
-                  x ++;
-                 continue;
-               }
-               else if (count == 1)
-               {
-                /*
-                 * End of image...
-                 */
-
-                 break;
-               }
-               else if (count == 2)
-               {
-                /*
-                 * Delta...
-                 */
-
-                 count = getc(fp) * getc(fp) * img->xsize;
-                 color = 0;
-               }
-               else
-               {
-                /*
-                 * Absolute...
-                 */
-
-                 color = -1;
-                 align = ((4 - (count & 3)) / 2) & 1;
-               }
-             }
-             else
-               color = getc(fp);
-            }
-
-           /*
-           * Get a new color as needed...
-           */
-
-           count --;
-
-            if (bit == 0xf0)
-           {
-              if (color < 0)
-               temp = getc(fp);
-             else
-               temp = color;
-
-             /*
-             * Copy the color value...
-             */
-
-             *ptr++ = colormap[temp >> 4][2];
-             *ptr++ = colormap[temp >> 4][1];
-             *ptr++ = colormap[temp >> 4][0];
-             bit    = 0x0f;
-            }
-           else
-           {
-             /*
-             * Copy the color value...
-             */
-
-             *ptr++ = colormap[temp & 15][2];
-             *ptr++ = colormap[temp & 15][1];
-             *ptr++ = colormap[temp & 15][0];
-             bit    = 0xf0;
-           }
-         }
-          break;
-
-      case 8 : /* 256-color */
-          for (x = img->xsize; x > 0; x --)
-         {
-          /*
-           * Get a new count as needed...
-           */
-
-            if (compression != BI_RLE8)
-           {
-             count = 1;
-             color = -1;
-            }
-
-           if (count == 0)
-           {
-             while (align > 0)
-             {
-               align --;
-               getc(fp);
-              }
-
-             if ((count = getc(fp)) == 0)
-             {
-               if ((count = getc(fp)) == 0)
-               {
-                /*
-                 * End of line...
-                 */
-
-                  x ++;
-                 continue;
-               }
-               else if (count == 1)
-               {
-                /*
-                 * End of image...
-                 */
-
-                 break;
-               }
-               else if (count == 2)
-               {
-                /*
-                 * Delta...
-                 */
-
-                 count = getc(fp) * getc(fp) * img->xsize;
-                 color = 0;
-               }
-               else
-               {
-                /*
-                 * Absolute...
-                 */
-
-                 color = -1;
-                 align = (2 - (count & 1)) & 1;
-               }
-             }
-             else
-               color = getc(fp);
-            }
-
-           /*
-           * Get a new color as needed...
-           */
-
-            if (color < 0)
-             temp = getc(fp);
-           else
-             temp = color;
-
-            count --;
-
-           /*
-           * Copy the color value...
-           */
-
-           *ptr++ = colormap[temp][2];
-           *ptr++ = colormap[temp][1];
-           *ptr++ = colormap[temp][0];
-         }
-          break;
-
-      case 24 : /* 24-bit RGB */
-          for (x = img->xsize; x > 0; x --, ptr += 3)
-         {
-           ptr[2] = getc(fp);
-           ptr[1] = getc(fp);
-           ptr[0] = getc(fp);
-         }
-
-         /*
-         * Read remaining bytes to align to 32 bits...
-         */
-
-         for (temp = img->xsize * 3; temp & 3; temp ++)
-           getc(fp);
-          break;
-    }
-
-    if (saturation != 100 || hue != 0)
-      cfImageRGBAdjust(in, img->xsize, saturation, hue);
-
-    switch (img->colorspace)
-    {
-      default :
-         break;
-
-      case CF_IMAGE_WHITE :
-         cfImageRGBToWhite(in, out, img->xsize);
-         break;
-
-      case CF_IMAGE_RGB :
-         cfImageRGBToRGB(in, out, img->xsize);
-         break;
-
-      case CF_IMAGE_BLACK :
-         cfImageRGBToBlack(in, out, img->xsize);
-         break;
-
-      case CF_IMAGE_CMY :
-         cfImageRGBToCMY(in, out, img->xsize);
-         break;
-
-      case CF_IMAGE_CMYK :
-         cfImageRGBToCMYK(in, out, img->xsize);
-         break;
-    }
-
-    if (lut)
-      cfImageLut(out, img->xsize * bpp, lut);
-
-    _cfImagePutRow(img, 0, y, img->xsize, out);
-  }
-
-  fclose(fp);
-  free(in);
-  free(out);
-
-  return (0);
-}
-
-
-/*
- * 'read_word()' - Read a 16-bit unsigned integer.
- */
-
-static unsigned short     /* O - 16-bit unsigned integer */
-read_word(FILE *fp)       /* I - File to read from */
-{
-  unsigned char b0, b1; /* Bytes from file */
-
-  b0 = getc(fp);
-  b1 = getc(fp);
-
-  return ((b1 << 8) | b0);
-}
-
-
-/*
- * 'read_dword()' - Read a 32-bit unsigned integer.
- */
-
-static unsigned int               /* O - 32-bit unsigned integer */
-read_dword(FILE *fp)              /* I - File to read from */
-{
-  unsigned char b0, b1, b2, b3; /* Bytes from file */
-
-  b0 = getc(fp);
-  b1 = getc(fp);
-  b2 = getc(fp);
-  b3 = getc(fp);
-
-  return ((((((b3 << 8) | b2) << 8) | b1) << 8) | b0);
-}
-
-
-/*
- * 'read_long()' - Read a 32-bit signed integer.
- */
-
-static int                        /* O - 32-bit signed integer */
-read_long(FILE *fp)               /* I - File to read from */
-{
-  unsigned char b0, b1, b2, b3; /* Bytes from file */
-
-  b0 = getc(fp);
-  b1 = getc(fp);
-  b2 = getc(fp);
-  b3 = getc(fp);
-
-  return ((int)(((((b3 << 8) | b2) << 8) | b1) << 8) | b0);
-}
-
index c4e6f0339f0174c8b516caf2ed014d1607361010..5496f7e3bd3f02904a6ad199cefebb88dcc791a1 100644 (file)
-/*
- *   Colorspace conversions for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2006 by Easy Software Products.
- *
- *   The color saturation/hue matrix stuff is provided thanks to Mr. Paul
- *   Haeberli at "http://www.sgi.com/grafica/matrix/index.html".
- *
- *   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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   cfImageCMYKToBlack()         - Convert CMYK data to black.
- *   cfImageCMYKToCMY()           - Convert CMYK colors to CMY.
- *   cfImageCMYKToCMYK()          - Convert CMYK colors to CMYK.
- *   cfImageCMYKToRGB()           - Convert CMYK colors to device-dependent
- *                                    RGB.
- *   cfImageCMYKToWhite()         - Convert CMYK colors to luminance.
- *   cfImageLut()                 - Adjust all pixel values with the given
- *                                    LUT.
- *   cfImageRGBAdjust()           - Adjust the hue and saturation of the
- *                                    given RGB colors.
- *   cfImageRGBToBlack()          - Convert RGB data to black.
- *   cfImageRGBToCMY()            - Convert RGB colors to CMY.
- *   cfImageRGBToCMYK()           - Convert RGB colors to CMYK.
- *   cfImageRGBToRGB()            - Convert RGB colors to device-dependent
- *                                    RGB.
- *   cfImageRGBToWhite()          - Convert RGB colors to luminance.
- *   cfImageSetProfile()          - Set the device color profile.
- *   cfImageSetRasterColorSpace() - Set the destination colorspace.
- *   cfImageWhiteToBlack()        - Convert luminance colors to black.
- *   cfImageWhiteToCMY()          - Convert luminance colors to CMY.
- *   cfImageWhiteToCMYK()         - Convert luminance colors to CMYK.
- *   cfImageWhiteToRGB()          - Convert luminance data to RGB.
- *   cfImageWhiteToWhite()        - Convert luminance colors to device-
- *                                  dependent luminance.
- *   cie_lab()                    - Map CIE Lab transformation...
- *   hue_rotate()                 - Rotate the hue, maintaining luminance.
- *   ident()                      - Make an identity matrix.
- *   mult()                       - Multiply two matrices.
- *   rgb_to_lab()                 - Convert an RGB color to CIE Lab.
- *   rgb_to_xyz()                 - Convert an RGB color to CIE XYZ.
- *   saturate()                   - Make a saturation matrix.
- *   x_form()                     - Transform a 3D point using a matrix...
- *   x_rotate()                   - Rotate about the x (red) axis...
- *   y_rotate()                   - Rotate about the y (green) axis...
- *   z_rotate()                   - Rotate about the z (blue) axis...
- *   z_shear()                    - Shear z using x and y...
- */
-
-/*
- * Include necessary headers...
- */
+//
+//   Colorspace conversions for libcupsfilters.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1993-2006 by Easy Software Products.
+//
+//   The color saturation/hue matrix stuff is provided thanks to Mr. Paul
+//   Haeberli at "http://www.sgi.com/grafica/matrix/index.html".
+//
+//   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 "COPYING"
+//   which should have been included with this file.
+//
+// Contents:
+//
+//   cfImageCMYKToBlack()         - Convert CMYK data to black.
+//   cfImageCMYKToCMY()           - Convert CMYK colors to CMY.
+//   cfImageCMYKToCMYK()          - Convert CMYK colors to CMYK.
+//   cfImageCMYKToRGB()           - Convert CMYK colors to device-dependent
+//                                  RGB.
+//   cfImageCMYKToWhite()         - Convert CMYK colors to luminance.
+//   cfImageLut()                 - Adjust all pixel values with the given
+//                                  LUT.
+//   cfImageRGBAdjust()           - Adjust the hue and saturation of the
+//                                  given RGB colors.
+//   cfImageRGBToBlack()          - Convert RGB data to black.
+//   cfImageRGBToCMY()            - Convert RGB colors to CMY.
+//   cfImageRGBToCMYK()           - Convert RGB colors to CMYK.
+//   cfImageRGBToRGB()            - Convert RGB colors to device-dependent
+//                                  RGB.
+//   cfImageRGBToWhite()          - Convert RGB colors to luminance.
+//   cfImageSetProfile()          - Set the device color profile.
+//   cfImageSetRasterColorSpace() - Set the destination colorspace.
+//   cfImageWhiteToBlack()        - Convert luminance colors to black.
+//   cfImageWhiteToCMY()          - Convert luminance colors to CMY.
+//   cfImageWhiteToCMYK()         - Convert luminance colors to CMYK.
+//   cfImageWhiteToRGB()          - Convert luminance data to RGB.
+//   cfImageWhiteToWhite()        - Convert luminance colors to device-
+//                                  dependent luminance.
+//   cie_lab()                    - Map CIE Lab transformation...
+//   hue_rotate()                 - Rotate the hue, maintaining luminance.
+//   ident()                      - Make an identity matrix.
+//   mult()                       - Multiply two matrices.
+//   rgb_to_lab()                 - Convert an RGB color to CIE Lab.
+//   rgb_to_xyz()                 - Convert an RGB color to CIE XYZ.
+//   saturate()                   - Make a saturation matrix.
+//   x_form()                     - Transform a 3D point using a matrix...
+//   x_rotate()                   - Rotate about the x (red) axis...
+//   y_rotate()                   - Rotate about the y (green) axis...
+//   z_rotate()                   - Rotate about the z (blue) axis...
+//   z_shear()                    - Shear z using x and y...
+//
+
+//
+// Include necessary headers...
+//
 
 #include "image-private.h"
 
 
-/*
- * Define some math constants that are required...
- */
+//
+// Define some math constants that are required...
+//
 
 #ifndef M_PI
 #  define M_PI         3.14159265358979323846
-#endif /* !M_PI */
+#endif // !M_PI
 
 #ifndef M_SQRT2
 #  define M_SQRT2      1.41421356237309504880
-#endif /* !M_SQRT2 */
+#endif // !M_SQRT2
 
 #ifndef M_SQRT1_2
 #  define M_SQRT1_2    0.70710678118654752440
-#endif /* !M_SQRT1_2 */
+#endif // !M_SQRT1_2
 
-/*
- * CIE XYZ whitepoint...
- */
+//
+// CIE XYZ whitepoint...
+//
 
 #define D65_X  (0.412453 + 0.357580 + 0.180423)
 #define D65_Y  (0.212671 + 0.715160 + 0.072169)
 #define D65_Z  (0.019334 + 0.119193 + 0.950227)
 
 
-/*
- * Lookup table structure...
- */
+//
+// Lookup table structure...
+//
 
 typedef int cups_clut_t[3][256];
 
 
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
 
 static int             cfImageHaveProfile = 0;
-                                       /* Do we have a color profile? */
+                                       // Do we have a color profile?
 static int             *cfImageDensity;
-                                       /* Ink/marker density LUT */
+                                       // Ink/marker density LUT
 static cups_clut_t     *cfImageMatrix;
-                                       /* Color transform matrix LUT */
+                                       // Color transform matrix LUT
 static cups_cspace_t   cfImageColorSpace = CUPS_CSPACE_RGB;
-                                       /* Destination colorspace */
+                                       // Destination colorspace
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 static float   cie_lab(float x, float xn);
 static void    hue_rotate(float [3][3], float);
@@ -116,24 +116,25 @@ static void       mult(float [3][3], float [3][3], float [3][3]);
 static void    rgb_to_lab(cf_ib_t *val);
 static void    rgb_to_xyz(cf_ib_t *val);
 static void    saturate(float [3][3], float);
-static void    x_form(float [3][3], float, float, float, float *, float *, float *);
+static void    x_form(float [3][3], float, float, float, float *, float *,
+                      float *);
 static void    x_rotate(float [3][3], float, float);
 static void    y_rotate(float [3][3], float, float);
 static void    z_rotate(float [3][3], float, float);
 static void    z_shear(float [3][3], float, float);
 
 
-/*
- * 'cfImageCMYKToBlack()' - Convert CMYK data to black.
- */
+//
+// 'cfImageCMYKToBlack()' - Convert CMYK data to black.
+//
 
 void
 cfImageCMYKToBlack(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
-  int  k;                              /* Black value */
+  int  k;                              // Black value
 
 
   if (cfImageHaveProfile)
@@ -165,18 +166,18 @@ cfImageCMYKToBlack(
 }
 
 
-/*
- * 'cfImageCMYKToCMY()' - Convert CMYK colors to CMY.
- */
+//
+// 'cfImageCMYKToCMY()' - Convert CMYK colors to CMY.
+//
 
 void
 cfImageCMYKToCMY(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
-  int  c, m, y, k;                     /* CMYK values */
-  int  cc, cm, cy;                     /* Calibrated CMY values */
+  int  c, m, y, k;                     // CMYK values
+  int  cc, cm, cy;                     // Calibrated CMY values
 
 
   if (cfImageHaveProfile)
@@ -252,18 +253,18 @@ cfImageCMYKToCMY(
 }
 
 
-/*
- * 'cfImageCMYKToCMYK()' - Convert CMYK colors to CMYK.
- */
+//
+// 'cfImageCMYKToCMYK()' - Convert CMYK colors to CMYK.
+//
 
 void
 cfImageCMYKToCMYK(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
-  int  c, m, y, k;                     /* CMYK values */
-  int  cc, cm, cy;                     /* Calibrated CMY values */
+  int  c, m, y, k;                     // CMYK values
+  int  cc, cm, cy;                     // Calibrated CMY values
 
 
   if (cfImageHaveProfile)
@@ -324,18 +325,18 @@ cfImageCMYKToCMYK(
 }
 
 
-/*
- * 'cfImageCMYKToRGB()' - Convert CMYK colors to device-dependent RGB.
- */
+//
+// 'cfImageCMYKToRGB()' - Convert CMYK colors to device-dependent RGB.
+//
 
 void
 cfImageCMYKToRGB(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
-  int  c, m, y, k;                     /* CMYK values */
-  int  cr, cg, cb;                     /* Calibrated RGB values */
+  int  c, m, y, k;                     // CMYK values
+  int  cr, cg, cb;                     // Calibrated RGB values
 
 
   if (cfImageHaveProfile)
@@ -421,17 +422,17 @@ cfImageCMYKToRGB(
 }
 
 
-/*
- * 'cfImageCMYKToWhite()' - Convert CMYK colors to luminance.
- */
+//
+// 'cfImageCMYKToWhite()' - Convert CMYK colors to luminance.
+//
 
 void
 cfImageCMYKToWhite(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
-  int  w;                              /* White value */
+  int  w;                              // White value
 
 
   if (cfImageHaveProfile)
@@ -467,14 +468,14 @@ cfImageCMYKToWhite(
 }
 
 
-/*
- * 'cfImageLut()' - Adjust all pixel values with the given LUT.
- */
+//
+// 'cfImageLut()' - Adjust all pixel values with the given LUT.
+//
 
 void
-cfImageLut(cf_ib_t       *pixels,      /* IO - Input/output pixels */
-             int             count,    /* I  - Number of pixels/bytes to adjust */
-             const cf_ib_t *lut)       /* I  - Lookup table */
+cfImageLut(cf_ib_t         *pixels,    // IO - Input/output pixels
+          int             count,       // I  - Number of pixels/bytes to adjust
+          const cf_ib_t   *lut)        // I  - Lookup table
 {
   while (count > 0)
   {
@@ -485,36 +486,36 @@ cfImageLut(cf_ib_t       *pixels, /* IO - Input/output pixels */
 }
 
 
-/*
- * 'cfImageRGBAdjust()' - Adjust the hue and saturation of the given RGB colors.
- */
+//
+// 'cfImageRGBAdjust()' - Adjust the hue and saturation of the given RGB colors.
+//
 
 void
-cfImageRGBAdjust(cf_ib_t *pixels,      /* IO - Input/output pixels */
-                  int       count,     /* I - Number of pixels to adjust */
-                  int       saturation,/* I - Color saturation (%) */
-                  int       hue)       /* I - Color hue (degrees) */
+cfImageRGBAdjust(cf_ib_t   *pixels,    // IO - Input/output pixels
+                int       count,       // I - Number of pixels to adjust
+                int       saturation,  // I - Color saturation (%)
+                int       hue)         // I - Color hue (degrees)
 {
-  int                  i, j, k;        /* Looping vars */
-  float                        mat[3][3];      /* Color adjustment matrix */
-  static int           last_sat = 100, /* Last saturation used */
-                       last_hue = 0;   /* Last hue used */
-  static cups_clut_t   *lut = NULL;    /* Lookup table for matrix */
+  int                  i, j, k;        // Looping vars
+  float                        mat[3][3];      // Color adjustment matrix
+  static int           last_sat = 100, // Last saturation used
+                       last_hue = 0;   // Last hue used
+  static cups_clut_t   *lut = NULL;    // Lookup table for matrix
 
 
   if (saturation != last_sat || hue != last_hue || !lut)
   {
-   /*
-    * Build the color adjustment matrix...
-    */
+    //
+    // Build the color adjustment matrix...
+    //
 
     ident(mat);
     saturate(mat, saturation * 0.01);
     hue_rotate(mat, (float)hue);
 
-   /*
-    * Allocate memory for the lookup table...
-    */
+    //
+    // Allocate memory for the lookup table...
+    //
 
     if (lut == NULL)
       lut = calloc(3, sizeof(cups_clut_t));
@@ -522,26 +523,26 @@ cfImageRGBAdjust(cf_ib_t *pixels, /* IO - Input/output pixels */
     if (lut == NULL)
       return;
 
-   /*
-    * Convert the matrix into a 3x3 array of lookup tables...
-    */
+    //
+    // Convert the matrix into a 3x3 array of lookup tables...
+    //
 
     for (i = 0; i < 3; i ++)
       for (j = 0; j < 3; j ++)
         for (k = 0; k < 256; k ++)
           lut[i][j][k] = mat[i][j] * k + 0.5;
 
-   /*
-    * Save the saturation and hue to compare later...
-    */
+    //
+    // Save the saturation and hue to compare later...
+    //
 
     last_sat = saturation;
     last_hue = hue;
   }
 
- /*
-  * Adjust each pixel in the given buffer.
-  */
+  //
+  // Adjust each pixel in the given buffer.
+  //
 
   while (count > 0)
   {
@@ -581,15 +582,15 @@ cfImageRGBAdjust(cf_ib_t *pixels, /* IO - Input/output pixels */
 }
 
 
-/*
- * 'cfImageRGBToBlack()' - Convert RGB data to black.
- */
+//
+// 'cfImageRGBToBlack()' - Convert RGB data to black.
+//
 
 void
 cfImageRGBToBlack(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
   if (cfImageHaveProfile)
     while (count > 0)
@@ -608,18 +609,18 @@ cfImageRGBToBlack(
 }
 
 
-/*
- * 'cfImageRGBToCMY()' - Convert RGB colors to CMY.
- */
+//
+// 'cfImageRGBToCMY()' - Convert RGB colors to CMY.
+//
 
 void
 cfImageRGBToCMY(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
-  int  c, m, y, k;                     /* CMYK values */
-  int  cc, cm, cy;                     /* Calibrated CMY values */
+  int  c, m, y, k;                     // CMYK values
+  int  cc, cm, cy;                     // Calibrated CMY values
 
 
   if (cfImageHaveProfile)
@@ -683,19 +684,19 @@ cfImageRGBToCMY(
 }
 
 
-/*
- * 'cfImageRGBToCMYK()' - Convert RGB colors to CMYK.
- */
+//
+// 'cfImageRGBToCMYK()' - Convert RGB colors to CMYK.
+//
 
 void
 cfImageRGBToCMYK(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
-  int  c, m, y, k,                     /* CMYK values */
-       km;                             /* Maximum K value */
-  int  cc, cm, cy;                     /* Calibrated CMY values */
+  int  c, m, y, k,                     // CMYK values
+       km;                             // Maximum K value
+  int  cc, cm, cy;                     // Calibrated CMY values
 
 
   if (cfImageHaveProfile)
@@ -773,18 +774,18 @@ cfImageRGBToCMYK(
 }
 
 
-/*
- * 'cfImageRGBToRGB()' - Convert RGB colors to device-dependent RGB.
- */
+//
+// 'cfImageRGBToRGB()' - Convert RGB colors to device-dependent RGB.
+//
 
 void
 cfImageRGBToRGB(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
-  int  c, m, y, k;                     /* CMYK values */
-  int  cr, cg, cb;                     /* Calibrated RGB values */
+  int  c, m, y, k;                     // CMYK values
+  int  cr, cg, cb;                     // Calibrated RGB values
 
 
   if (cfImageHaveProfile)
@@ -863,15 +864,15 @@ cfImageRGBToRGB(
 }
 
 
-/*
- * 'cfImageRGBToWhite()' - Convert RGB colors to luminance.
- */
+//
+// 'cfImageRGBToWhite()' - Convert RGB colors to luminance.
+//
 
 void
 cfImageRGBToWhite(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
   if (cfImageHaveProfile)
   {
@@ -894,23 +895,23 @@ cfImageRGBToWhite(
 }
 
 
-/*
- * 'cfImageSetProfile()' - Set the device color profile.
- */
+//
+// 'cfImageSetProfile()' - Set the device color profile.
+//
 
 void
-cfImageSetProfile(float d,             /* I - Ink/marker density */
-                    float g,           /* I - Ink/marker gamma */
-                    float matrix[3][3])        /* I - Color transform matrix */
+cfImageSetProfile(float d,             // I - Ink/marker density
+                 float g,              // I - Ink/marker gamma
+                 float matrix[3][3])   // I - Color transform matrix
 {
-  int  i, j, k;                        /* Looping vars */
-  float        m;                              /* Current matrix value */
-  int  *im;                            /* Pointer into cfImageMatrix */
+  int  i, j, k;                        // Looping vars
+  float        m;                              // Current matrix value
+  int  *im;                            // Pointer into cfImageMatrix
 
 
- /*
-  * Allocate memory for the profile data...
-  */
+  //
+  // Allocate memory for the profile data...
+  //
 
   if (cfImageMatrix == NULL)
     cfImageMatrix = calloc(3, sizeof(cups_clut_t));
@@ -924,9 +925,9 @@ cfImageSetProfile(float d,          /* I - Ink/marker density */
   if (cfImageDensity == NULL)
     return;
 
- /*
-  * Populate the profile lookup tables...
-  */
+  //
+  // Populate the profile lookup tables...
+  //
 
   cfImageHaveProfile  = 1;
 
@@ -940,23 +941,23 @@ cfImageSetProfile(float d,                /* I - Ink/marker density */
 }
 
 
-/*
- * 'cfImageSetRasterColorSpace()' - Set the destination colorspace.
- */
+//
+// 'cfImageSetRasterColorSpace()' - Set the destination colorspace.
+//
 
 void
 cfImageSetRasterColorSpace(
-    cups_cspace_t cs)                  /* I - Destination colorspace */
+    cups_cspace_t cs)                  // I - Destination colorspace
 {
- /*
-  * Set the destination colorspace...
-  */
+  //
+  // Set the destination colorspace...
+  //
 
   cfImageColorSpace = cs;
 
- /*
-  * Don't use color profiles in colorimetric colorspaces...
-  */
+  //
+  // Don't use color profiles in colorimetric colorspaces...
+  //
 
   if (cs == CUPS_CSPACE_CIEXYZ ||
       cs == CUPS_CSPACE_CIELab ||
@@ -965,15 +966,15 @@ cfImageSetRasterColorSpace(
 }
 
 
-/*
- * 'cfImageWhiteToBlack()' - Convert luminance colors to black.
- */
+//
+// 'cfImageWhiteToBlack()' - Convert luminance colors to black.
+//
 
 void
 cfImageWhiteToBlack(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
   if (cfImageHaveProfile)
     while (count > 0)
@@ -990,15 +991,15 @@ cfImageWhiteToBlack(
 }
 
 
-/*
- * 'cfImageWhiteToCMY()' - Convert luminance colors to CMY.
- */
+//
+// 'cfImageWhiteToCMY()' - Convert luminance colors to CMY.
+//
 
 void
 cfImageWhiteToCMY(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
   if (cfImageHaveProfile)
     while (count > 0)
@@ -1020,15 +1021,15 @@ cfImageWhiteToCMY(
 }
 
 
-/*
- * 'cfImageWhiteToCMYK()' - Convert luminance colors to CMYK.
- */
+//
+// 'cfImageWhiteToCMYK()' - Convert luminance colors to CMYK.
+//
 
 void
 cfImageWhiteToCMYK(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
   if (cfImageHaveProfile)
     while (count > 0)
@@ -1051,15 +1052,15 @@ cfImageWhiteToCMYK(
 }
 
 
-/*
- * 'cfImageWhiteToRGB()' - Convert luminance data to RGB.
- */
+//
+// 'cfImageWhiteToRGB()' - Convert luminance data to RGB.
+//
 
 void
 cfImageWhiteToRGB(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
   if (cfImageHaveProfile)
   {
@@ -1092,16 +1093,16 @@ cfImageWhiteToRGB(
 }
 
 
-/*
- * 'cfImageWhiteToWhite()' - Convert luminance colors to device-dependent
- *                             luminance.
- */
+//
+// 'cfImageWhiteToWhite()' - Convert luminance colors to device-dependent
+//                           luminance.
+//
 
 void
 cfImageWhiteToWhite(
-    const cf_ib_t *in,         /* I - Input pixels */
-    cf_ib_t       *out,                /* I - Output pixels */
-    int             count)             /* I - Number of pixels */
+    const cf_ib_t   *in,               // I - Input pixels
+    cf_ib_t         *out,              // I - Output pixels
+    int             count)             // I - Number of pixels
 {
   if (cfImageHaveProfile)
     while (count > 0)
@@ -1114,15 +1115,15 @@ cfImageWhiteToWhite(
 }
 
 
-/*
- * 'cie_lab()' - Map CIE Lab transformation...
- */
+//
+// 'cie_lab()' - Map CIE Lab transformation...
+//
 
-static float                           /* O - Adjusted color value */
-cie_lab(float x,                               /* I - Raw color value */
-       float xn)                       /* I - Whitepoint color value */
+static float                           // O - Adjusted color value
+cie_lab(float x,                       // I - Raw color value
+       float xn)                       // I - Whitepoint color value
 {
-  float x_xn;                          /* Fraction of whitepoint */
+  float x_xn;                          // Fraction of whitepoint
 
 
   x_xn = x / xn;
@@ -1134,31 +1135,31 @@ cie_lab(float x,                                /* I - Raw color value */
 }
 
 
-/
- * 'hue_rotate()' - Rotate the hue, maintaining luminance.
- */
+//
+// 'hue_rotate()' - Rotate the hue, maintaining luminance.
+//
 
 static void
-hue_rotate(float mat[3][3],            /* I - Matrix to append to */
-          float rot)                   /* I - Hue rotation in degrees */
+hue_rotate(float mat[3][3],            // I - Matrix to append to
+          float rot)                   // I - Hue rotation in degrees
 {
-  float hmat[3][3];                    /* Hue matrix */
-  float lx, ly, lz;                    /* Luminance vector */
-  float xrs, xrc;                      /* X rotation sine/cosine */
-  float yrs, yrc;                      /* Y rotation sine/cosine */
-  float zrs, zrc;                      /* Z rotation sine/cosine */
-  float zsx, zsy;                      /* Z shear x/y */
+  float hmat[3][3];                    // Hue matrix
+  float lx, ly, lz;                    // Luminance vector
+  float xrs, xrc;                      // X rotation sine/cosine
+  float yrs, yrc;                      // Y rotation sine/cosine
+  float zrs, zrc;                      // Z rotation sine/cosine
+  float zsx, zsy;                      // Z shear x/y
 
 
- /*
-  * Load the identity matrix...
-  */
+  //
+  // Load the identity matrix...
+  //
 
   ident(hmat);
 
- /*
-  * Rotate the grey vector into positive Z...
-  */
+  //
+  // Rotate the grey vector into positive Z...
+  //
 
   xrs = M_SQRT1_2;
   xrc = M_SQRT1_2;
@@ -1168,51 +1169,51 @@ hue_rotate(float mat[3][3],             /* I - Matrix to append to */
   yrc = -M_SQRT2 * yrs;
   y_rotate(hmat,yrs,yrc);
 
- /*
-  * Shear the space to make the luminance plane horizontal...
-  */
+  //
+  // Shear the space to make the luminance plane horizontal...
+  //
 
   x_form(hmat, 0.3086, 0.6094, 0.0820, &lx, &ly, &lz);
   zsx = lx / lz;
   zsy = ly / lz;
   z_shear(hmat, zsx, zsy);
 
- /*
-  * Rotate the hue...
-  */
+  //
+  // Rotate the hue...
+  //
 
   zrs = sin(rot * M_PI / 180.0);
   zrc = cos(rot * M_PI / 180.0);
 
   z_rotate(hmat, zrs, zrc);
 
- /*
-  * Unshear the space to put the luminance plane back...
-  */
+  //
+  // Unshear the space to put the luminance plane back...
+  //
 
   z_shear(hmat, -zsx, -zsy);
 
- /*
-  * Rotate the grey vector back into place...
-  */
+  //
+  // Rotate the grey vector back into place...
+  //
 
   y_rotate(hmat, -yrs, yrc);
   x_rotate(hmat, -xrs, xrc);
 
- /*
-  * Append it to the current matrix...
-  */
+  //
+  // Append it to the current matrix...
+  //
 
   mult(hmat, mat, mat);
 }
 
 
-/
- * 'ident()' - Make an identity matrix.
- */
+//
+// 'ident()' - Make an identity matrix.
+//
 
 static void
-ident(float mat[3][3])                 /* I - Matrix to identify */
+ident(float mat[3][3])                 // I - Matrix to identify
 {
   mat[0][0] = 1.0;
   mat[0][1] = 0.0;
@@ -1226,22 +1227,22 @@ ident(float mat[3][3])                  /* I - Matrix to identify */
 }
 
 
-/
- * 'mult()' - Multiply two matrices.
- */
+//
+// 'mult()' - Multiply two matrices.
+//
 
 static void
-mult(float a[3][3],                    /* I - First matrix */
-     float b[3][3],                    /* I - Second matrix */
-     float c[3][3])                    /* I - Destination matrix */
+mult(float a[3][3],                    // I - First matrix
+     float b[3][3],                    // I - Second matrix
+     float c[3][3])                    // I - Destination matrix
 {
-  int  x, y;                           /* Looping vars */
-  float        temp[3][3];                     /* Temporary matrix */
+  int  x, y;                           // Looping vars
+  float        temp[3][3];                     // Temporary matrix
 
 
- /*
-  * Multiply a and b, putting the result in temp...
-  */
+  //
+  // Multiply a and b, putting the result in temp...
+  //
 
   for (y = 0; y < 3; y ++)
     for (x = 0; x < 3; x ++)
@@ -1249,52 +1250,52 @@ mult(float a[3][3],                     /* I - First matrix */
                    b[y][1] * a[1][x] +
                    b[y][2] * a[2][x];
 
- /*
-  * Copy temp to c (that way c can be a pointer to a or b).
-  */
+  //
+  // Copy temp to c (that way c can be a pointer to a or b).
+  //
 
   memcpy(c, temp, sizeof(temp));
 }
 
 
-/*
- * 'rgb_to_lab()' - Convert an RGB color to CIE Lab.
- */
+//
+// 'rgb_to_lab()' - Convert an RGB color to CIE Lab.
+//
 
 static void
-rgb_to_lab(cf_ib_t *val)               /* IO - Color value */
+rgb_to_lab(cf_ib_t *val)               // IO - Color value
 {
-  float        r,                              /* Red value */
-       g,                              /* Green value */
-       b,                              /* Blue value */
-       ciex,                           /* CIE X value */
-       ciey,                           /* CIE Y value */
-       ciez,                           /* CIE Z value */
-       ciey_yn,                        /* Normalized luminance */
-       ciel,                           /* CIE L value */
-       ciea,                           /* CIE a value */
-       cieb;                           /* CIE b value */
-
-
- /*
-  * Convert sRGB to linear RGB...
-  */
+  float        r,                              // Red value
+       g,                              // Green value
+       b,                              // Blue value
+       ciex,                           // CIE X value
+       ciey,                           // CIE Y value
+       ciez,                           // CIE Z value
+       ciey_yn,                        // Normalized luminance
+       ciel,                           // CIE L value
+       ciea,                           // CIE a value
+       cieb;                           // CIE b value
+
+
+  //
+  // Convert sRGB to linear RGB...
+  //
 
   r = pow((val[0] / 255.0 + 0.055) / 1.055, 2.4);
   g = pow((val[1] / 255.0 + 0.055) / 1.055, 2.4);
   b = pow((val[2] / 255.0 + 0.055) / 1.055, 2.4);
 
- /*
-  * Convert to CIE XYZ...
-  */
+  //
+  // Convert to CIE XYZ...
+  //
 
   ciex = 0.412453 * r + 0.357580 * g + 0.180423 * b; 
   ciey = 0.212671 * r + 0.715160 * g + 0.072169 * b;
   ciez = 0.019334 * r + 0.119193 * g + 0.950227 * b;
 
- /*
-  * Normalize and convert to CIE Lab...
-  */
+  //
+  // Normalize and convert to CIE Lab...
+  //
 
   ciey_yn = ciey / D65_Y;
 
@@ -1303,22 +1304,22 @@ rgb_to_lab(cf_ib_t *val)                /* IO - Color value */
   else
     ciel = 903.3 * ciey_yn;
 
-/*ciel = ciel;*/
+  //ciel = ciel;
   ciea = 500 * (cie_lab(ciex, D65_X) - cie_lab(ciey, D65_Y));
   cieb = 200 * (cie_lab(ciey, D65_Y) - cie_lab(ciez, D65_Z));
 
- /*
-  * Scale the L value and bias the a and b values by 128 so that all
-  * numbers are from 0 to 255.
-  */
+  //
+  // Scale the L value and bias the a and b values by 128 so that all
+  // numbers are from 0 to 255.
+  //
 
   ciel = ciel * 2.55 + 0.5;
   ciea += 128.5;
   cieb += 128.5;
 
- /*
-  * Output 8-bit values...
-  */
+  //
+  // Output 8-bit values...
+  //
 
   if (ciel < 0.0)
     val[0] = 0;
@@ -1343,40 +1344,40 @@ rgb_to_lab(cf_ib_t *val)                /* IO - Color value */
 }
 
 
-/*
- * 'rgb_to_xyz()' - Convert an RGB color to CIE XYZ.
- */
+//
+// 'rgb_to_xyz()' - Convert an RGB color to CIE XYZ.
+//
 
 static void
-rgb_to_xyz(cf_ib_t *val)               /* IO - Color value */
+rgb_to_xyz(cf_ib_t *val)               // IO - Color value
 {
-  float        r,                              /* Red value */
-       g,                              /* Green value */
-       b,                              /* Blue value */
-       ciex,                           /* CIE X value */
-       ciey,                           /* CIE Y value */
-       ciez;                           /* CIE Z value */
+  float        r,                              // Red value
+       g,                              // Green value
+       b,                              // Blue value
+       ciex,                           // CIE X value
+       ciey,                           // CIE Y value
+       ciez;                           // CIE Z value
 
 
- /*
-  * Convert sRGB to linear RGB...
-  */
+  //
+  // Convert sRGB to linear RGB...
+  //
 
   r = pow((val[0] / 255.0 + 0.055) / 1.055, 2.4);
   g = pow((val[1] / 255.0 + 0.055) / 1.055, 2.4);
   b = pow((val[2] / 255.0 + 0.055) / 1.055, 2.4);
 
- /*
-  * Convert to CIE XYZ...
-  */
+  //
+  // Convert to CIE XYZ...
+  //
 
   ciex = 0.412453 * r + 0.357580 * g + 0.180423 * b; 
   ciey = 0.212671 * r + 0.715160 * g + 0.072169 * b;
   ciez = 0.019334 * r + 0.119193 * g + 0.950227 * b;
 
- /*
-  * Encode as 8-bit XYZ...
-  */
+  //
+  // Encode as 8-bit XYZ...
+  //
 
   if (ciex < 0.0f)
     val[0] = 0;
@@ -1401,15 +1402,15 @@ rgb_to_xyz(cf_ib_t *val)                /* IO - Color value */
 }
 
 
-/
- * 'saturate()' - Make a saturation matrix.
- */
+//
+// 'saturate()' - Make a saturation matrix.
+//
 
 static void
-saturate(float mat[3][3],              /* I - Matrix to append to */
-         float sat)                    /* I - Desired color saturation */
+saturate(float mat[3][3],              // I - Matrix to append to
+         float sat)                    // I - Desired color saturation
 {
-  float        smat[3][3];                     /* Saturation matrix */
+  float        smat[3][3];                     // Saturation matrix
 
 
   smat[0][0] = (1.0 - sat) * 0.3086 + sat;
@@ -1426,18 +1427,18 @@ saturate(float mat[3][3],               /* I - Matrix to append to */
 }
 
 
-/* 
- * 'x_form()' - Transform a 3D point using a matrix...
- */
+// 
+// 'x_form()' - Transform a 3D point using a matrix...
+//
 
 static void
-x_form(float mat[3][3],                        /* I - Matrix */
-      float x,                         /* I - Input X coordinate */
-      float y,                         /* I - Input Y coordinate */
-      float z,                         /* I - Input Z coordinate */
-      float *tx,                       /* O - Output X coordinate */
-      float *ty,                       /* O - Output Y coordinate */
-      float *tz)                       /* O - Output Z coordinate */
+x_form(float mat[3][3],                        // I - Matrix
+       float x,                                // I - Input X coordinate
+       float y,                                // I - Input Y coordinate
+       float z,                                // I - Input Z coordinate
+       float *tx,                      // O - Output X coordinate
+       float *ty,                      // O - Output Y coordinate
+       float *tz)                      // O - Output Z coordinate
 {
   *tx = x * mat[0][0] + y * mat[1][0] + z * mat[2][0];
   *ty = x * mat[0][1] + y * mat[1][1] + z * mat[2][1];
@@ -1445,16 +1446,16 @@ x_form(float mat[3][3],                 /* I - Matrix */
 }
 
 
-/* 
- * 'x_rotate()' - Rotate about the x (red) axis...
- */
+// 
+// 'x_rotate()' - Rotate about the x (red) axis...
+//
 
 static void
-x_rotate(float mat[3][3],              /* I - Matrix */
-        float rs,                      /* I - Rotation angle sine */
-        float rc)                      /* I - Rotation angle cosine */
+x_rotate(float mat[3][3],              // I - Matrix
+        float rs,                      // I - Rotation angle sine
+        float rc)                      // I - Rotation angle cosine
 {
-  float rmat[3][3];                    /* I - Rotation matrix */
+  float rmat[3][3];                    // I - Rotation matrix
 
 
   rmat[0][0] = 1.0;
@@ -1473,16 +1474,16 @@ x_rotate(float mat[3][3],               /* I - Matrix */
 }
 
 
-/* 
- * 'y_rotate()' - Rotate about the y (green) axis...
- */
+// 
+// 'y_rotate()' - Rotate about the y (green) axis...
+//
 
 static void
-y_rotate(float mat[3][3],              /* I - Matrix */
-        float rs,                      /* I - Rotation angle sine */
-        float rc)                      /* I - Rotation angle cosine */
+y_rotate(float mat[3][3],              // I - Matrix
+        float rs,                      // I - Rotation angle sine
+        float rc)                      // I - Rotation angle cosine
 {
-  float rmat[3][3];                    /* I - Rotation matrix */
+  float rmat[3][3];                    // I - Rotation matrix
 
 
   rmat[0][0] = rc;
@@ -1497,20 +1498,20 @@ y_rotate(float mat[3][3],               /* I - Matrix */
   rmat[2][1] = 0.0;
   rmat[2][2] = rc;
 
-  mult(rmat,mat,mat);
+  mult(rmat, mat, mat);
 }
 
 
-/* 
- * 'z_rotate()' - Rotate about the z (blue) axis...
- */
+// 
+// 'z_rotate()' - Rotate about the z (blue) axis...
+//
 
 static void
-z_rotate(float mat[3][3],              /* I - Matrix */
-        float rs,                      /* I - Rotation angle sine */
-        float rc)                      /* I - Rotation angle cosine */
+z_rotate(float mat[3][3],              // I - Matrix
+        float rs,                      // I - Rotation angle sine
+        float rc)                      // I - Rotation angle cosine
 {
-  float rmat[3][3];                    /* I - Rotation matrix */
+  float rmat[3][3];                    // I - Rotation matrix
 
 
   rmat[0][0] = rc;
@@ -1525,20 +1526,20 @@ z_rotate(float mat[3][3],               /* I - Matrix */
   rmat[2][1] = 0.0;
   rmat[2][2] = 1.0;
 
-  mult(rmat,mat,mat);
+  mult(rmat, mat, mat);
 }
 
 
-/* 
- * 'z_shear()' - Shear z using x and y...
- */
+// 
+// 'z_shear()' - Shear z using x and y...
+//
 
 static void
-z_shear(float mat[3][3],                       /* I - Matrix */
-       float dx,                       /* I - X shear */
-       float dy)                       /* I - Y shear */
+z_shear(float mat[3][3],               // I - Matrix
+       float dx,                       // I - X shear
+       float dy)                       // I - Y shear
 {
-  float smat[3][3];                    /* Shear matrix */
+  float smat[3][3];                    // Shear matrix
 
 
   smat[0][0] = 1.0;
@@ -1555,4 +1556,3 @@ z_shear(float mat[3][3],                  /* I - Matrix */
 
   mult(smat, mat, mat);
 }
-
index 8979c58ed66fb48b23e84b8dfb12eac661ee5947..fb5ad39456bd4ad757895df3dd3ab89c772cbd83 100644 (file)
@@ -1,52 +1,53 @@
-/*
- *   JPEG image routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadJPEG() - Read a JPEG image file.
- */
-
-/*
- * Include necessary headers...
- */
+//
+//   JPEG image routines for CUPS.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1993-2007 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 "COPYING"
+//   which should have been included with this file.
+//
+// Contents:
+//
+//   _cfImageReadJPEG() - Read a JPEG image file.
+//
+
+//
+// Include necessary headers...
+//
 
 #include "image-private.h"
 
 #ifdef HAVE_LIBJPEG
-#  include <jpeglib.h> /* JPEG/JFIF image definitions */
+#  include <jpeglib.h> // JPEG/JFIF image definitions
 
-#define JPEG_APP0 0xE0 /* APP0 marker code */
+#define JPEG_APP0 0xE0 // APP0 marker code
 
-/*
- * '_cfImageReadJPEG()' - Read a JPEG image file.
- */
+//
+// '_cfImageReadJPEG()' - Read a JPEG image file.
+//
 
-int                                    /* O  - Read status */
+int                                    // O  - Read status
 _cfImageReadJPEG(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I  - Image file */
-    cf_icspace_t  primary,             /* I  - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I  - Secondary choice for colorspace */
-    int             saturation,                /* I  - Color saturation (%) */
-    int             hue,               /* I  - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I  - Lookup table for gamma/brightness */
+    cf_image_t      *img,              // IO - Image
+    FILE            *fp,               // I  - Image file
+    cf_icspace_t    primary,           // I  - Primary choice for colorspace
+    cf_icspace_t    secondary,         // I  - Secondary choice for colorspace
+    int             saturation,                // I  - Color saturation (%)
+    int             hue,               // I  - Color hue (degrees)
+    const cf_ib_t   *lut)              // I  - Lookup table for
+                                        //      gamma/brightness
 {
-  struct jpeg_decompress_struct        cinfo;  /* Decompressor info */
-  struct jpeg_error_mgr        jerr;           /* Error handler info */
-  cf_ib_t              *in,            /* Input pixels */
-                       *out;           /* Output pixels */
-  jpeg_saved_marker_ptr        marker;         /* Pointer to marker data */
-  int                  psjpeg = 0;     /* Non-zero if Photoshop CMYK JPEG */
+  struct jpeg_decompress_struct        cinfo;  // Decompressor info
+  struct jpeg_error_mgr        jerr;           // Error handler info
+  cf_ib_t              *in,            // Input pixels
+                       *out;           // Output pixels
+  jpeg_saved_marker_ptr        marker;         // Pointer to marker data
+  int                  psjpeg = 0;     // Non-zero if Photoshop CMYK JPEG
   static const char    *cspaces[] =
-                       {               /* JPEG colorspaces... */
+                       {               // JPEG colorspaces...
                          "JCS_UNKNOWN",
                          "JCS_GRAYSCALE",
                          "JCS_RGB",
@@ -57,21 +58,21 @@ _cfImageReadJPEG(
 
   (void)cspaces;
 
- /*
-  * Read the JPEG header...
-  */
+  //
+  // Read the JPEG header...
+  //
 
   cinfo.err = jpeg_std_error(&jerr);
   jpeg_create_decompress(&cinfo);
-  jpeg_save_markers(&cinfo, JPEG_APP0 + 14, 0xffff); /* Adobe JPEG */
+  jpeg_save_markers(&cinfo, JPEG_APP0 + 14, 0xffff); // Adobe JPEG
   jpeg_stdio_src(&cinfo, fp);
   jpeg_read_header(&cinfo, 1);
 
- /*
-  * Parse any Adobe APPE data embedded in the JPEG file.  Since Adobe doesn't
-  * bother following standards, we have to invert the CMYK JPEG data written by
-  * Adobe apps...
-  */
+  //
+  // Parse any Adobe APPE data embedded in the JPEG file.  Since Adobe doesn't
+  // bother following standards, we have to invert the CMYK JPEG data written by
+  // Adobe apps...
+  //
 
   for (marker = cinfo.marker_list; marker; marker = marker->next)
     if (marker->marker == (JPEG_APP0 + 14) && marker->data_length >= 12 &&
@@ -138,15 +139,16 @@ _cfImageReadJPEG(
   int temp = -1;
 
 #ifdef HAVE_EXIF
-   /*
-    scan image file for exif data
-    */
+  //
+  // Scan image file for exif data
+  //
 
   temp = _cfImageReadEXIF(img, fp);
 #endif
-  /* 
-    check headers only if EXIF contains no info about ppi
-    */
+
+  //
+  // Check headers only if EXIF contains no info about ppi
+  //
 
   if (temp != 1 && cinfo.X_density > 0 && cinfo.Y_density > 0 && cinfo.density_unit > 0)
   {
@@ -186,12 +188,12 @@ _cfImageReadJPEG(
 
     if (psjpeg && cinfo.output_components == 4)
     {
-     /*
-      * Invert CMYK data from Photoshop...
-      */
+     //
+     // Invert CMYK data from Photoshop...
+     
 
-      cf_ib_t  *ptr;   /* Pointer into buffer */
-      int      i;      /* Looping var */
+      cf_ib_t  *ptr;   // Pointer into buffer
+      int      i;      // Looping var
 
 
       for (ptr = in, i = img->xsize * 4; i > 0; i --, ptr ++)
@@ -221,7 +223,7 @@ _cfImageReadJPEG(
       }
 
       DEBUG_puts("\n");
-#endif /* DEBUG */
+#endif // DEBUG
 
       if (lut)
         cfImageLut(in, img->xsize * cfImageGetDepth(img), lut);
@@ -283,7 +285,7 @@ _cfImageReadJPEG(
 
       _cfImagePutRow(img, 0, cinfo.output_scanline - 1, img->xsize, out);
     }
-    else /* JCS_CMYK */
+    else // JCS_CMYK
     {
       DEBUG_puts("DEBUG: JCS_CMYK\n");
 
@@ -323,5 +325,4 @@ _cfImageReadJPEG(
 
   return (0);
 }
-#endif /* HAVE_LIBJPEG */
-
+#endif // HAVE_LIBJPEG
index b96dc16462181f91ea44c99c64504d26b1a42e4e..b0e510b48adb0d54f98a404473b44e89b619ec33 100644 (file)
@@ -1,80 +1,80 @@
-/*
- *   PNG image routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadPNG() - Read a PNG image file.
- */
-
-/*
- * Include necessary headers...
- */
+//
+//   PNG image routines for CUPS.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1993-2007 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 "COPYING"
+//   which should have been included with this file.
+//
+// Contents:
+//
+//   _cfImageReadPNG() - Read a PNG image file.
+//
+
+//
+// Include necessary headers...
+//
 
 #include "image-private.h"
 
 #if defined(HAVE_LIBPNG) && defined(HAVE_LIBZ)
-#  include <png.h>     /* Portable Network Graphics (PNG) definitions */
+#  include <png.h>     // Portable Network Graphics (PNG) definitions
 
 
-/*
- * '_cfImageReadPNG()' - Read a PNG image file.
- */
+//
+// '_cfImageReadPNG()' - Read a PNG image file.
+//
 
-int                                    /* O - Read status */
+int                                    // O - Read status
 _cfImageReadPNG(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
+    cf_image_t      *img,              // IO - Image
+    FILE            *fp,               // I - Image file
+    cf_icspace_t    primary,           // I - Primary choice for colorspace
+    cf_icspace_t    secondary,         // I - Secondary choice for colorspace
+    int             saturation,                // I - Color saturation (%)
+    int             hue,               // I - Color hue (degrees)
+    const cf_ib_t   *lut)              // I - Lookup table for gamma/brightness
 {
-  int          y;                      /* Looping var */
-  png_structp  pp;                     /* PNG read pointer */
-  png_infop    info;                   /* PNG info pointers */
-  png_uint_32  width,                  /* Width of image */
-               height;                 /* Height of image */
-  int          bit_depth,              /* Bit depth */
-               color_type,             /* Color type */
-               interlace_type,         /* Interlace type */
-               compression_type,       /* Compression type */
-               filter_type;            /* Filter type */
-  png_uint_32  xppm,                   /* X pixels per meter */
-               yppm;                   /* Y pixels per meter */
-  int          bpp;                    /* Bytes per pixel */
-  int          pass,                   /* Current pass */
-               passes;                 /* Number of passes required */
-  cf_ib_t      *in,                    /* Input pixels */
-               *inptr,                 /* Pointer into pixels */
-               *out;                   /* Output pixels */
-  png_color_16 bg;                     /* Background color */
-
-
- /*
-  * Setup the PNG data structures...
-  */
+  int          y;                      // Looping var
+  png_structp  pp;                     // PNG read pointer
+  png_infop    info;                   // PNG info pointers
+  png_uint_32  width,                  // Width of image
+               height;                 // Height of image
+  int          bit_depth,              // Bit depth
+               color_type,             // Color type
+               interlace_type,         // Interlace type
+               compression_type,       // Compression type
+               filter_type;            // Filter type
+  png_uint_32  xppm,                   // X pixels per meter
+               yppm;                   // Y pixels per meter
+  int          bpp;                    // Bytes per pixel
+  int          pass,                   // Current pass
+               passes;                 // Number of passes required
+  cf_ib_t      *in,                    // Input pixels
+               *inptr,                 // Pointer into pixels
+               *out;                   // Output pixels
+  png_color_16 bg;                     // Background color
+
+
+  //
+  // Setup the PNG data structures...
+  //
 
   pp   = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
   info = png_create_info_struct(pp);
 
- /*
-  * Initialize the PNG read "engine"...
-  */
+  //
+  // Initialize the PNG read "engine"...
+  //
 
   png_init_io(pp, fp);
 
- /*
-  * Get the image dimensions and load the output image...
-  */
+  //
+  // Get the image dimensions and load the output image...
+  //
 
   png_read_info(pp, info);
 
@@ -119,15 +119,16 @@ _cfImageReadPNG(
   int temp = -1;
 
 #ifdef HAVE_EXIF
-   /*
-    scan image file for exif data
-    */
+  //
+  // Scan image file for EXIF data
+  //
 
   temp = _cfImageReadEXIF(img, fp);
 #endif
-  /* 
-    check headers only if EXIF contains no info about ppi
-    */
+
+  //
+  // Check headers only if EXIF contains no info about ppi
+  //
 
   if (temp != 1 && (xppm = png_get_x_pixels_per_meter(pp, info)) != 0 &&
       (yppm = png_get_y_pixels_per_meter(pp, info)) != 0)
@@ -148,9 +149,9 @@ _cfImageReadPNG(
 
   passes = png_set_interlace_handling(pp);
 
- /*
-  * Handle transparency...
-  */
+  //
+  // Handle transparency...
+  //
 
   if (png_get_valid(pp, info, PNG_INFO_tRNS))
     png_set_tRNS_to_alpha(pp);
@@ -163,9 +164,9 @@ _cfImageReadPNG(
 
   if (passes == 1)
   {
-   /*
-    * Load one row at a time...
-    */
+    //
+    // Load one row at a time...
+    //
 
     if (color_type == PNG_COLOR_TYPE_GRAY ||
        color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
@@ -175,11 +176,11 @@ _cfImageReadPNG(
   }
   else
   {
-   /*
-    * Interlaced images must be loaded all at once...
-    */
+    //
+    // Interlaced images must be loaded all at once...
+    //
 
-    size_t bufsize;                    /* Size of buffer */
+    size_t bufsize;                    // Size of buffer
 
 
     if (color_type == PNG_COLOR_TYPE_GRAY ||
@@ -229,9 +230,9 @@ _cfImageReadPNG(
     return (1);
   }
 
- /*
-  * Read the image, interlacing as needed...
-  */
+  //
+  // Read the image, interlacing as needed...
+  //
 
   for (pass = 1; pass <= passes; pass ++)
     for (inptr = in, y = 0; y < img->ysize; y ++)
@@ -240,9 +241,9 @@ _cfImageReadPNG(
 
       if (pass == passes)
       {
-       /*
-        * Output this row...
-       */
+       //
+       // Output this row...
+       //
 
        if (color_type & PNG_COLOR_MASK_COLOR)
        {
@@ -316,5 +317,4 @@ _cfImageReadPNG(
 
   return (0);
 }
-#endif /* HAVE_LIBPNG && HAVE_LIBZ */
-
+#endif // HAVE_LIBPNG && HAVE_LIBZ
index ce99afb60015ac1132257c833929ce802366e877..767f2da5fd56ac30179d4a6612e48b1bd95d194f 100644 (file)
@@ -1,21 +1,23 @@
-/*
- *   Private image library definitions for CUPS Filters.
- *
- *   Copyright 2007-2010 by Apple Inc.
- *   Copyright 1993-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 "COPYING"
- *   which should have been included with this file.
- */
+//
+//   Private image library definitions for libcupsfilters.
+//
+//   Copyright 2007-2010 by Apple Inc.
+//   Copyright 1993-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 "COPYING"
+//   which should have been included with this file.
+//
+
 
 #ifndef _CUPS_IMAGE_PRIVATE_H_
 #  define _CUPS_IMAGE_PRIVATE_H_
 
-/*
- * Include necessary headers...
- */
+
+//
+// Include necessary headers...
+//
 
 #  include <config.h>
 #  include "image.h"
@@ -29,7 +31,7 @@
 #    include <io.h>
 #  else
 #    include <unistd.h>
-#  endif /* WIN32 */
+#  endif // WIN32
 #  include <errno.h>
 #  include <math.h>    
 
 #      include <libexif/exif-data.h>
 #endif
 
-/*
- * Constants...
- */
+
+//
+// Constants...
+//
 
 #  define CF_IMAGE_MAX_WIDTH   0x07ffffff
-                                       /* 2^27-1 to allow for 15-channel data */
+                                       // 2^27-1 to allow for 15-channel data
 #  define CF_IMAGE_MAX_HEIGHT  0x3fffffff
-                                       /* 2^30-1 */
+                                       // 2^30-1
 
-#  define CF_TILE_SIZE         256     /* 256x256 pixel tiles */
-#  define CF_TILE_MINIMUM      10      /* Minimum number of tiles */
+#  define CF_TILE_SIZE         256     // 256x256 pixel tiles
+#  define CF_TILE_MINIMUM      10      // Minimum number of tiles
 
 
-/*
- * min/max/abs macros...
- */
+//
+// min/max/abs macros...
+//
 
 #  ifndef max
 #    define    max(a,b)        ((a) > (b) ? (a) : (b))
-#  endif /* !max */
+#  endif // !max
 #  ifndef min
 #    define    min(a,b)        ((a) < (b) ? (a) : (b))
-#  endif /* !min */
+#  endif // !min
 #  ifndef abs
 #    define    abs(a)          ((a) < 0 ? -(a) : (a))
-#  endif /* !abs */
+#  endif // !abs
 
 
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
 
-typedef enum cf_iztype_e               /**** Image zoom type ****/
+typedef enum cf_iztype_e               // **** Image zoom type ****
 {
-  CF_IZOOM_FAST,                       /* Use nearest-neighbor sampling */
-  CF_IZOOM_NORMAL,                     /* Use bilinear interpolation */
-  CF_IZOOM_BEST                                /* Use bicubic interpolation */
+  CF_IZOOM_FAST,                       // Use nearest-neighbor sampling
+  CF_IZOOM_NORMAL,                     // Use bilinear interpolation
+  CF_IZOOM_BEST                                // Use bicubic interpolation
 } cf_iztype_t;
 
 struct cf_ic_s;
 
-typedef struct cf_itile_s              /**** Image tile ****/
+typedef struct cf_itile_s              // **** Image tile ****
 {
-  int                  dirty;          /* True if tile is dirty */
-  off_t                        pos;            /* Position of tile on disk (-1 if not
-                                          written) */
-  struct cf_ic_s       *ic;            /* Pixel data */
+  int                  dirty;          // True if tile is dirty
+  off_t                        pos;            // Position of tile on disk (-1 if not
+                                       // written)
+  struct cf_ic_s       *ic;            // Pixel data
 } cf_itile_t;
 
-typedef struct cf_ic_s         /**** Image tile cache ****/
+typedef struct cf_ic_s                 // **** Image tile cache ****
 {
-  struct cf_ic_s       *prev,          /* Previous tile in cache */
-                       *next;          /* Next tile in cache */
-  cf_itile_t           *tile;          /* Tile this is attached to */
-  cf_ib_t              *pixels;        /* Pixel data */
+  struct cf_ic_s       *prev,          // Previous tile in cache
+                       *next;          // Next tile in cache
+  cf_itile_t           *tile;          // Tile this is attached to
+  cf_ib_t              *pixels;        // Pixel data
 } cf_ic_t;
 
-struct cf_image_s                      /**** Image file data ****/
+struct cf_image_s                      // **** Image file data ****
 {
-  cf_icspace_t         colorspace;     /* Colorspace of image */
-  unsigned             xsize,          /* Width of image in pixels */
-                       ysize,          /* Height of image in pixels */
-                       xppi,           /* X resolution in pixels-per-inch */
-                       yppi,           /* Y resolution in pixels-per-inch */
-                       num_ics,        /* Number of cached tiles */
-                       max_ics;        /* Maximum number of cached tiles */
-  cf_itile_t           **tiles;        /* Tiles in image */
-  cf_ic_t              *first,         /* First cached tile in image */
-                       *last;          /* Last cached tile in image */
-  int                  cachefile;      /* Tile cache file */
-  char                 cachename[256]; /* Tile cache filename */
+  cf_icspace_t         colorspace;     // Colorspace of image
+  unsigned             xsize,          // Width of image in pixels
+                       ysize,          // Height of image in pixels
+                       xppi,           // X resolution in pixels-per-inch
+                       yppi,           // Y resolution in pixels-per-inch
+                       num_ics,        // Number of cached tiles
+                       max_ics;        // Maximum number of cached tiles
+  cf_itile_t           **tiles;        // Tiles in image
+  cf_ic_t              *first,         // First cached tile in image
+                       *last;          // Last cached tile in image
+  int                  cachefile;      // Tile cache file
+  char                 cachename[256]; // Tile cache filename
 };
 
-struct cf_izoom_s                      /**** Image zoom data ****/
+struct cf_izoom_s                      // **** Image zoom data ****
 {
-  cf_image_t           *img;           /* Image to zoom */
-  cf_iztype_t          type;           /* Type of zooming */
-  unsigned             xorig,          /* X origin */
-                       yorig,          /* Y origin */
-                       width,          /* Width of input area */
-                       height,         /* Height of input area */
-                       depth,          /* Number of bytes per pixel */
-                       rotated,        /* Non-zero if image needs to be
-                                          rotated */
-                       xsize,          /* Width of output image */
-                       ysize,          /* Height of output image */
-                       xmax,           /* Maximum input image X position */
-                       ymax,           /* Maximum input image Y position */
-                       xmod,           /* Threshold for Bresenheim rounding */
-                       ymod;           /* ... */
-  int                  xstep,          /* Amount to step for each pixel along
-                                          X */
+  cf_image_t           *img;           // Image to zoom
+  cf_iztype_t          type;           // Type of zooming
+  unsigned             xorig,          // X origin
+                       yorig,          // Y origin
+                       width,          // Width of input area
+                       height,         // Height of input area
+                       depth,          // Number of bytes per pixel
+                       rotated,        // Non-zero if image needs to be
+                                       // rotated
+                       xsize,          // Width of output image
+                       ysize,          // Height of output image
+                       xmax,           // Maximum input image X position
+                       ymax,           // Maximum input image Y position
+                       xmod,           // Threshold for Bresenheim rounding
+                       ymod;           // ...
+  int                  xstep,          // Amount to step for each pixel along
+                                       // X
                        xincr,
-                       instep,         /* Amount to step pixel pointer along
-                                          X */
+                       instep,         // Amount to step pixel pointer along
+                                       // X
                        inincr,
-                       ystep,          /* Amount to step for each pixel along
-                                          Y */
+                       ystep,          // Amount to step for each pixel along
+                                       // Y
                        yincr,
-                       row;            /* Current row */
-  cf_ib_t              *rows[2],       /* Horizontally scaled pixel data */
-                       *in;            /* Unscaled input pixel data */
+                       row;            // Current row
+  cf_ib_t              *rows[2],       // Horizontally scaled pixel data
+                       *in;            // Unscaled input pixel data
 };
 
 
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
 
 extern int             _cfImagePutCol(cf_image_t *img, int x, int y,
                                       int height, const cf_ib_t *pixels);
@@ -173,8 +176,7 @@ extern cf_izoom_t   *_cfImageZoomNew(cf_image_t *img, int xc0, int yc0,
                                         cf_iztype_t type);
 
 #ifdef HAVE_EXIF
-int            _cfImageReadEXIF(cf_image_t *img, FILE *fp);
+extern int             _cfImageReadEXIF(cf_image_t *img, FILE *fp);
 #endif
 
-#endif /* !_CUPS_IMAGE_PRIVATE_H_ */
-
+#endif // !_CUPS_IMAGE_PRIVATE_H_
index a7e90709fb23d9ab0ebd4dd669d2a6155302ce7a..09ef87b3430255ee9b49784233bab85e50396d92 100644 (file)
@@ -1,88 +1,88 @@
-/*
- *   TIFF file routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadTIFF() - Read a TIFF image file.
- */
-
-/*
- * Include necessary headers...
- */
+//
+//   TIFF file routines for CUPS.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1993-2007 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 "COPYING"
+//   which should have been included with this file.
+//
+// Contents:
+//
+//   _cfImageReadTIFF() - Read a TIFF image file.
+//
+
+//
+// Include necessary headers...
+//
 
 #include "image-private.h"
 
 #ifdef HAVE_LIBTIFF
-#  include <tiff.h>    /* TIFF image definitions */
+#  include <tiff.h>    // TIFF image definitions
 #  include <tiffio.h>
 #  include <unistd.h>
 
 
-/*
- * '_cfImageReadTIFF()' - Read a TIFF image file.
- */
+//
+// '_cfImageReadTIFF()' - Read a TIFF image file.
+//
 
-int                                    /* O - Read status */
+int                                    // O - Read status
 _cfImageReadTIFF(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
+    cf_image_t      *img,              // IO - Image
+    FILE            *fp,               // I - Image file
+    cf_icspace_t    primary,           // I - Primary choice for colorspace
+    cf_icspace_t    secondary,         // I - Secondary choice for colorspace
+    int             saturation,                // I - Color saturation (%)
+    int             hue,               // I - Color hue (degrees)
+    const cf_ib_t   *lut)              // I - Lookup table for gamma/brightness
 {
-  TIFF         *tif;                   /* TIFF file */
-  uint32_t     width, height;          /* Size of image */
-  uint16_t     photometric,            /* Colorspace */
-               compression,            /* Type of compression */
-               orientation,            /* Orientation */
-               resunit,                /* Units for resolution */
-               samples,                /* Number of samples/pixel */
-               bits,                   /* Number of bits/pixel */
-               inkset,                 /* Ink set for color separations */
-               numinks;                /* Number of inks in set */
-  float                xres,                   /* Horizontal resolution */
-               yres;                   /* Vertical resolution */
-  uint16_t     *redcmap,               /* Red colormap information */
-               *greencmap,             /* Green colormap information */
-               *bluecmap;              /* Blue colormap information */
-  int          c,                      /* Color index */
-               num_colors,             /* Number of colors */
-               bpp,                    /* Bytes per pixel */
-               x, y,                   /* Current x & y */
-               row,                    /* Current row in image */
-               xstart, ystart,         /* Starting x & y */
-               xdir, ydir,             /* X & y direction */
-               xcount, ycount,         /* X & Y counters */
-               pstep,                  /* Pixel step (= bpp or -2 * bpp) */
-               scanwidth,              /* Width of scanline */
-               r, g, b, k,             /* Red, green, blue, and black values */
-               alpha;                  /* Image includes alpha? */
-  cf_ib_t              *in,                    /* Input buffer */
-               *out,                   /* Output buffer */
-               *p,                     /* Pointer into buffer */
-               *scanline,              /* Scanline buffer */
-               *scanptr,               /* Pointer into scanline buffer */
-               bit,                    /* Current bit */
-               pixel,                  /* Current pixel */
-               zero,                   /* Zero value (bitmaps) */
-               one;                    /* One value (bitmaps) */
-
-
- /*
-  * Open the TIFF file and get the required parameters...
-  */
-
-  lseek(fileno(fp), 0, SEEK_SET); /* Work around "feature" in some stdio's */
+  TIFF         *tif;                   // TIFF file
+  uint32_t     width, height;          // Size of image
+  uint16_t     photometric,            // Colorspace
+               compression,            // Type of compression
+               orientation,            // Orientation
+               resunit,                // Units for resolution
+               samples,                // Number of samples/pixel
+               bits,                   // Number of bits/pixel
+               inkset,                 // Ink set for color separations
+               numinks;                // Number of inks in set
+  float                xres,                   // Horizontal resolution
+               yres;                   // Vertical resolution
+  uint16_t     *redcmap,               // Red colormap information
+               *greencmap,             // Green colormap information
+               *bluecmap;              // Blue colormap information
+  int          c,                      // Color index
+               num_colors,             // Number of colors
+               bpp,                    // Bytes per pixel
+               x, y,                   // Current x & y
+               row,                    // Current row in image
+               xstart, ystart,         // Starting x & y
+               xdir, ydir,             // X & y direction
+               xcount, ycount,         // X & Y counters
+               pstep,                  // Pixel step (= bpp or -2 * bpp)
+               scanwidth,              // Width of scanline
+               r, g, b, k,             // Red, green, blue, and black values
+               alpha;                  // Image includes alpha?
+  cf_ib_t      *in,                    // Input buffer
+               *out,                   // Output buffer
+               *p,                     // Pointer into buffer
+               *scanline,              // Scanline buffer
+               *scanptr,               // Pointer into scanline buffer
+               bit,                    // Current bit
+               pixel,                  // Current pixel
+               zero,                   // Zero value (bitmaps)
+               one;                    // One value (bitmaps)
+
+
+  //
+  // Open the TIFF file and get the required parameters...
+  //
+
+  lseek(fileno(fp), 0, SEEK_SET); // Work around "feature" in some stdio's
 
   if ((tif = TIFFFdOpen(fileno(fp), "", "r")) == NULL)
   {
@@ -129,29 +129,30 @@ _cfImageReadTIFF(
   if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bits))
     bits = 1;
 
- /*
-  * Get the image orientation...
-  */
+  //
+  // Get the image orientation...
+  //
 
   if (!TIFFGetField(tif, TIFFTAG_ORIENTATION, &orientation))
     orientation = 0;
 
- /*
-  * Get the image resolution...
-  */
+  //
+  // Get the image resolution...
+  //
   
   int temp = -1;
 
 #ifdef HAVE_EXIF
-   /*
-    scan image file for exif data
-    */
+  //
+  // Scan image file for EXIF data
+  //
 
   temp = _cfImageReadEXIF(img, fp);
 #endif
-  /* 
-    check headers only if EXIF contains no info about ppi
-    */
+
+  //
+  // Check headers only if EXIF contains no info about ppi
+  //
 
   if (temp != 1 && TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) &&
       TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) &&
@@ -185,19 +186,18 @@ _cfImageReadTIFF(
                  img->xppi, img->yppi));
   }
 
-
- /*
-  * See if the image has an alpha channel...
-  */
+  //
+  // See if the image has an alpha channel...
+  //
 
   if (samples == 2 || (samples == 4 && photometric == PHOTOMETRIC_RGB))
     alpha = 1;
   else
     alpha = 0;
 
- /*
-  * Check the size of the image...
-  */
+  //
+  // Check the size of the image...
+  //
 
   if (width == 0 || width > CF_IMAGE_MAX_WIDTH ||
       height == 0 || height > CF_IMAGE_MAX_HEIGHT ||
@@ -212,9 +212,9 @@ _cfImageReadTIFF(
     return (1);
   }
 
- /*
-  * Setup the image size and colorspace...
-  */
+  //
+  // Setup the image size and colorspace...
+  //
 
   img->xsize = width;
   img->ysize = height;
@@ -234,9 +234,9 @@ _cfImageReadTIFF(
 
   cfImageSetMaxTiles(img, 0);
 
- /*
-  * Set the X & Y start and direction according to the image orientation...
-  */
+  //
+  // Set the X & Y start and direction according to the image orientation...
+  //
 
   switch (orientation)
   {
@@ -300,16 +300,16 @@ _cfImageReadTIFF(
         break;
   }
 
- /*
-  * Allocate a scanline buffer...
-  */
+  //
+  // Allocate a scanline buffer...
+  //
 
   scanwidth = TIFFScanlineSize(tif);
   scanline  = _TIFFmalloc(scanwidth);
 
- /*
-  * Allocate input and output buffers...
-  */
+  //
+  // Allocate input and output buffers...
+  //
 
   if (orientation < ORIENTATION_LEFTTOP)
   {
@@ -332,11 +332,11 @@ _cfImageReadTIFF(
     out = malloc(img->ysize * bpp);
   }
 
- /*
-  * Read the image.  This is greatly complicated by the fact that TIFF
-  * supports literally hundreds of different colorspaces and orientations,
-  * each which must be handled separately...
-  */
+  //
+  // Read the image.  This is greatly complicated by the fact that TIFF
+  // supports literally hundreds of different colorspaces and orientations,
+  // each which must be handled separately...
+  //
 
   DEBUG_printf(("DEBUG: photometric = %d\n", photometric));
   DEBUG_printf(("DEBUG: compression = %d\n", compression));
@@ -358,9 +358,9 @@ _cfImageReadTIFF(
 
         if (orientation < ORIENTATION_LEFTTOP)
         {
-         /*
-          * Row major order...
-          */
+         //
+         // Row major order...
+         //
 
           for (y = ystart, ycount = img->ysize, row = 0;
                ycount > 0;
@@ -509,9 +509,9 @@ _cfImageReadTIFF(
         }
         else
         {
-         /*
-          * Column major order...
-          */
+         //
+         // Column major order...
+         //
 
           for (x = xstart, xcount = img->xsize, row = 0;
                xcount > 0;
@@ -685,9 +685,9 @@ _cfImageReadTIFF(
 
         if (orientation < ORIENTATION_LEFTTOP)
         {
-         /*
-          * Row major order...
-          */
+         //
+         // Row major order...
+         //
 
           for (y = ystart, ycount = img->ysize, row = 0;
                ycount > 0;
@@ -818,9 +818,9 @@ _cfImageReadTIFF(
         }
         else
         {
-         /*
-          * Column major order...
-          */
+         //
+         // Column major order...
+         //
 
           for (x = xstart, xcount = img->xsize, row = 0;
                xcount > 0;
@@ -954,9 +954,9 @@ _cfImageReadTIFF(
     case PHOTOMETRIC_RGB :
         if (orientation < ORIENTATION_LEFTTOP)
         {
-         /*
-          * Row major order...
-          */
+         //
+         // Row major order...
+         //
 
           for (y = ystart, ycount = img->ysize, row = 0;
                ycount > 0;
@@ -1095,9 +1095,9 @@ _cfImageReadTIFF(
         }
         else
         {
-         /*
-          * Column major order...
-          */
+         //
+         // Column major order...
+         //
 
           for (x = xstart, xcount = img->xsize, row = 0;
                xcount > 0;
@@ -1245,7 +1245,7 @@ _cfImageReadTIFF(
            !TIFFGetField(tif, TIFFTAG_NUMBEROFINKS, &numinks))
 #else
         if (!TIFFGetField(tif, TIFFTAG_INKSET, &inkset))
-#endif /* TIFFTAG_NUMBEROFINKS */
+#endif // TIFFTAG_NUMBEROFINKS
        {
           DEBUG_puts("WARNING: No inkset or number-of-inks tag in the file!\n");
        }
@@ -1254,9 +1254,9 @@ _cfImageReadTIFF(
        {
           if (orientation < ORIENTATION_LEFTTOP)
           {
-           /*
-            * Row major order...
-            */
+           //
+           // Row major order...
+           //
 
             for (y = ystart, ycount = img->ysize, row = 0;
                 ycount > 0;
@@ -1476,9 +1476,9 @@ _cfImageReadTIFF(
           }
           else
           {
-           /*
-            * Column major order...
-            */
+           //
+           // Column major order...
+           //
 
             for (x = xstart, xcount = img->xsize, row = 0;
                 xcount > 0;
@@ -1710,9 +1710,9 @@ _cfImageReadTIFF(
        return (-1);
   }
 
- /*
-  * Free temporary buffers, close the TIFF file, and return.
-  */
+  //
+  // Free temporary buffers, close the TIFF file, and return.
+  //
 
   _TIFFfree(scanline);
   free(in);
@@ -1721,5 +1721,4 @@ _cfImageReadTIFF(
   TIFFClose(tif);
   return (0);
 }
-#endif /* HAVE_LIBTIFF */
-
+#endif // HAVE_LIBTIFF
index 325ca8d7040803f45c3270841aa45035538a3aad..b761f17a56d044a0956fa7cf9bb024337ab843ec 100644 (file)
@@ -1,46 +1,45 @@
-/*
- *   Image zoom routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageZoomDelete() - Free a zoom record...
- *   _cfImageZoomFill()   - Fill a zoom record...
- *   _cfImageZoomNew()    - Allocate a pixel zoom record...
- *   zoom_bilinear()        - Fill a zoom record with image data utilizing
- *                            bilinear interpolation.
- *   zoom_nearest()         - Fill a zoom record quickly using nearest-neighbor
- *                            sampling.
- */
-
-/*
- * Include necessary headers...
- */
+//
+//   Image zoom routines for libcupsfilters.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1993-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 "COPYING"
+//   which should have been included with this file.
+//
+// Contents:
+//
+//   _cfImageZoomDelete()   - Free a zoom record...
+//   _cfImageZoomFill()     - Fill a zoom record...
+//   _cfImageZoomNew()      - Allocate a pixel zoom record...
+//   zoom_bilinear()        - Fill a zoom record with image data utilizing
+//                            bilinear interpolation.
+//   zoom_nearest()         - Fill a zoom record quickly using nearest-neighbor
+//                            sampling.
+
+//
+// Include necessary headers...
+//
 
 #include "image-private.h"
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 static void    zoom_bilinear(cf_izoom_t *z, int iy);
 static void    zoom_nearest(cf_izoom_t *z, int iy);
 
 
-/*
- * '_cfImageZoomDelete()' - Free a zoom record...
- */
+//
+// '_cfImageZoomDelete()' - Free a zoom record...
+//
 
 void
-_cfImageZoomDelete(cf_izoom_t *z)      /* I - Zoom record to free */
+_cfImageZoomDelete(cf_izoom_t *z)      // I - Zoom record to free
 {
   free(z->rows[0]);
   free(z->rows[1]);
@@ -49,14 +48,14 @@ _cfImageZoomDelete(cf_izoom_t *z)   /* I - Zoom record to free */
 }
 
 
-/*
- * '_cfImageZoomFill()' - Fill a zoom record with image data utilizing bilinear
- *                         interpolation.
- */
+//
+// '_cfImageZoomFill()' - Fill a zoom record with image data utilizing bilinear
+//                        interpolation.
+//
 
 void
-_cfImageZoomFill(cf_izoom_t *z,        /* I - Zoom record to fill */
-                   int     iy)         /* I - Zoom image row */
+_cfImageZoomFill(cf_izoom_t *z,                // I - Zoom record to fill
+                int        iy)         // I - Zoom image row
 {
   switch (z->type)
   {
@@ -71,31 +70,32 @@ _cfImageZoomFill(cf_izoom_t *z,     /* I - Zoom record to fill */
 }
 
 
-/*
- * '_cfImageZoomNew()' - Allocate a pixel zoom record...
- */
+//
+// '_cfImageZoomNew()' - Allocate a pixel zoom record...
+//
 
 cf_izoom_t *
 _cfImageZoomNew(
-    cf_image_t  *img,                  /* I - Image to zoom */
-    int           xc0,                 /* I - Upper-lefthand corner */
-    int           yc0,                 /* I - ... */
-    int           xc1,                 /* I - Lower-righthand corner */
-    int           yc1,                 /* I - ... */
-    int           xsize,               /* I - Final width of image */
-    int           ysize,               /* I - Final height of image */
-    int           rotated,             /* I - Non-zero if image is rotated 90 degs */
-    cf_iztype_t type)                  /* I - Zoom type */
+    cf_image_t    *img,                        // I - Image to zoom
+    int           xc0,                 // I - Upper-lefthand corner
+    int           yc0,                 // I - ...
+    int           xc1,                 // I - Lower-righthand corner
+    int           yc1,                 // I - ...
+    int           xsize,               // I - Final width of image
+    int           ysize,               // I - Final height of image
+    int           rotated,             // I - Non-zero if image is rotated 90
+                                        //     degrees
+    cf_iztype_t type)                  // I - Zoom type
 {
-  cf_izoom_t   *z;                     /* New zoom record */
-  int          flip;                   /* Flip on X axis? */
+  cf_izoom_t   *z;                     // New zoom record
+  int          flip;                   // Flip on X axis?
 
 
   if (xsize > CF_IMAGE_MAX_WIDTH ||
       ysize > CF_IMAGE_MAX_HEIGHT ||
       (xc1 - xc0) > CF_IMAGE_MAX_WIDTH ||
       (yc1 - yc0) > CF_IMAGE_MAX_HEIGHT)
-    return (NULL);             /* Protect against integer overflow */
+    return (NULL);             // Protect against integer overflow
 
   if ((z = (cf_izoom_t *)calloc(1, sizeof(cf_izoom_t))) == NULL)
     return (NULL);
@@ -131,7 +131,7 @@ _cfImageZoomNew(
     z->ystep   = z->height / z->ysize;
     z->yincr   = 1;
     z->instep  = z->xstep * z->depth;
-    z->inincr  = /* z->xincr * */ z->depth; /* z->xincr is always 1 */
+    z->inincr  = /* z->xincr * */ z->depth; // z->xincr is always 1
 
     if (z->width < img->ysize)
       z->xmax = z->width;
@@ -158,7 +158,7 @@ _cfImageZoomNew(
     z->ystep   = z->height / z->ysize;
     z->yincr   = 1;
     z->instep  = z->xstep * z->depth;
-    z->inincr  = /* z->xincr * */ z->depth; /* z->xincr is always 1 */
+    z->inincr  = /* z->xincr * */ z->depth; // z->xincr is always 1
 
     if (z->width < img->xsize)
       z->xmax = z->width;
@@ -202,19 +202,19 @@ _cfImageZoomNew(
 }
 
 
-/*
- * 'zoom_bilinear()' - Fill a zoom record with image data utilizing bilinear
- *                     interpolation.
- */
+//
+// 'zoom_bilinear()' - Fill a zoom record with image data utilizing bilinear
+//                     interpolation.
+//
 
 static void
-zoom_bilinear(cf_izoom_t *z,           /* I - Zoom record to fill */
-              int          iy)         /* I - Zoom image row */
+zoom_bilinear(cf_izoom_t   *z,         // I - Zoom record to fill
+              int          iy)         // I - Zoom image row
 {
-  cf_ib_t      *r,                     /* Row pointer */
-               *inptr;                 /* Pixel pointer */
-  int          xerr0,                  /* X error counter */
-               xerr1;                  /* ... */
+  cf_ib_t      *r,                     // Row pointer
+               *inptr;                 // Pixel pointer
+  int          xerr0,                  // X error counter
+               xerr1;                  // ...
   int          ix,
                x,
                count,
@@ -283,18 +283,18 @@ zoom_bilinear(cf_izoom_t *z,              /* I - Zoom record to fill */
 }
 
 
-/*
- * 'zoom_nearest()' - Fill a zoom record quickly using nearest-neighbor
- *                    sampling.
- */
+//
+// 'zoom_nearest()' - Fill a zoom record quickly using nearest-neighbor
+//                    sampling.
+//
 
 static void
-zoom_nearest(cf_izoom_t *z,            /* I - Zoom record to fill */
-             int          iy)          /* I - Zoom image row */
+zoom_nearest(cf_izoom_t   *z,          // I - Zoom record to fill
+             int          iy)          // I - Zoom image row
 {
-  cf_ib_t      *r,                     /* Row pointer */
-               *inptr;                 /* Pixel pointer */
-  int          xerr0;                  /* X error counter */
+  cf_ib_t      *r,                     // Row pointer
+               *inptr;                 // Pixel pointer
+  int          xerr0;                  // X error counter
   int          ix,
                x,
                count,
@@ -349,4 +349,3 @@ zoom_nearest(cf_izoom_t *z,         /* I - Zoom record to fill */
     }
   }
 }
-
index 836309d1d135c89398f17706bc35952fdd2dfe07..ad1cad24c2ba99afa3c2952c8cbfd927993b847d 100644 (file)
@@ -1,68 +1,70 @@
-/*
- *   Base image support for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   cfImageClose()         - Close an image file.
- *   cfImageGetCol()        - Get a column of pixels from an image.
- *   cfImageGetColorSpace() - Get the image colorspace.
- *   cfImageGetDepth()      - Get the number of bytes per pixel.
- *   cfImageGetHeight()     - Get the height of an image.
- *   cfImageGetRow()        - Get a row of pixels from an image.
- *   cfImageGetWidth()      - Get the width of an image.
- *   cfImageGetXPPI()       - Get the horizontal resolution of an image.
- *   cfImageGetYPPI()       - Get the vertical resolution of an image.
- *   cfImageOpen()          - Open an image file and read it into memory.
- *   _cfImagePutCol()       - Put a column of pixels to an image.
- *   _cfImagePutRow()       - Put a row of pixels to an image.
- *   cfImageSetMaxTiles()   - Set the maximum number of tiles to cache.
- *   cfImageCrop()          - Crop an image.
- *   flush_tile()           - Flush the least-recently-used tile in the cache.
- *   get_tile()             - Get a cached tile.
- *   _cfImageReadEXIF()   - to read exif metadata of images
- *   trim_spaces()          - helper function to extract results from string returned by exif library functions
- *   find_bytes()           - creates character array from image file, to make use in exif library functions
- */
-
-/*
- * Include necessary headers...
- */
+//
+//   Base image support for libcupsfilters.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1993-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 "COPYING"
+//   which should have been included with this file.
+//
+// Contents:
+//
+//   cfImageClose()         - Close an image file.
+//   cfImageGetCol()        - Get a column of pixels from an image.
+//   cfImageGetColorSpace() - Get the image colorspace.
+//   cfImageGetDepth()      - Get the number of bytes per pixel.
+//   cfImageGetHeight()     - Get the height of an image.
+//   cfImageGetRow()        - Get a row of pixels from an image.
+//   cfImageGetWidth()      - Get the width of an image.
+//   cfImageGetXPPI()       - Get the horizontal resolution of an image.
+//   cfImageGetYPPI()       - Get the vertical resolution of an image.
+//   cfImageOpen()          - Open an image file and read it into memory.
+//   _cfImagePutCol()       - Put a column of pixels to an image.
+//   _cfImagePutRow()       - Put a row of pixels to an image.
+//   cfImageSetMaxTiles()   - Set the maximum number of tiles to cache.
+//   cfImageCrop()          - Crop an image.
+//   flush_tile()           - Flush the least-recently-used tile in the cache.
+//   get_tile()             - Get a cached tile.
+//   _cfImageReadEXIF()     - to read exif metadata of images
+//   trim_spaces()          - helper function to extract results from string 
+//                            returned by exif library functions
+//   find_bytes()           - creates character array from image file, to make
+//                            use in exif library functions
+
+
+//
+// Include necessary headers...
+//
 
 
 #include "image-private.h"
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 static int     flush_tile(cf_image_t *img);
 static cf_ib_t *get_tile(cf_image_t *img, int x, int y);
 static void trim_spaces(char *buf);
 static unsigned char *find_bytes(FILE *fp, long int *size);
 
-/*
- * 'cfImageClose()' - Close an image file.
- */
+//
+// 'cfImageClose()' - Close an image file.
+//
 
 void
-cfImageClose(cf_image_t *img)  /* I - Image to close */
+cfImageClose(cf_image_t *img)          // I - Image to close
 {
-  cf_ic_t      *current,               /* Current cached tile */
-               *next;                  /* Next cached tile */
+  cf_ic_t      *current,               // Current cached tile
+               *next;                  // Next cached tile
 
 
- /*
-  * Wipe the tile cache file (if any)...
-  */
+  //
+  // Wipe the tile cache file (if any)...
+  //
 
   if (img->cachefile >= 0)
   {
@@ -72,9 +74,9 @@ cfImageClose(cf_image_t *img) /* I - Image to close */
     unlink(img->cachename);
   }
 
- /*
-  * Free the image cache...
-  */
+  //
+  // Free the image cache...
+  //
 
   DEBUG_puts("Freeing memory...");
 
@@ -86,9 +88,9 @@ cfImageClose(cf_image_t *img) /* I - Image to close */
     free(current);
   }
 
- /*
-  * Free the rest of memory...
-  */
+  //
+  // Free the rest of memory...
+  //
 
   if (img->tiles != NULL)
   {
@@ -105,21 +107,21 @@ cfImageClose(cf_image_t *img)     /* I - Image to close */
 }
 
 
-/*
- * 'cfImageGetCol()' - Get a column of pixels from an image.
- */
+//
+// 'cfImageGetCol()' - Get a column of pixels from an image.
+//
 
-int                                    /* O - -1 on error, 0 on success */
-cfImageGetCol(cf_image_t *img, /* I - Image */
-               int          x,         /* I - Column */
-               int          y,         /* I - Start row */
-               int          height,    /* I - Column height */
-               cf_ib_t    *pixels)     /* O - Pixel data */
+int                                    // O - -1 on error, 0 on success
+cfImageGetCol(cf_image_t   *img,       // I - Image
+             int          x,           // I - Column
+             int          y,           // I - Start row
+             int          height,      // I - Column height
+             cf_ib_t      *pixels)     // O - Pixel data
 {
-  int                  bpp,            /* Bytes per pixel */
-                       twidth,         /* Tile width */
-                       count;          /* Number of pixels to get */
-  const cf_ib_t        *ib;            /* Pointer into tile */
+  int                  bpp,            // Bytes per pixel
+                       twidth,         // Tile width
+                       count;          // Number of pixels to get
+  const cf_ib_t                *ib;            // Pointer into tile
 
 
   if (img == NULL || x < 0 || x >= img->xsize || y >= img->ysize)
@@ -172,54 +174,54 @@ cfImageGetCol(cf_image_t *img,    /* I - Image */
 }
 
 
-/*
- * 'cfImageGetColorSpace()' - Get the image colorspace.
- */
+//
+// 'cfImageGetColorSpace()' - Get the image colorspace.
+//
 
-cf_icspace_t                           /* O - Colorspace */
+cf_icspace_t                           // O - Colorspace
 cfImageGetColorSpace(
-    cf_image_t *img)                   /* I - Image */
+    cf_image_t *img)                   // I - Image
 {
   return (img->colorspace);
 }
 
 
-/*
- * 'cfImageGetDepth()' - Get the number of bytes per pixel.
- */
+//
+// 'cfImageGetDepth()' - Get the number of bytes per pixel.
+//
 
-int                                    /* O - Bytes per pixel */
-cfImageGetDepth(cf_image_t *img)       /* I - Image */
+int                                    // O - Bytes per pixel
+cfImageGetDepth(cf_image_t *img)       // I - Image
 {
   return (abs(img->colorspace));
 }
 
 
-/*
- * 'cfImageGetHeight()' - Get the height of an image.
- */
+//
+// 'cfImageGetHeight()' - Get the height of an image.
+//
 
-unsigned                               /* O - Height in pixels */
-cfImageGetHeight(cf_image_t *img)      /* I - Image */
+unsigned                               // O - Height in pixels
+cfImageGetHeight(cf_image_t *img)      // I - Image
 {
   return (img->ysize);
 }
 
 
-/*
- * 'cfImageGetRow()' - Get a row of pixels from an image.
- */
+//
+// 'cfImageGetRow()' - Get a row of pixels from an image.
+//
 
-int                                    /* O - -1 on error, 0 on success */
-cfImageGetRow(cf_image_t *img, /* I - Image */
-                int          x,                /* I - Start column */
-                int          y,                /* I - Row */
-                int          width,    /* I - Width of row */
-                cf_ib_t    *pixels)    /* O - Pixel data */
+int                                    // O - -1 on error, 0 on success
+cfImageGetRow(cf_image_t   *img,       // I - Image
+             int          x,           // I - Start column
+             int          y,           // I - Row
+             int          width,       // I - Width of row
+             cf_ib_t      *pixels)     // O - Pixel data
 {
-  int                  bpp,            /* Bytes per pixel */
-                       count;          /* Number of pixels to get */
-  const cf_ib_t        *ib;            /* Pointer to pixels */
+  int                  bpp,            // Bytes per pixel
+                       count;          // Number of pixels to get
+  const cf_ib_t                *ib;            // Pointer to pixels
 
 
   if (img == NULL || y < 0 || y >= img->ysize || x >= img->xsize)
@@ -259,53 +261,54 @@ cfImageGetRow(cf_image_t *img,    /* I - Image */
 }
 
 
-/*
- * 'cfImageGetWidth()' - Get the width of an image.
- */
+//
+// 'cfImageGetWidth()' - Get the width of an image.
+//
 
-unsigned                               /* O - Width in pixels */
-cfImageGetWidth(cf_image_t *img)       /* I - Image */
+unsigned                               // O - Width in pixels
+cfImageGetWidth(cf_image_t *img)       // I - Image
 {
   return (img->xsize);
 }
 
 
-/*
- * 'cfImageGetXPPI()' - Get the horizontal resolution of an image.
- */
+//
+// 'cfImageGetXPPI()' - Get the horizontal resolution of an image.
+//
 
-unsigned                               /* O - Horizontal PPI */
-cfImageGetXPPI(cf_image_t *img)        /* I - Image */
+unsigned                               // O - Horizontal PPI
+cfImageGetXPPI(cf_image_t *img)                // I - Image
 {
   return (img->xppi);
 }
 
 
-/*
- * 'cfImageGetYPPI()' - Get the vertical resolution of an image.
- */
+//
+// 'cfImageGetYPPI()' - Get the vertical resolution of an image.
+//
 
-unsigned                               /* O - Vertical PPI */
-cfImageGetYPPI(cf_image_t *img)        /* I - Image */
+unsigned                               // O - Vertical PPI
+cfImageGetYPPI(cf_image_t *img)                // I - Image
 {
   return (img->yppi);
 }
 
 
-/*
- * 'cfImageOpen()' - Open an image file and read it into memory.
- */
+//
+// 'cfImageOpen()' - Open an image file and read it into memory.
+//
 
-cf_image_t *                           /* O - New image */
+cf_image_t *                           // O - New image
 cfImageOpen(
-    const char      *filename,         /* I - Filename of image */
-    cf_icspace_t  primary,             /* I - Primary colorspace needed */
-    cf_icspace_t  secondary,           /* I - Secondary colorspace if primary no good */
-    int             saturation,                /* I - Color saturation level */
-    int             hue,               /* I - Color hue adjustment */
-    const cf_ib_t *lut)                /* I - RGB gamma/brightness LUT */
+    const char      *filename,         // I - Filename of image
+    cf_icspace_t    primary,           // I - Primary colorspace needed
+    cf_icspace_t    secondary,         // I - Secondary colorspace if primary
+                                        //     no good
+    int             saturation,                // I - Color saturation level
+    int             hue,               // I - Color hue adjustment
+    const cf_ib_t   *lut)              // I - RGB gamma/brightness LUT
 {
-  FILE         *fp;                    /* File pointer */
+  FILE         *fp;                    // File pointer
 
   DEBUG_printf(("cfImageOpen(\"%s\", %d, %d, %d, %d, %p)\n",
                filename ? filename : "(null)", primary, secondary,
@@ -314,35 +317,36 @@ cfImageOpen(
   if ((fp = fopen(filename, "r")) == NULL)
     return (NULL);
 
-  return cfImageOpenFP(fp, primary, secondary, saturation, hue, lut);
+  return (cfImageOpenFP(fp, primary, secondary, saturation, hue, lut));
 }
 
 
-/*
- * 'cfImageOpenFP()' - Open an image file and read it into memory.
- */
+//
+// 'cfImageOpenFP()' - Open an image file and read it into memory.
+//
 
-cf_image_t *                           /* O - New image */
+cf_image_t *                           // O - New image
 cfImageOpenFP(
-    FILE            *fp,               /* I - File pointer of image */
-    cf_icspace_t  primary,             /* I - Primary colorspace needed */
-    cf_icspace_t  secondary,           /* I - Secondary colorspace if primary no good */
-    int             saturation,                /* I - Color saturation level */
-    int             hue,               /* I - Color hue adjustment */
-    const cf_ib_t *lut)                /* I - RGB gamma/brightness LUT */
+    FILE            *fp,               // I - File pointer of image
+    cf_icspace_t    primary,           // I - Primary colorspace needed
+    cf_icspace_t    secondary,         // I - Secondary colorspace if primary
+                                        //     no good
+    int             saturation,                // I - Color saturation level
+    int             hue,               // I - Color hue adjustment
+    const cf_ib_t   *lut)              // I - RGB gamma/brightness LUT
 {
-  unsigned char        header[16],             /* First 16 bytes of file */
-               header2[16];            /* Bytes 2048-2064 (PhotoCD) */
-  cf_image_t   *img;                   /* New image buffer */
-  int          status;                 /* Status of load... */
+  unsigned char        header[16],             // First 16 bytes of file
+               header2[16];            // Bytes 2048-2064 (PhotoCD)
+  cf_image_t   *img;                   // New image buffer
+  int          status;                 // Status of load...
 
 
   DEBUG_printf(("cfImageOpen2(%p, %d, %d, %d, %d, %p)\n",
                fp, primary, secondary, saturation, hue, lut));
 
- /*
-  * Figure out the file type...
-  */
+  //
+  // Figure out the file type...
+  //
 
   if (fp == NULL)
     return (NULL);
@@ -359,9 +363,9 @@ cfImageOpenFP(
     DEBUG_printf(("Error reading file!"));
   fseek(fp, 0, SEEK_SET);
 
- /*
-  * Allocate memory...
-  */
+  //
+  // Allocate memory...
+  //
 
   img = calloc(sizeof(cf_image_t), 1);
 
@@ -371,9 +375,9 @@ cfImageOpenFP(
     return (NULL);
   }
 
- /*
-  * Load the image as appropriate...
-  */
+  //
+  // Load the image as appropriate...
+  //
 
   img->cachefile = -1;
   img->max_ics   = CF_TILE_MINIMUM;
@@ -383,23 +387,23 @@ cfImageOpenFP(
 #if defined(HAVE_LIBPNG) && defined(HAVE_LIBZ)
   if (!memcmp(header, "\211PNG", 4))
     status = _cfImageReadPNG(img, fp, primary, secondary, saturation, hue,
-                               lut);
+                            lut);
   else
-#endif /* HAVE_LIBPNG && HAVE_LIBZ */
+#endif // HAVE_LIBPNG && HAVE_LIBZ
 #ifdef HAVE_LIBJPEG
-  if (!memcmp(header, "\377\330\377", 3) &&    /* Start-of-Image */
-          header[3] >= 0xe0 && header[3] <= 0xef)      /* APPn */
+  if (!memcmp(header, "\377\330\377", 3) &&    // Start-of-Image
+      header[3] >= 0xe0 && header[3] <= 0xef)  // APPn
     status = _cfImageReadJPEG(img, fp, primary, secondary, saturation, hue,
-                                lut);
+                             lut);
   else
-#endif /* HAVE_LIBJPEG */
+#endif // HAVE_LIBJPEG
 #ifdef HAVE_LIBTIFF
   if (!memcmp(header, "MM\000\052", 4) ||
-           !memcmp(header, "II\052\000", 4))
+      !memcmp(header, "II\052\000", 4))
     status = _cfImageReadTIFF(img, fp, primary, secondary, saturation, hue,
-                                lut);
+                             lut);
   else
-#endif /* HAVE_LIBTIFF */
+#endif // HAVE_LIBTIFF
   {
     fclose(fp);
     status = -1;
@@ -415,24 +419,24 @@ cfImageOpenFP(
 }
 
 
-/*
- * '_cfImagePutCol()' - Put a column of pixels to an image.
- */
+//
+// '_cfImagePutCol()' - Put a column of pixels to an image.
+//
 
-int                                    /* O - -1 on error, 0 on success */
+int                                    // O - -1 on error, 0 on success
 _cfImagePutCol(
-    cf_image_t    *img,                /* I - Image */
-    int             x,                 /* I - Column */
-    int             y,                 /* I - Start row */
-    int             height,            /* I - Column height */
-    const cf_ib_t *pixels)             /* I - Pixels to put */
+    cf_image_t      *img,              // I - Image
+    int             x,                 // I - Column
+    int             y,                 // I - Start row
+    int             height,            // I - Column height
+    const cf_ib_t   *pixels)           // I - Pixels to put
 {
-  int          bpp,                    /* Bytes per pixel */
-               twidth,                 /* Width of tile */
-               count;                  /* Number of pixels to put */
-  int          tilex,                  /* Column within tile */
-               tiley;                  /* Row within tile */
-  cf_ib_t      *ib;                    /* Pointer to pixels in tile */
+  int          bpp,                    // Bytes per pixel
+               twidth,                 // Width of tile
+               count;                  // Number of pixels to put
+  int          tilex,                  // Column within tile
+               tiley;                  // Row within tile
+  cf_ib_t      *ib;                    // Pointer to pixels in tile
 
 
   if (img == NULL || x < 0 || x >= img->xsize || y >= img->ysize)
@@ -490,23 +494,23 @@ _cfImagePutCol(
 }
 
 
-/*
- * '_cfImagePutRow()' - Put a row of pixels to an image.
- */
+//
+// '_cfImagePutRow()' - Put a row of pixels to an image.
+//
 
-int                                    /* O - -1 on error, 0 on success */
+int                                    // O - -1 on error, 0 on success
 _cfImagePutRow(
-    cf_image_t    *img,                /* I - Image */
-    int             x,                 /* I - Start column */
-    int             y,                 /* I - Row */
-    int             width,             /* I - Row width */
-    const cf_ib_t *pixels)             /* I - Pixel data */
+    cf_image_t      *img,              // I - Image
+    int             x,                 // I - Start column
+    int             y,                 // I - Row
+    int             width,             // I - Row width
+    const cf_ib_t   *pixels)           // I - Pixel data
 {
-  int          bpp,                    /* Bytes per pixel */
-               count;                  /* Number of pixels to put */
-  int          tilex,                  /* Column within tile */
-               tiley;                  /* Row within tile */
-  cf_ib_t      *ib;                    /* Pointer to pixels in tile */
+  int          bpp,                    // Bytes per pixel
+               count;                  // Number of pixels to put
+  int          tilex,                  // Column within tile
+               tiley;                  // Row within tile
+  cf_ib_t      *ib;                    // Pointer to pixels in tile
 
 
   if (img == NULL || y < 0 || y >= img->ysize || x >= img->xsize)
@@ -551,23 +555,23 @@ _cfImagePutRow(
 }
 
 
-/*
- * 'cfImageSetMaxTiles()' - Set the maximum number of tiles to cache.
- *
- * If the "max_tiles" argument is 0 then the maximum number of tiles is
- * computed from the image size or the RIP_CACHE environment variable.
- */
+//
+// 'cfImageSetMaxTiles()' - Set the maximum number of tiles to cache.
+//
+// If the "max_tiles" argument is 0 then the maximum number of tiles is
+// computed from the image size or the RIP_CACHE environment variable.
+//
 
 void
 cfImageSetMaxTiles(
-    cf_image_t *img,                   /* I - Image to set */
-    int          max_tiles)            /* I - Number of tiles to cache */
+    cf_image_t   *img,                 // I - Image to set
+    int          max_tiles)            // I - Number of tiles to cache
 {
-  int  cache_size,                     /* Size of tile cache in bytes */
-       min_tiles,                      /* Minimum number of tiles to cache */
-       max_size;                       /* Maximum cache size in bytes */
-  char *cache_env,                     /* Cache size environment variable */
-       cache_units[255];               /* Cache size units */
+  int  cache_size,                     // Size of tile cache in bytes
+       min_tiles,                      // Minimum number of tiles to cache
+       max_size;                       // Maximum cache size in bytes
+  char *cache_env,                     // Cache size environment variable
+       cache_units[255];               // Cache size units
 
 
   min_tiles = max(CF_TILE_MINIMUM,
@@ -619,59 +623,66 @@ cfImageSetMaxTiles(
 }
 
 
+//
+// 'cfImageCrop()' - Crop an image.
+//                   (posw, posh):    Position of left corner
+//                   (width, height): Width and height of required image.
 
-/*
- * 'cfImageCrop()' - Crop an image.
- *                   (posw, posh):    Position of left corner
- *                   (width, height): Width and height of required image.
- */
-
-cf_image_t* cfImageCrop(cf_image_t* img,int posw,int posh,int width,int height)
+cf_image_t*
+cfImageCrop(cf_image_t* img,
+           int posw,
+           int posh,
+           int width,
+           int height)
 {
   int image_width = cfImageGetWidth(img);
-  cf_image_t* temp=calloc(sizeof(cf_image_t),1);
-  cf_ib_t *pixels=(cf_ib_t*)malloc(img->xsize*cfImageGetDepth(img));
+  cf_image_t* temp = calloc(sizeof(cf_image_t), 1);
+  cf_ib_t *pixels = (cf_ib_t*)malloc(img->xsize * cfImageGetDepth(img));
+
   temp->cachefile = -1;
   temp->max_ics = CF_TILE_MINIMUM;
-  temp->colorspace=img->colorspace;
+  temp->colorspace = img->colorspace;
   temp->xppi = img->xppi;
   temp->yppi = img->yppi;
   temp->num_ics = 0;
-  temp->first =temp->last = NULL;
+  temp->first = temp->last = NULL;
   temp->tiles = NULL;
   temp->xsize = width;
   temp->ysize = height;
-  for(int i=posh;i<min(cfImageGetHeight(img),posh+height);i++){
-    cfImageGetRow(img,posw,i,min(width,image_width-posw),pixels);
-    _cfImagePutRow(temp,0,i-posh,min(width,image_width-posw),pixels);
+
+  for (int i = posh; i < min(cfImageGetHeight(img), posh + height); i ++)
+  {
+    cfImageGetRow(img, posw, i, min(width, image_width - posw), pixels);
+    _cfImagePutRow(temp, 0, i - posh, min(width, image_width - posw), pixels);
   }
+
   free(pixels);
-  return temp;
+
+  return (temp);
 }
 
 
-/*
- * 'flush_tile()' - Flush the least-recently-used tile in the cache.
- */
+//
+// 'flush_tile()' - Flush the least-recently-used tile in the cache.
+//
 
 static int
-flush_tile(cf_image_t *img)            /* I - Image */
+flush_tile(cf_image_t *img)            // I - Image
 {
-  int          bpp;                    /* Bytes per pixel */
-  cf_itile_t   *tile;                  /* Pointer to tile */
+  int          bpp;                    // Bytes per pixel
+  cf_itile_t   *tile;                  // Pointer to tile
 
 
-  bpp  = cfImageGetDepth(img);
-  if(img==NULL||img->first==NULL||img->first->tile==NULL)
-  {
-    return -1;
-  }
+  bpp = cfImageGetDepth(img);
+  if(img == NULL || img->first == NULL || img->first->tile == NULL)
+    return (-1);
+
   tile = img->first->tile;
 
   if (!tile->dirty)
   {
     tile->ic = NULL;
-    return 0;
+    return (0);
   }
 
   if (img->cachefile < 0)
@@ -681,7 +692,7 @@ flush_tile(cf_image_t *img)         /* I - Image */
     {
       tile->ic    = NULL;
       tile->dirty = 0;
-      return 0;
+      return (0);
     }
 
     DEBUG_printf(("Created swap file \"%s\"...\n", img->cachename));
@@ -693,7 +704,7 @@ flush_tile(cf_image_t *img)         /* I - Image */
     {
       tile->ic    = NULL;
       tile->dirty = 0;
-      return 0;
+      return (0);
     }
   }
   else
@@ -702,7 +713,7 @@ flush_tile(cf_image_t *img)         /* I - Image */
     {
       tile->ic    = NULL;
       tile->dirty = 0;
-      return 0;
+      return (0);
     }
   }
 
@@ -712,26 +723,26 @@ flush_tile(cf_image_t *img)               /* I - Image */
 
   tile->ic    = NULL;
   tile->dirty = 0;
-  return 0;
+  return (0);
 }
 
 
-/*
- * 'get_tile()' - Get a cached tile.
- */
+//
+// 'get_tile()' - Get a cached tile.
+//
 
-static cf_ib_t *                       /* O - Pointer to tile or NULL */
-get_tile(cf_image_t *img,              /* I - Image */
-         int          x,               /* I - Column in image */
-         int          y)               /* I - Row in image */
+static cf_ib_t *                       // O - Pointer to tile or NULL
+get_tile(cf_image_t *img,              // I - Image
+         int          x,               // I - Column in image
+         int          y)               // I - Row in image
 {
-  int          bpp,                    /* Bytes per pixel */
-               tilex,                  /* Column within tile */
-               tiley,                  /* Row within tile */
-               xtiles,                 /* Number of tiles horizontally */
-               ytiles;                 /* Number of tiles vertically */
-  cf_ic_t      *ic;                    /* Cache pointer */
-  cf_itile_t   *tile;                  /* Tile pointer */
+  int          bpp,                    // Bytes per pixel
+               tilex,                  // Column within tile
+               tiley,                  // Row within tile
+               xtiles,                 // Number of tiles horizontally
+               ytiles;                 // Number of tiles vertically
+  cf_ic_t      *ic;                    // Cache pointer
+  cf_itile_t   *tile;                  // Tile pointer
 
 
   if (img->tiles == NULL)
@@ -831,18 +842,18 @@ get_tile(cf_image_t *img,         /* I - Image */
 
   if (ic != img->last)
   {
-   /*
-    * Remove the cache entry from the list...
-    */
+    //
+    // Remove the cache entry from the list...
+    //
 
     if (ic->prev != NULL)
       ic->prev->next = ic->next;
     if (ic->next != NULL)
       ic->next->prev = ic->prev;
 
-   /*
-    * And add it to the end...
-    */
+    //
+    // And add it to the end...
+    //
 
     if (img->last != NULL)
       img->last->next = ic;
@@ -856,10 +867,11 @@ get_tile(cf_image_t *img,         /* I - Image */
   return (ic->pixels + bpp * (y * CF_TILE_SIZE + x));
 }
 
+
 #ifdef HAVE_EXIF
-/*
-  helper function required by EXIF read function
-  */
+//
+// Helper function required by EXIF read function
+//
 
 static void trim_spaces(char *buf)
 {
@@ -869,18 +881,17 @@ static void trim_spaces(char *buf)
     if (*buf != ' ')
       s = buf;
   }
-  *++s = 0; /* null terminate the string on the first of the final spaces */
+  *++s = 0; // null terminate the string on the first of the final spaces
 }
 
-/*
-  implementation for EXIF read function
-  */
 
-/*
-  helper function to extract bytes from image files
-  */
+//
+// Helper function to extract bytes from image files
+//
 
-static unsigned char *find_bytes(FILE *fp, long int *size)
+static unsigned char *
+find_bytes(FILE *fp,
+          long int *size)
 {
   unsigned char *buf;
 
@@ -904,10 +915,17 @@ static unsigned char *find_bytes(FILE *fp, long int *size)
 
   fseek(fp, originalOffset, SEEK_SET);
 
-  return buf;
+  return (buf);
 }
 
-int _cfImageReadEXIF(cf_image_t *img, FILE *fp)
+
+//
+// Implementation for EXIF read function
+//
+
+int
+_cfImageReadEXIF(cf_image_t *img,
+                FILE *fp)
 {
 
   if (fp == NULL)
@@ -925,7 +943,7 @@ int _cfImageReadEXIF(cf_image_t *img, FILE *fp)
       (ed = exif_data_new_from_data(buf, bufSize)) == NULL)
   {
     DEBUG_printf(("DEBUG: No EXIF data found"));
-    return 2;
+    return (2);
   }
 
   ExifIfd ifd = EXIF_IFD_0;
@@ -939,7 +957,7 @@ int _cfImageReadEXIF(cf_image_t *img, FILE *fp)
   if (entryX == NULL || entryY == NULL)
   {
     DEBUG_printf(("DEBUG: No EXIF data found"));
-    return 2;
+    return (2);
   }
 
   if (entryX)
@@ -956,9 +974,10 @@ int _cfImageReadEXIF(cf_image_t *img, FILE *fp)
       sscanf(buf1, "%d", &xRes);
       img->xppi = xRes;
     }
-    else{
+    else
+    {
       free(buf);
-      return 2;
+      return (2);
     }
   }
 
@@ -977,11 +996,11 @@ int _cfImageReadEXIF(cf_image_t *img, FILE *fp)
     }
     else{
       free(buf);
-      return 2;
+      return (2);
     }
   }
 
   free(buf);
-  return 1;
+  return (1);
 }
-#endif
+#endif // HAVE_EXIF
index 197c7cc2048273a4c31cee2ae516299aa1b97bdf..6d03b3dbeadda7a46badcc93e09fa7ef194e93f2 100644 (file)
@@ -1,60 +1,63 @@
-/*
- *   Image library definitions for CUPS Filters.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-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 "COPYING"
- *   which should have been included with this file.
- */
+//
+//   Image library definitions for libcupsilters.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1993-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 "COPYING"
+//   which should have been included with this file.
+//
+
 
 #ifndef _CUPS_FILTERS_IMAGE_H_
 #  define _CUPS_FILTERS_IMAGE_H_
 
-/*
- * Include necessary headers...
- */
+
+//
+// Include necessary headers...
+//
 
 #  include <stdio.h>
 #  include <cups/raster.h>
 
 #  ifdef __cplusplus
 extern "C" {
-#  endif /* __cplusplus */
+#  endif // __cplusplus
 
-/*
- * Constants...
- */
 
-typedef enum cf_icspace_e      /**** Image colorspaces ****/
+//
+// Constants...
+//
+
+typedef enum cf_icspace_e      // **** Image colorspaces ****
 {
-  CF_IMAGE_CMYK = -4,          /* Cyan, magenta, yellow, and black */
-  CF_IMAGE_CMY = -3,           /* Cyan, magenta, and yellow */
-  CF_IMAGE_BLACK = -1,         /* Black */
-  CF_IMAGE_WHITE = 1,          /* White (luminance) */
-  CF_IMAGE_RGB = 3,            /* Red, green, and blue */
-  CF_IMAGE_RGB_CMYK = 4                /* Use RGB or CMYK */
+  CF_IMAGE_CMYK = -4,          // Cyan, magenta, yellow, and black
+  CF_IMAGE_CMY = -3,           // Cyan, magenta, and yellow
+  CF_IMAGE_BLACK = -1,         // Black
+  CF_IMAGE_WHITE = 1,          // White (luminance)
+  CF_IMAGE_RGB = 3,            // Red, green, and blue
+  CF_IMAGE_RGB_CMYK = 4                // Use RGB or CMYK
 } cf_icspace_t;
 
 
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
 
-typedef unsigned char cf_ib_t;        /**** Image byte ****/
+typedef unsigned char cf_ib_t;        // **** Image byte ****
 
 struct cf_image_s;
-typedef struct cf_image_s cf_image_t; /**** Image file data ****/
+typedef struct cf_image_s cf_image_t; // **** Image file data ****
 
 struct cf_izoom_s;
-typedef struct cf_izoom_s cf_izoom_t; /**** Image zoom data ****/
+typedef struct cf_izoom_s cf_izoom_t; // **** Image zoom data ****
 
 
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
 
 extern void            cfImageClose(cf_image_t *img);
 extern void            cfImageCMYKToBlack(const cf_ib_t *in,
@@ -120,7 +123,6 @@ extern cf_image_t*  cfImageCrop(cf_image_t* img,int posw,
 
 #  ifdef __cplusplus
 }
-#  endif /* __cplusplus */
-
-#endif /* !_CUPS_FILTERS_IMAGE_H_ */
+#  endif // __cplusplus
 
+#endif // !_CUPS_FILTERS_IMAGE_H_
index 22a264d316c98dd5238cc817dd4251a80e9b6ae1..c596fa06dafaa3843645b74dfd70db0ce21f882d 100644 (file)
@@ -1,22 +1,22 @@
-/*
- * Image file to PDF filter function for cups-filters.
- * developped by BBR Inc. 2006-2007
- *
- * This is based on imagetops.c of CUPS
- *
- * imagetops.c copyright notice is follows
- *
- *   Copyright 1993-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
- *   "COPYING" which should have been included with this file.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Image file to PDF filter function for libcupsfilters.
+// Originally developped by BBR Inc. 2006-2007
+//
+// This is based on imagetops.c of CUPS
+//
+// imagetops.c copyright notice is follows
+//
+//   Copyright 1993-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
+//   "COPYING" which should have been included with this file.
+//
+
+//
+// Include necessary headers...
+//
 
 #include "config.h"
 #include <cupsfilters/filter.h>
 #define N_OBJECT_ALLOC 100
 #define LINEBUFSIZE 1024
 
-/*
- * Types...
- */
 
-struct pdfObject {
+//
+// Types...
+//
+
+struct pdfObject
+{
     int offset;
 };
 
-typedef struct imagetopdf_doc_s {       /**** Document information ****/
-  int          Flip,                   /* Flip/mirror pages */
-               XPosition,              /* Horizontal position on page */
-               YPosition,              /* Vertical position on page */
-               Collate,                /* Collate copies? */
-               Copies,                 /* Number of copies */
-               Reverse,                /* Output order */
-               EvenDuplex;             /* Duplex needs even number of pages? */
-  int          Orientation,            /* 0 = portrait, 1 = landscape, etc. */
-               Duplex,                 /* Duplexed? */
-               Color;                  /* Print in color? */
-  float        PageLeft,               /* Left margin */
-               PageRight,              /* Right margin */
-               PageBottom,             /* Bottom margin */
-               PageTop,                /* Top margin */
-               PageWidth,              /* Total page width */
-               PageLength;             /* Total page length */
+typedef struct imagetopdf_doc_s         // **** Document information ****
+{
+  int          Flip,                   // Flip/mirror pages
+               XPosition,              // Horizontal position on page
+               YPosition,              // Vertical position on page
+               Collate,                // Collate copies?
+               Copies,                 // Number of copies
+               Reverse,                // Output order
+               EvenDuplex;             // Duplex needs even number of pages?
+  int          Orientation,            // 0 = portrait, 1 = landscape, etc.
+               Duplex,                 // Duplexed?
+               Color;                  // Print in color?
+  float        PageLeft,               // Left margin
+               PageRight,              // Right margin
+               PageBottom,             // Bottom margin
+               PageTop,                // Top margin
+               PageWidth,              // Total page width
+               PageLength;             // Total page length
   struct pdfObject *objects;
   int          currentObjectNo;
   int          allocatedObjectNum;
@@ -66,35 +69,36 @@ typedef struct imagetopdf_doc_s {       /**** Document information ****/
   int          catalogObj;
   int          pagesObj;
   const char   *title;
-  int          xpages,                 /* # x pages */
-               ypages,                 /* # y pages */
-               xpage,                  /* Current x page */
-               ypage,                  /* Current y page */
-               page;                   /* Current page number */
-  int          xc0, yc0,               /* Corners of the page in */
-               xc1, yc1;               /* image coordinates */
-  float                left, top;              /* Left and top of image */
-  float                xprint,                 /* Printable area */
+  int          xpages,                 // # x pages
+               ypages,                 // # y pages
+               xpage,                  // Current x page
+               ypage,                  // Current y page
+               page;                   // Current page number
+  int          xc0, yc0,               // Corners of the page in
+               xc1, yc1;               // image coordinates
+  float                left, top;              // Left and top of image
+  float                xprint,                 // Printable area
                yprint,
-               xinches,                /* Total size in inches */
+               xinches,                // Total size in inches
                yinches;
-  float                xsize,                  /* Total size in points */
+  float                xsize,                  // Total size in points
                ysize,
                xsize2,
                ysize2;
-  float                aspect;                 /* Aspect ratio */
-  cf_image_t   *img;                   /* Image to print */
-  int          colorspace;             /* Output colorspace */
-  cf_ib_t      *row;                   /* Current row */
-  float                gammaval;               /* Gamma correction value */
-  float                brightness;             /* Gamma correction value */
+  float                aspect;                 // Aspect ratio
+  cf_image_t   *img;                   // Image to print
+  int          colorspace;             // Output colorspace
+  cf_ib_t      *row;                   // Current row
+  float                gammaval;               // Gamma correction value
+  float                brightness;             // Gamma correction value
   char         linebuf[LINEBUFSIZE];
   FILE         *outputfp;
 } imagetopdf_doc_t;
 
-/*
- * Local functions...
- */
+
+//
+// Local functions...
+//
 
 #ifdef OUT_AS_HEX
 static void    out_hex(imagetopdf_doc_t *doc, cf_ib_t *, int, int);
@@ -120,12 +124,16 @@ static int        out_page_object(imagetopdf_doc_t *doc, int pageObj,
 static int     out_page_contents(imagetopdf_doc_t *doc, int contentsObj);
 static int     out_image(imagetopdf_doc_t *doc, int imgObj);
 
-static void set_offset(imagetopdf_doc_t *doc, int obj)
+static void
+set_offset(imagetopdf_doc_t *doc,
+          int obj)
 {
   doc->objects[obj].offset = doc->currentOffset;
 }
 
-static int alloc_page_objects(imagetopdf_doc_t *doc, int nPages)
+static int
+alloc_page_objects(imagetopdf_doc_t *doc,
+                  int nPages)
 {
   int i, n;
 
@@ -141,28 +149,31 @@ static int alloc_page_objects(imagetopdf_doc_t *doc, int nPages)
   return (0);
 }
 
-static int new_obj(imagetopdf_doc_t *doc)
+static int
+new_obj(imagetopdf_doc_t *doc)
 {
   if (doc->objects == NULL)
   {
-    if ((doc->objects = malloc(sizeof(struct pdfObject)*N_OBJECT_ALLOC))
-         == NULL)
+    if ((doc->objects = malloc(sizeof(struct pdfObject) * N_OBJECT_ALLOC)) ==
+       NULL)
       return(-1);
     doc->allocatedObjectNum = N_OBJECT_ALLOC;
   }
   if (doc->currentObjectNo >= doc->allocatedObjectNum)
   {
     if ((doc->objects = realloc(doc->objects,
-         sizeof(struct pdfObject)*(doc->allocatedObjectNum+N_OBJECT_ALLOC)))
-         == NULL)
+                               sizeof(struct pdfObject) *
+                               (doc->allocatedObjectNum + N_OBJECT_ALLOC))) ==
+       NULL)
       return(-1);
     doc->allocatedObjectNum += N_OBJECT_ALLOC;
   }
   doc->objects[doc->currentObjectNo].offset = doc->currentOffset;
-  return doc->currentObjectNo++;
+  return (doc->currentObjectNo++);
 }
 
-static void free_all_obj(imagetopdf_doc_t *doc)
+static void
+free_all_obj(imagetopdf_doc_t *doc)
 {
   if (doc->objects != NULL)
   {
@@ -171,13 +182,17 @@ static void free_all_obj(imagetopdf_doc_t *doc)
   }
 }
 
-static void putc_pdf(imagetopdf_doc_t *doc, char c)
+static void
+putc_pdf(imagetopdf_doc_t *doc,
+        char c)
 {
   fputc(c, doc->outputfp);
   doc->currentOffset++;
 }
 
-static void out_pdf(imagetopdf_doc_t *doc, const char *str)
+static void
+out_pdf(imagetopdf_doc_t *doc,
+       const char *str)
 {
   unsigned long len = strlen(str);
 
@@ -185,38 +200,42 @@ static void out_pdf(imagetopdf_doc_t *doc, const char *str)
   doc->currentOffset += len;
 }
 
-static void out_xref(imagetopdf_doc_t *doc)
+static void
+out_xref(imagetopdf_doc_t *doc)
 {
   char buf[21];
   int i;
 
   doc->xrefOffset = doc->currentOffset;
   out_pdf(doc, "xref\n");
-  snprintf(buf,21,"0 %d\n",doc->currentObjectNo);
+  snprintf(buf, 21, "0 %d\n", doc->currentObjectNo);
   out_pdf(doc, buf);
   out_pdf(doc, "0000000000 65535 f \n");
-  for (i = 1;i < doc->currentObjectNo;i++)
+  for (i = 1; i < doc->currentObjectNo; i ++)
   {
-    snprintf(buf,21,"%010d 00000 n \n",doc->objects[i].offset);
+    snprintf(buf, 21, "%010d 00000 n \n", doc->objects[i].offset);
     out_pdf(doc, buf);
   }
 }
 
-static void out_string(imagetopdf_doc_t *doc, const char *s)
+static void
+out_string(imagetopdf_doc_t *doc,
+          const char *s)
 {
   char c;
 
   putc_pdf(doc, '(');
-  for (;(c = *s) != '\0';s++) {
-    if (c == '\\' || c == '(' || c == ')') {
+  for (; (c = *s) != '\0'; s ++)
+  {
+    if (c == '\\' || c == '(' || c == ')')
       putc_pdf(doc, '\\');
-    }
     putc_pdf(doc, c);
   }
   putc_pdf(doc, ')');
 }
 
-static void out_trailer(imagetopdf_doc_t *doc)
+static void
+out_trailer(imagetopdf_doc_t *doc)
 {
   time_t       curtime;
   struct tm    *curtm;
@@ -224,37 +243,39 @@ static void out_trailer(imagetopdf_doc_t *doc)
 
   curtime = time(NULL);
   curtm = localtime(&curtime);
-  strftime(curdate, sizeof(curdate),"D:%Y%m%d%H%M%S%z", curtm);
+  strftime(curdate, sizeof(curdate), "D:%Y%m%d%H%M%S%z", curtm);
 
   out_pdf(doc, "trailer\n");
-  snprintf(doc->linebuf, LINEBUFSIZE,"<</Size %d ",doc->currentObjectNo);
+  snprintf(doc->linebuf, LINEBUFSIZE, "<</Size %d ", doc->currentObjectNo);
   out_pdf(doc, doc->linebuf);
   out_pdf(doc, "/Root 1 0 R\n");
   out_pdf(doc, "/Info << /Title ");
   out_string(doc, doc->title);
   putc_pdf(doc, ' ');
-  snprintf(doc->linebuf,LINEBUFSIZE,"/CreationDate (%s) ",curdate);
+  snprintf(doc->linebuf, LINEBUFSIZE, "/CreationDate (%s) ", curdate);
   out_pdf(doc, doc->linebuf);
-  snprintf(doc->linebuf,LINEBUFSIZE,"/ModDate (%s) ",curdate);
+  snprintf(doc->linebuf, LINEBUFSIZE, "/ModDate (%s) ", curdate);
   out_pdf(doc, doc->linebuf);
   out_pdf(doc, "/Producer (imagetopdf) ");
   out_pdf(doc, "/Trapped /False >>\n");
   out_pdf(doc, ">>\n");
   out_pdf(doc, "startxref\n");
-  snprintf(doc->linebuf,LINEBUFSIZE,"%d\n",doc->xrefOffset);
+  snprintf(doc->linebuf, LINEBUFSIZE, "%d\n", doc->xrefOffset);
   out_pdf(doc, doc->linebuf);
   out_pdf(doc, "%%EOF\n");
 }
 
-static int out_prologue(imagetopdf_doc_t *doc, int nPages)
+static int
+out_prologue(imagetopdf_doc_t *doc,
+            int nPages)
 {
   int i;
 
-  /* out header */
-  if (new_obj(doc) < 0) /* dummy for no 0 object */
+  // out header
+  if (new_obj(doc) < 0) // dummy for no 0 object
     return (-1);
   out_pdf(doc, "%PDF-1.3\n");
-  /* out binary for transfer program */
+  // out binary for transfer program
   doc->linebuf[0] = '%';
   doc->linebuf[1] = (char)129;
   doc->linebuf[2] = (char)130;
@@ -272,38 +293,44 @@ static int out_prologue(imagetopdf_doc_t *doc, int nPages)
   if (alloc_page_objects(doc, nPages) < 0)
     return (-1);
 
-  /* out catalog */
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "%d 0 obj <</Type/Catalog /Pages %d 0 R ",doc->catalogObj,doc->pagesObj);
+  // out catalog
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "%d 0 obj <</Type/Catalog /Pages %d 0 R ", doc->catalogObj, doc->pagesObj);
   out_pdf(doc, doc->linebuf);
   out_pdf(doc, ">> endobj\n");
 
-  /* out Pages */
+  // out Pages
   set_offset(doc, doc->pagesObj);
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "%d 0 obj <</Type/Pages /Kids [ ",doc->pagesObj);
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "%d 0 obj <</Type/Pages /Kids [ ", doc->pagesObj);
   out_pdf(doc, doc->linebuf);
-  if (doc->Reverse) {
-    for (i = nPages-1;i >= 0;i--)
+  if (doc->Reverse)
+  {
+    for (i = nPages - 1; i >= 0; i --)
     {
-      snprintf(doc->linebuf,LINEBUFSIZE,"%d 0 R ",doc->pageObjects[i]);
+      snprintf(doc->linebuf, LINEBUFSIZE, "%d 0 R ", doc->pageObjects[i]);
       out_pdf(doc, doc->linebuf);
     }
-  } else {
-    for (i = 0;i < nPages;i++)
+  }
+  else
     {
-      snprintf(doc->linebuf,LINEBUFSIZE,"%d 0 R ",doc->pageObjects[i]);
+    for (i = 0; i < nPages; i ++)
+    {
+      snprintf(doc->linebuf, LINEBUFSIZE, "%d 0 R ", doc->pageObjects[i]);
       out_pdf(doc, doc->linebuf);
     }
   }
   out_pdf(doc, "] ");
-  snprintf(doc->linebuf,LINEBUFSIZE,"/Count %d >> endobj\n",nPages);
+  snprintf(doc->linebuf, LINEBUFSIZE, "/Count %d >> endobj\n", nPages);
   out_pdf(doc, doc->linebuf);
   return (0);
 }
 
-static int out_page_object(imagetopdf_doc_t *doc, int pageObj, int contentsObj,
-                        int imgObj)
+static int
+out_page_object(imagetopdf_doc_t *doc,
+               int pageObj,
+               int contentsObj,
+               int imgObj)
 {
   int trfuncObj;
   int lengthObj;
@@ -311,75 +338,82 @@ static int out_page_object(imagetopdf_doc_t *doc, int pageObj, int contentsObj,
   int length;
   int outTrfunc = (doc->gammaval != 1.0 || doc->brightness != 1.0);
 
-  /* out Page Object */
+  // out Page Object
   set_offset(doc, pageObj);
-  snprintf(doc->linebuf,LINEBUFSIZE,
+  snprintf(doc->linebuf, LINEBUFSIZE,
     "%d 0 obj <</Type/Page /Parent %d 0 R ",
-    pageObj,doc->pagesObj);
+    pageObj, doc->pagesObj);
   out_pdf(doc, doc->linebuf);
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "/MediaBox [ 0 0 %f %f ] ",doc->PageWidth,doc->PageLength);
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "/MediaBox [ 0 0 %f %f ] ", doc->PageWidth, doc->PageLength);
   out_pdf(doc, doc->linebuf);
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "/TrimBox [ 0 0 %f %f ] ",doc->PageWidth,doc->PageLength);
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "/TrimBox [ 0 0 %f %f ] ", doc->PageWidth, doc->PageLength);
   out_pdf(doc, doc->linebuf);
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "/CropBox [ 0 0 %f %f ] ",doc->PageWidth,doc->PageLength);
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "/CropBox [ 0 0 %f %f ] ", doc->PageWidth, doc->PageLength);
   out_pdf(doc, doc->linebuf);
-  if (contentsObj >= 0) {
-    snprintf(doc->linebuf,LINEBUFSIZE,
-      "/Contents %d 0 R ",contentsObj);
+  if (contentsObj >= 0)
+  {
+    snprintf(doc->linebuf, LINEBUFSIZE,
+      "/Contents %d 0 R ", contentsObj);
     out_pdf(doc, doc->linebuf);
-    snprintf(doc->linebuf,LINEBUFSIZE,
+    snprintf(doc->linebuf, LINEBUFSIZE,
       "/Resources <</ProcSet [/PDF] "
-      "/XObject << /Im %d 0 R >>\n",imgObj);
+      "/XObject << /Im %d 0 R >>\n", imgObj);
     out_pdf(doc, doc->linebuf);
-  } else {
-    /* empty page */
-    snprintf(doc->linebuf,LINEBUFSIZE,
+  }
+  else
+  {
+    // empty page
+    snprintf(doc->linebuf, LINEBUFSIZE,
       "/Resources <</ProcSet [/PDF] \n");
     out_pdf(doc, doc->linebuf);
   }
-  if (outTrfunc) {
+  if (outTrfunc)
+  {
     if ((trfuncObj = new_obj(doc)) < 0)
       return (-1);
     if ((lengthObj = new_obj(doc)) < 0)
       return (-1);
-    snprintf(doc->linebuf,LINEBUFSIZE,
-      "/ExtGState << /GS1 << /TR %d 0 R >> >>\n",trfuncObj);
+    snprintf(doc->linebuf, LINEBUFSIZE,
+      "/ExtGState << /GS1 << /TR %d 0 R >> >>\n", trfuncObj);
     out_pdf(doc, doc->linebuf);
   }
   out_pdf(doc, "     >>\n>>\nendobj\n");
 
-  if (outTrfunc) {
-    /* out translate function */
+  if (outTrfunc)
+  {
+    // out translate function
     set_offset(doc, trfuncObj);
-    snprintf(doc->linebuf,LINEBUFSIZE,
+    snprintf(doc->linebuf, LINEBUFSIZE,
       "%d 0 obj <</FunctionType 4 /Domain [0 1.0]"
       " /Range [0 1.0] /Length %d 0 R >>\n",
-      trfuncObj,lengthObj);
+      trfuncObj, lengthObj);
     out_pdf(doc, doc->linebuf);
     out_pdf(doc, "stream\n");
     startOffset = doc->currentOffset;
-    snprintf(doc->linebuf,LINEBUFSIZE,
+    snprintf(doc->linebuf, LINEBUFSIZE,
      "{ neg 1 add dup 0 lt { pop 1 } { %.3f exp neg 1 add } "
      "ifelse %.3f mul }\n", doc->gammaval, doc->brightness);
     out_pdf(doc, doc->linebuf);
     length = doc->currentOffset - startOffset;
-    snprintf(doc->linebuf,LINEBUFSIZE,
+    snprintf(doc->linebuf, LINEBUFSIZE,
      "endstream\nendobj\n");
     out_pdf(doc, doc->linebuf);
 
-    /* out length object */
+    // out length object
     set_offset(doc, lengthObj);
-    snprintf(doc->linebuf,LINEBUFSIZE,
-      "%d 0 obj %d endobj\n",lengthObj,length);
+    snprintf(doc->linebuf, LINEBUFSIZE,
+      "%d 0 obj %d endobj\n", lengthObj, length);
     out_pdf(doc, doc->linebuf);
   }
   return (0);
 }
 
-static int out_page_contents(imagetopdf_doc_t *doc, int contentsObj)
+static int
+out_page_contents(imagetopdf_doc_t *doc,
+                 int contentsObj)
 {
   int startOffset;
   int lengthObj;
@@ -388,8 +422,8 @@ static int out_page_contents(imagetopdf_doc_t *doc, int contentsObj)
   set_offset(doc, contentsObj);
   if ((lengthObj = new_obj(doc)) < 0)
     return (-1);
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "%d 0 obj <</Length %d 0 R >> stream\n",contentsObj,lengthObj);
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "%d 0 obj <</Length %d 0 R >> stream\n", contentsObj, lengthObj);
   out_pdf(doc, doc->linebuf);
   startOffset = doc->currentOffset;
 
@@ -397,26 +431,26 @@ static int out_page_contents(imagetopdf_doc_t *doc, int contentsObj)
     out_pdf(doc, "/GS1 gs\n");
   if (doc->Flip)
   {
-    snprintf(doc->linebuf,LINEBUFSIZE,
-      "-1 0 0 1 %.0f 0 cm\n",doc->PageWidth);
+    snprintf(doc->linebuf, LINEBUFSIZE,
+      "-1 0 0 1 %.0f 0 cm\n", doc->PageWidth);
     out_pdf(doc, doc->linebuf);
   }
 
   switch (doc->Orientation)
   {
     case 1:
-       snprintf(doc->linebuf,LINEBUFSIZE,
-         "0 1 -1 0 %.0f 0 cm\n",doc->PageWidth);
+       snprintf(doc->linebuf, LINEBUFSIZE,
+         "0 1 -1 0 %.0f 0 cm\n", doc->PageWidth);
        out_pdf(doc, doc->linebuf);
        break;
     case 2:
-       snprintf(doc->linebuf,LINEBUFSIZE,
-         "-1 0 0 -1 %.0f %.0f cm\n",doc->PageWidth, doc->PageLength);
+       snprintf(doc->linebuf, LINEBUFSIZE,
+         "-1 0 0 -1 %.0f %.0f cm\n", doc->PageWidth, doc->PageLength);
        out_pdf(doc, doc->linebuf);
        break;
     case 3:
-       snprintf(doc->linebuf,LINEBUFSIZE,
-         "0 -1 1 0 0 %.0f cm\n",doc->PageLength);
+       snprintf(doc->linebuf, LINEBUFSIZE,
+         "0 -1 1 0 0 %.0f cm\n", doc->PageLength);
        out_pdf(doc, doc->linebuf);
        break;
   }
@@ -426,11 +460,11 @@ static int out_page_contents(imagetopdf_doc_t *doc, int contentsObj)
   doc->yc0 = cfImageGetHeight(doc->img) * doc->ypage / doc->ypages;
   doc->yc1 = cfImageGetHeight(doc->img) * (doc->ypage + 1) / doc->ypages - 1;
 
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "1 0 0 1 %.1f %.1f cm\n",doc->left,doc->top);
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "1 0 0 1 %.1f %.1f cm\n", doc->left, doc->top);
   out_pdf(doc, doc->linebuf);
 
-  snprintf(doc->linebuf,LINEBUFSIZE,
+  snprintf(doc->linebuf, LINEBUFSIZE,
     "%.3f 0 0 %.3f 0 0 cm\n",
      doc->xprint * 72.0, doc->yprint * 72.0);
   out_pdf(doc, doc->linebuf);
@@ -438,21 +472,23 @@ static int out_page_contents(imagetopdf_doc_t *doc, int contentsObj)
   length = doc->currentOffset - startOffset - 1;
   out_pdf(doc, "endstream\nendobj\n");
 
-  /* out length object */
+  // out length object
   set_offset(doc, lengthObj);
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "%d 0 obj %d endobj\n",lengthObj,length);
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "%d 0 obj %d endobj\n", lengthObj, length);
   out_pdf(doc, doc->linebuf);
   return (0);
 }
 
-static int out_image(imagetopdf_doc_t *doc, int imgObj)
+static int
+out_image(imagetopdf_doc_t *doc,
+         int imgObj)
 {
-  int          y;                      /* Current Y coordinate in image */
+  int          y;                      // Current Y coordinate in image
 #ifdef OUT_AS_ASCII85
-  int          out_offset;             /* Offset into output buffer */
+  int          out_offset;             // Offset into output buffer
 #endif
-  int          out_length;             /* Length of output buffer */
+  int          out_length;             // Length of output buffer
   int startOffset;
   int lengthObj;
   int length;
@@ -460,7 +496,7 @@ static int out_image(imagetopdf_doc_t *doc, int imgObj)
   set_offset(doc, imgObj);
   if ((lengthObj = new_obj(doc)) < 0)
     return (-1);
-  snprintf(doc->linebuf,LINEBUFSIZE,
+  snprintf(doc->linebuf, LINEBUFSIZE,
     "%d 0 obj << /Length %d 0 R /Type /XObject "
     "/Subtype /Image /Name /Im"
 #ifdef OUT_AS_HEX
@@ -470,9 +506,9 @@ static int out_image(imagetopdf_doc_t *doc, int imgObj)
     "/Filter /ASCII85Decode "
 #endif
 #endif
-    ,imgObj,lengthObj);
+    , imgObj, lengthObj);
   out_pdf(doc, doc->linebuf);
-  snprintf(doc->linebuf,LINEBUFSIZE,
+  snprintf(doc->linebuf, LINEBUFSIZE,
     "/Width %d /Height %d /BitsPerComponent 8 ",
     doc->xc1 - doc->xc0 + 1, doc->yc1 - doc->yc0 + 1);
   out_pdf(doc, doc->linebuf);
@@ -500,7 +536,7 @@ static int out_image(imagetopdf_doc_t *doc, int imgObj)
   startOffset = doc->currentOffset;
 
 #ifdef OUT_AS_ASCII85
-  /* out ascii85 needs multiple of 4bytes */
+  // out ascii85 needs multiple of 4bytes
   for (y = doc->yc0, out_offset = 0; y <= doc->yc1; y ++)
   {
     cfImageGetRow(doc->img, doc->xc0, y, doc->xc1 - doc->xc0 + 1,
@@ -531,76 +567,79 @@ static int out_image(imagetopdf_doc_t *doc, int imgObj)
   length = doc->currentOffset - startOffset;
   out_pdf(doc, "\nendstream\nendobj\n");
 
-  /* out length object */
+  // out length object
   set_offset(doc, lengthObj);
-  snprintf(doc->linebuf,LINEBUFSIZE,
-    "%d 0 obj %d endobj\n",lengthObj,length);
+  snprintf(doc->linebuf, LINEBUFSIZE,
+    "%d 0 obj %d endobj\n", lengthObj, length);
   out_pdf(doc, doc->linebuf);
   return (0);
 }
 
-/*
- * 'cfFilterImageToPDF()' - Filter function to convert many common image file
- *                  formats into PDF
- */
-
-int                             /* O - Error status */
-cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
-          int outputfd,        /* I - File descriptor output stream */
-          int inputseekable,   /* I - Is input stream seekable? (unused) */
-          cf_filter_data_t *data, /* I - Job and printer data */
-          void *parameters)    /* I - Filter-specific parameters (unused) */
+
+//
+// 'cfFilterImageToPDF()' - Filter function to convert many common image file
+//                          formats into PDF
+//
+
+int                                     // O - Error status
+cfFilterImageToPDF(int inputfd,         // I - File descriptor input stream
+                  int outputfd,        // I - File descriptor output stream
+                  int inputseekable,   // I - Is input stream seekable?
+                                       //     (unused)
+                  cf_filter_data_t *data, // I - Job and printer data
+                  void *parameters)    // I - Filter-specific parameters
+                                        //     (unused)
 {
-  imagetopdf_doc_t     doc;            /* Document information */
-  cups_page_header2_t h;                /* CUPS Raster page header, to */
-                                        /* accommodate results of command */
-                                        /* line and IPP parsing */
-  int          num_options = 0;        /* Number of print options */
-  cups_option_t        *options = NULL;        /* Print options */
-  const char   *val;                   /* Option value */
-  float                zoom;                   /* Zoom facter */
-  int          xppi, yppi;             /* Pixels-per-inch */
-  int          hue, sat;               /* Hue and saturation adjustment */
+  imagetopdf_doc_t     doc;            // Document information
+  cups_page_header2_t h;                // CUPS Raster page header, to
+                                        // accommodate results of command
+                                        // line and IPP parsing
+  int          num_options = 0;        // Number of print options
+  cups_option_t        *options = NULL;        // Print options
+  const char   *val;                   // Option value
+  float                zoom;                   // Zoom facter
+  int          xppi, yppi;             // Pixels-per-inch
+  int          hue, sat;               // Hue and saturation adjustment
   int           pdf_printer = 0;
-  char         tempfile[1024];         /* Name of file to print */
-  FILE          *fp;                   /* Input file */
-  int           fd;                    /* File descriptor for temp file */
+  char         tempfile[1024];         // Name of file to print
+  FILE          *fp;                   // Input file
+  int           fd;                    // File descriptor for temp file
   char          buf[BUFSIZ];
   int           bytes;
   int          deviceCopies = 1;
   int          deviceCollate = 0;
   int          deviceReverse = 0;
   int          pl, pr;
-  int          fillprint = 0;          /* print-scaling = fill */
-  int          cropfit = 0;            /* -o crop-to-fit = true */
-  cf_logfunc_t log = data->logfunc;
+  int          fillprint = 0;          // print-scaling = fill
+  int          cropfit = 0;            // -o crop-to-fit = true
+  cf_logfunc_t  log = data->logfunc;
   void          *ld = data->logdata;
   cf_filter_iscanceledfunc_t iscanceled = data->iscanceledfunc;
   void          *icd = data->iscanceleddata;
-  ipp_t *printer_attrs = data->printer_attrs;
-  ipp_t *job_attrs = data->job_attrs;
+  ipp_t         *printer_attrs = data->printer_attrs;
+  ipp_t         *job_attrs = data->job_attrs;
   ipp_attribute_t *ipp;
   cups_cspace_t cspace = (cups_cspace_t)(-1);
-  int                  min_length = __INT32_MAX__,
-                       min_width = __INT32_MAX__,
-                       max_length = 0,
-                       max_width = 0;
-  float                customLeft = 0.0,
-                       customBottom = 0.0,
-                       customRight = 0.0,
-                       customTop = 0.0;
-  char                         defSize[41];
+  int          min_length = __INT32_MAX__,
+               min_width = __INT32_MAX__,
+               max_length = 0,
+               max_width = 0;
+  float        customLeft = 0.0,
+               customBottom = 0.0,
+               customRight = 0.0,
+               customTop = 0.0;
+  char                 defSize[41];
 
 
- /*
-  * Make sure status messages are not buffered...
-  */
+  //
+  // Make sure status messages are not buffered...
+  //
 
   setbuf(stderr, NULL);
 
- /*
-  * Initialize data structure
-  */
+  //
+  // Initialize data structure
+  //
 
   doc.Flip = 0;
   doc.XPosition = 0;
@@ -617,9 +656,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
   doc.gammaval = 1.0;
   doc.brightness = 1.0;
 
- /*
-  * Open the input data stream specified by the inputfd ...
-  */
+  //
+  // Open the input data stream specified by the inputfd ...
+  //
 
   if ((fp = fdopen(inputfd, "r")) == NULL)
   {
@@ -632,9 +671,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     return (1);
   }
 
- /*
-  * Copy input into temporary file if needed ...
-  */
+  //
+  // Copy input into temporary file if needed ...
+  //
 
   if (!inputseekable) {
     if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
@@ -656,9 +695,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     fclose(fp);
     close(fd);
 
-   /*
-    * Open the temporary file to read it instead of the original input ...
-    */
+    //
+    // Open the temporary file to read it instead of the original input ...
+    //
 
     if ((fp = fopen(tempfile, "r")) == NULL)
     {
@@ -673,9 +712,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     }
   }
 
- /*
-  * Open the output data stream specified by the outputfd...
-  */
+  //
+  // Open the output data stream specified by the outputfd...
+  //
 
   if ((doc.outputfp = fdopen(outputfd, "w")) == NULL)
   {
@@ -692,9 +731,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     return (1);
   }
 
- /*
-  * Process options and write the prolog...
-  */
+  //
+  // Process options and write the prolog...
+  //
 
   zoom = 1.0;
   xppi = 0;
@@ -705,38 +744,38 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
   doc.title = data->job_title;
   doc.Copies = data->copies;
 
- /*
-  * Option list...
-  * Also add job-attrs in options list itself. 
-  */
+  //
+  // Option list...
+  // Also add job-attrs in options list itself.
+  //
 
   num_options = cfJoinJobOptionsAndAttrs(data, num_options, &options);
 
- /* 
-  * Compute custom margins and min_width and min_length of the page... 
-  */
+  //
+  // Compute custom margins and min_width and min_length of the page...
+  //
 
-  if (printer_attrs != NULL) {
+  if (printer_attrs != NULL)
+  {
     int left, bottom, right, top;
     cfGenerateSizes(printer_attrs, CF_GEN_SIZES_DEFAULT, NULL, &ipp,
                    NULL, NULL, NULL, NULL, NULL, NULL,
                    &min_width, &min_length, &max_width, &max_length,
                    &left, &bottom, &right, &top, defSize, NULL);
-    customLeft = left*72.0/2540.0;
-    customBottom = bottom*72.0/2540.0;
-    customRight = right*72.0/2540.0;
-    customTop = top*72.0/2540.0;
+    customLeft = left * 72.0 / 2540.0;
+    customBottom = bottom * 72.0 / 2540.0;
+    customRight = right * 72.0 / 2540.0;
+    customTop = top * 72.0 / 2540.0;
   }
 
+  //
+  // Process job options...
+  //
 
- /*
-  * Process job options...
-  */
-
-  /* To find the correct output color space, resolution page size, ...
-     and to parse all releveant command line options we run 
-     cfRasterPrepareHeader() here and afterwards we simply take the
-     needed parameters from the header. */
+  // To find the correct output color space, resolution page size, ...
+  // and to parse all releveant command line options we run
+  // cfRasterPrepareHeader() here and afterwards we simply take the
+  // needed parameters from the header.
   cfRasterPrepareHeader(&h, data, CF_FILTER_OUT_FORMAT_CUPS_RASTER,
                        CF_FILTER_OUT_FORMAT_CUPS_RASTER, 0, &cspace);
   doc.Color = h.cupsNumColors <= 1 ? 0 : 1;
@@ -758,20 +797,19 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
   doc.Collate = h.Collate ? 1 : 0;
   doc.Copies = data->copies;
 
-  if (doc.Copies == 0) doc.Copies = 1;
+  if (doc.Copies == 0)
+    doc.Copies = 1;
 
-  /* Do we need to print the pages in reverse order? */
+  // Do we need to print the pages in reverse order?
   if ((val = cupsGetOption("OutputOrder", num_options, options)) != NULL ||
       (val = cupsGetOption("output-order", num_options, options)) != NULL ||
       (val = cupsGetOption("page-delivery", num_options, options)) != NULL)
-  {
     doc.Reverse = (strcasecmp(val, "Reverse") == 0 ||
                   strcasecmp(val, "reverse-order") == 0);
-  }
   else
     doc.Reverse = cfIPPReverseOutput(printer_attrs, job_attrs);
 
-  /* adjust to even page when duplex */
+  // adjust to even page when duplex
   if ((val = cupsGetOption("even-duplex", num_options, options)) != 0 &&
       (!strcasecmp(val, "true") || !strcasecmp(val, "on") ||
        !strcasecmp(val, "yes")))
@@ -793,24 +831,24 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
           (val = cfIPPAttrEnumValForPrinter(printer_attrs, job_attrs,
                                             "multiple-document-handling")) !=
           NULL)
-   /*
-    * This IPP attribute is unnecessarily complicated:
-    *
-    *   single-document, separate-documents-collated-copies,
-    *   single-document-new-sheet:
-    *      -> collate (true)
-    *
-    *   separate-documents-uncollated-copies:
-    *      -> can be uncollated (false)
-    */
+    //
+    // This IPP attribute is unnecessarily complicated:
+    //
+    //   single-document, separate-documents-collated-copies,
+    //   single-document-new-sheet:
+    //      -> collate (true)
+    //
+    //   separate-documents-uncollated-copies:
+    //      -> can be uncollated (false)
+    //
     doc.Collate =
       (strcasecmp(val, "separate-documents-uncollated-copies") != 0);
 
   if ((val = cupsGetOption("gamma", num_options, options)) != NULL)
-      doc.gammaval = atoi(val) * 0.001f;
+    doc.gammaval = atoi(val) * 0.001f;
 
   if ((val = cupsGetOption("brightness", num_options, options)) != NULL)
-      doc.brightness = atoi(val) * 0.01f;
+    doc.brightness = atoi(val) * 0.01f;
 
   if ((val = cupsGetOption("ppi", num_options, options)) != NULL)
   {
@@ -878,118 +916,124 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
       strcasecmp(val, "True") == 0)
     doc.Flip = 1;
 
-
- /*
-  * Open the input image to print...
-  */
+  //
+  // Open the input image to print...
+  //
 
   doc.colorspace = doc.Color ? CF_IMAGE_RGB_CMYK : CF_IMAGE_WHITE;
 
   doc.img = cfImageOpenFP(fp, doc.colorspace, CF_IMAGE_WHITE, sat, hue,
-                           NULL);
-  if (doc.img != NULL) {
-
-  int margin_defined = 0;
-  int fidelity = 0;
-  int document_large = 0;
-
-  if (customLeft != 0 || customRight != 0 ||
-      customBottom != 0 || customTop != 0 ||
-      doc.PageLength != doc.PageTop - doc.PageBottom ||
-      doc.PageWidth != doc.PageRight - doc.PageLeft)
-    margin_defined = 1;
-
-  if ((val = cupsGetOption("ipp-attribute-fidelity",num_options,options)) !=
-      NULL) {
-    if(!strcasecmp(val, "true") || !strcasecmp(val, "yes") ||
-        !strcasecmp(val, "on")) {
-      fidelity = 1;
+                         NULL);
+  if (doc.img != NULL)
+  {
+    int margin_defined = 0;
+    int fidelity = 0;
+    int document_large = 0;
+
+    if (customLeft != 0 || customRight != 0 ||
+       customBottom != 0 || customTop != 0 ||
+       doc.PageLength != doc.PageTop - doc.PageBottom ||
+       doc.PageWidth != doc.PageRight - doc.PageLeft)
+      margin_defined = 1;
+
+    if ((val = cupsGetOption("ipp-attribute-fidelity",num_options,options)) !=
+       NULL)
+    {
+      if(!strcasecmp(val, "true") || !strcasecmp(val, "yes") ||
+        !strcasecmp(val, "on"))
+       fidelity = 1;
     }
-  }
 
-  float w = (float)cfImageGetWidth(doc.img);
-  float h = (float)cfImageGetHeight(doc.img);
-  float pw = doc.PageRight-doc.PageLeft;
-  float ph = doc.PageTop-doc.PageBottom;
-  int tempOrientation = doc.Orientation;
-  if((val = cupsGetOption("orientation-requested",num_options,options))!=NULL) {
-    tempOrientation = atoi(val);
-  }
-  else if((val = cupsGetOption("landscape",num_options,options))!=NULL) {
-    if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")) {
-      tempOrientation = 4;
+    float w = (float)cfImageGetWidth(doc.img);
+    float h = (float)cfImageGetHeight(doc.img);
+    float pw = doc.PageRight - doc.PageLeft;
+    float ph = doc.PageTop - doc.PageBottom;
+    int tempOrientation = doc.Orientation;
+    if ((val = cupsGetOption("orientation-requested",
+                            num_options,options)) != NULL)
+      tempOrientation = atoi(val);
+    else if ((val = cupsGetOption("landscape", num_options,options)) != NULL)
+    {
+      if (!strcasecmp(val, "true") || !strcasecmp(val, "yes"))
+       tempOrientation = 4;
     }
-  }
-  if(tempOrientation==0) {
-    if(((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
-      tempOrientation = 4;
-  }
-  if(tempOrientation==4||tempOrientation==5) {
-    int tmp = pw;
-    pw = ph;
-    ph = tmp;
-  }
-  if (w * 72.0 / doc.img->xppi > pw || h * 72.0 / doc.img->yppi > ph)
-    document_large = 1;
-
-  if((val = cupsGetOption("print-scaling",num_options,options)) != NULL) {
-    if(!strcasecmp(val,"auto")) {
-      if(fidelity||document_large) {
-        if(margin_defined)
-          zoom = 1.0;       // fit method
-        else
-          fillprint = 1;    // fill method
-      }
-      else
-        cropfit = 1;        // none method
+    if (tempOrientation == 0)
+    {
+      if(((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
+       tempOrientation = 4;
     }
-    else if(!strcasecmp(val,"auto-fit")) {
-      if(fidelity||document_large)
-        zoom = 1.0;         // fit method
-      else
-        cropfit = 1;        // none method
+    if (tempOrientation == 4 || tempOrientation == 5)
+    {
+      int tmp = pw;
+      pw = ph;
+      ph = tmp;
     }
-    else if(!strcasecmp(val,"fill"))
-      fillprint = 1;        // fill method
-    else if(!strcasecmp(val,"fit"))
-      zoom = 1.0;           // fitplot = 1 or fit method
-    else
-      cropfit=1;            // none or crop-to-fit
-  }
-  else{       // print-scaling is not defined, look for alternate options.
+    if (w * 72.0 / doc.img->xppi > pw || h * 72.0 / doc.img->yppi > ph)
+      document_large = 1;
 
-  if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
-    zoom = atoi(val) * 0.01;
-  else if (((val =
-            cupsGetOption("fit-to-page", num_options, options)) != NULL) ||
-          ((val = cupsGetOption("fitplot", num_options, options)) != NULL))
-  {
-    if (!strcasecmp(val, "yes") || !strcasecmp(val, "on") ||
-             !strcasecmp(val, "true"))
-      zoom = 1.0;
+    if ((val = cupsGetOption("print-scaling", num_options, options)) != NULL)
+    {
+      if (!strcasecmp(val, "auto"))
+      {
+       if (fidelity || document_large)
+        {
+         if (margin_defined)
+           zoom = 1.0;       // fit method
+         else
+           fillprint = 1;    // fill method
+       }
+       else
+         cropfit = 1;        // none method
+      }
+      else if (!strcasecmp(val, "auto-fit"))
+      {
+       if (fidelity || document_large)
+         zoom = 1.0;         // fit method
+       else
+         cropfit = 1;        // none method
+      }
+      else if (!strcasecmp(val, "fill"))
+       fillprint = 1;        // fill method
+      else if (!strcasecmp(val, "fit"))
+       zoom = 1.0;           // fitplot = 1 or fit method
+      else
+       cropfit = 1;          // none or crop-to-fit
+    }
     else
-      zoom = 0.0;
-  }
-  else if ((val = cupsGetOption("natural-scaling", num_options, options)) !=
-          NULL)
-    zoom = 0.0;
+    {       // print-scaling is not defined, look for alternate options.
+      if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
+       zoom = atoi(val) * 0.01;
+      else if (((val =
+                cupsGetOption("fit-to-page", num_options, options)) != NULL) ||
+              ((val = cupsGetOption("fitplot", num_options, options)) != NULL))
+      {
+       if (!strcasecmp(val, "yes") || !strcasecmp(val, "on") ||
+           !strcasecmp(val, "true"))
+         zoom = 1.0;
+       else
+         zoom = 0.0;
+      }
+      else if ((val = cupsGetOption("natural-scaling", num_options, options)) !=
+              NULL)
+       zoom = 0.0;
 
-  if((val = cupsGetOption("fill",num_options,options))!=0) {
-    if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")) {
-      fillprint = 1;
-    }
-  }
+      if ((val = cupsGetOption("fill", num_options, options)) != 0)
+      {
+       if (!strcasecmp(val, "true") || !strcasecmp(val, "yes"))
+         fillprint = 1;
+      }
 
-  if((val = cupsGetOption("crop-to-fit",num_options,options))!= NULL){
-    if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")) {
-      cropfit=1;
+      if ((val = cupsGetOption("crop-to-fit", num_options, options)) != NULL)
+      {
+       if (!strcasecmp(val, "true") || !strcasecmp(val , "yes"))
+         cropfit = 1;
+      }
     }
-  } }
   }
-  if(fillprint||cropfit)
+  if (fillprint || cropfit)
   {
-    /* For cropfit do the math without the unprintable margins to get correct
-       centering */
+    // For cropfit do the math without the unprintable margins to get correct
+    // centering
     if (cropfit)
     {
       doc.PageBottom = 0.0;
@@ -999,25 +1043,22 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     }
     float w = (float)cfImageGetWidth(doc.img);
     float h = (float)cfImageGetHeight(doc.img);
-    float pw = doc.PageRight-doc.PageLeft;
-    float ph = doc.PageTop-doc.PageBottom;
+    float pw = doc.PageRight - doc.PageLeft;
+    float ph = doc.PageTop - doc.PageBottom;
     int tempOrientation = doc.Orientation;
     const char *val;
     int flag = 3;
-    if((val = cupsGetOption("orientation-requested",num_options,options))!=NULL)
-    {
+    if ((val = cupsGetOption("orientation-requested", num_options, options)) !=
+       NULL)
       tempOrientation = atoi(val);
-    }
-    else if((val = cupsGetOption("landscape",num_options,options))!=NULL)
+    else if((val = cupsGetOption("landscape", num_options, options)) != NULL)
     {
-      if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
-      {
+      if (!strcasecmp(val, "true") || !strcasecmp(val, "yes"))
         tempOrientation = 4;
-      }
     }
-    if(tempOrientation>0)
+    if (tempOrientation > 0)
     {
-      if(tempOrientation==4||tempOrientation==5)
+      if (tempOrientation == 4 || tempOrientation == 5)
       {
         float temp = pw;
         pw = ph;
@@ -1025,7 +1066,7 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
         flag = 4;
       }
     }
-    if(tempOrientation==0)
+    if (tempOrientation == 0)
     {
       if(((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
       {
@@ -1035,36 +1076,40 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
         flag = 4;
       }
     }
-    if(fillprint){
-      float final_w,final_h;
-      if(w*ph/pw <=h){
-        final_w =w;
-        final_h =w*ph/pw;
+    if (fillprint)
+    {
+      float final_w, final_h;
+      if (w * ph / pw <= h)
+      {
+        final_w = w;
+        final_h = w * ph / pw;
       }
-      else{
-        final_w = h*pw/ph;
+      else
+      {
+        final_w = h * pw / ph;
         final_h = h;
       }
-      float posw=(w-final_w)/2,posh=(h-final_h)/2;
-      posw = (1+doc.XPosition)*posw;
-      posh = (1-doc.YPosition)*posh;
-      cf_image_t *img2 = cfImageCrop(doc.img,posw,posh,final_w,final_h);
+      float posw = (w - final_w) / 2, posh = (h - final_h) / 2;
+      posw = (1 + doc.XPosition) * posw;
+      posh = (1 - doc.YPosition) * posh;
+      cf_image_t *img2 = cfImageCrop(doc.img, posw, posh, final_w, final_h);
       cfImageClose(doc.img);
       doc.img = img2;
     }
-    else {
-      float final_w=w,final_h=h;
+    else
+    {
+      float final_w = w, final_h = h;
       if (w > pw * doc.img->xppi / 72.0)
        final_w = pw * doc.img->xppi / 72.0;
       if (h > ph * doc.img->yppi / 72.0)
        final_h = ph * doc.img->yppi / 72.0;
-      float posw=(w-final_w)/2,posh=(h-final_h)/2;
-      posw = (1+doc.XPosition)*posw;
-      posh = (1-doc.YPosition)*posh;
-      cf_image_t *img2 = cfImageCrop(doc.img,posw,posh,final_w,final_h);
+      float posw = (w - final_w) / 2, posh = (h - final_h) / 2;
+      posw = (1 + doc.XPosition) * posw;
+      posh = (1 - doc.YPosition) * posh;
+      cf_image_t *img2 = cfImageCrop(doc.img, posw, posh, final_w, final_h);
       cfImageClose(doc.img);
       doc.img = img2;
-      if(flag==4)
+      if (flag == 4)
       {
        doc.PageBottom += (doc.PageLength - final_w * 72.0 / doc.img->xppi) / 2;
        doc.PageTop = doc.PageBottom + final_w * 72.0 / doc.img->xppi;
@@ -1078,8 +1123,8 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
        doc.PageLeft += (doc.PageWidth - final_w * 72.0 / doc.img->xppi) / 2;
        doc.PageRight = doc.PageLeft + final_w * 72.0 / doc.img->xppi;
       }
-      if(doc.PageBottom<0) doc.PageBottom = 0;
-      if(doc.PageLeft<0) doc.PageLeft = 0;
+      if (doc.PageBottom < 0) doc.PageBottom = 0;
+      if (doc.PageLeft < 0) doc.PageLeft = 0;
     }
   }
 
@@ -1097,9 +1142,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
 
   doc.colorspace = cfImageGetColorSpace(doc.img);
 
- /*
-  * Scale as necessary...
-  */
+  //
+  // Scale as necessary...
+  //
 
   if (zoom == 0.0 && xppi == 0)
   {
@@ -1116,9 +1161,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
 
   if (xppi > 0)
   {
-   /*
-    * Scale the image as neccesary to match the desired pixels-per-inch.
-    */
+    //
+    // Scale the image as neccesary to match the desired pixels-per-inch.
+    //
 
     if (doc.Orientation & 1)
     {
@@ -1151,9 +1196,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     if (cupsGetOption("orientation-requested", num_options, options) == NULL &&
         cupsGetOption("landscape", num_options, options) == NULL)
     {
-     /*
-      * Rotate the image if it will fit landscape but not portrait...
-      */
+      //
+      // Rotate the image if it will fit landscape but not portrait...
+      //
 
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterImageToPDF: Auto orientation...");
@@ -1161,9 +1206,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
       if ((doc.xinches > doc.xprint || doc.yinches > doc.yprint) &&
           doc.xinches <= doc.yprint && doc.yinches <= doc.xprint)
       {
-       /*
-       * Rotate the image as needed...
-       */
+       //
+       // Rotate the image as needed...
+       //
 
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterImageToPDF: Using landscape orientation...");
@@ -1177,9 +1222,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
   }
   else
   {
-   /*
-    * Scale percentage of page size...
-    */
+    //
+    // Scale percentage of page size...
+    //
 
     doc.xprint = (doc.PageRight - doc.PageLeft) / 72.0;
     doc.yprint = (doc.PageTop - doc.PageBottom) / 72.0;
@@ -1228,19 +1273,19 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     if (cupsGetOption("orientation-requested", num_options, options) == NULL &&
         cupsGetOption("landscape", num_options, options) == NULL)
     {
-     /*
-      * Choose the rotation with the largest area, but prefer
-      * portrait if they are equal...
-      */
+      //
+      // Choose the rotation with the largest area, but prefer
+      // portrait if they are equal...
+      //
 
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterImageToPDF: Auto orientation...");
 
       if ((doc.xsize * doc.ysize) < (doc.xsize2 * doc.xsize2))
       {
-       /*
-       * Do landscape orientation...
-       */
+       //
+       // Do landscape orientation...
+       //
 
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterImageToPDF: Using landscape orientation...");
@@ -1253,9 +1298,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
       }
       else
       {
-       /*
-       * Do portrait orientation...
-       */
+       //
+       // Do portrait orientation...
+       //
 
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterImageToPDF: Using portrait orientation...");
@@ -1287,16 +1332,16 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     }
   }
 
- /*
-  * Compute the number of pages to print and the size of the image on each
-  * page...
-  */
+  //
+  // Compute the number of pages to print and the size of the image on each
+  // page...
+  //
 
-  if (zoom == 1.0) {
-    /* If fitplot is specified, make xpages, ypages 1 forcedly.
-       Because calculation error may be caused and
-          result of ceil function may be larger than 1.
-    */
+  if (zoom == 1.0)
+  {
+    // If fitplot is specified, make xpages, ypages 1 forcedly.
+    // Because calculation error may be caused and
+    // result of ceil function may be larger than 1.
     doc.xpages = doc.ypages = 1;
   } else {
     doc.xpages = ceil(doc.xinches / doc.xprint);
@@ -1310,22 +1355,22 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
               "cfFilterImageToPDF: xpages = %dx%.2fin, ypages = %dx%.2fin",
               doc.xpages, doc.xprint, doc.ypages, doc.yprint);
 
- /*
-  * Update the page size for custom sizes...
-  */
+  //
+  // Update the page size for custom sizes...
+  //
 
   strcpy(defSize, h.cupsPageSizeName);
 
   if ((strncasecmp(defSize, "Custom", 6)) == 0 ||
       strcasestr(defSize, "_custom_"))
   {
-    float      width,          /* New width in points */
-               length;         /* New length in points */
+    float      width,          // New width in points
+               length;         // New length in points
 
 
-   /*
-    * Use the correct width and length for the current orientation...
-    */
+    //
+    // Use the correct width and length for the current orientation...
+    //
 
     if (doc.Orientation & 1)
     {
@@ -1338,16 +1383,16 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
       length = doc.yprint * 72.0;
     }
 
-   /*
-    * Add margins to page size...
-    */
+    //
+    // Add margins to page size...
+    //
 
     width += customLeft + customRight;
     length += customTop + customBottom;
 
-   /*
-    * Enforce minimums...
-    */
+    //
+    // Enforce minimums...
+    //
 
     if (width < min_width)
       width = min_width;
@@ -1359,9 +1404,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
                 "inches...",
                 width / 72.0, length / 72.0);
 
-   /*
-    * Set the new custom size...
-    */
+    //
+    // Set the new custom size...
+    //
 
     strcpy(h.cupsPageSizeName, "Custom");
 
@@ -1370,9 +1415,9 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     h.PageSize[0]     = width + 0.5;
     h.PageSize[1]     = length + 0.5;
 
-   /*
-    * Update page variables...
-    */
+    //
+    // Update page variables...
+    //
 
     doc.PageWidth  = width;
     doc.PageLength = length;
@@ -1382,13 +1427,15 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     doc.PageTop = length - customTop;
   }
 
-  if (doc.Copies == 1) {
-    /* collate is not needed */
+  if (doc.Copies == 1)
+  {
+    // collate is not needed
     doc.Collate = 0;
   }
 
-  if (!doc.Duplex) {
-    /* evenDuplex is not needed */
+  if (!doc.Duplex)
+  {
+    // evenDuplex is not needed
     doc.EvenDuplex = 0;
   }
 
@@ -1419,7 +1466,7 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
   if (deviceCopies > 1 && doc.Collate)
   {
     if ((val = cupsGetOption("hardware-collate",
-                           num_options, options)) != NULL)
+                            num_options, options)) != NULL)
     {
       // Use hardware collate according to the caller's instructions
       if (!strcasecmp(val, "true") || !strcasecmp(val, "on") ||
@@ -1441,68 +1488,69 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
 
   if (deviceCopies && doc.Collate && !deviceCollate)
   {
-    /* Copying by device , software collate is impossible */
-    /* Enable software copying */
+    // Copying by device , software collate is impossible
+    // Enable software copying
     doc.Copies = deviceCopies;
     deviceCopies = 1;
   }
 
   if (doc.Copies > 1 && deviceCopies == 1 && doc.Duplex)
   {
-    /* Enable software collate, or same pages are printed in both sides */
+    // Enable software collate, or same pages are printed in both sides
     doc.Collate = 1;
     if (deviceCollate)
       deviceCollate = 0;
   }
 
   if (doc.Duplex && doc.Collate && !deviceCollate)
-    /* Enable evenDuplex or the first page of the second copy may be
-      printed on the back side of the end of the first copy */
+    // Enable evenDuplex or the first page of the second copy may be
+    // printed on the back side of the end of the first copy
     doc.EvenDuplex = 1;
 
   if (doc.Duplex && doc.Reverse && !deviceReverse)
-    /* Enable evenDuplex or the first page may be empty. */
+    // Enable evenDuplex or the first page may be empty.
     doc.EvenDuplex = 1;
 
-  /* change feature for software */
+  // change feature for software
   if (deviceCollate)
     doc.Collate = 0;
 
-  if (deviceReverse) {
+  if (deviceReverse)
     doc.Reverse = 0;
-  }
 
- /*
-  * See if we need to collate, and if so how we need to do it...
-  */
+  //
+  // See if we need to collate, and if so how we need to do it...
+  //
 
-  if (doc.xpages == 1 && doc.ypages == 1
-      && (doc.Collate || deviceCollate) && !doc.EvenDuplex) {
-    /* collate is not needed, disable it */
+  if (doc.xpages == 1 && doc.ypages == 1 &&
+      (doc.Collate || deviceCollate) && !doc.EvenDuplex)
+  {
+    // collate is not needed, disable it
     deviceCollate = 0;
     doc.Collate = 0;
   }
 
   if (((doc.xpages*doc.ypages) % 2) == 0) {
-    /* even pages, disable EvenDuplex */
+    // even pages, disable EvenDuplex
     doc.EvenDuplex = 0;
   }
 
- /*
-  * Start sending the document with any commands needed...
-  */
+  //
+  // Start sending the document with any commands needed...
+  //
 
   if (out_prologue(&doc, doc.Copies * doc.xpages * doc.ypages +
-                 (doc.EvenDuplex ? 1 : 0)) < 0)
+                  (doc.EvenDuplex ? 1 : 0)) < 0)
     goto out_of_memory;
 
- /*
-  * Output the pages...
-  */
+  //
+  // Output the pages...
+  //
 
   doc.row = malloc(cfImageGetWidth(doc.img) * abs(doc.colorspace) + 3);
 
-  if (log) {
+  if (log)
+  {
     log(ld, CF_LOGLEVEL_DEBUG,
        "cfFilterImageToPDF: XPosition=%d, YPosition=%d, Orientation=%d",
        doc.XPosition, doc.YPosition, doc.Orientation);
@@ -1516,10 +1564,13 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
        doc.PageBottom, doc.PageTop, doc.PageLength);
   }
 
-  if (doc.Flip) {
+  if (doc.Flip)
+  {
     pr = doc.PageWidth - doc.PageLeft;
     pl = doc.PageWidth - doc.PageRight;
-  } else {
+  }
+  else
+  {
     pr = doc.PageRight;
     pl = doc.PageLeft;
   }
@@ -1647,13 +1698,13 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
     int *contentsObjs;
     int *imgObjs;
 
-    if ((contentsObjs = malloc(sizeof(int)*doc.xpages*doc.ypages)) == NULL)
+    if ((contentsObjs = malloc(sizeof(int) * doc.xpages * doc.ypages)) == NULL)
     {
       if (log) log(ld, CF_LOGLEVEL_ERROR,
                   "cfFilterImageToPDF: Can't allocate contentsObjs");
       goto out_of_memory;
     }
-    if ((imgObjs = malloc(sizeof(int)*doc.xpages*doc.ypages)) == NULL)
+    if ((imgObjs = malloc(sizeof(int) * doc.xpages * doc.ypages)) == NULL)
     {
       if (log) log(ld, CF_LOGLEVEL_ERROR,
                   "cfFilterImageToPDF: Can't allocate imgObjs");
@@ -1672,22 +1723,23 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
          goto canceled;
        }
 
-       if ((contentsObj = contentsObjs[doc.ypages*doc.xpage+doc.ypage] =
+       if ((contentsObj = contentsObjs[doc.ypages * doc.xpage + doc.ypage] =
             new_obj(&doc)) < 0)
          goto out_of_memory;
-       if ((imgObj = imgObjs[doc.ypages*doc.xpage+doc.ypage] =
+       if ((imgObj = imgObjs[doc.ypages * doc.xpage + doc.ypage] =
             new_obj(&doc)) < 0)
          goto out_of_memory;
 
-       /* out contents object */
+       // out contents object
        if (out_page_contents(&doc, contentsObj) < 0)
          goto out_of_memory;
 
-       /* out image object */
+       // out image object
        if (out_image(&doc, imgObj) < 0)
          goto out_of_memory;
       }
-    for (doc.page = 0; doc.Copies > 0 ; doc.Copies --) {
+    for (doc.page = 0; doc.Copies > 0; doc.Copies --)
+    {
       for (doc.xpage = 0; doc.xpage < doc.xpages; doc.xpage ++)
        for (doc.ypage = 0; doc.ypage < doc.ypages; doc.ypage ++, doc.page ++)
        {
@@ -1698,22 +1750,23 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
            goto canceled;
          }
 
-         /* out Page Object */
+         // out Page Object
          if (out_page_object(&doc, doc.pageObjects[doc.page],
-                           contentsObjs[doc.ypages * doc.xpage + doc.ypage],
-                           imgObjs[doc.ypages * doc.xpage + doc.ypage]) < 0)
+                             contentsObjs[doc.ypages * doc.xpage + doc.ypage],
+                             imgObjs[doc.ypages * doc.xpage + doc.ypage]) < 0)
            goto out_of_memory;
          if (pdf_printer && log)
            log(ld, CF_LOGLEVEL_CONTROL,
-               "PAGE: %d %d\n", doc.page+1, 1);
+               "PAGE: %d %d\n", doc.page + 1, 1);
        }
-      if (doc.EvenDuplex) {
-       /* out empty page */
+      if (doc.EvenDuplex)
+      {
+       // out empty page
        if (out_page_object(&doc, doc.pageObjects[doc.page], -1, -1) < 0)
          goto out_of_memory;
        if (pdf_printer && log)
          log(ld, CF_LOGLEVEL_CONTROL,
-             "PAGE: %d %d\n", doc.page+1, 1);
+             "PAGE: %d %d\n", doc.page + 1, 1);
       }
     }
     free(contentsObjs);
@@ -1740,15 +1793,15 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
        if ((contentsObj = new_obj(&doc)) < 0)
          goto out_of_memory;
 
-       /* out contents object */
+       // out contents object
        if (out_page_contents(&doc, contentsObj) < 0)
          goto out_of_memory;
 
-       /* out image object */
+       // out image object
        if (out_image(&doc, imgObj) < 0)
          goto out_of_memory;
 
-       for (p = 0;p < doc.Copies;p++, doc.page++)
+       for (p = 0; p < doc.Copies; p ++, doc.page ++)
        {
          if (iscanceled && iscanceled(icd))
          {
@@ -1757,20 +1810,21 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
            goto canceled;
          }
 
-         /* out Page Object */
+         // out Page Object
          if (out_page_object(&doc, doc.pageObjects[doc.page], contentsObj,
-                           imgObj) < 0)
+                             imgObj) < 0)
            goto out_of_memory;
          if (pdf_printer && log)
            log(ld, CF_LOGLEVEL_CONTROL,
-               "PAGE: %d %d\n", doc.page+1, 1);
+               "PAGE: %d %d\n", doc.page + 1, 1);
        }
       }
-    if (doc.EvenDuplex) {
-      /* out empty pages */
+    if (doc.EvenDuplex)
+    {
+      // out empty pages
       int p;
 
-      for (p = 0;p < doc.Copies;p++, doc.page++)
+      for (p = 0; p < doc.Copies; p++, doc.page++)
       {
        if (iscanceled && iscanceled(icd))
        {
@@ -1792,9 +1846,10 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
   out_xref(&doc);
   out_trailer(&doc);
   free_all_obj(&doc);
- /*
-  * Close files...
-  */
+
+  //
+  // Close files...
+  //
 
   cfImageClose(doc.img);
   fclose(doc.outputfp);
@@ -1812,28 +1867,29 @@ cfFilterImageToPDF(int inputfd,         /* I - File descriptor input stream */
   return (2);
 }
 
+
 #ifdef OUT_AS_HEX
-/*
- * 'out_hex()' - Print binary data as a series of hexadecimal numbers.
- */
+//
+// 'out_hex()' - Print binary data as a series of hexadecimal numbers.
+//
 
 static void
 out_hex(imagetopdf_doc_t *doc,
-       cf_ib_t *data,          /* I - Data to print */
-       int       length,               /* I - Number of bytes to print */
-       int       last_line)            /* I - Last line of raster data? */
+       cf_ib_t   *data,                // I - Data to print
+       int       length,               // I - Number of bytes to print
+       int       last_line)            // I - Last line of raster data?
 {
-  static int   col = 0;                /* Current column */
+  static int   col = 0;                // Current column
   static char  *hex = "0123456789ABCDEF";
-                                       /* Hex digits */
+                                       // Hex digits
 
 
   while (length > 0)
   {
-   /*
-    * Put the hex chars out to the file; note that we don't use printf()
-    * for speed reasons...
-    */
+    //
+    // Put the hex chars out to the file; note that we don't use printf()
+    // for speed reasons...
+    //
 
     putc_pdf(doc, hex[*data >> 4]);
     putc_pdf(doc, hex[*data & 15]);
@@ -1857,23 +1913,24 @@ out_hex(imagetopdf_doc_t *doc,
 }
 #else
 
+
 #ifdef OUT_AS_ASCII85
-/*
- * 'out_ascii85()' - Print binary data as a series of base-85 numbers.
- */
+//
+// 'out_ascii85()' - Print binary data as a series of base-85 numbers.
+//
 
 static void
 out_ascii85(imagetopdf_doc_t *doc,
-           cf_ib_t *data,              /* I - Data to print */
-           int       length,           /* I - Number of bytes to print */
-           int       last_line)        /* I - Last line of raster data? */
+           cf_ib_t   *data,            // I - Data to print
+           int       length,           // I - Number of bytes to print
+           int       last_line)        // I - Last line of raster data?
 {
-  unsigned     b;                      /* Binary data word */
-  unsigned char        c[6];                   /* ASCII85 encoded chars */
-  static int   col = 0;                /* Current column */
+  unsigned     b;                      // Binary data word
+  unsigned char        c[6];                   // ASCII85 encoded chars
+  static int   col = 0;                // Current column
 
 
-  c[5] = '\0'; /* end mark */
+  c[5] = '\0'; // end mark
   while (length > 3)
   {
     b = (((((data[0] << 8) | data[1]) << 8) | data[2]) << 8) | data[3];
@@ -1935,15 +1992,17 @@ out_ascii85(imagetopdf_doc_t *doc,
   }
 }
 #else
-/*
- * 'out_bin()' - Print binary data as binary.
- */
+
+
+//
+// 'out_bin()' - Print binary data as binary.
+//
 
 static void
 out_bin(imagetopdf_doc_t *doc,
-       cf_ib_t *data,          /* I - Data to print */
-       int       length,               /* I - Number of bytes to print */
-       int       last_line)            /* I - Last line of raster data? */
+       cf_ib_t   *data,                // I - Data to print
+       int       length,               // I - Number of bytes to print
+       int       last_line)            // I - Last line of raster data?
 {
   while (length > 0)
   {
index c45d5ea30ea1e9b809c2d859b27aceb3ecd89c46..c9ff3b0a1d7f47c4caf66696cbddb79f9b8fed23 100644 (file)
@@ -1,34 +1,34 @@
-/*
- *   Image file to raster filter function for cups-filters
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 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 "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   cfFilterImageToRaster() - The image conversion filter function
- *   blank_line()    - Clear a line buffer to the blank value...
- *   format_cmy()    - Convert image data to CMY.
- *   format_cmyk()   - Convert image data to CMYK.
- *   format_k()      - Convert image data to black.
- *   format_kcmy()   - Convert image data to KCMY.
- *   format_kcmycm() - Convert image data to KCMYcm.
- *   format_rgba()   - Convert image data to RGBA/RGBW.
- *   format_w()      - Convert image data to luminance.
- *   format_ymc()    - Convert image data to YMC.
- *   format_ymck()   - Convert image data to YMCK.
- *   make_lut()      - Make a lookup table given gamma and brightness values.
- *   raster_cb()     - Validate the page header.
- */
-
-/*
- * Include necessary headers...
- */
+//
+//   Image file to raster filter function for libcupsfilters.
+//
+//   Copyright 2007-2011 by Apple Inc.
+//   Copyright 1993-2007 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 "COPYING"
+//   which should have been included with this file.
+//
+// Contents:
+//
+//   cfFilterImageToRaster() - The image conversion filter function
+//   blank_line()    - Clear a line buffer to the blank value...
+//   format_cmy()    - Convert image data to CMY.
+//   format_cmyk()   - Convert image data to CMYK.
+//   format_k()      - Convert image data to black.
+//   format_kcmy()   - Convert image data to KCMY.
+//   format_kcmycm() - Convert image data to KCMYcm.
+//   format_rgba()   - Convert image data to RGBA/RGBW.
+//   format_w()      - Convert image data to luminance.
+//   format_ymc()    - Convert image data to YMC.
+//   format_ymck()   - Convert image data to YMCK.
+//   make_lut()      - Make a lookup table given gamma and brightness values.
+//   raster_cb()     - Validate the page header.
+//
+
+//
+// Include necessary headers...
+//
 
 #include <cupsfilters/filter.h>
 #include <cupsfilters/raster.h>
 #include <string.h>
 
 
-/*
- * Types...
- */
-
-typedef struct {                /**** Document information ****/
-  int  Flip,                   /* Flip/mirror pages */
-        XPosition,             /* Horizontal position on page */
-       YPosition,              /* Vertical position on page */
-       Collate,                /* Collate copies? */
-       Copies;                 /* Number of copies */
-  int   Orientation,           /* 0 = portrait, 1 = landscape, etc. */
-        Duplex,                /* Duplexed? */
-        Color;                 /* Print in color? */
-  float PageLeft,              /* Left margin */
-        PageRight,             /* Right margin */
-        PageBottom,            /* Bottom margin */
-        PageTop,               /* Top margin */
-        PageWidth,             /* Total page width */
-        PageLength;            /* Total page length */
-  cf_ib_t OnPixels[256],       /* On-pixel LUT */
-           OffPixels[256];     /* Off-pixel LUT */
-  cf_logfunc_t logfunc;     /* Logging function, NULL for no
-                                  logging */
-  void  *logdata;               /* User data for logging function, can
-                                  be NULL */
+//
+// Types...
+//
+
+typedef struct                  // **** Document information ****¨
+{
+  int  Flip,                   // Flip/mirror pages
+        XPosition,             // Horizontal position on page
+       YPosition,              // Vertical position on page
+       Collate,                // Collate copies?
+       Copies;                 // Number of copies
+  int   Orientation,           // 0 = portrait, 1 = landscape, etc.
+        Duplex,                // Duplexed?
+        Color;                 // Print in color?
+  float PageLeft,              // Left margin
+        PageRight,             // Right margin
+        PageBottom,            // Bottom margin
+        PageTop,               // Top margin
+        PageWidth,             // Total page width
+        PageLength;            // Total page length
+  cf_ib_t OnPixels[256],       // On-pixel LUT
+           OffPixels[256];     // Off-pixel LUT
+  cf_logfunc_t logfunc;         // Logging function, NULL for no
+                               // logging
+  void  *logdata;               // User data for logging function, can
+                               // be NULL
 } imagetoraster_doc_t;
 
 
-/*
- * Constants...
- */
+//
+// Constants...
+//
 
-int    Floyd16x16[16][16] =            /* Traditional Floyd ordered dither */
+int    Floyd16x16[16][16] =            // Traditional Floyd ordered dither
        {
          { 0,   128, 32,  160, 8,   136, 40,  168,
            2,   130, 34,  162, 10,  138, 42,  170 },
@@ -128,9 +129,9 @@ int Floyd4x4[4][4] =
        };
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 static void    blank_line(cups_page_header2_t *header, unsigned char *row);
 static void    format_cmy(imagetoraster_doc_t *doc,
@@ -173,78 +174,77 @@ static void       format_ymck(imagetoraster_doc_t *doc,
 static void    make_lut(cf_ib_t *, int, float, float);
 
 
-/*
- * 'cfFilterImageToRaster()' - Filter function to convert many common image file
- *                     formats into CUPS Raster
- */
+//
+// 'cfFilterImageToRaster()' - Filter function to convert many common image file
+//                             formats into CUPS Raster
+//
 
-int                                /* O - Error status */
-cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream */
-             int outputfd,        /* I - File descriptor output stream */
-             int inputseekable,   /* I - Is input stream seekable? (unused) */
-             cf_filter_data_t *data, /* I - Job and printer data */
-             void *parameters)    /* I - Filter-specific parameters (unused) */
+int                                        // O - Error status
+cfFilterImageToRaster(int inputfd,         // I - File descriptor input stream
+                     int outputfd,        // I - File descriptor output stream
+                     int inputseekable,   // I - Is input stream seekable?
+                     cf_filter_data_t *data, // I - Job and printer data
+                     void *parameters)    // I - Filter-specific parameters
+                                           //     (unused)
 {
-  imagetoraster_doc_t  doc;            /* Document information */
-  int                  i;              /* Looping var */
-  cf_image_t           *img;           /* Image to print */
-  float                        xprint,         /* Printable area */
+  imagetoraster_doc_t  doc;            // Document information
+  int                  i;              // Looping var
+  cf_image_t           *img;           // Image to print
+  float                        xprint,         // Printable area
                        yprint,
-                       xinches,        /* Total size in inches */
+                       xinches,        // Total size in inches
                        yinches;
-  float                        xsize,          /* Total size in points */
+  float                        xsize,          // Total size in points
                        ysize,
                        xsize2,
                        ysize2;
-  float                        aspect;         /* Aspect ratio */
-  int                  xpages,         /* # x pages */
-                       ypages,         /* # y pages */
-                       xpage,          /* Current x page */
-                       ypage,          /* Current y page */
-                       xtemp,          /* Bitmap width in pixels */
-                       ytemp,          /* Bitmap height in pixels */
-                       page;           /* Current page number */
-  int                  xc0, yc0,       /* Corners of the page in image
-                                          coords */
+  float                        aspect;         // Aspect ratio
+  int                  xpages,         // # x pages
+                       ypages,         // # y pages
+                       xpage,          // Current x page
+                       ypage,          // Current y page
+                       xtemp,          // Bitmap width in pixels
+                       ytemp,          // Bitmap height in pixels
+                       page;           // Current page number
+  int                  xc0, yc0,       // Corners of the page in image coords
                        xc1, yc1;
-  cups_cspace_t         cspace = -1;    /* CUPS color space */
-  cups_raster_t                *ras;           /* Raster stream */
-  cups_page_header2_t  header;         /* Page header */
-  int                  num_options = 0;        /* Number of print options */
-  cups_option_t                *options = NULL;        /* Print options */
-  const char           *val;           /* Option value */
-  int                  slowcollate,    /* Collate copies the slow way */
-                       slowcopies;     /* Make copies the "slow" way? */
-  float                        g;              /* Gamma correction value */
-  float                        b;              /* Brightness factor */
-  float                        zoom;           /* Zoom facter */
-  int                  xppi, yppi;     /* Pixels-per-inch */
-  int                  hue, sat;       /* Hue and saturation adjustment */
-  cf_izoom_t           *z;             /* Image zoom buffer */
-  cf_iztype_t          zoom_type;      /* Image zoom type */
-  int                  primary,        /* Primary image colorspace */
-                       secondary;      /* Secondary image colorspace */
-  cf_ib_t              *row,           /* Current row */
-                       *r0,            /* Top row */
-                       *r1;            /* Bottom row */
-  int                  y,              /* Current Y coordinate on page */
-                       iy,             /* Current Y coordinate in image */
-                       last_iy,        /* Previous Y coordinate in image */
-                       yerr0,          /* Top Y error value */
-                       yerr1;          /* Bottom Y error value */
-  cf_ib_t              lut[256];       /* Gamma/brightness LUT */
-  int                  plane,          /* Current color plane */
-                       num_planes;     /* Number of color planes */
-  char                 tempfile[1024]; /* Name of temporary file */
-  FILE                  *fp;           /* Input file */
-  int                   fd;            /* File descriptor for temp file */
+  cups_cspace_t         cspace = -1;    // CUPS color space
+  cups_raster_t                *ras;           // Raster stream
+  cups_page_header2_t  header;         // Page header
+  int                  num_options = 0;// Number of print options
+  cups_option_t                *options = NULL;// Print options
+  const char           *val;           // Option value
+  int                  slowcollate,    // Collate copies the slow way
+                       slowcopies;     // Make copies the "slow" way?
+  float                        g;              // Gamma correction value
+  float                        b;              // Brightness factor
+  float                        zoom;           // Zoom facter
+  int                  xppi, yppi;     // Pixels-per-inch
+  int                  hue, sat;       // Hue and saturation adjustment
+  cf_izoom_t           *z;             // Image zoom buffer
+  cf_iztype_t          zoom_type;      // Image zoom type
+  int                  primary,        // Primary image colorspace
+                       secondary;      // Secondary image colorspace
+  cf_ib_t              *row,           // Current row
+                       *r0,            // Top row
+                       *r1;            // Bottom row
+  int                  y,              // Current Y coordinate on page
+                       iy,             // Current Y coordinate in image
+                       last_iy,        // Previous Y coordinate in image
+                       yerr0,          // Top Y error value
+                       yerr1;          // Bottom Y error value
+  cf_ib_t              lut[256];       // Gamma/brightness LUT
+  int                  plane,          // Current color plane
+                       num_planes;     // Number of color planes
+  char                 tempfile[1024]; // Name of temporary file
+  FILE                  *fp;           // Input file
+  int                   fd;            // File descriptor for temp file
   char                  buf[BUFSIZ];
   int                   bytes;
-  cf_cm_calibration_t   cm_calibrate;   /* Are we color calibrating the
-                                          device? */
-  int                   cm_disabled = 0;/* Color management disabled? */
-  int                   fillprint = 0; /* print-scaling = fill */
-  int                   cropfit = 0;   /* -o crop-to-fit */
+  cf_cm_calibration_t   cm_calibrate;   // Are we color calibrating the device?
+  int                   cm_disabled = 0;// Color management disabled?
+  int                   fillprint = 0; // print-scaling = fill
+  int                   cropfit = 0;   // -o crop-to-fit
   cf_logfunc_t      log = data->logfunc;
   void                  *ld = data->logdata;
   cf_filter_iscanceledfunc_t iscanceled = data->iscanceledfunc;
@@ -259,21 +259,24 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
                        customRight = 0.0,
                        customTop = 0.0;
   char                         defSize[41];
-  cf_filter_out_format_t   outformat;
-
-  /* Note: With the CF_FILTER_OUT_FORMAT_APPLE_RASTER,
-     CF_FILTER_OUT_FORMAT_PWG_RASTER, or CF_FILTER_OUT_FORMAT_PCLM
-     selections the output is actually CUPS Raster but information
-     about available color spaces and depths are taken from the
-     urf-supported or pwg-raster-document-type-supported printer IPP
-     attributes (PCLM is always sRGB 8-bit). These modes are for
-     further processing with rastertopwg or pwgtopclm. This can
-     change in the future when we add Apple Raster and PWG Raster
-     output support to this filter. */
+  cf_filter_out_format_t outformat;
+
+  //
+  // Note: With the CF_FILTER_OUT_FORMAT_APPLE_RASTER,
+  // CF_FILTER_OUT_FORMAT_PWG_RASTER, or CF_FILTER_OUT_FORMAT_PCLM
+  // selections the output is actually CUPS Raster but information
+  // about available color spaces and depths are taken from the
+  // urf-supported or pwg-raster-document-type-supported printer IPP
+  // attributes (PCLM is always sRGB 8-bit). These modes are for
+  // further processing with rastertopwg or pwgtopclm. This can
+  // change in the future when we add Apple Raster and PWG Raster
+  // output support to this filter.
+  //
 
   outformat = CF_FILTER_OUT_FORMAT_CUPS_RASTER;
   val = data->final_content_type;
-  if (val) {
+  if (val)
+  {
     if (strcasestr(val, "pwg"))
       outformat = CF_FILTER_OUT_FORMAT_PWG_RASTER;
     else if (strcasestr(val, "urf"))
@@ -289,19 +292,20 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
                 (outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER ? "Apple Raster" :
                  "PCLm"))));
 
- /*
-  * Make sure status messages are not buffered...
-  */
+  //
+  // Make sure status messages are not buffered...
+  //
 
   setbuf(stderr, NULL);
 
- /*
-  * Ignore broken pipe signals...
-  */
+  //
+  // Ignore broken pipe signals...
+  //
 
   signal(SIGPIPE, SIG_IGN);
 
-  if (printer_attrs != NULL) {
+  if (printer_attrs != NULL)
+  {
     int minw, minl, maxw, maxl;
     int left, bottom, right, top;
     cfGenerateSizes(printer_attrs, CF_GEN_SIZES_DEFAULT, NULL, &ipp,
@@ -317,9 +321,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     customTop = top * 72.0 / 2540.0;
   }
 
- /*
-  * Initialize data structure
-  */
+  //
+  // Initialize data structure
+  //
 
   doc.Flip = 0;
   doc.XPosition = 0;
@@ -329,15 +333,15 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
   doc.logfunc = data->logfunc;
   doc.logdata = data->logdata;
 
- /*
-  * Option list...
-  */
+  //
+  // Option list...
+  //
 
   num_options = cfJoinJobOptionsAndAttrs(data, num_options, &options);
 
- /*
-  * Open the input data stream specified by the inputfd ...
-  */
+  //
+  // Open the input data stream specified by the inputfd ...
+  //
 
   if ((fp = fdopen(inputfd, "r")) == NULL)
   {
@@ -350,11 +354,12 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     return (1);
   }
 
- /*
-  * Copy input into temporary file if needed ...
-  */
+  //
+  // Copy input into temporary file if needed ...
+  //
 
-  if (!inputseekable) {
+  if (!inputseekable)
+  {
     if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
     {
       if (log) log(ld, CF_LOGLEVEL_ERROR,
@@ -374,9 +379,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     fclose(fp);
     close(fd);
 
-   /*
-    * Open the temporary file to read it instead of the original input ...
-    */
+    //
+    // Open the temporary file to read it instead of the original input ...
+    //
 
     if ((fp = fopen(tempfile, "r")) == NULL)
     {
@@ -391,9 +396,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     }
   }
 
- /*
-  * Process options and write the prolog...
-  */
+  //
+  // Process options and write the prolog...
+  //
 
   zoom = 1.0;
   xppi = 0;
@@ -405,9 +410,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
 
   doc.Copies = data->copies;
 
- /*
-  * Process job options...
-  */
+  //
+  // Process job options...
+  //
 
   cfRasterPrepareHeader(&header, data, outformat,
                        CF_FILTER_OUT_FORMAT_CUPS_RASTER, 1, &cspace);
@@ -455,7 +460,7 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
        "cfFilterImageToRaster: doc.PageBottom = %.1f", doc.PageBottom);
   }
 
-  /*  Find print-rendering-intent */
+  //  Find print-rendering-intent
 
   header.cupsRenderingIntent[0] = '\0';
   cfGetPrintRenderIntent(data, header.cupsRenderingIntent,
@@ -467,14 +472,14 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
   if ((val = cupsGetOption("multiple-document-handling",
                           num_options, options)) != NULL)
   {
-   /*
-    * This IPP attribute is unnecessarily complicated...
-    *
-      single-document, separate-documents-collated-copies, and
-      single-document-new-sheet all require collated copies.
-    *
-      separate-documents-collated-copies allows for uncollated copies.
-    */
+    //
+    // This IPP attribute is unnecessarily complicated...
+    //
+    //  single-document, separate-documents-collated-copies, and
+    //  single-document-new-sheet all require collated copies.
+    //
+    //  separate-documents-collated-copies allows for uncollated copies.
+    //
 
     doc.Collate = strcasecmp(val, "separate-documents-collated-copies") != 0;
   }
@@ -485,9 +490,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
 
   if ((val = cupsGetOption("gamma", num_options, options)) != NULL)
   {
-   /*
-    * Get gamma value from 1 to 10000...
-    */
+    //
+    // Get gamma value from 1 to 10000...
+    //
 
     g = atoi(val) * 0.001f;
 
@@ -499,9 +504,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
 
   if ((val = cupsGetOption("brightness", num_options, options)) != NULL)
   {
-   /*
-    * Get brightness value from 10 to 1000.
-    */
+    //
+    // Get brightness value from 10 to 1000.
+    //
 
     b = atoi(val) * 0.01f;
 
@@ -581,7 +586,8 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
       (ipp = ippFindAttribute(printer_attrs, "mirror-print-default",
                              IPP_TAG_ZERO)) != NULL)
   {
-    if (val == NULL && ipp != NULL) {
+    if (val == NULL && ipp != NULL)
+    {
       ippAttributeString(ipp, buf, sizeof(buf));
       val = buf;
     }
@@ -591,7 +597,7 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
               !strcasecmp(val, "yes")))
     doc.Flip = 1;
 
-  /* support the "cm-calibration" option */
+  // support the "cm-calibration" option
   cm_calibrate = cfCmGetCupsColorCalibrateMode(data);
 
   if (cm_calibrate == CF_CM_CALIBRATION_ENABLED)
@@ -599,9 +605,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
   else
     cm_disabled = cfCmIsPrinterCmDisabled(data);
 
- /*
-  * Choose the appropriate colorspace...
-  */
+  //
+  // Choose the appropriate colorspace...
+  //
 
   switch (header.cupsColorSpace)
   {
@@ -710,16 +716,16 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
        break;
   }
 
- /*
-  * Apply a color profile...
-  */
+  //
+  // Apply a color profile...
+  //
    
   if ((val = cupsGetOption("profile", num_options, options)) != NULL &&
       !cm_disabled)
   {
-    float         density;                /* Ink density to use */
-    float         gamma;                  /* Gamma correction to use */
-    float         matrix[3][3];           /* Transform matrix */
+    float         density;                // Ink density to use
+    float         gamma;                  // Gamma correction to use
+    float         matrix[3][3];           // Transform matrix
 
     sscanf(val, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",
            &(density), &(gamma),
@@ -745,15 +751,15 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
 
   cfImageSetRasterColorSpace(header.cupsColorSpace);
 
- /*
-  * Create a gamma/brightness LUT...
-  */
+  //
+  // Create a gamma/brightness LUT...
+  //
 
   make_lut(lut, primary, g, b);
 
- /*
-  * Open the input image to print...
-  */
+  //
+  // Open the input image to print...
+  //
 
   if (log) log(ld, CF_LOGLEVEL_INFO,
               "cfFilterImageToRaster: Loading print file.");
@@ -765,147 +771,137 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
   else
     img = cfImageOpenFP(fp, primary, secondary, sat, hue, lut);
 
-  if(img!=NULL){
-
-  int margin_defined = 0;
-  int fidelity = 0;
-  int document_large = 0;
-
-  if (customLeft != 0 || customRight != 0 ||
-      customBottom != 0 || customTop != 0 ||
-      doc.PageLength != doc.PageTop - doc.PageBottom ||
-      doc.PageWidth != doc.PageRight - doc.PageLeft)
-    margin_defined = 1;
-
-  if ((val = cupsGetOption("ipp-attribute-fidelity",
-                          num_options, options)) != NULL)
+  if (img != NULL)
   {
-    if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")||
-        !strcasecmp(val,"on"))
+    int margin_defined = 0;
+    int fidelity = 0;
+    int document_large = 0;
+
+    if (customLeft != 0 || customRight != 0 ||
+       customBottom != 0 || customTop != 0 ||
+       doc.PageLength != doc.PageTop - doc.PageBottom ||
+       doc.PageWidth != doc.PageRight - doc.PageLeft)
+      margin_defined = 1;
+
+    if ((val = cupsGetOption("ipp-attribute-fidelity",
+                            num_options, options)) != NULL)
     {
-      fidelity = 1;
+      if(!strcasecmp(val, "true") || !strcasecmp(val, "yes")||
+        !strcasecmp(val, "on"))
+       fidelity = 1;
     }
-  }
 
-  float w = (float)cfImageGetWidth(img);
-  float h = (float)cfImageGetHeight(img);
-  float pw = doc.PageRight-doc.PageLeft;
-  float ph = doc.PageTop-doc.PageBottom;
-  int tempOrientation = doc.Orientation;
-  if((val = cupsGetOption("orientation-requested",num_options,options))!=NULL)
-  {
-    tempOrientation = atoi(val);
-  }
-  else if((val = cupsGetOption("landscape",num_options,options))!=NULL)
-  {
-    if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
+    float w = (float)cfImageGetWidth(img);
+    float h = (float)cfImageGetHeight(img);
+    float pw = doc.PageRight - doc.PageLeft;
+    float ph = doc.PageTop - doc.PageBottom;
+    int tempOrientation = doc.Orientation;
+    if ((val = cupsGetOption("orientation-requested",
+                            num_options, options)) != NULL)
+      tempOrientation = atoi(val);
+    else if ((val = cupsGetOption("landscape",
+                                 num_options, options)) != NULL)
     {
-      tempOrientation = 4;
+      if (!strcasecmp(val, "true") || !strcasecmp(val, "yes"))
+       tempOrientation = 4;
     }
-  }
-  if(tempOrientation==0)
-  {
-    if(((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
+    if (tempOrientation == 0)
     {
-      tempOrientation = 4;
+      if (((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
+       tempOrientation = 4;
     }
-  }
-  if(tempOrientation==4||tempOrientation==5)
-  {
-    int tmp = pw;
-    pw = ph;
-    ph = tmp;
-  }
-  if (w * 72.0 / img->xppi > pw || h * 72.0 / img->yppi > ph)
-    document_large = 1;
+    if (tempOrientation == 4 || tempOrientation == 5)
+    {
+      int tmp = pw;
+      pw = ph;
+      ph = tmp;
+    }
+    if (w * 72.0 / img->xppi > pw || h * 72.0 / img->yppi > ph)
+      document_large = 1;
 
-  if((val = cupsGetOption("print-scaling",num_options,options)) != NULL)
-  {
-    if(!strcasecmp(val,"auto"))
+    if ((val = cupsGetOption("print-scaling", num_options, options)) != NULL)
     {
-      if(fidelity||document_large)
+      if (!strcasecmp(val, "auto"))
       {
-        if(margin_defined)
-          zoom = 1.0;       // fit method
-        else
-          fillprint = 1;    // fill method
+       if (fidelity || document_large)
+       {
+         if (margin_defined)
+           zoom = 1.0;       // fit method
+         else
+           fillprint = 1;    // fill method
+       }
+       else
+         cropfit = 1;        // none method
+      }
+      else if (!strcasecmp(val, "auto-fit"))
+      {
+       if (fidelity || document_large)
+         zoom = 1.0;         // fit method
+       else
+         cropfit = 1;        // none method
       }
+      else if (!strcasecmp(val, "fill"))
+       fillprint = 1;        // fill method
+      else if(!strcasecmp(val, "fit"))
+       zoom = 1.0;           // fitplot = 1 or fit method
       else
-        cropfit = 1;        // none method
+       cropfit=1;            // none or crop-to-fit
     }
-    else if(!strcasecmp(val,"auto-fit"))
+    else       // print-scaling is not defined, look for alternate options.
     {
-      if(fidelity||document_large)
-        zoom = 1.0;         // fit method
-      else
-        cropfit = 1;        // none method
-    }
-    else if(!strcasecmp(val,"fill"))
-      fillprint = 1;        // fill method
-    else if(!strcasecmp(val,"fit"))
-      zoom = 1.0;           // fitplot = 1 or fit method
-    else
-      cropfit=1;            // none or crop-to-fit
-  }
-  else{       // print-scaling is not defined, look for alternate options.
-    if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
-    zoom = atoi(val) * 0.01;
-  else if (((val =
-            cupsGetOption("fit-to-page", num_options, options)) != NULL) ||
-          ((val = cupsGetOption("fitplot", num_options, options)) != NULL))
-  {
-    if (!strcasecmp(val, "yes") || !strcasecmp(val, "on") ||
-       !strcasecmp(val, "true"))
-      zoom = 1.0;
-    else
-      zoom = 0.0;
-  }
-  else if ((val = cupsGetOption("natural-scaling", num_options, options))
-          != NULL)
-    zoom = 0.0;
+      if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
+       zoom = atoi(val) * 0.01;
+      else if (((val =
+                cupsGetOption("fit-to-page", num_options, options)) != NULL) ||
+              ((val = cupsGetOption("fitplot", num_options, options)) != NULL))
+      {
+       if (!strcasecmp(val, "yes") || !strcasecmp(val, "on") ||
+           !strcasecmp(val, "true"))
+         zoom = 1.0;
+       else
+         zoom = 0.0;
+      }
+      else if ((val = cupsGetOption("natural-scaling", num_options, options))
+              != NULL)
+       zoom = 0.0;
 
-  if((val = cupsGetOption("fill",num_options,options))!=0) {
-    if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
-    {
-      fillprint = 1;
-    }
-  }
-  if((val = cupsGetOption("crop-to-fit",num_options,options))!= NULL){
-    if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
-    {
-      cropfit=1;
+      if ((val = cupsGetOption("fill", num_options, options)) != NULL)
+      {
+       if (!strcasecmp(val, "true") || !strcasecmp(val, "yes"))
+         fillprint = 1;
+      }
+      if ((val = cupsGetOption("crop-to-fit", num_options, options)) != NULL)
+      {
+       if (!strcasecmp(val, "true") || !strcasecmp(val, "yes"))
+         cropfit = 1;
+      }
     }
-  } }
   }
 
-  if(img!=NULL)
+  if (img != NULL)
   {
-    if(fillprint||cropfit)
+    if (fillprint || cropfit)
     {
       float w = (float)cfImageGetWidth(img);
       float h = (float)cfImageGetHeight(img);
-      /* For cropfit do the math without the unprintable margins to get correct
-        centering, for fillprint, fill the printable area */
-      float pw = (cropfit ? doc.PageWidth : doc.PageRight-doc.PageLeft);
-      float ph = (cropfit ? doc.PageLength : doc.PageTop-doc.PageBottom);
+      // For cropfit do the math without the unprintable margins to get correct
+      // centering, for fillprint, fill the printable area
+      float pw = (cropfit ? doc.PageWidth : doc.PageRight - doc.PageLeft);
+      float ph = (cropfit ? doc.PageLength : doc.PageTop - doc.PageBottom);
       const char *val;
       int tempOrientation = doc.Orientation;
-      int flag =3;
+      int flag = 3;
       if ((val = cupsGetOption("orientation-requested",
                               num_options, options)) != NULL)
-      {
         tempOrientation = atoi(val);
-      }
-      else if((val = cupsGetOption("landscape",num_options,options))!=NULL)
+      else if ((val = cupsGetOption("landscape", num_options, options)) != NULL)
       {
-        if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
-        {
+        if(!strcasecmp(val, "true") || !strcasecmp(val, "yes"))
           tempOrientation = 4;
-        }
       }
-      if(tempOrientation>0)
+      if (tempOrientation > 0)
       {
-        if(tempOrientation==4||tempOrientation==5)
+        if (tempOrientation == 4 || tempOrientation == 5)
         {
           float temp = pw;
           pw = ph;
@@ -913,9 +909,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
           flag = 4;
         }
       }
-      if(tempOrientation==0)
+      if (tempOrientation == 0)
       {
-        if(((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
+        if (((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
         {
           int temp = pw;
           pw = ph;
@@ -923,39 +919,42 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
           flag = 4;
         }
       }
-      if(fillprint)
+      if (fillprint)
       {
         // Final width and height of cropped image.
-        float final_w,final_h;
-        if(w*ph/pw <=h){
-          final_w =w;
-          final_h =w*ph/pw; 
+        float final_w, final_h;
+        if(w * ph / pw <= h)
+       {
+          final_w = w;
+          final_h = w * ph / pw; 
         }
-        else{
-          final_w = h*pw/ph;
+        else
+       {
+          final_w = h * pw / ph;
           final_h = h;
         }
         // posw and posh are position of the cropped image along width and
        // height.
-        float posw=(w-final_w)/2,posh=(h-final_h)/2;
-        posw = (1+doc.XPosition)*posw;
-        posh = (1-doc.YPosition)*posh;
-        cf_image_t *img2 = cfImageCrop(img,posw,posh,final_w,final_h);
+        float posw = (w - final_w) / 2, posh = (h - final_h) / 2;
+        posw = (1 + doc.XPosition) * posw;
+        posh = (1 - doc.YPosition) * posh;
+        cf_image_t *img2 = cfImageCrop(img, posw, posh, final_w, final_h);
         cfImageClose(img);
         img = img2;
       }
-      else {
-        float final_w=w,final_h=h;
+      else
+      {
+        float final_w = w, final_h = h;
         if (w > pw * img->xppi / 72.0)
           final_w = pw * img->xppi / 72.0;
         if (h > ph * img->yppi / 72.0)
           final_h = ph * img->yppi / 72.0;
-       float posw=(w-final_w)/2,posh=(h-final_h)/2;
-        posw = (1+doc.XPosition)*posw;
-       posh = (1-doc.YPosition)*posh;
-       /* Check whether the unprintable margins hide away a part of the image,
-          if so, correct the image cut */
-       if(flag==4)
+       float posw = (w - final_w) / 2, posh = (h - final_h) / 2;
+        posw = (1 + doc.XPosition) * posw;
+       posh = (1 - doc.YPosition) * posh;
+       // Check whether the unprintable margins hide away a part of the image,
+       // if so, correct the image cut
+       if (flag == 4)
        {
          float margin, cutoff;
          margin = (doc.PageLength - final_w * 72.0 / img->xppi) / 2;
@@ -1019,14 +1018,15 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
          else
            final_w -= (margin - doc.PageRight) * img->xppi / 72.0;
        }
-       if(doc.PageBottom<0) doc.PageBottom = 0;
-       if(doc.PageLeft<0) doc.PageLeft = 0;
-       cf_image_t *img2 = cfImageCrop(img,posw,posh,final_w,final_h);
+       if (doc.PageBottom<0) doc.PageBottom = 0;
+       if (doc.PageLeft<0) doc.PageLeft = 0;
+       cf_image_t *img2 = cfImageCrop(img, posw, posh, final_w, final_h);
        cfImageClose(img);
        img = img2;
       }        
     }
   }
+
   if (!inputseekable)
     unlink(tempfile);
 
@@ -1037,9 +1037,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     return (1);
   }
 
- /*
-  * Scale as necessary...
-  */
+  //
+  // Scale as necessary...
+  //
 
   if (zoom == 0.0 && xppi == 0)
   {
@@ -1056,9 +1056,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
 
   if (xppi > 0)
   {
-   /*
-    * Scale the image as neccesary to match the desired pixels-per-inch.
-    */
+    //
+    // Scale the image as neccesary to match the desired pixels-per-inch.
+    //
 
     if (doc.Orientation & 1)
     {
@@ -1091,9 +1091,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     if (cupsGetOption("orientation-requested", num_options, options) == NULL &&
         cupsGetOption("landscape", num_options, options) == NULL)
     {
-     /*
-      * Rotate the image if it will fit landscape but not portrait...
-      */
+      //
+      // Rotate the image if it will fit landscape but not portrait...
+      //
 
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterImageToRaster: Auto orientation...");
@@ -1101,9 +1101,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
       if ((xinches > xprint || yinches > yprint) &&
           xinches <= yprint && yinches <= xprint)
       {
-       /*
-       * Rotate the image as needed...
-       */
+       //
+       // Rotate the image as needed...
+       //
 
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterImageToRaster: Using landscape orientation...");
@@ -1117,9 +1117,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
   }
   else
   {
-   /*
-    * Scale percentage of page size...
-    */
+    //
+    // Scale percentage of page size...
+    //
 
     xprint = (doc.PageRight - doc.PageLeft) / 72.0;
     yprint = (doc.PageTop - doc.PageBottom) / 72.0;
@@ -1161,19 +1161,19 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     if (cupsGetOption("orientation-requested", num_options, options) == NULL &&
         cupsGetOption("landscape", num_options, options) == NULL)
     {
-     /*
-      * Choose the rotation with the largest area, but prefer
-      * portrait if they are equal...
-      */
+      //
+      // Choose the rotation with the largest area, but prefer
+      // portrait if they are equal...
+      //
 
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterImageToRaster: Auto orientation...");
 
       if ((xsize * ysize) < (xsize2 * ysize2))
       {
-       /*
-       * Do landscape orientation...
-       */
+       //
+       // Do landscape orientation...
+       //
 
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterImageToRaster: Using landscape orientation...");
@@ -1186,9 +1186,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
       }
       else
       {
-       /*
-       * Do portrait orientation...
-       */
+       //
+       // Do portrait orientation...
+       //
 
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterImageToRaster: Using portrait orientation...");
@@ -1220,10 +1220,10 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     }
   }
 
- /*
-  * Compute the number of pages to print and the size of the image on each
-  * page...
-  */
+  //
+  // Compute the number of pages to print and the size of the image on each
+  // page...
+  //
 
   xpages = ceil(xinches / xprint);
   ypages = ceil(yinches / yprint);
@@ -1235,24 +1235,24 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
               "cfFilterImageToRaster: xpages = %dx%.2fin, ypages = %dx%.2fin",
               xpages, xprint, ypages, yprint);
 
- /*
-  * Compute the bitmap size...
-  */
+  //
+  // Compute the bitmap size...
+  //
 
-  /* If size if specified by user, use it, else default size from
-     printer_attrs */
+  // If size if specified by user, use it, else default size from
+  // printer_attrs
   strcpy(defSize, header.cupsPageSizeName);
 
   if ((strncasecmp(defSize, "Custom", 6)) == 0 ||
       strcasestr(defSize, "_custom_"))
   {
-    float      width,          /* New width in points */
-               length;         /* New length in points */
+    float      width,          // New width in points
+               length;         // New length in points
 
 
-   /*
-    * Use the correct width and length for the current orientation...
-    */
+    //
+    // Use the correct width and length for the current orientation...
+    //
 
     if (doc.Orientation & 1)
     {
@@ -1265,16 +1265,16 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
       length = yprint * 72.0;
     }
 
-   /*
-    * Add margins to page size...
-    */
+    //
+    // Add margins to page size...
+    //
 
     width  += customLeft + customRight;
     length += customBottom + customTop;
 
-   /*
-    * Enforce minimums...
-    */
+    //
+    // Enforce minimums...
+    //
 
     if (width < min_width)
       width = min_width;
@@ -1286,9 +1286,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
                 "inches...",
                 width / 72.0, length / 72.0);
 
-   /*
-    * Set the new custom size...
-    */
+    //
+    // Set the new custom size...
+    //
 
     strcpy(header.cupsPageSizeName, "Custom");
 
@@ -1297,9 +1297,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     header.PageSize[0]     = width + 0.5;
     header.PageSize[1]     = length + 0.5;
 
-   /*
-    * Update page variables...
-    */
+    //
+    // Update page variables...
+    //
 
     doc.PageWidth  = width;
     doc.PageLength = length;
@@ -1308,24 +1308,26 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
     doc.PageBottom = customBottom;
     doc.PageTop = length - customTop;
 
-   /*
-    * Remove margins from page size...
-    */
+    //
+    // Remove margins from page size...
+    //
 
     width -= customLeft + customRight;
     length -= customTop + customBottom;
 
-   /*
-    * Set the bitmap size...
-    */
+    //
+    // Set the bitmap size...
+    //
 
     header.cupsWidth  = width * header.HWResolution[0] / 72.0;
     header.cupsHeight = length * header.HWResolution[1] / 72.0;
 
-  } else {
-   /*
-    * Set the bitmap size...
-    */
+  }
+  else
+  {
+    //
+    // Set the bitmap size...
+    //
 
     header.cupsWidth  = (doc.Orientation & 1 ? yprint : xprint) *
       header.HWResolution[0];
@@ -1526,19 +1528,19 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
   else
     zoom_type = CF_IZOOM_FAST;
 
- /*
-  * See if we need to collate, and if so how we need to do it...
-  */
+  //
+  // See if we need to collate, and if so how we need to do it...
+  //
 
   if (xpages == 1 && ypages == 1)
     doc.Collate = 0;
 
-  /* We should also check printer-attrs here, but printer-attrs shows
-     hardware copies ("copies-supported = 1-99") and hardware collate
-     ("multiple-document-handling-supported =
-     separate-documents-uncollated-copies,
-     separate-documents-collated-copies") even on cheapest raster
-     printers */
+  // We should also check printer-attrs here, but printer-attrs shows
+  // hardware copies ("copies-supported = 1-99") and hardware collate
+  // ("multiple-document-handling-supported =
+  // separate-documents-uncollated-copies,
+  // separate-documents-collated-copies") even on cheapest raster
+  // printers
   slowcollate = doc.Collate &&
     ((val = cupsGetOption("hardware-collate", num_options, options)) == NULL ||
      !strcasecmp(val, "false") || !strcasecmp(val, "off") ||
@@ -1558,9 +1560,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
   else
     header.NumCopies = 1;
 
- /*
-  * Create the dithering lookup tables...
-  */
+  //
+  // Create the dithering lookup tables...
+  //
 
   doc.OnPixels[0]    = 0x00;
   doc.OnPixels[255]  = 0xff;
@@ -1585,11 +1587,12 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
         break;
   }
 
- /*
-  * Output the pages...
-  */
+  //
+  // Output the pages...
+  //
 
-  if (log) {
+  if (log)
+  {
     log(ld, CF_LOGLEVEL_DEBUG,
        "cfFilterImageToRaster: cupsWidth = %d", header.cupsWidth);
     log(ld, CF_LOGLEVEL_DEBUG,
@@ -1650,9 +1653,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
 
         for (plane = 0; plane < num_planes; plane ++)
        {
-        /*
-         * Initialize the image "zoom" engine...
-         */
+         //
+         // Initialize the image "zoom" engine...
+         //
 
           if (doc.Flip)
            z = _cfImageZoomNew(img, xc0, yc0, xc1, yc1, -xtemp, ytemp,
@@ -1661,9 +1664,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
            z = _cfImageZoomNew(img, xc0, yc0, xc1, yc1, xtemp, ytemp,
                                  doc.Orientation & 1, zoom_type);
 
-         /*
-         * Write leading blank space as needed...
-         */
+         //
+         // Write leading blank space as needed...
+         //
 
           if (header.cupsHeight > z->ysize && doc.YPosition <= 0)
          {
@@ -1690,9 +1693,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
             }
          }
 
-         /*
-         * Then write image data...
-         */
+         //
+         // Then write image data...
+         //
 
          for (y = z->ysize, yerr0 = 0, yerr1 = z->ysize, iy = 0, last_iy = -2;
                y > 0;
@@ -1708,9 +1711,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
               last_iy = iy;
            }
 
-           /*
-           * Format this line of raster data for the printer...
-           */
+           //
+           // Format this line of raster data for the printer...
+           //
 
            blank_line(&header, row);
 
@@ -1774,9 +1777,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
                  break;
            }
 
-           /*
-           * Write the raster data ...
-           */
+           //
+           // Write the raster data ...
+           //
 
            if (cupsRasterWritePixels(ras, row, header.cupsBytesPerLine) <
                                      header.cupsBytesPerLine)
@@ -1787,9 +1790,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
              return (1);
            }
 
-           /*
-           * Compute the next scanline in the image...
-           */
+           //
+           // Compute the next scanline in the image...
+           //
 
            iy    += z->ystep;
            yerr0 += z->ymod;
@@ -1802,9 +1805,9 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
            }
          }
 
-         /*
-         * Write trailing blank space as needed...
-         */
+         //
+         // Write trailing blank space as needed...
+         //
 
           if (header.cupsHeight > z->ysize && doc.YPosition >= 0)
          {
@@ -1831,15 +1834,17 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
             }
          }
 
-         /*
-         * Free memory used for the "zoom" engine...
-         */
+         //
+         // Free memory used for the "zoom" engine...
+         //
+
           _cfImageZoomDelete(z);
         }
       }
- /*
-  * Close files...
-  */
+
+  //
+  // Close files...
+  //
 
  canceled:
   free(row);
@@ -1851,15 +1856,15 @@ cfFilterImageToRaster(int inputfd,         /* I - File descriptor input stream *
 }
 
 
-/*
- * 'blank_line()' - Clear a line buffer to the blank value...
- */
+//
+// 'blank_line()' - Clear a line buffer to the blank value...
+//
 
 static void
-blank_line(cups_page_header2_t *header,        /* I - Page header */
-           unsigned char       *row)   /* I - Row buffer */
+blank_line(cups_page_header2_t *header,        // I - Page header
+           unsigned char       *row)   // I - Row buffer
 {
-  int  count;                          /* Remaining bytes */
+  int  count;                          // Remaining bytes
 
 
   count = header->cupsBytesPerLine;
@@ -1923,32 +1928,32 @@ blank_line(cups_page_header2_t *header, /* I - Page header */
 }
 
 
-/*
- * 'format_cmy()' - Convert image data to CMY.
- */
+//
+// 'format_cmy()' - Convert image data to CMY.
+//
 
 static void
 format_cmy(imagetoraster_doc_t *doc,
-          cups_page_header2_t *header, /* I - Page header */
-          unsigned char      *row,     /* IO - Bitmap data for device */
-          int                y,        /* I - Current row */
-          int                z,        /* I - Current plane */
-          int                xsize,    /* I - Width of image data */
-          int                 ysize,   /* I - Height of image data */
-          int                yerr0,    /* I - Top Y error */
-          int                yerr1,    /* I - Bottom Y error */
-          cf_ib_t          *r0,        /* I - Primary image data */
-          cf_ib_t          *r1)        /* I - Image data for interpolation */
+          cups_page_header2_t *header, // I - Page header
+          unsigned char       *row,    // IO - Bitmap data for device
+          int                 y,       // I - Current row
+          int                 z,       // I - Current plane
+          int                 xsize,   // I - Width of image data
+          int                 ysize,   // I - Height of image data
+          int                 yerr0,   // I - Top Y error
+          int                 yerr1,   // I - Bottom Y error
+          cf_ib_t             *r0,     // I - Primary image data
+          cf_ib_t             *r1)     // I - Image data for interpolation
 {
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               *cptr,                  /* Pointer into cyan */
-               *mptr,                  /* Pointer into magenta */
-               *yptr,                  /* Pointer into yellow */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          bandwidth;              /* Width of a color band */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
+  cf_ib_t      *ptr,                   // Pointer into row
+               *cptr,                  // Pointer into cyan
+               *mptr,                  // Pointer into magenta
+               *yptr,                  // Pointer into yellow
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          bandwidth;              // Width of a color band
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
 
 
   switch (doc->XPosition)
@@ -2299,34 +2304,34 @@ format_cmy(imagetoraster_doc_t *doc,
 }
 
 
-/*
- * 'format_cmyk()' - Convert image data to CMYK.
- */
+//
+// 'format_cmyk()' - Convert image data to CMYK.
+//
 
 static void
 format_cmyk(imagetoraster_doc_t *doc,
-           cups_page_header2_t *header,/* I - Page header */
-            unsigned char       *row,  /* IO - Bitmap data for device */
-           int                 y,      /* I - Current row */
-           int                 z,      /* I - Current plane */
-           int                 xsize,  /* I - Width of image data */
-           int                 ysize,  /* I - Height of image data */
-           int                 yerr0,  /* I - Top Y error */
-           int                 yerr1,  /* I - Bottom Y error */
-           cf_ib_t           *r0,      /* I - Primary image data */
-           cf_ib_t           *r1)      /* I - Image data for interpolation */
+           cups_page_header2_t *header,// I - Page header
+            unsigned char       *row,  // IO - Bitmap data for device
+           int                 y,      // I - Current row
+           int                 z,      // I - Current plane
+           int                 xsize,  // I - Width of image data
+           int                 ysize,  // I - Height of image data
+           int                 yerr0,  // I - Top Y error
+           int                 yerr1,  // I - Bottom Y error
+           cf_ib_t             *r0,    // I - Primary image data
+           cf_ib_t             *r1)    // I - Image data for interpolation
 {
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               *cptr,                  /* Pointer into cyan */
-               *mptr,                  /* Pointer into magenta */
-               *yptr,                  /* Pointer into yellow */
-               *kptr,                  /* Pointer into black */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          bandwidth;              /* Width of a color band */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
-  int          pc, pm, py;             /* CMY pixels */
+  cf_ib_t      *ptr,                   // Pointer into row
+               *cptr,                  // Pointer into cyan
+               *mptr,                  // Pointer into magenta
+               *yptr,                  // Pointer into yellow
+               *kptr,                  // Pointer into black
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          bandwidth;              // Width of a color band
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
+  int          pc, pm, py;             // CMY pixels
 
 
   switch (doc->XPosition)
@@ -2696,28 +2701,28 @@ format_cmyk(imagetoraster_doc_t *doc,
 }
 
 
-/*
- * 'format_K()' - Convert image data to black.
- */
+//
+// 'format_K()' - Convert image data to black.
+//
 
 static void
 format_K(imagetoraster_doc_t *doc,
-        cups_page_header2_t *header,   /* I - Page header */
-         unsigned char       *row,     /* IO - Bitmap data for device */
-        int                 y,         /* I - Current row */
-        int                 z,         /* I - Current plane */
-        int                 xsize,     /* I - Width of image data */
-        int                 ysize,     /* I - Height of image data */
-        int                 yerr0,     /* I - Top Y error */
-        int                 yerr1,     /* I - Bottom Y error */
-        cf_ib_t           *r0, /* I - Primary image data */
-        cf_ib_t           *r1) /* I - Image data for interpolation */
+        cups_page_header2_t *header,   // I - Page header
+         unsigned char       *row,     // IO - Bitmap data for device
+        int                 y,         // I - Current row
+        int                 z,         // I - Current plane
+        int                 xsize,     // I - Width of image data
+        int                 ysize,     // I - Height of image data
+        int                 yerr0,     // I - Top Y error
+        int                 yerr1,     // I - Bottom Y error
+        cf_ib_t             *r0,       // I - Primary image data
+        cf_ib_t             *r1)       // I - Image data for interpolation
 {
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
+  cf_ib_t      *ptr,                   // Pointer into row
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
 
 
   (void)z;
@@ -2816,34 +2821,34 @@ format_K(imagetoraster_doc_t *doc,
 }
 
 
-/*
- * 'format_kcmy()' - Convert image data to KCMY.
- */
+//
+// 'format_kcmy()' - Convert image data to KCMY.
+//
 
 static void
 format_kcmy(imagetoraster_doc_t *doc,
-           cups_page_header2_t *header,/* I - Page header */
-            unsigned char       *row,  /* IO - Bitmap data for device */
-           int                 y,      /* I - Current row */
-           int                 z,      /* I - Current plane */
-           int                 xsize,  /* I - Width of image data */
-           int                 ysize,  /* I - Height of image data */
-           int                 yerr0,  /* I - Top Y error */
-           int                 yerr1,  /* I - Bottom Y error */
-           cf_ib_t           *r0,      /* I - Primary image data */
-           cf_ib_t           *r1)      /* I - Image data for interpolation */
+           cups_page_header2_t *header,// I - Page header
+            unsigned char       *row,  // IO - Bitmap data for device
+           int                 y,      // I - Current row
+           int                 z,      // I - Current plane
+           int                 xsize,  // I - Width of image data
+           int                 ysize,  // I - Height of image data
+           int                 yerr0,  // I - Top Y error
+           int                 yerr1,  // I - Bottom Y error
+           cf_ib_t             *r0,    // I - Primary image data
+           cf_ib_t             *r1)    // I - Image data for interpolation
 {
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               *cptr,                  /* Pointer into cyan */
-               *mptr,                  /* Pointer into magenta */
-               *yptr,                  /* Pointer into yellow */
-               *kptr,                  /* Pointer into black */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          bandwidth;              /* Width of a color band */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
-  int          pc, pm, py;             /* CMY pixels */
+  cf_ib_t      *ptr,                   // Pointer into row
+               *cptr,                  // Pointer into cyan
+               *mptr,                  // Pointer into magenta
+               *yptr,                  // Pointer into yellow
+               *kptr,                  // Pointer into black
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          bandwidth;              // Width of a color band
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
+  int          pc, pm, py;             // CMY pixels
 
 
   switch (doc->XPosition)
@@ -3244,38 +3249,38 @@ format_kcmy(imagetoraster_doc_t *doc,
 }
 
 
-/*
- * 'format_kcmycm()' - Convert image data to KCMYcm.
- */
+//
+// 'format_kcmycm()' - Convert image data to KCMYcm.
+//
 
 static void
 format_kcmycm(
     imagetoraster_doc_t *doc,
-    cups_page_header2_t *header,       /* I - Page header */
-    unsigned char       *row,          /* IO - Bitmap data for device */
-    int                 y,             /* I - Current row */
-    int                 z,             /* I - Current plane */
-    int                 xsize,         /* I - Width of image data */
-    int                 ysize,         /* I - Height of image data */
-    int                 yerr0,         /* I - Top Y error */
-    int                 yerr1,         /* I - Bottom Y error */
-    cf_ib_t           *r0,             /* I - Primary image data */
-    cf_ib_t           *r1)             /* I - Image data for interpolation */
+    cups_page_header2_t *header,       // I - Page header
+    unsigned char       *row,          // IO - Bitmap data for device
+    int                 y,             // I - Current row
+    int                 z,             // I - Current plane
+    int                 xsize,         // I - Width of image data
+    int                 ysize,         // I - Height of image data
+    int                 yerr0,         // I - Top Y error
+    int                 yerr1,         // I - Bottom Y error
+    cf_ib_t             *r0,           // I - Primary image data
+    cf_ib_t             *r1)           // I - Image data for interpolation
 {
-  int          pc, pm, py, pk;         /* Cyan, magenta, yellow, and
-                                          black values */
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               *cptr,                  /* Pointer into cyan */
-               *mptr,                  /* Pointer into magenta */
-               *yptr,                  /* Pointer into yellow */
-               *kptr,                  /* Pointer into black */
-               *lcptr,                 /* Pointer into light cyan */
-               *lmptr,                 /* Pointer into light magenta */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          bandwidth;              /* Width of a color band */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
+  int          pc, pm, py, pk;         // Cyan, magenta, yellow, and
+                                       // black values
+  cf_ib_t      *ptr,                   // Pointer into row
+               *cptr,                  // Pointer into cyan
+               *mptr,                  // Pointer into magenta
+               *yptr,                  // Pointer into yellow
+               *kptr,                  // Pointer into black
+               *lcptr,                 // Pointer into light cyan
+               *lmptr,                 // Pointer into light magenta
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          bandwidth;              // Width of a color band
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
 
 
   switch (doc->XPosition)
@@ -3308,13 +3313,13 @@ format_kcmycm(
          pk = pc && pm && py;
 
          if (pk)
-           *ptr++ ^= 32;       /* Black */
+           *ptr++ ^= 32;       // Black
          else if (pc && pm)
-           *ptr++ ^= 17;       /* Blue (cyan + light magenta) */
+           *ptr++ ^= 17;       // Blue (cyan + light magenta)
          else if (pc && py)
-           *ptr++ ^= 6;        /* Green (light cyan + yellow) */
+           *ptr++ ^= 6;        // Green (light cyan + yellow)
          else if (pm && py)
-           *ptr++ ^= 12;       /* Red (magenta + yellow) */
+           *ptr++ ^= 12;       // Red (magenta + yellow)
          else if (pc)
            *ptr++ ^= 16;
          else if (pm)
@@ -3345,20 +3350,20 @@ format_kcmycm(
          pk = pc && pm && py;
 
          if (pk)
-           *kptr ^= bitmask;   /* Black */
+           *kptr ^= bitmask;   // Black
          else if (pc && pm)
          {
-           *cptr ^= bitmask;   /* Blue (cyan + light magenta) */
+           *cptr ^= bitmask;   // Blue (cyan + light magenta)
            *lmptr ^= bitmask;
          }
          else if (pc && py)
          {
-           *lcptr ^= bitmask;  /* Green (light cyan + yellow) */
+           *lcptr ^= bitmask;  // Green (light cyan + yellow)
            *yptr  ^= bitmask;
          }
          else if (pm && py)
          {
-           *mptr ^= bitmask;   /* Red (magenta + yellow) */
+           *mptr ^= bitmask;   // Red (magenta + yellow)
            *yptr ^= bitmask;
          }
          else if (pc)
@@ -3397,11 +3402,11 @@ format_kcmycm(
           if (pk && z == 0)
             *ptr ^= bitmask;
          else if (pc && pm && (z == 1 || z == 5))
-           *ptr ^= bitmask;    /* Blue (cyan + light magenta) */
+           *ptr ^= bitmask;    // Blue (cyan + light magenta)
          else if (pc && py && (z == 3 || z == 4))
-           *ptr ^= bitmask;    /* Green (light cyan + yellow) */
+           *ptr ^= bitmask;    // Green (light cyan + yellow)
          else if (pm && py && (z == 2 || z == 3))
-           *ptr ^= bitmask;    /* Red (magenta + yellow) */
+           *ptr ^= bitmask;    // Red (magenta + yellow)
          else if (pc && z == 1)
            *ptr ^= bitmask;
          else if (pm && z == 2)
@@ -3422,32 +3427,32 @@ format_kcmycm(
 }
 
 
-/*
- * 'format_rgba()' - Convert image data to RGBA/RGBW.
- */
+//
+// 'format_rgba()' - Convert image data to RGBA/RGBW.
+//
 
 static void
 format_rgba(imagetoraster_doc_t *doc,
-           cups_page_header2_t *header,/* I - Page header */
-            unsigned char       *row,  /* IO - Bitmap data for device */
-           int                 y,      /* I - Current row */
-           int                 z,      /* I - Current plane */
-           int                 xsize,  /* I - Width of image data */
-           int                 ysize,  /* I - Height of image data */
-           int                 yerr0,  /* I - Top Y error */
-           int                 yerr1,  /* I - Bottom Y error */
-           cf_ib_t           *r0,      /* I - Primary image data */
-           cf_ib_t           *r1)      /* I - Image data for interpolation */
+           cups_page_header2_t *header,// I - Page header
+            unsigned char       *row,  // IO - Bitmap data for device
+           int                 y,      // I - Current row
+           int                 z,      // I - Current plane
+           int                 xsize,  // I - Width of image data
+           int                 ysize,  // I - Height of image data
+           int                 yerr0,  // I - Top Y error
+           int                 yerr1,  // I - Bottom Y error
+           cf_ib_t             *r0,    // I - Primary image data
+           cf_ib_t             *r1)    // I - Image data for interpolation
 {
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               *cptr,                  /* Pointer into cyan */
-               *mptr,                  /* Pointer into magenta */
-               *yptr,                  /* Pointer into yellow */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          bandwidth;              /* Width of a color band */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
+  cf_ib_t      *ptr,                   // Pointer into row
+               *cptr,                  // Pointer into cyan
+               *mptr,                  // Pointer into magenta
+               *yptr,                  // Pointer into yellow
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          bandwidth;              // Width of a color band
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
 
 
   switch (doc->XPosition)
@@ -3824,28 +3829,28 @@ format_rgba(imagetoraster_doc_t *doc,
 }
 
 
-/*
- * 'format_w()' - Convert image data to luminance.
- */
+//
+// 'format_w()' - Convert image data to luminance.
+//
 
 static void
 format_w(imagetoraster_doc_t *doc,
-        cups_page_header2_t *header,   /* I - Page header */
-        unsigned char    *row, /* IO - Bitmap data for device */
-        int              y,            /* I - Current row */
-        int              z,            /* I - Current plane */
-        int              xsize,        /* I - Width of image data */
-        int                 ysize,     /* I - Height of image data */
-        int              yerr0,        /* I - Top Y error */
-        int              yerr1,        /* I - Bottom Y error */
-        cf_ib_t        *r0,    /* I - Primary image data */
-        cf_ib_t        *r1)    /* I - Image data for interpolation */
+        cups_page_header2_t *header,   // I - Page header
+        unsigned char    *row,         // IO - Bitmap data for device
+        int              y,            // I - Current row
+        int              z,            // I - Current plane
+        int              xsize,        // I - Width of image data
+        int              ysize,        // I - Height of image data
+        int              yerr0,        // I - Top Y error
+        int              yerr1,        // I - Bottom Y error
+        cf_ib_t          *r0,          // I - Primary image data
+        cf_ib_t          *r1)          // I - Image data for interpolation
 {
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
+  cf_ib_t      *ptr,                   // Pointer into row
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
 
 
   (void)z;
@@ -3944,32 +3949,32 @@ format_w(imagetoraster_doc_t *doc,
 }
 
 
-/*
- * 'format_ymc()' - Convert image data to YMC.
- */
+//
+// 'format_ymc()' - Convert image data to YMC.
+//
 
 static void
 format_ymc(imagetoraster_doc_t *doc,
-          cups_page_header2_t *header, /* I - Page header */
-          unsigned char      *row,     /* IO - Bitmap data for device */
-          int                y,        /* I - Current row */
-          int                z,        /* I - Current plane */
-          int                xsize,    /* I - Width of image data */
-          int                 ysize,   /* I - Height of image data */
-          int                yerr0,    /* I - Top Y error */
-          int                yerr1,    /* I - Bottom Y error */
-          cf_ib_t          *r0,        /* I - Primary image data */
-          cf_ib_t          *r1)        /* I - Image data for interpolation */
+          cups_page_header2_t *header, // I - Page header
+          unsigned char      *row,     // IO - Bitmap data for device
+          int                y,        // I - Current row
+          int                z,        // I - Current plane
+          int                xsize,    // I - Width of image data
+          int                 ysize,   // I - Height of image data
+          int                yerr0,    // I - Top Y error
+          int                yerr1,    // I - Bottom Y error
+          cf_ib_t            *r0,      // I - Primary image data
+          cf_ib_t            *r1)      // I - Image data for interpolation
 {
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               *cptr,                  /* Pointer into cyan */
-               *mptr,                  /* Pointer into magenta */
-               *yptr,                  /* Pointer into yellow */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          bandwidth;              /* Width of a color band */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
+  cf_ib_t      *ptr,                   // Pointer into row
+               *cptr,                  // Pointer into cyan
+               *mptr,                  // Pointer into magenta
+               *yptr,                  // Pointer into yellow
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          bandwidth;              // Width of a color band
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
 
 
   switch (doc->XPosition)
@@ -4335,34 +4340,34 @@ format_ymc(imagetoraster_doc_t *doc,
 }
 
 
-/*
- * 'format_ymck()' - Convert image data to YMCK.
- */
+//
+// 'format_ymck()' - Convert image data to YMCK.
+//
 
 static void
 format_ymck(imagetoraster_doc_t *doc,
-           cups_page_header2_t *header,/* I - Page header */
-            unsigned char       *row,  /* IO - Bitmap data for device */
-           int                 y,      /* I - Current row */
-           int                 z,      /* I - Current plane */
-           int                 xsize,  /* I - Width of image data */
-           int                 ysize,  /* I - Height of image data */
-           int                 yerr0,  /* I - Top Y error */
-           int                 yerr1,  /* I - Bottom Y error */
-           cf_ib_t           *r0,      /* I - Primary image data */
-           cf_ib_t           *r1)      /* I - Image data for interpolation */
+           cups_page_header2_t *header,// I - Page header
+            unsigned char       *row,  // IO - Bitmap data for device
+           int                 y,      // I - Current row
+           int                 z,      // I - Current plane
+           int                 xsize,  // I - Width of image data
+           int                 ysize,  // I - Height of image data
+           int                 yerr0,  // I - Top Y error
+           int                 yerr1,  // I - Bottom Y error
+           cf_ib_t             *r0,    // I - Primary image data
+           cf_ib_t             *r1)    // I - Image data for interpolation
 {
-  cf_ib_t      *ptr,                   /* Pointer into row */
-               *cptr,                  /* Pointer into cyan */
-               *mptr,                  /* Pointer into magenta */
-               *yptr,                  /* Pointer into yellow */
-               *kptr,                  /* Pointer into black */
-               bitmask;                /* Current mask for pixel */
-  int          bitoffset;              /* Current offset in line */
-  int          bandwidth;              /* Width of a color band */
-  int          x,                      /* Current X coordinate on page */
-               *dither;                /* Pointer into dither array */
-  int          pc, pm, py;             /* CMY pixels */
+  cf_ib_t      *ptr,                   // Pointer into row
+               *cptr,                  // Pointer into cyan
+               *mptr,                  // Pointer into magenta
+               *yptr,                  // Pointer into yellow
+               *kptr,                  // Pointer into black
+               bitmask;                // Current mask for pixel
+  int          bitoffset;              // Current offset in line
+  int          bandwidth;              // Width of a color band
+  int          x,                      // Current X coordinate on page
+               *dither;                // Pointer into dither array
+  int          pc, pm, py;             // CMY pixels
 
 
   switch (doc->XPosition)
@@ -4765,18 +4770,18 @@ format_ymck(imagetoraster_doc_t *doc,
 }
 
 
-/*
- * 'make_lut()' - Make a lookup table given gamma and brightness values.
- */
+//
+// 'make_lut()' - Make a lookup table given gamma and brightness values.
+//
 
 static void
-make_lut(cf_ib_t  *lut,                /* I - Lookup table */
-        int        colorspace,         /* I - Colorspace */
-         float      g,                 /* I - Image gamma */
-         float      b)                 /* I - Image brightness */
+make_lut(cf_ib_t    *lut,              // I - Lookup table
+        int        colorspace,         // I - Colorspace
+         float      g,                 // I - Image gamma
+         float      b)                 // I - Image brightness
 {
-  int  i;                              /* Looping var */
-  int  v;                              /* Current value */
+  int  i;                              // Looping var
+  int  v;                              // Current value
 
 
   g = 1.0 / g;