]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
CUPS backends: Code clean-up for code in backend/
authorTill Kamppeter <till.kamppeter@gmail.com>
Sat, 22 Oct 2022 14:32:45 +0000 (16:32 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sat, 22 Oct 2022 14:32:45 +0000 (16:32 +0200)
Cleaned up the code of the legacy CUPS backends 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.

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

In addition, all the file's header comments reflect the new license
now, Apache 2.0, the same license as used for CUPS.

backend/beh.c
backend/cups-brf.c
backend/implicitclass.c
backend/parallel.c
backend/serial.c

index 1bc481854a50bb331acead6a35186bac4f1a05dc..7e588c2e36c982c67324e2023311114232f25625 100644 (file)
@@ -1,23 +1,21 @@
-/*
- * beh ("Backend Error Handler") wrapper backend to extend the possibilities
- * of handling errors of backends.
- *
- * Copyright 2015 by Till Kamppeter
- *
- * This is based on dnssd.c of CUPS
- * dnssd.c copyright notice is follows:
- *
- * Copyright 2008-2015 by Apple Inc.
- *
- * 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.
- */
-
-/*
- * Include necessary headers.
- */
+//
+// beh ("Backend Error Handler") wrapper backend to extend the possibilities
+// of handling errors of backends.
+//
+// Copyright 2015 by Till Kamppeter
+//
+// This is based on dnssd.c of CUPS
+// dnssd.c copyright notice is as follows:
+//
+// Copyright 2008-2015 by Apple Inc.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers.
+//
 
 #include <config.h>
 #include <cups/cups.h>
 #include <string.h>
 #include <errno.h>
 
-/*
- * Local globals...
- */
 
-static int             job_canceled = 0; /* Set to 1 on SIGTERM */
+//
+// Local globals...
+//
 
-/*
- * Local functions...
- */
+static int             job_canceled = 0; // Set to 1 on SIGTERM
+
+
+//
+// Local functions...
+//
 
 static int             call_backend(char *uri, int argc, char **argv,
                                     char *tempfile);
 static void            sigterm_handler(int sig);
 
 
-/*
- * 'main()' - Browse for printers.
- */
+//
+// 'main()' - Browse for printers.
+//
 
-int                                    /* O - Exit status */
-main(int  argc,                                /* I - Number of command-line args */
-     char *argv[]) {                   /* I - Command-line arguments */
+int                                    // O - Exit status
+main(int  argc,                                // I - Number of command-line args
+     char *argv[])                     // I - Command-line arguments
+{
   char *uri, *ptr, *filename;
   char tmpfilename[1024], buf[8192];
   int dd, att, delay, retval;
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
-  struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+  struct sigaction action;             // Actions for POSIX signals
+#endif // HAVE_SIGACTION && !HAVE_SIGSET
 
- /*
-  * Don't buffer stderr, and catch SIGTERM...
-  */
+  //
+  // Don't buffer stderr, and catch SIGTERM...
+  //
 
   setbuf(stderr, NULL);
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
+#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs
   sigset(SIGTERM, sigterm_handler);
 #elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
@@ -74,13 +75,14 @@ main(int  argc,                             /* I - Number of command-line args */
   sigaction(SIGTERM, &action, NULL);
 #else
   signal(SIGTERM, sigterm_handler);
-#endif /* HAVE_SIGSET */
+#endif // HAVE_SIGSET
 
- /*
-  * Check command-line...
-  */
+  //
+  // Check command-line...
+  //
 
-  if (argc == 1) {
+  if (argc == 1)
+  {
     if ((ptr = strrchr(argv[0], '/')) != NULL)
       ptr ++;
     else
@@ -88,26 +90,30 @@ main(int  argc,                             /* I - Number of command-line args */
     printf("network %s \"Unknown\" \"Backend Error Handler\"\n",
           ptr);
     return (CUPS_BACKEND_OK);
-  } else if (argc < 6) {
+  }
+  else if (argc < 6)
+  {
     fprintf(stderr,
            "Usage: %s job-id user title copies options [file]\n",
            argv[0]);
     return (CUPS_BACKEND_FAILED);
   }
 
- /*
-  * Read out the parameters
-  */
+  //
+  // Read out the parameters
+  //
 
   uri = getenv("DEVICE_URI");
-  if (!uri) {
+  if (!uri)
+  {
     fprintf(stderr,
            "ERROR: No device URI supplied!");
     return (CUPS_BACKEND_FAILED);
   }
 
   ptr = strstr(uri, ":/");
-  if (!ptr) goto bad_uri;
+  if (!ptr)
+    goto bad_uri;
   ptr += 2;
   if (*ptr == '0')
     dd = 0;
@@ -116,31 +122,37 @@ main(int  argc,                           /* I - Number of command-line args */
   else
     goto bad_uri;
   ptr ++;
-  if (*ptr != '/') goto bad_uri;
+  if (*ptr != '/')
+    goto bad_uri;
   ptr ++;
   att = 0;
-  while (isdigit(*ptr)) {
+  while (isdigit(*ptr))
+  {
     att = att * 10 + (int)(*ptr) - 48;
     ptr ++;
   }
-  if (*ptr != '/') goto bad_uri;
+  if (*ptr != '/')
+    goto bad_uri;
   ptr ++;
   delay = 0;
-  while (isdigit(*ptr)) {
+  while (isdigit(*ptr))
+  {
     delay = delay * 10 + (int)(*ptr) - 48;
     ptr ++;
   }
-  if (*ptr != '/') goto bad_uri;
+  if (*ptr != '/')
+    goto bad_uri;
   ptr ++;
   fprintf(stderr,
          "DEBUG: beh: Don't disable: %d; Attempts: %d; Delay: %d; Destination URI: %s\n",
          dd, att, delay, ptr);
 
- /*
-  * If reading from stdin, write everything into a temporary file
-  */
+  //
+  // If reading from stdin, write everything into a temporary file
+  //
 
-  if (argc == 6) {
+  if (argc == 6)
+  {
     char *tmpdir;
     int fd;
     FILE *tmpfile;
@@ -151,7 +163,8 @@ main(int  argc,                             /* I - Number of command-line args */
       tmpdir = "/tmp";
     snprintf(tmpfilename, sizeof(tmpfilename), "%s/beh-XXXXXX", tmpdir);
     fd = mkstemp(tmpfilename);
-    if (fd < 0) {
+    if (fd < 0)
+    {
       fprintf(stderr,
              "ERROR: beh: Could not create temporary file: %s\n",
              strerror(errno));
@@ -163,19 +176,23 @@ main(int  argc,                           /* I - Number of command-line args */
     fclose(tmpfile);
                    
     filename = tmpfilename;
-  } else {
+  }
+  else
+  {
     tmpfilename[0] = '\0';
     filename = argv[6];
   }
 
- /*
-  * Do it!
-  */
+  //
+  // Do it!
+  //
 
   while ((retval = call_backend(ptr, argc, argv, filename)) !=
         CUPS_BACKEND_OK &&
-        !job_canceled) {
-    if (att > 0) {
+        !job_canceled)
+  {
+    if (att > 0)
+    {
       att --;
       if (att == 0)
        break;
@@ -187,18 +204,18 @@ main(int  argc,                           /* I - Number of command-line args */
   if (strlen(tmpfilename) > 0)
     unlink(tmpfilename);
 
- /*
-  * Return the exit value of the backend only if requested
-  */
+  //
+  // Return the exit value of the backend only if requested
+  //
 
   if (!dd)
     return (retval);
   else
     return (CUPS_BACKEND_OK);
 
- /*
-  * Error handling
-  */
+  //
+  // Error handling
+  //
 
  bad_uri:
 
@@ -208,25 +225,26 @@ main(int  argc,                           /* I - Number of command-line args */
 }
 
 
-/*
- * 'call_backend()' - Execute the command line of the destination backend
- */
+//
+// 'call_backend()' - Execute the command line of the destination backend
+//
 
 static int
-call_backend(char *uri,                 /* I - URI of final destination */
-            int  argc,                 /* I - Number of command line
-                                              arguments */
-            char **argv,               /* I - Command-line arguments */
-            char *filename) {          /* I - File name of input data */
-  const char   *cups_serverbin;        /* Location of programs */
-  char         scheme[1024],           /* Scheme from URI */
-                *ptr,                  /* Pointer into scheme */
-               cmdline[65536];         /* Backend command line */
+call_backend(char *uri,                 // I - URI of final destination
+            int  argc,                 // I - Number of command line
+                                       //     arguments
+            char **argv,               // I - Command-line arguments
+            char *filename)            // I - File name of input data
+{
+  const char   *cups_serverbin;        // Location of programs
+  char         scheme[1024],           // Scheme from URI
+                *ptr,                  // Pointer into scheme
+               cmdline[65536];         // Backend command line
   int           retval;
 
- /*
-  * Build the backend command line...
-  */
+  //
+  // Build the backend command line...
+  //
 
   strncpy(scheme, uri, sizeof(scheme) - 1);
   if (strlen(uri) > 1023)
@@ -237,24 +255,26 @@ call_backend(char *uri,                 /* I - URI of final destination */
   if ((cups_serverbin = getenv("CUPS_SERVERBIN")) == NULL)
     cups_serverbin = CUPS_SERVERBIN;
 
-  if (!strncasecmp(uri, "file:", 5) || uri[0] == '/') {
+  if (!strncasecmp(uri, "file:", 5) || uri[0] == '/')
+  {
     fprintf(stderr,
            "ERROR: beh: Direct output into a file not supported.\n");
     exit (CUPS_BACKEND_FAILED);
-  } else
+  }
+  else
     snprintf(cmdline, sizeof(cmdline),
             "%s/backend/%s '%s' '%s' '%s' '%s' '%s' %s",
             cups_serverbin, scheme, argv[1], argv[2], argv[3],
-            /* Apply number of copies only if beh was called with a
-               file name and not with the print data in stdin, as
-               backends should handle copies only if they are called
-               with a file name */
+            // Apply number of copies only if beh was called with a
+            // file name and not with the print data in stdin, as
+            // backends should handle copies only if they are called
+            // with a file name
             (argc == 6 ? "1" : argv[4]),
             argv[5], filename);
 
- /*
-  * Overwrite the device URI and run the actual backend...
-  */
+  //
+  // Overwrite the device URI and run the actual backend...
+  //
 
   setenv("DEVICE_URI", uri, 1);
 
@@ -275,12 +295,13 @@ call_backend(char *uri,                 /* I - URI of final destination */
 }
 
 
-/*
- * 'sigterm_handler()' - Handle termination signals.
- */
+//
+// 'sigterm_handler()' - Handle termination signals.
+//
 
 static void
-sigterm_handler(int sig) {             /* I - Signal number (unused) */
+sigterm_handler(int sig)               // I - Signal number (unused)
+{
   (void)sig;
 
   fprintf(stderr,
index 72f3c16cb4e934e36eb74d9acc536208ba65d007..eb7f7d17c1d12ba7a7f4ed42cf8cb042f514cbd0 100644 (file)
@@ -1,28 +1,11 @@
-/*
- * BRF (Braille-Ready Format) virtual backend
- *
- * Copyright (c) 2017 by Samuel Thibault <samuel.thibault@ens-lyon.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
+//
+// BRF (Braille-Ready Format) virtual backend
+//
+// Copyright (c) 2017 by Samuel Thibault <samuel.thibault@ens-lyon.org>
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #include <cups/backend.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <pwd.h>
 
-int main(int argc, char *argv[]) {
+
+int
+main(int argc,
+     char *argv[])
+{
   char *user;
   char *dir;
   char *title;
@@ -46,118 +33,139 @@ int main(int argc, char *argv[]) {
   int ret;
   int fd;
 
-  if (setuid(0)) {
-    /* We need to be root to be able to turn into another user.  */
+  if (setuid(0))
+  {
+    // We need to be root to be able to turn into another user.
     fprintf(stderr,"ERROR: cups-brf must be called as root\n");
-    return CUPS_BACKEND_FAILED;
+    return (CUPS_BACKEND_FAILED);
   }
 
-  if (argc == 1) {
-    /* This is just discovery.  */
+  if (argc == 1)
+  {
+    // This is just discovery.
     printf("file cups-brf:/ \"Virtual Braille BRF Printer\" \"CUPS-BRF\" \"MFG:Generic;MDL:CUPS-BRF Printer;DES:Generic CUPS-BRF Printer;CLS:PRINTER;CMD:BRF;\"\n");
-    return CUPS_BACKEND_OK;
+    return (CUPS_BACKEND_OK);
   }
 
-  if (argc < 6) {
-    /* Invalid number of parameters.  */
+  if (argc < 6)
+  {
+    // Invalid number of parameters.
     fprintf(stderr, "ERROR: cups-brf jobid user name nb options [filename]\n");
-    return CUPS_BACKEND_FAILED;
+    return (CUPS_BACKEND_FAILED);
   }
 
-  if (argc == 7) {
-    /* Explicit file name, open it.  */
+  if (argc == 7)
+  {
+    // Explicit file name, open it.
     char *filename = argv[6];
     fd = open(filename,  O_RDONLY);
     if (dup2(fd, STDIN_FILENO) < 0) {
       fprintf(stderr, "ERROR: opening file \"%s\"\n", filename);
-      return CUPS_BACKEND_FAILED;
+      return (CUPS_BACKEND_FAILED);
     }
   }
 
-  /* Now we have everything, turn into the user */
+  // Now we have everything, turn into the user
   user = argv[2];
   pw = getpwnam(user);
-  if (pw == NULL) {
+  if (pw == NULL)
+  {
     fprintf(stderr, "ERROR: getting user \"%s\" information\n", user);
-    return CUPS_BACKEND_FAILED;
+    return (CUPS_BACKEND_FAILED);
   }
-  if (setgid(pw->pw_gid)) {
+  if (setgid(pw->pw_gid))
+  {
     fprintf(stderr, "ERROR: turning gid into %u\n", pw->pw_gid);
-    return CUPS_BACKEND_FAILED;
+    return (CUPS_BACKEND_FAILED);
   }
-  if (setuid(pw->pw_uid)) {
+  if (setuid(pw->pw_uid))
+  {
     fprintf(stderr, "ERROR: turning uid into %u\n", pw->pw_uid);
-    return CUPS_BACKEND_FAILED;
+    return (CUPS_BACKEND_FAILED);
   }
 
-  /* Now we act as user */
+  // Now we act as user
   umask(0077);
 
-  /* Create BRF directory in $HOME */
-  if (asprintf(&dir, "%s/BRF", pw->pw_dir) < 0) {
+  // Create BRF directory in $HOME
+  if (asprintf(&dir, "%s/BRF", pw->pw_dir) < 0)
+  {
     fprintf(stderr, "ERROR: could not allocate memory\n");
-    return CUPS_BACKEND_FAILED;
+    return (CUPS_BACKEND_FAILED);
   }
   fprintf(stderr, "DEBUG: creating directory \"%s\n", dir);
   ret = mkdir(dir, 0700);
-  if (ret == -1 && errno != EEXIST) {
-    fprintf(stderr, "ERROR: could not create directory \"%s\": %s\n", dir, strerror(errno));
-    return CUPS_BACKEND_FAILED;
+  if (ret == -1 && errno != EEXIST)
+  {
+    fprintf(stderr, "ERROR: could not create directory \"%s\": %s\n",
+           dir, strerror(errno));
+    return (CUPS_BACKEND_FAILED);
   }
 
-  /* Avoid escaping from the directory */
+  // Avoid escaping from the directory
   title = argv[3];
-  for (c = title; *c; c++) {
+  for (c = title; *c; c++)
+  {
     if (*c == '/')
       *c = '_';
   }
-  /* Avoid hiding the file */
+  // Avoid hiding the file
   while (*title == '.')
     title++;
 
-  /* Avoid empty title */
+  // Avoid empty title
   if (!*title)
     title = "unknown";
 
-  /* generate mask */
-  if (asprintf(&outfile, "%s/%s.XXXXXX.brf", dir, title) < 0) {
+  // generate mask
+  if (asprintf(&outfile, "%s/%s.XXXXXX.brf", dir, title) < 0)
+  {
     fprintf(stderr, "ERROR: could not allocate memory\n");
-    return CUPS_BACKEND_FAILED;
+    return (CUPS_BACKEND_FAILED);
   }
 
-  /* Create file */
+  // Create file
   fprintf(stderr, "DEBUG: creating file \"%s\n", outfile);
   fd = mkstemps(outfile, 4);
-  if (fd < 0) {
-    fprintf(stderr, "ERROR: could not create file \"%s\": %s\n", outfile, strerror(errno));
-    return CUPS_BACKEND_FAILED;
+  if (fd < 0)
+  {
+    fprintf(stderr, "ERROR: could not create file \"%s\": %s\n",
+           outfile, strerror(errno));
+    return (CUPS_BACKEND_FAILED);
   }
 
-  /* We are all set, copy data.  */
-  while (1) {
-    /* Read some.  */
+  // We are all set, copy data.
+  while (1)
+  {
+    // Read some.
     sizein = read(STDIN_FILENO, buffer, sizeof(buffer));
-    if (sizein < 0) {
+    if (sizein < 0)
+    {
       fprintf(stderr, "ERROR: while reading input: %s\n", strerror(errno));
-      return CUPS_BACKEND_FAILED;
+      return (CUPS_BACKEND_FAILED);
     }
     if (sizein == 0)
-      /* We are done! */
+      // We are done!
       break;
 
-    /* Write it.  */
-    for (done = 0; done < sizein; done += sizeout) {
+    // Write it.
+    for (done = 0; done < sizein; done += sizeout)
+    {
       sizeout = write(fd, buffer + done, sizein - done);
-      if (sizeout < 0) {
-       fprintf(stderr, "ERROR: while writing to \"%s\": %s\n", outfile, strerror(errno));
-       return CUPS_BACKEND_FAILED;
+      if (sizeout < 0)
+      {
+       fprintf(stderr, "ERROR: while writing to \"%s\": %s\n",
+               outfile, strerror(errno));
+       return (CUPS_BACKEND_FAILED);
       }
     }
   }
-  if (close(fd) < 0) {
-    fprintf(stderr, "ERROR: while closing \"%s\": %s\n", outfile, strerror(errno));
-    return CUPS_BACKEND_FAILED;
+  if (close(fd) < 0)
+  {
+    fprintf(stderr, "ERROR: while closing \"%s\": %s\n",
+           outfile, strerror(errno));
+    return (CUPS_BACKEND_FAILED);
   }
 
-  return CUPS_BACKEND_OK;
+  return (CUPS_BACKEND_OK);
 }
index 0bf420c0742a9d7089265585fdac8d6032e2f816..757be56d8d0637d2c477e4a355863a28a034e091 100644 (file)
@@ -1,24 +1,22 @@
-/*
- * implicitclass backend for implementing an implicit-class-like behavior
- * of redundant print servers managed by cups-browsed.
- *
- * Copyright 2015-2019 by Till Kamppeter
- * Copyright 2018-2019 by Deepak Patankar
- *
- * This is based on dnssd.c of CUPS
- * dnssd.c copyright notice is follows:
- *
- * Copyright 2008-2015 by Apple Inc.
- *
- * 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.
- */
-
-/*
- * Include necessary headers.
- */
+//
+// implicitclass backend for implementing an implicit-class-like behavior
+// of redundant print servers managed by cups-browsed.
+//
+// Copyright 2015-2019 by Till Kamppeter
+// Copyright 2018-2019 by Deepak Patankar
+//
+// This is based on dnssd.c of CUPS
+// dnssd.c copyright notice is follows:
+//
+// Copyright 2008-2015 by Apple Inc.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers.
+//
 
 #include <config.h>
 #include <cups/cups.h>
 #include <ppd/ppd-filter.h>
 #include <cupsfilters/ipp.h>
 
-/*
- * Local globals...
- */
 
-/* IPP Attribute which cups-browsed uses to tell us the destination queue for
-   the current job */
-#define CUPS_BROWSED_DEST_PRINTER "cups-browsed-dest-printer"
+//
+// Local globals...
+//
 
-static int             job_canceled = 0; /* Set to 1 on SIGTERM */
+// IPP Attribute which cups-browsed uses to tell us the destination queue for
+// the current job
+#define CUPS_BROWSED_DEST_PRINTER "cups-browsed-dest-printer"
 
-/*
- * Local functions...
- */
+static int             job_canceled = 0; // Set to 1 on SIGTERM
 
-static void            sigterm_handler(int sig);
 
-#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
-#define HAVE_CUPS_1_6 1
-#endif
-
-#ifndef HAVE_CUPS_1_6
-int
-ippGetInteger(ipp_attribute_t *attr,
-              int             element)
-{
-  return (attr->values[element].integer);
-}
-#endif
+//
+// Local functions...
+//
 
+static void            sigterm_handler(int sig);
 
-int                             /* O  - Next delay value */
-next_delay(int current,         /* I  - Current delay value or 0 */
-           int *previous)       /* IO - Previous delay value */
-{
-  int next;          /* Next delay value */
-  if (current > 0) {
-    next      = (current + *previous) % 12;
-    *previous = next < current ? 0 : current;
-  } else {
-    next      = 1;
-    *previous = 0;
-  }
-  return (next);
-}
 
-/*
- * 'main()' - Browse for printers.
- */
+//
+// 'main()' - Browse for printers.
+//
 
-int                                    /* O - Exit status */
-main(int  argc,                                /* I - Number of command-line args */
-     char *argv[])                     /* I - Command-line arguments */
+int                                    // O - Exit status
+main(int  argc,                                // I - Number of command-line args
+     char *argv[])                     // I - Command-line arguments
 {
-  const char   *device_uri;            /* URI with which we were called */
+  const char   *device_uri;            // URI with which we were called
   char scheme[64], username[32], queue_name[1024], resource[32],
-       printer_uri[1024],document_format[256],resolution[16];
+       printer_uri[1024], document_format[256], resolution[16];
   int port, status;
   const char *ptr1 = NULL;
-  char *ptr2,*ptr3,*ptr4;
+  char *ptr2, *ptr3, *ptr4;
   const char *job_id;
   int i;
-  char dest_host[1024];        /* Destination host */
+  char dest_host[1024];        // Destination host
   ipp_t *request, *response;
   ipp_attribute_t *attr;
   char uri[HTTP_MAX_URI];
@@ -104,16 +76,16 @@ main(int  argc,                            /* I - Number of command-line args */
                   "printer-defaults"
                 };
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
-  struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+  struct sigaction action;             // Actions for POSIX signals
+#endif // HAVE_SIGACTION && !HAVE_SIGSET
 
- /*
-  * Don't buffer stderr, and catch SIGTERM...
-  */
+  //
+  // Don't buffer stderr, and catch SIGTERM...
+  //
 
   setbuf(stderr, NULL);
 
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
+#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs
   sigset(SIGTERM, sigterm_handler);
 #elif defined(HAVE_SIGACTION)
   memset(&action, 0, sizeof(action));
@@ -123,14 +95,16 @@ main(int  argc,                            /* I - Number of command-line args */
   sigaction(SIGTERM, &action, NULL);
 #else
   signal(SIGTERM, sigterm_handler);
-#endif /* HAVE_SIGSET */
+#endif // HAVE_SIGSET
 
- /*
-  * Check command-line...
-  */
+  //
+  // Check command-line...
+  //
 
-  if (argc >= 6) {
-    if ((device_uri = getenv("DEVICE_URI")) == NULL) {
+  if (argc >= 6)
+  {
+    if ((device_uri = getenv("DEVICE_URI")) == NULL)
+    {
       if (!argv || !argv[0] || !strchr(argv[0], ':'))
        return (-1);
 
@@ -143,7 +117,8 @@ main(int  argc,                             /* I - Number of command-line args */
                             &port,
                             resource, sizeof(resource));
     if (status != HTTP_URI_STATUS_OK &&
-       status != HTTP_URI_STATUS_UNKNOWN_SCHEME) {
+       status != HTTP_URI_STATUS_UNKNOWN_SCHEME)
+    {
       fprintf(stderr, "ERROR: Incorrect device URI syntax: %s\n",
              device_uri);
       return (CUPS_BACKEND_STOP);
@@ -151,10 +126,11 @@ main(int  argc,                           /* I - Number of command-line args */
     httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
                     "localhost", ippPort(), "/printers/%s", queue_name);
     job_id = argv[1];
-    for (i = 0; i < 120; i++) {
-      /* Wait up to 60 sec for cups-browsed to supply the destination host */
-      /* Try reading the option in which cups-browsed has deposited the
-        destination host */
+    for (i = 0; i < 120; i++)
+    {
+      // Wait up to 60 sec for cups-browsed to supply the destination host
+      // Try reading the option in which cups-browsed has deposited the
+      // destination host
       request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
       ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
                   uri);
@@ -169,14 +145,16 @@ main(int  argc,                           /* I - Number of command-line args */
          NULL)
        goto failed;
       for (attr = ippFirstAttribute(response); attr != NULL;
-          attr = ippNextAttribute(response)) {
+          attr = ippNextAttribute(response))
+      {
        while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER)
          attr = ippNextAttribute(response);
        if (attr == NULL)
          break;
        ptr1 = NULL;
        while (attr != NULL && ippGetGroupTag(attr) ==
-              IPP_TAG_PRINTER) {
+              IPP_TAG_PRINTER)
+       {
          if (!strcmp(ippGetName(attr),
                      CUPS_BROWSED_DEST_PRINTER "-default"))
            ptr1 = ippGetString(attr, 0, NULL);
@@ -191,50 +169,59 @@ main(int  argc,                           /* I - Number of command-line args */
              (ptr1 ? ptr1 : "Option not found"));
       if (ptr1 == NULL)
        goto failed;
-      /* Destination host is between double quotes, as double quotes are
-        illegal in host names one easily recognizes whether the option is
-        complete and avoids accepting a partially written host name */
+      // Destination host is between double quotes, as double quotes are
+      // illegal in host names one easily recognizes whether the option is
+      // complete and avoids accepting a partially written host name
       if (*ptr1 != '"')
        goto failed;
       ptr1 ++;
-      /* Check whether option was set for this job, if not, keep waiting */
+      // Check whether option was set for this job, if not, keep waiting
       if (strncmp(ptr1, job_id, strlen(job_id)) != 0)
        goto failed;
       ptr1 += strlen(job_id);
       if (*ptr1 != ' ')
        goto failed;
       ptr1 ++;
-      /* Read destination host name (or message) and check whether it is
-        complete (second double quote) */
-      if ((ptr2 = strchr(ptr1, '"')) != NULL) {
+      // Read destination host name (or message) and check whether it is
+      // complete (second double quote)
+      if ((ptr2 = strchr(ptr1, '"')) != NULL)
+      {
        *ptr2 = '\0';
        break;
       }
     failed:
-      /* Pause half a second before next attempt */
+      // Pause half a second before next attempt
       usleep(500000);
     }
 
-    if (i >= 120) {
-      /* Timeout, no useful data from cups-browsed received */
+    if (i >= 120)
+    {
+      // Timeout, no useful data from cups-browsed received
       fprintf(stderr, "ERROR: No destination host name supplied by cups-browsed for printer \"%s\", is cups-browsed running?\n",
              queue_name);
       return (CUPS_BACKEND_STOP);
     }
-    strncpy(dest_host,ptr1,sizeof(dest_host) - 1);
-    if (!strcmp(dest_host, "NO_DEST_FOUND")) {
-      /* All remote queues are either disabled or not accepting jobs, let
-        CUPS retry after the usual interval */
-      fprintf(stderr, "ERROR: No suitable destination host found by cups-browsed.\n");
+    strncpy(dest_host, ptr1, sizeof(dest_host) - 1);
+    if (!strcmp(dest_host, "NO_DEST_FOUND"))
+    {
+      // All remote queues are either disabled or not accepting jobs, let
+      // CUPS retry after the usual interval
+      fprintf(stderr,
+             "ERROR: No suitable destination host found by cups-browsed.\n");
       return (CUPS_BACKEND_RETRY);
-    } else if (!strcmp(dest_host, "ALL_DESTS_BUSY")) {
-      /* We queue on the client and all remote queues are busy, so we wait
-        5 sec  and check again then */
-      fprintf(stderr, "DEBUG: No free destination host found by cups-browsed, retrying in 5 sec.\n");
+    }
+    else if (!strcmp(dest_host, "ALL_DESTS_BUSY"))
+    {
+      // We queue on the client and all remote queues are busy, so we wait
+      // 5 sec  and check again then
+      fprintf(stderr,
+             "DEBUG: No free destination host found by cups-browsed, retrying in 5 sec.\n");
       sleep(5);
       return (CUPS_BACKEND_RETRY_CURRENT);
-    } else {
-      /* We have the destination host name now, do the job */
+    }
+    else
+    {
+      // We have the destination host name now, do the job
       char *title;
       int num_options = 0;
       cups_option_t *options = NULL;
@@ -243,24 +230,28 @@ main(int  argc,                           /* I - Number of command-line args */
       cf_filter_universal_parameter_t universal_parameters;
       cf_filter_external_t ipp_backend_params;
       cf_filter_filter_in_chain_t universal_in_chain,
-                              ipp_in_chain;
+                                 ipp_in_chain;
       cups_array_t *filter_chain;
       int retval;
 
-      fprintf(stderr, "DEBUG: Received destination host name from cups-browsed: printer-uri %s\n",
+      fprintf(stderr,
+             "DEBUG: Received destination host name from cups-browsed: printer-uri %s\n",
              ptr1);
 
-      /* Parse the command line options and prepare them for the new print
-        job */
+      // Parse the command line options and prepare them for the new print
+      // job
       cupsSetUser(argv[2]);
       title = argv[3];
-      if (title == NULL) {
-       if (argc == 7) {
+      if (title == NULL)
+      {
+       if (argc == 7)
+       {
          if ((title = strrchr(argv[6], '/')) != NULL)
            title ++;
          else
            title = argv[6];
-       } else
+       }
+       else
          title = "(stdin)";
       }
       num_options = cupsAddOption("copies", argv[4], num_options, &options);
@@ -268,18 +259,20 @@ main(int  argc,                           /* I - Number of command-line args */
       if (argc == 7)
        fd = open(argv[6], O_RDONLY);
       else
-       fd = 0; /* stdin */
+       fd = 0; // stdin
 
-      /* Finding the document format in which the pdftoippprinter will
-        convert the pdf file */
-      if ((ptr3 = strchr(ptr1, ' ')) != NULL) {
-       *ptr3='\0';
+      // Finding the document format in which the pdftoippprinter will
+      // convert the pdf file
+      if ((ptr3 = strchr(ptr1, ' ')) != NULL)
+      {
+       *ptr3 = '\0';
        ptr3++;
       }
 
-      /* Finding the resolution requested for the job */
-      if ((ptr4 = strchr(ptr3, ' ')) != NULL) {
-       *ptr4='\0';
+      // Finding the resolution requested for the job
+      if ((ptr4 = strchr(ptr3, ' ')) != NULL)
+      {
+       *ptr4 = '\0';
        ptr4++;
       }
 
@@ -287,10 +280,11 @@ main(int  argc,                           /* I - Number of command-line args */
       strncpy(document_format, ptr3, sizeof(document_format) - 1);
       strncpy(resolution, ptr4, sizeof(resolution) - 1);
 
-      fprintf(stderr,"DEBUG: Received job for the printer with the destination uri - %s, Final-document format for the printer - %s and requested resolution - %s\n",
+      fprintf(stderr,
+             "DEBUG: Received job for the printer with the destination uri - %s, Final-document format for the printer - %s and requested resolution - %s\n",
              printer_uri, document_format, resolution);
 
-      /* Adjust option list for the cfFilterUniversal() filter function call */
+      // Adjust option list for the cfFilterUniversal() filter function call
       num_options = cupsAddOption("Resolution", resolution,
                                  num_options, &options);
       num_options = cupsRemoveOption("cups-browsed-dest-printer",
@@ -298,8 +292,8 @@ main(int  argc,                             /* I - Number of command-line args */
       num_options = cupsRemoveOption("cups-browsed",
                                     num_options, &options);
 
-      /* Set up filter data record to be used by the filter functions to
-        process the job */
+      // Set up filter data record to be used by the filter functions to
+      // process the job
       filter_data.printer = printer_uri;
       filter_data.job_id = atoi(argv[1]);
       filter_data.job_user = argv[2];
@@ -307,52 +301,53 @@ main(int  argc,                           /* I - Number of command-line args */
       filter_data.copies = atoi(argv[4]);
       filter_data.content_type = "application/vnd.cups-pdf";
       filter_data.final_content_type = document_format;
-      filter_data.job_attrs = NULL;        /* We use command line options */
+      filter_data.job_attrs = NULL;        // We use command line options
       filter_data.printer_attrs =
        cfGetPrinterAttributes4(printer_uri, NULL, 0, NULL, 0, 1, 0);
-                                           /* Poll the printer attributes from
-                                             the printer */
+                                           // Poll the printer attributes from
+                                          // the printer
       filter_data.num_options = num_options;
-      filter_data.options = options;       /* Command line options from 5th
-                                             arg */
+      filter_data.options = options;       // Command line options from 5th
+                                          // arg
       filter_data.extension = NULL;
       filter_data.back_pipe[0] = -1;
       filter_data.back_pipe[1] = -1;
       filter_data.side_pipe[0] = -1;
       filter_data.side_pipe[1] = -1;
-      filter_data.logfunc = cfCUPSLogFunc;  /* Logging scheme of CUPS */
+      filter_data.logfunc = cfCUPSLogFunc;  // Logging scheme of CUPS
       filter_data.logdata = NULL;
-      filter_data.iscanceledfunc = cfCUPSIsCanceledFunc; /* Job-is-canceled
-                                                          function */
+      filter_data.iscanceledfunc = cfCUPSIsCanceledFunc; // Job-is-canceled
+                                                        // function
       filter_data.iscanceleddata = &job_canceled;
 
-      /* If the polling of the printer's IPP attributes has failed, it
-        means most probably that it is not a driverless IPP printer
-        (IPP 2.x) but a legacy IPP printer (IPP 1.x) which usually
-        has unsufficient capability info. Therefore we fall back to
-        the PPD file here which contains some info from the printer's
-        DNS-SD record.
-
-         If we have successfully polled the IPP attributes from the
-        printer, these attributes are the most precise printer
-        capability info and as the queue's PPD is only for the
-        cluster we prefer the IPP attributes. */
+      // If the polling of the printer's IPP attributes has failed, it
+      // means most probably that it is not a driverless IPP printer
+      // (IPP 2.x) but a legacy IPP printer (IPP 1.x) which usually
+      // has unsufficient capability info. Therefore we fall back to
+      // the PPD file here which contains some info from the printer's
+      // DNS-SD record.
+      //
+      // If we have successfully polled the IPP attributes from the
+      // printer, these attributes are the most precise printer
+      // capability info and as the queue's PPD is only for the
+      // cluster we prefer the IPP attributes.
       if (filter_data.printer_attrs == NULL &&
          ppdFilterLoadPPDFile(&filter_data, getenv("PPD")) < 0)
       {
        ippDelete(response);
-       fprintf(stderr, "ERROR: Unable to get sufficient capability info of the destination printer.\n");
+       fprintf(stderr,
+               "ERROR: Unable to get sufficient capability info of the destination printer.\n");
        return (CUPS_BACKEND_FAILED);
       }
 
       cfFilterOpenBackAndSidePipes(&filter_data);
 
-      /* Parameters for cfFilterUniversal() call */
+      // Parameters for cfFilterUniversal() call
       universal_parameters.actual_output_type = NULL;
       memset(&(universal_parameters.texttopdf_params), 0,
             sizeof(cf_filter_texttopdf_parameter_t));
 
-      /* Parameters for cfFilterExternalCUPS() call for IPP backend */
+      // Parameters for cfFilterExternalCUPS() call for IPP backend
       ipp_backend_params.filter = "ipp";
       ipp_backend_params.exec_mode = 1;
       ipp_backend_params.num_options = 0;
@@ -360,12 +355,12 @@ main(int  argc,                           /* I - Number of command-line args */
       ipp_backend_params.envp = NULL;
       cfFilterAddEnvVar("DEVICE_URI", printer_uri, &ipp_backend_params.envp);
 
-      /* Filter chain entry for the ppdFilterUniversal() filter function call */
+      // Filter chain entry for the ppdFilterUniversal() filter function call
       universal_in_chain.function = ppdFilterUniversal;
       universal_in_chain.parameters = &universal_parameters;
       universal_in_chain.name = "Filters";
 
-      /* Filter chain entry for the IPP CUPS backend call */
+      // Filter chain entry for the IPP CUPS backend call
       ipp_in_chain.function = ppdFilterExternalCUPS;
       ipp_in_chain.parameters = &ipp_backend_params;
       ipp_in_chain.name = "Backend";
@@ -374,23 +369,23 @@ main(int  argc,                           /* I - Number of command-line args */
       cupsArrayAdd(filter_chain, &universal_in_chain);
       cupsArrayAdd(filter_chain, &ipp_in_chain);
 
-      /* DEVICE_URI environment variable */
+      // DEVICE_URI environment variable
       setenv("DEVICE_URI", printer_uri, 1);
 
-      /* FINAL_CONTENT_TYPE environment variable */
+      // FINAL_CONTENT_TYPE environment variable
       setenv("FINAL_CONTENT_TYPE", document_format, 1);
 
-      /* We call the IPP CUPS backend at the end of the chain, so we have
-        no output */
+      // We call the IPP CUPS backend at the end of the chain, so we have
+      // no output
       nullfd = open("/dev/null", O_WRONLY);
 
-      /* Call the filter chain to run the needed filters and the backend */
+      // Call the filter chain to run the needed filters and the backend
       retval = cfFilterChain(fd, nullfd, fd != 0 ? 1 : 0, &filter_data,
                             filter_chain);
 
       cfFilterCloseBackAndSidePipes(&filter_data);
 
-      /* Clean up */
+      // Clean up
       if (ipp_backend_params.envp)
       {
        for (i = 0; ipp_backend_params.envp[i]; i ++)
@@ -402,32 +397,35 @@ main(int  argc,                           /* I - Number of command-line args */
 
       ppdFilterFreePPDFile(&filter_data);
 
-      if (retval) {
+      if (retval)
+      {
        fprintf(stderr, "ERROR: Job processing failed.\n");
        return (CUPS_BACKEND_FAILED);
       }
     }
-  } else if (argc != 1) {
+  }
+  else if (argc != 1)
+  {
     fprintf(stderr,
            "Usage: %s job-id user title copies options [file]\n",
            argv[0]);
     return (CUPS_BACKEND_FAILED);
   }
 
- /*
-  * No discovery mode at all for this backend
-  */
+  //
+  // No discovery mode at all for this backend
+  //
 
   return (CUPS_BACKEND_OK);
 }
 
 
-/*
- * 'sigterm_handler()' - Handle termination signals.
- */
+//
+// 'sigterm_handler()' - Handle termination signals.
+//
 
 static void
-sigterm_handler(int sig)               /* I - Signal number (unused) */
+sigterm_handler(int sig)               // I - Signal number (unused)
 {
   (void)sig;
 
index 6fc76211933e65659e6cb79426f58b0346c29da9..88ba7aec1a3966a9da2f6da9459074d71f830383 100644 (file)
@@ -1,26 +1,24 @@
-/*
- *   Parallel port backend 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:
- *
- *   main()         - Send a file to the specified parallel port.
- *   drain_output() - Drain pending print data to the device.
- *   list_devices() - List all parallel devices.
- *   run_loop()     - Read and write print and back-channel data.
- *   side_cb()      - Handle side-channel requests...
- */
-
-/*
- * Include necessary headers.
- */
+//
+// Parallel port backend for cups-filters.
+//
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
+// Contents:
+//
+//   main()         - Send a file to the specified parallel port.
+//   drain_output() - Drain pending print data to the device.
+//   list_devices() - List all parallel devices.
+//   run_loop()     - Read and write print and back-channel data.
+//   side_cb()      - Handle side-channel requests...
+//
+
+//
+// Include necessary headers.
+//
 
 #include <cupsfilters/ieee1284.h>
 #include <unistd.h>
@@ -30,9 +28,9 @@
 #include <sys/socket.h>
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 static int     drain_output(int print_fd, int device_fd);
 static void    list_devices(void);
@@ -41,44 +39,45 @@ static ssize_t      run_loop(int print_fd, int device_fd, int use_bc,
 static int     side_cb(int print_fd, int device_fd, int use_bc);
 
 
-/*
- * 'main()' - Send a file to the specified parallel port.
- *
- * Usage:
- *
- *    printer-uri job-id user title copies options [file]
- */
+//
+// 'main()' - Send a file to the specified parallel port.
+//
+// Usage:
+//
+//    printer-uri job-id user title copies options [file]
+//
 
-int                                    /* O - Exit status */
-main(int  argc,                                /* I - Number of command-line arguments (6 or 7) */
-     char *argv[])                     /* I - Command-line arguments */
+int                                    // O - Exit status
+main(int  argc,                                // I - Number of command-line arguments
+                                        //     (6 or 7)
+     char *argv[])                     // I - Command-line arguments
 {
-  char         method[255],            /* Method in URI */
-               hostname[1024],         /* Hostname */
-               username[255],          /* Username info (not used) */
-               resource[1024],         /* Resource info (device and options) */
-               *options;               /* Pointer to options */
-  int          port;                   /* Port number (not used) */
-  int          print_fd,               /* Print file */
-               device_fd,              /* Parallel device */
-               use_bc;                 /* Read back-channel data? */
-  int          copies;                 /* Number of copies to print */
-  ssize_t      tbytes;                 /* Total number of bytes written */
-  struct termios opts;                 /* Parallel port options */
+  char         method[255],            // Method in URI
+               hostname[1024],         // Hostname
+               username[255],          // Username info (not used)
+               resource[1024],         // Resource info (device and options)
+               *options;               // Pointer to options
+  int          port;                   // Port number (not used)
+  int          print_fd,               // Print file
+               device_fd,              // Parallel device
+               use_bc;                 // Read back-channel data?
+  int          copies;                 // Number of copies to print
+  ssize_t      tbytes;                 // Total number of bytes written
+  struct termios opts;                 // Parallel port options
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
-  struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+  struct sigaction action;             // Actions for POSIX signals
+#endif // HAVE_SIGACTION && !HAVE_SIGSET
 
 
- /*
-  * Make sure status messages are not buffered...
-  */
+  //
+  // Make sure status messages are not buffered...
+  //
 
   setbuf(stderr, NULL);
 
- /*
-  * Ignore SIGPIPE signals...
-  */
+  //
+  // Ignore SIGPIPE signals...
+  //
 
 #ifdef HAVE_SIGSET
   sigset(SIGPIPE, SIG_IGN);
@@ -88,11 +87,11 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   sigaction(SIGPIPE, &action, NULL);
 #else
   signal(SIGPIPE, SIG_IGN);
-#endif /* HAVE_SIGSET */
+#endif // HAVE_SIGSET
 
- /*
-  * Check command-line...
-  */
+  //
+  // Check command-line...
+  //
 
   if (argc == 1)
   {
@@ -106,10 +105,10 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
     return (CUPS_BACKEND_FAILED);
   }
 
- /*
-  * If we have 7 arguments, print the file named on the command-line.
-  * Otherwise, send stdin instead...
-  */
+  //
+  // If we have 7 arguments, print the file named on the command-line.
+  // Otherwise, send stdin instead...
+  //
 
   if (argc == 6)
   {
@@ -118,9 +117,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   }
   else
   {
-   /*
-    * Try to open the print file...
-    */
+    //
+    // Try to open the print file...
+    //
 
     if ((print_fd = open(argv[6], O_RDONLY)) < 0)
     {
@@ -131,42 +130,42 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
     copies = atoi(argv[4]);
   }
 
- /*
-  * Extract the device name and options from the URI...
-  */
+  //
+  // Extract the device name and options from the URI...
+  //
 
   httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
                   method, sizeof(method), username, sizeof(username),
                  hostname, sizeof(hostname), &port,
                  resource, sizeof(resource));
 
- /*
-  * See if there are any options...
-  */
+  //
+  // See if there are any options...
+  //
 
   if ((options = strchr(resource, '?')) != NULL)
   {
-   /*
-    * Yup, terminate the device name string and move to the first
-    * character of the options...
-    */
+    //
+    // Yup, terminate the device name string and move to the first
+    // character of the options...
+    //
 
     *options++ = '\0';
   }
 
- /*
-  * Open the parallel port device...
-  */
+  //
+  // Open the parallel port device...
+  //
 
   fputs("STATE: +connecting-to-device\n", stderr);
 
   do
   {
 #if defined(__linux) || defined(__FreeBSD__)
-   /*
-    * The Linux and FreeBSD parallel port drivers currently are broken WRT
-    * select() and bidirection I/O...
-    */
+    //
+    // The Linux and FreeBSD parallel port drivers currently are broken WRT
+    // select() and bidirection I/O...
+    //
 
     device_fd = open(resource, O_WRONLY | O_EXCL);
     use_bc    = 0;
@@ -179,25 +178,25 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
     }
     else
       use_bc = 1;
-#endif /* __linux || __FreeBSD__ */
+#endif // __linux || __FreeBSD__
 
     if (device_fd == -1)
     {
       if (getenv("CLASS") != NULL)
       {
-       /*
-        * If the CLASS environment variable is set, the job was submitted
-       * to a class and not to a specific queue.  In this case, we want
-       * to abort immediately so that the job can be requeued on the next
-       * available printer in the class.
-       */
+       //
+        // If the CLASS environment variable is set, the job was submitted
+       // to a class and not to a specific queue.  In this case, we want
+       // to abort immediately so that the job can be requeued on the next
+       // available printer in the class.
+       //
 
         fputs("INFO: Unable to contact printer, queuing on next printer in "
               "class.\n", stderr);
 
-       /*
-        * Sleep 5 seconds to keep the job from requeuing too rapidly...
-       */
+       //
+        // Sleep 5 seconds to keep the job from requeuing too rapidly...
+       //
 
        sleep(5);
 
@@ -226,21 +225,21 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
 
   fputs("STATE: -connecting-to-device\n", stderr);
 
- /*
-  * Set any options provided...
-  */
+  //
+  // Set any options provided...
+  //
 
   tcgetattr(device_fd, &opts);
 
-  opts.c_lflag &= ~(ICANON | ECHO | ISIG);     /* Raw mode */
+  opts.c_lflag &= ~(ICANON | ECHO | ISIG);     // Raw mode
 
-  /**** No options supported yet ****/
+  // **** No options supported yet ****
 
   tcsetattr(device_fd, TCSANOW, &opts);
 
- /*
-  * Finally, send the print file...
-  */
+  //
+  // Finally, send the print file...
+  //
 
   tbytes = 0;
 
@@ -260,9 +259,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
       fputs("INFO: Print file sent.\n", stderr);
   }
 
- /*
-  * Close the socket connection and input file and return...
-  */
+  //
+  // Close the socket connection and input file and return...
+  //
 
   close(device_fd);
 
@@ -273,38 +272,38 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
 }
 
 
-/*
- * 'drain_output()' - Drain pending print data to the device.
- */
+//
+// 'drain_output()' - Drain pending print data to the device.
+//
 
-static int                             /* O - 0 on success, -1 on error */
-drain_output(int print_fd,             /* I - Print file descriptor */
-             int device_fd)            /* I - Device file descriptor */
+static int                             // O - 0 on success, -1 on error
+drain_output(int print_fd,             // I - Print file descriptor
+             int device_fd)            // I - Device file descriptor
 {
-  int          nfds;                   /* Maximum file descriptor value + 1 */
-  fd_set       input;                  /* Input set for reading */
-  ssize_t      print_bytes,            /* Print bytes read */
-               bytes;                  /* Bytes written */
-  char         print_buffer[8192],     /* Print data buffer */
-               *print_ptr;             /* Pointer into print data buffer */
-  struct timeval timeout;              /* Timeout for read... */
+  int          nfds;                   // Maximum file descriptor value + 1
+  fd_set       input;                  // Input set for reading
+  ssize_t      print_bytes,            // Print bytes read
+               bytes;                  // Bytes written
+  char         print_buffer[8192],     // Print data buffer
+               *print_ptr;             // Pointer into print data buffer
+  struct timeval timeout;              // Timeout for read...
 
 
- /*
-  * Figure out the maximum file descriptor value to use with select()...
-  */
+  //
+  // Figure out the maximum file descriptor value to use with select()...
+  //
 
   nfds = (print_fd > device_fd ? print_fd : device_fd) + 1;
 
- /*
-  * Now loop until we are out of data from print_fd...
-  */
+  //
+  // Now loop until we are out of data from print_fd...
+  //
 
   for (;;)
   {
-   /*
-    * Use select() to determine whether we have data to copy around...
-    */
+    //
+    // Use select() to determine whether we have data to copy around...
+    //
 
     FD_ZERO(&input);
     FD_SET(print_fd, &input);
@@ -321,9 +320,9 @@ drain_output(int print_fd,          /* I - Print file descriptor */
     if ((print_bytes = read(print_fd, print_buffer,
                            sizeof(print_buffer))) < 0)
     {
-     /*
-      * Read error - bail if we don't see EAGAIN or EINTR...
-      */
+      //
+      // Read error - bail if we don't see EAGAIN or EINTR...
+      //
 
       if (errno != EAGAIN && errno != EINTR)
       {
@@ -335,9 +334,9 @@ drain_output(int print_fd,          /* I - Print file descriptor */
     }
     else if (print_bytes == 0)
     {
-     /*
-      * End of file, return...
-      */
+      //
+      // End of file, return...
+      //
 
       return (0);
     }
@@ -349,9 +348,9 @@ drain_output(int print_fd,          /* I - Print file descriptor */
     {
       if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
       {
-       /*
-        * Write error - bail if we don't see an error we can retry...
-       */
+       //
+        // Write error - bail if we don't see an error we can retry...
+       //
 
         if (errno != ENOSPC && errno != ENXIO && errno != EAGAIN &&
            errno != EINTR && errno != ENOTTY)
@@ -372,27 +371,27 @@ drain_output(int print_fd,                /* I - Print file descriptor */
 }
 
 
-/*
- * 'list_devices()' - List all parallel devices.
- */
+//
+// 'list_devices()' - List all parallel devices.
+//
 
 static void
 list_devices(void)
 {
 #ifdef __sun
   static char  *funky_hex = "0123456789abcdefghijklmnopqrstuvwxyz";
-                               /* Funky hex numbering used for some devices */
-#endif /* __sun */
+                               // Funky hex numbering used for some devices
+#endif // __sun
 
 #ifdef __linux
-  int  i;                      /* Looping var */
-  int  fd;                     /* File descriptor */
-  char device[512],            /* Device filename */
-       basedevice[255],        /* Base device filename for ports */
-       device_id[1024],        /* Device ID string */
-       make_model[1024],       /* Make and model */
-       info[2048],             /* Info string */
-       uri[1024];              /* Device URI */
+  int  i;                      // Looping var
+  int  fd;                     // File descriptor
+  char device[512],            // Device filename
+       basedevice[255],        // Base device filename for ports
+       device_id[1024],        // Device ID string
+       make_model[1024],       // Make and model
+       info[2048],             // Info string
+       uri[1024];              // Device URI
 
 
   if (!access("/dev/parallel/", 0))
@@ -404,9 +403,9 @@ list_devices(void)
 
   for (i = 0; i < 4; i ++)
   {
-   /*
-    * Open the port, if available...
-    */
+    //
+    // Open the port, if available...
+    //
 
     sprintf(device, "%s%d", basedevice, i);
     if ((fd = open(device, O_RDWR | O_EXCL)) < 0)
@@ -414,9 +413,9 @@ list_devices(void)
 
     if (fd >= 0)
     {
-     /*
-      * Now grab the IEEE 1284 device ID string...
-      */
+      //
+      // Now grab the IEEE 1284 device ID string...
+      //
 
       snprintf(uri, sizeof(uri), "parallel:%s", device);
 
@@ -437,13 +436,13 @@ list_devices(void)
     }
   }
 #elif defined(__sun)
-  int          i, j, n;        /* Looping vars */
-  char         device[255];    /* Device filename */
+  int          i, j, n;        // Looping vars
+  char         device[255];    // Device filename
 
 
- /*
-  * Standard parallel ports...
-  */
+  //
+  // Standard parallel ports...
+  //
 
   for (i = 0; i < 10; i ++)
   {
@@ -470,9 +469,9 @@ list_devices(void)
              device, i + 1);
   }
 
- /*
-  * MAGMA parallel ports...
-  */
+  //
+  // MAGMA parallel ports...
+  //
 
   for (i = 0; i < 40; i ++)
   {
@@ -482,15 +481,15 @@ list_devices(void)
              device, (i / 10) + 1, (i % 10) + 1);
   }
 
- /*
-  * Central Data parallel ports...
-  */
+  //
+  // Central Data parallel ports...
+  //
 
   for (i = 0; i < 9; i ++)
     for (j = 0; j < 8; j ++)
       for (n = 0; n < 32; n ++)
       {
-        if (i == 8)    /* EtherLite */
+        if (i == 8)    // EtherLite
           sprintf(device, "/dev/sts/lpN%d%c", j, funky_hex[n]);
         else
           sprintf(device, "/dev/sts/lp%c%d%c", i + 'C', j,
@@ -507,9 +506,9 @@ list_devices(void)
        }
       }
 #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
-  int  i;                      /* Looping var */
-  int  fd;                     /* File descriptor */
-  char device[255];            /* Device filename */
+  int  i;                      // Looping var
+  int  fd;                     // File descriptor
+  char device[255];            // Device filename
 
 
   for (i = 0; i < 3; i ++)
@@ -532,47 +531,47 @@ list_devices(void)
 }
 
 
-/*
- * 'run_loop()' - Read and write print and back-channel data.
- */
+//
+// 'run_loop()' - Read and write print and back-channel data.
+//
 
-static ssize_t                         /* O - Total bytes on success, -1 on error */
-run_loop(int print_fd,                 /* I - Print file descriptor */
-       int device_fd,                  /* I - Device file descriptor */
-       int use_bc,                     /* I - Use back-channel? */
-       int update_state)               /* I - Update printer-state-reasons? */
+static ssize_t                         // O - Total bytes on success, -1 on error
+run_loop(int print_fd,                 // I - Print file descriptor
+       int device_fd,                  // I - Device file descriptor
+       int use_bc,                     // I - Use back-channel?
+       int update_state)               // I - Update printer-state-reasons?
 {
-  int          nfds;                   /* Maximum file descriptor value + 1 */
-  fd_set       input,                  /* Input set for reading */
-               output;                 /* Output set for writing */
-  ssize_t      print_bytes,            /* Print bytes read */
-               bc_bytes,               /* Backchannel bytes read */
-               total_bytes,            /* Total bytes written */
-               bytes;                  /* Bytes written */
-  int          paperout;               /* "Paper out" status */
-  int          offline;                /* "Off-line" status */
-  char         print_buffer[8192],     /* Print data buffer */
-               *print_ptr,             /* Pointer into print data buffer */
-               bc_buffer[1024];        /* Back-channel data buffer */
-  struct timeval timeout;              /* Timeout for select() */
-  int           sc_ok;                  /* Flag a side channel error and
-                                          stop using the side channel
-                                          in such a case. */
+  int          nfds;                   // Maximum file descriptor value + 1
+  fd_set       input,                  // Input set for reading
+               output;                 // Output set for writing
+  ssize_t      print_bytes,            // Print bytes read
+               bc_bytes,               // Backchannel bytes read
+               total_bytes,            // Total bytes written
+               bytes;                  // Bytes written
+  int          paperout;               // "Paper out" status
+  int          offline;                // "Off-line" status
+  char         print_buffer[8192],     // Print data buffer
+               *print_ptr,             // Pointer into print data buffer
+               bc_buffer[1024];        // Back-channel data buffer
+  struct timeval timeout;              // Timeout for select()
+  int           sc_ok;                  // Flag a side channel error and
+                                       // stop using the side channel
+                                       // in such a case.
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
-  struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+  struct sigaction action;             // Actions for POSIX signals
+#endif // HAVE_SIGACTION && !HAVE_SIGSET
 
 
- /*
-  * If we are printing data from a print driver on stdin, ignore SIGTERM
-  * so that the driver can finish out any page data, e.g. to eject the
-  * current page.  We only do this for stdin printing as otherwise there
-  * is no way to cancel a raw print job...
-  */
+  //
+  // If we are printing data from a print driver on stdin, ignore SIGTERM
+  // so that the driver can finish out any page data, e.g. to eject the
+  // current page.  We only do this for stdin printing as otherwise there
+  // is no way to cancel a raw print job...
+  //
 
   if (!print_fd)
   {
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
+#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs
     sigset(SIGTERM, SIG_IGN);
 #elif defined(HAVE_SIGACTION)
     memset(&action, 0, sizeof(action));
@@ -582,40 +581,40 @@ run_loop(int print_fd,                    /* I - Print file descriptor */
     sigaction(SIGTERM, &action, NULL);
 #else
     signal(SIGTERM, SIG_IGN);
-#endif /* HAVE_SIGSET */
+#endif // HAVE_SIGSET
   }
   else if (print_fd < 0)
   {
-   /*
-    * Copy print data from stdin, but don't mess with the signal handlers...
-    */
+    //
+    // Copy print data from stdin, but don't mess with the signal handlers...
+    //
 
     print_fd = 0;
   }
 
- /*
-  * Figure out the maximum file descriptor value to use with select()...
-  */
+  //
+  // Figure out the maximum file descriptor value to use with select()...
+  //
 
   nfds = (print_fd > device_fd ? print_fd : device_fd) + 1;
 
 
- /*
-  * Side channel is OK...
-  */
+  //
+  // Side channel is OK...
+  //
 
   sc_ok = 1;
 
- /*
-  * Now loop until we are out of data from print_fd...
-  */
+  //
+  // Now loop until we are out of data from print_fd...
+  //
 
   for (print_bytes = 0, print_ptr = print_buffer, offline = -1,
-           paperout = -1, total_bytes = 0;;)
+        paperout = -1, total_bytes = 0;;)
   {
-   /*
-    * Use select() to determine whether we have data to copy around...
-    */
+    //
+    // Use select() to determine whether we have data to copy around...
+    //
 
     FD_ZERO(&input);
     if (!print_bytes)
@@ -634,9 +633,9 @@ run_loop(int print_fd,                      /* I - Print file descriptor */
 
     if (select(nfds, &input, &output, NULL, &timeout) < 0)
     {
-     /*
-      * Pause printing to clear any pending errors...
-      */
+      //
+      // Pause printing to clear any pending errors...
+      //
 
       if (errno == ENXIO && offline != 1 && update_state)
       {
@@ -654,29 +653,29 @@ run_loop(int print_fd,                    /* I - Print file descriptor */
       continue;
     }
 
-   /*
-    * Check if we have a side-channel request ready...
-    */
+    //
+    // Check if we have a side-channel request ready...
+    //
 
     if (sc_ok && FD_ISSET(CUPS_SC_FD, &input))
     {
-     /*
-      * Do the side-channel request, then start back over in the select
-      * loop since it may have read from print_fd...
-      *
-      * If the side channel processing errors, go straight on to avoid
-      * blocking of the backend by side channel problems, deactivate the side
-      * channel.
-      */
+      //
+      // Do the side-channel request, then start back over in the select
+      // loop since it may have read from print_fd...
+      //
+      // If the side channel processing errors, go straight on to avoid
+      // blocking of the backend by side channel problems, deactivate the side
+      // channel.
+      //
 
       if (side_cb(print_fd, device_fd, use_bc))
        sc_ok = 0;
       continue;
     }
 
-   /*
-    * Check if we have back-channel data ready...
-    */
+    //
+    // Check if we have back-channel data ready...
+    //
 
     if (FD_ISSET(device_fd, &input))
     {
@@ -695,18 +694,18 @@ run_loop(int print_fd,                    /* I - Print file descriptor */
         use_bc = 0;
     }
 
-   /*
-    * Check if we have print data ready...
-    */
+    //
+    // Check if we have print data ready...
+    //
 
     if (FD_ISSET(print_fd, &input))
     {
       if ((print_bytes = read(print_fd, print_buffer,
                               sizeof(print_buffer))) < 0)
       {
-       /*
-        * Read error - bail if we don't see EAGAIN or EINTR...
-       */
+       //
+        // Read error - bail if we don't see EAGAIN or EINTR...
+       //
 
        if (errno != EAGAIN && errno != EINTR)
        {
@@ -718,9 +717,9 @@ run_loop(int print_fd,                      /* I - Print file descriptor */
       }
       else if (print_bytes == 0)
       {
-       /*
-        * End of file, break out of the loop...
-       */
+       //
+        // End of file, break out of the loop...
+       //
 
         break;
       }
@@ -731,18 +730,18 @@ run_loop(int print_fd,                    /* I - Print file descriptor */
               (int)print_bytes);
     }
 
-   /*
-    * Check if the device is ready to receive data and we have data to
-    * send...
-    */
+    //
+    // Check if the device is ready to receive data and we have data to
+    // send...
+    //
 
     if (print_bytes && FD_ISSET(device_fd, &output))
     {
       if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
       {
-       /*
-        * Write error - bail if we don't see an error we can retry...
-       */
+       //
+        // Write error - bail if we don't see an error we can retry...
+       //
 
         if (errno == ENOSPC)
        {
@@ -789,27 +788,27 @@ run_loop(int print_fd,                    /* I - Print file descriptor */
     }
   }
 
- /*
-  * Return with success...
-  */
+  //
+  // Return with success...
+  //
 
   return (total_bytes);
 }
 
 
-/*
- * 'side_cb()' - Handle side-channel requests...
- */
+//
+// 'side_cb()' - Handle side-channel requests...
+//
 
-static int                             /* O - 0 on success, -1 on error */
-side_cb(int         print_fd,          /* I - Print file */
-        int         device_fd,         /* I - Device file */
-       int         use_bc)             /* I - Using back-channel? */
+static int                             // O - 0 on success, -1 on error
+side_cb(int         print_fd,          // I - Print file
+        int         device_fd,         // I - Device file
+       int         use_bc)             // I - Using back-channel?
 {
-  cups_sc_command_t    command;        /* Request command */
-  cups_sc_status_t     status;         /* Request/response status */
-  char                 data[2048];     /* Request/response data */
-  int                  datalen;        /* Request/response data size */
+  cups_sc_command_t    command;        // Request command
+  cups_sc_status_t     status;         // Request/response status
+  char                 data[2048];     // Request/response data
+  int                  datalen;        // Request/response data size
 
 
   datalen = sizeof(data);
index 6c54655c535450c3ef94a195b057ba07aa22c9c6..1c3623d3d07c12d609e1b2409da76678d6eaafb3 100644 (file)
@@ -1,24 +1,22 @@
-/*
- *   Serial port backend for CUPS.
- *
- *   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:
- *
- *   main()         - Send a file to the printer or server.
- *   list_devices() - List all serial devices.
- *   side_cb()      - Handle side-channel requests...
- */
-
-/*
- * Include necessary headers.
- */
+//
+// Serial port backend for cups-filters.
+//
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
+// Contents:
+//
+//   main()         - Send a file to the printer or server.
+//   list_devices() - List all serial devices.
+//   side_cb()      - Handle side-channel requests...
+//
+
+//
+// Include necessary headers.
+//
 
 #include <config.h>
 #include <cups/cups.h>
 #include <sys/select.h>
 #ifdef HAVE_SYS_IOCTL_H
 #  include <sys/ioctl.h>
-#endif /* HAVE_SYS_IOCTL_H */
+#endif // HAVE_SYS_IOCTL_H
 
 #ifndef CRTSCTS
 #  ifdef CNEW_RTSCTS
 #    define CRTSCTS CNEW_RTSCTS
 #  else
 #    define CRTSCTS 0
-#  endif /* CNEW_RTSCTS */
-#endif /* !CRTSCTS */
+#  endif // CNEW_RTSCTS
+#endif // !CRTSCTS
 
 #if defined(__APPLE__)
 #  include <CoreFoundation/CoreFoundation.h>
 #  include <IOKit/IOKitLib.h>
 #  include <IOKit/serial/IOSerialKeys.h>
 #  include <IOKit/IOBSD.h>
-#endif /* __APPLE__ */
+#endif // __APPLE__
 
 #if defined(__linux) && defined(TIOCGSERIAL)
 #  include <linux/serial.h>
 #  include <linux/ioctl.h>
-#endif /* __linux && TIOCGSERIAL */
+#endif // __linux && TIOCGSERIAL
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 static int     drain_output(int print_fd, int device_fd);
 static void    list_devices(void);
 static int     side_cb(int print_fd, int device_fd, int use_bc);
 
 
-/*
- * 'main()' - Send a file to the printer or server.
- *
- * Usage:
- *
- *    printer-uri job-id user title copies options [file]
- */
+//
+// 'main()' - Send a file to the printer or server.
+//
+// Usage:
+//
+//    printer-uri job-id user title copies options [file]
+//
 
-int                                    /* O - Exit status */
-main(int  argc,                                /* I - Number of command-line arguments (6 or 7) */
-     char *argv[])                     /* I - Command-line arguments */
+int                                    // O - Exit status
+main(int  argc,                                // I - Number of command-line arguments (6 or 7)
+     char *argv[])                     // I - Command-line arguments
 {
-  char         method[255],            /* Method in URI */
-               hostname[1024],         /* Hostname */
-               username[255],          /* Username info (not used) */
-               resource[1024],         /* Resource info (device and options) */
-               *options,               /* Pointer to options */
-               *name,                  /* Name of option */
-               *value,                 /* Value of option */
-               sep;                    /* Option separator */
-  int          port;                   /* Port number (not used) */
-  int          copies;                 /* Number of copies to print */
-  int          side_eof = 0,           /* Saw EOF on side-channel? */
-               print_fd,               /* Print file */
-               device_fd;              /* Serial device */
-  int          nfds;                   /* Maximum file descriptor value + 1 */
-  fd_set       input,                  /* Input set for reading */
-               output;                 /* Output set for writing */
-  ssize_t      print_bytes,            /* Print bytes read */
-               bc_bytes,               /* Backchannel bytes read */
-               total_bytes,            /* Total bytes written */
-               bytes;                  /* Bytes written */
-  int          dtrdsr;                 /* Do dtr/dsr flow control? */
-  int          print_size;             /* Size of output buffer for writes */
-  char         print_buffer[8192],     /* Print data buffer */
-               *print_ptr,             /* Pointer into print data buffer */
-               bc_buffer[1024];        /* Back-channel data buffer */
-  struct termios opts;                 /* Serial port options */
-  struct termios origopts;             /* Original port options */
+  char         method[255],            // Method in URI
+               hostname[1024],         // Hostname
+               username[255],          // Username info (not used)
+               resource[1024],         // Resource info (device and options)
+               *options,               // Pointer to options
+               *name,                  // Name of option
+               *value,                 // Value of option
+               sep;                    // Option separator
+  int          port;                   // Port number (not used)
+  int          copies;                 // Number of copies to print
+  int          side_eof = 0,           // Saw EOF on side-channel?
+               print_fd,               // Print file
+               device_fd;              // Serial device
+  int          nfds;                   // Maximum file descriptor value + 1
+  fd_set       input,                  // Input set for reading
+               output;                 // Output set for writing
+  ssize_t      print_bytes,            // Print bytes read
+               bc_bytes,               // Backchannel bytes read
+               total_bytes,            // Total bytes written
+               bytes;                  // Bytes written
+  int          dtrdsr;                 // Do dtr/dsr flow control?
+  int          print_size;             // Size of output buffer for writes
+  char         print_buffer[8192],     // Print data buffer
+               *print_ptr,             // Pointer into print data buffer
+               bc_buffer[1024];        // Back-channel data buffer
+  struct termios opts;                 // Serial port options
+  struct termios origopts;             // Original port options
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
-  struct sigaction action;             /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
-  char         print_sleep = 0;        /* Print first sleep flag on every transmit */
+  struct sigaction action;             // Actions for POSIX signals
+#endif // HAVE_SIGACTION && !HAVE_SIGSET
+  char         print_sleep = 0;        // Print first sleep flag on every transmit
 
 
- /*
-  * Make sure status messages are not buffered...
-  */
+  //
+  // Make sure status messages are not buffered...
+  //
 
   setbuf(stderr, NULL);
 
- /*
-  * Ignore SIGPIPE signals...
-  */
+  //
+  // Ignore SIGPIPE signals...
+  //
 
 #ifdef HAVE_SIGSET
   sigset(SIGPIPE, SIG_IGN);
@@ -129,11 +127,11 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   sigaction(SIGPIPE, &action, NULL);
 #else
   signal(SIGPIPE, SIG_IGN);
-#endif /* HAVE_SIGSET */
+#endif // HAVE_SIGSET
 
- /*
-  * Check command-line...
-  */
+  //
+  // Check command-line...
+  //
 
   if (argc == 1)
   {
@@ -147,10 +145,10 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
     return (CUPS_BACKEND_FAILED);
   }
 
- /*
-  * If we have 7 arguments, print the file named on the command-line.
-  * Otherwise, send stdin instead...
-  */
+  //
+  // If we have 7 arguments, print the file named on the command-line.
+  // Otherwise, send stdin instead...
+  //
 
   if (argc == 6)
   {
@@ -159,9 +157,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   }
   else
   {
-   /*
-    * Try to open the print file...
-    */
+    //
+    // Try to open the print file...
+    //
 
     if ((print_fd = open(argv[6], O_RDONLY)) < 0)
     {
@@ -172,32 +170,32 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
     copies = atoi(argv[4]);
   }
 
- /*
-  * Extract the device name and options from the URI...
-  */
+  //
+  // Extract the device name and options from the URI...
+  //
 
   httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
                   method, sizeof(method), username, sizeof(username),
                  hostname, sizeof(hostname), &port,
                  resource, sizeof(resource));
 
- /*
-  * See if there are any options...
-  */
+  //
+  // See if there are any options...
+  //
 
   if ((options = strchr(resource, '?')) != NULL)
   {
-   /*
-    * Yup, terminate the device name string and move to the first
-    * character of the options...
-    */
+    //
+    // Yup, terminate the device name string and move to the first
+    // character of the options...
+    //
 
     *options++ = '\0';
   }
 
- /*
-  * Open the serial port device...
-  */
+  //
+  // Open the serial port device...
+  //
 
   fputs("STATE: +connecting-to-device\n", stderr);
 
@@ -208,19 +206,19 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
     {
       if (getenv("CLASS") != NULL)
       {
-       /*
-        * If the CLASS environment variable is set, the job was submitted
-       * to a class and not to a specific queue.  In this case, we want
-       * to abort immediately so that the job can be requeued on the next
-       * available printer in the class.
-       */
+       //
+        // If the CLASS environment variable is set, the job was submitted
+        // to a class and not to a specific queue.  In this case, we want
+       // to abort immediately so that the job can be requeued on the next
+       // available printer in the class.
+       //
 
         fputs("INFO: Unable to contact printer, queuing on next printer in "
               "class.\n", stderr);
 
-       /*
-        * Sleep 5 seconds to keep the job from requeuing too rapidly...
-       */
+       //
+        // Sleep 5 seconds to keep the job from requeuing too rapidly...
+       //
 
        sleep(5);
 
@@ -243,27 +241,27 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
 
   fputs("STATE: -connecting-to-device\n", stderr);
 
- /*
-  * Set any options provided...
-  */
+  //
+  // Set any options provided...
+  //
 
   tcgetattr(device_fd, &origopts);
   tcgetattr(device_fd, &opts);
 
   opts.c_lflag &= ~(ICANON | ECHO | ISIG);
-                                       /* Raw mode */
-  opts.c_oflag &= ~OPOST;              /* Don't post-process */
+                                       // Raw mode
+  opts.c_oflag &= ~OPOST;              // Don't post-process
 
-  print_size = 96;                     /* 9600 baud / 10 bits/char / 10Hz */
-  dtrdsr     = 0;                      /* No dtr/dsr flow control */
+  print_size = 96;                     // 9600 baud / 10 bits/char / 10Hz
+  dtrdsr     = 0;                      // No dtr/dsr flow control
 
   if (options)
   {
     while (*options)
     {
-     /*
-      * Get the name...
-      */
+      //
+      // Get the name...
+      //
 
       name = options;
 
@@ -275,9 +273,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
       if (sep == '=')
       {
-       /*
-        * Get the value...
-       */
+       //
+        // Get the value...
+       //
 
         value = options;
 
@@ -290,15 +288,15 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
       else
         value = (char *)"";
 
-     /*
-      * Process the option...
-      */
+      //
+      // Process the option...
+      //
 
       if (!strcasecmp(name, "baud"))
       {
-       /*
-        * Set the baud rate...
-       */
+       //
+        // Set the baud rate...
+       //
 
         print_size = atoi(value) / 100;
 
@@ -337,30 +335,30 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
              cfsetispeed(&opts, B57600);
              cfsetospeed(&opts, B57600);
              break;
-#  endif /* B57600 */
+#  endif // B57600
 #  ifdef B115200
          case 115200 :
              cfsetispeed(&opts, B115200);
              cfsetospeed(&opts, B115200);
              break;
-#  endif /* B115200 */
+#  endif // B115200
 #  ifdef B230400
          case 230400 :
              cfsetispeed(&opts, B230400);
              cfsetospeed(&opts, B230400);
              break;
-#  endif /* B230400 */
+#  endif // B230400
           default :
              fprintf(stderr, "WARNING: Unsupported baud rate: %s\n", value);
              break;
        }
-#endif /* B19200 == 19200 */
+#endif // B19200 == 19200
       }
       else if (!strcasecmp(name, "bits"))
       {
-       /*
-        * Set number of data bits...
-       */
+       //
+        // Set number of data bits...
+       //
 
         switch (atoi(value))
        {
@@ -379,9 +377,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
       }
       else if (!strcasecmp(name, "parity"))
       {
-       /*
-       * Set parity checking...
-       */
+       //
+       // Set parity checking...
+       //
 
        if (!strcasecmp(value, "even"))
        {
@@ -397,9 +395,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
          opts.c_cflag &= ~PARENB;
        else if (!strcasecmp(value, "space"))
        {
-        /*
-         * Note: we only support space parity with 7 bits per character...
-         */
+         //
+         // Note: we only support space parity with 7 bits per character...
+         //
 
          opts.c_cflag &= ~CSIZE;
           opts.c_cflag |= CS8;
@@ -407,10 +405,10 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
         }
        else if (!strcasecmp(value, "mark"))
        {
-        /*
-         * Note: we only support mark parity with 7 bits per character
-         * and 1 stop bit...
-         */
+         //
+         // Note: we only support mark parity with 7 bits per character
+         // and 1 stop bit...
+         //
 
          opts.c_cflag &= ~CSIZE;
           opts.c_cflag |= CS7;
@@ -420,9 +418,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
       }
       else if (!strcasecmp(name, "flow"))
       {
-       /*
-       * Set flow control...
-       */
+       //
+       // Set flow control...
+       //
 
        if (!strcasecmp(value, "none"))
        {
@@ -467,16 +465,16 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   tcsetattr(device_fd, TCSANOW, &opts);
   fcntl(device_fd, F_SETFL, 0);
 
- /*
-  * Now that we are "connected" to the port, ignore SIGTERM so that we
-  * can finish out any page data the driver sends (e.g. to eject the
-  * current page...  Only ignore SIGTERM if we are printing data from
-  * stdin (otherwise you can't cancel raw jobs...)
-  */
+  //
+  // Now that we are "connected" to the port, ignore SIGTERM so that we
+  // can finish out any page data the driver sends (e.g. to eject the
+  // current page...  Only ignore SIGTERM if we are printing data from
+  // stdin (otherwise you can't cancel raw jobs...)
+  //
 
   if (!print_fd)
   {
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
+#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs
     sigset(SIGTERM, SIG_IGN);
 #elif defined(HAVE_SIGACTION)
     memset(&action, 0, sizeof(action));
@@ -486,21 +484,21 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
     sigaction(SIGTERM, &action, NULL);
 #else
     signal(SIGTERM, SIG_IGN);
-#endif /* HAVE_SIGSET */
+#endif // HAVE_SIGSET
   }
 
- /*
-  * Figure out the maximum file descriptor value to use with select()...
-  */
+  //
+  // Figure out the maximum file descriptor value to use with select()...
+  //
 
   nfds = (print_fd > device_fd ? print_fd : device_fd) + 1;
 
- /*
-  * Finally, send the print file.  Ordinarily we would just use the
-  * backendRunLoop() function, however since we need to use smaller
-  * writes and may need to do DSR/DTR flow control, we duplicate much
-  * of the code here instead...
-  */
+  //
+  // Finally, send the print file.  Ordinarily we would just use the
+  // backendRunLoop() function, however since we need to use smaller
+  // writes and may need to do DSR/DTR flow control, we duplicate much
+  // of the code here instead...
+  //
 
   if (print_size > sizeof(print_buffer))
     print_size = sizeof(print_buffer);
@@ -517,15 +515,15 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
       lseek(print_fd, 0, SEEK_SET);
     }
 
-   /*
-    * Now loop until we are out of data from print_fd...
-    */
+    //
+    // Now loop until we are out of data from print_fd...
+    //
 
     for (print_bytes = 0, print_ptr = print_buffer;;)
     {
-     /*
-      * Use select() to determine whether we have data to copy around...
-      */
+      //
+      // Use select() to determine whether we have data to copy around...
+      //
 
       FD_ZERO(&input);
       if (!print_bytes)
@@ -539,27 +537,27 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
        FD_SET(device_fd, &output);
 
       if (select(nfds, &input, &output, NULL, NULL) < 0)
-       continue;                       /* Ignore errors here */
+       continue;                       // Ignore errors here
 
-     /*
-      * Check if we have a side-channel request ready...
-      */
+      //
+      // Check if we have a side-channel request ready...
+      //
 
       if (FD_ISSET(CUPS_SC_FD, &input))
       {
-       /*
-       * Do the side-channel request, then start back over in the select
-       * loop since it may have read from print_fd...
-       */
+       //
+       // Do the side-channel request, then start back over in the select
+       // loop since it may have read from print_fd...
+       //
 
         if (side_cb(print_fd, device_fd, 1))
          side_eof = 1;
        continue;
       }
 
-     /*
-      * Check if we have back-channel data ready...
-      */
+      //
+      // Check if we have back-channel data ready...
+      //
 
       if (FD_ISSET(device_fd, &input))
       {
@@ -571,17 +569,17 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
        }
       }
 
-     /*
-      * Check if we have print data ready...
-      */
+      //
+      // Check if we have print data ready...
+      //
 
       if (FD_ISSET(print_fd, &input))
       {
        if ((print_bytes = read(print_fd, print_buffer, print_size)) < 0)
        {
-        /*
-          * Read error - bail if we don't see EAGAIN or EINTR...
-         */
+         //
+          // Read error - bail if we don't see EAGAIN or EINTR...
+         //
 
          if (errno != EAGAIN && errno != EINTR)
          {
@@ -601,9 +599,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
        }
        else if (print_bytes == 0)
        {
-        /*
-          * End of file, break out of the loop...
-         */
+         //
+          // End of file, break out of the loop...
+         //
 
           break;
        }
@@ -611,18 +609,18 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
        print_ptr = print_buffer;
       }
 
-     /*
-      * Check if the device is ready to receive data and we have data to
-      * send...
-      */
+      //
+      // Check if the device is ready to receive data and we have data to
+      // send...
+      //
 
       if (print_bytes && FD_ISSET(device_fd, &output))
       {
        if (dtrdsr)
        {
-        /*
-         * Check the port and sleep until DSR is set...
-         */
+         //
+         // Check the port and sleep until DSR is set...
+         //
 
          int status;
 
@@ -630,17 +628,17 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
          if (!ioctl(device_fd, TIOCMGET, &status))
             if (!(status & TIOCM_DSR))
            {
-            /*
-             * Wait for DSR to go high...
-             */
+             //
+             // Wait for DSR to go high...
+             //
 
              fputs("DEBUG: DSR is low; waiting for device.\n", stderr);
 
               do
              {
-              /*
-               * Poll every 100ms...
-               */
+               //
+               // Poll every 100ms...
+               //
 
                usleep(100000);
 
@@ -653,10 +651,11 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
             }
        }
 
-       /*
-        * on every transmit need to wait a little
-               * even though the DSR is OK for some unknown reasons.
-       */
+       //
+       // On every transmit need to wait a little
+       // even though the DSR is OK for some unknown reasons.
+       //
+
        if (print_sleep == 0)
        {
                usleep(10000);
@@ -665,9 +664,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
        if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
        {
-        /*
-          * Write error - bail if we don't see an error we can retry...
-         */
+         //
+          // Write error - bail if we don't see an error we can retry...
+         //
 
          if (errno != EAGAIN && errno != EINTR && errno != ENOTTY)
          {
@@ -696,9 +695,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
     }
   }
 
- /*
-  * Close the serial port and input file and return...
-  */
+  //
+  // Close the serial port and input file and return...
+  //
 
   tcsetattr(device_fd, TCSADRAIN, &origopts);
 
@@ -711,38 +710,38 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
 }
 
 
-/*
- * 'drain_output()' - Drain pending print data to the device.
- */
+//
+// 'drain_output()' - Drain pending print data to the device.
+//
 
-static int                             /* O - 0 on success, -1 on error */
-drain_output(int print_fd,             /* I - Print file descriptor */
-             int device_fd)            /* I - Device file descriptor */
+static int                             // O - 0 on success, -1 on error
+drain_output(int print_fd,             // I - Print file descriptor
+             int device_fd)            // I - Device file descriptor
 {
-  int          nfds;                   /* Maximum file descriptor value + 1 */
-  fd_set       input;                  /* Input set for reading */
-  ssize_t      print_bytes,            /* Print bytes read */
-               bytes;                  /* Bytes written */
-  char         print_buffer[8192],     /* Print data buffer */
-               *print_ptr;             /* Pointer into print data buffer */
-  struct timeval timeout;              /* Timeout for read... */
+  int          nfds;                   // Maximum file descriptor value + 1
+  fd_set       input;                  // Input set for reading
+  ssize_t      print_bytes,            // Print bytes read
+               bytes;                  // Bytes written
+  char         print_buffer[8192],     // Print data buffer
+               *print_ptr;             // Pointer into print data buffer
+  struct timeval timeout;              // Timeout for read...
 
 
- /*
 * Figure out the maximum file descriptor value to use with select()...
 */
+ //
// Figure out the maximum file descriptor value to use with select()...
//
 
   nfds = (print_fd > device_fd ? print_fd : device_fd) + 1;
 
- /*
-  * Now loop until we are out of data from print_fd...
-  */
+  //
+  // Now loop until we are out of data from print_fd...
+  //
 
   for (;;)
   {
-   /*
-    * Use select() to determine whether we have data to copy around...
-    */
+    //
+    // Use select() to determine whether we have data to copy around...
+    //
 
     FD_ZERO(&input);
     FD_SET(print_fd, &input);
@@ -759,9 +758,9 @@ drain_output(int print_fd,          /* I - Print file descriptor */
     if ((print_bytes = read(print_fd, print_buffer,
                            sizeof(print_buffer))) < 0)
     {
-     /*
-      * Read error - bail if we don't see EAGAIN or EINTR...
-      */
+      //
+      // Read error - bail if we don't see EAGAIN or EINTR...
+      //
 
       if (errno != EAGAIN && errno != EINTR)
       {
@@ -773,9 +772,9 @@ drain_output(int print_fd,          /* I - Print file descriptor */
     }
     else if (print_bytes == 0)
     {
-     /*
-      * End of file, return...
-      */
+      //
+      // End of file, return...
+      //
 
       return (0);
     }
@@ -787,9 +786,9 @@ drain_output(int print_fd,          /* I - Print file descriptor */
     {
       if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
       {
-       /*
-        * Write error - bail if we don't see an error we can retry...
-       */
+       //
+        // Write error - bail if we don't see an error we can retry...
+       //
 
         if (errno != ENOSPC && errno != ENXIO && errno != EAGAIN &&
            errno != EINTR && errno != ENOTTY)
@@ -810,28 +809,28 @@ drain_output(int print_fd,                /* I - Print file descriptor */
 }
 
 
-/*
- * 'list_devices()' - List all serial devices.
- */
+//
+// 'list_devices()' - List all serial devices.
+//
 
 static void
 list_devices(void)
 {
 #if defined(__sun) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
   static char  *funky_hex = "0123456789abcdefghijklmnopqrstuvwxyz";
-                                       /* Funky hex numbering used for some *
-                                        * devices                           */
-#endif /* __sun || __FreeBSD__ || __OpenBSD__ || __FreeBSD_kernel__ */
+                                       // Funky hex numbering used for some *
+                                        * devices                          
+#endif // __sun || __FreeBSD__ || __OpenBSD__ || __FreeBSD_kernel__
 
 
 #ifdef __linux
-  int                  i, j;           /* Looping vars */
-  int                  fd;             /* File descriptor */
-  char                 device[255];    /* Device filename */
-  char                 info[255];      /* Device info/description */
+  int                  i, j;           // Looping vars
+  int                  fd;             // File descriptor
+  char                 device[255];    // Device filename
+  char                 info[255];      // Device info/description
 #  ifdef TIOCGSERIAL
-  struct serial_struct serinfo;        /* serial port info */
-#  endif /* TIOCGSERIAL */
+  struct serial_struct serinfo;        // serial port info
+#  endif // TIOCGSERIAL
 
 
   for (i = 0; i < 100; i ++)
@@ -841,9 +840,9 @@ list_devices(void)
     if ((fd = open(device, O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0)
     {
 #  ifdef TIOCGSERIAL
-     /*
-      * See if this port exists...
-      */
+      //
+      // See if this port exists...
+      //
 
       serinfo.reserved_char[0] = 0;
 
@@ -851,15 +850,15 @@ list_devices(void)
       {
        if (serinfo.type == PORT_UNKNOWN)
        {
-        /*
-         * Nope...
-         */
+         //
+         // Nope...
+         //
 
          close(fd);
          continue;
        }
       }
-#  endif /* TIOCGSERIAL */
+#  endif // TIOCGSERIAL
 
       close(fd);
 
@@ -869,7 +868,7 @@ list_devices(void)
       printf("serial serial:%s?baud=230400 \"Unknown\" \"%s\"\n", device, info);
 #  else
       printf("serial serial:%s?baud=115200 \"Unknown\" \"%s\"\n", device, info);
-#  endif /* _ARCH_PPC || powerpc || __powerpc */
+#  endif // _ARCH_PPC || powerpc || __powerpc
     }
   }
 
@@ -907,14 +906,14 @@ list_devices(void)
     }
   }
 #elif defined(__sun)
-  int          i, j, n;                /* Looping vars */
-  char         device[255];            /* Device filename */
-  char         info[255];              /* Device info/description */
+  int          i, j, n;                // Looping vars
+  char         device[255];            // Device filename
+  char         info[255];              // Device info/description
 
 
- /*
-  * Standard serial ports...
-  */
+  //
+  // Standard serial ports...
+  //
 
   for (i = 0; i < 26; i ++)
   {
@@ -927,13 +926,13 @@ list_devices(void)
       printf("serial serial:%s?baud=115200 \"Unknown\" \"%s\"\n", device, info);
 #  else
       printf("serial serial:%s?baud=38400 \"Unknown\" \"%s\"\n", device, info);
-#  endif /* B115200 */
+#  endif // B115200
     }
   }
 
- /*
-  * MAGMA serial ports...
-  */
+  //
+  // MAGMA serial ports...
+  //
 
   for (i = 0; i < 40; i ++)
   {
@@ -943,15 +942,15 @@ list_devices(void)
              device, (i / 10) + 1, (i % 10) + 1);
   }
 
- /*
-  * Central Data serial ports...
-  */
+  //
+  // Central Data serial ports...
+  //
 
   for (i = 0; i < 9; i ++)
     for (j = 0; j < 8; j ++)
       for (n = 0; n < 32; n ++)
       {
-        if (i == 8)    /* EtherLite */
+        if (i == 8)    // EtherLite
           sprintf(device, "/dev/sts/ttyN%d%c", j, funky_hex[n]);
         else
           sprintf(device, "/dev/sts/tty%c%d%c", i + 'C', j,
@@ -968,15 +967,15 @@ list_devices(void)
        }
       }
 #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
-  int  i, j;                           /* Looping vars */
-  int  fd;                             /* File descriptor */
-  char device[255];                    /* Device filename */
-  char info[255];                      /* Device info/description */
+  int  i, j;                           // Looping vars
+  int  fd;                             // File descriptor
+  char device[255];                    // Device filename
+  char info[255];                      // Device info/description
 
 
- /*
-  * SIO ports...
-  */
+  //
+  // SIO ports...
+  //
 
   for (i = 0; i < 32; i ++)
   {
@@ -991,11 +990,11 @@ list_devices(void)
     }
   }
 
- /*
-  * Cyclades ports...
-  */
+  //
+  // Cyclades ports...
+  //
 
-  for (i = 0; i < 16; i ++) /* Should be up to 65536 boards... */
+  for (i = 0; i < 16; i ++) // Should be up to 65536 boards...
     for (j = 0; j < 32; j ++)
     {
       sprintf(device, "/dev/ttyc%d%c", i, funky_hex[j]);
@@ -1015,11 +1014,11 @@ list_devices(void)
       }
     }
 
- /*
-  * Digiboard ports...
-  */
+  //
+  // Digiboard ports...
+  //
 
-  for (i = 0; i < 16; i ++) /* Should be up to 65536 boards... */
+  for (i = 0; i < 16; i ++) // Should be up to 65536 boards...
     for (j = 0; j < 32; j ++)
     {
       sprintf(device, "/dev/ttyD%d%c", i, funky_hex[j]);
@@ -1031,9 +1030,9 @@ list_devices(void)
       }
     }
 
- /*
-  * Stallion ports...
-  */
+  //
+  // Stallion ports...
+  //
 
   for (i = 0; i < 32; i ++)
   {
@@ -1046,9 +1045,9 @@ list_devices(void)
     }
   }
 
- /*
-  * SX ports...
-  */
+  //
+  // SX ports...
+  //
 
   for (i = 0; i < 128; i ++)
   {
@@ -1061,15 +1060,15 @@ list_devices(void)
     }
   }
 #elif defined(__NetBSD__)
-  int  i, j;                           /* Looping vars */
-  int  fd;                             /* File descriptor */
-  char device[255];                    /* Device filename */
-  char info[255];                      /* Device info/description */
+  int  i, j;                           // Looping vars
+  int  fd;                             // File descriptor
+  char device[255];                    // Device filename
+  char info[255];                      // Device info/description
 
 
- /*
-  * Standard serial ports...
-  */
+  //
+  // Standard serial ports...
+  //
 
   for (i = 0; i < 4; i ++)
   {
@@ -1084,11 +1083,11 @@ list_devices(void)
     }
   }
 
- /*
-  * Cyclades-Z ports...
-  */
+  //
+  // Cyclades-Z ports...
+  //
 
-  for (i = 0; i < 16; i ++) /* Should be up to 65536 boards... */
+  for (i = 0; i < 16; i ++) // Should be up to 65536 boards...
     for (j = 0; j < 64; j ++)
     {
       sprintf(device, "/dev/ttyCZ%02d%02d", i, j);
@@ -1100,9 +1099,9 @@ list_devices(void)
       }
     }
 #elif defined(__APPLE__)
- /*
-  * Standard serial ports on MacOS X...
-  */
+  //
+  // Standard serial ports on MacOS X...
+  //
 
   kern_return_t                        kernResult;
   mach_port_t                  masterPort;
@@ -1115,9 +1114,9 @@ list_devices(void)
   if (KERN_SUCCESS != kernResult)
     return;
 
- /*
-  * Serial devices are instances of class IOSerialBSDClient.
-  */
+  //
+  // Serial devices are instances of class IOSerialBSDClient.
+  //
 
   classesToMatch = IOServiceMatching(kIOSerialBSDServiceValue);
   if (classesToMatch != NULL)
@@ -1139,7 +1138,7 @@ list_devices(void)
        Boolean         result;
 
 
-       /* Check if hidden... */
+       // Check if hidden...
        hiddenVal = IORegistryEntrySearchCFProperty(serialService,
                                                    kIOServicePlane,
                                                    CFSTR("HiddenPort"),
@@ -1147,7 +1146,7 @@ list_devices(void)
                                                    kIORegistryIterateRecursively |
                                                    kIORegistryIterateParents);
        if (hiddenVal)
-         CFRelease(hiddenVal); /* This interface should not be used */
+         CFRelease(hiddenVal); // This interface should not be used
        else
        {
          serialNameAsCFString =
@@ -1185,9 +1184,9 @@ list_devices(void)
        IOObjectRelease(serialService);
       }
 
-     /*
-      * Release the iterator.
-      */
+      //
+      // Release the iterator.
+      //
 
       IOObjectRelease(serialPortIterator);
     }
@@ -1196,19 +1195,19 @@ list_devices(void)
 }
 
 
-/*
- * 'side_cb()' - Handle side-channel requests...
- */
+//
+// 'side_cb()' - Handle side-channel requests...
+//
 
-static int                             /* O - 0 on success, -1 on error */
-side_cb(int print_fd,                  /* I - Print file */
-        int device_fd,                 /* I - Device file */
-       int use_bc)                     /* I - Using back-channel? */
+static int                             // O - 0 on success, -1 on error
+side_cb(int print_fd,                  // I - Print file
+        int device_fd,                 // I - Device file
+       int use_bc)                     // I - Using back-channel?
 {
-  cups_sc_command_t    command;        /* Request command */
-  cups_sc_status_t     status;         /* Request/response status */
-  char                 data[2048];     /* Request/response data */
-  int                  datalen;        /* Request/response data size */
+  cups_sc_command_t    command;        // Request command
+  cups_sc_status_t     status;         // Request/response status
+  char                 data[2048];     // Request/response data
+  int                  datalen;        // Request/response data size
 
 
   datalen = sizeof(data);