]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/ppd-emit.c
Add missing file.
[thirdparty/cups.git] / cups / ppd-emit.c
index e750029efd2fbdee128041bf919ce20009f221f7..8bffb2bc3609256358e3d624dcce09555ccc8693 100644 (file)
@@ -1,20 +1,13 @@
 /*
- * "$Id$"
- *
  * PPD code emission routines for CUPS.
  *
- * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2007-2019 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 "LICENSE.txt"
- * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more
+ * information.
  *
  * PostScript is a trademark of Adobe Systems, Inc.
- *
- * This file is subject to the Apple OS-Developed Software exception.
  */
 
 /*
  */
 
 #include "cups-private.h"
+#include "debug-internal.h"
 #include "ppd.h"
-#if defined(WIN32) || defined(__EMX__)
+#if defined(_WIN32) || defined(__EMX__)
 #  include <io.h>
 #else
 #  include <unistd.h>
-#endif /* WIN32 || __EMX__ */
+#endif /* _WIN32 || __EMX__ */
 
 
 /*
@@ -71,7 +65,7 @@ ppdCollect(ppd_file_t    *ppd,                /* I - PPD file data */
  * The choices array should be freed using @code free@ when you are
  * finished with it.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 int                                    /* O - Number of options marked */
@@ -244,7 +238,7 @@ ppdEmit(ppd_file_t    *ppd,         /* I - PPD file record */
  *
  * When "limit" is zero, this function is identical to ppdEmit().
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 int                                    /* O - 0 on success, -1 on failure */
@@ -330,11 +324,11 @@ ppdEmitFd(ppd_file_t    *ppd,             /* I - PPD file record */
 
     while (buflength > 0)
     {
-#ifdef WIN32
+#ifdef _WIN32
       if ((bytes = (ssize_t)write(fd, bufptr, (unsigned)buflength)) < 0)
 #else
       if ((bytes = write(fd, bufptr, buflength)) < 0)
-#endif /* WIN32 */
+#endif /* _WIN32 */
       {
         if (errno == EAGAIN || errno == EINTR)
          continue;
@@ -447,6 +441,9 @@ ppdEmitJCL(ppd_file_t *ppd,         /* I - PPD file record */
     * Clean up the job title...
     */
 
+    if (!title)
+      title = "Unknown";
+
     if ((ptr = strrchr(title, '/')) != NULL)
     {
      /*
@@ -496,6 +493,9 @@ ppdEmitJCL(ppd_file_t *ppd,         /* I - PPD file record */
     * issues with some printer's PJL implementations...
     */
 
+    if (!user)
+      user = "anonymous";
+
     snprintf(displaymsg, sizeof(displaymsg), "%d %s %s", job_id, user, temp);
 
    /*
@@ -538,7 +538,7 @@ ppdEmitJCL(ppd_file_t *ppd,         /* I - PPD file record */
 /*
  * 'ppdEmitJCLEnd()' - Emit JCLEnd code to a file.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 int                                    /* O - 0 on success, -1 on failure */
@@ -597,7 +597,7 @@ ppdEmitJCLEnd(ppd_file_t *ppd,              /* I - PPD file record */
  * The return string is allocated on the heap and should be freed using
  * @code free@ when you are done with it.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 char *                                 /* O - String containing option code or @code NULL@ if there is no option code */
@@ -664,6 +664,9 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
        {
           switch (cparam->type)
          {
+           case PPD_CUSTOM_UNKNOWN :
+               break;
+
            case PPD_CUSTOM_CURVE :
            case PPD_CUSTOM_INVCURVE :
            case PPD_CUSTOM_POINTS :
@@ -710,6 +713,9 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
        {
           switch (cparam->type)
          {
+           case PPD_CUSTOM_UNKNOWN :
+               break;
+
            case PPD_CUSTOM_CURVE :
            case PPD_CUSTOM_INVCURVE :
            case PPD_CUSTOM_POINTS :
@@ -805,6 +811,9 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
              {
                switch (cparam->type)
                {
+                 case PPD_CUSTOM_UNKNOWN :
+                     break;
+
                  case PPD_CUSTOM_CURVE :
                  case PPD_CUSTOM_INVCURVE :
                  case PPD_CUSTOM_POINTS :
@@ -838,7 +847,7 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
            *bufptr++ = *cptr++;
        }
       }
-      else
+      else if (choices[i]->code)
       {
        /*
         * Otherwise just copy the option code directly...
@@ -1007,6 +1016,9 @@ ppdEmitString(ppd_file_t    *ppd, /* I - PPD file record */
        {
           switch (cparam->type)
          {
+           case PPD_CUSTOM_UNKNOWN :
+               break;
+
            case PPD_CUSTOM_CURVE :
            case PPD_CUSTOM_INVCURVE :
            case PPD_CUSTOM_POINTS :
@@ -1071,7 +1083,7 @@ ppdEmitString(ppd_file_t    *ppd, /* I - PPD file record */
       DEBUG_printf(("2ppdEmitString: Offset in string is %d...",
                     (int)(bufptr - buffer)));
     }
-    else
+    else if (choices[i]->code)
     {
       strlcpy(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1));
       bufptr += strlen(bufptr);
@@ -1200,8 +1212,3 @@ ppd_handle_media(ppd_file_t *ppd) /* I - PPD file */
     }
   }
 }
-
-
-/*
- * End of "$Id$".
- */