-/*
- * Private array definitions for libppd.
- *
- * Copyright 2011-2012 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Private array definitions for libppd.
+//
+// Copyright 2011-2012 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _PPD_ARRAY_PRIVATE_H_
# define _PPD_ARRAY_PRIVATE_H_
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
# include <cups/array.h>
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Functions...
- */
+//
+// Functions...
+//
extern int _ppdArrayAddStrings(cups_array_t *a, const char *s,
char delim);
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_PPD_ARRAY_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_PPD_ARRAY_PRIVATE_H_
-/*
- * Sorted array routines for libppd.
- *
- * Copyright 2007-2014 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Sorted array routines for libppd.
+//
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "debug-internal.h"
#include "array-private.h"
-/*
- * '_ppdArrayAddStrings()' - Add zero or more delimited strings to an array.
- *
- * Note: The array MUST be created using the @link _ppdArrayNewStrings@
- * function. Duplicate strings are NOT added. If the string pointer "s" is NULL
- * or the empty string, no strings are added to the array.
- */
+//
+// '_ppdArrayAddStrings()' - Add zero or more delimited strings to an array.
+//
+// Note: The array MUST be created using the @link _ppdArrayNewStrings@
+// function. Duplicate strings are NOT added. If the string pointer "s" is NULL
+// or the empty string, no strings are added to the array.
+//
-int /* O - 1 on success, 0 on failure */
-_ppdArrayAddStrings(cups_array_t *a, /* I - Array */
- const char *s, /* I - Delimited strings or NULL */
- char delim)/* I - Delimiter character */
+int // O - 1 on success, 0 on failure
+_ppdArrayAddStrings(cups_array_t *a, // I - Array
+ const char *s, // I - Delimited strings or NULL
+ char delim) // I - Delimiter character
{
- char *buffer, /* Copy of string */
- *start, /* Start of string */
- *end; /* End of string */
- int status = 1; /* Status of add */
+ char *buffer, // Copy of string
+ *start, // Start of string
+ *end; // End of string
+ int status = 1; // Status of add
- DEBUG_printf(("_ppdArrayAddStrings(a=%p, s=\"%s\", delim='%c')", (void *)a, s, delim));
+ DEBUG_printf(("_ppdArrayAddStrings(a=%p, s=\"%s\", delim='%c')",
+ (void *)a, s, delim));
if (!a || !s || !*s)
{
if (delim == ' ')
{
- /*
- * Skip leading whitespace...
- */
+ //
+ // Skip leading whitespace...
+ //
DEBUG_puts("1_ppdArrayAddStrings: Skipping leading whitespace.");
if (!strchr(s, delim) &&
(delim != ' ' || (!strchr(s, '\t') && !strchr(s, '\n'))))
{
- /*
- * String doesn't contain a delimiter, so add it as a single value...
- */
+ //
+ // String doesn't contain a delimiter, so add it as a single value...
+ //
DEBUG_puts("1_ppdArrayAddStrings: No delimiter seen, adding a single "
"value.");
{
for (start = end = buffer; *end; start = end)
{
- /*
- * Find the end of the current delimited string and see if we need to add
- * it...
- */
+ //
+ // Find the end of the current delimited string and see if we need to add
+ // it...
+ //
if (delim == ' ')
{
}
-/*
- * '_ppdArrayNewStrings()' - Create a new array of comma-delimited strings.
- *
- * Note: The array automatically manages copies of the strings passed. If the
- * string pointer "s" is NULL or the empty string, no strings are added to the
- * newly created array.
- */
+//
+// '_ppdArrayNewStrings()' - Create a new array of comma-delimited strings.
+//
+// Note: The array automatically manages copies of the strings passed. If the
+// string pointer "s" is NULL or the empty string, no strings are added to the
+// newly created array.
+//
-cups_array_t * /* O - Array */
-_ppdArrayNewStrings(const char *s, /* I - Delimited strings or NULL */
- char delim) /* I - Delimiter character */
+cups_array_t * // O - Array
+_ppdArrayNewStrings(const char *s, // I - Delimited strings or NULL
+ char delim) // I - Delimiter character
{
- cups_array_t *a; /* Array */
+ cups_array_t *a; // Array
if ((a = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0,
-/*
- * Internal debugging macros for libppd.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Internal debugging macros for libppd.
+//
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _PPD_DEBUG_INTERNAL_H_
# define _PPD_DEBUG_INTERNAL_H_
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
# include "debug-private.h"
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * The debug macros are used if you compile with DEBUG defined.
- *
- * Usage:
- *
- * DEBUG_puts("string")
- * DEBUG_printf(("format string", arg, arg, ...));
- *
- * Note the extra parenthesis around the DEBUG_printf macro...
- *
- * Newlines are not required on the end of messages, as both add one when
- * writing the output.
- *
- * If the first character is a digit, then it represents the "log level" of the
- * message from 0 to 9. The default level is 1. The following defines the
- * current levels we use:
- *
- * 0 = public APIs, other than value accessor functions
- * 1 = return values for public APIs
- * 2 = public value accessor APIs, progress for public APIs
- * 3 = return values for value accessor APIs
- * 4 = private APIs, progress for value accessor APIs
- * 5 = return values for private APIs
- * 6 = progress for private APIs
- * 7 = static functions
- * 8 = return values for static functions
- * 9 = progress for static functions
- */
+//
+// The debug macros are used if you compile with DEBUG defined.
+//
+// Usage:
+//
+// DEBUG_puts("string")
+// DEBUG_printf(("format string", arg, arg, ...));
+//
+// Note the extra parenthesis around the DEBUG_printf macro...
+//
+// Newlines are not required on the end of messages, as both add one when
+// writing the output.
+//
+// If the first character is a digit, then it represents the "log level" of the
+// message from 0 to 9. The default level is 1. The following defines the
+// current levels we use:
+//
+// 0 = public APIs, other than value accessor functions
+// 1 = return values for public APIs
+// 2 = public value accessor APIs, progress for public APIs
+// 3 = return values for value accessor APIs
+// 4 = private APIs, progress for value accessor APIs
+// 5 = return values for private APIs
+// 6 = progress for private APIs
+// 7 = static functions
+// 8 = return values for static functions
+// 9 = progress for static functions
+//
# ifdef DEBUG
# include <assert.h>
# define DEBUG_puts(x)
# define DEBUG_printf(x)
# define DEBUG_assert(x)
-# endif /* DEBUG */
+# endif // DEBUG
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
# ifdef DEBUG
extern int _ppd_debug_fd;
extern int _ppd_debug_level;
extern void _ppd_debug_printf(const char *format, ...);
extern void _ppd_debug_puts(const char *s);
-# endif /* DEBUG */
+# endif // DEBUG
# ifdef __cplusplus
}
-# endif /* __cplusplus */
+# endif // __cplusplus
-#endif /* !_PPD_DEBUG_INTERNAL_H_ */
+#endif // !_PPD_DEBUG_INTERNAL_H_
-/*
- * Private debugging APIs for libppd.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private debugging APIs for libppd.
+//
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _PPD_DEBUG_PRIVATE_H_
# define _PPD_DEBUG_PRIVATE_H_
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
-
-
-/*
- * The debug macros are used if you compile with DEBUG defined.
- *
- * Usage:
- *
- * DEBUG_set("logfile", "level", "filter", 1)
- *
- * The DEBUG_set macro allows an application to programmatically enable (or
- * disable) debug logging. The arguments correspond to the PPD_DEBUG_LOG,
- * PPD_DEBUG_LEVEL, and PPD_DEBUG_FILTER environment variables. The 1 on the
- * end forces the values to override the environment.
- */
+# endif // __cplusplus
+
+
+//
+// The debug macros are used if you compile with DEBUG defined.
+//
+// Usage:
+//
+// DEBUG_set("logfile", "level", "filter", 1)
+//
+// The DEBUG_set macro allows an application to programmatically enable (or
+// disable) debug logging. The arguments correspond to the PPD_DEBUG_LOG,
+// PPD_DEBUG_LEVEL, and PPD_DEBUG_FILTER environment variables. The 1 on the
+// end forces the values to override the environment.
+//
# ifdef DEBUG
# define DEBUG_set(logfile,level,filter) _ppd_debug_set(logfile,level,filter,1)
# else
# define DEBUG_set(logfile,level,filter)
-# endif /* DEBUG */
+# endif // DEBUG
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
extern void _ppd_debug_set(const char *logfile, const char *level, const char *filter, int force);
# ifdef _WIN32
extern int _ppd_gettimeofday(struct timeval *tv, void *tz);
# define gettimeofday(a,b) _ppd_gettimeofday(a, b)
-# endif /* _WIN32 */
+# endif // _WIN32
# ifdef __cplusplus
}
-# endif /* __cplusplus */
+# endif // __cplusplus
-#endif /* !_PPD_DEBUG_PRIVATE_H_ */
+#endif // !_PPD_DEBUG_PRIVATE_H_
-/*
- * Debugging functions for libppd.
- *
- * Copyright © 2008-2018 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Debugging functions for libppd.
+//
+// Copyright © 2008-2018 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "debug-internal.h"
# include <time.h>
# include <io.h>
# define getpid (int)GetCurrentProcessId
-int /* O - 0 on success, -1 on failure */
-_ppd_gettimeofday(struct timeval *tv, /* I - Timeval struct */
- void *tz) /* I - Timezone */
+int // O - 0 on success, -1 on failure
+_ppd_gettimeofday(struct timeval *tv, // I - Timeval struct
+ void *tz) // I - Timezone
{
- struct _timeb timebuffer; /* Time buffer struct */
+ struct _timeb timebuffer; // Time buffer struct
_ftime(&timebuffer);
tv->tv_sec = (long)timebuffer.time;
tv->tv_usec = timebuffer.millitm * 1000;
#else
# include <sys/time.h>
# include <unistd.h>
-#endif /* _WIN32 */
+#endif // _WIN32
#include <regex.h>
#include <fcntl.h>
#ifdef DEBUG
-/*
- * Globals...
- */
+//
+// Globals...
+//
int _ppd_debug_fd = -1;
- /* Debug log file descriptor */
+ // Debug log file descriptor
int _ppd_debug_level = 1;
- /* Log level (0 to 9) */
+ // Log level (0 to 9)
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
static regex_t *debug_filter = NULL;
- /* Filter expression for messages */
-static int debug_init = 0; /* Did we initialize debugging? */
+ // Filter expression for messages
+static int debug_init = 0; // Did we initialize debugging?
-/*
- * '_ppd_debug_printf()' - Write a formatted line to the log.
- */
+//
+// '_ppd_debug_printf()' - Write a formatted line to the log.
+//
void
-_ppd_debug_printf(const char *format, /* I - Printf-style format string */
- ...) /* I - Additional arguments as needed */
+_ppd_debug_printf(const char *format, // I - Printf-style format string
+ ...) // I - Additional arguments as needed
{
- va_list ap; /* Pointer to arguments */
- struct timeval curtime; /* Current time */
- char buffer[2048]; /* Output buffer */
- ssize_t bytes; /* Number of bytes in buffer */
- int level; /* Log level in message */
+ va_list ap; // Pointer to arguments
+ struct timeval curtime; // Current time
+ char buffer[2048]; // Output buffer
+ ssize_t bytes; // Number of bytes in buffer
+ int level; // Log level in message
- /*
- * See if we need to do any logging...
- */
+ //
+ // See if we need to do any logging...
+ //
if (!debug_init)
_ppd_debug_set(getenv("PPD_DEBUG_LOG"), getenv("PPD_DEBUG_LEVEL"),
if (_ppd_debug_fd < 0)
return;
- /*
- * Filter as needed...
- */
+ //
+ // Filter as needed...
+ //
if (isdigit(format[0]))
level = *format++ - '0';
if (debug_filter)
{
- int result; /* Filter result */
+ int result; // Filter result
result = regexec(debug_filter, format, 0, NULL, 0);
return;
}
- /*
- * Format the message...
- */
+ //
+ // Format the message...
+ //
gettimeofday(&curtime, NULL);
snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d.%03d ",
(int)(curtime.tv_sec % 60), (int)(curtime.tv_usec / 1000));
va_start(ap, format);
- bytes = _ppd_safe_vsnprintf(buffer + 19, sizeof(buffer) - 20, format, ap) + 19;
+ bytes = _ppd_safe_vsnprintf(buffer + 19, sizeof(buffer) - 20, format, ap) +
+ 19;
va_end(ap);
if ((size_t)bytes >= (sizeof(buffer) - 1))
buffer[bytes] = '\0';
}
- /*
- * Write it out...
- */
+ //
+ // Write it out...
+ //
write(_ppd_debug_fd, buffer, (size_t)bytes);
}
-/*
- * '_ppd_debug_puts()' - Write a single line to the log.
- */
+//
+// '_ppd_debug_puts()' - Write a single line to the log.
+//
void
-_ppd_debug_puts(const char *s) /* I - String to output */
+_ppd_debug_puts(const char *s) // I - String to output
{
- struct timeval curtime; /* Current time */
- char buffer[2048]; /* Output buffer */
- ssize_t bytes; /* Number of bytes in buffer */
- int level; /* Log level in message */
+ struct timeval curtime; // Current time
+ char buffer[2048]; // Output buffer
+ ssize_t bytes; // Number of bytes in buffer
+ int level; // Log level in message
- /*
- * See if we need to do any logging...
- */
+ //
+ // See if we need to do any logging...
+ //
if (!debug_init)
_ppd_debug_set(getenv("PPD_DEBUG_LOG"), getenv("PPD_DEBUG_LEVEL"),
if (_ppd_debug_fd < 0)
return;
- /*
- * Filter as needed...
- */
+ //
+ // Filter as needed...
+ //
if (isdigit(s[0]))
level = *s++ - '0';
if (debug_filter)
{
- int result; /* Filter result */
+ int result; // Filter result
result = regexec(debug_filter, s, 0, NULL, 0);
return;
}
- /*
- * Format the message...
- */
+ //
+ // Format the message...
+ //
gettimeofday(&curtime, NULL);
bytes = snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d.%03d %s",
buffer[bytes] = '\0';
}
- /*
- * Write it out...
- */
+ //
+ // Write it out...
+ //
write(_ppd_debug_fd, buffer, (size_t)bytes);
}
-/*
- * '_ppd_debug_set()' - Enable or disable debug logging.
- */
+//
+// '_ppd_debug_set()' - Enable or disable debug logging.
+//
void
-_ppd_debug_set(const char *logfile, /* I - Log file or NULL */
- const char *level, /* I - Log level or NULL */
- const char *filter, /* I - Filter string or NULL */
- int force) /* I - Force initialization */
+_ppd_debug_set(const char *logfile, // I - Log file or NULL
+ const char *level, // I - Log level or NULL
+ const char *filter, // I - Filter string or NULL
+ int force) // I - Force initialization
{
if (!debug_init || force)
{
- /*
- * Restore debug settings to defaults...
- */
+ //
+ // Restore debug settings to defaults...
+ //
if (_ppd_debug_fd != -1)
{
_ppd_debug_level = 1;
- /*
- * Open logs, set log levels, etc.
- */
+ //
+ // Open logs, set log levels, etc.
+ //
if (!logfile)
_ppd_debug_fd = -1;
_ppd_debug_fd = 2;
else
{
- char buffer[1024]; /* Filename buffer */
+ char buffer[1024]; // Filename buffer
snprintf(buffer, sizeof(buffer), logfile, getpid());
debug_init = 1;
}
-
}
#else
-/*
- * '_ppd_debug_set()' - Enable or disable debug logging.
- */
+//
+// '_ppd_debug_set()' - Enable or disable debug logging.
+//
void
-_ppd_debug_set(const char *logfile, /* I - Log file or NULL */
- const char *level, /* I - Log level or NULL */
- const char *filter, /* I - Filter string or NULL */
- int force) /* I - Force initialization */
+_ppd_debug_set(const char *logfile, // I - Log file or NULL
+ const char *level, // I - Log level or NULL
+ const char *filter, // I - Filter string or NULL
+ int force) // I - Force initialization
{
(void)logfile;
(void)level;
(void)filter;
(void)force;
}
-#endif /* DEBUG */
+#endif // DEBUG
-/*
- * '_ppd_safe_vsnprintf()' - Format a string into a fixed size buffer,
- * quoting special characters.
- */
+//
+// '_ppd_safe_vsnprintf()' - Format a string into a fixed size buffer,
+// quoting special characters.
+//
-ssize_t /* O - Number of bytes formatted */
+ssize_t // O - Number of bytes formatted
_ppd_safe_vsnprintf(
- char *buffer, /* O - Output buffer */
- size_t bufsize, /* O - Size of output buffer */
- const char *format, /* I - printf-style format string */
- va_list ap) /* I - Pointer to additional arguments */
+ char *buffer, // O - Output buffer
+ size_t bufsize, // O - Size of output buffer
+ const char *format, // I - printf-style format string
+ va_list ap) // I - Pointer to additional arguments
{
- char *bufptr, /* Pointer to position in buffer */
- *bufend, /* Pointer to end of buffer */
- size, /* Size character (h, l, L) */
- type; /* Format type character */
- int width, /* Width of field */
- prec; /* Number of characters of precision */
- char tformat[100], /* Temporary format string for snprintf() */
- *tptr, /* Pointer into temporary format */
- temp[1024]; /* Buffer for formatted numbers */
- char *s; /* Pointer to string */
- ssize_t bytes; /* Total number of bytes needed */
+ char *bufptr, // Pointer to position in buffer
+ *bufend, // Pointer to end of buffer
+ size, // Size character (h, l, L)
+ type; // Format type character
+ int width, // Width of field
+ prec; // Number of characters of precision
+ char tformat[100], // Temporary format string for snprintf()
+ *tptr, // Pointer into temporary format
+ temp[1024]; // Buffer for formatted numbers
+ char *s; // Pointer to string
+ ssize_t bytes; // Total number of bytes needed
if (!buffer || bufsize < 2 || !format)
return (-1);
- /*
- * Loop through the format string, formatting as needed...
- */
+ //
+ // Loop through the format string, formatting as needed...
+ //
bufptr = buffer;
bufend = buffer + bufsize - 1;
if (*format == '*')
{
- /*
- * Get width from argument...
- */
+ //
+ // Get width from argument...
+ //
format ++;
width = va_arg(ap, int);
if (*format == '*')
{
- /*
- * Get precision from argument...
- */
+ //
+ // Get precision from argument...
+ //
format ++;
prec = va_arg(ap, int);
switch (type)
{
- case 'E' : /* Floating point formats */
+ case 'E' : // Floating point formats
case 'G' :
case 'e' :
case 'f' :
}
break;
- case 'B' : /* Integer formats */
+ case 'B' : // Integer formats
case 'X' :
case 'b' :
case 'd' :
if (size == 'L')
snprintf(temp, sizeof(temp), tformat, va_arg(ap, long long));
else
-# endif /* HAVE_LONG_LONG */
+# endif // HAVE_LONG_LONG
if (size == 'l')
snprintf(temp, sizeof(temp), tformat, va_arg(ap, long));
else
}
break;
- case 'p' : /* Pointer value */
+ case 'p' : // Pointer value
if ((size_t)(width + 2) > sizeof(temp))
break;
}
break;
- case 'c' : /* Character or character array */
+ case 'c' : // Character or character array
bytes += width;
if (bufptr)
}
break;
- case 's' : /* String */
+ case 's' : // String
if ((s = va_arg(ap, char *)) == NULL)
s = "(null)";
- /*
- * Copy the C string, replacing control chars and \ with
- * C character escapes...
- */
+ //
+ // Copy the C string, replacing control chars and \ with
+ // C character escapes...
+ //
for (bufend --; *s && bufptr < bufend; s ++)
{
bufend ++;
break;
- case 'n' : /* Output number of chars so far */
+ case 'n' : // Output number of chars so far
*(va_arg(ap, int *)) = (int)bytes;
break;
}
}
}
- /*
- * Nul-terminate the string and return the number of characters needed.
- */
+ //
+ // Nul-terminate the string and return the number of characters needed.
+ //
*bufptr = '\0';
-/*
- * Option encoding routines for libppd.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Option encoding routines for libppd.
+//
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
#include "ipp-private.h"
#include "debug-internal.h"
-/*
- * Local list of option names, the value tags they should use, and the list of
- * supported operations...
- *
- * **** THIS LIST MUST BE SORTED BY ATTRIBUTE NAME ****
- */
+//
+// Local list of option names, the value tags they should use, and the list of
+// supported operations...
+//
+// **** THIS LIST MUST BE SORTED BY ATTRIBUTE NAME ****
+//
static const ipp_op_t ipp_job_creation[] =
{
{ 0, "copies", IPP_TAG_INTEGER, IPP_TAG_JOB,
IPP_TAG_DOCUMENT },
{ 0, "copies-default", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
- { 0, "date-time-at-completed",IPP_TAG_DATE, IPP_TAG_ZERO }, /* never send as option */
- { 0, "date-time-at-creation", IPP_TAG_DATE, IPP_TAG_ZERO }, /* never send as option */
- { 0, "date-time-at-processing",IPP_TAG_DATE, IPP_TAG_ZERO }, /* never send as option */
+ { 0, "date-time-at-completed",IPP_TAG_DATE, IPP_TAG_ZERO },
+ // never send as option
+ { 0, "date-time-at-creation", IPP_TAG_DATE, IPP_TAG_ZERO },
+ // never send as option
+ { 0, "date-time-at-processing",IPP_TAG_DATE, IPP_TAG_ZERO },
+ // never send as option
{ 0, "device-uri", IPP_TAG_URI, IPP_TAG_PRINTER },
{ 1, "document-copies", IPP_TAG_RANGE, IPP_TAG_JOB,
IPP_TAG_DOCUMENT,
{ 0, "job-cancel-after-default", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
{ 0, "job-hold-until", IPP_TAG_KEYWORD, IPP_TAG_JOB },
{ 0, "job-hold-until-default", IPP_TAG_KEYWORD, IPP_TAG_PRINTER },
- { 0, "job-id", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */
+ { 0, "job-id", IPP_TAG_INTEGER, IPP_TAG_ZERO },
+ // never send as option
{ 0, "job-impressions", IPP_TAG_INTEGER, IPP_TAG_OPERATION },
- { 0, "job-impressions-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */
+ { 0, "job-impressions-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO },
+ // never send as option
{ 0, "job-k-limit", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
{ 0, "job-k-octets", IPP_TAG_INTEGER, IPP_TAG_OPERATION },
- { 0, "job-k-octets-completed",IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */
+ { 0, "job-k-octets-completed",IPP_TAG_INTEGER, IPP_TAG_ZERO },
+ // never send as option
{ 0, "job-media-sheets", IPP_TAG_INTEGER, IPP_TAG_OPERATION },
- { 0, "job-media-sheets-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */
+ { 0, "job-media-sheets-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO },
+ // never send as option
{ 0, "job-name", IPP_TAG_NAME, IPP_TAG_OPERATION,
IPP_TAG_JOB },
{ 0, "job-page-limit", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
{ 0, "job-pages", IPP_TAG_INTEGER, IPP_TAG_OPERATION },
- { 0, "job-pages-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */
+ { 0, "job-pages-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO },
+ // never send as option
{ 0, "job-password", IPP_TAG_STRING, IPP_TAG_OPERATION,
IPP_TAG_ZERO,
ipp_job_creation },
{ 0, "job-quota-period", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
{ 1, "job-sheets", IPP_TAG_NAME, IPP_TAG_JOB },
{ 1, "job-sheets-default", IPP_TAG_NAME, IPP_TAG_PRINTER },
- { 0, "job-state", IPP_TAG_ENUM, IPP_TAG_ZERO }, /* never send as option */
- { 0, "job-state-message", IPP_TAG_TEXT, IPP_TAG_ZERO }, /* never send as option */
- { 0, "job-state-reasons", IPP_TAG_KEYWORD, IPP_TAG_ZERO }, /* never send as option */
+ { 0, "job-state", IPP_TAG_ENUM, IPP_TAG_ZERO },
+ // never send as option
+ { 0, "job-state-message", IPP_TAG_TEXT, IPP_TAG_ZERO },
+ // never send as option
+ { 0, "job-state-reasons", IPP_TAG_KEYWORD, IPP_TAG_ZERO },
+ // never send as option
{ 0, "job-uuid", IPP_TAG_URI, IPP_TAG_JOB },
{ 0, "landscape", IPP_TAG_BOOLEAN, IPP_TAG_JOB },
{ 1, "marker-change-time", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
{ 0, "sides", IPP_TAG_KEYWORD, IPP_TAG_JOB,
IPP_TAG_DOCUMENT },
{ 0, "sides-default", IPP_TAG_KEYWORD, IPP_TAG_PRINTER },
- { 0, "time-at-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */
- { 0, "time-at-creation", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */
- { 0, "time-at-processing", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */
+ { 0, "time-at-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO },
+ // never send as option
+ { 0, "time-at-creation", IPP_TAG_INTEGER, IPP_TAG_ZERO },
+ // never send as option
+ { 0, "time-at-processing", IPP_TAG_INTEGER, IPP_TAG_ZERO },
+ // never send as option
{ 0, "wrap", IPP_TAG_BOOLEAN, IPP_TAG_JOB },
{ 0, "wrap-default", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER },
{ 0, "x-dimension", IPP_TAG_INTEGER, IPP_TAG_JOB,
};
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static int ppd_compare_ipp_options(_ppd_ipp_option_t *a,
_ppd_ipp_option_t *b);
-/*
- * '_ppdIppFindOption()' - Find the attribute information for an option.
- */
+//
+// '_ppdIppFindOption()' - Find the attribute information for an option.
+//
-_ppd_ipp_option_t * /* O - Attribute information */
-_ppdIppFindOption(const char *name) /* I - Option/attribute name */
+_ppd_ipp_option_t * // O - Attribute information
+_ppdIppFindOption(const char *name) // I - Option/attribute name
{
- _ppd_ipp_option_t key; /* Search key */
+ _ppd_ipp_option_t key; // Search key
- /*
- * Lookup the proper value and group tags for this option...
- */
+ //
+ // Lookup the proper value and group tags for this option...
+ //
key.name = name;
return ((_ppd_ipp_option_t *)bsearch(&key, ipp_options,
- sizeof(ipp_options) / sizeof(ipp_options[0]),
- sizeof(ipp_options[0]),
- (int (*)(const void *, const void *))
+ sizeof(ipp_options) /
+ sizeof(ipp_options[0]),
+ sizeof(ipp_options[0]),
+ (int (*)(const void *, const void *))
ppd_compare_ipp_options));
}
-/*
- * 'ppd_compare_ipp_options()' - Compare two IPP options.
- */
+//
+// 'ppd_compare_ipp_options()' - Compare two IPP options.
+//
-static int /* O - Result of comparison */
-ppd_compare_ipp_options(_ppd_ipp_option_t *a, /* I - First option */
- _ppd_ipp_option_t *b) /* I - Second option */
+static int // O - Result of comparison
+ppd_compare_ipp_options(_ppd_ipp_option_t *a, // I - First option
+ _ppd_ipp_option_t *b) // I - Second option
{
return (strcmp(a->name, b->name));
}
-/*
- * This file contains model number definitions for the CUPS sample
- * ESC/P driver.
- *
- * Copyright 2007 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// This file contains model number definitions for the cups-filters sample
+// ESC/P driver.
+//
+// Copyright 2007 by Apple Inc.
+// Copyright 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
-#define EPSON_9PIN 0 /* 9-pin dot matrix */
-#define EPSON_24PIN 1 /* 24-pin dot matrix */
-#define EPSON_COLOR 2 /* Epson Stylus Color with ESC . */
-#define EPSON_PHOTO 3 /* Epson Stylus Photo with ESC . */
-#define EPSON_ICOLOR 4 /* Epson Stylus Color with ESC i */
-#define EPSON_IPHOTO 5 /* Epson Stylus Photo with ESC i */
+#define EPSON_9PIN 0 // 9-pin dot matrix
+#define EPSON_24PIN 1 // 24-pin dot matrix
+#define EPSON_COLOR 2 // Epson Stylus Color with ESC .
+#define EPSON_PHOTO 3 // Epson Stylus Photo with ESC .
+#define EPSON_ICOLOR 4 // Epson Stylus Color with ESC i
+#define EPSON_IPHOTO 5 // Epson Stylus Photo with ESC i
-/*
- * Private file check definitions for libppd.
- *
- * Copyright © 2007-2018 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.
- */
+//
+// Private file check definitions for libppd.
+//
+// Copyright © 2007-2018 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.
+//
#ifndef _PPD_FILE_PRIVATE_H_
# define _PPD_FILE_PRIVATE_H_
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
# include "string-private.h"
# include <cupsfilters/log.h>
# ifdef _WIN32
# include <io.h>
# include <sys/locking.h>
-# endif /* _WIN32 */
+# endif // _WIN32
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
-typedef enum /**** _ppdFileCheck return values ****/
+typedef enum // **** _ppdFileCheck return values ****
{
- _PPD_FILE_CHECK_OK = 0, /* Everything OK */
- _PPD_FILE_CHECK_MISSING = 1, /* File is missing */
- _PPD_FILE_CHECK_PERMISSIONS = 2, /* File (or parent dir) has bad perms */
- _PPD_FILE_CHECK_WRONG_TYPE = 3, /* File has wrong type */
- _PPD_FILE_CHECK_RELATIVE_PATH = 4 /* File contains a relative path */
+ _PPD_FILE_CHECK_OK = 0, // Everything OK
+ _PPD_FILE_CHECK_MISSING = 1, // File is missing
+ _PPD_FILE_CHECK_PERMISSIONS = 2, // File (or parent dir) has bad perms
+ _PPD_FILE_CHECK_WRONG_TYPE = 3, // File has wrong type
+ _PPD_FILE_CHECK_RELATIVE_PATH = 4 // File contains a relative path
} _ppd_fc_result_t;
-typedef enum /**** _ppdFileCheck file type
- values ****/
+typedef enum // **** _ppdFileCheck file type
+ // values ****
{
- _PPD_FILE_CHECK_FILE = 0, /* Check the file and parent
- directory */
- _PPD_FILE_CHECK_PROGRAM = 1, /* Check the program and parent
- directory */
- _PPD_FILE_CHECK_FILE_ONLY = 2, /* Check the file only */
- _PPD_FILE_CHECK_DIRECTORY = 3 /* Check the directory */
+ _PPD_FILE_CHECK_FILE = 0, // Check the file and parent
+ // directory
+ _PPD_FILE_CHECK_PROGRAM = 1, // Check the program and parent
+ // directory
+ _PPD_FILE_CHECK_FILE_ONLY = 2, // Check the file only
+ _PPD_FILE_CHECK_DIRECTORY = 3 // Check the directory
} _ppd_fc_filetype_t;
typedef void (*_ppd_fc_func_t)(void *context, _ppd_fc_result_t result,
- const char *message);
+ const char *message);
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
extern _ppd_fc_result_t _ppdFileCheck(const char *filename,
_ppd_fc_filetype_t filetype,
# ifdef __cplusplus
}
-# endif /* __cplusplus */
+# endif // __cplusplus
-#endif /* !_PPD_FILE_PRIVATE_H_ */
+#endif // !_PPD_FILE_PRIVATE_H_
-/*
- * File functions for libppd
- *
- * Copyright © 2007-2019 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.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// File functions for libppd
+//
+// Copyright © 2007-2019 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.
+
+
+//
+// Include necessary headers...
+//
#include "file-private.h"
#include "language-private.h"
# ifdef HAVE_LIBZ
# include <zlib.h>
-# endif /* HAVE_LIBZ */
+# endif // HAVE_LIBZ
#ifndef _WIN32
-/*
- * '_ppdFileCheck()' - Check the permissions of the given filename.
- */
+//
+// '_ppdFileCheck()' - Check the permissions of the given filename.
+//
-_ppd_fc_result_t /* O - Check result */
+_ppd_fc_result_t // O - Check result
_ppdFileCheck(
- const char *filename, /* I - Filename to check */
- _ppd_fc_filetype_t filetype, /* I - Type of file checks? */
- int dorootchecks, /* I - Check for root permissions? */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Data pointer for log function */
+ const char *filename, // I - Filename to check
+ _ppd_fc_filetype_t filetype, // I - Type of file checks?
+ int dorootchecks, // I - Check for root permissions?
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Data pointer for log function
{
- struct stat fileinfo; /* File information */
- char message[1024], /* Message string */
- temp[1024], /* Parent directory filename */
- *ptr; /* Pointer into parent directory */
- _ppd_fc_result_t result; /* Check result */
+ struct stat fileinfo; // File information
+ char message[1024], // Message string
+ temp[1024], // Parent directory filename
+ *ptr; // Pointer into parent directory
+ _ppd_fc_result_t result; // Check result
- /*
- * Does the filename contain a relative path ("../")?
- */
+ //
+ // Does the filename contain a relative path ("../")?
+ //
if (strstr(filename, "../"))
{
- /*
- * Yes, fail it!
- */
+ //
+ // Yes, fail it!
+ //
result = _PPD_FILE_CHECK_RELATIVE_PATH;
goto finishup;
}
- /*
- * Does the program even exist and is it accessible?
- */
+ //
+ // Does the program even exist and is it accessible?
+ //
if (stat(filename, &fileinfo))
{
- /*
- * Nope...
- */
+ //
+ // Nope...
+ //
result = _PPD_FILE_CHECK_MISSING;
goto finishup;
}
- /*
- * Check the execute bit...
- */
+ //
+ // Check the execute bit...
+ //
result = _PPD_FILE_CHECK_OK;
if (result)
goto finishup;
- /*
- * Are we doing root checks?
- */
+ //
+ // Are we doing root checks?
+ //
if (!dorootchecks)
{
- /*
- * Nope, so anything (else) goes...
- */
+ //
+ // Nope, so anything (else) goes...
+ //
goto finishup;
}
- /*
- * Verify permission of the file itself:
- *
- * 1. Must be owned by root
- * 2. Must not be writable by group
- * 3. Must not be setuid
- * 4. Must not be writable by others
- */
-
- if (fileinfo.st_uid || /* 1. Must be owned by root */
- (fileinfo.st_mode & S_IWGRP) || /* 2. Must not be writable by group */
- (fileinfo.st_mode & S_ISUID) || /* 3. Must not be setuid */
- (fileinfo.st_mode & S_IWOTH)) /* 4. Must not be writable by others */
+ //
+ // Verify permission of the file itself:
+ //
+ // 1. Must be owned by root
+ // 2. Must not be writable by group
+ // 3. Must not be setuid
+ // 4. Must not be writable by others
+ //
+
+ if (fileinfo.st_uid || // 1. Must be owned by root
+ (fileinfo.st_mode & S_IWGRP) || // 2. Must not be writable by group
+ (fileinfo.st_mode & S_ISUID) || // 3. Must not be setuid
+ (fileinfo.st_mode & S_IWOTH)) // 4. Must not be writable by others
{
result = _PPD_FILE_CHECK_PERMISSIONS;
goto finishup;
filetype == _PPD_FILE_CHECK_FILE_ONLY)
goto finishup;
- /*
- * Now check the containing directory...
- */
+ //
+ // Now check the containing directory...
+ //
strlcpy(temp, filename, sizeof(temp));
if ((ptr = strrchr(temp, '/')) != NULL)
if (stat(temp, &fileinfo))
{
- /*
- * Doesn't exist?!?
- */
+ //
+ // Doesn't exist?!?
+ //
result = _PPD_FILE_CHECK_MISSING;
filetype = _PPD_FILE_CHECK_DIRECTORY;
goto finishup;
}
- if (fileinfo.st_uid || /* 1. Must be owned by root */
- (fileinfo.st_mode & S_IWGRP) || /* 2. Must not be writable by group */
- (fileinfo.st_mode & S_ISUID) || /* 3. Must not be setuid */
- (fileinfo.st_mode & S_IWOTH)) /* 4. Must not be writable by others */
+ if (fileinfo.st_uid || // 1. Must be owned by root
+ (fileinfo.st_mode & S_IWGRP) || // 2. Must not be writable by group
+ (fileinfo.st_mode & S_ISUID) || // 3. Must not be setuid
+ (fileinfo.st_mode & S_IWOTH)) // 4. Must not be writable by others
{
result = _PPD_FILE_CHECK_PERMISSIONS;
filetype = _PPD_FILE_CHECK_DIRECTORY;
filename = temp;
}
- /*
- * Common return point...
- */
+ //
+ // Common return point...
+ //
finishup:
if (log)
{
cups_lang_t *lang = cupsLangDefault();
- /* Localization information */
+ // Localization information
cf_loglevel_t loglevel;
switch (result)
if (filetype == _PPD_FILE_CHECK_DIRECTORY)
snprintf(message, sizeof(message),
_ppdLangString(lang, _("Directory \"%s\" permissions OK "
- "(0%o/uid=%d/gid=%d).")),
+ "(0%o/uid=%d/gid=%d).")),
filename, fileinfo.st_mode, (int)fileinfo.st_uid,
(int)fileinfo.st_gid);
else
snprintf(message, sizeof(message),
_ppdLangString(lang, _("File \"%s\" permissions OK "
- "(0%o/uid=%d/gid=%d).")),
+ "(0%o/uid=%d/gid=%d).")),
filename, fileinfo.st_mode, (int)fileinfo.st_uid,
(int)fileinfo.st_gid);
break;
if (filetype == _PPD_FILE_CHECK_DIRECTORY)
snprintf(message, sizeof(message),
_ppdLangString(lang, _("Directory \"%s\" not available: "
- "%s")),
+ "%s")),
filename, strerror(errno));
else
snprintf(message, sizeof(message),
if (filetype == _PPD_FILE_CHECK_DIRECTORY)
snprintf(message, sizeof(message),
_ppdLangString(lang, _("Directory \"%s\" has insecure "
- "permissions "
- "(0%o/uid=%d/gid=%d).")),
+ "permissions "
+ "(0%o/uid=%d/gid=%d).")),
filename, fileinfo.st_mode, (int)fileinfo.st_uid,
(int)fileinfo.st_gid);
else
snprintf(message, sizeof(message),
_ppdLangString(lang, _("File \"%s\" has insecure "
- "permissions "
- "(0%o/uid=%d/gid=%d).")),
+ "permissions "
+ "(0%o/uid=%d/gid=%d).")),
filename, fileinfo.st_mode, (int)fileinfo.st_uid,
(int)fileinfo.st_gid);
break;
if (filetype == _PPD_FILE_CHECK_DIRECTORY)
snprintf(message, sizeof(message),
_ppdLangString(lang, _("Directory \"%s\" contains a "
- "relative path.")), filename);
+ "relative path.")), filename);
else
snprintf(message, sizeof(message),
_ppdLangString(lang, _("File \"%s\" contains a relative "
- "path.")), filename);
+ "path.")), filename);
break;
}
return (result);
}
-#endif /* !_WIN32 */
+#endif // !_WIN32
//
-// GNU gettext message generator for the CUPS PPD Compiler.
+// GNU gettext message generator for the libppd PPD Compiler.
//
// This program is used to generate a dummy source file containing all of
// the standard media and sample driver strings. The results are picked up
//
static void
-write_cstring(const char *s) /* I - String to write */
+write_cstring(const char *s) // I - String to write
{
fputs("_(\"", stdout);
if (s)
-/*
- * This file contains model number definitions for the CUPS sample
- * HP driver.
- *
- * Copyright 2007 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// This file contains model number definitions for the CUPS sample
+// HP driver.
+//
+// Copyright 2007 by Apple Inc.
+// Copyright 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
-#define HP_LASERJET 0 /* HP LaserJet */
-#define HP_DESKJET 1 /* HP DeskJet with simple color */
-#define HP_DESKJET2 2 /* HP DeskJet with CRet color */
+#define HP_LASERJET 0 // HP LaserJet
+#define HP_DESKJET 1 // HP DeskJet with simple color
+#define HP_DESKJET2 2 // HP DeskJet with CRet color
-/*
- * PostScript filter function and image file to PostScript filter function
- * for libppd.
- *
- * Copyright © 2020 by Till Kamppeter
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1993-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// PostScript filter function and image file to PostScript filter function
+// for libppd.
+//
+// Copyright © 2020 by Till Kamppeter
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1993-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include <cupsfilters/filter.h>
#include <cupsfilters/image.h>
#include <sys/wait.h>
-/*
- * Constants...
- */
-
-#define PSTOPS_BORDERNONE 0 /* No border or hairline border */
-#define PSTOPS_BORDERTHICK 1 /* Think border */
-#define PSTOPS_BORDERSINGLE 2 /* Single-line hairline border */
-#define PSTOPS_BORDERSINGLE2 3 /* Single-line thick border */
-#define PSTOPS_BORDERDOUBLE 4 /* Double-line hairline border */
-#define PSTOPS_BORDERDOUBLE2 5 /* Double-line thick border */
-
-#define PSTOPS_LAYOUT_LRBT 0 /* Left to right, bottom to top */
-#define PSTOPS_LAYOUT_LRTB 1 /* Left to right, top to bottom */
-#define PSTOPS_LAYOUT_RLBT 2 /* Right to left, bottom to top */
-#define PSTOPS_LAYOUT_RLTB 3 /* Right to left, top to bottom */
-#define PSTOPS_LAYOUT_BTLR 4 /* Bottom to top, left to right */
-#define PSTOPS_LAYOUT_TBLR 5 /* Top to bottom, left to right */
-#define PSTOPS_LAYOUT_BTRL 6 /* Bottom to top, right to left */
-#define PSTOPS_LAYOUT_TBRL 7 /* Top to bottom, right to left */
-
-#define PSTOPS_LAYOUT_NEGATEY 1 /* The bits for the layout */
-#define PSTOPS_LAYOUT_NEGATEX 2 /* definitions above... */
+//
+// Constants...
+//
+
+#define PSTOPS_BORDERNONE 0 // No border or hairline border
+#define PSTOPS_BORDERTHICK 1 // Think border
+#define PSTOPS_BORDERSINGLE 2 // Single-line hairline border
+#define PSTOPS_BORDERSINGLE2 3 // Single-line thick border
+#define PSTOPS_BORDERDOUBLE 4 // Double-line hairline border
+#define PSTOPS_BORDERDOUBLE2 5 // Double-line thick border
+
+#define PSTOPS_LAYOUT_LRBT 0 // Left to right, bottom to top
+#define PSTOPS_LAYOUT_LRTB 1 // Left to right, top to bottom
+#define PSTOPS_LAYOUT_RLBT 2 // Right to left, bottom to top
+#define PSTOPS_LAYOUT_RLTB 3 // Right to left, top to bottom
+#define PSTOPS_LAYOUT_BTLR 4 // Bottom to top, left to right
+#define PSTOPS_LAYOUT_TBLR 5 // Top to bottom, left to right
+#define PSTOPS_LAYOUT_BTRL 6 // Bottom to top, right to left
+#define PSTOPS_LAYOUT_TBRL 7 // Top to bottom, right to left
+
+#define PSTOPS_LAYOUT_NEGATEY 1 // The bits for the layout
+#define PSTOPS_LAYOUT_NEGATEX 2 // definitions above...
#define PSTOPS_LAYOUT_VERTICAL 4
-/*
- * Types...
- */
+//
+// Types...
+//
-typedef struct /**** Page information ****/
+typedef struct // **** Page information ****
{
- char *label; /* Page label */
- int bounding_box[4]; /* PageBoundingBox */
- off_t offset; /* Offset to start of page */
- ssize_t length; /* Number of bytes for page */
- int num_options; /* Number of options for this page */
- cups_option_t *options; /* Options for this page */
+ char *label; // Page label
+ int bounding_box[4]; // PageBoundingBox
+ off_t offset; // Offset to start of page
+ ssize_t length; // Number of bytes for page
+ int num_options; // Number of options for this page
+ cups_option_t *options; // Options for this page
} pstops_page_t;
-typedef struct /**** Document information ****/
+typedef struct // **** Document information ****
{
- int page; /* Current page */
- int bounding_box[4]; /* BoundingBox from header */
- int new_bounding_box[4]; /* New composite bounding box */
- int num_options; /* Number of document-wide options */
- cups_option_t *options; /* Document-wide options */
- int normal_landscape, /* Normal rotation for landscape? */
- saw_eof, /* Saw the %%EOF comment? */
- slow_collate, /* Collate copies by hand? */
- slow_duplex, /* Duplex pages slowly? */
- slow_order, /* Reverse pages slowly? */
- use_ESPshowpage; /* Use ESPshowpage? */
- cups_array_t *pages; /* Pages in document */
- cups_file_t *temp; /* Temporary file, if any */
- char tempfile[1024]; /* Temporary filename */
- int job_id; /* Job ID */
- const char *user, /* User name */
- *title; /* Job name */
- int copies; /* Number of copies */
- const char *ap_input_slot, /* AP_FIRSTPAGE_InputSlot value */
- *ap_manual_feed, /* AP_FIRSTPAGE_ManualFeed value */
- *ap_media_color, /* AP_FIRSTPAGE_MediaColor value */
- *ap_media_type, /* AP_FIRSTPAGE_MediaType value */
- *ap_page_region, /* AP_FIRSTPAGE_PageRegion value */
- *ap_page_size; /* AP_FIRSTPAGE_PageSize value */
- int collate, /* Collate copies? */
- emit_jcl, /* Emit JCL commands? */
- fit_to_page; /* Fit pages to media */
- const char *input_slot, /* InputSlot value */
- *manual_feed, /* ManualFeed value */
- *media_color, /* MediaColor value */
- *media_type, /* MediaType value */
- *page_region, /* PageRegion value */
- *page_size; /* PageSize value */
- int mirror, /* doc->mirror/mirror pages */
- number_up, /* Number of pages on each sheet */
- number_up_layout, /* doc->number_up_layout of N-up
- pages */
- output_order, /* Requested reverse output order? */
- page_border; /* doc->page_border around pages */
- const char *page_label, /* page-label option, if any */
- *page_ranges, /* page-ranges option, if any */
- *inputPageRange, /* input-page-ranges option, if any */
- *page_set; /* page-set option, if any */
- /* Basic settings from PPD defaults/options, global vars of original pstops */
- int Orientation, /* 0 = portrait, 1 = landscape, etc. */
- Duplex, /* Duplexed? */
- LanguageLevel, /* PS Language level of printer */
- Color; /* Color printer? */
- float PageLeft, /* Left margin */
- PageRight, /* Right margin */
- PageBottom, /* Bottom margin */
- PageTop, /* Top margin */
- PageWidth, /* Total page width */
- PageLength; /* Total page length */
- cups_file_t *inputfp; /* Temporary file, if any */
- FILE *outputfp; /* Temporary file, if any */
- cf_logfunc_t logfunc; /* Logging function, NULL for no
- logging */
- void *logdata; /* User data for logging function, can
- be NULL */
- cf_filter_iscanceledfunc_t iscanceledfunc; /* Function returning 1 when
- job is canceled, NULL for not
- supporting stop on cancel */
- void *iscanceleddata; /* User data for is-canceled function,
- can be NULL */
+ int page; // Current page
+ int bounding_box[4]; // BoundingBox from header
+ int new_bounding_box[4]; // New composite bounding box
+ int num_options; // Number of document-wide options
+ cups_option_t *options; // Document-wide options
+ int normal_landscape, // Normal rotation for landscape?
+ saw_eof, // Saw the %%EOF comment?
+ slow_collate, // Collate copies by hand?
+ slow_duplex, // Duplex pages slowly?
+ slow_order, // Reverse pages slowly?
+ use_ESPshowpage; // Use ESPshowpage?
+ cups_array_t *pages; // Pages in document
+ cups_file_t *temp; // Temporary file, if any
+ char tempfile[1024]; // Temporary filename
+ int job_id; // Job ID
+ const char *user, // User name
+ *title; // Job name
+ int copies; // Number of copies
+ const char *ap_input_slot, // AP_FIRSTPAGE_InputSlot value
+ *ap_manual_feed, // AP_FIRSTPAGE_ManualFeed value
+ *ap_media_color, // AP_FIRSTPAGE_MediaColor value
+ *ap_media_type, // AP_FIRSTPAGE_MediaType value
+ *ap_page_region, // AP_FIRSTPAGE_PageRegion value
+ *ap_page_size; // AP_FIRSTPAGE_PageSize value
+ int collate, // Collate copies?
+ emit_jcl, // Emit JCL commands?
+ fit_to_page; // Fit pages to media
+ const char *input_slot, // InputSlot value
+ *manual_feed, // ManualFeed value
+ *media_color, // MediaColor value
+ *media_type, // MediaType value
+ *page_region, // PageRegion value
+ *page_size; // PageSize value
+ int mirror, // doc->mirror/mirror pages
+ number_up, // Number of pages on each sheet
+ number_up_layout, // doc->number_up_layout of N-up
+ // pages
+ output_order, // Requested reverse output order?
+ page_border; // doc->page_border around pages
+ const char *page_label, // page-label option, if any
+ *page_ranges, // page-ranges option, if any
+ *inputPageRange, // input-page-ranges option, if any
+ *page_set; // page-set option, if any
+ // Basic settings from PPD defaults/options, global vars of original pstops
+ int Orientation, // 0 = portrait, 1 = landscape, etc.
+ Duplex, // Duplexed?
+ LanguageLevel, // PS Language level of printer
+ Color; // Color printer?
+ float PageLeft, // Left margin
+ PageRight, // Right margin
+ PageBottom, // Bottom margin
+ PageTop, // Top margin
+ PageWidth, // Total page width
+ PageLength; // Total page length
+ cups_file_t *inputfp; // Temporary file, if any
+ FILE *outputfp; // Temporary file, if any
+ cf_logfunc_t logfunc; // Logging function, NULL for no
+ // logging
+ void *logdata; // User data for logging function, can
+ // be NULL
+ cf_filter_iscanceledfunc_t iscanceledfunc; // Function returning 1 when
+ // job is canceled, NULL for not
+ // supporting stop on cancel
+ void *iscanceleddata; // User data for is-canceled function,
+ // can be NULL
} pstops_doc_t;
-/*
- * Convenience macros...
- */
+//
+// Convenience macros...
+//
#define is_first_page(p) (doc->number_up == 1 || \
((p) % doc->number_up) == 1)
((p) % doc->number_up) != 0)
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static pstops_page_t *add_page(pstops_doc_t *doc, const char *label);
-static int check_range(int page ,const char *Ranges,const char *pageset);
+static int check_range(int page, const char *Ranges,
+ const char *pageset);
static void copy_bytes(pstops_doc_t *doc,
off_t offset, size_t length);
static ssize_t copy_comments(pstops_doc_t *doc,
float bottom, float top,
float width);
static void write_labels(pstops_doc_t *doc, int orient);
-static void write_labels_outputfile_only(pstops_doc_t *doc, int orient);
-static void write_options(pstops_doc_t *doc, ppd_file_t *ppd,
+static void write_labels_outputfile_only(pstops_doc_t *doc,
+ int orient);
+static void write_options(pstops_doc_t *doc, ppd_file_t *ppd,
int num_options, cups_option_t *options);
static void write_text_comment(pstops_doc_t *doc,
const char *name, const char *value);
-/*
- * 'ppdFilterPSToPS()' - Filter function to insert PostScript code from
- * PPD file (PostScript printer driver) into a
- * PostScript data stream
- */
-
-int /* O - Error status */
-ppdFilterPSToPS(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream */
- int inputseekable, /* I - Is input stream seekable? (unused) */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters) /* I - Filter-specific parameters (unused) */
+
+//
+// 'ppdFilterPSToPS()' - Filter function to insert PostScript code from
+// PPD file (PostScript printer driver) into a
+// PostScript data stream
+//
+
+int // O - Error status
+ppdFilterPSToPS(int inputfd, // I - File descriptor input stream
+ int outputfd, // I - File descriptor output stream
+ int inputseekable, // I - Is input stream seekable?
+ // (unused)
+ cf_filter_data_t *data, // I - Job and printer data
+ void *parameters) // I - Filter-specific parameters
+ // (unused)
{
ppd_filter_data_ext_t *filter_data_ext =
(ppd_filter_data_ext_t *)cfFilterDataGetExt(data,
PPD_FILTER_DATA_EXT);
- pstops_doc_t doc; /* Document information */
- cups_file_t *inputfp,*fp; /* Print file */
- FILE *outputfp; /* Output data stream */
+ pstops_doc_t doc; // Document information
+ cups_file_t *inputfp,*fp; // Print file
+ FILE *outputfp; // Output data stream
char line[8192],
- buffer[8192]; /* Line buffers */
- ssize_t len,bytes; /* Length of line buffers */
- pstops_page_t *pageinfo;
- cf_logfunc_t log = data->logfunc;
- void *ld = data->logdata;
+ buffer[8192]; // Line buffers
+ ssize_t len, bytes; // Length of line buffers
+ pstops_page_t *pageinfo;
+ cf_logfunc_t log = data->logfunc;
+ void *ld = data->logdata;
cf_filter_iscanceledfunc_t iscanceled = data->iscanceledfunc;
- void *icd = data->iscanceleddata;
- int proc_pipe[2];
- int pstops_pid = 0;
- int childStatus;
- int status = 0;
+ void *icd = data->iscanceleddata;
+ int proc_pipe[2];
+ int pstops_pid = 0;
+ int childStatus;
+ int status = 0;
(void)inputseekable;
(void)parameters;
- /*
- * Ignore broken pipe signals...
- */
+ //
+ // Ignore broken pipe signals...
+ //
signal(SIGPIPE, SIG_IGN);
- /*
- * Process job options...
- */
+ //
+ // Process job options...
+ //
if (set_pstops_options(&doc, (filter_data_ext ? filter_data_ext->ppd : NULL),
data->job_id, data->job_user,
return (1);
}
-
- if(doc.inputPageRange)
- {
- if(pipe(proc_pipe))
- {
- if (log) log(ld, CF_LOGLEVEL_ERROR,
+
+ if (doc.inputPageRange)
+ {
+ if (pipe(proc_pipe))
+ {
+ if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterPSToPS: Unable to create pipe for input-page-ranges");
- return (1);
- }
+ return (1);
+ }
if ((pstops_pid = fork()) == 0)
- {
- close(proc_pipe[0]);
+ {
+ close(proc_pipe[0]);
if ((fp = cupsFileOpenFd(inputfd, "r")) == NULL)
- {
+ {
if (!iscanceled || !iscanceled(icd))
{
- if (log) log(ld, CF_LOGLEVEL_DEBUG,
- "ppdFilterPSToPS: Unable to open input data stream.");
+ if (log) log(ld, CF_LOGLEVEL_DEBUG,
+ "ppdFilterPSToPS: Unable to open input data stream.");
}
- exit (1);
- }
+ exit (1);
+ }
- bytes = cupsFileGetLine(fp,buffer,sizeof(buffer));
+ bytes = cupsFileGetLine(fp,buffer,sizeof(buffer));
while (strncmp(buffer, "%%Page:", 7) && strncmp(buffer, "%%Trailer", 9))
- {
- bytes = write(proc_pipe[1], buffer, bytes);
- if ((bytes = cupsFileGetLine(fp, buffer, sizeof(buffer))) == 0)
- break;
- }
-
- int input_page_number=0;
+ {
+ bytes = write(proc_pipe[1], buffer, bytes);
+ if ((bytes = cupsFileGetLine(fp, buffer, sizeof(buffer))) == 0)
+ break;
+ }
- while (!strncmp(buffer, "%%Page:", 7))
- {
- input_page_number ++;
+ int input_page_number = 0;
- if(check_range(input_page_number,doc.inputPageRange,NULL))
+ while (!strncmp(buffer, "%%Page:", 7))
{
+ input_page_number ++;
+
+ if(check_range(input_page_number,doc.inputPageRange,NULL))
+ {
bytes = write(proc_pipe[1], buffer, bytes);
- bytes = cupsFileGetLine(fp,buffer,sizeof(buffer));
- while(strncmp(buffer, "%%Page:", 7) && strncmp(buffer, "%%Trailer", 9))
- { bytes = write(proc_pipe[1], buffer, bytes);
- bytes = cupsFileGetLine(fp,buffer,sizeof(buffer));
- }
+ bytes = cupsFileGetLine(fp, buffer, sizeof(buffer));
+ while(strncmp(buffer, "%%Page:", 7) &&
+ strncmp(buffer, "%%Trailer", 9))
+ {
+ bytes = write(proc_pipe[1], buffer, bytes);
+ bytes = cupsFileGetLine(fp, buffer, sizeof(buffer));
+ }
+ }
+ else
+ {
+ bytes = cupsFileGetLine(fp, buffer, sizeof(buffer));
+ while(strncmp(buffer, "%%Page:", 7) &&
+ strncmp(buffer, "%%Trailer", 9))
+ bytes = cupsFileGetLine(fp, buffer, sizeof(buffer));
+ }
}
- else
+ while (bytes)
{
- bytes = cupsFileGetLine(fp,buffer,sizeof(buffer));
- while(strncmp(buffer, "%%Page:", 7) && strncmp(buffer, "%%Trailer", 9))
- {
- bytes = cupsFileGetLine(fp,buffer,sizeof(buffer));
- }
+ bytes = write(proc_pipe[1], buffer, bytes);
+ bytes= cupsFileGetLine(fp,buffer,sizeof(buffer));
}
+ close(proc_pipe[1]);
+ cupsFileClose(fp);
+ exit(0);
}
- while (bytes)
+ else
{
- bytes = write(proc_pipe[1], buffer, bytes);
- bytes= cupsFileGetLine(fp,buffer,sizeof(buffer));
+ close(proc_pipe[1]);
+ close(inputfd);
+ inputfd=proc_pipe[0];
}
- close(proc_pipe[1]);
- cupsFileClose(fp);
- exit(0);
- }
- else
- {
- close(proc_pipe[1]);
- close(inputfd);
- inputfd=proc_pipe[0];
- }
}
- /*
- * Open the input data stream specified by the inputfd...
- */
+ //
+ // Open the input data stream specified by the inputfd...
+ //
+
if ((inputfp = cupsFileOpenFd(inputfd, "r")) == NULL)
{
if (!iscanceled || !iscanceled(icd))
return (1);
}
- /*
- * Open the output data stream specified by the outputfd...
- */
+ //
+ // Open the output data stream specified by the outputfd...
+ //
if ((outputfp = fdopen(outputfd, "w")) == NULL)
{
return (1);
}
- /*
- * Read the first line to see if we have DSC comments...
- */
+ //
+ // Read the first line to see if we have DSC comments...
+ //
if ((len = (ssize_t)cupsFileGetLine(inputfp, line, sizeof(line))) == 0)
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: The print file is empty.");
- /* Do not treat this an error, if a previous filter eliminated all
- pages the job should get dequeued without anything printed. */
+ // Do not treat this an error, if a previous filter eliminated all
+ // pages the job should get dequeued without anything printed.
return (0);
}
doc.inputfp = inputfp;
doc.outputfp = outputfp;
-
- /*
- * Write any "exit server" options that have been selected...
- */
+
+ //
+ // Write any "exit server" options that have been selected...
+ //
if (filter_data_ext)
ppdEmit(filter_data_ext->ppd, outputfp, PPD_ORDER_EXIT);
- /*
- * Write any JCL commands that are needed to print PostScript code...
- */
+ //
+ // Write any JCL commands that are needed to print PostScript code...
+ //
if (filter_data_ext && doc.emit_jcl)
ppdEmitJCL(filter_data_ext->ppd, outputfp, doc.job_id, doc.user, doc.title);
- /*
- * Start with a DSC header...
- */
+ //
+ // Start with a DSC header...
+ //
doc_puts(&doc, "%!PS-Adobe-3.0\n");
- /*
- * Skip leading PJL in the document...
- */
+ //
+ // Skip leading PJL in the document...
+ //
while (!strncmp(line, "\033%-12345X", 9) || !strncmp(line, "@PJL ", 5))
{
- /*
- * Yup, we have leading PJL fun, so skip it until we hit the line
- * with "ENTER LANGUAGE"...
- */
+ //
+ // Yup, we have leading PJL fun, so skip it until we hit the line
+ // with "ENTER LANGUAGE"...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: Skipping PJL header...");
break;
}
- /*
- * Now see if the document conforms to the Adobe Document Structuring
- * Conventions...
- */
+ //
+ // Now see if the document conforms to the Adobe Document Structuring
+ // Conventions...
+ //
if (!strncmp(line, "%!PS-Adobe-", 11))
{
- /*
- * Yes, filter the document...
- */
+ //
+ // Yes, filter the document...
+ //
if (filter_data_ext)
copy_dsc(&doc, filter_data_ext->ppd, line, len, sizeof(line));
}
else
{
- /*
- * No, display an error message and treat the file as if it contains
- * a single page...
- */
+ //
+ // No, display an error message and treat the file as if it contains
+ // a single page...
+ //
if (filter_data_ext)
copy_non_dsc(&doc, filter_data_ext->ppd, line, len, sizeof(line));
}
- /*
- * Send %%EOF as needed...
- */
+ //
+ // Send %%EOF as needed...
+ //
if (!doc.saw_eof)
doc_puts(&doc, "%%EOF\n");
- /*
- * End the job with the appropriate JCL command or CTRL-D...
- */
+ //
+ // End the job with the appropriate JCL command or CTRL-D...
+ //
if (doc.emit_jcl)
{
doc_putc(&doc, 0x04);
}
- /*
- * Close files and remove the temporary file if needed...
- */
+ //
+ // Close files and remove the temporary file if needed...
+ //
if (doc.temp)
{
doc.pages = NULL;
}
- if(doc.inputPageRange)
- {
- retry_wait:
- if (waitpid (pstops_pid, &childStatus, 0) == -1) {
- if (errno == EINTR)
- goto retry_wait;
- if (log) log(ld, CF_LOGLEVEL_ERROR,
- "ppdFilterPSToPS: Error while waiting for input_page_ranges to finish - %s.",
- strerror(errno));
- }
- /* How did the sub-process terminate */
- if (childStatus) {
- if (WIFEXITED(childStatus)) {
- /* Via exit() anywhere or return() in the main() function */
+ if (doc.inputPageRange)
+ {
+ retry_wait:
+ if (waitpid (pstops_pid, &childStatus, 0) == -1)
+ {
+ if (errno == EINTR)
+ goto retry_wait;
+ if (log) log(ld, CF_LOGLEVEL_ERROR,
+ "ppdFilterPSToPS: Error while waiting for input_page_ranges to finish - %s.",
+ strerror(errno));
+ }
+ // How did the sub-process terminate
+ if (childStatus)
+ {
+ if (WIFEXITED(childStatus))
+ {
+ // Via exit() anywhere or return() in the main() function
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterPSToPS: input-page-ranges filter (PID %d) stopped with status %d",
pstops_pid, WEXITSTATUS(childStatus));
- } else {
- /* Via signal */
+ }
+ else
+ {
+ // Via signal
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterPSToPS: imput-page-ranges filter (PID %d) crashed on signal %d",
pstops_pid, WTERMSIG(childStatus));
}
- status=1;
- } else {
+ status = 1;
+ }
+ else
+ {
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: input-page-ranges-filter (PID %d) exited with no errors.",
pstops_pid);
}
-/*
- * 'ppdFilterImageToPS()' - Filter function to convert many common image file
- * formats into PostScript
- */
-
-int /* O - Error status */
-ppdFilterImageToPS(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream*/
- int inputseekable, /* I - Is input stream seekable?
- (unused) */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters) /* I - Filter-specific parameters
- (unused) */
+//
+// 'ppdFilterImageToPS()' - Filter function to convert many common image file
+// formats into PostScript
+//
+
+int // O - Error status
+ppdFilterImageToPS(int inputfd, // I - File descriptor input
+ // stream
+ int outputfd, // I - File descriptor output
+ // stream
+ int inputseekable, // I - Is input stream seekable?
+ // (unused)
+ cf_filter_data_t *data, // I - Job and printer data
+ void *parameters) // I - Filter-specific
+ // parameters (unused)
{
ppd_filter_data_ext_t *filter_data_ext =
(ppd_filter_data_ext_t *)cfFilterDataGetExt(data,
PPD_FILTER_DATA_EXT);
- pstops_doc_t doc; /* Document information */
- cf_image_t *img; /* Image to print */
- float xprint, /* Printable area */
+ pstops_doc_t doc; // Document information
+ cf_image_t *img; // Image to print
+ float xprint, // Printable area
yprint,
- xinches, /* Total size in inches */
+ xinches, // Total size in inches
yinches;
- float xsize, /* Total size in points */
+ float xsize, // Total size in points
ysize,
xsize2,
ysize2;
- float aspect; /* Aspect ratio */
- int xpages, /* # x pages */
- ypages, /* # y pages */
- xpage, /* Current x page */
- ypage, /* Current y page */
- page; /* Current page number */
- int xc0, yc0, /* Corners of the page in image coords*/
+ float aspect; // Aspect ratio
+ int xpages, // # x pages
+ ypages, // # y pages
+ xpage, // Current x page
+ ypage, // Current y page
+ page; // Current page number
+ int xc0, yc0, // Corners of the page in image coords
xc1, yc1;
- cf_ib_t *row; /* Current row */
- int y; /* Current Y coordinate in image */
- int colorspace; /* Output colorspace */
- int out_offset, /* Offset into output buffer */
- out_length; /* Length of output buffer */
- ppd_file_t *ppd = NULL; /* PPD file */
- ppd_choice_t *choice; /* PPD option choice */
- int num_options; /* Number of print options */
- cups_option_t *options; /* Print options */
- const char *val; /* Option value */
- int slowcollate; /* Collate copies the slow way */
- float g; /* Gamma correction value */
- float b; /* Brightness factor */
- float zoom; /* Zoom facter */
- int xppi, yppi; /* Pixels-per-inch */
- int hue, sat; /* Hue and saturation adjustment */
- int realcopies, /* Real copies being printed */
- emit_jcl; /* Emit JCL? */
- float left, top; /* Left and top of image */
- time_t curtime; /* Current time */
- struct tm *curtm; /* Current date */
- char curdate[255]; /* Current date string */
- int fillprint = 0; /* print-scaling = fill */
- int cropfit = 0; /* -o crop-to-fit = true */
- cups_page_header2_t h; /* CUPS Raster page header, to */
- /* accommodate results of command */
- /* line parsing for PPD-less queue */
- int Flip, /* Flip/mirror pages */
- XPosition, /* Horizontal position on page */
- YPosition, /* Vertical position on page */
- Collate, /* Collate copies? */
- Copies; /* Number of copies */
- char tempfile[1024]; /* Name of file to print */
- FILE *inputfp; /* Input file */
- int fd; /* File descriptor for temp file */
+ cf_ib_t *row; // Current row
+ int y; // Current Y coordinate in image
+ int colorspace; // Output colorspace
+ int out_offset, // Offset into output buffer
+ out_length; // Length of output buffer
+ ppd_file_t *ppd = NULL; // PPD file
+ ppd_choice_t *choice; // PPD option choice
+ int num_options; // Number of print options
+ cups_option_t *options; // Print options
+ const char *val; // Option value
+ int slowcollate; // Collate copies the slow way
+ float g; // Gamma correction value
+ float b; // Brightness factor
+ float zoom; // Zoom facter
+ int xppi, yppi; // Pixels-per-inch
+ int hue, sat; // Hue and saturation adjustment
+ int realcopies, // Real copies being printed
+ emit_jcl; // Emit JCL?
+ float left, top; // Left and top of image
+ time_t curtime; // Current time
+ struct tm *curtm; // Current date
+ char curdate[255]; // Current date string
+ int fillprint = 0; // print-scaling = fill
+ int cropfit = 0; // -o crop-to-fit = true
+ cups_page_header2_t h; // CUPS Raster page header, to
+ // accommodate results of command
+ // line parsing for PPD-less queue
+ int Flip, // Flip/mirror pages
+ XPosition, // Horizontal position on page
+ YPosition, // Vertical position on page
+ Collate, // Collate copies?
+ Copies; // Number of copies
+ char tempfile[1024]; // Name of file to print
+ FILE *inputfp; // Input file
+ int fd; // File descriptor for temp file
char buf[BUFSIZ];
int bytes;
- cups_cspace_t cspace = (cups_cspace_t)(-1);
- cf_logfunc_t log = data->logfunc;
- void *ld = data->logdata;
+ cups_cspace_t cspace = (cups_cspace_t)(-1);
+ cf_logfunc_t log = data->logfunc;
+ void *ld = data->logdata;
cf_filter_iscanceledfunc_t iscanceled = data->iscanceledfunc;
- void *icd = data->iscanceleddata;
+ void *icd = data->iscanceleddata;
- /*
- * Make sure status messages are not buffered...
- */
+ //
+ // Make sure status messages are not buffered...
+ //
setbuf(stderr, NULL);
- /*
- * Ignore broken pipe signals...
- */
+ //
+ // Ignore broken pipe signals...
+ //
signal(SIGPIPE, SIG_IGN);
- /*
- * Initialize data structure
- */
+ //
+ // Initialize data structure
+ //
Flip = 0;
XPosition = 0;
Collate = 0;
Copies = 1;
- /*
- * Initialize document information structure...
- */
+ //
+ // Initialize document information structure...
+ //
memset(&doc, 0, sizeof(pstops_doc_t));
- /*
- * Open the input data stream specified by the inputfd ...
- */
+ //
+ // Open the input data stream specified by the inputfd ...
+ //
if ((inputfp = fdopen(inputfd, "r")) == NULL)
{
return (1);
}
- /*
- * Copy input into temporary file if needed ...
- */
+ //
+ // Copy input into temporary file if needed ...
+ //
if (!inputseekable) {
if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
fclose(inputfp);
close(fd);
- /*
- * Open the temporary file to read it instead of the original input ...
- */
+ //
+ // Open the temporary file to read it instead of the original input ...
+ //
if ((inputfp = fopen(tempfile, "r")) == NULL)
{
}
}
- /*
- * Open the output data stream specified by the outputfd...
- */
+ //
+ // Open the output data stream specified by the outputfd...
+ //
if ((doc.outputfp = fdopen(outputfd, "w")) == NULL)
{
return (1);
}
- /*
- * Process command-line options and write the prolog...
- */
+ //
+ // Process command-line options and write the prolog...
+ //
zoom = 1.0;
xppi = 0;
Copies = data->copies;
- /*
- * Option list...
- */
+ //
+ // Option list...
+ //
options = data->options;
num_options = data->num_options;
- /*
- * Process job options...
- */
+ //
+ // Process job options...
+ //
if (filter_data_ext)
ppd = filter_data_ext->ppd;
ppdFilterSetCommonOptions(ppd, num_options, options, 0,
- &doc.Orientation, &doc.Duplex,
- &doc.LanguageLevel, &doc.Color,
- &doc.PageLeft, &doc.PageRight,
- &doc.PageTop, &doc.PageBottom,
- &doc.PageWidth, &doc.PageLength,
- log, ld);
-
- /* The ppdFilterSetCommonOptions() does not set doc.Color
- according to option settings (user's demand for color/gray),
- so we parse the options and set the mode here */
+ &doc.Orientation, &doc.Duplex,
+ &doc.LanguageLevel, &doc.Color,
+ &doc.PageLeft, &doc.PageRight,
+ &doc.PageTop, &doc.PageBottom,
+ &doc.PageWidth, &doc.PageLength,
+ log, ld);
+
+ //
+ // The ppdFilterSetCommonOptions() does not set doc.Color
+ // according to option settings (user's demand for color/gray),
+ // so we parse the options and set the mode here
+ //
+
cfRasterPrepareHeader(&h, data, CF_FILTER_OUT_FORMAT_CUPS_RASTER,
CF_FILTER_OUT_FORMAT_CUPS_RASTER, 0, &cspace);
if (doc.Color)
doc.Color = h.cupsNumColors <= 1 ? 0 : 1;
- if (!ppd) {
- /* Without PPD use also the other findings of cfRasterParseIPPOptions() */
+ if (!ppd)
+ {
+ // Without PPD use also the other findings of cfRasterParseIPPOptions()
doc.Orientation = h.Orientation;
doc.Duplex = h.Duplex;
doc.LanguageLevel = 2;
Copies = h.NumCopies;
}
- if ((val = cupsGetOption("multiple-document-handling", num_options, options)) != NULL)
+ if ((val = cupsGetOption("multiple-document-handling",
+ num_options, options)) != NULL)
{
- /*
- * This IPP attribute is unnecessarily complicated...
- *
- * single-document, separate-documents-collated-copies, and
- * single-document-new-sheet all require collated copies.
- *
- * separate-documents-uncollated-copies allows for uncollated copies.
- */
+ //
+ // This IPP attribute is unnecessarily complicated...
+ //
+ // single-document, separate-documents-collated-copies, and
+ // single-document-new-sheet all require collated copies.
+ //
+ // separate-documents-uncollated-copies allows for uncollated copies.
+ //
Collate = strcasecmp(val, "separate-documents-uncollated-copies") != 0;
}
if ((val = cupsGetOption("gamma", num_options, options)) != NULL)
{
- /*
- * Get gamma value from 1 to 10000...
- */
+ //
+ // Get gamma value from 1 to 10000...
+ //
g = atoi(val) * 0.001f;
if ((val = cupsGetOption("brightness", num_options, options)) != NULL)
{
- /*
- * Get brightness value from 10 to 1000.
- */
+ //
+ // Get brightness value from 10 to 1000.
+ //
b = atoi(val) * 0.01f;
else
emit_jcl = 1;
- /*
- * Open the input image to print...
- */
+ //
+ // Open the input image to print...
+ //
colorspace = doc.Color ? CF_IMAGE_RGB_CMYK : CF_IMAGE_WHITE;
img = cfImageOpenFP(inputfp, colorspace, CF_IMAGE_WHITE, sat, hue, NULL);
- if (img != NULL) {
+ if (img != NULL)
+ {
int margin_defined = 0;
int fidelity = 0;
if (ppd && (ppd->custom_margins[0] || ppd->custom_margins[1] ||
ppd->custom_margins[2] || ppd->custom_margins[3]))
- /* In case of custom margins */
+ // In case of custom margins
margin_defined = 1;
if (doc.PageLength != doc.PageTop - doc.PageBottom ||
doc.PageWidth != doc.PageRight - doc.PageLeft)
if(!strcasecmp(val, "true") || !strcasecmp(val, "yes"))
tempOrientation = 4;
}
- if (tempOrientation == 0) {
+ if (tempOrientation == 0)
+ {
if (((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
tempOrientation = 4;
}
{
if (!strcasecmp(val, "auto"))
{
- if (fidelity || document_large) {
+ if (fidelity || document_large)
+ {
if (margin_defined)
zoom = 1.0; // fit method
else
}
if (fillprint || cropfit)
{
- /* For cropfit do the math without the unprintable margins to get correct
- centering */
+ // For cropfit do the math without the unprintable margins to get correct
+ // centering
if (cropfit)
{
pw = doc.PageWidth;
}
}
if (tempOrientation==0)
- {
+ {
if (((pw > ph) && (w < h)) || ((pw < ph) && (w > h)))
{
int temp = pw;
flag = 4;
}
}
- if (fillprint) {
+ if (fillprint)
+ {
float final_w, final_h;
- if (w * ph / pw <= h) {
+ if (w * ph / pw <= h)
+ {
final_w = w;
- final_h = w * ph / pw;
+ final_h = w * ph / pw;
}
else
{
colorspace = cfImageGetColorSpace(img);
- /*
- * Scale as necessary...
- */
+ //
+ // Scale as necessary...
+ //
if (zoom == 0.0 && xppi == 0)
{
if (xppi > 0)
{
- /*
- * Scale the image as neccesary to match the desired pixels-per-inch.
- */
+ //
+ // Scale the image as neccesary to match the desired pixels-per-inch.
+ //
if (doc.Orientation & 1)
{
if (cupsGetOption("orientation-requested", num_options, options) == NULL &&
cupsGetOption("landscape", num_options, options) == NULL)
{
- /*
- * Rotate the image if it will fit landscape but not portrait...
- */
+ //
+ // Rotate the image if it will fit landscape but not portrait...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterImageToPS: Auto orientation...");
if ((xinches > xprint || yinches > yprint) &&
xinches <= yprint && yinches <= xprint)
{
- /*
- * Rotate the image as needed...
- */
+ //
+ // Rotate the image as needed...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterImageToPS: Using landscape orientation...");
}
else
{
- /*
- * Scale percentage of page size...
- */
+ //
+ // Scale percentage of page size...
+ //
xprint = (doc.PageRight - doc.PageLeft) / 72.0;
yprint = (doc.PageTop - doc.PageBottom) / 72.0;
if (cupsGetOption("orientation-requested", num_options, options) == NULL &&
cupsGetOption("landscape", num_options, options) == NULL)
{
- /*
- * Choose the rotation with the largest area, but prefer
- * portrait if they are equal...
- */
+ //
+ // Choose the rotation with the largest area, but prefer
+ // portrait if they are equal...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterImageToPS: Auto orientation...");
if ((xsize * ysize) < (xsize2 * xsize2))
{
- /*
- * Do landscape orientation...
- */
+ //
+ // Do landscape orientation...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterImageToPS: Using landscape orientation...");
}
else
{
- /*
- * Do portrait orientation...
- */
+ //
+ // Do portrait orientation...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterImageToPS: Using portrait orientation...");
}
}
- /*
- * Compute the number of pages to print and the size of the image on each
- * page...
- */
+ //
+ // Compute the number of pages to print and the size of the image on each
+ // page...
+ //
xpages = ceil(xinches / xprint);
ypages = ceil(yinches / yprint);
"ppdFilterImageToPS: xpages = %dx%.2fin, ypages = %dx%.2fin",
xpages, xprint, ypages, yprint);
- /*
- * Update the page size for custom sizes...
- */
+ //
+ // Update the page size for custom sizes...
+ //
if ((choice = ppdFindMarkedChoice(ppd, "PageSize")) != NULL &&
strcasecmp(choice->choice, "Custom") == 0)
{
- float width, /* New width in points */
- length; /* New length in points */
- char s[255]; /* New custom page size... */
+ float width, // New width in points
+ length; // New length in points
+ char s[255]; // New custom page size...
- /*
- * Use the correct width and length for the current orientation...
- */
+ //
+ // Use the correct width and length for the current orientation...
+ //
if (doc.Orientation & 1)
{
length = yprint * 72.0;
}
- /*
- * Add margins to page size...
- */
+ //
+ // Add margins to page size...
+ //
width += ppd->custom_margins[0] + ppd->custom_margins[2];
length += ppd->custom_margins[1] + ppd->custom_margins[3];
- /*
- * Enforce minimums...
- */
+ //
+ // Enforce minimums...
+ //
if (width < ppd->custom_min[0])
width = ppd->custom_min[0];
"ppdFilterImageToPS: Updated custom page size to %.2f x %.2f inches...",
width / 72.0, length / 72.0);
- /*
- * Set the new custom size...
- */
+ //
+ // Set the new custom size...
+ //
sprintf(s, "Custom.%.0fx%.0f", width, length);
ppdMarkOption(ppd, "PageSize", s);
- /*
- * Update page variables...
- */
+ //
+ // Update page variables...
+ //
doc.PageWidth = width;
doc.PageLength = length;
doc.PageTop = length - ppd->custom_margins[3];
}
- /*
- * See if we need to collate, and if so how we need to do it...
- */
+ //
+ // See if we need to collate, and if so how we need to do it...
+ //
if (xpages == 1 && ypages == 1)
Collate = 0;
else
realcopies = 1;
- /*
- * Write any "exit server" options that have been selected...
- */
+ //
+ // Write any "exit server" options that have been selected...
+ //
ppdEmit(ppd, doc.outputfp, PPD_ORDER_EXIT);
- /*
- * Write any JCL commands that are needed to print PostScript code...
- */
+ //
+ // Write any JCL commands that are needed to print PostScript code...
+ //
if (emit_jcl)
ppdEmitJCL(ppd, doc.outputfp, data->job_id, data->job_user,
data->job_title);
- /*
- * Start sending the document with any commands needed...
- */
+ //
+ // Start sending the document with any commands needed...
+ //
curtime = time(NULL);
curtm = localtime(&curtime);
doc_puts(&doc, "%!PS-Adobe-3.0\n");
doc_printf(&doc, "%%%%BoundingBox: %.0f %.0f %.0f %.0f\n",
- doc.PageLeft, doc.PageBottom, doc.PageRight, doc.PageTop);
+ doc.PageLeft, doc.PageBottom, doc.PageRight, doc.PageTop);
doc_printf(&doc, "%%%%LanguageLevel: %d\n", doc.LanguageLevel);
doc_printf(&doc, "%%%%Pages: %d\n", xpages * ypages * Copies);
doc_puts(&doc, "%%DocumentData: Clean7Bit\n");
if (g != 1.0 || b != 1.0)
doc_printf(&doc,
- "{ neg 1 add dup 0 lt { pop 1 } { %.3f exp neg 1 add } "
- "ifelse %.3f mul } bind settransfer\n", g, b);
+ "{ neg 1 add dup 0 lt { pop 1 } { %.3f exp neg 1 add } "
+ "ifelse %.3f mul } bind settransfer\n", g, b);
write_common(&doc);
switch (doc.Orientation)
{
case 0 :
write_label_prolog(&doc, cupsGetOption("page-label", num_options,
- options),
- doc.PageBottom, doc.PageTop, doc.PageWidth);
+ options),
+ doc.PageBottom, doc.PageTop, doc.PageWidth);
break;
case 1 :
write_label_prolog(&doc, cupsGetOption("page-label", num_options,
- options),
- doc.PageLeft, doc.PageRight, doc.PageLength);
+ options),
+ doc.PageLeft, doc.PageRight, doc.PageLength);
break;
case 2 :
write_label_prolog(&doc, cupsGetOption("page-label", num_options,
- options),
- doc.PageLength - doc.PageTop,
- doc.PageLength - doc.PageBottom,
- doc.PageWidth);
+ options),
+ doc.PageLength - doc.PageTop,
+ doc.PageLength - doc.PageBottom,
+ doc.PageWidth);
break;
case 3 :
write_label_prolog(&doc, cupsGetOption("page-label", num_options,
- options),
- doc.PageWidth - doc.PageRight,
- doc.PageWidth - doc.PageLeft,
- doc.PageLength);
+ options),
+ doc.PageWidth - doc.PageRight,
+ doc.PageWidth - doc.PageLeft,
+ doc.PageLength);
break;
}
doc_puts(&doc, "%%EndProlog\n");
- /*
- * Output the pages...
- */
+ //
+ // Output the pages...
+ //
row = malloc(cfImageGetWidth(img) * abs(colorspace) + 3);
if (row == NULL)
switch (doc.Orientation)
{
- case 1 : /* Landscape */
+ case 1 : // Landscape
doc_printf(&doc, "%.0f 0 translate 90 rotate\n",
- doc.PageWidth);
+ doc.PageWidth);
break;
- case 2 : /* Reverse Portrait */
+ case 2 : // Reverse Portrait
doc_printf(&doc, "%.0f %.0f translate 180 rotate\n",
- doc.PageWidth, doc.PageLength);
+ doc.PageWidth, doc.PageLength);
break;
- case 3 : /* Reverse Landscape */
+ case 3 : // Reverse Landscape
doc_printf(&doc, "0 %.0f translate -90 rotate\n",
- doc.PageLength);
+ doc.PageLength);
break;
}
doc_printf(&doc, "%.1f %.1f translate\n", left, top);
doc_printf(&doc, "%.3f %.3f scale\n\n",
- xprint * 72.0 / (xc1 - xc0 + 1),
- yprint * 72.0 / (yc1 - yc0 + 1));
+ xprint * 72.0 / (xc1 - xc0 + 1),
+ yprint * 72.0 / (yc1 - yc0 + 1));
if (doc.LanguageLevel == 1)
{
doc_printf(&doc, "/picture %d string def\n",
- (xc1 - xc0 + 1) * abs(colorspace));
+ (xc1 - xc0 + 1) * abs(colorspace));
doc_printf(&doc, "%d %d 8[1 0 0 -1 0 1]",
- (xc1 - xc0 + 1), (yc1 - yc0 + 1));
+ (xc1 - xc0 + 1), (yc1 - yc0 + 1));
if (colorspace == CF_IMAGE_WHITE)
doc_puts(&doc, "{currentfile picture readhexstring pop} image\n");
}
doc_printf(&doc,
- "<<"
- "/ImageType 1"
- "/Width %d"
- "/Height %d"
- "/BitsPerComponent 8",
- xc1 - xc0 + 1, yc1 - yc0 + 1);
+ "<<"
+ "/ImageType 1"
+ "/Width %d"
+ "/Height %d"
+ "/BitsPerComponent 8",
+ xc1 - xc0 + 1, yc1 - yc0 + 1);
switch (colorspace)
{
doc_puts(&doc, "%%EOF\n");
free(row);
-
- /*
- * End the job with the appropriate JCL command or CTRL-D otherwise.
- */
+
+ //
+ // End the job with the appropriate JCL command or CTRL-D otherwise.
+ //
if (emit_jcl)
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterImageToPS: Printing completed.", page);
- /*
- * Close files...
- */
+ //
+ // Close files...
+ //
cfImageClose(img);
fclose(doc.outputfp);
}
-/*
- * 'add_page()' - Add a page to the pages array.
- */
+//
+// 'add_page()' - Add a page to the pages array.
+//
-static pstops_page_t * /* O - New page info object */
-add_page(pstops_doc_t *doc, /* I - Document information */
- const char *label) /* I - Page label */
+static pstops_page_t * // O - New page info object
+add_page(pstops_doc_t *doc, // I - Document information
+ const char *label) // I - Page label
{
- pstops_page_t *pageinfo; /* New page info object */
- cf_logfunc_t log = doc->logfunc;
+ pstops_page_t *pageinfo; // New page info object
+ cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
}
-/*
- * 'check_range()' - Check to see if the current page is selected for
- * printing.
- */
+//
+// 'check_range()' - Check to see if the current page is selected for
+// printing.
+//
-static int /* O - 1 if selected, 0 otherwise */
-check_range(int page, /* I - Page number */
- const char *Ranges, /* I - page_ranges or inputPageRange */
- const char *pageset ) /* I - Only provided with page_ranges else NULL */
+static int // O - 1 if selected, 0 otherwise
+check_range(int page, // I - Page number
+ const char *Ranges, // I - page_ranges or inputPageRange
+ const char *pageset ) // I - Only provided with page_ranges
+ // else NULL
{
- const char *range; /* Pointer into range string */
- int lower, upper; /* Lower and upper page numbers */
+ const char *range; // Pointer into range string
+ int lower, upper; // Lower and upper page numbers
if (pageset)
{
- /*
- * See if we only print even or odd pages...
- */
+ //
+ // See if we only print even or odd pages...
+ //
if (!strcasecmp(pageset, "even") && (page & 1))
return (0);
}
if (!Ranges)
- return (1); /* No range, print all pages... */
+ return (1); // No range, print all pages...
for (range = Ranges; *range != '\0';)
{
}
-/*
- * 'copy_bytes()' - Copy bytes from the temporary file to the output file.
- */
+//
+// 'copy_bytes()' - Copy bytes from the temporary file to the output file.
+//
static void
-copy_bytes(pstops_doc_t *doc, /* I - Document info */
- off_t offset, /* I - Offset to page data */
- size_t length) /* I - Length of page data */
+copy_bytes(pstops_doc_t *doc, // I - Document info
+ off_t offset, // I - Offset to page data
+ size_t length) // I - Length of page data
{
- char buffer[8192]; /* Data buffer */
- ssize_t nbytes; /* Number of bytes read */
- size_t nleft; /* Number of bytes left/remaining */
+ char buffer[8192]; // Data buffer
+ ssize_t nbytes; // Number of bytes read
+ size_t nleft; // Number of bytes left/remaining
cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
}
-/*
- * 'copy_comments()' - Copy all of the comments section.
- *
- * This function expects "line" to be filled with a comment line.
- * On return, "line" will contain the next line in the file, if any.
- */
+//
+// 'copy_comments()' - Copy all of the comments section.
+//
+// This function expects "line" to be filled with a comment line.
+// On return, "line" will contain the next line in the file, if any.
+//
-static ssize_t /* O - Length of next line */
-copy_comments(pstops_doc_t *doc, /* I - Document info */
- ppd_file_t *ppd, /* I - PPD file */
- char *line, /* I - Line buffer */
- ssize_t linelen, /* I - Length of initial line */
- size_t linesize) /* I - Size of line buffer */
+static ssize_t // O - Length of next line
+copy_comments(pstops_doc_t *doc, // I - Document info
+ ppd_file_t *ppd, // I - PPD file
+ char *line, // I - Line buffer
+ ssize_t linelen, // I - Length of initial line
+ size_t linesize) // I - Size of line buffer
{
- int saw_bounding_box, /* Saw %%BoundingBox: comment? */
- saw_for, /* Saw %%For: comment? */
- saw_pages, /* Saw %%Pages: comment? */
- saw_title; /* Saw %%Title: comment? */
+ int saw_bounding_box, // Saw %%BoundingBox: comment?
+ saw_for, // Saw %%For: comment?
+ saw_pages, // Saw %%Pages: comment?
+ saw_title; // Saw %%Title: comment?
cf_logfunc_t log = doc->logfunc;
- void *ld = doc->logdata;
+ void *ld = doc->logdata;
- /*
- * Loop until we see %%EndComments or a non-comment line...
- */
+ //
+ // Loop until we see %%EndComments or a non-comment line...
+ //
saw_bounding_box = 0;
saw_for = 0;
while (line[0] == '%')
{
- /*
- * Strip trailing whitespace...
- */
+ //
+ // Strip trailing whitespace...
+ //
while (linelen > 0)
{
line[linelen] = '\0';
}
- /*
- * Log the header...
- */
+ //
+ // Log the header...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: %s", line);
- /*
- * Pull the headers out...
- */
+ //
+ // Pull the headers out...
+ //
if (!strncmp(line, "%%Pages:", 8))
{
- int pages; /* Number of pages */
+ int pages; // Number of pages
if (saw_pages && log)
log(ld, CF_LOGLEVEL_DEBUG,
if (doc->Duplex &&
(pages = atoi(line + 8)) > 0 && pages <= doc->number_up)
{
- /*
- * Since we will only be printing on a single page, disable duplexing.
- */
+ //
+ // Since we will only be printing on a single page, disable duplexing.
+ //
doc->Duplex = 0;
doc->slow_duplex = 0;
}
else if (strstr(line + 14, "(atend)"))
{
- /*
- * Do nothing for now but use the default imageable area...
- */
+ //
+ // Do nothing for now but use the default imageable area...
+ //
}
else if (sscanf(line + 14, "%d%d%d%d", doc->bounding_box + 0,
doc->bounding_box + 1, doc->bounding_box + 2,
}
else if (!strncmp(line, "%cupsRotation:", 14))
{
- /*
- * Reset orientation of document?
- */
+ //
+ // Reset orientation of document?
+ //
int orient = (atoi(line + 14) / 90) & 3;
if (orient != doc->Orientation)
{
- /*
- * Yes, update things so that the pages come out right...
- */
+ //
+ // Yes, update things so that the pages come out right...
+ //
doc->Orientation = (4 - doc->Orientation + orient) & 3;
ppdFilterUpdatePageVars(doc->Orientation,
- &doc->PageLeft, &doc->PageRight,
- &doc->PageTop, &doc->PageBottom,
- &doc->PageWidth, &doc->PageLength);
+ &doc->PageLeft, &doc->PageRight,
+ &doc->PageTop, &doc->PageBottom,
+ &doc->PageWidth, &doc->PageLength);
doc->Orientation = orient;
}
}
if (doc->copies != 1 && (!doc->collate || !doc->slow_collate))
{
- /*
- * Tell the document processor the copy and duplex options
- * that are required...
- */
+ //
+ // Tell the document processor the copy and duplex options
+ // that are required...
+ //
doc_printf(doc, "%%%%Requirements: numcopies(%d)%s%s\n", doc->copies,
doc->collate ? " collate" : "",
doc->Duplex ? " duplex" : "");
- /*
- * Apple uses RBI comments for various non-PPD options...
- */
+ //
+ // Apple uses RBI comments for various non-PPD options...
+ //
doc_printf(doc, "%%RBINumCopies: %d\n", doc->copies);
}
else
{
- /*
- * Tell the document processor the duplex option that is required...
- */
+ //
+ // Tell the document processor the duplex option that is required...
+ //
if (doc->Duplex)
doc_puts(doc, "%%Requirements: duplex\n");
- /*
- * Apple uses RBI comments for various non-PPD options...
- */
+ //
+ // Apple uses RBI comments for various non-PPD options...
+ //
doc_puts(doc, "%RBINumCopies: 1\n");
}
}
-/*
- * 'copy_dsc()' - Copy a DSC-conforming document.
- *
- * This function expects "line" to be filled with the %!PS-Adobe comment line.
- */
+//
+// 'copy_dsc()' - Copy a DSC-conforming document.
+//
+// This function expects "line" to be filled with the %!PS-Adobe comment line.
+//
static void
-copy_dsc(pstops_doc_t *doc, /* I - Document info */
- ppd_file_t *ppd, /* I - PPD file */
- char *line, /* I - Line buffer */
- ssize_t linelen, /* I - Length of initial line */
- size_t linesize) /* I - Size of line buffer */
+copy_dsc(pstops_doc_t *doc, // I - Document info
+ ppd_file_t *ppd, // I - PPD file
+ char *line, // I - Line buffer
+ ssize_t linelen, // I - Length of initial line
+ size_t linesize) // I - Size of line buffer
{
- int number; /* Page number */
- pstops_page_t *pageinfo; /* Page information */
- cf_logfunc_t log = doc->logfunc;
+ int number; // Page number
+ pstops_page_t *pageinfo; // Page information
+ cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
cf_filter_iscanceledfunc_t iscanceled = doc->iscanceledfunc;
void *icd = doc->iscanceleddata;
- /*
- * Make sure we use ESPshowpage for EPS files...
- */
+ //
+ // Make sure we use ESPshowpage for EPS files...
+ //
if (strstr(line, "EPSF"))
{
doc->number_up = 1;
}
- /*
- * Start sending the document with any commands needed...
- */
+ //
+ // Start sending the document with any commands needed...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: Before copy_comments - %s", line);
linelen = copy_comments(doc, ppd, line, linelen, linesize);
- /*
- * Now find the prolog section, if any...
- */
+ //
+ // Now find the prolog section, if any...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: Before copy_prolog - %s", line);
linelen = copy_prolog(doc, ppd, line, linelen, linesize);
- /*
- * Then the document setup section...
- */
+ //
+ // Then the document setup section...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: Before copy_setup - %s", line);
linelen = copy_setup(doc, ppd, line, linelen, linesize);
- /*
- * Copy until we see %%Page:...
- */
+ //
+ // Copy until we see %%Page:...
+ //
while (strncmp(line, "%%Page:", 7) && strncmp(line, "%%Trailer", 9))
{
break;
}
- /*
- * Then process pages until we have no more...
- */
+ //
+ // Then process pages until we have no more...
+ //
number = 0;
number ++;
- if (check_range((number - 1) / doc->number_up + 1,doc->page_ranges,doc->page_set))
+ if (check_range((number - 1) / doc->number_up + 1,
+ doc->page_ranges, doc->page_set))
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: Copying page %d...", number);
}
}
- /*
- * Finish up the last page(s)...
- */
+ //
+ // Finish up the last page(s)...
+ //
if (number && is_not_last_page(number) && cupsArrayLast(doc->pages) &&
- check_range((number - 1) / doc->number_up + 1,doc->page_ranges,doc->page_set))
+ check_range((number - 1) / doc->number_up + 1, doc->page_ranges,
+ doc->page_set))
{
pageinfo = (pstops_page_t *)cupsArrayLast(doc->pages);
if (doc->slow_duplex && (doc->page & 1))
{
- /*
- * Make sure we have an even number of pages...
- */
+ //
+ // Make sure we have an even number of pages...
+ //
pageinfo = add_page(doc, "(filler)");
if (pageinfo == NULL)
pageinfo->length = (ssize_t)(cupsFileTell(doc->temp) - pageinfo->offset);
}
- /*
- * Make additional copies as necessary...
- */
+ //
+ // Make additional copies as necessary...
+ //
number = doc->slow_order ? 0 : doc->page;
if (doc->temp && (!iscanceled || !iscanceled(icd)) &&
cupsArrayCount(doc->pages) > 0)
{
- int copy; /* Current copy */
+ int copy; // Current copy
- /*
- * Reopen the temporary file for reading...
- */
+ //
+ // Reopen the temporary file for reading...
+ //
cupsFileClose(doc->temp);
doc->temp = cupsFileOpen(doc->tempfile, "r");
- /*
- * Make the copies...
- */
+ //
+ // Make the copies...
+ //
if (doc->slow_collate)
copy = !doc->slow_order;
break;
}
- /*
- * Send end-of-job stuff followed by any start-of-job stuff required
- * for the JCL options...
- */
+ //
+ // Send end-of-job stuff followed by any start-of-job stuff required
+ // for the JCL options...
+ //
if (number && doc->emit_jcl && ppd && ppd->jcl_end)
{
- /*
- * Send the trailer...
- */
+ //
+ // Send the trailer...
+ //
doc_puts(doc, "%%Trailer\n");
doc_printf(doc, "%%%%Pages: %d\n", cupsArrayCount(doc->pages));
if (doc->number_up > 1 || doc->fit_to_page)
doc_printf(doc, "%%%%BoundingBox: %.0f %.0f %.0f %.0f\n",
- doc->PageLeft, doc->PageBottom, doc->PageRight, doc->PageTop);
+ doc->PageLeft, doc->PageBottom,
+ doc->PageRight, doc->PageTop);
else
doc_printf(doc, "%%%%BoundingBox: %d %d %d %d\n",
- doc->new_bounding_box[0], doc->new_bounding_box[1],
- doc->new_bounding_box[2], doc->new_bounding_box[3]);
+ doc->new_bounding_box[0], doc->new_bounding_box[1],
+ doc->new_bounding_box[2], doc->new_bounding_box[3]);
doc_puts(doc, "%%EOF\n");
- /*
- * Start a new document...
- */
+ //
+ // Start a new document...
+ //
ppdEmitJCLEnd(ppd, doc->outputfp);
ppdEmitJCL(ppd, doc->outputfp, doc->job_id, doc->user, doc->title);
number = 0;
}
- /*
- * Copy the prolog as needed...
- */
+ //
+ // Copy the prolog as needed...
+ //
if (!number)
{
copy_bytes(doc, 0, (size_t)pageinfo->offset);
}
- /*
- * Then copy all of the pages...
- */
+ //
+ // Then copy all of the pages...
+ //
pageinfo = doc->slow_order ? (pstops_page_t *)cupsArrayLast(doc->pages) :
(pstops_page_t *)cupsArrayFirst(doc->pages);
{
doc_printf(doc, "%%%%Page: (%d) %d\n", number, number);
doc_printf(doc, "%%%%PageBoundingBox: %.0f %.0f %.0f %.0f\n",
- doc->PageLeft, doc->PageBottom, doc->PageRight, doc->PageTop);
+ doc->PageLeft, doc->PageBottom,
+ doc->PageRight, doc->PageTop);
}
else
{
doc_printf(doc, "%%%%Page: %s %d\n", pageinfo->label, number);
doc_printf(doc, "%%%%PageBoundingBox: %d %d %d %d\n",
- pageinfo->bounding_box[0], pageinfo->bounding_box[1],
- pageinfo->bounding_box[2], pageinfo->bounding_box[3]);
+ pageinfo->bounding_box[0], pageinfo->bounding_box[1],
+ pageinfo->bounding_box[2], pageinfo->bounding_box[3]);
}
copy_bytes(doc, pageinfo->offset, (size_t)pageinfo->length);
}
}
- /*
- * Restore the old showpage operator as needed...
- */
+ //
+ // Restore the old showpage operator as needed...
+ //
if (doc->use_ESPshowpage)
doc_puts(doc, "userdict/showpage/ESPshowpage load put\n");
- /*
- * Write/copy the trailer...
- */
+ //
+ // Write/copy the trailer...
+ //
if (!iscanceled || !iscanceled(icd))
copy_trailer(doc, ppd, number, line, linelen, linesize);
}
-/*
- * 'copy_non_dsc()' - Copy a document that does not conform to the DSC.
- *
- * This function expects "line" to be filled with the %! comment line.
- */
+//
+// 'copy_non_dsc()' - Copy a document that does not conform to the DSC.
+//
+// This function expects "line" to be filled with the %! comment line.
+//
static void
-copy_non_dsc(pstops_doc_t *doc, /* I - Document info */
- ppd_file_t *ppd, /* I - PPD file */
- char *line, /* I - Line buffer */
- ssize_t linelen, /* I - Length of initial line */
- size_t linesize) /* I - Size of line buffer */
+copy_non_dsc(pstops_doc_t *doc, // I - Document info
+ ppd_file_t *ppd, // I - PPD file
+ char *line, // I - Line buffer
+ ssize_t linelen, // I - Length of initial line
+ size_t linesize) // I - Size of line buffer
{
- int copy; /* Current copy */
- char buffer[8192]; /* Copy buffer */
- ssize_t bytes; /* Number of bytes copied */
- cf_logfunc_t log = doc->logfunc;
+ int copy; // Current copy
+ char buffer[8192]; // Copy buffer
+ ssize_t bytes; // Number of bytes copied
+ cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
cf_filter_iscanceledfunc_t iscanceled = doc->iscanceledfunc;
void *icd = doc->iscanceleddata;
(void)linesize;
- /*
- * First let the user know that they are attempting to print a file
- * that may not print correctly...
- */
+ //
+ // First let the user know that they are attempting to print a file
+ // that may not print correctly...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPSToPS: This document does not conform to the Adobe Document "
"Structuring Conventions and may not print correctly.");
- /*
- * Then write a standard DSC comment section...
- */
+ //
+ // Then write a standard DSC comment section...
+ //
doc_printf(doc, "%%%%BoundingBox: %.0f %.0f %.0f %.0f\n",
- doc->PageLeft, doc->PageBottom, doc->PageRight, doc->PageTop);
+ doc->PageLeft, doc->PageBottom, doc->PageRight, doc->PageTop);
if (doc->slow_collate && doc->copies > 1)
doc_printf(doc, "%%%%Pages: %d\n", doc->copies);
if (doc->copies != 1 && (!doc->collate || !doc->slow_collate))
{
- /*
- * Tell the document processor the copy and duplex options
- * that are required...
- */
+ //
+ // Tell the document processor the copy and duplex options
+ // that are required...
+ //
doc_printf(doc, "%%%%Requirements: numcopies(%d)%s%s\n", doc->copies,
- doc->collate ? " collate" : "",
- doc->Duplex ? " duplex" : "");
+ doc->collate ? " collate" : "",
+ doc->Duplex ? " duplex" : "");
- /*
- * Apple uses RBI comments for various non-PPD options...
- */
+ //
+ // Apple uses RBI comments for various non-PPD options...
+ //
doc_printf(doc, "%%RBINumCopies: %d\n", doc->copies);
}
else
{
- /*
- * Tell the document processor the duplex option that is required...
- */
+ //
+ // Tell the document processor the duplex option that is required...
+ //
if (doc->Duplex)
doc_puts(doc, "%%Requirements: duplex\n");
- /*
- * Apple uses RBI comments for various non-PPD options...
- */
+ //
+ // Apple uses RBI comments for various non-PPD options...
+ //
doc_puts(doc, "%RBINumCopies: 1\n");
}
doc_puts(doc, "%%EndComments\n");
- /*
- * Then the prolog...
- */
+ //
+ // Then the prolog...
+ //
doc_puts(doc, "%%BeginProlog\n");
doc_puts(doc, "%%EndProlog\n");
- /*
- * Then the setup section...
- */
+ //
+ // Then the setup section...
+ //
doc_puts(doc, "%%BeginSetup\n");
doc_puts(doc, "%%EndSetup\n");
- /*
- * Finally, embed a copy of the file inside a %%Page...
- */
+ //
+ // Finally, embed a copy of the file inside a %%Page...
+ //
if ((!ppd || !ppd->num_filters) && log)
log(ld, CF_LOGLEVEL_CONTROL,
if (doc->temp && (!iscanceled || !iscanceled(icd)))
{
- /*
- * Reopen the temporary file for reading...
- */
+ //
+ // Reopen the temporary file for reading...
+ //
cupsFileClose(doc->temp);
doc->temp = cupsFileOpen(doc->tempfile, "r");
- /*
- * Make the additional copies as needed...
- */
+ //
+ // Make the additional copies as needed...
+ //
for (copy = 1; copy < doc->copies; copy ++)
{
}
}
- /*
- * Restore the old showpage operator as needed...
- */
+ //
+ // Restore the old showpage operator as needed...
+ //
if (doc->use_ESPshowpage)
doc_puts(doc, "userdict/showpage/ESPshowpage load put\n");
}
-/*
- * 'copy_page()' - Copy a page description.
- *
- * This function expects "line" to be filled with a %%Page comment line.
- * On return, "line" will contain the next line in the file, if any.
- */
-
-static ssize_t /* O - Length of next line */
-copy_page(pstops_doc_t *doc, /* I - Document info */
- ppd_file_t *ppd, /* I - PPD file */
- int number, /* I - Current page number */
- char *line, /* I - Line buffer */
- ssize_t linelen, /* I - Length of initial line */
- size_t linesize) /* I - Size of line buffer */
+//
+// 'copy_page()' - Copy a page description.
+//
+// This function expects "line" to be filled with a %%Page comment line.
+// On return, "line" will contain the next line in the file, if any.
+//
+
+static ssize_t // O - Length of next line
+copy_page(pstops_doc_t *doc, // I - Document info
+ ppd_file_t *ppd, // I - PPD file
+ int number, // I - Current page number
+ char *line, // I - Line buffer
+ ssize_t linelen, // I - Length of initial line
+ size_t linesize) // I - Size of line buffer
{
- char label[256], /* Page label string */
- *ptr; /* Pointer into line */
- int level; /* Embedded document level */
- pstops_page_t *pageinfo; /* Page information */
- int first_page; /* First page on N-up output? */
- int has_page_setup = 0; /* Does the page have
- %%Begin/EndPageSetup? */
- int bounding_box[4]; /* PageBoundingBox */
- cf_logfunc_t log = doc->logfunc;
+ char label[256], // Page label string
+ *ptr; // Pointer into line
+ int level; // Embedded document level
+ pstops_page_t *pageinfo; // Page information
+ int first_page; // First page on N-up output?
+ int has_page_setup = 0; // Does the page have
+ // %%Begin/EndPageSetup?
+ int bounding_box[4]; // PageBoundingBox
+ cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
- /*
- * Get the page label for this page...
- */
+ //
+ // Get the page label for this page...
+ //
first_page = is_first_page(number);
number = doc->page;
}
- /*
- * Create or update the current output page...
- */
+ //
+ // Create or update the current output page...
+ //
if (first_page)
{
else
pageinfo = (pstops_page_t *)cupsArrayLast(doc->pages);
- /*
- * Handle first page override...
- */
+ //
+ // Handle first page override...
+ //
if (doc->ap_input_slot || doc->ap_manual_feed)
{
if ((doc->page == 1 && (!doc->slow_order || !doc->Duplex)) ||
(doc->page == 2 && doc->slow_order && doc->Duplex))
{
- /*
- * First page/sheet gets AP_FIRSTPAGE_* options...
- */
+ //
+ // First page/sheet gets AP_FIRSTPAGE_* options...
+ //
pageinfo->num_options = cupsAddOption("InputSlot", doc->ap_input_slot,
pageinfo->num_options,
&(pageinfo->options));
pageinfo->num_options = cupsAddOption("ManualFeed",
doc->ap_input_slot ? "False" :
- doc->ap_manual_feed,
+ doc->ap_manual_feed,
pageinfo->num_options,
&(pageinfo->options));
pageinfo->num_options = cupsAddOption("MediaColor", doc->ap_media_color,
}
else if (doc->page == (doc->Duplex + 2))
{
- /*
- * Second page/sheet gets default options...
- */
+ //
+ // Second page/sheet gets default options...
+ //
pageinfo->num_options = cupsAddOption("InputSlot", doc->input_slot,
pageinfo->num_options,
&(pageinfo->options));
pageinfo->num_options = cupsAddOption("ManualFeed",
doc->input_slot ? "False" :
- doc->manual_feed,
+ doc->manual_feed,
pageinfo->num_options,
&(pageinfo->options));
pageinfo->num_options = cupsAddOption("MediaColor", doc->media_color,
}
}
- /*
- * Scan comments until we see something other than %%Page*: or
- * %%Include*...
- */
+ //
+ // Scan comments until we see something other than %%Page*: or
+ // %%Include*...
+ //
memcpy(bounding_box, doc->bounding_box, sizeof(bounding_box));
{
if (!strncmp(line, "%%PageBoundingBox:", 18))
{
- /*
- * %%PageBoundingBox: llx lly urx ury
- */
+ //
+ // %%PageBoundingBox: llx lly urx ury
+ //
if (sscanf(line + 18, "%d%d%d%d", bounding_box + 0,
bounding_box + 1, bounding_box + 2,
}
else if (doc->number_up == 1 && !doc->fit_to_page && doc->Orientation)
{
- int temp_bbox[4]; /* Temporary bounding box */
+ int temp_bbox[4]; // Temporary bounding box
memcpy(temp_bbox, bounding_box, sizeof(temp_bbox));
switch (doc->Orientation)
{
- case 1 : /* Landscape */
+ case 1 : // Landscape
bounding_box[0] = (int)(doc->PageLength - temp_bbox[3]);
bounding_box[1] = temp_bbox[0];
bounding_box[2] = (int)(doc->PageLength - temp_bbox[1]);
bounding_box[3] = temp_bbox[2];
break;
- case 2 : /* Reverse Portrait */
+ case 2 : // Reverse Portrait
bounding_box[0] = (int)(doc->PageWidth - temp_bbox[2]);
bounding_box[1] = (int)(doc->PageLength - temp_bbox[3]);
bounding_box[2] = (int)(doc->PageWidth - temp_bbox[0]);
bounding_box[3] = (int)(doc->PageLength - temp_bbox[1]);
break;
- case 3 : /* Reverse Landscape */
+ case 3 : // Reverse Landscape
bounding_box[0] = temp_bbox[1];
bounding_box[1] = (int)(doc->PageWidth - temp_bbox[2]);
bounding_box[2] = temp_bbox[3];
!strncmp(line, "%%PageRequirements:", 18) ||
!strncmp(line, "%%PageResources:", 16))
{
- /*
- * Copy literal...
- */
+ //
+ // Copy literal...
+ //
}
-#endif /* 0 */
+#endif // 0
else if (!strncmp(line, "%%PageCustomColors:", 19))
{
- /*
- * %%PageCustomColors: ...
- */
+ //
+ // %%PageCustomColors: ...
+ //
}
else if (!strncmp(line, "%%PageMedia:", 12))
{
- /*
- * %%PageMedia: ...
- */
+ //
+ // %%PageMedia: ...
+ //
}
else if (!strncmp(line, "%%PageOrientation:", 18))
{
- /*
- * %%PageOrientation: ...
- */
+ //
+ // %%PageOrientation: ...
+ //
}
else if (!strncmp(line, "%%PageProcessColors:", 20))
{
- /*
- * %%PageProcessColors: ...
- */
+ //
+ // %%PageProcessColors: ...
+ //
}
else if (!strncmp(line, "%%PageRequirements:", 18))
{
- /*
- * %%PageRequirements: ...
- */
+ //
+ // %%PageRequirements: ...
+ //
}
else if (!strncmp(line, "%%PageResources:", 16))
{
- /*
- * %%PageResources: ...
- */
+ //
+ // %%PageResources: ...
+ //
}
else if (!strncmp(line, "%%IncludeFeature:", 17))
{
- /*
- * %%IncludeFeature: *MainKeyword OptionKeyword
- */
+ //
+ // %%IncludeFeature: *MainKeyword OptionKeyword
+ //
if (doc->number_up == 1 &&!doc->fit_to_page)
pageinfo->num_options = include_feature(doc, ppd, line,
if (doc->number_up == 1)
{
- /*
- * Update the document's composite and page bounding box...
- */
+ //
+ // Update the document's composite and page bounding box...
+ //
memcpy(pageinfo->bounding_box, bounding_box,
sizeof(pageinfo->bounding_box));
doc->new_bounding_box[3] = bounding_box[3];
}
- /*
- * Output the page header as needed...
- */
+ //
+ // Output the page header as needed...
+ //
if (!doc->slow_order && first_page)
{
{
doc_printf(doc, "%%%%Page: (%d) %d\n", doc->page, doc->page);
doc_printf(doc, "%%%%PageBoundingBox: %.0f %.0f %.0f %.0f\n",
- doc->PageLeft, doc->PageBottom, doc->PageRight, doc->PageTop);
+ doc->PageLeft, doc->PageBottom, doc->PageRight, doc->PageTop);
}
else
{
doc_printf(doc, "%%%%Page: %s %d\n", pageinfo->label, doc->page);
doc_printf(doc, "%%%%PageBoundingBox: %d %d %d %d\n",
- pageinfo->bounding_box[0], pageinfo->bounding_box[1],
- pageinfo->bounding_box[2], pageinfo->bounding_box[3]);
+ pageinfo->bounding_box[0], pageinfo->bounding_box[1],
+ pageinfo->bounding_box[2], pageinfo->bounding_box[3]);
}
}
- /*
- * Copy any page setup commands...
- */
+ //
+ // Copy any page setup commands...
+ //
if (first_page)
doc_puts(doc, "%%BeginPageSetup\n");
if (has_page_setup)
{
- int feature = 0; /* In a Begin/EndFeature block? */
+ int feature = 0; // In a Begin/EndFeature block?
while ((linelen = (ssize_t)cupsFileGetLine(doc->inputfp, line, linesize)) >
0)
doc_write(doc, line, (size_t)linelen);
}
- /*
- * Skip %%EndPageSetup...
- */
+ //
+ // Skip %%EndPageSetup...
+ //
if (linelen > 0 && !strncmp(line, "%%EndPageSetup", 14))
linelen = (ssize_t)cupsFileGetLine(doc->inputfp, line, linesize);
if (first_page)
{
- char *page_setup; /* PageSetup commands to send */
+ char *page_setup; // PageSetup commands to send
if (pageinfo->num_options > 0)
write_options(doc, ppd, pageinfo->num_options, pageinfo->options);
- /*
- * Output commands for the current page...
- */
+ //
+ // Output commands for the current page...
+ //
page_setup = ppdEmitString(ppd, PPD_ORDER_PAGE, 0);
}
}
- /*
- * Prep for the start of the page description...
- */
+ //
+ // Prep for the start of the page description...
+ //
start_nup(doc, number, 1, bounding_box);
if (first_page)
doc_puts(doc, "%%EndPageSetup\n");
- /*
- * Read the rest of the page description...
- */
+ //
+ // Read the rest of the page description...
+ //
level = 0;
(!strncmp(line, "%%BeginData:", 12) &&
!strstr(line, "ASCII") && !strstr(line, "Hex")))
{
- /*
- * Copy binary data...
- */
+ //
+ // Copy binary data...
+ //
- int bytes; /* Bytes of data */
+ int bytes; // Bytes of data
doc_write(doc, line, (size_t)linelen);
while ((linelen = (ssize_t)cupsFileGetLine(doc->inputfp, line, linesize)) >
0);
- /*
- * Finish up this page and return...
- */
+ //
+ // Finish up this page and return...
+ //
end_nup(doc, number);
}
-/*
- * 'copy_prolog()' - Copy the document prolog section.
- *
- * This function expects "line" to be filled with a %%BeginProlog comment line.
- * On return, "line" will contain the next line in the file, if any.
- */
+//
+// 'copy_prolog()' - Copy the document prolog section.
+//
+// This function expects "line" to be filled with a %%BeginProlog comment line.
+// On return, "line" will contain the next line in the file, if any.
+//
-static ssize_t /* O - Length of next line */
-copy_prolog(pstops_doc_t *doc, /* I - Document info */
- ppd_file_t *ppd, /* I - PPD file */
- char *line, /* I - Line buffer */
- ssize_t linelen, /* I - Length of initial line */
- size_t linesize) /* I - Size of line buffer */
+static ssize_t // O - Length of next line
+copy_prolog(pstops_doc_t *doc, // I - Document info
+ ppd_file_t *ppd, // I - PPD file
+ char *line, // I - Line buffer
+ ssize_t linelen, // I - Length of initial line
+ size_t linesize) // I - Size of line buffer
{
cf_logfunc_t log = doc->logfunc;
- void *ld = doc->logdata;
+ void *ld = doc->logdata;
while (strncmp(line, "%%BeginProlog", 13))
}
-/*
- * 'copy_setup()' - Copy the document setup section.
- *
- * This function expects "line" to be filled with a %%BeginSetup comment line.
- * On return, "line" will contain the next line in the file, if any.
- */
+//
+// 'copy_setup()' - Copy the document setup section.
+//
+// This function expects "line" to be filled with a %%BeginSetup comment line.
+// On return, "line" will contain the next line in the file, if any.
+//
-static ssize_t /* O - Length of next line */
-copy_setup(pstops_doc_t *doc, /* I - Document info */
- ppd_file_t *ppd, /* I - PPD file */
- char *line, /* I - Line buffer */
- ssize_t linelen, /* I - Length of initial line */
- size_t linesize) /* I - Size of line buffer */
+static ssize_t // O - Length of next line
+copy_setup(pstops_doc_t *doc, // I - Document info
+ ppd_file_t *ppd, // I - PPD file
+ char *line, // I - Line buffer
+ ssize_t linelen, // I - Length of initial line
+ size_t linesize) // I - Size of line buffer
{
- int num_options; /* Number of options */
- cups_option_t *options; /* Options */
- cf_logfunc_t log = doc->logfunc;
+ int num_options; // Number of options
+ cups_option_t *options; // Options
+ cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
break;
else if (!strncmp(line, "%%IncludeFeature:", 17))
{
- /*
- * %%IncludeFeature: *MainKeyword OptionKeyword
- */
+ //
+ // %%IncludeFeature: *MainKeyword OptionKeyword
+ //
if (doc->number_up == 1 && !doc->fit_to_page)
num_options = include_feature(doc, ppd, line, num_options, &options);
}
-/*
- * 'copy_trailer()' - Copy the document trailer.
- *
- * This function expects "line" to be filled with a %%Trailer comment line.
- * On return, "line" will contain the next line in the file, if any.
- */
-
-static ssize_t /* O - Length of next line */
-copy_trailer(pstops_doc_t *doc, /* I - Document info */
- ppd_file_t *ppd, /* I - PPD file */
- int number, /* I - Number of pages */
- char *line, /* I - Line buffer */
- ssize_t linelen, /* I - Length of initial line */
- size_t linesize) /* I - Size of line buffer */
+//
+// 'copy_trailer()' - Copy the document trailer.
+//
+// This function expects "line" to be filled with a %%Trailer comment line.
+// On return, "line" will contain the next line in the file, if any.
+//
+
+static ssize_t // O - Length of next line
+copy_trailer(pstops_doc_t *doc, // I - Document info
+ ppd_file_t *ppd, // I - PPD file
+ int number, // I - Number of pages
+ char *line, // I - Line buffer
+ ssize_t linelen, // I - Length of initial line
+ size_t linesize) // I - Size of line buffer
{
- cf_logfunc_t log = doc->logfunc;
+ cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
- /*
- * Write the trailer comments...
- */
+ //
+ // Write the trailer comments...
+ //
(void)ppd;
doc_printf(doc, "%%%%Pages: %d\n", number);
if (doc->number_up > 1 || doc->fit_to_page)
doc_printf(doc, "%%%%BoundingBox: %.0f %.0f %.0f %.0f\n",
- doc->PageLeft, doc->PageBottom, doc->PageRight, doc->PageTop);
+ doc->PageLeft, doc->PageBottom, doc->PageRight, doc->PageTop);
else
doc_printf(doc, "%%%%BoundingBox: %d %d %d %d\n",
- doc->new_bounding_box[0], doc->new_bounding_box[1],
- doc->new_bounding_box[2], doc->new_bounding_box[3]);
+ doc->new_bounding_box[0], doc->new_bounding_box[1],
+ doc->new_bounding_box[2], doc->new_bounding_box[3]);
return (linelen);
}
-/*
- * 'do_prolog()' - Send the necessary document prolog commands.
- */
+//
+// 'do_prolog()' - Send the necessary document prolog commands.
+//
static void
-do_prolog(pstops_doc_t *doc, /* I - Document information */
- ppd_file_t *ppd) /* I - PPD file */
+do_prolog(pstops_doc_t *doc, // I - Document information
+ ppd_file_t *ppd) // I - PPD file
{
- char *ps; /* PS commands */
+ char *ps; // PS commands
- /*
- * Send the document prolog commands...
- */
+ //
+ // Send the document prolog commands...
+ //
if (ppd && ppd->patches)
{
free(ps);
}
- /*
- * Define ESPshowpage here so that applications that define their
- * own procedure to do a showpage pick it up...
- */
+ //
+ // Define ESPshowpage here so that applications that define their
+ // own procedure to do a showpage pick it up...
+ //
if (doc->use_ESPshowpage)
doc_puts(doc, "userdict/ESPshowpage/showpage load put\n"
}
-/*
- * 'do_setup()' - Send the necessary document setup commands.
- */
+//
+// 'do_setup()' - Send the necessary document setup commands.
+//
static void
-do_setup(pstops_doc_t *doc, /* I - Document information */
- ppd_file_t *ppd) /* I - PPD file */
+do_setup(pstops_doc_t *doc, // I - Document information
+ ppd_file_t *ppd) // I - PPD file
{
- char *ps; /* PS commands */
+ char *ps; // PS commands
+
+ //
+ // Disable CTRL-D so that embedded files don't cause printing
+ // errors...
- /*
- * Disable CTRL-D so that embedded files don't cause printing
- * errors...
- */
doc_puts(doc, "% Disable CTRL-D as an end-of-file marker...\n");
doc_puts(doc, "userdict dup(\\004)cvn{}put (\\004\\004)cvn{}put\n");
- /*
- * Send all the printer-specific setup commands...
- */
+ //
+ // Send all the printer-specific setup commands...
+ //
if ((ps = ppdEmitString(ppd, PPD_ORDER_DOCUMENT, 0.0)) != NULL)
{
free(ps);
}
- /*
- * Set the number of copies for the job...
- */
+ //
+ // Set the number of copies for the job...
+ //
if (doc->copies != 1 && (!doc->collate || !doc->slow_collate))
{
doc_puts(doc, "%RBIEndNonPPDFeature\n");
}
- /*
- * If we are doing N-up printing, disable setpagedevice...
- */
+ //
+ // If we are doing N-up printing, disable setpagedevice...
+ //
if (doc->number_up > 1)
{
doc_puts(doc, "userdict/setpagedevice{pop}bind put\n");
}
- /*
- * Make sure we have rectclip and rectstroke procedures of some sort...
- */
+ //
+ // Make sure we have rectclip and rectstroke procedures of some sort...
+ //
write_common(doc);
- /*
- * Write the page and label prologs...
- */
+ //
+ // Write the page and label prologs...
+ //
if (doc->number_up == 2 || doc->number_up == 6)
{
- /*
- * For 2- and 6-up output, rotate the labels to match the orientation
- * of the pages...
- */
+ //
+ // For 2- and 6-up output, rotate the labels to match the orientation
+ // of the pages...
+ //
if (doc->Orientation & 1)
write_label_prolog(doc, doc->page_label, doc->PageBottom,
}
-/*
- * 'doc_printf()' - Send a formatted string to the output file and/or the
- * temp file.
- *
- * This function should be used for all page-level output that is affected
- * by ordering, collation, etc.
- */
+//
+// 'doc_printf()' - Send a formatted string to the output file and/or the
+// temp file.
+//
+// This function should be used for all page-level output that is affected
+// by ordering, collation, etc.
+//
static void
-doc_printf(pstops_doc_t *doc, /* I - Document information */
- const char *format, /* I - Printf-style format string */
- ...) /* I - Additional arguments as needed */
+doc_printf(pstops_doc_t *doc, // I - Document information
+ const char *format, // I - Printf-style format string
+ ...) // I - Additional arguments as needed
{
- va_list ap; /* Pointer to arguments */
- char buffer[1024]; /* Output buffer */
- ssize_t bytes; /* Number of bytes to write */
+ va_list ap; // Pointer to arguments
+ char buffer[1024]; // Output buffer
+ ssize_t bytes; // Number of bytes to write
cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
}
-/*
- * 'doc_putc()' - Send a single character to the output file and/or the
- * temp file.
- *
- * This function should be used for all page-level output that is affected
- * by ordering, collation, etc.
- */
+//
+// 'doc_putc()' - Send a single character to the output file and/or the
+// temp file.
+//
+// This function should be used for all page-level output that is affected
+// by ordering, collation, etc.
+//
static void
-doc_putc(pstops_doc_t *doc, /* I - Document information */
- const char c) /* I - Character to send */
+doc_putc(pstops_doc_t *doc, // I - Document information
+ const char c) // I - Character to send
{
doc_write(doc, &c, 1);
}
-/*
- * 'doc_puts()' - Send a nul-terminated string to the output file and/or the
- * temp file.
- *
- * This function should be used for all page-level output that is affected
- * by ordering, collation, etc.
- */
+//
+// 'doc_puts()' - Send a nul-terminated string to the output file and/or the
+// temp file.
+//
+// This function should be used for all page-level output that is affected
+// by ordering, collation, etc.
+//
static void
-doc_puts(pstops_doc_t *doc, /* I - Document information */
- const char *s) /* I - String to send */
+doc_puts(pstops_doc_t *doc, // I - Document information
+ const char *s) // I - String to send
{
doc_write(doc, s, strlen(s));
}
-/*
- * 'doc_write()' - Send data to the output file and/or the temp file.
- */
+//
+// 'doc_write()' - Send data to the output file and/or the temp file.
+//
static void
-doc_write(pstops_doc_t *doc, /* I - Document information */
- const char *s, /* I - Data to send */
- size_t len) /* I - Number of bytes to send */
+doc_write(pstops_doc_t *doc, // I - Document information
+ const char *s, // I - Data to send
+ size_t len) // I - Number of bytes to send
{
if (!doc->slow_order)
fwrite(s, 1, len, doc->outputfp);
}
-/*
- * 'end_nup()' - End processing for N-up printing.
- */
+//
+// 'end_nup()' - End processing for N-up printing.
+//
static void
-end_nup(pstops_doc_t *doc, /* I - Document information */
- int number) /* I - Page number */
+end_nup(pstops_doc_t *doc, // I - Document information
+ int number) // I - Page number
{
if (doc->number_up > 1)
doc_puts(doc, "userdict/ESPsave get restore\n");
{
if (doc->Orientation & 1)
{
- /*
- * Rotate the labels back to portrait...
- */
+ //
+ // Rotate the labels back to portrait...
+ //
write_labels(doc, doc->Orientation - 1);
}
else if (doc->Orientation == 0)
{
- /*
- * Rotate the labels to landscape...
- */
+ //
+ // Rotate the labels to landscape...
+ //
write_labels(doc, doc->normal_landscape ? 1 : 3);
}
else
{
- /*
- * Rotate the labels to landscape...
- */
+ //
+ // Rotate the labels to landscape...
+ //
write_labels(doc, doc->normal_landscape ? 3 : 1);
}
}
-/*
- * 'include_feature()' - Include a printer option/feature command.
- */
+//
+// 'include_feature()' - Include a printer option/feature command.
+//
-static int /* O - New number of options */
+static int // O - New number of options
include_feature(
- pstops_doc_t *doc, /* I - Document information */
- ppd_file_t *ppd, /* I - PPD file */
- const char *line, /* I - DSC line */
- int num_options, /* I - Number of options */
- cups_option_t **options) /* IO - Options */
+ pstops_doc_t *doc, // I - Document information
+ ppd_file_t *ppd, // I - PPD file
+ const char *line, // I - DSC line
+ int num_options, // I - Number of options
+ cups_option_t **options) // IO - Options
{
- char name[255], /* Option name */
- value[255]; /* Option value */
- ppd_option_t *option; /* Option in file */
- cf_logfunc_t log = doc->logfunc;
+ char name[255], // Option name
+ value[255]; // Option value
+ ppd_option_t *option; // Option in file
+ cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
- /*
- * Get the "%%IncludeFeature: *Keyword OptionKeyword" values...
- */
+ //
+ // Get the "%%IncludeFeature: *Keyword OptionKeyword" values...
+ //
if (sscanf(line + 17, "%254s%254s", name, value) != 2)
{
return (num_options);
}
- /*
- * Find the option and choice...
- */
+ //
+ // Find the option and choice...
+ //
if ((option = ppdFindOption(ppd, name + 1)) == NULL)
{
return (num_options);
}
- /*
- * Add the option to the option array and return...
- */
+ //
+ // Add the option to the option array and return...
+ //
return (cupsAddOption(name + 1, value, num_options, options));
}
-/*
- * 'parse_text()' - Parse a text value in a comment.
- *
- * This function parses a DSC text value as defined on page 36 of the
- * DSC specification. Text values are either surrounded by parenthesis
- * or whitespace-delimited.
- *
- * The value returned is the literal characters for the entire text
- * string, including any parenthesis and escape characters.
- */
-
-static char * /* O - Value or NULL on error */
-parse_text(const char *start, /* I - Start of text value */
- char **end, /* O - End of text value */
- char *buffer, /* I - Buffer */
- size_t bufsize) /* I - Size of buffer */
+//
+// 'parse_text()' - Parse a text value in a comment.
+//
+// This function parses a DSC text value as defined on page 36 of the
+// DSC specification. Text values are either surrounded by parenthesis
+// or whitespace-delimited.
+//
+// The value returned is the literal characters for the entire text
+// string, including any parenthesis and escape characters.
+//
+
+static char * // O - Value or NULL on error
+parse_text(const char *start, // I - Start of text value
+ char **end, // O - End of text value
+ char *buffer, // I - Buffer
+ size_t bufsize) // I - Size of buffer
{
- char *bufptr, /* Pointer in buffer */
- *bufend; /* End of buffer */
- int level; /* Parenthesis level */
+ char *bufptr, // Pointer in buffer
+ *bufend; // End of buffer
+ int level; // Parenthesis level
- /*
- * Skip leading whitespace...
- */
+ //
+ // Skip leading whitespace...
+ //
while (isspace(*start & 255))
start ++;
- /*
- * Then copy the value...
- */
+ //
+ // Then copy the value...
+ //
level = 0;
bufptr = buffer;
}
else if (*start == '\\')
{
- /*
- * Copy escaped character...
- */
+ //
+ // Copy escaped character...
+ //
- int i; /* Looping var */
+ int i; // Looping var
for (i = 1;
*bufptr = '\0';
- /*
- * Return the value and new pointer into the line...
- */
+ //
+ // Return the value and new pointer into the line...
+ //
if (end)
*end = (char *)start;
}
-/*
- * 'ps_hex()' - Print binary data as a series of hexadecimal numbers.
- */
+//
+// 'ps_hex()' - Print binary data as a series of hexadecimal numbers.
+//
static void
ps_hex(pstops_doc_t *doc,
- cf_ib_t *data, /* I - Data to print */
- int length, /* I - Number of bytes to print */
- int last_line) /* I - Last line of raster data? */
+ cf_ib_t *data, // I - Data to print
+ int length, // I - Number of bytes to print
+ int last_line) // I - Last line of raster data?
{
- static int col = 0; /* Current column */
+ static int col = 0; // Current column
static char *hex = "0123456789ABCDEF";
- /* Hex digits */
+ // Hex digits
while (length > 0)
{
- /*
- * Put the hex chars out to the file; note that we don't use fprintf()
- * for speed reasons...
- */
+ //
+ // Put the hex chars out to the file; note that we don't use fprintf()
+ // for speed reasons...
+ //
doc_putc(doc, hex[*data >> 4]);
doc_putc(doc, hex[*data & 15]);
}
-/*
- * 'ps_ascii85()' - Print binary data as a series of base-85 numbers.
- */
+//
+// 'ps_ascii85()' - Print binary data as a series of base-85 numbers.
+//
static void
ps_ascii85(pstops_doc_t *doc,
- cf_ib_t *data, /* I - Data to print */
- int length, /* I - Number of bytes to print */
- int last_line) /* I - Last line of raster data? */
+ cf_ib_t *data, // I - Data to print
+ int length, // I - Number of bytes to print
+ int last_line) // I - Last line of raster data?
{
- unsigned b; /* Binary data word */
- unsigned char c[5]; /* ASCII85 encoded chars */
- static int col = 0; /* Current column */
+ unsigned b; // Binary data word
+ unsigned char c[5]; // ASCII85 encoded chars
+ static int col = 0; // Current column
while (length > 3)
}
-/*
- * 'set_pstops_options()' - Set pstops options.
- */
+//
+// 'set_pstops_options()' - Set pstops options.
+//
static int
set_pstops_options(
- pstops_doc_t *doc, /* I - Document information */
- ppd_file_t *ppd, /* I - PPD file */
- int job_id, /* I - Job ID */
- char *job_user, /* I - Job User */
- char *job_title, /* I - Job Title */
- int copies, /* I - Number of copies */
- int num_options, /* I - Number of options */
- cups_option_t *options, /* I - Options */
- cf_logfunc_t logfunc, /* I - Logging function,
- NULL for no logging */
- void *logdata, /* I - User data for logging function,
- can be NULL */
- cf_filter_iscanceledfunc_t iscanceledfunc, /* I - Function returning 1 when
- job is canceled, NULL for not
- supporting stop on cancel */
- void *iscanceleddata) /* I - User data for is-canceled
- function, can be NULL */
+ pstops_doc_t *doc, // I - Document information
+ ppd_file_t *ppd, // I - PPD file
+ int job_id, // I - Job ID
+ char *job_user, // I - Job User
+ char *job_title, // I - Job Title
+ int copies, // I - Number of copies
+ int num_options, // I - Number of options
+ cups_option_t *options, // I - Options
+ cf_logfunc_t logfunc, // I - Logging function,
+ // NULL for no logging
+ void *logdata, // I - User data for logging function,
+ // can be NULL
+ cf_filter_iscanceledfunc_t iscanceledfunc, // I - Function returning 1 when
+ // job is canceled, NULL for not
+ // supporting stop on cancel
+ void *iscanceleddata) // I - User data for is-canceled
+ // function, can be NULL
{
- const char *val; /* Option value */
- int intval; /* Integer option value */
- ppd_attr_t *attr; /* PPD attribute */
- ppd_option_t *option; /* PPD option */
- ppd_choice_t *choice; /* PPD choice */
- const char *content_type; /* Original content type */
- int max_copies; /* Maximum number of copies supported */
- cf_logfunc_t log = logfunc;
+ const char *val; // Option value
+ int intval; // Integer option value
+ ppd_attr_t *attr; // PPD attribute
+ ppd_option_t *option; // PPD option
+ ppd_choice_t *choice; // PPD choice
+ const char *content_type; // Original content type
+ int max_copies; // Maximum number of copies supported
+ cf_logfunc_t log = logfunc;
void *ld = logdata;
cf_filter_iscanceledfunc_t iscanceled = iscanceledfunc;
void *icd = iscanceleddata;
- /*
- * Initialize document information structure...
- */
+ //
+ // Initialize document information structure...
+ //
memset(doc, 0, sizeof(pstops_doc_t));
- /* Job info, to appear on the printer's front panel while printing */
+ // Job info, to appear on the printer's front panel while printing
doc->job_id = (job_id > 0 ? job_id : 0);
doc->user = (job_user ? job_user : "Unknown");
doc->title = (job_title ? job_title : "");
- /* Number of copies, 1 if this filter should not handle copies */
+ // Number of copies, 1 if this filter should not handle copies
doc->copies = (copies > 0 ? copies : 1);
- /* Logging function */
+ // Logging function
doc->logfunc = log;
doc->logdata = ld;
- /* Job-is-canceled function */
+ // Job-is-canceled function
doc->iscanceledfunc = iscanceled;
doc->iscanceleddata = icd;
- /* Set some common values */
+ // Set some common values
ppdFilterSetCommonOptions(ppd, num_options, options, 1,
- &doc->Orientation, &doc->Duplex,
- &doc->LanguageLevel, &doc->Color,
- &doc->PageLeft, &doc->PageRight,
- &doc->PageTop, &doc->PageBottom,
- &doc->PageWidth, &doc->PageLength,
- log, ld);
+ &doc->Orientation, &doc->Duplex,
+ &doc->LanguageLevel, &doc->Color,
+ &doc->PageLeft, &doc->PageRight,
+ &doc->PageTop, &doc->PageBottom,
+ &doc->PageWidth, &doc->PageLength,
+ log, ld);
if (ppd && ppd->landscape > 0)
doc->normal_landscape = 1;
doc->new_bounding_box[2] = INT_MIN;
doc->new_bounding_box[3] = INT_MIN;
- /*
- * AP_FIRSTPAGE_* and the corresponding non-first-page options.
- */
+ //
+ // AP_FIRSTPAGE_* and the corresponding non-first-page options.
+ //
doc->ap_input_slot = cupsGetOption("AP_FIRSTPAGE_InputSlot", num_options,
options);
if ((choice = ppdFindMarkedChoice(ppd, "PageSize")) != NULL)
doc->page_size = choice->choice;
- /*
- * collate, multiple-document-handling
- */
+ //
+ // collate, multiple-document-handling
+ //
if ((val = cupsGetOption("multiple-document-handling",
num_options, options)) != NULL)
{
- /*
- * This IPP attribute is unnecessarily complicated...
- *
- * single-document, separate-documents-collated-copies, and
- * single-document-new-sheet all require collated copies.
- *
- * separate-documents-uncollated-copies allows for uncollated copies.
- */
+ //
+ // This IPP attribute is unnecessarily complicated...
+ //
+ // single-document, separate-documents-collated-copies, and
+ // single-document-new-sheet all require collated copies.
+ //
+ // separate-documents-uncollated-copies allows for uncollated copies.
+ //
doc->collate = strcasecmp(val, "separate-documents-uncollated-copies") != 0;
}
!strcasecmp(val, "yes")))
doc->collate = 1;
- /*
- * emit-jcl
- */
+ //
+ // emit-jcl
+ //
if ((val = cupsGetOption("emit-jcl", num_options, options)) != NULL &&
(!strcasecmp(val, "false") || !strcasecmp(val, "off") ||
else
doc->emit_jcl = 1;
- /*
- * fit-to-page/ipp-attribute-fidelity
- *
- * (Only for original PostScript content)
- */
+ //
+ // fit-to-page/ipp-attribute-fidelity
+ //
+ // (Only for original PostScript content)
+ //
if ((content_type = getenv("CONTENT_TYPE")) == NULL)
content_type = "application/postscript";
doc->fit_to_page = 1;
}
- /*
- * mirror/MirrorPrint
- */
+ //
+ // mirror/MirrorPrint
+ //
if ((choice = ppdFindMarkedChoice(ppd, "MirrorPrint")) != NULL)
{
!strcasecmp(val, "yes")))
doc->mirror = 1;
- /*
- * number-up
- */
+ //
+ // number-up
+ //
if ((val = cupsGetOption("number-up", num_options, options)) != NULL)
{
else
doc->number_up = 1;
- /*
- * number-up-layout
- */
+ //
+ // number-up-layout
+ //
if ((val = cupsGetOption("number-up-layout", num_options, options)) != NULL)
{
else
doc->number_up_layout = PSTOPS_LAYOUT_LRTB;
- /*
- * OutputOrder
- */
+ //
+ // OutputOrder
+ //
if ((val = cupsGetOption("OutputOrder", num_options, options)) != NULL)
{
}
else if (ppd)
{
- /*
- * Figure out the right default output order from the PPD file...
- */
+ //
+ // Figure out the right default output order from the PPD file...
+ //
if ((choice = ppdFindMarkedChoice(ppd, "OutputBin")) != NULL &&
(attr = ppdFindAttr(ppd, "PageStackOrder", choice->choice)) != NULL &&
doc->output_order = !strcasecmp(attr->value, "Reverse");
}
- /*
- * page-border
- */
+ //
+ // page-border
+ //
if ((val = cupsGetOption("page-border", num_options, options)) != NULL)
{
else
doc->page_border = PSTOPS_BORDERNONE;
- /*
- * page-label
- */
+ //
+ // page-label
+ //
doc->page_label = cupsGetOption("page-label", num_options, options);
-
- /*
- * input-page-ranges
- */
- doc->inputPageRange=cupsGetOption("input-page-ranges",num_options,options);
-
- /*
- * page-ranges
- */
+ //
+ // input-page-ranges
+ //
+
+ doc->inputPageRange=cupsGetOption("input-page-ranges", num_options, options);
+
+ //
+ // page-ranges
+ //
doc->page_ranges = cupsGetOption("page-ranges", num_options, options);
- /*
- * page-set
- */
+ //
+ // page-set
+ //
doc->page_set = cupsGetOption("page-set", num_options, options);
- /*
- * Now figure out if we have to force collated copies, etc.
- */
+ //
+ // Now figure out if we have to force collated copies, etc.
+ //
if ((attr = ppdFindAttr(ppd, "cupsMaxCopies", NULL)) != NULL)
max_copies = atoi(attr->value);
doc->collate = 1;
else if (ppd && ppd->manual_copies && doc->Duplex && doc->copies > 1)
{
- /*
- * Force collated copies when printing a duplexed document to
- * a non-PS printer that doesn't do hardware copy generation.
- * Otherwise the copies will end up on the front/back side of
- * each page.
- */
+ //
+ // Force collated copies when printing a duplexed document to
+ // a non-PS printer that doesn't do hardware copy generation.
+ // Otherwise the copies will end up on the front/back side of
+ // each page.
+ //
doc->collate = 1;
}
- /*
- * See if we have to filter the fast or slow way...
- */
+ //
+ // See if we have to filter the fast or slow way...
+ //
if (doc->collate && doc->copies > 1)
{
- /*
- * See if we need to manually collate the pages...
- */
+ //
+ // See if we need to manually collate the pages...
+ //
doc->slow_collate = 1;
(choice = ppdFindMarkedChoice(ppd, "Collate")) != NULL &&
!strcasecmp(choice->choice, "True"))
{
- /*
- * Hardware collate option is selected, see if the option is
- * conflicting - if not, collate in hardware. Otherwise,
- * turn the hardware collate option off...
- */
+ //
+ // Hardware collate option is selected, see if the option is
+ // conflicting - if not, collate in hardware. Otherwise,
+ // turn the hardware collate option off...
+ //
if ((option = ppdFindOption(ppd, "Collate")) != NULL &&
!option->conflicted)
else
doc->slow_duplex = 0;
- /*
- * Create a temporary file for page data if we need to filter slowly...
- */
+ //
+ // Create a temporary file for page data if we need to filter slowly...
+ //
if (doc->slow_order || doc->slow_collate)
{
}
}
- /*
- * Figure out if we should use ESPshowpage or not...
- */
+ //
+ // Figure out if we should use ESPshowpage or not...
+ //
if (doc->page_label || getenv("CLASSIFICATION") || doc->number_up > 1 ||
doc->page_border)
{
- /*
- * Yes, use ESPshowpage...
- */
+ //
+ // Yes, use ESPshowpage...
+ //
doc->use_ESPshowpage = 1;
}
}
-/*
- * 'skip_page()' - Skip past a page that won't be printed.
- */
+//
+// 'skip_page()' - Skip past a page that won't be printed.
+//
-static ssize_t /* O - Length of next line */
-skip_page(pstops_doc_t *doc, /* I - Document information */
- char *line, /* I - Line buffer */
- ssize_t linelen, /* I - Length of initial line */
- size_t linesize) /* I - Size of line buffer */
+static ssize_t // O - Length of next line
+skip_page(pstops_doc_t *doc, // I - Document information
+ char *line, // I - Line buffer
+ ssize_t linelen, // I - Length of initial line
+ size_t linesize) // I - Size of line buffer
{
- int level; /* Embedded document level */
+ int level; // Embedded document level
cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
(!strncmp(line, "%%BeginData:", 12) &&
!strstr(line, "ASCII") && !strstr(line, "Hex")))
{
- /*
- * Skip binary data...
- */
+ //
+ // Skip binary data...
+ //
- ssize_t bytes; /* Bytes of data */
+ ssize_t bytes; // Bytes of data
bytes = atoi(strchr(line, ':') + 1);
}
-/*
- * 'start_nup()' - Start processing for N-up printing.
- */
+//
+// 'start_nup()' - Start processing for N-up printing.
+//
static void
-start_nup(pstops_doc_t *doc, /* I - Document information */
- int number, /* I - Page number */
- int show_border, /* I - Show the border? */
- const int *bounding_box) /* I - BoundingBox value */
+start_nup(pstops_doc_t *doc, // I - Document information
+ int number, // I - Page number
+ int show_border, // I - Show the border?
+ const int *bounding_box) // I - BoundingBox value
{
- int pos; /* Position on page */
- int x, y; /* Relative position of subpage */
- double w, l, /* Width and length of subpage */
- tx, ty; /* Translation values for subpage */
- double pagew, /* Printable width of page */
- pagel; /* Printable height of page */
- int bboxx, /* BoundingBox X origin */
- bboxy, /* BoundingBox Y origin */
- bboxw, /* BoundingBox width */
- bboxl; /* BoundingBox height */
- double margin = 0; /* Current margin for border */
- cf_logfunc_t log = doc->logfunc;
+ int pos; // Position on page
+ int x, y; // Relative position of subpage
+ double w, l, // Width and length of subpage
+ tx, ty; // Translation values for subpage
+ double pagew, // Printable width of page
+ pagel; // Printable height of page
+ int bboxx, // BoundingBox X origin
+ bboxy, // BoundingBox Y origin
+ bboxw, // BoundingBox width
+ bboxl; // BoundingBox height
+ double margin = 0; // Current margin for border
+ cf_logfunc_t log = doc->logfunc;
void *ld = doc->logdata;
switch (doc->Orientation)
{
- case 1 : /* Landscape */
+ case 1 : // Landscape
doc_printf(doc, "%.1f 0.0 translate 90 rotate\n", doc->PageLength);
break;
- case 2 : /* Reverse Portrait */
+ case 2 : // Reverse Portrait
doc_printf(doc, "%.1f %.1f translate 180 rotate\n", doc->PageWidth,
doc->PageLength);
break;
- case 3 : /* Reverse Landscape */
+ case 3 : // Reverse Landscape
doc_printf(doc, "0.0 %.1f translate -90 rotate\n", doc->PageWidth);
break;
}
- /*
- * Mirror the page as needed...
- */
+ //
+ // Mirror the page as needed...
+ //
if (doc->mirror)
doc_printf(doc, "%.1f 0.0 translate -1 1 scale\n", doc->PageWidth);
- /*
- * Offset and scale as necessary for fit_to_page/fit-to-page/number-up...
- */
+ //
+ // Offset and scale as necessary for fit_to_page/fit-to-page/number-up...
+ //
if (doc->Duplex && doc->number_up > 1 && ((number / doc->number_up) & 1))
doc_printf(doc, "%.1f %.1f translate\n", doc->PageWidth - doc->PageRight,
break;
}
- /*
- * Draw borders as necessary...
- */
+ //
+ // Draw borders as necessary...
+ //
if (doc->page_border && show_border)
{
- int rects; /* Number of border rectangles */
- double fscale; /* Scaling value for points */
+ int rects; // Number of border rectangles
+ double fscale; // Scaling value for points
rects = (doc->page_border & PSTOPS_BORDERDOUBLE) ? 2 : 1;
fscale = doc->PageWidth / w;
margin = 2.25 * fscale;
- /*
- * Set the line width and color...
- */
+ //
+ // Set the line width and color...
+ //
doc_puts(doc, "gsave\n");
doc_printf(doc, "%.3f setlinewidth 0 setgray newpath\n",
(doc->page_border & PSTOPS_BORDERTHICK) ? 0.5 * fscale :
0.24 * fscale);
- /*
- * Draw border boxes...
- */
+ //
+ // Draw border boxes...
+ //
for (; rects > 0; rects --, margin += 2 * fscale)
if (doc->number_up > 1)
doc->PageRight - doc->PageLeft - 2 * margin,
doc->PageTop - doc->PageBottom - 2 * margin);
- /*
- * Restore pen settings...
- */
+ //
+ // Restore pen settings...
+ //
doc_puts(doc, "grestore\n");
}
if (doc->fit_to_page)
{
- /*
- * Offset the page by its bounding box...
- */
+ //
+ // Offset the page by its bounding box...
+ //
doc_printf(doc, "%d %d translate\n", -bounding_box[0],
-bounding_box[1]);
if (doc->fit_to_page || doc->number_up > 1)
{
- /*
- * Clip the page to the page's bounding box...
- */
+ //
+ // Clip the page to the page's bounding box...
+ //
doc_printf(doc, "%.1f %.1f %.1f %.1f ESPrc\n",
bboxx + margin, bboxy + margin,
}
-/*
- * 'write_common()' - Write common procedures...
- */
+//
+// 'write_common()' - Write common procedures...
+//
static void
write_common(pstops_doc_t *doc)
}
-/*
- * 'write_label_prolog()' - Write the prolog with the classification
- * and page label.
- */
+//
+// 'write_label_prolog()' - Write the prolog with the classification
+// and page label.
+
static void
-write_label_prolog(pstops_doc_t *doc, /* I - Document info */
- const char *label, /* I - Page label */
- float bottom, /* I - Bottom position in points */
- float top, /* I - Top position in points */
- float width) /* I - Width in points */
+write_label_prolog(pstops_doc_t *doc, // I - Document info
+ const char *label, // I - Page label
+ float bottom, // I - Bottom position in points
+ float top, // I - Top position in points
+ float width) // I - Width in points
{
- const char *classification; /* CLASSIFICATION environment
- variable */
- const char *ptr; /* Temporary string pointer */
+ const char *classification; // CLASSIFICATION environment
+ // variable
+ const char *ptr; // Temporary string pointer
- /*
- * First get the current classification...
- */
+ //
+ // First get the current classification...
+ //
if ((classification = getenv("CLASSIFICATION")) == NULL)
classification = "";
if (strcmp(classification, "none") == 0)
classification = "";
- /*
- * If there is nothing to show, bind an empty 'write labels' procedure
- * and return...
- */
+ //
+ // If there is nothing to show, bind an empty 'write labels' procedure
+ // and return...
+ //
if (!classification[0] && (label == NULL || !label[0]))
{
return;
}
- /*
- * Set the classification + page label string...
- */
+ //
+ // Set the classification + page label string...
+ //
doc_puts(doc, "userdict");
if (!strcmp(classification, "confidential"))
if (classification[0])
doc_puts(doc, " - ");
- /*
- * Quote the label string as needed...
- */
+ //
+ // Quote the label string as needed...
+ //
for (ptr = label; *ptr; ptr ++)
{
doc_puts(doc, ")put\n");
- /*
- * Then get a 14 point Helvetica-Bold font...
- */
+ //
+ // Then get a 14 point Helvetica-Bold font...
+ //
doc_puts(doc, "userdict/ESPpf /Helvetica-Bold findfont 14 scalefont put\n");
- /*
- * Finally, the procedure to write the labels on the page...
- */
+ //
+ // Finally, the procedure to write the labels on the page...
+ //
doc_puts(doc, "userdict/ESPwl{\n");
doc_puts(doc, " ESPpf setfont\n");
}
-/*
- * 'write_labels()' - Write the actual page labels.
- *
- * This function is a copy of the one in common.c since we need to
- * use doc_puts/doc_printf instead of puts/printf...
- */
+//
+// 'write_labels()' - Write the actual page labels.
+//
+// This function is a copy of the one in common.c since we need to
+// use doc_puts/doc_printf instead of puts/printf...
+//
static void
-write_labels(pstops_doc_t *doc, /* I - Document information */
- int orient) /* I - Orientation of the page */
+write_labels(pstops_doc_t *doc, // I - Document information
+ int orient) // I - Orientation of the page
{
- float width, /* Width of page */
- length; /* Length of page */
+ float width, // Width of page
+ length; // Length of page
doc_puts(doc, "gsave\n");
switch (orient & 3)
{
- case 1 : /* Landscape */
+ case 1 : // Landscape
doc_printf(doc, "%.1f 0.0 translate 90 rotate\n", length);
break;
- case 2 : /* Reverse Portrait */
+ case 2 : // Reverse Portrait
doc_printf(doc, "%.1f %.1f translate 180 rotate\n", width, length);
break;
- case 3 : /* Reverse Landscape */
+ case 3 : // Reverse Landscape
doc_printf(doc, "0.0 %.1f translate -90 rotate\n", width);
break;
}
}
-/*
- * 'write_labels_outputfile_only()' - Write the actual page labels to the
- * output file.
- *
- * This function is a copy of the one in common.c. Since we use it only
- * in this filter, we have moved it to here.
- */
+//
+// 'write_labels_outputfile_only()' - Write the actual page labels to the
+// output file.
+//
+// This function is a copy of the one in common.c. Since we use it only
+// in this filter, we have moved it to here.
+//
static void
-write_labels_outputfile_only(pstops_doc_t *doc,/* I - Document information */
- int orient)/* I - Orientation of the page */
+write_labels_outputfile_only(pstops_doc_t *doc,// I - Document information
+ int orient)// I - Orientation of the page
{
- float width, /* Width of page */
- length; /* Length of page */
+ float width, // Width of page
+ length; // Length of page
doc_puts(doc, "gsave\n");
switch (orient & 3)
{
- case 1 : /* Landscape */
+ case 1 : // Landscape
doc_printf(doc, "%.1f 0.0 translate 90 rotate\n", length);
break;
- case 2 : /* Reverse Portrait */
+ case 2 : // Reverse Portrait
doc_printf(doc, "%.1f %.1f translate 180 rotate\n",
width, length);
break;
- case 3 : /* Reverse Landscape */
+ case 3 : // Reverse Landscape
doc_printf(doc, "0.0 %.1f translate -90 rotate\n", width);
break;
}
}
-/*
- * 'write_options()' - Write options provided via %%IncludeFeature.
- */
+//
+// 'write_options()' - Write options provided via %%IncludeFeature.
+//
static void
write_options(
- pstops_doc_t *doc, /* I - Document */
- ppd_file_t *ppd, /* I - PPD file */
- int num_options, /* I - Number of options */
- cups_option_t *options) /* I - Options */
+ pstops_doc_t *doc, // I - Document
+ ppd_file_t *ppd, // I - PPD file
+ int num_options, // I - Number of options
+ cups_option_t *options) // I - Options
{
- int i; /* Looping var */
- ppd_option_t *option; /* PPD option */
- float min_order; /* Minimum OrderDependency value */
- char *doc_setup, /* DocumentSetup commands to send */
- *any_setup; /* AnySetup commands to send */
+ int i; // Looping var
+ ppd_option_t *option; // PPD option
+ float min_order; // Minimum OrderDependency value
+ char *doc_setup, // DocumentSetup commands to send
+ *any_setup; // AnySetup commands to send
- /*
- * Figure out the minimum OrderDependency value...
- */
+ //
+ // Figure out the minimum OrderDependency value...
+ //
if ((option = ppdFindOption(ppd, "PageRegion")) != NULL)
min_order = option->order;
option->order < min_order)
min_order = option->order;
- /*
- * Mark and extract them...
- */
+ //
+ // Mark and extract them...
+ //
ppdMarkOptions(ppd, num_options, options);
doc_setup = ppdEmitString(ppd, PPD_ORDER_DOCUMENT, min_order);
any_setup = ppdEmitString(ppd, PPD_ORDER_ANY, min_order);
- /*
- * Then send them out...
- */
+ //
+ // Then send them out...
+ //
if (doc->number_up > 1)
{
- /*
- * Temporarily restore setpagedevice so we can set the options...
- */
+ //
+ // Temporarily restore setpagedevice so we can set the options...
+ //
doc_puts(doc, "userdict/setpagedevice/CUPSsetpagedevice load put\n");
}
if (doc->number_up > 1)
{
- /*
- * Disable setpagedevice again...
- */
+ //
+ // Disable setpagedevice again...
+ //
doc_puts(doc, "userdict/setpagedevice{pop}bind put\n");
}
}
-/*
- * 'write_text_comment()' - Write a DSC text comment.
- */
+//
+// 'write_text_comment()' - Write a DSC text comment.
+//
static void
-write_text_comment(pstops_doc_t *doc, /* I - Document */
- const char *name, /* I - Comment name ("Title", etc.) */
- const char *value) /* I - Comment value */
+write_text_comment(pstops_doc_t *doc, // I - Document
+ const char *name, // I - Comment name ("Title", etc.)
+ const char *value) // I - Comment value
{
- int len; /* Current line length */
+ int len; // Current line length
- /*
- * DSC comments are of the form:
- *
- * %%name: value
- *
- * The name and value must be limited to 7-bit ASCII for most printers,
- * so we escape all non-ASCII and ASCII control characters as described
- * in the Adobe Document Structuring Conventions specification.
- */
+ //
+ // DSC comments are of the form:
+ //
+ // %%name: value
+ //
+ // The name and value must be limited to 7-bit ASCII for most printers,
+ // so we escape all non-ASCII and ASCII control characters as described
+ // in the Adobe Document Structuring Conventions specification.
+ //
doc_printf(doc, "%%%%%s: (", name);
len = 5 + strlen(name);
{
if (*value < ' ' || *value >= 127)
{
- /*
- * Escape this character value...
- */
+ //
+ // Escape this character value...
+ //
- if (len >= 251) /* Keep line < 254 chars */
+ if (len >= 251) // Keep line < 254 chars
break;
doc_printf(doc, "\\%03o", *value & 255);
}
else if (*value == '\\')
{
- /*
- * Escape the backslash...
- */
+ //
+ // Escape the backslash...
+ //
- if (len >= 253) /* Keep line < 254 chars */
+ if (len >= 253) // Keep line < 254 chars
break;
doc_putc(doc, '\\');
}
else
{
- /*
- * Put this character literally...
- */
+ //
+ // Put this character literally...
+ //
- if (len >= 254) /* Keep line < 254 chars */
+ if (len >= 254) // Keep line < 254 chars
break;
doc_putc(doc, *value);
-/*
- * Private IPP definitions for libppd.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private IPP definitions for libppd.
+//
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _PPD_IPP_PRIVATE_H_
# define _PPD_IPP_PRIVATE_H_
-/*
- * Include necessary headers...
- */
+
+//
+// Include necessary headers...
+//
# include <cups/file.h>
# include <cups/ipp.h>
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Structures...
- */
+//
+// Structures...
+//
-typedef struct _ppd_ipp_option_s /**** Attribute mapping data ****/
+typedef struct _ppd_ipp_option_s // **** Attribute mapping data ****
{
- int multivalue; /* Option has multiple values? */
- const char *name; /* Option/attribute name */
- ipp_tag_t value_tag; /* Value tag for this attribute */
- ipp_tag_t group_tag; /* Group tag for this attribute */
- ipp_tag_t alt_group_tag; /* Alternate group tag for this
- * attribute */
- const ipp_op_t *operations; /* Allowed operations for this attr */
+ int multivalue; // Option has multiple values?
+ const char *name; // Option/attribute name
+ ipp_tag_t value_tag; // Value tag for this attribute
+ ipp_tag_t group_tag; // Group tag for this attribute
+ ipp_tag_t alt_group_tag; // Alternate group tag for this
+ // attribute
+ const ipp_op_t *operations; // Allowed operations for this attr
} _ppd_ipp_option_t;
-/*
- * Prototypes for private functions...
- */
+//
+// Prototypes for private functions...
+//
-/* encode.c */
+// encode.c
extern _ppd_ipp_option_t *_ppdIppFindOption(const char *name);
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_PPD_IPP_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_PPD_IPP_PRIVATE_H_
-/*
- * This file contains model number definitions for the CUPS sample
- * label printer driver.
- *
- * Copyright 2007 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// This file contains model number definitions for the CUPS sample
+// label printer driver.
+//
+// Copyright 2007 by Apple Inc.
+// Copyright 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
-#define DYMO_3x0 0 /* Dymo Labelwriter 300/330/330 Turbo */
+#define DYMO_3x0 0 // Dymo Labelwriter 300/330/330 Turbo
-#define ZEBRA_EPL_LINE 0x10 /* Zebra EPL line mode printers */
-#define ZEBRA_EPL_PAGE 0x11 /* Zebra EPL page mode printers */
-#define ZEBRA_ZPL 0x12 /* Zebra ZPL-based printers */
-#define ZEBRA_CPCL 0x13 /* Zebra CPCL-based printers */
+#define ZEBRA_EPL_LINE 0x10 // Zebra EPL line mode printers
+#define ZEBRA_EPL_PAGE 0x11 // Zebra EPL page mode printers
+#define ZEBRA_ZPL 0x12 // Zebra ZPL-based printers
+#define ZEBRA_CPCL 0x13 // Zebra CPCL-based printers
-#define INTELLITECH_PCL 0x20 /* Intellitech PCL-based printers */
+#define INTELLITECH_PCL 0x20 // Intellitech PCL-based printers
-/*
- * Private localization support for libppd.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private localization support functions for libppd.
+//
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _PPD_LANGUAGE_PRIVATE_H_
# define _PPD_LANGUAGE_PRIVATE_H_
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
# include "config.h"
# include <stdio.h>
# include <cups/transcode.h>
# ifdef __APPLE__
# include <CoreFoundation/CoreFoundation.h>
-# endif /* __APPLE__ */
+# endif // __APPLE__
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Macro for localized text...
- */
+//
+// Macro for localized text...
+//
# define _(x) x
-/*
- * Constants...
- */
+//
+// Constants...
+//
-# define _PPD_MESSAGE_PO 0 /* Message file is in GNU .po format */
-# define _PPD_MESSAGE_UNQUOTE 1 /* Unescape \foo in strings? */
-# define _PPD_MESSAGE_STRINGS 2 /* Message file is in Apple .strings format */
-# define _PPD_MESSAGE_EMPTY 4 /* Allow empty localized strings */
+# define _PPD_MESSAGE_PO 0 // Message file is in GNU .po format
+# define _PPD_MESSAGE_UNQUOTE 1 // Unescape \foo in strings?
+# define _PPD_MESSAGE_STRINGS 2 // Message file is in Apple .strings
+ // format
+# define _PPD_MESSAGE_EMPTY 4 // Allow empty localized strings
-/*
- * Types...
- */
+//
+// Types...
+//
-typedef struct _ppd_message_s /**** Message catalog entry ****/
+typedef struct _ppd_message_s // **** Message catalog entry ****
{
- char *msg, /* Original string */
- *str; /* Localized string */
+ char *msg, // Original string
+ *str; // Localized string
} _ppd_message_t;
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
extern const char *_ppdLangString(cups_lang_t *lang, const char *message);
extern void _ppdMessageFree(cups_array_t *a);
# ifdef __cplusplus
}
-# endif /* __cplusplus */
+# endif // __cplusplus
-#endif /* !_PPD_LANGUAGE_PRIVATE_H_ */
+#endif // !_PPD_LANGUAGE_PRIVATE_H_
-/*
- * I18N/language support for libppd.
- *
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// I18N/language support for libppd.
+//
+// Copyright 2007-2017 by Apple Inc.
+// Copyright 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "language-private.h"
#include "debug-internal.h"
#ifdef HAVE_LANGINFO_H
# include <langinfo.h>
-#endif /* HAVE_LANGINFO_H */
+#endif // HAVE_LANGINFO_H
#ifdef _WIN32
# include <io.h>
#else
# include <unistd.h>
-#endif /* _WIN32 */
+#endif // _WIN32
#ifdef HAVE_COREFOUNDATION_H
# include <CoreFoundation/CoreFoundation.h>
-#endif /* HAVE_COREFOUNDATION_H */
+#endif // HAVE_COREFOUNDATION_H
#include <cups/file.h>
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
static _ppd_mutex_t lang_mutex = _PPD_MUTEX_INITIALIZER;
- /* Mutex to control access to cache */
+ // Mutex to control access to cache
#ifdef __APPLE__
typedef struct
{
- const char * const language; /* Language ID */
- const char * const locale; /* Locale ID */
+ const char * const language; // Language ID
+ const char * const locale; // Locale ID
} _apple_language_locale_t;
static const _apple_language_locale_t apple_language_locale[] =
-{ /* Language to locale ID LUT */
+{ // Language to locale ID LUT
{ "en", "en_US" },
{ "nb", "no" },
{ "nb_NO", "no" },
{ "zh_HANT", "zh_TW" },
{ "zh-Hant_CN", "zh_TW" }
};
-#endif /* __APPLE__ */
+#endif // __APPLE__
-/*
- * Local functions...
- */
-
+//
+// Local functions...
+//
#ifdef __APPLE__
static const char *appleLangDefault(void);
# define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
# else
# define CF_RETURNS_RETAINED
-# endif /* __has_feature(attribute_cf_returns_retained) */
-# endif /* !CF_RETURNED_RETAINED */
+# endif // __has_feature(attribute_cf_returns_retained)
+# endif // !CF_RETURNED_RETAINED
static cups_array_t *appleMessageLoad(const char *locale) CF_RETURNS_RETAINED;
-# endif /* CUPS_BUNDLEDIR */
-#endif /* __APPLE__ */
+# endif // CUPS_BUNDLEDIR
+#endif // __APPLE__
static int ppd_message_compare(_ppd_message_t *m1, _ppd_message_t *m2);
static void ppd_message_free(_ppd_message_t *m);
static void ppd_message_load(cups_lang_t *lang);
static void ppd_unquote(char *d, const char *s);
-/*
- * '_ppdLangString()' - Get a message string.
- *
- * The returned string is UTF-8 encoded; use cupsUTF8ToCharset() to
- * convert the string to the language encoding.
- */
+//
+// '_ppdLangString()' - Get a message string.
+//
+// The returned string is UTF-8 encoded; use cupsUTF8ToCharset() to
+// convert the string to the language encoding.
+//
-const char * /* O - Localized message */
-_ppdLangString(cups_lang_t *lang, /* I - Language */
- const char *message) /* I - Message */
+const char * // O - Localized message
+_ppdLangString(cups_lang_t *lang, // I - Language
+ const char *message) // I - Message
{
- const char *s; /* Localized message */
+ const char *s; // Localized message
- DEBUG_printf(("_ppdLangString(lang=%p, message=\"%s\")", (void *)lang, message));
+ DEBUG_printf(("_ppdLangString(lang=%p, message=\"%s\")",
+ (void *)lang, message));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!lang || !message || !*message)
return (message);
_ppdMutexLock(&lang_mutex);
- /*
- * Load the message catalog if needed...
- */
+ //
+ // Load the message catalog if needed...
+ //
if (!lang->strings)
ppd_message_load(lang);
}
-/*
- * '_ppdMessageFree()' - Free a messages array.
- */
+//
+// '_ppdMessageFree()' - Free a messages array.
+//
void
-_ppdMessageFree(cups_array_t *a) /* I - Message array */
+_ppdMessageFree(cups_array_t *a) // I - Message array
{
#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
- /*
- * Release the cups.strings dictionary as needed...
- */
+ //
+ // Release the cups.strings dictionary as needed...
+ //
if (cupsArrayUserData(a))
CFRelease((CFDictionaryRef)cupsArrayUserData(a));
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
+#endif // __APPLE__ && CUPS_BUNDLEDIR
- /*
- * Free the array...
- */
+ //
+ // Free the array...
+ //
cupsArrayDelete(a);
}
-/*
- * '_ppdMessageLoad()' - Load a .po or .strings file into a messages array.
- */
+//
+// '_ppdMessageLoad()' - Load a .po or .strings file into a messages array.
+//
-cups_array_t * /* O - New message array */
-_ppdMessageLoad(const char *filename, /* I - Message catalog to load */
- int flags) /* I - Load flags */
+cups_array_t * // O - New message array
+_ppdMessageLoad(const char *filename, // I - Message catalog to load
+ int flags) // I - Load flags
{
- cups_file_t *fp; /* Message file */
- cups_array_t *a; /* Message array */
- _ppd_message_t *m; /* Current message */
- char s[4096], /* String buffer */
- *ptr, /* Pointer into buffer */
- *temp; /* New string */
- size_t length, /* Length of combined strings */
- ptrlen; /* Length of string */
+ cups_file_t *fp; // Message file
+ cups_array_t *a; // Message array
+ _ppd_message_t *m; // Current message
+ char s[4096], // String buffer
+ *ptr, // Pointer into buffer
+ *temp; // New string
+ size_t length, // Length of combined strings
+ ptrlen; // Length of string
DEBUG_printf(("4_ppdMessageLoad(filename=\"%s\")", filename));
- /*
- * Create an array to hold the messages...
- */
+ //
+ // Create an array to hold the messages...
+ //
if ((a = _ppdMessageNew(NULL)) == NULL)
{
return (NULL);
}
- /*
- * Open the message catalog file...
- */
+ //
+ // Open the message catalog file...
+ //
if ((fp = cupsFileOpen(filename, "r")) == NULL)
{
}
else
{
- /*
- * Read messages from the catalog file until EOF...
- *
- * The format is the GNU gettext .po format, which is fairly simple:
- *
- * msgid "some text"
- * msgstr "localized text"
- *
- * The ID and localized text can span multiple lines using the form:
- *
- * msgid ""
- * "some long text"
- * msgstr ""
- * "localized text spanning "
- * "multiple lines"
- */
+ //
+ // Read messages from the catalog file until EOF...
+ //
+ // The format is the GNU gettext .po format, which is fairly simple:
+ //
+ // msgid "some text"
+ // msgstr "localized text"
+ //
+ // The ID and localized text can span multiple lines using the form:
+ //
+ // msgid ""
+ // "some long text"
+ // msgstr ""
+ // "localized text spanning "
+ // "multiple lines"
+ //
m = NULL;
while (cupsFileGets(fp, s, sizeof(s)) != NULL)
{
- /*
- * Skip blank and comment lines...
- */
+ //
+ // Skip blank and comment lines...
+ //
if (s[0] == '#' || !s[0])
continue;
- /*
- * Strip the trailing quote...
- */
+ //
+ // Strip the trailing quote...
+ //
if ((ptr = strrchr(s, '\"')) == NULL)
continue;
*ptr = '\0';
- /*
- * Find start of value...
- */
+ //
+ // Find start of value...
+ //
if ((ptr = strchr(s, '\"')) == NULL)
continue;
ptr ++;
- /*
- * Unquote the text...
- */
+ //
+ // Unquote the text...
+ //
if (flags & _PPD_MESSAGE_UNQUOTE)
ppd_unquote(ptr, ptr);
- /*
- * Create or add to a message...
- */
+ //
+ // Create or add to a message...
+ //
if (!strncmp(s, "msgid", 5))
{
- /*
- * Add previous message as needed...
- */
+ //
+ // Add previous message as needed...
+ //
if (m)
{
if (m->str && (m->str[0] || (flags & _PPD_MESSAGE_EMPTY)))
- {
cupsArrayAdd(a, m);
- }
else
{
- /*
- * Translation is empty, don't add it... (STR #4033)
- */
+ //
+ // Translation is empty, don't add it... (STR #4033)
+ //
free(m->msg);
if (m->str)
}
}
- /*
- * Create a new message with the given msgid string...
- */
+ //
+ // Create a new message with the given msgid string...
+ //
if ((m = (_ppd_message_t *)calloc(1, sizeof(_ppd_message_t))) == NULL)
break;
}
else if (s[0] == '\"' && m)
{
- /*
- * Append to current string...
- */
+ //
+ // Append to current string...
+ //
length = strlen(m->str ? m->str : m->msg);
ptrlen = strlen(ptr);
- if ((temp = realloc(m->str ? m->str : m->msg, length + ptrlen + 1)) == NULL)
+ if ((temp = realloc(m->str ? m->str : m->msg,
+ length + ptrlen + 1)) == NULL)
{
if (m->str)
free(m->str);
if (m->str)
{
- /*
- * Copy the new portion to the end of the msgstr string - safe
- * to use memcpy because the buffer is allocated to the correct
- * size...
- */
+ //
+ // Copy the new portion to the end of the msgstr string - safe
+ // to use memcpy because the buffer is allocated to the correct
+ // size...
+ //
m->str = temp;
}
else
{
- /*
- * Copy the new portion to the end of the msgid string - safe
- * to use memcpy because the buffer is allocated to the correct
- * size...
- */
+ //
+ // Copy the new portion to the end of the msgid string - safe
+ // to use memcpy because the buffer is allocated to the correct
+ // size...
+ //
m->msg = temp;
}
else if (!strncmp(s, "msgstr", 6) && m)
{
- /*
- * Set the string...
- */
+ //
+ // Set the string...
+ //
if ((m->str = strdup(ptr)) == NULL)
{
}
}
- /*
- * Add the last message string to the array as needed...
- */
+ //
+ // Add the last message string to the array as needed...
+ //
if (m)
{
if (m->str && (m->str[0] || (flags & _PPD_MESSAGE_EMPTY)))
- {
cupsArrayAdd(a, m);
- }
else
{
- /*
- * Translation is empty, don't add it... (STR #4033)
- */
+ //
+ // Translation is empty, don't add it... (STR #4033)
+ //
free(m->msg);
if (m->str)
}
}
- /*
- * Close the message catalog file and return the new array...
- */
+ //
+ // Close the message catalog file and return the new array...
+ //
cupsFileClose(fp);
- DEBUG_printf(("5_ppdMessageLoad: Returning %d messages...", cupsArrayCount(a)));
+ DEBUG_printf(("5_ppdMessageLoad: Returning %d messages...",
+ cupsArrayCount(a)));
return (a);
}
-/*
- * '_ppdMessageLookup()' - Lookup a message string.
- */
+//
+// '_ppdMessageLookup()' - Lookup a message string.
+//
-const char * /* O - Localized message */
-_ppdMessageLookup(cups_array_t *a, /* I - Message array */
- const char *m) /* I - Message */
+const char * // O - Localized message
+_ppdMessageLookup(cups_array_t *a, // I - Message array
+ const char *m) // I - Message
{
- _ppd_message_t key, /* Search key */
- *match; /* Matching message */
+ _ppd_message_t key, // Search key
+ *match; // Matching message
DEBUG_printf(("_ppdMessageLookup(a=%p, m=\"%s\")", (void *)a, m));
- /*
- * Lookup the message string; if it doesn't exist in the catalog,
- * then return the message that was passed to us...
- */
+ //
+ // Lookup the message string; if it doesn't exist in the catalog,
+ // then return the message that was passed to us...
+ //
key.msg = (char *)m;
match = (_ppd_message_t *)cupsArrayFind(a, &key);
#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
if (!match && cupsArrayUserData(a))
{
- /*
- * Try looking the string up in the cups.strings dictionary...
- */
+ //
+ // Try looking the string up in the cups.strings dictionary...
+ //
- CFDictionaryRef dict; /* cups.strings dictionary */
- CFStringRef cfm, /* Message as a CF string */
- cfstr; /* Localized text as a CF string */
+ CFDictionaryRef dict; // cups.strings dictionary
+ CFStringRef cfm, // Message as a CF string
+ cfstr; // Localized text as a CF string
dict = (CFDictionaryRef)cupsArrayUserData(a);
- cfm = CFStringCreateWithCString(kCFAllocatorDefault, m, kCFStringEncodingUTF8);
+ cfm = CFStringCreateWithCString(kCFAllocatorDefault, m,
+ kCFStringEncodingUTF8);
match = calloc(1, sizeof(_ppd_message_t));
match->msg = strdup(m);
cfstr = cfm ? CFDictionaryGetValue(dict, cfm) : NULL;
if (cfstr)
{
- char buffer[1024]; /* Message buffer */
+ char buffer[1024]; // Message buffer
CFStringGetCString(cfstr, buffer, sizeof(buffer), kCFStringEncodingUTF8);
match->str = strdup(buffer);
- DEBUG_printf(("1_ppdMessageLookup: Found \"%s\" as \"%s\"...", m, buffer));
+ DEBUG_printf(("1_ppdMessageLookup: Found \"%s\" as \"%s\"...",
+ m, buffer));
}
else
{
if (cfm)
CFRelease(cfm);
}
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
+#endif // __APPLE__ && CUPS_BUNDLEDIR
if (match && match->str)
return (match->str);
}
-/*
- * '_ppdMessageNew()' - Make a new message catalog array.
- */
+//
+// '_ppdMessageNew()' - Make a new message catalog array.
+//
-cups_array_t * /* O - Array */
-_ppdMessageNew(void *context) /* I - User data */
+cups_array_t * // O - Array
+_ppdMessageNew(void *context) // I - User data
{
return (cupsArrayNew3((cups_array_func_t)ppd_message_compare, context,
(cups_ahash_func_t)NULL, 0,
}
-/*
- * 'ppd_message_compare()' - Compare two messages.
- */
+//
+// 'ppd_message_compare()' - Compare two messages.
+//
-static int /* O - Result of comparison */
+static int // O - Result of comparison
ppd_message_compare(
- _ppd_message_t *m1, /* I - First message */
- _ppd_message_t *m2) /* I - Second message */
+ _ppd_message_t *m1, // I - First message
+ _ppd_message_t *m2) // I - Second message
{
return (strcmp(m1->msg, m2->msg));
}
-/*
- * 'ppd_message_free()' - Free a message.
- */
+//
+// 'ppd_message_free()' - Free a message.
+//
static void
-ppd_message_free(_ppd_message_t *m) /* I - Message */
+ppd_message_free(_ppd_message_t *m) // I - Message
{
if (m->msg)
free(m->msg);
}
-/*
- * 'ppd_message_load()' - Load the message catalog for a language.
- */
+//
+// 'ppd_message_load()' - Load the message catalog for a language.
+//
static void
-ppd_message_load(cups_lang_t *lang) /* I - Language */
+ppd_message_load(cups_lang_t *lang) // I - Language
{
#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
lang->strings = appleMessageLoad(lang->language);
#else
- char filename[1024]; /* Filename for language locale file */
- char localedir[1003];/* Filename for language locale dir */
+ char filename[1024]; // Filename for language locale file
+ char localedir[1003];// Filename for language locale dir
char *p;
- /* Directory supplied by environment variable CUPS_LOCALEDIR */
+ // Directory supplied by environment variable CUPS_LOCALEDIR
if ((p = getenv("CUPS_LOCALEDIR")) != NULL)
strncpy (localedir, p, sizeof(localedir) - 1);
- else {
- /* Determine CUPS datadir (usually /usr/share/cups) */
+ else
+ {
+ // Determine CUPS datadir (usually /usr/share/cups)
if ((p = getenv("CUPS_DATADIR")) == NULL)
p = CUPS_DATADIR;
snprintf(localedir, sizeof(localedir), "%s/locale", p);
if (strchr(lang->language, '_') && access(filename, 0))
{
- /*
- * Country localization not available, look for generic localization...
- */
+ //
+ // Country localization not available, look for generic localization...
+ //
snprintf(filename, sizeof(filename), "%s/%.2s/cups_%.2s.po", localedir,
lang->language, lang->language);
if (access(filename, 0))
{
- /*
- * No generic localization, so use POSIX...
- */
+ //
+ // No generic localization, so use POSIX...
+ //
DEBUG_printf(("4ppd_message_load: access(\"%s\", 0): %s", filename,
strerror(errno)));
}
}
- /*
- * Read the strings from the file...
- */
+ //
+ // Read the strings from the file...
+ //
lang->strings = _ppdMessageLoad(filename, _PPD_MESSAGE_UNQUOTE);
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
+#endif // __APPLE__ && CUPS_BUNDLEDIR
}
-/*
- * 'ppd_read_strings()' - Read a pair of strings from a .strings file.
- */
+//
+// 'ppd_read_strings()' - Read a pair of strings from a .strings file.
+//
-static int /* O - 1 on success, 0 on failure */
-ppd_read_strings(cups_file_t *fp, /* I - .strings file */
- int flags, /* I - CUPS_MESSAGE_xxx flags */
- cups_array_t *a) /* I - Message catalog array */
+static int // O - 1 on success, 0 on failure
+ppd_read_strings(cups_file_t *fp, // I - .strings file
+ int flags, // I - CUPS_MESSAGE_xxx flags
+ cups_array_t *a) // I - Message catalog array
{
- char buffer[8192], /* Line buffer */
- *bufptr, /* Pointer into buffer */
- *msg, /* Pointer to start of message */
- *str; /* Pointer to start of translation string */
- _ppd_message_t *m; /* New message */
+ char buffer[8192], // Line buffer
+ *bufptr, // Pointer into buffer
+ *msg, // Pointer to start of message
+ *str; // Pointer to start of translation string
+ _ppd_message_t *m; // New message
while (cupsFileGets(fp, buffer, sizeof(buffer)))
{
- /*
- * Skip any line (comments, blanks, etc.) that isn't:
- *
- * "message" = "translation";
- */
+ //
+ // Skip any line (comments, blanks, etc.) that isn't:
+ //
+ // "message" = "translation";
+ //
for (bufptr = buffer; *bufptr && isspace(*bufptr & 255); bufptr ++);
if (*bufptr != '\"')
continue;
- /*
- * Find the end of the message...
- */
+ //
+ // Find the end of the message...
+ //
bufptr ++;
for (msg = bufptr; *bufptr && *bufptr != '\"'; bufptr ++)
if (flags & _PPD_MESSAGE_UNQUOTE)
ppd_unquote(msg, msg);
- /*
- * Find the start of the translation...
- */
+ //
+ // Find the start of the translation...
+ //
while (*bufptr && isspace(*bufptr & 255))
bufptr ++;
if (*bufptr != '\"')
continue;
- /*
- * Find the end of the translation...
- */
+ //
+ // Find the end of the translation...
+ //
bufptr ++;
for (str = bufptr; *bufptr && *bufptr != '\"'; bufptr ++)
if (flags & _PPD_MESSAGE_UNQUOTE)
ppd_unquote(str, str);
- /*
- * If we get this far we have a valid pair of strings, add them...
- */
+ //
+ // If we get this far we have a valid pair of strings, add them...
+ //
if ((m = malloc(sizeof(_ppd_message_t))) == NULL)
break;
m->str = strdup(str);
if (m->msg && m->str)
- {
cupsArrayAdd(a, m);
- }
else
{
if (m->msg)
return (1);
}
- /*
- * No more strings...
- */
+ //
+ // No more strings...
+ //
return (0);
}
-/*
- * 'ppd_unquote()' - Unquote characters in strings...
- */
+//
+// 'ppd_unquote()' - Unquote characters in strings...
+//
static void
-ppd_unquote(char *d, /* O - Unquoted string */
- const char *s) /* I - Original string */
+ppd_unquote(char *d, // O - Unquoted string
+ const char *s) // I - Original string
{
while (*s)
{
-/*
- * PDF-to-PostScript filter function for libppd.
- *
- * Copyright 2011-2020 by Till Kamppeter
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- *
- * Contents:
- *
- * parsePDFTOPDFComment() - Check whether we are executed after pdftopdf
- * remove_options() - Remove unwished entries from an option list
- * log_command_line() - Log the command line of a program which we call
- * ppdFilterPDFToPS() - pdftops filter function
- */
-
-/*
- * Include necessary headers...
- */
+//
+// PDF-to-PostScript filter function for libppd.
+//
+// Copyright 2011-2020 by Till Kamppeter
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+// Contents:
+//
+// parsePDFTOPDFComment() - Check whether we are executed after pdftopdf
+// remove_options() - Remove unwished entries from an option list
+// log_command_line() - Log the command line of a program which we call
+// ppdFilterPDFToPS() - pdftops filter function
+//
+
+//
+// Include necessary headers...
+//
#include <config.h>
#include <cups/cups.h>
#define MAX_CHECK_COMMENT_LINES 20
-/*
- * Type definitions
- */
+//
+// Type definitions
+//
typedef unsigned renderer_t;
-enum renderer_e {GS = 0, PDFTOPS = 1, ACROREAD = 2, PDFTOCAIRO = 3, MUPDF = 4,
- HYBRID = 5};
+enum renderer_e
+{
+ GS = 0,
+ PDFTOPS = 1,
+ ACROREAD = 2,
+ PDFTOCAIRO = 3,
+ MUPDF = 4,
+ HYBRID = 5
+};
-/*
- * When calling the "pstops" filter we exclude the following options from its
- * command line as we have applied these options already to the PDF input,
- * either on the "pdftops"/Ghostscript call in this filter or by use of the
- * "pdftopdf" filter before this filter.
- */
+//
+// When calling the "pstops" filter we exclude the following options from its
+// command line as we have applied these options already to the PDF input,
+// either on the "pdftops"/Ghostscript call in this filter or by use of the
+// "pdftopdf" filter before this filter.
+//
-const char *pstops_exclude_general[] = {
+const char *pstops_exclude_general[] =
+{
"crop-to-fit",
"fill",
"fitplot",
NULL
};
-const char *pstops_exclude_page_management[] = {
+const char *pstops_exclude_page_management[] =
+{
"brightness",
"Collate",
"even-duplex",
NULL
};
-
-/*
- * Check whether we were called after the "pdftopdf" filter and extract
- * parameters passed over by "pdftopdf" in the header comments of the PDF
- * file
- */
+//
+// Check whether we were called after the "pdftopdf" filter and extract
+// parameters passed over by "pdftopdf" in the header comments of the PDF
+// file
+//
static void
-parse_pdftopdf_comment(char *filename, /* I - Input file */
- int *pdftopdfapplied, /* O - Does the input
- data come from
- pdftopdf filter?*/
- char *deviceCopies, /* O - Number of copies
- (hardware) */
- int *deviceCollate, /* O - Hardware collate*/
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for
- log function */
+parse_pdftopdf_comment(char *filename, // I - Input file
+ int *pdftopdfapplied, // O - Does the input
+ // data come from
+ // pdftopdf filter?
+ char *deviceCopies, // O - Number of copies
+ // (hardware)
+ int *deviceCollate, // O - Hardware collate
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for
+ // log function
{
char buf[4096];
int i;
FILE *fp;
- if ((fp = fopen(filename,"rb")) == NULL) {
+ if ((fp = fopen(filename, "rb")) == NULL)
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterPDFToPS: Cannot open input file \"%s\"",
filename);
return;
}
- /* skip until PDF start header */
- while (fgets(buf,sizeof(buf),fp) != 0) {
- if (strncmp(buf,"%PDF",4) == 0) {
+ // skip until PDF start header
+ while (fgets(buf, sizeof(buf), fp) != 0)
+ {
+ if (strncmp(buf, "%PDF", 4) == 0)
break;
- }
}
- for (i = 0;i < MAX_CHECK_COMMENT_LINES;i++) {
- if (fgets(buf,sizeof(buf),fp) == 0) break;
- if (strncmp(buf,"%%PDFTOPDFNumCopies",19) == 0) {
+ for (i = 0; i < MAX_CHECK_COMMENT_LINES; i ++)
+ {
+ if (fgets(buf, sizeof(buf), fp) == 0)
+ break;
+ if (strncmp(buf, "%%PDFTOPDFNumCopies", 19) == 0)
+ {
char *p;
- p = strchr(buf+19,':') + 1;
- while (*p == ' ' || *p == '\t') p++;
+ p = strchr(buf + 19, ':') + 1;
+ while (*p == ' ' || *p == '\t')
+ p ++;
strncpy(deviceCopies, p, 31);
deviceCopies[31] = '\0';
p = deviceCopies + strlen(deviceCopies) - 1;
- while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') p--;
+ while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
+ p --;
*(p + 1) = '\0';
*pdftopdfapplied = 1;
- } else if (strncmp(buf,"%%PDFTOPDFCollate",17) == 0) {
+ }
+ else if (strncmp(buf, "%%PDFTOPDFCollate", 17) == 0)
+ {
char *p;
- p = strchr(buf+17,':') + 1;
- while (*p == ' ' || *p == '\t') p++;
- if (strncasecmp(p,"true",4) == 0) {
+ p = strchr(buf + 17, ':') + 1;
+ while (*p == ' ' || *p == '\t')
+ p ++;
+ if (strncasecmp(p, "true", 4) == 0)
*deviceCollate = 1;
- } else {
+ else
*deviceCollate = 0;
- }
- *pdftopdfapplied = 1;
- } else if (strcmp(buf,"% This file was generated by pdftopdf") == 0) {
*pdftopdfapplied = 1;
}
+ else if (strcmp(buf, "% This file was generated by pdftopdf") == 0)
+ *pdftopdfapplied = 1;
}
fclose(fp);
}
-/*
- * Check whether given file is empty
- */
+//
+// Check whether given file is empty
+//
-static int /* O - Result: 1: Empty; 0: Contains pages */
-is_empty(char *filename, /* I - Input file */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Auxiliary data for log function */
+static int // O - Result: 1: Empty; 0: Contains pages
+is_empty(char *filename, // I - Input file
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Auxiliary data for log function
{
FILE *fp = NULL;
fp = fopen(filename, "rb");
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterPDFToPS: Cannot open input file \"%s\"",
filename);
- return 1;
+ return (1);
}
else
{
char buf[1];
rewind(fp);
- if (fread(buf, 1, 1, fp) == 0) {
+ if (fread(buf, 1, 1, fp) == 0)
+ {
fclose(fp);
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPDFToPS: Input is empty, outputting empty file.");
- return 1;
+ return (1);
}
fclose(fp);
int pages = cfPDFPages(filename);
- if (pages == 0) {
+ if (pages == 0)
+ {
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPDFToPS: No pages left, outputting empty file.");
- return 1;
+ return (1);
}
if (pages > 0)
- return 0;
- return 1;
+ return (0);
+ return (1);
}
}
-/*
- * Before calling any command line utility, log its command line in CUPS'
- * debug mode
- */
+//
+// Before calling any command line utility, log its command line in CUPS'
+// debug mode
+//
void
-log_command_line(const char* file, /* I - Program to be executed */
- char *const argv[], /* I - Argument list */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Auxiliary data for log function */
+log_command_line(const char* file, // I - Program to be executed
+ char *const argv[], // I - Argument list
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Auxiliary data for log function
{
int i;
char *apos;
if (log == NULL)
return;
- /* Debug output: Full command line of program to be called */
- snprintf(buf, sizeof(buf) - 1, "ppdFilterPDFToPS: Running command line for %s:",
+ // Debug output: Full command line of program to be called
+ snprintf(buf, sizeof(buf) - 1,
+ "ppdFilterPDFToPS: Running command line for %s:",
(file ? file : argv[0]));
if (file)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf) - 1,
" %s", file);
- for (i = (file ? 1 : 0); argv[i]; i ++) {
+ for (i = (file ? 1 : 0); argv[i]; i ++)
+ {
if ((strchr(argv[i],' ')) || (strchr(argv[i],'\t')))
apos = "'";
else
}
-/*
- * 'ppdFilterPDFToPS()' - Filter function to convert PDF input into
- * PostScript to be printed on PostScript printers
- */
+//
+// 'ppdFilterPDFToPS()' - Filter function to convert PDF input into
+// PostScript to be printed on PostScript printers
+//
-int /* O - Error status */
-ppdFilterPDFToPS(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream */
- int inputseekable, /* I - Is input stream seekable? (unused) */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters) /* I - Filter-specific parameters (unused) */
+int // O - Error status
+ppdFilterPDFToPS(int inputfd, // I - File descriptor input stream
+ int outputfd, // I - File descriptor output stream
+ int inputseekable, // I - Is input stream seekable?
+ // (unused)
+ cf_filter_data_t *data,// I - Job and printer data
+ void *parameters) // I - Filter-specific parameters
+ // (unused)
{
ppd_filter_data_ext_t *filter_data_ext =
(ppd_filter_data_ext_t *)cfFilterDataGetExt(data,
PPD_FILTER_DATA_EXT);
- renderer_t renderer = CUPS_PDFTOPS_RENDERER; /* Renderer: gs or pdftops
- or acroread or pdftocairo
- or hybrid */
- FILE *inputfp; /* Input file pointer */
- int fd = 0; /* Copy file descriptor */
+ renderer_t renderer = CUPS_PDFTOPS_RENDERER; // Renderer: gs or pdftops
+ // or acroread or pdftocairo
+ // or hybrid
+ FILE *inputfp; // Input file pointer
+ int fd = 0; // Copy file descriptor
int i, j;
- int pdftopdfapplied = 0; /* Input data from pdftopdf filter? */
- char deviceCopies[32] = "1"; /* Hardware copies */
- int deviceCollate = 0; /* Hardware collate */
- char make_model[128] = ""; /* Printer make and model (for quirks)*/
- char *filename, /* PDF file to convert */
- tempfile[1024]; /* Temporary file */
- char buffer[8192]; /* Copy buffer */
- int bytes; /* Bytes copied */
- int num_options = 0, /* Number of options */
- num_pstops_options; /* Number of options for pstops */
- cups_option_t *options = NULL, /* Options */
- *pstops_options, /* Options for pstops filter function */
+ int pdftopdfapplied = 0; // Input data from pdftopdf filter?
+ char deviceCopies[32] = "1"; // Hardware copies
+ int deviceCollate = 0; // Hardware collate
+ char make_model[128] = ""; // Printer make and model (for quirks)
+ char *filename, // PDF file to convert
+ tempfile[1024]; // Temporary file
+ char buffer[8192]; // Copy buffer
+ int bytes; // Bytes copied
+ int num_options = 0, // Number of options
+ num_pstops_options; // Number of options for pstops
+ cups_option_t *options = NULL, // Options
+ *pstops_options, // Options for pstops filter function
*option;
const char *exclude;
cf_filter_data_t pstops_filter_data;
int ret;
- const char *val; /* Option value */
- ppd_file_t *ppd = NULL; /* PPD file */
- char resolution[128] = ""; /* Output resolution */
- int xres = 0, yres = 0, /* resolution values */
+ const char *val; // Option value
+ ppd_file_t *ppd = NULL; // PPD file
+ char resolution[128] = ""; // Output resolution
+ int xres = 0, yres = 0, // resolution values
mres, res,
maxres = CUPS_PDFTOPS_MAX_RESOLUTION,
- /* Maximum image rendering resolution */
- numvalues = 0; /* Number of values actually read */
+ // Maximum image rendering resolution
+ numvalues = 0; // Number of values actually read
ppd_choice_t *choice;
ppd_attr_t *attr;
cups_page_header2_t header;
- cups_file_t *fp; /* Post-processing input file */
- int pdf_pid, /* Process ID for pdftops/gs */
- pdf_argc = 0, /* Number of args for pdftops/gs */
- pstops_pid = 0, /* Process ID of pstops filter */
- pstops_pipe[2], /* Pipe to pstops filter */
- need_post_proc = 0, /* Post-processing needed? */
- post_proc_pid = 0, /* Process ID of post-processing */
- post_proc_pipe[2], /* Pipe to post-processing */
- wait_children, /* Number of child processes left */
- wait_pid, /* Process ID from wait() */
- wait_status, /* Status from child */
- exit_status = 0; /* Exit status */
- int gray_output = 0; /* Checking for monochrome/grayscale PostScript output */
- char *pdf_argv[100], /* Arguments for pdftops/gs */
- *ptr; /* Pointer into value */
- int duplex, tumble; /* Duplex settings for PPD-less
- printing */
+ cups_file_t *fp; // Post-processing input file
+ int pdf_pid, // Process ID for pdftops/gs
+ pdf_argc = 0, // Number of args for pdftops/gs
+ pstops_pid = 0, // Process ID of pstops filter
+ pstops_pipe[2], // Pipe to pstops filter
+ need_post_proc = 0, // Post-processing needed?
+ post_proc_pid = 0, // Process ID of post-processing
+ post_proc_pipe[2], // Pipe to post-processing
+ wait_children, // Number of child processes left
+ wait_pid, // Process ID from wait()
+ wait_status, // Status from child
+ exit_status = 0; // Exit status
+ int gray_output = 0; // Checking for monochrome/grayscale
+ // PostScript output
+ char *pdf_argv[100], // Arguments for pdftops/gs
+ *ptr; // Pointer into value
+ int duplex, tumble; // Duplex settings for PPD-less
+ // printing
cups_cspace_t cspace = (cups_cspace_t)(-1);
- cf_logfunc_t log = data->logfunc;
- void *ld = data->logdata;
+ cf_logfunc_t log = data->logfunc;
+ void *ld = data->logdata;
cf_filter_iscanceledfunc_t iscanceled = data->iscanceledfunc;
- void *icd = data->iscanceleddata;
- ipp_t *printer_attrs = data->printer_attrs;
- ipp_t *job_attrs = data->job_attrs;
+ void *icd = data->iscanceleddata;
+ ipp_t *printer_attrs = data->printer_attrs;
+ ipp_t *job_attrs = data->job_attrs;
ipp_attribute_t *ipp;
(void)inputseekable;
(void)parameters;
- /*
- * Ignore broken pipe signals...
- */
+ //
+ // Ignore broken pipe signals...
+ //
signal(SIGPIPE, SIG_IGN);
- /*
- * Open the input data stream specified by the inputfd...
- */
+ //
+ // Open the input data stream specified by the inputfd...
+ //
if ((inputfp = fdopen(inputfd, "r")) == NULL)
{
return (1);
}
- /*
- * Copy input into temporary file ...
- */
+ //
+ // Copy input into temporary file ...
+ //
if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
{
filename = tempfile;
- /*
- * Stop on empty or zero-pages files without error, perhaps we eliminated
- * all pages via the "page-ranges" option and a previous filter
- */
+ //
+ // Stop on empty or zero-pages files without error, perhaps we eliminated
+ // all pages via the "page-ranges" option and a previous filter
+ //
if (is_empty(filename, log, ld))
{
return 0;
}
- /*
- * Read out copy counts and collate setting passed over by pdftopdf
- */
+ //
+ // Read out copy counts and collate setting passed over by pdftopdf
+ //
parse_pdftopdf_comment(filename, &pdftopdfapplied, deviceCopies,
&deviceCollate, log, ld);
- /*
- * CUPS option list
- */
+ //
+ // CUPS option list
+ //
num_options = cfJoinJobOptionsAndAttrs(data, num_options, &options);
if (filter_data_ext)
ppd = filter_data_ext->ppd;
- /*
- * Process job options...
- */
+ //
+ // Process job options...
+ //
if ((val = cupsGetOption("make-and-model", num_options, options)) != NULL)
{
for (ptr = make_model; *ptr; ptr ++)
if (*ptr == '-') *ptr = ' ';
}
- else if(printer_attrs){
- if((ipp = ippFindAttribute(printer_attrs, "printer-make-and-model", IPP_TAG_ZERO))!=NULL){
+ else if(printer_attrs)
+ {
+ if ((ipp = ippFindAttribute(printer_attrs, "printer-make-and-model",
+ IPP_TAG_ZERO)) != NULL)
+ {
char make[56];
char* model;
ippAttributeString(ipp, make, sizeof(make));
if (!strncasecmp(make, "Hewlett Packard ", 16) ||
- !strncasecmp(make, "Hewlett-Packard ", 16)) {
- model = make + 16;
- strncpy(make, "HP", sizeof(make));
+ !strncasecmp(make, "Hewlett-Packard ", 16))
+ {
+ model = make + 16;
+ strncpy(make, "HP", sizeof(make));
}
else if ((model = strchr(make, ' ')) != NULL)
*model++ = '\0';
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPDFToPS: Printer make and model: %s", make_model);
- /*
- * Select the PDF renderer: Ghostscript (gs), Poppler (pdftops),
- * Adobe Reader (arcoread), Poppler with Cairo (pdftocairo), or
- * Hybrid (hybrid, Poppler for Brother, Minolta, Konica Minolta, Dell, and
- * old HP LaserJets and Ghostscript otherwise)
- */
+ //
+ // Select the PDF renderer: Ghostscript (gs), Poppler (pdftops),
+ // Adobe Reader (arcoread), Poppler with Cairo (pdftocairo), or
+ // Hybrid (hybrid, Poppler for Brother, Minolta, Konica Minolta, Dell, and
+ // old HP LaserJets and Ghostscript otherwise)
+ //
if ((val = cupsGetOption("pdftops-renderer", num_options, options)) != NULL)
{
}
else
renderer = GS;
- /*
- * Use Poppler instead of Ghostscript for old HP LaserJet printers due to
- * a bug in their PS interpreters. They are very slow with Ghostscript.
- * A LaserJet is considered old if its model number does not have a letter
- * in the beginning, like LaserJet 3 or LaserJet 4000, not LaserJet P2015.
- * See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742765
- */
+
+ //
+ // Use Poppler instead of Ghostscript for old HP LaserJet printers due to
+ // a bug in their PS interpreters. They are very slow with Ghostscript.
+ // A LaserJet is considered old if its model number does not have a letter
+ // in the beginning, like LaserJet 3 or LaserJet 4000, not LaserJet P2015.
+ // See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742765
+ //
+
if (make_model[0] &&
((!strncasecmp(make_model, "HP", 2) ||
!strncasecmp(make_model, "Hewlett-Packard", 15) ||
if (isspace(*ptr)) continue;
if (isdigit(*ptr))
{
- while (*ptr && isalnum(*ptr)) ptr ++;
- if (!*ptr) /* End of string, no further word */
+ while (*ptr && isalnum(*ptr))
+ ptr ++;
+ if (!*ptr) // End of string, no further word
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPDFToPS: Switching to Poppler's pdftops instead of "
}
}
- /*
- * Create option list for pstops filter function, stripping options which
- * "pstops" does not need to apply any more
- */
+ //
+ // Create option list for pstops filter function, stripping options which
+ // "pstops" does not need to apply any more
+ //
num_pstops_options = 0;
pstops_options = NULL;
for (i = num_options, option = options; i > 0; i --, option ++)
{
for (j = 0, exclude = pstops_exclude_general[j]; exclude;
- j++, exclude = pstops_exclude_general[j])
- if (!strcasecmp(option->name, exclude)) break;
- if (exclude) continue;
+ j ++, exclude = pstops_exclude_general[j])
+ if (!strcasecmp(option->name, exclude))
+ break;
+ if (exclude)
+ continue;
if (pdftopdfapplied)
{
for (j = 0, exclude = pstops_exclude_page_management[j]; exclude;
j++, exclude = pstops_exclude_page_management[j])
- if (!strcasecmp(option->name, exclude)) break;
- if (exclude) continue;
+ if (!strcasecmp(option->name, exclude))
+ break;
+ if (exclude)
+ continue;
}
num_pstops_options = cupsAddOption(option->name,
option->value,
if (pdftopdfapplied && deviceCollate)
{
- /*
- * Add collate option to the pstops call if pdftopdf has found out that the
- * printer does hardware collate.
- */
+ //
+ // Add collate option to the pstops call if pdftopdf has found out that the
+ // printer does hardware collate.
+ //
num_pstops_options = cupsAddOption("Collate",
"True",
num_pstops_options, &pstops_options);
}
- /*
- * Create data record to call the pstops filter function
- */
+ //
+ // Create data record to call the pstops filter function
+ //
pstops_filter_data.job_id = data->job_id;
pstops_filter_data.job_user = data->job_user;
pstops_filter_data.iscanceledfunc = iscanceled;
pstops_filter_data.iscanceleddata = icd;
- /*
- * Force monochrome/grayscale PostScript output
- * if job is to be printed in monochrome/grayscale
- */
- if (ppd && ppd->color_device == 0) /* Monochrome printer */
+ //
+ // Force monochrome/grayscale PostScript output
+ // if job is to be printed in monochrome/grayscale
+ //
+
+ if (ppd && ppd->color_device == 0) // Monochrome printer
gray_output = 1;
- else /*Color Printer - user option for Grayscale */
+ else //Color Printer - user option for Grayscale
{
if ((val = cupsGetOption("pwg-raster-document-type", num_options,
- options)) != NULL ||
- (val = cupsGetOption("PwgRasterDocumentType", num_options,
- options)) != NULL ||
- (val = cupsGetOption("print-color-mode", num_options,
- options)) != NULL ||
- (val = cupsGetOption("PrintColorMode", num_options,
- options)) != NULL ||
- (val = cupsGetOption("color-space", num_options,
- options)) != NULL ||
- (val = cupsGetOption("ColorSpace", num_options,
- options)) != NULL ||
- (val = cupsGetOption("color-model", num_options,
- options)) != NULL ||
- (val = cupsGetOption("ColorModel", num_options,
- options)) != NULL ||
- (val = cupsGetOption("output-mode", num_options,
- options)) != NULL ||
- (val = cupsGetOption("OutputMode", num_options,
- options)) != NULL)
+ options)) != NULL ||
+ (val = cupsGetOption("PwgRasterDocumentType", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("print-color-mode", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("PrintColorMode", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("color-space", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("ColorSpace", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("color-model", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("ColorModel", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("output-mode", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("OutputMode", num_options,
+ options)) != NULL)
+ {
+ if (strcasestr(val, "Black") ||
+ strcasestr(val, "Gray") ||
+ strcasestr(val, "Mono"))
+ gray_output = 1;
+ }
+ else
+ {
+ if(job_attrs != NULL)
{
- if (strcasestr(val, "Black") ||
- strcasestr(val, "Gray") ||
- strcasestr(val, "Mono"))
- gray_output = 1;
- }
- else{
- if(job_attrs!=NULL){
- if((ipp = ippFindAttribute(job_attrs, "pwg-raster-document-type", IPP_TAG_ZERO))!=NULL ||
- (ipp = ippFindAttribute(job_attrs, "color-space", IPP_TAG_ZERO))!=NULL ||
- (ipp = ippFindAttribute(job_attrs, "color-model", IPP_TAG_ZERO))!=NULL ||
- (ipp = ippFindAttribute(job_attrs, "print-color-mode", IPP_TAG_ZERO))!=NULL ||
- (ipp = ippFindAttribute(job_attrs, "output-mode", IPP_TAG_ZERO))){
- ippAttributeString(ipp, buffer, sizeof(buffer));
- val = buffer;
- if(strcasestr(val, "Black") ||
- (strcasestr(val, "Gray")) ||
- (strcasestr(val, "Mono")))
- gray_output = 1;
- }
- }
+ if ((ipp = ippFindAttribute(job_attrs, "pwg-raster-document-type",
+ IPP_TAG_ZERO)) != NULL ||
+ (ipp = ippFindAttribute(job_attrs, "color-space",
+ IPP_TAG_ZERO)) != NULL ||
+ (ipp = ippFindAttribute(job_attrs, "color-model",
+ IPP_TAG_ZERO)) != NULL ||
+ (ipp = ippFindAttribute(job_attrs, "print-color-mode",
+ IPP_TAG_ZERO)) != NULL ||
+ (ipp = ippFindAttribute(job_attrs, "output-mode",
+ IPP_TAG_ZERO)) != NULL)
+ {
+ ippAttributeString(ipp, buffer, sizeof(buffer));
+ val = buffer;
+ if(strcasestr(val, "Black") ||
+ (strcasestr(val, "Gray")) ||
+ (strcasestr(val, "Mono")))
+ gray_output = 1;
+ }
}
+ }
}
- /*
- * Build the command-line for the ppdFilterPDFToPS, gs, mutool, pdftocairo, or
- * acroread filter...
- */
+ //
+ // Build the command-line for the ppdFilterPDFToPS, gs, mutool, pdftocairo, or
+ // acroread filter...
+ //
if (renderer == PDFTOPS)
{
pdf_argv[7] = (char *)"-sDEVICE=ps2write";
# else
pdf_argv[7] = (char *)"-sDEVICE=pswrite";
-# endif /* HAVE_GHOSTSCRIPT_PS2WRITE */
+# endif // HAVE_GHOSTSCRIPT_PS2WRITE
pdf_argv[8] = (char *)"-dShowAcroForm";
pdf_argv[9] = (char *)"-sOUTPUTFILE=%stdout";
- if (gray_output == 1) /* Checking for monochrome/grayscale PostScript
- output */
+ if (gray_output == 1) // Checking for monochrome/grayscale PostScript
+ // output
{
pdf_argv[10] = (char *)"-sProcessColorModel=DeviceGray";
pdf_argv[11] = (char *)"-sColorConversionStrategy=Gray";
pdf_argv[3] = (char *)"-smtf";
pdf_argv[4] = (char *)"-Fps";
pdf_argv[5] = (char *)"-o-";
- if (gray_output == 1) /* Checking for monochrome/grayscale PostScript
- output */
+ if (gray_output == 1) // Checking for monochrome/grayscale PostScript
+ // output
pdf_argv[6] = (char *)"-cgray";
else
pdf_argv[6] = (char *)"-crgb";
pdf_argc = 2;
}
- /*
- * Set language level and TrueType font handling...
- */
+ //
+ // Set language level and TrueType font handling...
+ //
if (ppd)
{
}
else if (renderer == GS)
pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=2";
- else if (renderer != MUPDF) /* MuPDF is PS level 2 only */
- /* PDFTOCAIRO, ACROREAD */
+ else if (renderer != MUPDF) // MuPDF is PS level 2 only
+ // PDFTOCAIRO, ACROREAD
pdf_argv[pdf_argc++] = (char *)"-level2";
}
else
{
if (renderer == PDFTOPS)
{
- /* Do not emit PS Level 3 with Poppler on Brother and HP PostScript
- laser printers as some do not like it.
- See https://bugs.launchpad.net/bugs/277404 and
- https://bugs.launchpad.net/bugs/1306849 comment #42. */
+ // Do not emit PS Level 3 with Poppler on Brother and HP PostScript
+ // laser printers as some do not like it.
+ // See https://bugs.launchpad.net/bugs/277404 and
+ // https://bugs.launchpad.net/bugs/1306849 comment #42.
if (!make_model[0] ||
!strncasecmp(make_model, "Brother", 7) ||
((!strncasecmp(make_model, "HP", 2) ||
}
else if (renderer == GS)
{
- /* Do not emit PS Level 3 with Ghostscript on Brother PostScript
- laser printers as some do not like it.
- See https://bugs.launchpad.net/bugs/1306849 comment #42. */
+ // Do not emit PS Level 3 with Ghostscript on Brother PostScript
+ // laser printers as some do not like it.
+ // See https://bugs.launchpad.net/bugs/1306849 comment #42.
if (!make_model[0] ||
!strncasecmp(make_model, "Brother", 7))
pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=2";
if (log) log(ld, CF_LOGLEVEL_WARN,
"ppdFilterPDFToPS: Level 3 PostScript not supported by mutool.");
}
- else /* PDFTOCAIRO || ACROREAD */
+ else // PDFTOCAIRO || ACROREAD
pdf_argv[pdf_argc++] = (char *)"-level3";
}
}
{
if (renderer == PDFTOPS)
{
- /* Do not emit PS Level 3 with Poppler on HP PostScript laser printers
- as some do not like it. See https://bugs.launchpad.net/bugs/277404.*/
+ // Do not emit PS Level 3 with Poppler on HP PostScript laser printers
+ // as some do not like it. See https://bugs.launchpad.net/bugs/277404.
if (!make_model[0] ||
((!strncasecmp(make_model, "HP", 2) ||
!strncasecmp(make_model, "Hewlett-Packard", 15) ||
}
else if (renderer == GS)
pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=3";
- else if (renderer != MUPDF) /* MuPDF is PS level 2 only */
- /* PDFTOCAIRO || ACROREAD */
+ else if (renderer != MUPDF) // MuPDF is PS level 2 only
+ // PDFTOCAIRO || ACROREAD
pdf_argv[pdf_argc++] = (char *)"-level3";
}
#ifdef HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES
if ((renderer == PDFTOPS) || (renderer == PDFTOCAIRO))
{
- /*
- * Use the page sizes of the original PDF document, this way documents
- * which contain pages of different sizes can be printed correctly
- */
+ //
+ // Use the page sizes of the original PDF document, this way documents
+ // which contain pages of different sizes can be printed correctly
+ //
pdf_argv[pdf_argc++] = (char *)"-origpagesizes";
pdf_argv[pdf_argc++] = (char *)"-nocenter";
}
else
-#endif /* HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES */
+#endif // HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES
if (renderer == ACROREAD)
{
- /*
- * Use the page sizes of the original PDF document, this way documents
- * which contain pages of different sizes can be printed correctly
- */
+ //
+ // Use the page sizes of the original PDF document, this way documents
+ // which contain pages of different sizes can be printed correctly
+ //
pdf_argv[pdf_argc++] = (char *)"-choosePaperByPDFPageSize";
}
- /*
- * Set output resolution ...
- */
+ //
+ // Set output resolution ...
+ //
if (ppd)
{
- /* Ignore error exits of ppdRasterInterpretPPD(), if it found a resolution
- setting before erroring it is OK for us */
+ // Ignore error exits of ppdRasterInterpretPPD(), if it found a resolution
+ // setting before erroring it is OK for us
ppdRasterInterpretPPD(&header, ppd, num_options, options, NULL);
- /* 100 dpi is default, this means that if we have 100 dpi here this
- method failed to find the printing resolution */
+ // 100 dpi is default, this means that if we have 100 dpi here this
+ // method failed to find the printing resolution
resolution[0] = '\0';
if (header.HWResolution[0] != 100 || header.HWResolution[1] != 100)
{
"ppdFilterPDFToPS: No resolution information found in the PPD file.");
}
}
- else{
+ else
+ {
cfRasterPrepareHeader(&header, data, CF_FILTER_OUT_FORMAT_CUPS_RASTER,
CF_FILTER_OUT_FORMAT_CUPS_RASTER, 0, &cspace);
if (header.HWResolution[0] > 100 && header.HWResolution[1] > 100)
xres = header.HWResolution[0];
yres = header.HWResolution[1];
}
- else if((ipp = ippFindAttribute(printer_attrs, "printer-resolution-default", IPP_TAG_ZERO))!=NULL){
+ else if ((ipp = ippFindAttribute(printer_attrs,
+ "printer-resolution-default",
+ IPP_TAG_ZERO)) != NULL)
+ {
ippAttributeString(ipp, buffer, sizeof(buffer));
const char *p = buffer;
xres = atoi(p);
- if((p = strchr(p, 'x'))!=NULL){
- yres = atoi(p+1);
- }
- else yres = xres;
+ if ((p = strchr(p, 'x')) != NULL)
+ yres = atoi(p + 1);
+ else
+ yres = xres;
}
- else if((ipp = ippFindAttribute(printer_attrs, "printer-resolution-supported", IPP_TAG_ZERO))!=NULL){
+ else if ((ipp = ippFindAttribute(printer_attrs,
+ "printer-resolution-supported",
+ IPP_TAG_ZERO))!=NULL){
ippAttributeString(ipp, buffer, sizeof(buffer));
- for(i=0; buffer[i]!='\0';i++){
- if(buffer[i]==' ' ||
- buffer[i]==','){
- buffer[i]='\0';
- break;
- }
+ for (i = 0; buffer[i] != '\0'; i ++)
+ {
+ if(buffer[i] == ' ' ||
+ buffer[i] == ',')
+ {
+ buffer[i] = '\0';
+ break;
+ }
}
const char *p = buffer;
xres = atoi(p);
- if((p = strchr(p, 'x'))!=NULL){
- yres = atoi(p+1);
- }
- else yres = xres;
+ if((p = strchr(p, 'x')) != NULL)
+ yres = atoi(p + 1);
+ else
+ yres = xres;
}
}
if ((xres == 0) && (yres == 0))
{
if ((val = cupsGetOption("printer-resolution", num_options,
- options)) != NULL ||
+ options)) != NULL ||
(val = cupsGetOption("Resolution", num_options, options)) != NULL)
{
xres = yres = strtol(val, (char **)&ptr, 10);
else
res = 300;
- /*
- * Get the ceiling for the image rendering resolution
- */
+ //
+ // Get the ceiling for the image rendering resolution
+ //
if ((val = cupsGetOption("pdftops-max-image-resolution",
num_options, options)) != NULL)
val);
}
- /*
- * Reduce the image rendering resolution to not exceed a given maximum
- * to make processing of jobs by the PDF->PS converter and the printer faster
- *
- * maxres = 0 means no limit
- */
+ //
+ // Reduce the image rendering resolution to not exceed a given maximum
+ // to make processing of jobs by the PDF->PS converter and the printer faster
+ //
+ // maxres = 0 means no limit
+ //
if (maxres)
while (res > maxres)
if ((renderer == PDFTOPS) || (renderer == PDFTOCAIRO))
{
#ifdef HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION
- /*
- * Set resolution to avoid slow processing by the printer when the
- * resolution of embedded images does not match the printer's resolution
- */
+ //
+ // Set resolution to avoid slow processing by the printer when the
+ // resolution of embedded images does not match the printer's resolution
+ //
+
pdf_argv[pdf_argc++] = (char *)"-r";
snprintf(resolution, sizeof(resolution), "%d", res);
pdf_argv[pdf_argc++] = resolution;
if (log) log(ld, CF_LOGLEVEL_DEBUG,
- "ppdFilterPDFToPS: Using image rendering resolution %d dpi", res);
-#endif /* HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION */
- if (gray_output == 1) /* Checking for monochrome/grayscale PostScript
- output */
+ "ppdFilterPDFToPS: Using image rendering resolution %d dpi",
+ res);
+#endif // HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION
+ if (gray_output == 1) // Checking for monochrome/grayscale PostScript
+ // output
{
- /* Poppler does not explicitly support turning colored PDF files into
- grayscale PostScript. As a workaround, one could let the "pdftops"
- command line utility generate PostScript level 1 output which is
- always grayscale, but output files get huge and printing too
- slow.
- Recommended solution is to not use Poppler as PDF renderer for
- printing, especially if one uses a color PostScript printer and
- wants to have the possibility to print jobs also in grayscale.
- See the use of the "pdftops-renderer" option in the README file. */
- /* Example code for PostScript level1 workaround: */
- /* pdf_argv[1] = (char *)"-level1";
- pdf_argv[pdf_argc++] = (char *)"-optimizecolorspace"; */
- /* Issue a warning message when printing a grayscale job with Poppler */
+ //
+ // Poppler does not explicitly support turning colored PDF files into
+ // grayscale PostScript. As a workaround, one could let the "pdftops"
+ // command line utility generate PostScript level 1 output which is
+ // always grayscale, but output files get huge and printing too
+ // slow.
+ // Recommended solution is to not use Poppler as PDF renderer for
+ // printing, especially if one uses a color PostScript printer and
+ // wants to have the possibility to print jobs also in grayscale.
+ // See the use of the "pdftops-renderer" option in the README file.
+ // Example code for PostScript level1 workaround:
+ // pdf_argv[1] = (char *)"-level1";
+ // pdf_argv[pdf_argc++] = (char *)"-optimizecolorspace";
+ //
+
+ // Issue a warning message when printing a grayscale job with Poppler
if (log) log(ld, CF_LOGLEVEL_WARN,
"ppdFilterPDFToPS: Grayscale/monochrome printing requested for this "
"job but Poppler is not able to convert to "
}
else if (renderer == GS)
{
- /*
- * Set resolution to avoid slow processing by the printer when the
- * resolution of embedded images does not match the printer's resolution
- */
+ //
+ // Set resolution to avoid slow processing by the printer when the
+ // resolution of embedded images does not match the printer's resolution
+ //
+
snprintf(resolution, 127, "-r%d", res);
pdf_argv[pdf_argc++] = resolution;
if (log) log(ld, CF_LOGLEVEL_DEBUG,
- "ppdFilterPDFToPS: Using image rendering resolution %d dpi", res);
- /*
- * PostScript debug mode: If you send a job with "lpr -o psdebug" Ghostscript
- * will not compress the pages, so that the PostScript code can get
- * analysed. This is especially important if a PostScript printer errors or
- * misbehaves on Ghostscript's output.
- * On Kyocera and Utax (uses Kyocera hard- and software) printers we always
- * suppress page compression, to avoid slow processing of raster images.
- */
+ "ppdFilterPDFToPS: Using image rendering resolution %d dpi",
+ res);
+ //
+ // PostScript debug mode: If you send a job with "lpr -o psdebug"
+ // Ghostscript will not compress the pages, so that the PostScript
+ // code can get analysed. This is especially important if a
+ // PostScript printer errors or misbehaves on Ghostscript's
+ // output. On Kyocera and Utax (uses Kyocera hard- and software)
+ // printers we always suppress page compression, to avoid slow
+ // processing of raster images.
+ //
+
val = cupsGetOption("psdebug", num_options, options);
if ((val && strcasecmp(val, "no") && strcasecmp(val, "off") &&
strcasecmp(val, "false")) ||
"or Kyocera/Utax printer)");
pdf_argv[pdf_argc++] = (char *)"-dCompressPages=false";
}
- /*
- * The PostScript interpreters on many printers have bugs which make
- * the interpreter crash, error out, or otherwise misbehave on too
- * heavily compressed input files, especially if code with compressed
- * elements is compressed again. Therefore we reduce compression here.
- */
+
+ //
+ // The PostScript interpreters on many printers have bugs which make
+ // the interpreter crash, error out, or otherwise misbehave on too
+ // heavily compressed input files, especially if code with compressed
+ // elements is compressed again. Therefore we reduce compression here.
+ //
+
pdf_argv[pdf_argc++] = (char *)"-dCompressFonts=false";
pdf_argv[pdf_argc++] = (char *)"-dNoT3CCITT";
if (make_model[0] &&
pdf_argv[pdf_argc++] = (char *)"-dEncodeMonoImages=false";
pdf_argv[pdf_argc++] = (char *)"-dEncodeColorImages=false";
}
- /*
- * Toshiba's PS interpreters have an issue with how we handle
- * TrueType/Type42 fonts, therefore we add command line options to turn
- * the TTF outlines into bitmaps, usually Type 3 PostScript fonts, only
- * large glyphs into normal image data.
- * See https://bugs.launchpad.net/bugs/978120
- */
+
+ //
+ // Toshiba's PS interpreters have an issue with how we handle
+ // TrueType/Type42 fonts, therefore we add command line options to turn
+ // the TTF outlines into bitmaps, usually Type 3 PostScript fonts, only
+ // large glyphs into normal image data.
+ // See https://bugs.launchpad.net/bugs/978120
+ //
+
if (make_model[0] &&
!strncasecmp(make_model, "Toshiba", 7))
{
}
else if (renderer == MUPDF)
{
- /*
- * Add Resolution option to avoid slow processing by the printer when the
- * resolution of embedded images does not match the printer's resolution
- */
+ //
+ // Add Resolution option to avoid slow processing by the printer when the
+ // resolution of embedded images does not match the printer's resolution
+ //
+
snprintf(resolution, 127, "-r%dx%d", res, res);
pdf_argv[pdf_argc++] = resolution;
- /*
- * Add input file name
- */
+
+ //
+ // Add input file name
+ //
+
pdf_argv[pdf_argc++] = filename;
}
log_command_line(NULL, pdf_argv, log, ld);
- /*
- * Do we need post-processing of the PostScript output to work around bugs
- * of the printer's PostScript interpreter?
- */
+ //
+ // Do we need post-processing of the PostScript output to work around bugs
+ // of the printer's PostScript interpreter?
+ //
if ((renderer == PDFTOPS) || (renderer == PDFTOCAIRO) ||
(renderer == MUPDF))
else
need_post_proc = 1;
- /*
- * Do we need post-processing of the PostScript output to apply option
- * settings when doing PPD-less printing?
- */
+ //
+ // Do we need post-processing of the PostScript output to apply option
+ // settings when doing PPD-less printing?
+ //
if (!ppd)
need_post_proc = 1;
- /*
- * Execute "pdftops/gs/mutool [ | PS post-processing ] [ | pstops ]"...
- */
+ //
+ // Execute "pdftops/gs/mutool [ | PS post-processing ] [ | pstops ]"...
+ //
- /*
- * Create a pipe for each pair of subsequent processes. The variables
- * are named by the receiving process.
- */
+ //
+ // Create a pipe for each pair of subsequent processes. The variables
+ // are named by the receiving process.
+ //
if (ppd)
{
if ((pdf_pid = fork()) == 0)
{
- /*
- * Child comes here...
- */
+ //
+ // Child comes here...
+ //
if (need_post_proc)
{
}
else if (renderer == ACROREAD)
{
- /*
- * use filename as stdin for acroread to force output to stdout
- */
+ //
+ // use filename as stdin for acroread to force output to stdout
+ //
if ((fd = open(filename, O_RDONLY)))
{
}
else if (pdf_pid < 0)
{
- /*
- * Unable to fork!
- */
+ //
+ // Unable to fork!
+ //
if (log)
{
}
if (log) log(ld, CF_LOGLEVEL_DEBUG,
- "ppdFilterPDFToPS: Started filter %s (PID %d)", pdf_argv[0], pdf_pid);
+ "ppdFilterPDFToPS: Started filter %s (PID %d)",
+ pdf_argv[0], pdf_pid);
if (need_post_proc)
{
if ((post_proc_pid = fork()) == 0)
{
- /*
- * Child comes here...
- */
+ //
+ // Child comes here...
+ //
close(post_proc_pipe[1]);
if (ppd)
if (renderer == ACROREAD)
{
- /*
- * Set %Title and %For from filter arguments since acroread inserts
- * garbage for these when using -toPostScript
- */
+ //
+ // Set %Title and %For from filter arguments since acroread inserts
+ // garbage for these when using -toPostScript
+ //
while ((bytes = cupsFileGetLine(fp, buffer, sizeof(buffer))) > 0 &&
strncmp(buffer, "%%BeginProlog", 13))
printf("%s", buffer);
}
- /*
- * Copy the rest of the file
- */
+ //
+ // Copy the rest of the file
+ //
+
while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
fwrite(buffer, 1, bytes, stdout);
}
else
{
+ //
+ // Copy everything until after initial comments (Prolog section)
+ //
- /*
- * Copy everything until after initial comments (Prolog section)
- */
while ((bytes = cupsFileGetLine(fp, buffer, sizeof(buffer))) > 0 &&
strncmp(buffer, "%%BeginProlog", 13) &&
strncmp(buffer, "%%EndProlog", 11) &&
if (bytes > 0)
{
- /*
- * Insert PostScript interpreter bug fix code in the beginning of
- * the Prolog section (before the first active PostScript code)
- */
+ //
+ // Insert PostScript interpreter bug fix code in the beginning of
+ // the Prolog section (before the first active PostScript code)
+ //
+
if (strncmp(buffer, "%%BeginProlog", 13))
{
- /* No Prolog section, create one */
+ // No Prolog section, create one
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPDFToPS: Adding Prolog section for workaround "
"PostScript code");
if (renderer == GS && make_model[0])
{
-
- /*
- * Kyocera (and Utax) printers have a bug in their PostScript
- * interpreter making them crashing on PostScript input data
- * generated by Ghostscript's "ps2write" output device.
- *
- * The problem can be simply worked around by preceding the
- * PostScript code with some extra bits.
- *
- * See https://bugs.launchpad.net/bugs/951627
- *
- * In addition, at least some of Kyocera's PostScript printers are
- * very slow on rendering images which request interpolation. So we
- * also add some code to eliminate interpolation requests.
- *
- * See https://bugs.launchpad.net/bugs/1026974
- */
+ //
+ // Kyocera (and Utax) printers have a bug in their PostScript
+ // interpreter making them crashing on PostScript input data
+ // generated by Ghostscript's "ps2write" output device.
+ //
+ // The problem can be simply worked around by preceding the
+ // PostScript code with some extra bits.
+ //
+ // See https://bugs.launchpad.net/bugs/951627
+ //
+ // In addition, at least some of Kyocera's PostScript printers are
+ // very slow on rendering images which request interpolation. So we
+ // also add some code to eliminate interpolation requests.
+ //
+ // See https://bugs.launchpad.net/bugs/1026974
+ //
if (!strncasecmp(make_model, "Kyocera", 7) ||
!strncasecmp(make_model, "Utax", 4))
puts("% =====");
}
- /*
- * Brother printers have a bug in their PostScript interpreter
- * making them printing one blank page if PostScript input data
- * generated by Ghostscript's "ps2write" output device is used.
- *
- * The problem can be simply worked around by preceding the
- * PostScript code with some extra bits.
- *
- * See https://bugs.launchpad.net/bugs/950713
- */
+ //
+ // Brother printers have a bug in their PostScript interpreter
+ // making them printing one blank page if PostScript input data
+ // generated by Ghostscript's "ps2write" output device is used.
+ //
+ // The problem can be simply worked around by preceding the
+ // PostScript code with some extra bits.
+ //
+ // See https://bugs.launchpad.net/bugs/950713
+ //
else if (!strncasecmp(make_model, "Brother", 7))
{
if (strncmp(buffer, "%%BeginProlog", 13))
{
- /* Close newly created Prolog section */
+ // Close newly created Prolog section
if (strncmp(buffer, "%%EndProlog", 11))
puts("%%EndProlog");
printf("%s", buffer);
if (!ppd)
{
- /*
- * Copy everything until the setup section
- */
+ //
+ // Copy everything until the setup section
+ //
+
while (bytes > 0 &&
strncmp(buffer, "%%BeginSetup", 12) &&
strncmp(buffer, "%%EndSetup", 10) &&
if (bytes > 0)
{
- /*
- * Insert option PostScript code in Setup section
- */
+ //
+ // Insert option PostScript code in Setup section
+ //
+
if (strncmp(buffer, "%%BeginSetup", 12))
{
- /* No Setup section, create one */
+ // No Setup section, create one
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPDFToPS: Adding Setup section for option "
"PostScript code");
puts("%%BeginSetup");
}
- /*
- * Duplex
- */
+ //
+ // Duplex
+ //
+
duplex = 0;
tumble = 0;
if ((val = cupsGetOption("sides",
else
puts("<</Duplex false>> setpagedevice");
- /*
- * Resolution
- */
+ //
+ // Resolution
+ //
+
if ((xres > 0) && (yres > 0))
printf("<</HWResolution[%d %d]>> setpagedevice\n", xres, yres);
- /*
- * InputSlot/MediaSource
- */
+ //
+ // InputSlot/MediaSource
+ //
+
if ((val = cupsGetOption("media-position", num_options,
options)) != NULL ||
(val = cupsGetOption("MediaPosition", num_options,
puts("<</MediaPosition 1 /ManualFeed false>> setpagedevice");
}
- /*
- * ColorModel
- */
+ //
+ // ColorModel
+ //
+
if ((val = cupsGetOption("pwg-raster-document-type", num_options,
options)) != NULL ||
(val = cupsGetOption("PwgRasterDocumentType", num_options,
if (strncmp(buffer, "%%BeginSetup", 12))
{
- /* Close newly created Setup section */
+ // Close newly created Setup section
if (strncmp(buffer, "%%EndSetup", 10))
puts("%%EndSetup");
printf("%s", buffer);
}
}
- /*
- * Copy the rest of the file
- */
+ //
+ // Copy the rest of the file
+ //
+
while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
fwrite(buffer, 1, bytes, stdout);
}
}
else if (post_proc_pid < 0)
{
- /*
- * Unable to fork!
- */
+ //
+ // Unable to fork!
+ //
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterPDFToPS: Unable to execute post-processing process: %s",
}
if (log) log(ld, CF_LOGLEVEL_DEBUG,
- "ppdFilterPDFToPS: Started post-processing (PID %d)", post_proc_pid);
+ "ppdFilterPDFToPS: Started post-processing (PID %d)",
+ post_proc_pid);
}
if (ppd)
{
if ((pstops_pid = fork()) == 0)
{
- /*
- * Child comes here...
- */
+ //
+ // Child comes here...
+ //
close(pstops_pipe[1]);
if (need_post_proc)
close(post_proc_pipe[1]);
}
- ret = ppdFilterPSToPS(pstops_pipe[0], outputfd, 0, &pstops_filter_data, NULL);
+ ret = ppdFilterPSToPS(pstops_pipe[0], outputfd, 0, &pstops_filter_data,
+ NULL);
close(pstops_pipe[0]);
if (ret && log) log(ld, CF_LOGLEVEL_ERROR,
}
else if (pstops_pid < 0)
{
- /*
- * Unable to fork!
- */
+ //
+ // Unable to fork!
+ //
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterPDFToPS: Unable to execute pstops program: %s",
}
if (log) log(ld, CF_LOGLEVEL_DEBUG,
- "ppdFilterPDFToPS: Started filter pstops (PID %d)", pstops_pid);
+ "ppdFilterPDFToPS: Started filter pstops (PID %d)",
+ pstops_pid);
close(pstops_pipe[0]);
close(pstops_pipe[1]);
close(post_proc_pipe[1]);
}
- /*
- * Wait for the child processes to exit...
- */
+ //
+ // Wait for the child processes to exit...
+ //
wait_children = 1 + need_post_proc + (ppd ? 1 : 0);
while (wait_children > 0)
{
- /*
- * Wait until we get a valid process ID or the job is canceled...
- */
+ //
+ // Wait until we get a valid process ID or the job is canceled...
+ //
while ((wait_pid = wait(&wait_status)) < 0 && errno == EINTR)
{
wait_children --;
- /*
- * Report child status...
- */
+ //
+ // Report child status...
+ //
if (wait_status)
{
}
}
- /*
- * Cleanup and exit...
- */
+ //
+ // Cleanup and exit...
+ //
- error:
+ error:
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterPDFToPS: Closing files ...");
-/*
- * PPD model-specific attribute routines for libppd.
- *
- * Copyright 2007-2015 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// PPD model-specific attribute routines for libppd.
+//
+// Copyright 2007-2015 by Apple Inc.
+// Copyright 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "ppd.h"
#include "debug-internal.h"
-/*
- * 'ppdFindAttr()' - Find the first matching attribute.
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'ppdFindAttr()' - Find the first matching attribute.
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
-ppd_attr_t * /* O - Attribute or @code NULL@ if not found */
-ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */
- const char *name, /* I - Attribute name */
- const char *spec) /* I - Specifier string or @code NULL@ */
+ppd_attr_t * // O - Attribute or @code NULL@ if not
+ // found
+ppdFindAttr(ppd_file_t *ppd, // I - PPD file data
+ const char *name, // I - Attribute name
+ const char *spec) // I - Specifier string or @code NULL@
{
- ppd_attr_t key, /* Search key */
- *attr; /* Current attribute */
+ ppd_attr_t key, // Search key
+ *attr; // Current attribute
DEBUG_printf(("2ppdFindAttr(ppd=%p, name=\"%s\", spec=\"%s\")", ppd, name,
spec));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !name || ppd->num_attrs == 0)
return (NULL);
- /*
- * Search for a matching attribute...
- */
+ //
+ // Search for a matching attribute...
+ //
memset(&key, 0, sizeof(key));
strlcpy(key.name, name, sizeof(key.name));
- /*
- * Return the first matching attribute, if any...
- */
+ //
+ // Return the first matching attribute, if any...
+ //
if ((attr = (ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key)) != NULL)
{
if (spec)
{
- /*
- * Loop until we find the first matching attribute for "spec"...
- */
+ //
+ // Loop until we find the first matching attribute for "spec"...
+ //
while (attr && _ppd_strcasecmp(spec, attr->spec))
{
}
-/*
- * 'ppdFindNextAttr()' - Find the next matching attribute.
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'ppdFindNextAttr()' - Find the next matching attribute.
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
-ppd_attr_t * /* O - Attribute or @code NULL@ if not found */
-ppdFindNextAttr(ppd_file_t *ppd, /* I - PPD file data */
- const char *name, /* I - Attribute name */
- const char *spec) /* I - Specifier string or @code NULL@ */
+ppd_attr_t * // O - Attribute or @code NULL@ if not
+ // found
+ppdFindNextAttr(ppd_file_t *ppd, // I - PPD file data
+ const char *name, // I - Attribute name
+ const char *spec) // I - Specifier string or @code NULL@
{
- ppd_attr_t *attr; /* Current attribute */
+ ppd_attr_t *attr; // Current attribute
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !name || ppd->num_attrs == 0)
return (NULL);
- /*
- * See if there are more attributes to return...
- */
+ //
+ // See if there are more attributes to return...
+ //
while ((attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) != NULL)
{
- /*
- * Check the next attribute to see if it is a match...
- */
+ //
+ // Check the next attribute to see if it is a match...
+ //
if (_ppd_strcasecmp(attr->name, name))
{
- /*
- * Nope, reset the current pointer to the end of the array...
- */
+ //
+ // Nope, reset the current pointer to the end of the array...
+ //
cupsArrayIndex(ppd->sorted_attrs, cupsArrayCount(ppd->sorted_attrs));
break;
}
- /*
- * Return the next attribute's value...
- */
+ //
+ // Return the next attribute's value...
+ //
return (attr);
}
-/*
- * 'ppdNormalizeMakeAndModel()' - Normalize a product/make-and-model string.
- *
- * This function tries to undo the mistakes made by many printer manufacturers
- * to produce a clean make-and-model string we can use.
- */
+//
+// 'ppdNormalizeMakeAndModel()' - Normalize a product/make-and-model string.
+//
+// This function tries to undo the mistakes made by many printer manufacturers
+// to produce a clean make-and-model string we can use.
+//
-char * /* O - Normalized make-and-model string or NULL on error */
+char * // O - Normalized make-and-model string
+ // or NULL on error
ppdNormalizeMakeAndModel(
- const char *make_and_model, /* I - Original make-and-model string */
- char *buffer, /* I - String buffer */
- size_t bufsize) /* I - Size of string buffer */
+ const char *make_and_model, // I - Original make-and-model string
+ char *buffer, // I - String buffer
+ size_t bufsize) // I - Size of string buffer
{
- char *bufptr; /* Pointer into buffer */
+ char *bufptr; // Pointer into buffer
if (!make_and_model || !buffer || bufsize < 1)
return (NULL);
}
- /*
- * Skip leading whitespace...
- */
+ //
+ // Skip leading whitespace...
+ //
while (_ppd_isspace(*make_and_model))
make_and_model ++;
- /*
- * Remove parenthesis and add manufacturers as needed...
- */
+ //
+ // Remove parenthesis and add manufacturers as needed...
+ //
if (make_and_model[0] == '(')
{
}
else if (!_ppd_strncasecmp(make_and_model, "XPrint", 6))
{
- /*
- * Xerox XPrint...
- */
+ //
+ // Xerox XPrint...
+ //
snprintf(buffer, bufsize, "Xerox %s", make_and_model);
}
else if (!_ppd_strncasecmp(make_and_model, "Eastman", 7))
{
- /*
- * Kodak...
- */
+ //
+ // Kodak...
+ //
snprintf(buffer, bufsize, "Kodak %s", make_and_model + 7);
}
else if (!_ppd_strncasecmp(make_and_model, "laserwriter", 11))
{
- /*
- * Apple LaserWriter...
- */
+ //
+ // Apple LaserWriter...
+ //
snprintf(buffer, bufsize, "Apple LaserWriter%s", make_and_model + 11);
}
else if (!_ppd_strncasecmp(make_and_model, "colorpoint", 10))
{
- /*
- * Seiko...
- */
+ //
+ // Seiko...
+ //
snprintf(buffer, bufsize, "Seiko %s", make_and_model);
}
else if (!_ppd_strncasecmp(make_and_model, "fiery", 5))
{
- /*
- * EFI...
- */
+ //
+ // EFI...
+ //
snprintf(buffer, bufsize, "EFI %s", make_and_model);
}
else if (!_ppd_strncasecmp(make_and_model, "ps ", 3) ||
!_ppd_strncasecmp(make_and_model, "colorpass", 9))
{
- /*
- * Canon...
- */
+ //
+ // Canon...
+ //
snprintf(buffer, bufsize, "Canon %s", make_and_model);
}
else if (!_ppd_strncasecmp(make_and_model, "designjet", 9) ||
!_ppd_strncasecmp(make_and_model, "deskjet", 7))
{
- /*
- * HP...
- */
+ //
+ // HP...
+ //
snprintf(buffer, bufsize, "HP %s", make_and_model);
}
else
strlcpy(buffer, make_and_model, bufsize);
- /*
- * Clean up the make...
- */
+ //
+ // Clean up the make...
+ //
if (!_ppd_strncasecmp(buffer, "agfa", 4))
{
- /*
- * Replace with AGFA (all uppercase)...
- */
+ //
+ // Replace with AGFA (all uppercase)...
+ //
buffer[0] = 'A';
buffer[1] = 'G';
}
else if (!_ppd_strncasecmp(buffer, "Hewlett-Packard hp ", 19))
{
- /*
- * Just put "HP" on the front...
- */
+ //
+ // Just put "HP" on the front...
+ //
buffer[0] = 'H';
buffer[1] = 'P';
}
else if (!_ppd_strncasecmp(buffer, "Hewlett-Packard ", 16))
{
- /*
- * Just put "HP" on the front...
- */
+ //
+ // Just put "HP" on the front...
+ //
buffer[0] = 'H';
buffer[1] = 'P';
}
else if (!_ppd_strncasecmp(buffer, "Lexmark International", 21))
{
- /*
- * Strip "International"...
- */
+ //
+ // Strip "International"...
+ //
_ppd_strcpy(buffer + 8, buffer + 21);
}
else if (!_ppd_strncasecmp(buffer, "herk", 4))
{
- /*
- * Replace with LHAG...
- */
+ //
+ // Replace with LHAG...
+ //
buffer[0] = 'L';
buffer[1] = 'H';
}
else if (!_ppd_strncasecmp(buffer, "linotype", 8))
{
- /*
- * Replace with LHAG...
- */
+ //
+ // Replace with LHAG...
+ //
buffer[0] = 'L';
buffer[1] = 'H';
_ppd_strcpy(buffer + 4, buffer + 8);
}
- /*
- * Remove trailing whitespace and return...
- */
+ //
+ // Remove trailing whitespace and return...
+ //
for (bufptr = buffer + strlen(buffer) - 1;
bufptr >= buffer && _ppd_isspace(*bufptr);
-/*
- * PPD cache implementation for libppd.
- *
- * Copyright © 2010-2019 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// PPD cache implementation for libppd.
+//
+// Copyright © 2010-2019 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "array-private.h"
#include <errno.h>
-/*
- * Macro to test for two almost-equal PWG measurements.
- */
+//
+// Macro to test for two almost-equal PWG measurements.
+//
#define _PPD_PWG_EQUIVALENT(x, y) (abs((x)-(y)) < 2)
-/*
- * Macros to work around typos in older libcups version
- */
+//
+// Macros to work around typos in older libcups version
+//
#if (CUPS_VERSION_MAJOR < 2) || ((CUPS_VERSION_MAJOR == 2) && ((CUPS_VERSION_MINOR < 3) || ((CUPS_VERSION_MINOR == 3) && (CUPS_VERSION_PATCH < 1))))
#define IPP_FINISHINGS_CUPS_FOLD_ACCORDION IPP_FINISHINGS_CUPS_FOLD_ACCORDIAN
#endif
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static void ppd_pwg_add_finishing(cups_array_t *finishings, ipp_finishings_t template, const char *name, const char *value);
static void ppd_pwg_add_message(cups_array_t *a, const char *msg, const char *str);
static int ppd_pwg_compare_finishings(ppd_pwg_finishings_t *a, ppd_pwg_finishings_t *b);
static void ppd_pwg_free_finishings(ppd_pwg_finishings_t *f);
-char *ppd_cache_status_message = NULL; /* Last PPD cache error */
+char *ppd_cache_status_message = NULL; // Last PPD cache error
-/*
- * 'set_error()' - Set the last status-message of PPD cache functions.
- */
+//
+// 'set_error()' - Set the last status-message of PPD cache functions.
+//
-void
-set_error(const char *message, /* I - status-message value */
- int localize) /* I - Localize the message? */
+static void
+set_error(const char *message, // I - status-message value
+ int localize) // I - Localize the message?
{
if (!message && errno)
{
{
if (localize)
{
- /*
- * Get the message catalog...
- */
+ //
+ // Get the message catalog...
+ //
ppd_cache_status_message =
_ppdStrAlloc(_ppdLangString(cupsLangDefault(),
ppd_cache_status_message));
}
-/*
- * 'ppdConvertOptions()' - Convert printer options to standard IPP attributes.
- *
- * This functions converts PPD and CUPS-specific options to their standard IPP
- * attributes and values and adds them to the specified IPP request.
- */
+//
+// 'ppdConvertOptions()' - Convert printer options to standard IPP attributes.
+//
+// This functions converts PPD and CUPS-specific options to their standard IPP
+// attributes and values and adds them to the specified IPP request.
+//
-int /* O - New number of copies */
+int // O - New number of copies
ppdConvertOptions(
- ipp_t *request, /* I - IPP request */
- ppd_file_t *ppd, /* I - PPD file */
- ppd_cache_t *pc, /* I - PPD cache info */
- ipp_attribute_t *media_col_sup, /* I - media-col-supported values */
- ipp_attribute_t *doc_handling_sup, /* I - multiple-document-handling-supported values */
+ ipp_t *request, // I - IPP request
+ ppd_file_t *ppd, // I - PPD file
+ ppd_cache_t *pc, // I - PPD cache info
+ ipp_attribute_t *media_col_sup, // I - media-col-supported values
+ ipp_attribute_t *doc_handling_sup,
+ // I - multiple-document-handling-supported values
ipp_attribute_t *print_color_mode_sup,
- /* I - Printer supports print-color-mode */
- const char *user, /* I - User info */
- const char *format, /* I - document-format value */
- int copies, /* I - Number of copies */
- int num_options, /* I - Number of options */
- cups_option_t *options) /* I - Options */
+ // I - Printer supports print-color-mode
+ const char *user, // I - User info
+ const char *format, // I - document-format value
+ int copies, // I - Number of copies
+ int num_options, // I - Number of options
+ cups_option_t *options) // I - Options
{
- int i; /* Looping var */
- const char *keyword, /* PWG keyword */
- *password; /* Password string */
- pwg_size_t *size; /* PWG media size */
- ipp_t *media_col, /* media-col value */
- *media_size; /* media-size value */
- const char *media_source, /* media-source value */
- *media_type, /* media-type value */
- *collate_str, /* multiple-document-handling value */
- *color_attr_name, /* Supported color attribute */
- *mandatory, /* Mandatory attributes */
- *finishing_template; /* Finishing template */
- int num_finishings = 0, /* Number of finishing values */
- finishings[10]; /* Finishing enum values */
- ppd_choice_t *choice; /* Marked choice */
+ int i; // Looping var
+ const char *keyword, // PWG keyword
+ *password; // Password string
+ pwg_size_t *size; // PWG media size
+ ipp_t *media_col, // media-col value
+ *media_size; // media-size value
+ const char *media_source, // media-source value
+ *media_type, // media-type value
+ *collate_str, // multiple-document-handling value
+ *color_attr_name, // Supported color attribute
+ *mandatory, // Mandatory attributes
+ *finishing_template; // Finishing template
+ int num_finishings = 0, // Number of finishing values
+ finishings[10]; // Finishing enum values
+ ppd_choice_t *choice; // Marked choice
int finishings_copies = copies;
- /* Number of copies for finishings */
+ // Number of copies for finishings
- /*
- * Send standard IPP attributes...
- */
+ //
+ // Send standard IPP attributes...
+ //
- if (pc->password && (password = cupsGetOption("job-password", num_options, options)) != NULL && ippGetOperation(request) != IPP_OP_VALIDATE_JOB)
+ if (pc->password &&
+ (password = cupsGetOption("job-password",
+ num_options, options)) != NULL &&
+ ippGetOperation(request) != IPP_OP_VALIDATE_JOB)
{
- ipp_attribute_t *attr = NULL; /* job-password attribute */
+ ipp_attribute_t *attr = NULL; // job-password attribute
- if ((keyword = cupsGetOption("job-password-encryption", num_options, options)) == NULL)
+ if ((keyword = cupsGetOption("job-password-encryption", num_options,
+ options)) == NULL)
keyword = "none";
if (!strcmp(keyword, "none"))
{
- /*
- * Add plain-text job-password...
- */
+ //
+ // Add plain-text job-password...
+ //
- attr = ippAddOctetString(request, IPP_TAG_OPERATION, "job-password", password, (int)strlen(password));
+ attr = ippAddOctetString(request, IPP_TAG_OPERATION, "job-password",
+ password, (int)strlen(password));
}
else
{
- /*
- * Add hashed job-password...
- */
+ //
+ // Add hashed job-password...
+ //
- unsigned char hash[64]; /* Hash of password */
- ssize_t hashlen; /* Length of hash */
+ unsigned char hash[64]; // Hash of password
+ ssize_t hashlen; // Length of hash
- if ((hashlen = cupsHashData(keyword, password, strlen(password), hash, sizeof(hash))) > 0)
- attr = ippAddOctetString(request, IPP_TAG_OPERATION, "job-password", hash, (int)hashlen);
+ if ((hashlen = cupsHashData(keyword, password, strlen(password), hash,
+ sizeof(hash))) > 0)
+ attr = ippAddOctetString(request, IPP_TAG_OPERATION, "job-password",
+ hash, (int)hashlen);
}
if (attr)
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "job-password-encryption", NULL, keyword);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "job-password-encryption", NULL, keyword);
}
if (pc->account_id)
{
- if ((keyword = cupsGetOption("job-account-id", num_options, options)) == NULL)
+ if ((keyword = cupsGetOption("job-account-id",
+ num_options, options)) == NULL)
keyword = cupsGetOption("job-billing", num_options, options);
if (keyword)
- ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, "job-account-id", NULL, keyword);
+ ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, "job-account-id", NULL,
+ keyword);
}
if (pc->accounting_user_id)
{
- if ((keyword = cupsGetOption("job-accounting-user-id", num_options, options)) == NULL)
+ if ((keyword = cupsGetOption("job-accounting-user-id",
+ num_options, options)) == NULL)
keyword = user;
if (keyword)
- ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, "job-accounting-user-id", NULL, keyword);
+ ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME,
+ "job-accounting-user-id", NULL, keyword);
}
- for (mandatory = (const char *)cupsArrayFirst(pc->mandatory); mandatory; mandatory = (const char *)cupsArrayNext(pc->mandatory))
+ for (mandatory = (const char *)cupsArrayFirst(pc->mandatory); mandatory;
+ mandatory = (const char *)cupsArrayNext(pc->mandatory))
{
if (strcmp(mandatory, "copies") &&
strcmp(mandatory, "destination-uris") &&
(keyword = cupsGetOption(mandatory, num_options, options)) != NULL)
{
_ppd_ipp_option_t *opt = _ppdIppFindOption(mandatory);
- /* Option type */
+ // Option type
ipp_tag_t value_tag = opt ? opt->value_tag : IPP_TAG_NAME;
- /* Value type */
+ // Value type
switch (value_tag)
{
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- ippAddInteger(request, IPP_TAG_JOB, value_tag, mandatory, atoi(keyword));
+ ippAddInteger(request, IPP_TAG_JOB, value_tag, mandatory,
+ atoi(keyword));
break;
case IPP_TAG_BOOLEAN :
- ippAddBoolean(request, IPP_TAG_JOB, mandatory, !_ppd_strcasecmp(keyword, "true"));
+ ippAddBoolean(request, IPP_TAG_JOB, mandatory,
+ !_ppd_strcasecmp(keyword, "true"));
break;
case IPP_TAG_RANGE :
{
- int lower, upper; /* Range */
+ int lower, upper; // Range
if (sscanf(keyword, "%d-%d", &lower, &upper) != 2)
lower = upper = atoi(keyword);
}
break;
case IPP_TAG_STRING :
- ippAddOctetString(request, IPP_TAG_JOB, mandatory, keyword, (int)strlen(keyword));
+ ippAddOctetString(request, IPP_TAG_JOB, mandatory, keyword,
+ (int)strlen(keyword));
break;
default :
- if (!strcmp(mandatory, "print-color-mode") && !strcmp(keyword, "monochrome"))
+ if (!strcmp(mandatory, "print-color-mode") &&
+ !strcmp(keyword, "monochrome"))
{
if (ippContainsString(print_color_mode_sup, "auto-monochrome"))
keyword = "auto-monochrome";
- else if (ippContainsString(print_color_mode_sup, "process-monochrome") && !ippContainsString(print_color_mode_sup, "monochrome"))
+ else if (ippContainsString(print_color_mode_sup,
+ "process-monochrome") &&
+ !ippContainsString(print_color_mode_sup, "monochrome"))
keyword = "process-monochrome";
}
- ippAddString(request, IPP_TAG_JOB, value_tag, mandatory, NULL, keyword);
+ ippAddString(request, IPP_TAG_JOB, value_tag, mandatory, NULL,
+ keyword);
break;
}
}
if ((keyword = cupsGetOption("PageSize", num_options, options)) == NULL)
keyword = cupsGetOption("media", num_options, options);
- media_source = ppdCacheGetSource(pc, cupsGetOption("InputSlot", num_options, options));
- media_type = ppdCacheGetType(pc, cupsGetOption("MediaType", num_options, options));
+ media_source = ppdCacheGetSource(pc, cupsGetOption("InputSlot", num_options,
+ options));
+ media_type = ppdCacheGetType(pc, cupsGetOption("MediaType", num_options,
+ options));
size = ppdCacheGetSize(pc, keyword);
if (size || media_source || media_type)
{
- /*
- * Add a media-col value...
- */
+ //
+ // Add a media-col value...
+ //
media_col = ippNew();
}
if (keyword)
- ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-bin", NULL, keyword);
+ ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-bin", NULL,
+ keyword);
color_attr_name = print_color_mode_sup ? "print-color-mode" : "output-mode";
- if ((keyword = cupsGetOption("print-color-mode", num_options, options)) == NULL)
+ if ((keyword = cupsGetOption("print-color-mode",
+ num_options, options)) == NULL)
{
if ((choice = ppdFindMarkedChoice(ppd, "ColorModel")) != NULL)
{
{
if (ippContainsString(print_color_mode_sup, "auto-monochrome"))
keyword = "auto-monochrome";
- else if (ippContainsString(print_color_mode_sup, "process-monochrome") && !ippContainsString(print_color_mode_sup, "monochrome"))
+ else if (ippContainsString(print_color_mode_sup, "process-monochrome") &&
+ !ippContainsString(print_color_mode_sup, "monochrome"))
keyword = "process-monochrome";
}
if (keyword)
- ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, color_attr_name, NULL, keyword);
+ ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, color_attr_name, NULL,
+ keyword);
if ((keyword = cupsGetOption("print-quality", num_options, options)) != NULL)
- ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", atoi(keyword));
+ ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality",
+ atoi(keyword));
else if ((choice = ppdFindMarkedChoice(ppd, "cupsPrintQuality")) != NULL)
{
if (!_ppd_strcasecmp(choice->choice, "draft"))
- ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", IPP_QUALITY_DRAFT);
+ ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality",
+ IPP_QUALITY_DRAFT);
else if (!_ppd_strcasecmp(choice->choice, "normal"))
- ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", IPP_QUALITY_NORMAL);
+ ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality",
+ IPP_QUALITY_NORMAL);
else if (!_ppd_strcasecmp(choice->choice, "high"))
- ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", IPP_QUALITY_HIGH);
+ ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality",
+ IPP_QUALITY_HIGH);
}
if ((keyword = cupsGetOption("sides", num_options, options)) != NULL)
ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, keyword);
- else if (pc->sides_option && (choice = ppdFindMarkedChoice(ppd, pc->sides_option)) != NULL)
+ else if (pc->sides_option &&
+ (choice = ppdFindMarkedChoice(ppd, pc->sides_option)) != NULL)
{
if (pc->sides_1sided && !_ppd_strcasecmp(choice->choice, pc->sides_1sided))
- ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "one-sided");
- else if (pc->sides_2sided_long && !_ppd_strcasecmp(choice->choice, pc->sides_2sided_long))
- ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "two-sided-long-edge");
- else if (pc->sides_2sided_short && !_ppd_strcasecmp(choice->choice, pc->sides_2sided_short))
- ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "two-sided-short-edge");
+ ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL,
+ "one-sided");
+ else if (pc->sides_2sided_long &&
+ !_ppd_strcasecmp(choice->choice, pc->sides_2sided_long))
+ ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL,
+ "two-sided-long-edge");
+ else if (pc->sides_2sided_short &&
+ !_ppd_strcasecmp(choice->choice, pc->sides_2sided_short))
+ ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL,
+ "two-sided-short-edge");
}
- /*
- * Copies...
- */
+ //
+ // Copies...
+ //
- if ((keyword = cupsGetOption("multiple-document-handling", num_options, options)) != NULL)
+ if ((keyword = cupsGetOption("multiple-document-handling",
+ num_options, options)) != NULL)
{
if (strstr(keyword, "uncollated"))
keyword = "false";
!_ppd_strcasecmp(format, "image/tiff") ||
!_ppd_strncasecmp(format, "image/x-", 8))
{
- /*
- * Collation makes no sense for single page image formats...
- */
+ //
+ // Collation makes no sense for single page image formats...
+ //
keyword = "false";
}
else if (!_ppd_strncasecmp(format, "image/", 6) ||
!_ppd_strcasecmp(format, "application/vnd.cups-raster"))
{
- /*
- * Multi-page image formats will have copies applied by the upstream
- * filters...
- */
+ //
+ // Multi-page image formats will have copies applied by the upstream
+ // filters...
+ //
copies = 1;
}
copies = 1;
}
- /*
- * Map finishing options...
- */
+ //
+ // Map finishing options...
+ //
- if ((finishing_template = cupsGetOption("cupsFinishingTemplate", num_options, options)) == NULL)
- finishing_template = cupsGetOption("finishing-template", num_options, options);
+ if ((finishing_template = cupsGetOption("cupsFinishingTemplate",
+ num_options, options)) == NULL)
+ finishing_template = cupsGetOption("finishing-template",
+ num_options, options);
if (finishing_template && strcmp(finishing_template, "none"))
{
- ipp_t *fin_col = ippNew(); /* finishings-col value */
+ ipp_t *fin_col = ippNew(); // finishings-col value
- ippAddString(fin_col, IPP_TAG_JOB, IPP_TAG_KEYWORD, "finishing-template", NULL, finishing_template);
+ ippAddString(fin_col, IPP_TAG_JOB, IPP_TAG_KEYWORD, "finishing-template",
+ NULL, finishing_template);
ippAddCollection(request, IPP_TAG_JOB, "finishings-col", fin_col);
ippDelete(fin_col);
- if (copies != finishings_copies && (keyword = cupsGetOption("job-impressions", num_options, options)) != NULL)
+ if (copies != finishings_copies &&
+ (keyword = cupsGetOption("job-impressions",
+ num_options, options)) != NULL)
{
- /*
- * Send job-pages-per-set attribute to apply finishings correctly...
- */
+ //
+ // Send job-pages-per-set attribute to apply finishings correctly...
+ //
- ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", atoi(keyword) / finishings_copies);
+ ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set",
+ atoi(keyword) / finishings_copies);
}
}
else
{
- num_finishings = ppdCacheGetFinishingValues(ppd, pc, (int)(sizeof(finishings) / sizeof(finishings[0])), finishings);
+ num_finishings =
+ ppdCacheGetFinishingValues(ppd, pc,
+ (int)(sizeof(finishings) /
+ sizeof(finishings[0])), finishings);
if (num_finishings > 0)
{
- ippAddIntegers(request, IPP_TAG_JOB, IPP_TAG_ENUM, "finishings", num_finishings, finishings);
+ ippAddIntegers(request, IPP_TAG_JOB, IPP_TAG_ENUM, "finishings",
+ num_finishings, finishings);
- if (copies != finishings_copies && (keyword = cupsGetOption("job-impressions", num_options, options)) != NULL)
+ if (copies != finishings_copies &&
+ (keyword = cupsGetOption("job-impressions",
+ num_options, options)) != NULL)
{
- /*
- * Send job-pages-per-set attribute to apply finishings correctly...
- */
+ //
+ // Send job-pages-per-set attribute to apply finishings correctly...
+ //
- ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", atoi(keyword) / finishings_copies);
+ ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER,
+ "job-pages-per-set", atoi(keyword) / finishings_copies);
}
}
}
}
-/*
- * 'ppdCacheCreateWithFile()' - Create PPD cache and mapping data from a
- * written file.
- *
- * Use the @link ppdCacheWriteFile@ function to write PWG mapping data to a
- * file.
- */
+//
+// 'ppdCacheCreateWithFile()' - Create PPD cache and mapping data from a
+// written file.
+//
+// Use the @link ppdCacheWriteFile@ function to write PWG mapping data to a
+// file.
+//
-ppd_cache_t * /* O - PPD cache and mapping data */
+ppd_cache_t * // O - PPD cache and mapping data
ppdCacheCreateWithFile(
- const char *filename, /* I - File to read */
- ipp_t **attrs) /* IO - IPP attributes, if any */
+ const char *filename, // I - File to read
+ ipp_t **attrs) // IO - IPP attributes, if any
{
- cups_file_t *fp; /* File */
- ppd_cache_t *pc; /* PWG mapping data */
- pwg_size_t *size; /* Current size */
- pwg_map_t *map; /* Current map */
- ppd_pwg_finishings_t *finishings; /* Current finishings option */
- int linenum, /* Current line number */
- num_bins, /* Number of bins in file */
- num_sizes, /* Number of sizes in file */
- num_sources, /* Number of sources in file */
- num_types; /* Number of types in file */
- char line[2048], /* Current line */
- *value, /* Pointer to value in line */
- *valueptr, /* Pointer into value */
- pwg_keyword[128], /* PWG keyword */
+ cups_file_t *fp; // File
+ ppd_cache_t *pc; // PWG mapping data
+ pwg_size_t *size; // Current size
+ pwg_map_t *map; // Current map
+ ppd_pwg_finishings_t *finishings; // Current finishings option
+ int linenum, // Current line number
+ num_bins, // Number of bins in file
+ num_sizes, // Number of sizes in file
+ num_sources, // Number of sources in file
+ num_types; // Number of types in file
+ char line[2048], // Current line
+ *value, // Pointer to value in line
+ *valueptr, // Pointer into value
+ pwg_keyword[128], // PWG keyword
ppd_keyword[PPD_MAX_NAME];
- /* PPD keyword */
+ // PPD keyword
ppd_pwg_print_color_mode_t print_color_mode;
- /* Print color mode for preset */
- ppd_pwg_print_quality_t print_quality;/* Print quality for preset */
+ // Print color mode for preset
+ ppd_pwg_print_quality_t print_quality;// Print quality for preset
ppd_pwg_print_content_optimize_t print_content_optimize;
- /* Content optimize for preset */
+ // Content optimize for preset
DEBUG_printf(("ppdCacheCreateWithFile(filename=\"%s\")", filename));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (attrs)
*attrs = NULL;
return (NULL);
}
- /*
- * Open the file...
- */
+ //
+ // Open the file...
+ //
if ((fp = cupsFileOpen(filename, "r")) == NULL)
{
return (NULL);
}
- /*
- * Read the first line and make sure it has "#CUPS-PPD-CACHE-version" in it...
- */
+ //
+ // Read the first line and make sure it has "#CUPS-PPD-CACHE-version" in it...
+ //
if (!cupsFileGets(fp, line, sizeof(line)))
{
return (NULL);
}
- /*
- * Allocate the mapping data structure...
- */
+ //
+ // Allocate the mapping data structure...
+ //
if ((pc = calloc(1, sizeof(ppd_cache_t))) == NULL)
{
pc->max_copies = 9999;
- /*
- * Read the file...
- */
+ //
+ // Read the file...
+ //
linenum = 0;
num_bins = 0;
else if (!_ppd_strcasecmp(line, "Filter"))
{
if (!pc->filters)
- pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
cupsArrayAdd(pc->filters, value);
}
else if (!_ppd_strcasecmp(line, "PreFilter"))
{
if (!pc->prefilters)
- pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
cupsArrayAdd(pc->prefilters, value);
}
}
else if (!_ppd_strcasecmp(line, "IPP"))
{
- off_t pos = cupsFileTell(fp), /* Position in file */
+ off_t pos = cupsFileTell(fp), // Position in file
length = strtol(value, NULL, 10);
- /* Length of IPP attributes */
+ // Length of IPP attributes
if (attrs && *attrs)
{
if (attrs)
{
- /*
- * Read IPP attributes into the provided variable...
- */
+ //
+ // Read IPP attributes into the provided variable...
+ //
*attrs = ippNew();
}
else
{
- /*
- * Skip the IPP data entirely...
- */
+ //
+ // Skip the IPP data entirely...
+ //
cupsFileSeek(fp, pos + length);
}
goto create_error;
}
- if ((pc->sources = calloc((size_t)num_sources, sizeof(pwg_map_t))) == NULL)
+ if ((pc->sources = calloc((size_t)num_sources,
+ sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("ppdCacheCreateWithFile: Unable to allocate %d sources.",
num_sources));
}
else if (!_ppd_strcasecmp(line, "Preset"))
{
- /*
- * Preset output-mode print-quality name=value ...
- */
+ //
+ // Preset output-mode print-quality name=value ...
+ //
- print_color_mode = (ppd_pwg_print_color_mode_t)strtol(value, &valueptr, 10);
- print_quality = (ppd_pwg_print_quality_t)strtol(valueptr, &valueptr, 10);
+ print_color_mode =
+ (ppd_pwg_print_color_mode_t)strtol(value, &valueptr, 10);
+ print_quality =
+ (ppd_pwg_print_quality_t)strtol(valueptr, &valueptr, 10);
if (print_color_mode < PPD_PWG_PRINT_COLOR_MODE_MONOCHROME ||
print_color_mode >= PPD_PWG_PRINT_COLOR_MODE_MAX ||
}
else if (!_ppd_strcasecmp(line, "OptimizePreset"))
{
- /*
- * Preset print_content_optimize name=value ...
- */
+ //
+ // Preset print_content_optimize name=value ...
+ //
- print_content_optimize = (ppd_pwg_print_content_optimize_t)strtol(value, &valueptr, 10);
+ print_content_optimize =
+ (ppd_pwg_print_content_optimize_t)strtol(value, &valueptr, 10);
if (print_content_optimize < PPD_PWG_PRINT_CONTENT_OPTIMIZE_AUTO ||
print_content_optimize >= PPD_PWG_PRINT_CONTENT_OPTIMIZE_MAX ||
else if (!_ppd_strcasecmp(line, "FinishingTemplate"))
{
if (!pc->templates)
- pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
cupsArrayAdd(pc->templates, value);
}
else if (!_ppd_strcasecmp(line, "SupportFile"))
{
if (!pc->support_files)
- pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
cupsArrayAdd(pc->support_files, value);
}
return (pc);
- /*
- * If we get here the file was bad - free any data and return...
- */
+ //
+ // If we get here the file was bad - free any data and return...
+ //
create_error:
}
-/*
- * 'ppdCacheCreateWithPPD()' - Create PWG mapping data from a PPD file.
- */
+//
+// 'ppdCacheCreateWithPPD()' - Create PWG mapping data from a PPD file.
+//
-ppd_cache_t * /* O - PPD cache and mapping data */
-ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
+ppd_cache_t * // O - PPD cache and mapping data
+ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file
{
- int i, j, k; /* Looping vars */
- ppd_cache_t *pc; /* PWG mapping data */
- ppd_option_t *input_slot, /* InputSlot option */
- *media_type, /* MediaType option */
- *output_bin, /* OutputBin option */
- *color_model, /* ColorModel option */
- *duplex, /* Duplex option */
- *ppd_option; /* Other PPD option */
- ppd_choice_t *choice; /* Current InputSlot/MediaType */
- pwg_map_t *map; /* Current source/type map */
- int preset_added = 0; /* Preset definition found in PPD? */
- ppd_attr_t *ppd_attr; /* Current PPD preset attribute */
- int num_options; /* Number of preset options and props */
- cups_option_t *options; /* Preset options and properties */
- ppd_size_t *ppd_size; /* Current PPD size */
- pwg_size_t *pwg_size; /* Current PWG size */
+ int i, j, k; // Looping vars
+ ppd_cache_t *pc; // PWG mapping data
+ ppd_option_t *input_slot, // InputSlot option
+ *media_type, // MediaType option
+ *output_bin, // OutputBin option
+ *color_model, // ColorModel option
+ *duplex, // Duplex option
+ *ppd_option; // Other PPD option
+ ppd_choice_t *choice; // Current InputSlot/MediaType
+ pwg_map_t *map; // Current source/type map
+ int preset_added = 0; // Preset definition found in PPD?
+ ppd_attr_t *ppd_attr; // Current PPD preset attribute
+ int num_options; // Number of preset options and props
+ cups_option_t *options; // Preset options and properties
+ ppd_size_t *ppd_size; // Current PPD size
+ pwg_size_t *pwg_size; // Current PWG size
char pwg_keyword[3 + PPD_MAX_NAME + 1 + 12 + 1 + 12 + 3],
- /* PWG keyword string */
+ // PWG keyword string
ppd_name[PPD_MAX_NAME];
- /* Normalized PPD name */
- const char *pwg_name; /* Standard PWG media name */
- pwg_media_t *pwg_media; /* PWG media data */
+ // Normalized PPD name
+ const char *pwg_name; // Standard PWG media name
+ pwg_media_t *pwg_media; // PWG media data
ppd_pwg_print_color_mode_t pwg_print_color_mode;
- /* print-color-mode index */
- ppd_pwg_print_quality_t pwg_print_quality;
- /* print-quality index */
- int similar; /* Are the old and new size similar? */
- pwg_size_t *old_size; /* Current old size */
- int old_imageable, /* Old imageable length in 2540ths */
- old_borderless, /* Old borderless state */
- old_known_pwg; /* Old PWG name is well-known */
- int new_width, /* New width in 2540ths */
- new_length, /* New length in 2540ths */
- new_left, /* New left margin in 2540ths */
- new_bottom, /* New bottom margin in 2540ths */
- new_right, /* New right margin in 2540ths */
- new_top, /* New top margin in 2540ths */
- new_imageable, /* New imageable length in 2540ths */
- new_borderless, /* New borderless state */
- new_known_pwg; /* New PWG name is well-known */
- pwg_size_t *new_size; /* New size to add, if any */
- const char *filter; /* Current filter */
- ppd_pwg_finishings_t *finishings; /* Current finishings value */
- char msg_id[256]; /* Message identifier */
+ // print-color-mode index
+ ppd_pwg_print_quality_t pwg_print_quality;
+ // print-quality index
+ int similar; // Are the old and new size similar?
+ pwg_size_t *old_size; // Current old size
+ int old_imageable, // Old imageable length in 2540ths
+ old_borderless, // Old borderless state
+ old_known_pwg; // Old PWG name is well-known
+ int new_width, // New width in 2540ths
+ new_length, // New length in 2540ths
+ new_left, // New left margin in 2540ths
+ new_bottom, // New bottom margin in 2540ths
+ new_right, // New right margin in 2540ths
+ new_top, // New top margin in 2540ths
+ new_imageable, // New imageable length in 2540ths
+ new_borderless, // New borderless state
+ new_known_pwg; // New PWG name is well-known
+ pwg_size_t *new_size; // New size to add, if any
+ const char *filter; // Current filter
+ ppd_pwg_finishings_t *finishings; // Current finishings value
+ char msg_id[256]; // Message identifier
DEBUG_printf(("ppdCacheCreateWithPPD(ppd=%p)", ppd));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd)
return (NULL);
- /*
- * Allocate memory...
- */
+ //
+ // Allocate memory...
+ //
if ((pc = calloc(1, sizeof(ppd_cache_t))) == NULL)
{
pc->strings = _ppdMessageNew(NULL);
- /*
- * Copy and convert size data...
- */
+ //
+ // Copy and convert size data...
+ //
if (ppd->num_sizes > 0)
{
- if ((pc->sizes = calloc((size_t)ppd->num_sizes, sizeof(pwg_size_t))) == NULL)
+ if ((pc->sizes = calloc((size_t)ppd->num_sizes,
+ sizeof(pwg_size_t))) == NULL)
{
DEBUG_printf(("ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_size_t's.", ppd->num_sizes));
i > 0;
i --, ppd_size ++)
{
- /*
- * Don't copy over custom size...
- */
+ //
+ // Don't copy over custom size...
+ //
if (!_ppd_strcasecmp(ppd_size->name, "Custom"))
continue;
- /*
- * Convert the PPD size name to the corresponding PWG keyword name.
- */
+ //
+ // Convert the PPD size name to the corresponding PWG keyword name.
+ //
- if ((pwg_media = pwgMediaForSize(PWG_FROM_POINTS(ppd_size->width), PWG_FROM_POINTS(ppd_size->length))) != NULL)
+ if ((pwg_media =
+ pwgMediaForSize(PWG_FROM_POINTS(ppd_size->width),
+ PWG_FROM_POINTS(ppd_size->length))) != NULL)
{
- /*
- * Standard name, do we have conflicts?
- */
+ //
+ // Standard name, do we have conflicts?
+ //
for (j = 0; j < pc->num_sizes; j ++)
if (!strcmp(pc->sizes[j].map.pwg, pwg_media->pwg))
if (pwg_media && strncmp(pwg_media->pwg, "custom_", 7) != 0)
{
- /*
- * Standard name and no conflicts, use it!
- */
+ //
+ // Standard name and no conflicts, use it!
+ //
pwg_name = pwg_media->pwg;
new_known_pwg = 1;
}
else
{
- /*
- * Not a standard name; convert it to a PWG vendor name of the form:
- *
- * pp_lowerppd_WIDTHxHEIGHTuu
- */
+ //
+ // Not a standard name; convert it to a PWG vendor name of the form:
+ //
+ // pp_lowerppd_WIDTHxHEIGHTuu
+ //
pwg_name = pwg_keyword;
new_known_pwg = 0;
PWG_FROM_POINTS(ppd_size->length), NULL);
}
- /*
- * If we have a similar paper with non-zero margins then we only want to
- * keep it if it has a larger imageable area length. The NULL check is for
- * dimensions that are <= 0...
- */
+ //
+ // If we have a similar paper with non-zero margins then we only
+ // want to keep it if it has a larger imageable area length.
+ // The NULL check is for dimensions that are <= 0...
+ //
if ((pwg_media = pwgMediaForSize(PWG_FROM_POINTS(ppd_size->width),
PWG_FROM_POINTS(ppd_size->length))) ==
new_borderless = new_bottom == 0 && new_top == 0 &&
new_left == 0 && new_right == 0;
- for (k = pc->num_sizes, similar = 0, old_size = pc->sizes, new_size = NULL;
+ for (k = pc->num_sizes, similar = 0, old_size = pc->sizes,
+ new_size = NULL;
k > 0 && !similar;
k --, old_size ++)
{
_PPD_PWG_EQUIVALENT(old_size->length, new_length);
if (similar &&
- (new_known_pwg || (!old_known_pwg && new_imageable > old_imageable)))
+ (new_known_pwg ||
+ (!old_known_pwg && new_imageable > old_imageable)))
{
- /*
- * The new paper has a larger imageable area so it could replace
- * the older paper. Regardless of the imageable area, we always
- * prefer the size with a well-known PWG name.
- */
+ //
+ // The new paper has a larger imageable area so it could replace
+ // the older paper. Regardless of the imageable area, we always
+ // prefer the size with a well-known PWG name.
+ //
new_size = old_size;
free(old_size->map.ppd);
if (!similar)
{
- /*
- * The paper was unique enough to deserve its own entry so add it to the
- * end.
- */
+ //
+ // The paper was unique enough to deserve its own entry so add it to the
+ // end.
+ //
new_size = pwg_size ++;
pc->num_sizes ++;
if (new_size)
{
- /*
- * Save this size...
- */
+ //
+ // Save this size...
+ //
new_size->map.ppd = strdup(ppd_size->name);
new_size->map.pwg = strdup(pwg_name);
if (ppd->variable_sizes)
{
- /*
- * Generate custom size data...
- */
+ //
+ // Generate custom size data...
+ //
pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
PWG_FROM_POINTS(ppd->custom_max[0]),
PWG_FROM_POINTS(ppd->custom_max[1]), NULL);
- /* Some PPD files have upper limits too large to be treated with
- int numbers, if we have an overflow (negative result for one
- dimension) use a fixed, large value instead */
+ // Some PPD files have upper limits too large to be treated with
+ // int numbers, if we have an overflow (negative result for one
+ // dimension) use a fixed, large value instead
char *p1, *p2;
char *newmax = (pwg_keyword[strlen(pwg_keyword) - 1] == 'n' ?
"10000" : "100000");
pc->custom_size.top = PWG_FROM_POINTS(ppd->custom_margins[3]);
}
- /*
- * Copy and convert InputSlot data...
- */
+ //
+ // Copy and convert InputSlot data...
+ //
if ((input_slot = ppdFindOption(ppd, "InputSlot")) == NULL)
input_slot = ppdFindOption(ppd, "HPPaperSource");
{
pc->source_option = strdup(input_slot->keyword);
- if ((pc->sources = calloc((size_t)input_slot->num_choices, sizeof(pwg_map_t))) == NULL)
+ if ((pc->sources = calloc((size_t)input_slot->num_choices,
+ sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for InputSlot.", input_slot->num_choices));
pwg_name = "main-roll";
else
{
- /*
- * Convert PPD name to lowercase...
- */
+ //
+ // Convert PPD name to lowercase...
+ //
pwg_name = pwg_keyword;
ppdPwgUnppdizeName(choice->choice, pwg_keyword, sizeof(pwg_keyword),
map->pwg = strdup(pwg_name);
map->ppd = strdup(choice->choice);
- /*
- * Add localized text for PWG keyword to message catalog...
- */
+ //
+ // Add localized text for PWG keyword to message catalog...
+ //
snprintf(msg_id, sizeof(msg_id), "media-source.%s", pwg_name);
ppd_pwg_add_message(pc->strings, msg_id, choice->text);
}
}
- /*
- * Copy and convert MediaType data...
- */
+ //
+ // Copy and convert MediaType data...
+ //
if ((media_type = ppdFindOption(ppd, "MediaType")) != NULL)
{
- if ((pc->types = calloc((size_t)media_type->num_choices, sizeof(pwg_map_t))) == NULL)
+ if ((pc->types = calloc((size_t)media_type->num_choices,
+ sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for MediaType.", media_type->num_choices));
pwg_name = "transparency";
else
{
- /*
- * Convert PPD name to lowercase...
- */
+ //
+ // Convert PPD name to lowercase...
+ //
pwg_name = pwg_keyword;
ppdPwgUnppdizeName(choice->choice, pwg_keyword, sizeof(pwg_keyword),
map->pwg = strdup(pwg_name);
map->ppd = strdup(choice->choice);
- /*
- * Add localized text for PWG keyword to message catalog...
- */
+ //
+ // Add localized text for PWG keyword to message catalog...
+ //
snprintf(msg_id, sizeof(msg_id), "media-type.%s", pwg_name);
ppd_pwg_add_message(pc->strings, msg_id, choice->text);
}
}
- /*
- * Copy and convert OutputBin data...
- */
+ //
+ // Copy and convert OutputBin data...
+ //
if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL)
{
- if ((pc->bins = calloc((size_t)output_bin->num_choices, sizeof(pwg_map_t))) == NULL)
+ if ((pc->bins = calloc((size_t)output_bin->num_choices,
+ sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for OutputBin.", output_bin->num_choices));
map->pwg = strdup(pwg_keyword);
map->ppd = strdup(choice->choice);
- /*
- * Add localized text for PWG keyword to message catalog...
- */
+ //
+ // Add localized text for PWG keyword to message catalog...
+ //
snprintf(msg_id, sizeof(msg_id), "output-bin.%s", pwg_keyword);
ppd_pwg_add_message(pc->strings, msg_id, choice->text);
if ((ppd_attr = ppdFindAttr(ppd, "APPrinterPreset", NULL)) != NULL)
{
- /*
- * "Classic" Mac OS approach
- */
-
- /*
- * Copy and convert APPrinterPreset (output-mode + print-quality) data...
- */
-
- const char *quality, /* com.apple.print.preset.quality value */
- *output_mode, /* com.apple.print.preset.output-mode value */
- *color_model_val, /* ColorModel choice */
- *graphicsType, /* com.apple.print.preset.graphicsType value */
- *media_front_coating; /* com.apple.print.preset.media-front-coating value */
+ //
+ // "Classic" Mac OS approach
+ //
+
+ //
+ // Copy and convert APPrinterPreset (output-mode + print-quality) data...
+ //
+
+ const char *quality, // com.apple.print.preset.quality value
+ *output_mode, // com.apple.print.preset.output-mode
+ // value
+ *color_model_val, // ColorModel choice
+ *graphicsType, // com.apple.print.preset.graphicsType
+ // value
+ *media_front_coating;
+ // com.apple.print.preset.media-front-coating value
do
{
- /*
- * Add localized text for PWG keyword to message catalog...
- */
+ //
+ // Add localized text for PWG keyword to message catalog...
+ //
snprintf(msg_id, sizeof(msg_id), "preset-name.%s", ppd_attr->spec);
ppd_pwg_add_message(pc->strings, msg_id, ppd_attr->text);
- /*
- * Get the options for this preset...
- */
+ //
+ // Get the options for this preset...
+ //
num_options = ppdParseOptions(ppd_attr->value, 0, &options,
PPD_PARSE_ALL);
if ((quality = cupsGetOption("com.apple.print.preset.quality",
num_options, options)) != NULL)
{
- /*
- * Get the print-quality for this preset...
- */
+ //
+ // Get the print-quality for this preset...
+ //
if (!strcmp(quality, "low"))
pwg_print_quality = PPD_PWG_PRINT_QUALITY_DRAFT;
else
pwg_print_quality = PPD_PWG_PRINT_QUALITY_NORMAL;
- /*
- * Ignore graphicsType "Photo" presets that are not high quality.
- */
+ //
+ // Ignore graphicsType "Photo" presets that are not high quality.
+ //
graphicsType = cupsGetOption("com.apple.print.preset.graphicsType",
num_options, options);
!strcmp(graphicsType, "Photo"))
continue;
- /*
- * Ignore presets for normal and draft quality where the coating
- * isn't "none" or "autodetect".
- */
+ //
+ // Ignore presets for normal and draft quality where the coating
+ // isn't "none" or "autodetect".
+ //
media_front_coating = cupsGetOption(
"com.apple.print.preset.media-front-coating",
strcmp(media_front_coating, "autodetect"))
continue;
- /*
- * Get the output mode for this preset...
- */
+ //
+ // Get the output mode for this preset...
+ //
output_mode = cupsGetOption("com.apple.print.preset.output-mode",
num_options, options);
else
pwg_print_color_mode = PPD_PWG_PRINT_COLOR_MODE_COLOR;
- /*
- * Save the options for this combination as needed...
- */
+ //
+ // Save the options for this combination as needed...
+ //
if (!pc->num_presets[pwg_print_color_mode][pwg_print_quality])
pc->num_presets[pwg_print_color_mode][pwg_print_quality] =
!pc->num_presets[PPD_PWG_PRINT_COLOR_MODE_MONOCHROME][PPD_PWG_PRINT_QUALITY_NORMAL] &&
!pc->num_presets[PPD_PWG_PRINT_COLOR_MODE_MONOCHROME][PPD_PWG_PRINT_QUALITY_HIGH])
{
- /*
- * Try adding some common color options to create grayscale presets. These
- * are listed in order of popularity...
- */
+ //
+ // Try adding some common color options to create grayscale
+ // presets. These are listed in order of popularity...
+ //
- const char *color_option = NULL, /* Color control option */
- *gray_choice = NULL; /* Choice to select grayscale */
+ const char *color_option = NULL, // Color control option
+ *gray_choice = NULL; // Choice to select grayscale
if ((color_model = ppdFindOption(ppd, "ColorModel")) != NULL &&
ppdFindChoice(color_model, "Gray"))
if (color_option && gray_choice)
{
- /*
- * Copy and convert ColorModel (output-mode) data...
- */
+ //
+ // Copy and convert ColorModel (output-mode) data...
+ //
- cups_option_t *coption, /* Color option */
- *moption; /* Monochrome option */
+ cups_option_t *coption, // Color option
+ *moption; // Monochrome option
for (pwg_print_quality = PPD_PWG_PRINT_QUALITY_DRAFT;
pwg_print_quality < PPD_PWG_PRINT_QUALITY_MAX;
{
if (pc->num_presets[PPD_PWG_PRINT_COLOR_MODE_COLOR][pwg_print_quality])
{
- /*
- * Copy the color options...
- */
+ //
+ // Copy the color options...
+ //
num_options = pc->num_presets[PPD_PWG_PRINT_COLOR_MODE_COLOR]
[pwg_print_quality];
else if (pwg_print_quality != PPD_PWG_PRINT_QUALITY_NORMAL)
continue;
- /*
- * Add the grayscale option to the preset...
- */
+ //
+ // Add the grayscale option to the preset...
+ //
pc->num_presets[PPD_PWG_PRINT_COLOR_MODE_MONOCHROME][pwg_print_quality] =
cupsAddOption(color_option, gray_choice,
if (!preset_added)
{
- /*
- * Auto-association of PPD file option settings with the IPP job attributes
- * print-color-mode, print-quality, and print-content-optimize
- *
- * This is used to retro-fit PPD files and classic CUPS drivers into
- * Printer Applications, which are IPP printers for the clients and so
- * should get controlled by standard IPP attributes as far as possible
- *
- * Note that settings assigned to print-content-optimize are only used
- * when printing with "high" print-quality
- */
+ //
+ // Auto-association of PPD file option settings with the IPP job attributes
+ // print-color-mode, print-quality, and print-content-optimize
+ //
+ // This is used to retro-fit PPD files and classic CUPS drivers into
+ // Printer Applications, which are IPP printers for the clients and so
+ // should get controlled by standard IPP attributes as far as possible
+ //
+ // Note that settings assigned to print-content-optimize are only used
+ // when printing with "high" print-quality
+ //
ppdCacheAssignPresets(ppd, pc);
}
- /*
- * Copy and convert Duplex (sides) data...
- */
+ //
+ // Copy and convert Duplex (sides) data...
+ //
if ((duplex = ppdFindOption(ppd, "Duplex")) == NULL)
if ((duplex = ppdFindOption(ppd, "JCLDuplex")) == NULL)
i --, choice ++)
{
if ((!_ppd_strcasecmp(choice->choice, "None") ||
- !_ppd_strcasecmp(choice->choice, "False")) && !pc->sides_1sided)
+ !_ppd_strcasecmp(choice->choice, "False")) &&
+ !pc->sides_1sided)
pc->sides_1sided = strdup(choice->choice);
else if ((!_ppd_strcasecmp(choice->choice, "DuplexNoTumble") ||
!_ppd_strcasecmp(choice->choice, "LongEdge") ||
- !_ppd_strcasecmp(choice->choice, "Top")) && !pc->sides_2sided_long)
+ !_ppd_strcasecmp(choice->choice, "Top")) &&
+ !pc->sides_2sided_long)
pc->sides_2sided_long = strdup(choice->choice);
else if ((!_ppd_strcasecmp(choice->choice, "DuplexTumble") ||
!_ppd_strcasecmp(choice->choice, "ShortEdge") ||
}
}
- /*
- * Copy filters and pre-filters...
- */
+ //
+ // Copy filters and pre-filters...
+ //
- pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
cupsArrayAdd(pc->filters,
"application/vnd.cups-raw application/octet-stream 0 -");
else
cupsArrayAdd(pc->filters, "application/vnd.cups-postscript 0 -");
- /*
- * See if we have a command filter...
- */
+ //
+ // See if we have a command filter...
+ //
for (filter = (const char *)cupsArrayFirst(pc->filters);
filter;
((ppd_attr = ppdFindAttr(ppd, "cupsCommands", NULL)) == NULL ||
_ppd_strcasecmp(ppd_attr->value, "none")))
{
- /*
- * No command filter and no cupsCommands keyword telling us not to use one.
- * See if this is a PostScript printer, and if so add a PostScript command
- * filter...
- */
+ //
+ // No command filter and no cupsCommands keyword telling us not to use one.
+ // See if this is a PostScript printer, and if so add a PostScript command
+ // filter...
+ //
for (filter = (const char *)cupsArrayFirst(pc->filters);
filter;
if ((ppd_attr = ppdFindAttr(ppd, "cupsPreFilter", NULL)) != NULL)
{
- pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
do
- {
cupsArrayAdd(pc->prefilters, ppd_attr->value);
- }
while ((ppd_attr = ppdFindNextAttr(ppd, "cupsPreFilter", NULL)) != NULL);
}
if ((ppd_attr = ppdFindAttr(ppd, "cupsSingleFile", NULL)) != NULL)
pc->single_file = !_ppd_strcasecmp(ppd_attr->value, "true");
- /*
- * Copy the product string, if any...
- */
+ //
+ // Copy the product string, if any...
+ //
if (ppd->product)
pc->product = strdup(ppd->product);
- /*
- * Copy finishings mapping data...
- */
+ //
+ // Copy finishings mapping data...
+ //
if ((ppd_attr = ppdFindAttr(ppd, "cupsIPPFinishings", NULL)) != NULL)
{
- /*
- * Have proper vendor mapping of IPP finishings values to PPD options...
- */
+ //
+ // Have proper vendor mapping of IPP finishings values to PPD options...
+ //
- pc->finishings = cupsArrayNew3((cups_array_func_t)ppd_pwg_compare_finishings,
- NULL, NULL, 0, NULL,
- (cups_afree_func_t)ppd_pwg_free_finishings);
+ pc->finishings =
+ cupsArrayNew3((cups_array_func_t)ppd_pwg_compare_finishings,
+ NULL, NULL, 0, NULL,
+ (cups_afree_func_t)ppd_pwg_free_finishings);
do
{
finishings->value = (ipp_finishings_t)atoi(ppd_attr->spec);
finishings->num_options = ppdParseOptions(ppd_attr->value, 0,
- &(finishings->options),
- PPD_PARSE_OPTIONS);
+ &(finishings->options),
+ PPD_PARSE_OPTIONS);
cupsArrayAdd(pc->finishings, finishings);
}
}
else
{
- /*
- * No IPP mapping data, try to map common/standard PPD keywords...
- */
+ //
+ // No IPP mapping data, try to map common/standard PPD keywords...
+ //
- pc->finishings = cupsArrayNew3((cups_array_func_t)ppd_pwg_compare_finishings, NULL, NULL, 0, NULL, (cups_afree_func_t)ppd_pwg_free_finishings);
+ pc->finishings =
+ cupsArrayNew3((cups_array_func_t)ppd_pwg_compare_finishings,
+ NULL, NULL, 0, NULL,
+ (cups_afree_func_t)ppd_pwg_free_finishings);
if ((ppd_option = ppdFindOption(ppd, "StapleLocation")) != NULL)
{
- /*
- * Add staple finishings...
- */
+ //
+ // Add staple finishings...
+ //
if (ppdFindChoice(ppd_option, "SinglePortrait"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_LEFT, "StapleLocation", "SinglePortrait");
- if (ppdFindChoice(ppd_option, "UpperLeft")) /* Ricoh extension */
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_LEFT, "StapleLocation", "UpperLeft");
- if (ppdFindChoice(ppd_option, "UpperRight")) /* Ricoh extension */
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_RIGHT, "StapleLocation", "UpperRight");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_LEFT,
+ "StapleLocation", "SinglePortrait");
+ if (ppdFindChoice(ppd_option, "UpperLeft")) // Ricoh extension
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_LEFT,
+ "StapleLocation", "UpperLeft");
+ if (ppdFindChoice(ppd_option, "UpperRight")) // Ricoh extension
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_RIGHT,
+ "StapleLocation", "UpperRight");
if (ppdFindChoice(ppd_option, "SingleLandscape"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_BOTTOM_LEFT, "StapleLocation", "SingleLandscape");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_STAPLE_BOTTOM_LEFT,
+ "StapleLocation", "SingleLandscape");
if (ppdFindChoice(ppd_option, "DualLandscape"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_DUAL_LEFT, "StapleLocation", "DualLandscape");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_DUAL_LEFT,
+ "StapleLocation", "DualLandscape");
}
if ((ppd_option = ppdFindOption(ppd, "RIPunch")) != NULL)
{
- /*
- * Add (Ricoh) punch finishings...
- */
+ //
+ // Add (Ricoh) punch finishings...
+ //
if (ppdFindChoice(ppd_option, "Left2"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_DUAL_LEFT, "RIPunch", "Left2");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_DUAL_LEFT,
+ "RIPunch", "Left2");
if (ppdFindChoice(ppd_option, "Left3"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_TRIPLE_LEFT, "RIPunch", "Left3");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_TRIPLE_LEFT,
+ "RIPunch", "Left3");
if (ppdFindChoice(ppd_option, "Left4"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_QUAD_LEFT, "RIPunch", "Left4");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_QUAD_LEFT,
+ "RIPunch", "Left4");
if (ppdFindChoice(ppd_option, "Right2"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_DUAL_RIGHT, "RIPunch", "Right2");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_DUAL_RIGHT,
+ "RIPunch", "Right2");
if (ppdFindChoice(ppd_option, "Right3"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_TRIPLE_RIGHT, "RIPunch", "Right3");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_TRIPLE_RIGHT,
+ "RIPunch", "Right3");
if (ppdFindChoice(ppd_option, "Right4"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_QUAD_RIGHT, "RIPunch", "Right4");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_QUAD_RIGHT,
+ "RIPunch", "Right4");
if (ppdFindChoice(ppd_option, "Upper2"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_DUAL_TOP, "RIPunch", "Upper2");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_DUAL_TOP,
+ "RIPunch", "Upper2");
if (ppdFindChoice(ppd_option, "Upper3"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_TRIPLE_TOP, "RIPunch", "Upper3");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_TRIPLE_TOP,
+ "RIPunch", "Upper3");
if (ppdFindChoice(ppd_option, "Upper4"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_QUAD_TOP, "RIPunch", "Upper4");
+ ppd_pwg_add_finishing(pc->finishings,
+ IPP_FINISHINGS_PUNCH_QUAD_TOP,
+ "RIPunch", "Upper4");
}
if ((ppd_option = ppdFindOption(ppd, "BindEdge")) != NULL)
{
- /*
- * Add bind finishings...
- */
+ //
+ // Add bind finishings...
+ //
if (ppdFindChoice(ppd_option, "Left"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_BIND_LEFT, "BindEdge", "Left");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_BIND_LEFT,
+ "BindEdge", "Left");
if (ppdFindChoice(ppd_option, "Right"))
ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_BIND_RIGHT, "BindEdge", "Right");
if (ppdFindChoice(ppd_option, "Top"))
if ((ppd_option = ppdFindOption(ppd, "FoldType")) != NULL)
{
- /*
- * Add (Adobe) fold finishings...
- */
+ //
+ // Add (Adobe) fold finishings...
+ //
if (ppdFindChoice(ppd_option, "ZFold"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_Z, "FoldType", "ZFold");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_Z,
+ "FoldType", "ZFold");
if (ppdFindChoice(ppd_option, "Saddle"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_HALF, "FoldType", "Saddle");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_HALF,
+ "FoldType", "Saddle");
if (ppdFindChoice(ppd_option, "DoubleGate"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_DOUBLE_GATE, "FoldType", "DoubleGate");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_DOUBLE_GATE,
+ "FoldType", "DoubleGate");
if (ppdFindChoice(ppd_option, "LeftGate"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LEFT_GATE, "FoldType", "LeftGate");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LEFT_GATE,
+ "FoldType", "LeftGate");
if (ppdFindChoice(ppd_option, "RightGate"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_RIGHT_GATE, "FoldType", "RightGate");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_RIGHT_GATE,
+ "FoldType", "RightGate");
if (ppdFindChoice(ppd_option, "Letter"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LETTER, "FoldType", "Letter");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LETTER,
+ "FoldType", "Letter");
if (ppdFindChoice(ppd_option, "XFold"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_POSTER, "FoldType", "XFold");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_POSTER,
+ "FoldType", "XFold");
}
if ((ppd_option = ppdFindOption(ppd, "RIFoldType")) != NULL)
{
- /*
- * Add (Ricoh) fold finishings...
- */
+ //
+ // Add (Ricoh) fold finishings...
+ //
if (ppdFindChoice(ppd_option, "OutsideTwoFold"))
- ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LETTER, "RIFoldType", "OutsideTwoFold");
+ ppd_pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LETTER,
+ "RIFoldType", "OutsideTwoFold");
}
if (cupsArrayCount(pc->finishings) == 0)
if ((ppd_option = ppdFindOption(ppd, "cupsFinishingTemplate")) != NULL)
{
- pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ pc->templates = cupsArrayNew3((cups_array_func_t)strcmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
- for (choice = ppd_option->choices, i = ppd_option->num_choices; i > 0; choice ++, i --)
+ for (choice = ppd_option->choices, i = ppd_option->num_choices; i > 0;
+ choice ++, i --)
{
cupsArrayAdd(pc->templates, (void *)choice->choice);
- /*
- * Add localized text for PWG keyword to message catalog...
- */
+ //
+ // Add localized text for PWG keyword to message catalog...
+ //
snprintf(msg_id, sizeof(msg_id), "finishing-template.%s", choice->choice);
ppd_pwg_add_message(pc->strings, msg_id, choice->text);
}
}
- /*
- * Max copies...
- */
+ //
+ // Max copies...
+ //
if ((ppd_attr = ppdFindAttr(ppd, "cupsMaxCopies", NULL)) != NULL)
pc->max_copies = atoi(ppd_attr->value);
else
pc->max_copies = 9999;
- /*
- * cupsChargeInfoURI, cupsJobAccountId, cupsJobAccountingUserId,
- * cupsJobPassword, and cupsMandatory.
- */
+ //
+ // cupsChargeInfoURI, cupsJobAccountId, cupsJobAccountingUserId,
+ // cupsJobPassword, and cupsMandatory.
+ //
if ((ppd_attr = ppdFindAttr(ppd, "cupsChargeInfoURI", NULL)) != NULL)
pc->charge_info_uri = strdup(ppd_attr->value);
if ((ppd_attr = ppdFindAttr(ppd, "cupsMandatory", NULL)) != NULL)
pc->mandatory = _ppdArrayNewStrings(ppd_attr->value, ' ');
- /*
- * Support files...
- */
+ //
+ // Support files...
+ //
- pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
for (ppd_attr = ppdFindAttr(ppd, "cupsICCProfile", NULL);
ppd_attr;
if ((ppd_attr = ppdFindAttr(ppd, "APPrinterIconPath", NULL)) != NULL)
cupsArrayAdd(pc->support_files, ppd_attr->value);
- /*
- * Return the cache data...
- */
+ //
+ // Return the cache data...
+ //
return (pc);
- /*
- * If we get here we need to destroy the PWG mapping data and return NULL...
- */
+ //
+ // If we get here we need to destroy the PWG mapping data and return NULL...
+ //
create_error:
}
-/*
- * 'ppdCacheAssignPresets()' - Go through all the options and choices in
- * the PPD to find out which influence
- * color/bw, print quality, and content
- * optimizations to assign them to the prsets
- * so that jobs can easily be controlled with
- * standard IPP attributes
- */
+//
+// 'ppdCacheAssignPresets()' - Go through all the options and choices
+// in the PPD to find out which influence
+// on color/bw, print quality, and content
+// optimization they have to assign them
+// to the presets so that jobs can easily
+// be controlled with standard IPP
+// attributes
+//
void
ppdCacheAssignPresets(ppd_file_t *ppd,
int name_factor = 10; // print quality
int color_factor = 1000;
- /* Do we have a color printer ? */
+ // Do we have a color printer ?
is_color = (ppd->color_device ? 1 : 0);
- /* what is the base/default resolution for this PPD? */
+ // what is the base/default resolution for this PPD?
ppdMarkDefaults(ppd);
ppdRasterInterpretPPD(&header, ppd, 0, NULL, NULL);
if (header.HWResolution[0] != 100 || header.HWResolution[1] != 100)
base_res_y = base_res_x;
}
- /* Go through all options of the PPD file */
+ // Go through all options of the PPD file
for (i = ppd->num_groups, group = ppd->groups;
i > 0;
i --, group ++)
{
- /* Skip the "Installable Options" group */
+ // Skip the "Installable Options" group
if (strncasecmp(group->name, "Installable", 11) == 0)
continue;
o = option->keyword;
- /* Skip options which do not change color mode and quality or
- generally do not make sense in presets */
+ // Skip options which do not change color mode and quality or
+ // generally do not make sense in presets
if (strcasecmp(o, "PageSize") == 0 ||
strcasecmp(o, "PageRegion") == 0 ||
strcasecmp(o, "InputSlot") == 0 ||
strcasecmp(o, "Collate") == 0)
continue;
- /* Set members options of composite options in Foomatic to stay
- controlled by the composite option */
-
- /* Composite options in Foomaticar options which set a number of
- other options, so each choice of them is the same as a preset
- in CUPS. In addition, some PPDs in Foomatic have a composite
- option named "PrintoutMode" with 6 choices, exactly the 6 of
- the grid of CUPS presets, color/mono in draft, mediaum, and
- high quality. The composite options are created by hand, so
- they surely do for what they are intended for and so they are
- safer as this preset auto-generation algorithm. Therefore we
- only let the composite option be set in our presets and set
- the members options to leave the control at the composite
- option */
+ //
+ // Set member options of composite options in Foomatic to stay
+ // controlled by the composite option
+ //
+ // Composite options in Foomatic are options which set a number
+ // of other options, so each choice of them is the same as a
+ // preset in CUPS. In addition, some PPDs in Foomatic have a
+ // composite option named "PrintoutMode" with 6 choices, exactly
+ // the 6 of the grid of CUPS presets, color/mono in draft,
+ // medium, and high quality. The composite options are created
+ // by hand, so they surely do for what they are intended for and
+ // so they are safer as this preset auto-generation
+ // algorithm. Therefore we only let the composite option be set
+ // in our presets and set the member options to leave the
+ // control at the composite option
+ //
if (strstr(ppd->nickname, "Foomatic") &&
!strncmp(option->choices[0].choice, "From", 4) &&
continue;
}
- /* Array for properties of the choices */
+ // Array for properties of the choices
choice_properties = cupsArrayNew(NULL, NULL);
- /*
- * Gather the data for each choice
- */
+ //
+ // Gather the data for each choice
+ //
for (k = 0; k < option->num_choices; k ++)
{
c = option->choices[k].choice;
- /* Is this the default choice? (preferred for "normal" quality,
- used for color if no choice name suggests being color */
+ // Is this the default choice? (preferred for "normal" quality,
+ // used for color if no choice name suggests being color)
if (strcmp(c, option->defchoice) == 0)
{
properties->is_default = 1;
default_ch = k;
}
- /*
- * Color/Monochrome - print-color-mode
- */
+ //
+ // Color/Monochrome - print-color-mode
+ //
- /* If we have a color device, check whether this option sets mono or
- color printing */
+ // If we have a color device, check whether this option sets mono or
+ // color printing
if (is_color)
{
if (strcasecmp(o, "CNIJSGrayScale") == 0)
else
properties->sets_color = 1;
}
- else if (strcasecmp(o, "HPColorAsGray") == 0 || /* HP PostScript */
- strcasecmp(o, "HPPJLColorAsGray") == 0) /* HP PostScript */
+ else if (strcasecmp(o, "HPColorAsGray") == 0 || // HP PostScript
+ strcasecmp(o, "HPPJLColorAsGray") == 0) // HP PostScript
{
if (strcasecmp(c, "True") == 0 ||
strcasecmp(c, "yes") == 0)
strcasestr(o, "ColorMode") ||
strcasecmp(o, "OutputMode") == 0 ||
strcasecmp(o, "PrintoutMode") == 0 ||
- strcasecmp(o, "ARCMode") == 0 || /* Sharp */
+ strcasecmp(o, "ARCMode") == 0 || // Sharp
strcasestr(o, "ColorMode") ||
- strcasecmp(o, "ColorResType") == 0 || /* Toshiba */
- strcasestr(o, "MonoColor")) /* Brother */
+ strcasecmp(o, "ColorResType") == 0 || // Toshiba
+ strcasestr(o, "MonoColor")) // Brother
{
- /* Monochrome/grayscale printing */
+ // Monochrome/grayscale printing
if (strcasestr(c, "Mono") ||
strcasecmp(c, "Black") == 0 ||
((p = strcasestr(c, "Black")) && strcasestr(p, "White")) ||
properties->sets_mono = 2;
else if (strcasestr(c, "Gray") ||
strcasestr(c, "Grey") ||
- strcasecmp(c, "BlackOnly") == 0) /* Lexmark */
+ strcasecmp(c, "BlackOnly") == 0) // Lexmark
properties->sets_mono = 3;
- /* Color printing */
+ // Color printing
if (((p = strcasestr(c, "CMY")) && !strcasestr(p, "Gray")) ||
- strcasecmp(c, "ColorOnly") == 0 || /* Lexmark */
+ strcasecmp(c, "ColorOnly") == 0 || // Lexmark
((p = strcasestr(c, "Adobe")) && strcasestr(p, "RGB")))
properties->sets_color = 2;
else if (strcasestr(c, "sRGB"))
properties->sets_color = 3;
}
- /* This option actually sets color mode */
+ // This option actually sets color mode
if (properties->sets_mono || properties->sets_color)
sets_color_mode = 1;
}
- /*
- * Output Quality - print-quality
- */
+ //
+ // Output Quality - print-quality
+ //
- /* check whether this option affects print quality or content
- optimization */
+ // check whether this option affects print quality or content
+ // optimization
- /* Determine influence of the options and choices on the print
- quality by their names */
+ // Determine influence of the options and choices on the print
+ // quality by their names
- /* Vendor-specific option and choice names */
- if (strcasecmp(o, "ARCPPriority") == 0) /* Sharp */
+ // Vendor-specific option and choice names
+ if (strcasecmp(o, "ARCPPriority") == 0) // Sharp
{
if (strcasecmp(c, "Quality") == 0)
properties->sets_high = 10;
else if (strcasecmp(c, "Speed") == 0)
properties->sets_draft = 10;
}
- else if (strcasecmp(o, "BRJpeg") == 0) /* Brother */
+ else if (strcasecmp(o, "BRJpeg") == 0) // Brother
{
if (strcasecmp(c, "QualityPrior") == 0)
properties->sets_high = 10;
else if (strcasecmp(c, "SpeedPrior") == 0)
properties->sets_draft = 10;
}
- else if (strcasecmp(o, "FXOutputMode") == 0) /* Fuji Xerox */
+ else if (strcasecmp(o, "FXOutputMode") == 0) // Fuji Xerox
{
if (strcasecmp(c, "Quality2") == 0)
properties->sets_high = 10;
else if (strcasecmp(c, "Standard") == 0)
properties->sets_normal = 10;
}
- else if (strcasecmp(o, "RIPrintMode") == 0) /* Ricoh & OEM */
+ else if (strcasecmp(o, "RIPrintMode") == 0) // Ricoh & OEM
{
if (strcasecmp(c, "1rhit") == 0)
properties->sets_high = 7;
else if (strcasecmp(c, "0rhit") == 0)
properties->sets_normal = 10;
}
- else if (strcasecmp(o, "EconoMode") == 0 || /* Foomatic */
- strcasecmp(o, "EconoFast") == 0) /* Foomatic (HP PPA) */
+ else if (strcasecmp(o, "EconoMode") == 0 || // Foomatic
+ strcasecmp(o, "EconoFast") == 0) // Foomatic (HP PPA)
{
if (strcasecmp(c, "Off") == 0 ||
strcasecmp(c, "False") == 0)
else if (strcasecmp(c, "High") == 0)
properties->sets_draft = 11;
}
- else if (strcasestr(o, "ColorPrecision")) /* Gutenprint */
+ else if (strcasestr(o, "ColorPrecision")) // Gutenprint
{
if (strcasecmp(c, "best") == 0)
properties->sets_high = 10;
}
- /* Generic boolean options which enhance quality if true */
+ // Generic boolean options which enhance quality if true
else if (((p = strcasestr(o, "slow")) && strcasestr(p, "dry")) ||
((p = strcasestr(o, "color")) && strcasestr(p, "enhance")) ||
((p = strcasestr(o, "resolution")) &&
!strcasestr(p, "enhance")) ||
strcasecmp(o, "RET") == 0 ||
- strcasecmp(o, "Smoothing") == 0 || /* HPLIP */
+ strcasecmp(o, "Smoothing") == 0 || // HPLIP
((p = strcasestr(o, "uni")) && strcasestr(p, "direction")))
{
if (strcasecmp(c, "True") == 0 ||
strcasecmp(c, "On") == 0 ||
strcasecmp(c, "Yes") == 0 ||
strcasecmp(c, "1") == 0 ||
- strcasecmp(c, "Medium") == 0) /* Resolution Enhancement/RET (HP)*/
+ strcasecmp(c, "Medium") == 0) // Resolution Enhancement/RET (HP)
properties->sets_high = 3;
else if (strcasecmp(c, "False") == 0 ||
strcasecmp(c, "Off") == 0 ||
strcasecmp(c, "0") == 0)
properties->sets_draft = 3;
}
- /* Generic boolean options which reduce quality if true */
+ // Generic boolean options which reduce quality if true
else if (strcasestr(o, "draft") ||
strcasestr(o, "economy") ||
((p = strcasestr(o, "eco")) && strcasestr(p, "mode")) ||
((p = strcasestr(o, "toner")) && strcasestr(p, "sav")) ||
((p = strcasestr(o, "bi")) && strcasestr(p, "direction")) ||
- strcasecmp(o, "EcoBlack") == 0 || /* Foomatic (Alps) */
+ strcasecmp(o, "EcoBlack") == 0 || // Foomatic (Alps)
strcasecmp(o, "bidi") == 0 ||
strcasecmp(o, "bi-di") == 0)
{
strcasecmp(c, "On") == 0 ||
strcasecmp(c, "Yes") == 0 ||
strcasecmp(c, "1") == 0 ||
- strcasecmp(c, "Medium") == 0) /* EconomyMode (Brother) */
+ strcasecmp(c, "Medium") == 0) // EconomyMode (Brother)
properties->sets_draft = 3;
else if (strcasecmp(c, "False") == 0 ||
strcasecmp(c, "Off") == 0 ||
strcasecmp(c, "0") == 0)
properties->sets_high = 3;
}
- /* Generic enumerated choice option and choice names */
+ // Generic enumerated choice option and choice names
else if (strcasecmp(o, "ColorModel") == 0 ||
strcasestr(o, "ColorMode") ||
- strcasecmp(o, "OutputMode") == 0 || /* HPLIP hpcups */
- strcasecmp(o, "PrintoutMode") == 0 || /* Foomatic */
+ strcasecmp(o, "OutputMode") == 0 || // HPLIP hpcups
+ strcasecmp(o, "PrintoutMode") == 0 || // Foomatic
strcasecmp(o, "PrintQuality") == 0 ||
strcasecmp(o, "PrintMode") == 0 ||
strcasestr(o, "ColorMode") ||
- strcasestr(o, "HalfTone") || /* HPLIP */
- strcasecmp(o, "ColorResType") == 0 || /* Toshiba */
- strcasestr(o, "MonoColor") || /* Brother */
+ strcasestr(o, "HalfTone") || // HPLIP
+ strcasecmp(o, "ColorResType") == 0 || // Toshiba
+ strcasestr(o, "MonoColor") || // Brother
strcasestr(o, "Quality") ||
strcasestr(o, "Resolution") ||
- strcasestr(o, "Precision") || /* ex. stpColorPrecision
- in Gutenprint */
- strcasestr(o, "PrintingDirection")) /* Gutenprint */
+ strcasestr(o, "Precision") || // ex. stpColorPrecision
+ // in Gutenprint
+ strcasestr(o, "PrintingDirection")) // Gutenprint
{
- /* High quality */
+ // High quality
if (strcasecmp(c, "Quality") == 0 ||
strcasecmp(c, "5") == 0)
properties->sets_high = 1;
else if (strcasestr(c, "Photo") ||
strcasestr(c, "Enhance") ||
strcasestr(c, "slow") ||
- strncasecmp(c, "ProRes", 6) == 0 || /* HPLIP */
- strncasecmp(c, "ImageREt", 8) == 0 || /* HPLIP */
+ strncasecmp(c, "ProRes", 6) == 0 || // HPLIP
+ strncasecmp(c, "ImageREt", 8) == 0 || // HPLIP
((p = strcasestr(c, "low")) && strcasestr(p, "speed")))
properties->sets_high = 2;
else if (strcasestr(c, "fine") ||
strcasestr(c, "deep") ||
((p = strcasestr(c, "high")) && !strcasestr(p, "speed")) ||
strcasestr(c, "HQ") ||
- strcasecmp(c, "ProRes600") == 0 || /* HPLIP */
- strcasecmp(c, "ImageREt1200") == 0 || /* HPLIP */
+ strcasecmp(c, "ProRes600") == 0 || // HPLIP
+ strcasecmp(c, "ImageREt1200") == 0 || // HPLIP
strcasecmp(c, "Enhanced") == 0)
properties->sets_high = 3;
else if (strcasestr(c, "best") ||
strcasecmp(c, "high") == 0 ||
strcasecmp(c, "fine") == 0 ||
strcasecmp(c, "HQ") == 0 ||
- strcasecmp(c, "CMYGray") == 0 || /* HPLIP */
- strcasecmp(c, "ProRes1200") == 0 || /* HPLIP */
- strcasecmp(c, "ImageREt2400") == 0 || /* HPLIP */
+ strcasecmp(c, "CMYGray") == 0 || // HPLIP
+ strcasecmp(c, "ProRes1200") == 0 || // HPLIP
+ strcasecmp(c, "ImageREt2400") == 0 || // HPLIP
strcasestr(c, "unidir"))
properties->sets_high = 4;
else if (strcasecmp(c, "best") == 0 ||
- strcasecmp(c, "ProRes2400") == 0 || /* HPLIP */
- strcasecmp(c, "monolowdetail") == 0) /* Toshiba */
+ strcasecmp(c, "ProRes2400") == 0 || // HPLIP
+ strcasecmp(c, "monolowdetail") == 0) // Toshiba
properties->sets_high = 5;
- /* Low/Draft quality */
- if (strcasecmp(c, "monolowdetail") == 0 || /* Toshiba */
+ // Low/Draft quality
+ if (strcasecmp(c, "monolowdetail") == 0 || // Toshiba
strcasecmp(c, "3") == 0)
properties->sets_draft = 1;
else if (((p = strcasestr(c, "fast")) && strcasestr(p, "draft")) ||
else if (strcasestr(c, "quick") ||
(strcasestr(c, "fast") &&
!(strncasecmp(c, "FastRes", 7) == 0 && isdigit(*(c + 7)))))
- /* HPLIP has FastRes600, FastRes1200, ... which are not draft */
+ // HPLIP has FastRes600, FastRes1200, ... which are not draft
properties->sets_draft = 3;
else if (strcasecmp(c, "quick") == 0 ||
strcasecmp(c, "fast") == 0 ||
strcasestr(c, "bidir"))
properties->sets_draft = 5;
- /* Use high or low quality but not the extremes */
+ // Use high or low quality but not the extremes
if (strcasestr(c, "ultra") ||
strcasestr(c, "very") ||
strcasestr(c, "super"))
properties->sets_draft --;
}
- /* Normal quality */
+ // Normal quality
if (strcasestr(c, "automatic") ||
strcasecmp(c, "none") == 0 ||
strcasecmp(c, "4") == 0 ||
- strcasecmp(c, "FastRes1200") == 0) /* HPLIP */
+ strcasecmp(c, "FastRes1200") == 0) // HPLIP
properties->sets_normal = 1;
else if (strcasestr(c, "normal") ||
strcasestr(c, "standard") ||
strcasestr(c, "default") ||
- strcasecmp(c, "FastRes600") == 0) /* HPLIP */
+ strcasecmp(c, "FastRes600") == 0) // HPLIP
properties->sets_normal = 2;
else if (strcasecmp(c, "normal") == 0 ||
strcasecmp(c, "standard") == 0 ||
properties->sets_normal = 4;
}
- /* Apply the weight factor for option/choice-name-related scores */
+ // Apply the weight factor for option/choice-name-related scores
properties->sets_high *= name_factor;
properties->sets_draft *= name_factor;
properties->sets_normal *= name_factor;
- /* Determine influence of the options and choices on the print
- quality by how they change the output resolution compared to
- the base/default resolution */
+ // Determine influence of the options and choices on the print
+ // quality by how they change the output resolution compared to
+ // the base/default resolution
if (base_res_x && base_res_y)
{
- /* First, analyse the code snippet (PostScript, PJL) assigned
- to each choice of the option whether it sets resolution */
+ // First, analyse the code snippet (PostScript, PJL) assigned
+ // to each choice of the option whether it sets resolution
if (option->choices[k].code && option->choices[k].code[0])
{
- /* Assume code to be PostScript (also used for CUPS Raster) */
+ // Assume code to be PostScript (also used for CUPS Raster)
preferred_bits = 0;
optheader = header;
if (ppdRasterExecPS(&optheader, &preferred_bits,
properties->res_y = optheader.HWResolution[1];
}
else
- properties->res_x = properties->res_y = 0; /* invalid */
+ properties->res_x = properties->res_y = 0; // invalid
if (properties->res_x == 0 || properties->res_y == 0)
{
- /* Now try PJL */
+ // Now try PJL
if ((p = strstr(option->choices[k].code, "SET")) &&
isspace(*(p + 3)) && (p = strstr(p + 4, "RESOLUTION=")))
{
}
}
if (properties->res_x == 100 && properties->res_y == 100)
- properties->res_x = properties->res_y = 0; /* Code does not
- set resolution */
+ properties->res_x = properties->res_y = 0; // Code does not
+ // set resolution
}
else
- properties->res_x = properties->res_y = 0; /* invalid */
+ properties->res_x = properties->res_y = 0; // invalid
- /* Then parse the choice name whether it contains a
- resolution value (Must have "dpi", as otherwise can be
- something else, like a page size */
+ // Then parse the choice name whether it contains a
+ // resolution value (Must have "dpi", as otherwise can be
+ // something else, like a page size)
if ((properties->res_x == 0 || properties->res_y == 0) &&
(p = strcasestr(c, "dpi")) != NULL)
{
}
}
- /* This option actually sets print quality */
+ // This option actually sets print quality
if (properties->sets_draft || properties->sets_high)
sets_quality = 1;
- /* Add the properties of this choice */
+ // Add the properties of this choice
cupsArrayAdd(choice_properties, properties);
}
- /*
- * Find the best choice for each field of the color/quality preset
- * grid
- */
+ //
+ // Find the best choice for each field of the color/quality preset
+ // grid
+ //
for (pass = 0; pass < 3; pass ++)
{
{
properties = cupsArrayIndex(choice_properties, k);
- /* presets[0][0]: Mono/Draft */
+ // presets[0][0]: Mono/Draft
if (best_mono_draft >= 0 &&
!properties->sets_color &&
(!properties->sets_high || pass > 0))
}
}
- /* presets[0][1]: Mono/Normal */
+ // presets[0][1]: Mono/Normal
if (best_mono_normal >= 0 &&
!properties->sets_color &&
(!properties->sets_draft || pass > 1) &&
}
}
- /* presets[0][2]: Mono/High */
+ // presets[0][2]: Mono/High
if (best_mono_high >= 0 &&
!properties->sets_color &&
(!properties->sets_draft || pass > 0))
}
}
- /* presets[1][0]: Color/Draft */
+ // presets[1][0]: Color/Draft
if (best_color_draft >= 0 &&
!properties->sets_mono &&
(!properties->sets_high || pass > 0))
}
}
- /* presets[1][1]: Color/Normal */
+ // presets[1][1]: Color/Normal
if (best_color_normal >= 0 &&
!properties->sets_mono &&
(!properties->sets_draft || pass > 1) &&
}
}
- /* presets[1][2]: Color/High */
+ // presets[1][2]: Color/High
if (best_color_high >= 0 &&
!properties->sets_mono &&
(!properties->sets_draft || pass > 0))
}
}
}
- /* Block next passes for the presets where we are done */
+ // Block next passes for the presets where we are done
if (best_mono_draft_ch >= 0)
best_mono_draft = -1;
if (best_mono_normal_ch >= 0)
best_color_high = -1;
}
- /*
- * Content Optimization - print-content-optimize
- */
+ //
+ // Content Optimization - print-content-optimize
+ //
for (k = 0; k < option->num_choices; k ++)
{
properties = cupsArrayIndex(choice_properties, k);
c = option->choices[k].choice;
- /* Vendor-specific options */
- if (strcasecmp(o, "ARCOType") == 0) /* Sharp */
+ // Vendor-specific options
+ if (strcasecmp(o, "ARCOType") == 0) // Sharp
{
if (strcasecmp(c, "COTDrawing") == 0)
{
else if (strcasecmp(c, "COTPhoto") == 0)
properties->for_photo = 3;
}
- else if (strcasecmp(o, "HPRGBEmulation") == 0) /* HP */
+ else if (strcasecmp(o, "HPRGBEmulation") == 0) // HP
{
if (strcasecmp(c, "DefaultSRGB") == 0)
properties->for_text = 3;
properties->for_photo = 3;
}
else
- /* Generic choice names */
+ // Generic choice names
{
if (strcasestr(c, "photo"))
properties->for_photo = 6;
}
}
- /* We apply these optimizations only in high quality mode
- therefore we prefer settings for high quality */
+ // We apply these optimizations only in high quality mode
+ // therefore we prefer settings for high quality
if (properties->sets_high && !properties->sets_draft)
{
if (properties->for_photo)
properties->for_tg += 10;
}
- /*
- * Find the best choice for each field of the content optimize presets
- */
+ //
+ // Find the best choice for each field of the content optimize presets
+ //
- /* Find best choice for each task */
- /* optimize_presets[1]: Photo */
+ // Find best choice for each task
+ // optimize_presets[1]: Photo
if (properties->for_photo > best_photo)
{
best_photo = properties->for_photo;
best_photo_ch = k;
}
- /* optimize_presets[2]: Graphics */
+ // optimize_presets[2]: Graphics
if (properties->for_graphics > best_graphics)
{
best_graphics = properties->for_graphics;
best_graphics_ch = k;
}
- /* optimize_presets[3]: Text */
+ // optimize_presets[3]: Text
if (properties->for_text > best_text)
{
best_text = properties->for_text;
best_text_ch = k;
}
- /* optimize_presets[4]: Text and Graphics */
+ // optimize_presets[4]: Text and Graphics
if (properties->for_tg > best_tg)
{
best_tg = properties->for_tg;
best_tg_ch = k;
}
- /* This option actually does content optimization */
+ // This option actually does content optimization
if (properties->for_text || properties->for_graphics ||
properties->for_tg || properties->for_photo)
sets_optimization = 1;
}
- /*
- * Fill in the presets
- */
+ //
+ // Fill in the presets
+ //
if (sets_color_mode || sets_quality)
{
- /* presets[0][0]: Mono/Draft */
+ // presets[0][0]: Mono/Draft
if (best_mono_draft_ch < 0)
best_mono_draft_ch = default_ch;
if (best_mono_draft_ch >= 0)
&(pc->presets[PPD_PWG_PRINT_COLOR_MODE_MONOCHROME]
[PPD_PWG_PRINT_QUALITY_DRAFT]));
- /* presets[0][1]: Mono/Normal */
+ // presets[0][1]: Mono/Normal
if (best_mono_normal_ch < 0)
best_mono_normal_ch = default_ch;
if (best_mono_normal_ch >= 0)
&(pc->presets[PPD_PWG_PRINT_COLOR_MODE_MONOCHROME]
[PPD_PWG_PRINT_QUALITY_NORMAL]));
- /* presets[0][2]: Mono/High */
+ // presets[0][2]: Mono/High
if (best_mono_high_ch < 0)
best_mono_high_ch = default_ch;
if (best_mono_high_ch >= 0)
&(pc->presets[PPD_PWG_PRINT_COLOR_MODE_MONOCHROME]
[PPD_PWG_PRINT_QUALITY_HIGH]));
- /* presets[1][0]: Color/Draft */
+ // presets[1][0]: Color/Draft
if (best_color_draft_ch < 0)
best_color_draft_ch = default_ch;
if (best_color_draft_ch >= 0)
&(pc->presets[PPD_PWG_PRINT_COLOR_MODE_COLOR]
[PPD_PWG_PRINT_QUALITY_DRAFT]));
- /* presets[1][1]: Color/Normal */
+ // presets[1][1]: Color/Normal
if (best_color_normal_ch < 0)
best_color_normal_ch = default_ch;
if (best_color_normal_ch >= 0)
&(pc->presets[PPD_PWG_PRINT_COLOR_MODE_COLOR]
[PPD_PWG_PRINT_QUALITY_NORMAL]));
- /* presets[1][2]: Color/High */
+ // presets[1][2]: Color/High
if (best_color_high_ch < 0)
best_color_high_ch = default_ch;
if (best_color_high_ch >= 0)
if (sets_optimization)
{
- /* optimize_presets[1]: Photo */
+ // optimize_presets[1]: Photo
if (best_photo_ch >= 0)
pc->num_optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_PHOTO] =
cupsAddOption
pc->num_optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_PHOTO],
&(pc->optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_PHOTO]));
- /* optimize_presets[2]: Graphics */
+ // optimize_presets[2]: Graphics
if (best_graphics_ch >= 0)
pc->num_optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_GRAPHICS] =
cupsAddOption
&(pc->optimize_presets
[PPD_PWG_PRINT_CONTENT_OPTIMIZE_GRAPHICS]));
- /* optimize_presets[1]: Text */
+ // optimize_presets[1]: Text
if (best_text_ch >= 0)
pc->num_optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_TEXT] =
cupsAddOption
pc->num_optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_TEXT],
&(pc->optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_TEXT]));
- /* optimize_presets[1]: Text and Graphics */
+ // optimize_presets[1]: Text and Graphics
if (best_tg_ch >= 0)
pc->num_optimize_presets
[PPD_PWG_PRINT_CONTENT_OPTIMIZE_TEXT_AND_GRAPHICS] =
}
}
-/*
- * 'ppdCacheDestroy()' - Free all memory used for PWG mapping data.
- */
+
+//
+// 'ppdCacheDestroy()' - Free all memory used for PWG mapping data.
+//
void
-ppdCacheDestroy(ppd_cache_t *pc) /* I - PPD cache and mapping data */
+ppdCacheDestroy(ppd_cache_t *pc) // I - PPD cache and mapping data
{
- int i, j; /* Looping vars */
- pwg_map_t *map; /* Current map */
- pwg_size_t *size; /* Current size */
+ int i, j; // Looping vars
+ pwg_map_t *map; // Current map
+ pwg_size_t *size; // Current size
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc)
return;
- /*
- * Free memory as needed...
- */
+ //
+ // Free memory as needed...
+ //
if (pc->bins)
{
cupsArrayDelete(pc->strings);
- for (i = PPD_PWG_PRINT_COLOR_MODE_MONOCHROME; i < PPD_PWG_PRINT_COLOR_MODE_MAX; i ++)
+ for (i = PPD_PWG_PRINT_COLOR_MODE_MONOCHROME;
+ i < PPD_PWG_PRINT_COLOR_MODE_MAX; i ++)
for (j = PPD_PWG_PRINT_QUALITY_DRAFT; j < PPD_PWG_PRINT_QUALITY_MAX; j ++)
if (pc->num_presets[i][j])
cupsFreeOptions(pc->num_presets[i][j], pc->presets[i][j]);
- for (i = PPD_PWG_PRINT_CONTENT_OPTIMIZE_AUTO; i < PPD_PWG_PRINT_CONTENT_OPTIMIZE_MAX; i ++)
+ for (i = PPD_PWG_PRINT_CONTENT_OPTIMIZE_AUTO;
+ i < PPD_PWG_PRINT_CONTENT_OPTIMIZE_MAX; i ++)
if (pc->num_optimize_presets[i])
cupsFreeOptions(pc->num_optimize_presets[i], pc->optimize_presets[i]);
}
-/*
- * 'ppdCacheGetBin()' - Get the PWG output-bin keyword associated with a PPD
- * OutputBin.
- */
+//
+// 'ppdCacheGetBin()' - Get the PWG output-bin keyword associated with a PPD
+// OutputBin.
+//
-const char * /* O - output-bin or NULL */
+const char * // O - output-bin or NULL
ppdCacheGetBin(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- const char *output_bin) /* I - PPD OutputBin string */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ const char *output_bin) // I - PPD OutputBin string
{
- int i; /* Looping var */
+ int i; // Looping var
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+
if (!pc || !output_bin)
return (NULL);
- /*
- * Look up the OutputBin string...
- */
-
+ //
+ // Look up the OutputBin string...
+ //
for (i = 0; i < pc->num_bins; i ++)
- if (!_ppd_strcasecmp(output_bin, pc->bins[i].ppd) || !_ppd_strcasecmp(output_bin, pc->bins[i].pwg))
+ if (!_ppd_strcasecmp(output_bin, pc->bins[i].ppd) ||
+ !_ppd_strcasecmp(output_bin, pc->bins[i].pwg))
return (pc->bins[i].pwg);
return (NULL);
}
-/*
- * 'ppdCacheGetFinishingOptions()' - Get PPD finishing options for the given
- * IPP finishings value(s).
- */
+//
+// 'ppdCacheGetFinishingOptions()' - Get PPD finishing options for the given
+// IPP finishings value(s).
+//
-int /* O - New number of options */
+int // O - New number of options
ppdCacheGetFinishingOptions(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- ipp_t *job, /* I - Job attributes or NULL */
- ipp_finishings_t value, /* I - IPP finishings value of IPP_FINISHINGS_NONE */
- int num_options, /* I - Number of options */
- cups_option_t **options) /* IO - Options */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ ipp_t *job, // I - Job attributes or NULL
+ ipp_finishings_t value, // I - IPP finishings value of
+ // IPP_FINISHINGS_NONE
+ int num_options, // I - Number of options
+ cups_option_t **options) // IO - Options
{
- int i; /* Looping var */
- ppd_pwg_finishings_t *f, /* PWG finishings options */
- key; /* Search key */
- ipp_attribute_t *attr; /* Finishings attribute */
- cups_option_t *option; /* Current finishings option */
+ int i; // Looping var
+ ppd_pwg_finishings_t *f, // PWG finishings options
+ key; // Search key
+ ipp_attribute_t *attr; // Finishings attribute
+ cups_option_t *option; // Current finishings option
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || cupsArrayCount(pc->finishings) == 0 || !options ||
(!job && value == IPP_FINISHINGS_NONE))
return (num_options);
- /*
- * Apply finishing options...
- */
+ //
+ // Apply finishing options...
+ //
if (job && (attr = ippFindAttribute(job, "finishings", IPP_TAG_ENUM)) != NULL)
{
- int num_values = ippGetCount(attr); /* Number of values */
+ int num_values = ippGetCount(attr); // Number of values
for (i = 0; i < num_values; i ++)
{
if ((f = cupsArrayFind(pc->finishings, &key)) != NULL)
{
- int j; /* Another looping var */
+ int j; // Another looping var
for (j = f->num_options, option = f->options; j > 0; j --, option ++)
num_options = cupsAddOption(option->name, option->value,
if ((f = cupsArrayFind(pc->finishings, &key)) != NULL)
{
- int j; /* Another looping var */
+ int j; // Another looping var
for (j = f->num_options, option = f->options; j > 0; j --, option ++)
num_options = cupsAddOption(option->name, option->value,
}
-/*
- * 'ppdCacheGetFinishingValues()' - Get IPP finishings value(s) from the given
- * PPD options.
- */
+//
+// 'ppdCacheGetFinishingValues()' - Get IPP finishings value(s) from the given
+// PPD options.
+//
-int /* O - Number of finishings values */
+int // O - Number of finishings values
ppdCacheGetFinishingValues(
- ppd_file_t *ppd, /* I - Marked PPD file */
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- int max_values, /* I - Maximum number of finishings values */
- int *values) /* O - Finishings values */
+ ppd_file_t *ppd, // I - Marked PPD file
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ int max_values, // I - Maximum number of finishings values
+ int *values) // O - Finishings values
{
- int i, /* Looping var */
- num_values = 0; /* Number of values */
- ppd_pwg_finishings_t *f; /* Current finishings option */
- cups_option_t *option; /* Current option */
- ppd_choice_t *choice; /* Marked PPD choice */
+ int i, // Looping var
+ num_values = 0; // Number of values
+ ppd_pwg_finishings_t *f; // Current finishings option
+ cups_option_t *option; // Current option
+ ppd_choice_t *choice; // Marked PPD choice
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
- DEBUG_printf(("ppdCacheGetFinishingValues(ppd=%p, pc=%p, max_values=%d, values=%p)", ppd, pc, max_values, values));
+ DEBUG_printf(("ppdCacheGetFinishingValues(ppd=%p, pc=%p, max_values=%d, values=%p)",
+ ppd, pc, max_values, values));
if (!ppd || !pc || max_values < 1 || !values)
{
return (0);
}
- /*
- * Go through the finishings options and see what is set...
- */
+ //
+ // Go through the finishings options and see what is set...
+ //
for (f = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings);
f;
f = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings))
{
- DEBUG_printf(("ppdCacheGetFinishingValues: Checking %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value)));
+ DEBUG_printf(("ppdCacheGetFinishingValues: Checking %d (%s)",
+ (int)f->value, ippEnumString("finishings", (int)f->value)));
for (i = f->num_options, option = f->options; i > 0; i --, option ++)
{
- DEBUG_printf(("ppdCacheGetFinishingValues: %s=%s?", option->name, option->value));
+ DEBUG_printf(("ppdCacheGetFinishingValues: %s=%s?",
+ option->name, option->value));
- if ((choice = ppdFindMarkedChoice(ppd, option->name)) == NULL || _ppd_strcasecmp(option->value, choice->choice))
+ if ((choice = ppdFindMarkedChoice(ppd, option->name)) == NULL ||
+ _ppd_strcasecmp(option->value, choice->choice))
{
DEBUG_puts("ppdCacheGetFinishingValues: NO");
break;
if (i == 0)
{
- DEBUG_printf(("ppdCacheGetFinishingValues: Adding %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value)));
+ DEBUG_printf(("ppdCacheGetFinishingValues: Adding %d (%s)",
+ (int)f->value, ippEnumString("finishings", (int)f->value)));
values[num_values ++] = (int)f->value;
if (num_values == 0)
{
- /*
- * Always have at least "finishings" = 'none'...
- */
+ //
+ // Always have at least "finishings" = 'none'...
+ //
DEBUG_puts("ppdCacheGetFinishingValues: Adding 3 (none).");
values[0] = IPP_FINISHINGS_NONE;
}
-/*
- * 'ppdCacheGetInputSlot()' - Get the PPD InputSlot associated with the job
- * attributes or a keyword string.
- */
+//
+// 'ppdCacheGetInputSlot()' - Get the PPD InputSlot associated with the job
+// attributes or a keyword string.
+//
-const char * /* O - PPD InputSlot or NULL */
+const char * // O - PPD InputSlot or NULL
ppdCacheGetInputSlot(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- ipp_t *job, /* I - Job attributes or NULL */
- const char *keyword) /* I - Keyword string or NULL */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ ipp_t *job, // I - Job attributes or NULL
+ const char *keyword) // I - Keyword string or NULL
{
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || pc->num_sources == 0 || (!job && !keyword))
return (NULL);
if (job && !keyword)
{
- /*
- * Lookup the media-col attribute and any media-source found there...
- */
+ //
+ // Lookup the media-col attribute and any media-source found there...
+ //
- ipp_attribute_t *media_col, /* media-col attribute */
- *media_source; /* media-source attribute */
- pwg_size_t size; /* Dimensional size */
- int margins_set; /* Were the margins set? */
+ ipp_attribute_t *media_col, // media-col attribute
+ *media_source; // media-source attribute
+ pwg_size_t size; // Dimensional size
+ int margins_set; // Were the margins set?
media_col = ippFindAttribute(job, "media-col", IPP_TAG_BEGIN_COLLECTION);
if (media_col &&
"media-source",
IPP_TAG_KEYWORD)) != NULL)
{
- /*
- * Use the media-source value from media-col...
- */
+ //
+ // Use the media-source value from media-col...
+ //
keyword = ippGetString(media_source, 0, NULL);
}
else if (pwgInitSize(&size, job, &margins_set))
{
- /*
- * For media <= 5x7, look for a photo tray...
- */
+ //
+ // For media <= 5x7, look for a photo tray...
+ //
if (size.width <= (5 * 2540) && size.length <= (7 * 2540))
keyword = "photo";
if (keyword)
{
- int i; /* Looping var */
+ int i; // Looping var
for (i = 0; i < pc->num_sources; i ++)
if (!_ppd_strcasecmp(keyword, pc->sources[i].pwg))
}
-/*
- * 'ppdCacheGetMediaType()' - Get the PPD MediaType associated with the job
- * attributes or a keyword string.
- */
+//
+// 'ppdCacheGetMediaType()' - Get the PPD MediaType associated with the job
+// attributes or a keyword string.
+//
-const char * /* O - PPD MediaType or NULL */
+const char * // O - PPD MediaType or NULL
ppdCacheGetMediaType(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- ipp_t *job, /* I - Job attributes or NULL */
- const char *keyword) /* I - Keyword string or NULL */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ ipp_t *job, // I - Job attributes or NULL
+ const char *keyword) // I - Keyword string or NULL
{
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || pc->num_types == 0 || (!job && !keyword))
return (NULL);
if (job && !keyword)
{
- /*
- * Lookup the media-col attribute and any media-source found there...
- */
+ //
+ // Lookup the media-col attribute and any media-source found there...
+ //
- ipp_attribute_t *media_col, /* media-col attribute */
- *media_type; /* media-type attribute */
+ ipp_attribute_t *media_col, // media-col attribute
+ *media_type; // media-type attribute
media_col = ippFindAttribute(job, "media-col", IPP_TAG_BEGIN_COLLECTION);
if (media_col)
if (keyword)
{
- int i; /* Looping var */
+ int i; // Looping var
for (i = 0; i < pc->num_types; i ++)
if (!_ppd_strcasecmp(keyword, pc->types[i].pwg))
}
-/*
- * 'ppdCacheGetOutputBin()' - Get the PPD OutputBin associated with the keyword
- * string.
- */
+//
+// 'ppdCacheGetOutputBin()' - Get the PPD OutputBin associated with the keyword
+// string.
+//
-const char * /* O - PPD OutputBin or NULL */
+const char * // O - PPD OutputBin or NULL
ppdCacheGetOutputBin(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- const char *output_bin) /* I - Keyword string */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ const char *output_bin) // I - Keyword string
{
- int i; /* Looping var */
+ int i; // Looping var
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || !output_bin)
return (NULL);
- /*
- * Look up the OutputBin string...
- */
-
+ //
+ // Look up the OutputBin string...
+ //
for (i = 0; i < pc->num_bins; i ++)
if (!_ppd_strcasecmp(output_bin, pc->bins[i].pwg))
}
-/*
- * 'ppdCacheGetPageSize()' - Get the PPD PageSize associated with the job
- * attributes or a keyword string.
- */
+//
+// 'ppdCacheGetPageSize()' - Get the PPD PageSize associated with the job
+// attributes or a keyword string.
+//
-const char * /* O - PPD PageSize or NULL */
+const char * // O - PPD PageSize or NULL
ppdCacheGetPageSize(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- ipp_t *job, /* I - Job attributes or NULL */
- const char *keyword, /* I - Keyword string or NULL */
- int *exact) /* O - 1 if exact match, 0 otherwise */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ ipp_t *job, // I - Job attributes or NULL
+ const char *keyword, // I - Keyword string or NULL
+ int *exact) // O - 1 if exact match, 0 otherwise
{
- int i, j; /* Looping vars */
- pwg_size_t *size, /* Current size */
- *variant, /* Page size variant */
- *closest, /* Closest size */
- jobsize; /* Size data from job */
- int margins_set, /* Were the margins set? */
- dwidth, /* Difference in width */
- dlength, /* Difference in length */
- dleft, /* Difference in left margins */
- dright, /* Difference in right margins */
- dbottom, /* Difference in bottom margins */
- dtop, /* Difference in top margins */
- dmin, /* Minimum difference */
- dclosest; /* Closest difference */
- const char *ppd_name; /* PPD media name */
+ int i, j; // Looping vars
+ pwg_size_t *size, // Current size
+ *variant, // Page size variant
+ *closest, // Closest size
+ jobsize; // Size data from job
+ int margins_set, // Were the margins set?
+ dwidth, // Difference in width
+ dlength, // Difference in length
+ dleft, // Difference in left margins
+ dright, // Difference in right margins
+ dbottom, // Difference in bottom margins
+ dtop, // Difference in top margins
+ dmin, // Minimum difference
+ dclosest; // Closest difference
+ const char *ppd_name; // PPD media name
DEBUG_printf(("ppdCacheGetPageSize(pc=%p, job=%p, keyword=\"%s\", exact=%p)",
pc, job, keyword, exact));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || (!job && !keyword))
return (NULL);
if (job)
{
- /*
- * Try getting the PPD media name from the job attributes...
- */
+ //
+ // Try getting the PPD media name from the job attributes...
+ //
- ipp_attribute_t *attr; /* Job attribute */
+ ipp_attribute_t *attr; // Job attribute
if ((attr = ippFindAttribute(job, "PageSize", IPP_TAG_ZERO)) == NULL)
if ((attr = ippFindAttribute(job, "PageRegion", IPP_TAG_ZERO)) == NULL)
ippGetName(attr), ippTagString(ippGetValueTag(attr))));
else
DEBUG_puts("1ppdCacheGetPageSize: Did not find media attribute.");
-#endif /* DEBUG */
+#endif // DEBUG
if (attr && (ippGetValueTag(attr) == IPP_TAG_NAME ||
ippGetValueTag(attr) == IPP_TAG_KEYWORD))
if (ppd_name)
{
- /*
- * Try looking up the named PPD size first...
- */
+ //
+ // Try looking up the named PPD size first...
+ //
for (i = pc->num_sizes, size = pc->sizes; i > 0; i --, size ++)
{
if (job && !keyword)
{
- /*
- * Get the size using media-col or media, with the preference being
- * media-col.
- */
+ //
+ // Get the size using media-col or media, with the preference being
+ // media-col.
+ //
if (!pwgInitSize(&jobsize, job, &margins_set))
return (NULL);
}
else
{
- /*
- * Get the size using a media keyword...
- */
+ //
+ // Get the size using a media keyword...
+ //
- pwg_media_t *media; /* Media definition */
+ pwg_media_t *media; // Media definition
if ((media = pwgMediaForPWG(keyword)) == NULL)
margins_set = 0;
}
- /*
- * Now that we have the dimensions and possibly the margins, look at the
- * available sizes and find the match...
- */
+ //
+ // Now that we have the dimensions and possibly the margins, look at the
+ // available sizes and find the match...
+ //
closest = NULL;
dclosest = dmin = 999999999;
{
for (i = pc->num_sizes, size = pc->sizes; i > 0; i --, size ++)
{
- /*
- * Adobe uses a size matching algorithm with an epsilon of 5 points, which
- * is just about 176/2540ths...
- */
+ //
+ // Adobe uses a size matching algorithm with an epsilon of 5 points, which
+ // is just about 176/2540ths...
+ //
dwidth = size->width - jobsize.width;
dlength = size->length - jobsize.length;
if (margins_set)
{
- /*
- * Check not only the base size (like "A4") but also variants (like
- * "A4.Borderless"). We check only the margins and orientation but do
- * not re-check the size.
- */
+ //
+ // Check not only the base size (like "A4") but also variants (like
+ // "A4.Borderless"). We check only the margins and orientation but do
+ // not re-check the size.
+ //
+
for (j = pc->num_sizes, variant = pc->sizes; j > 0; j --, variant ++)
{
if (!strcmp(size->map.ppd, variant->map.ppd) ||
(strlen(variant->map.ppd) > strlen(size->map.ppd) + 1) &&
variant->map.ppd[strlen(size->map.ppd)] == '.'))
{
- /*
- * Found a variant (or the base size)
- */
+ //
+ // Found a variant (or the base size)
+ //
- /*
- * First check orientation (we do not want ".Transverse" variants)
- */
+ //
+ // First check orientation (we do not want ".Transverse" variants)
+ //
if ((size->length - size->width) *
(variant->length - variant->width) < 0)
continue;
- /*
- * Borderless page size variant, use it only if the job requests
- * borderless
- */
+ //
+ // Borderless page size variant, use it only if the job requests
+ // borderless
+ //
if (strchr(variant->map.ppd, '.') &&
variant->left == 0 && variant->right == 0 &&
jobsize.top != 0 || jobsize.bottom != 0))
continue;
- /*
- * Use a tighter epsilon of 1 point (35/2540ths) for margins...
- */
+ //
+ // Use a tighter epsilon of 1 point (35/2540ths) for margins...
+ //
dleft = variant->left - jobsize.left;
dright = variant->right - jobsize.right;
dright = dright < 0 ? -dright : dright;
dbottom = dbottom < 0 ? -dbottom : dbottom;
dtop = dtop < 0 ? -dtop : dtop;
- /* In the sum we do a slight penalization of the variants to
- prefer the base if it has the same margins) */
+ // In the sum we do a slight penalization of the variants to
+ // prefer the base if it has the same margins)
dmin = dleft + dright + dbottom + dtop +
(strchr(variant->map.ppd, '.') ? 1 : 0);
return (closest->map.ppd);
}
- /*
- * If we get here we need to check for custom page size support...
- */
+ //
+ // If we get here we need to check for custom page size support...
+ //
if (jobsize.width >= pc->custom_min_width &&
jobsize.width <= pc->custom_max_width &&
jobsize.length >= pc->custom_min_length &&
jobsize.length <= pc->custom_max_length)
{
- /*
- * In range, format as Custom.WWWWxLLLL (points).
- */
+ //
+ // In range, format as Custom.WWWWxLLLL (points).
+ //
snprintf(pc->custom_ppd_size, sizeof(pc->custom_ppd_size), "Custom.%dx%d",
- (int)PWG_TO_POINTS(jobsize.width), (int)PWG_TO_POINTS(jobsize.length));
+ (int)PWG_TO_POINTS(jobsize.width),
+ (int)PWG_TO_POINTS(jobsize.length));
if (margins_set && exact)
{
return (pc->custom_ppd_size);
}
- /*
- * No custom page size support or the size is out of range - return NULL.
- */
+ //
+ // No custom page size support or the size is out of range - return NULL.
+ //
DEBUG_puts("1ppdCacheGetPageSize: Returning NULL");
}
-/*
- * 'ppdCacheGetSize()' - Get the PWG size associated with a PPD PageSize.
- */
+//
+// 'ppdCacheGetSize()' - Get the PWG size associated with a PPD PageSize.
+//
-pwg_size_t * /* O - PWG size or NULL */
+pwg_size_t * // O - PWG size or NULL
ppdCacheGetSize(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- const char *page_size) /* I - PPD PageSize */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ const char *page_size) // I - PPD PageSize
{
- int i; /* Looping var */
- pwg_media_t *media; /* Media */
- pwg_size_t *size; /* Current size */
+ int i; // Looping var
+ pwg_media_t *media; // Media
+ pwg_size_t *size; // Current size
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || !page_size)
return (NULL);
if (!_ppd_strncasecmp(page_size, "Custom.", 7))
{
- /*
- * Custom size; size name can be one of the following:
- *
- * Custom.WIDTHxLENGTHin - Size in inches
- * Custom.WIDTHxLENGTHft - Size in feet
- * Custom.WIDTHxLENGTHcm - Size in centimeters
- * Custom.WIDTHxLENGTHmm - Size in millimeters
- * Custom.WIDTHxLENGTHm - Size in meters
- * Custom.WIDTHxLENGTH[pt] - Size in points
- */
-
- double w, l; /* Width and length of page */
- char *ptr; /* Pointer into PageSize */
- struct lconv *loc; /* Locale data */
+ //
+ // Custom size; size name can be one of the following:
+ //
+ // Custom.WIDTHxLENGTHin - Size in inches
+ // Custom.WIDTHxLENGTHft - Size in feet
+ // Custom.WIDTHxLENGTHcm - Size in centimeters
+ // Custom.WIDTHxLENGTHmm - Size in millimeters
+ // Custom.WIDTHxLENGTHm - Size in meters
+ // Custom.WIDTHxLENGTH[pt] - Size in points
+ //
+
+ double w, l; // Width and length of page
+ char *ptr; // Pointer into PageSize
+ struct lconv *loc; // Locale data
loc = localeconv();
w = (float)_ppdStrScand(page_size + 7, &ptr, loc);
return (&(pc->custom_size));
}
- /*
- * Not a custom size - look it up...
- */
+ //
+ // Not a custom size - look it up...
+ //
for (i = pc->num_sizes, size = pc->sizes; i > 0; i --, size ++)
if (!_ppd_strcasecmp(page_size, size->map.ppd) ||
!_ppd_strcasecmp(page_size, size->map.pwg))
return (size);
- /*
- * Look up standard sizes...
- */
+ //
+ // Look up standard sizes...
+ //
if ((media = pwgMediaForPPD(page_size)) == NULL)
if ((media = pwgMediaForLegacy(page_size)) == NULL)
}
-/*
- * 'ppdCacheGetSource()' - Get the PWG media-source associated with a PPD
- * InputSlot.
- */
+//
+// 'ppdCacheGetSource()' - Get the PWG media-source associated with a PPD
+// InputSlot.
+//
-const char * /* O - PWG media-source keyword */
+const char * // O - PWG media-source keyword
ppdCacheGetSource(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- const char *input_slot) /* I - PPD InputSlot */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ const char *input_slot) // I - PPD InputSlot
{
- int i; /* Looping var */
- pwg_map_t *source; /* Current source */
+ int i; // Looping var
+ pwg_map_t *source; // Current source
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || !input_slot)
return (NULL);
for (i = pc->num_sources, source = pc->sources; i > 0; i --, source ++)
- if (!_ppd_strcasecmp(input_slot, source->ppd) || !_ppd_strcasecmp(input_slot, source->pwg))
+ if (!_ppd_strcasecmp(input_slot, source->ppd) ||
+ !_ppd_strcasecmp(input_slot, source->pwg))
return (source->pwg);
return (NULL);
}
-/*
- * 'ppdCacheGetType()' - Get the PWG media-type associated with a PPD
- * MediaType.
- */
+//
+// 'ppdCacheGetType()' - Get the PWG media-type associated with a PPD
+// MediaType.
+//
-const char * /* O - PWG media-type keyword */
+const char * // O - PWG media-type keyword
ppdCacheGetType(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- const char *media_type) /* I - PPD MediaType */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ const char *media_type) // I - PPD MediaType
{
- int i; /* Looping var */
- pwg_map_t *type; /* Current type */
+ int i; // Looping var
+ pwg_map_t *type; // Current type
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || !media_type)
return (NULL);
for (i = pc->num_types, type = pc->types; i > 0; i --, type ++)
- if (!_ppd_strcasecmp(media_type, type->ppd) || !_ppd_strcasecmp(media_type, type->pwg))
+ if (!_ppd_strcasecmp(media_type, type->ppd) ||
+ !_ppd_strcasecmp(media_type, type->pwg))
return (type->pwg);
return (NULL);
}
-/*
- * 'ppdCacheWriteFile()' - Write PWG mapping data to a file.
- */
+//
+// 'ppdCacheWriteFile()' - Write PWG mapping data to a file.
+//
-int /* O - 1 on success, 0 on failure */
+int // O - 1 on success, 0 on failure
ppdCacheWriteFile(
- ppd_cache_t *pc, /* I - PPD cache and mapping data */
- const char *filename, /* I - File to write */
- ipp_t *attrs) /* I - Attributes to write, if any */
+ ppd_cache_t *pc, // I - PPD cache and mapping data
+ const char *filename, // I - File to write
+ ipp_t *attrs) // I - Attributes to write, if any
{
- int i, j, k; /* Looping vars */
- cups_file_t *fp; /* Output file */
- pwg_size_t *size; /* Current size */
- pwg_map_t *map; /* Current map */
- ppd_pwg_finishings_t *f; /* Current finishing option */
- cups_option_t *option; /* Current option */
- const char *value; /* String value */
- char newfile[1024]; /* New filename */
+ int i, j, k; // Looping vars
+ cups_file_t *fp; // Output file
+ pwg_size_t *size; // Current size
+ pwg_map_t *map; // Current map
+ ppd_pwg_finishings_t *f; // Current finishing option
+ cups_option_t *option; // Current option
+ const char *value; // String value
+ char newfile[1024]; // New filename
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!pc || !filename)
{
return (0);
}
- /*
- * Open the file and write with compression...
- */
+ //
+ // Open the file and write with compression...
+ //
snprintf(newfile, sizeof(newfile), "%s.N", filename);
if ((fp = cupsFileOpen(newfile, "w9")) == NULL)
return (0);
}
- /*
- * Standard header...
- */
+ //
+ // Standard header...
+ //
cupsFilePrintf(fp, "#CUPS-PPD-CACHE-%d\n", PPD_CACHE_VERSION);
- /*
- * Output bins...
- */
+ //
+ // Output bins...
+ //
if (pc->num_bins > 0)
{
cupsFilePrintf(fp, "Bin %s %s\n", map->pwg, map->ppd);
}
- /*
- * Media sizes...
- */
+ //
+ // Media sizes...
+ //
cupsFilePrintf(fp, "NumSizes %d\n", pc->num_sizes);
for (i = pc->num_sizes, size = pc->sizes; i > 0; i --, size ++)
pc->custom_size.left, pc->custom_size.bottom,
pc->custom_size.right, pc->custom_size.top);
- /*
- * Media sources...
- */
+ //
+ // Media sources...
+ //
if (pc->source_option)
cupsFilePrintf(fp, "SourceOption %s\n", pc->source_option);
cupsFilePrintf(fp, "Source %s %s\n", map->pwg, map->ppd);
}
- /*
- * Media types...
- */
+ //
+ // Media types...
+ //
if (pc->num_types > 0)
{
cupsFilePrintf(fp, "Type %s %s\n", map->pwg, map->ppd);
}
- /*
- * Presets...
- */
+ //
+ // Presets...
+ //
- for (i = PPD_PWG_PRINT_COLOR_MODE_MONOCHROME; i < PPD_PWG_PRINT_COLOR_MODE_MAX; i ++)
+ for (i = PPD_PWG_PRINT_COLOR_MODE_MONOCHROME;
+ i < PPD_PWG_PRINT_COLOR_MODE_MAX; i ++)
for (j = PPD_PWG_PRINT_QUALITY_DRAFT; j < PPD_PWG_PRINT_QUALITY_MAX; j ++)
if (pc->num_presets[i][j])
{
cupsFilePutChar(fp, '\n');
}
- /*
- * Optimization Presets...
- */
+ //
+ // Optimization Presets...
+ //
- for (i = PPD_PWG_PRINT_CONTENT_OPTIMIZE_AUTO; i < PPD_PWG_PRINT_CONTENT_OPTIMIZE_MAX; i ++)
+ for (i = PPD_PWG_PRINT_CONTENT_OPTIMIZE_AUTO;
+ i < PPD_PWG_PRINT_CONTENT_OPTIMIZE_MAX; i ++)
if (pc->num_optimize_presets[i])
{
cupsFilePrintf(fp, "OptimizePreset %d", i);
cupsFilePutChar(fp, '\n');
}
- /*
- * Duplex/sides...
- */
+ //
+ // Duplex/sides...
+ //
if (pc->sides_option)
cupsFilePrintf(fp, "SidesOption %s\n", pc->sides_option);
if (pc->sides_2sided_short)
cupsFilePrintf(fp, "Sides2SidedShort %s\n", pc->sides_2sided_short);
- /*
- * Product, cupsFilter, cupsFilter2, and cupsPreFilter...
- */
+ //
+ // Product, cupsFilter, cupsFilter2, and cupsPreFilter...
+ //
if (pc->product)
cupsFilePutConf(fp, "Product", pc->product);
cupsFilePrintf(fp, "SingleFile %s\n", pc->single_file ? "true" : "false");
- /*
- * Finishing options...
- */
+ //
+ // Finishing options...
+ //
for (f = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings);
f;
for (value = (const char *)cupsArrayFirst(pc->templates); value; value = (const char *)cupsArrayNext(pc->templates))
cupsFilePutConf(fp, "FinishingTemplate", value);
- /*
- * Max copies...
- */
+ //
+ // Max copies...
+ //
cupsFilePrintf(fp, "MaxCopies %d\n", pc->max_copies);
- /*
- * Accounting/quota/PIN/managed printing values...
- */
+ //
+ // Accounting/quota/PIN/managed printing values...
+ //
if (pc->charge_info_uri)
cupsFilePutConf(fp, "ChargeInfoURI", pc->charge_info_uri);
value = (char *)cupsArrayNext(pc->mandatory))
cupsFilePutConf(fp, "Mandatory", value);
- /*
- * Support files...
- */
+ //
+ // Support files...
+ //
for (value = (char *)cupsArrayFirst(pc->support_files);
value;
value = (char *)cupsArrayNext(pc->support_files))
cupsFilePutConf(fp, "SupportFile", value);
- /*
- * IPP attributes, if any...
- */
+ //
+ // IPP attributes, if any...
+ //
if (attrs)
{
ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL, attrs);
}
- /*
- * Close and return...
- */
+ //
+ // Close and return...
+ //
if (cupsFileClose(fp))
{
}
-/*
- * 'ppdPwgInputSlotForSource()' - Get the InputSlot name for the given PWG
- * media-source.
- */
+//
+// 'ppdPwgInputSlotForSource()' - Get the InputSlot name for the given PWG
+// media-source.
+//
-const char * /* O - InputSlot name */
+const char * // O - InputSlot name
ppdPwgInputSlotForSource(
- const char *media_source, /* I - PWG media-source */
- char *name, /* I - Name buffer */
- size_t namesize) /* I - Size of name buffer */
+ const char *media_source, // I - PWG media-source
+ char *name, // I - Name buffer
+ size_t namesize) // I - Size of name buffer
{
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!media_source || !name || namesize < PPD_MAX_NAME)
return (NULL);
}
-/*
- * 'ppdPwgMediaTypeForType()' - Get the MediaType name for the given PWG
- * media-type.
- */
+//
+// 'ppdPwgMediaTypeForType()' - Get the MediaType name for the given PWG
+// media-type.
+//
-const char * /* O - MediaType name */
+const char * // O - MediaType name
ppdPwgMediaTypeForType(
- const char *media_type, /* I - PWG media-type */
- char *name, /* I - Name buffer */
- size_t namesize) /* I - Size of name buffer */
+ const char *media_type, // I - PWG media-type
+ char *name, // I - Name buffer
+ size_t namesize) // I - Size of name buffer
{
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!media_type || !name || namesize < PPD_MAX_NAME)
return (NULL);
}
-/*
- * 'ppdPwgPageSizeForMedia()' - Get the PageSize name for the given media.
- */
+//
+// 'ppdPwgPageSizeForMedia()' - Get the PageSize name for the given media.
+//
-const char * /* O - PageSize name */
+const char * // O - PageSize name
ppdPwgPageSizeForMedia(
- pwg_media_t *media, /* I - Media */
- char *name, /* I - PageSize name buffer */
- size_t namesize) /* I - Size of name buffer */
+ pwg_media_t *media, // I - Media
+ char *name, // I - PageSize name buffer
+ size_t namesize) // I - Size of name buffer
{
- const char *sizeptr, /* Pointer to size in PWG name */
- *dimptr; /* Pointer to dimensions in PWG name */
+ const char *sizeptr, // Pointer to size in PWG name
+ *dimptr; // Pointer to dimensions in PWG name
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!media || !name || namesize < PPD_MAX_NAME)
return (NULL);
- /*
- * Copy or generate a PageSize name...
- */
+ //
+ // Copy or generate a PageSize name...
+ //
if (media->ppd)
{
- /*
- * Use a standard Adobe name...
- */
+ //
+ // Use a standard Adobe name...
+ //
strlcpy(name, media->ppd, namesize);
}
(dimptr = strchr(sizeptr + 1, '_')) == NULL ||
(size_t)(dimptr - sizeptr) > namesize)
{
- /*
- * Use a name of the form "wNNNhNNN"...
- */
+ //
+ // Use a name of the form "wNNNhNNN"...
+ //
snprintf(name, namesize, "w%dh%d", (int)PWG_TO_POINTS(media->width),
(int)PWG_TO_POINTS(media->length));
}
else
{
- /*
- * Copy the size name from class_sizename_dimensions...
- */
+ //
+ // Copy the size name from class_sizename_dimensions...
+ //
memcpy(name, sizeptr + 1, (size_t)(dimptr - sizeptr - 1));
name[dimptr - sizeptr - 1] = '\0';
}
-/*
- * 'ppd_pwg_add_finishing()' - Add a finishings value.
- */
+//
+// 'ppd_pwg_add_finishing()' - Add a finishings value.
+//
static void
ppd_pwg_add_finishing(
- cups_array_t *finishings, /* I - Finishings array */
- ipp_finishings_t template, /* I - Finishing template */
- const char *name, /* I - PPD option */
- const char *value) /* I - PPD choice */
+ cups_array_t *finishings, // I - Finishings array
+ ipp_finishings_t template, // I - Finishing template
+ const char *name, // I - PPD option
+ const char *value) // I - PPD choice
{
- ppd_pwg_finishings_t *f; /* New finishings value */
+ ppd_pwg_finishings_t *f; // New finishings value
- if ((f = (ppd_pwg_finishings_t *)calloc(1, sizeof(ppd_pwg_finishings_t))) != NULL)
+ if ((f = (ppd_pwg_finishings_t *)calloc(1, sizeof(ppd_pwg_finishings_t))) !=
+ NULL)
{
f->value = template;
f->num_options = cupsAddOption(name, value, 0, &f->options);
}
-/*
- * 'ppd_pwg_add_message()' - Add a message to the PPD cached strings.
- */
+//
+// 'ppd_pwg_add_message()' - Add a message to the PPD cached strings.
+//
static void
-ppd_pwg_add_message(cups_array_t *a, /* I - Message catalog */
- const char *msg, /* I - Message identifier */
- const char *str) /* I - Localized string */
+ppd_pwg_add_message(cups_array_t *a, // I - Message catalog
+ const char *msg, // I - Message identifier
+ const char *str) // I - Localized string
{
- _ppd_message_t *m; /* New message */
+ _ppd_message_t *m; // New message
if ((m = calloc(1, sizeof(_ppd_message_t))) != NULL)
}
-/*
- * 'ppd_pwg_compare_finishings()' - Compare two finishings values.
- */
+//
+// 'ppd_pwg_compare_finishings()' - Compare two finishings values.
+//
-static int /* O - Result of comparison */
+static int // O - Result of comparison
ppd_pwg_compare_finishings(
- ppd_pwg_finishings_t *a, /* I - First finishings value */
- ppd_pwg_finishings_t *b) /* I - Second finishings value */
+ ppd_pwg_finishings_t *a, // I - First finishings value
+ ppd_pwg_finishings_t *b) // I - Second finishings value
{
return ((int)b->value - (int)a->value);
}
-/*
- * 'ppd_pwg_free_finishings()' - Free a finishings value.
- */
+//
+// 'ppd_pwg_free_finishings()' - Free a finishings value.
+//
static void
ppd_pwg_free_finishings(
- ppd_pwg_finishings_t *f) /* I - Finishings value */
+ ppd_pwg_finishings_t *f) // I - Finishings value
{
cupsFreeOptions(f->num_options, f->options);
free(f);
}
-/*
- * 'ppdPwgPpdizeName()' - Convert an IPP keyword to a PPD keyword.
- */
+//
+// 'ppdPwgPpdizeName()' - Convert an IPP keyword to a PPD keyword.
+//
void
-ppdPwgPpdizeName(const char *ipp, /* I - IPP keyword */
- char *name, /* I - Name buffer */
- size_t namesize) /* I - Size of name buffer */
+ppdPwgPpdizeName(const char *ipp, // I - IPP keyword
+ char *name, // I - Name buffer
+ size_t namesize) // I - Size of name buffer
{
- char *ptr, /* Pointer into name buffer */
- *end; /* End of name buffer */
+ char *ptr, // Pointer into name buffer
+ *end; // End of name buffer
if (!ipp)
}
-/*
- * 'ppdPwgPpdizeResolution()' - Convert PWG resolution values to PPD values.
- */
+//
+// 'ppdPwgPpdizeResolution()' - Convert PWG resolution values to PPD values.
+//
void
ppdPwgPpdizeResolution(
- ipp_attribute_t *attr, /* I - Attribute to convert */
- int element, /* I - Element to convert */
- int *xres, /* O - X resolution in DPI */
- int *yres, /* O - Y resolution in DPI */
- char *name, /* I - Name buffer */
- size_t namesize) /* I - Size of name buffer */
+ ipp_attribute_t *attr, // I - Attribute to convert
+ int element, // I - Element to convert
+ int *xres, // O - X resolution in DPI
+ int *yres, // O - Y resolution in DPI
+ char *name, // I - Name buffer
+ size_t namesize) // I - Size of name buffer
{
- ipp_res_t units; /* Units for resolution */
+ ipp_res_t units; // Units for resolution
*xres = ippGetResolution(attr, element, yres, &units);
}
-/*
- * 'ppdPwgUnppdizeName()' - Convert a PPD keyword to a lowercase IPP keyword.
- */
+//
+// 'ppdPwgUnppdizeName()' - Convert a PPD keyword to a lowercase IPP keyword.
+//
void
-ppdPwgUnppdizeName(const char *ppd, /* I - PPD keyword */
- char *name, /* I - Name buffer */
- size_t namesize, /* I - Size of name buffer */
- const char *dashchars)/* I - Characters to be replaced by
- dashes or NULL to replace all
- non-alphanumeric characters */
+ppdPwgUnppdizeName(const char *ppd, // I - PPD keyword
+ char *name, // I - Name buffer
+ size_t namesize, // I - Size of name buffer
+ const char *dashchars)// I - Characters to be replaced by
+ // dashes or NULL to replace all
+ // non-alphanumeric characters
{
- char *ptr, /* Pointer into name buffer */
- *end; /* End of name buffer */
- int nodash = 1; /* Next char in IPP name cannot be a
- dash (first char or after a dash) */
+ char *ptr, // Pointer into name buffer
+ *end; // End of name buffer
+ int nodash = 1; // Next char in IPP name cannot be a
+ // dash (first char or after a dash)
int firstchar = 1;
if (_ppd_islower(*ppd))
{
- /*
- * Already lowercase name, use as-is?
- */
+ //
+ // Already lowercase name, use as-is?
+ //
- const char *ppdptr; /* Pointer into PPD keyword */
+ const char *ppdptr; // Pointer into PPD keyword
for (ppdptr = ppd + 1; *ppdptr; ppdptr ++)
if (_ppd_isupper(*ppdptr) ||
firstchar = 0;
}
- /* Remove trailing dashes */
+ // Remove trailing dashes
while (ptr > name && *(ptr - 1) == '-')
ptr --;
-/*
- * PPD collection support for cups-filters
- *
- * This program handles listing and installing static PPD files, PPD files
- * created from driver information files, and dynamically generated PPD files
- * using driver helper programs.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// PPD collection support for libppd.
+//
+// This program handles listing and installing static PPD files, PPD files
+// created from driver information files, and dynamically generated PPD files
+// using driver helper programs.
+//
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include <cups/dir.h>
#include <cups/transcode.h>
#include <sys/wait.h>
-/*
- * Constants...
- */
+//
+// Constants...
+//
-#define TAR_BLOCK 512 /* Number of bytes in a block */
-#define TAR_BLOCKS 10 /* Blocking factor */
+#define TAR_BLOCK 512 // Number of bytes in a block
+#define TAR_BLOCKS 10 // Blocking factor
-#define TAR_MAGIC "ustar" /* 5 chars and a null */
-#define TAR_VERSION "00" /* POSIX tar version */
+#define TAR_MAGIC "ustar" // 5 chars and a null
+#define TAR_VERSION "00" // POSIX tar version
#define TAR_OLDGNU_MAGIC "ustar "
-#define TAR_OLDNORMAL '\0' /* Normal disk file, Unix compat */
-#define TAR_NORMAL '0' /* Normal disk file */
-#define TAR_LINK '1' /* Link to previously dumped file */
-#define TAR_SYMLINK '2' /* Symbolic link */
-#define TAR_CHR '3' /* Character special file */
-#define TAR_BLK '4' /* Block special file */
-#define TAR_DIR '5' /* Directory */
-#define TAR_FIFO '6' /* FIFO special file */
-#define TAR_CONTIG '7' /* Contiguous file */
+#define TAR_OLDNORMAL '\0' // Normal disk file, Unix compat
+#define TAR_NORMAL '0' // Normal disk file
+#define TAR_LINK '1' // Link to previously dumped file
+#define TAR_SYMLINK '2' // Symbolic link
+#define TAR_CHR '3' // Character special file
+#define TAR_BLK '4' // Block special file
+#define TAR_DIR '5' // Directory
+#define TAR_FIFO '6' // FIFO special file
+#define TAR_CONTIG '7' // Contiguous file
-/*
- * PPD information structures...
- */
+//
+// PPD information structures...
+//
-typedef union /**** TAR record format ****/
+typedef union // **** TAR record format ****
{
- unsigned char all[TAR_BLOCK]; /* Raw data block */
+ unsigned char all[TAR_BLOCK]; // Raw data block
struct
{
- char pathname[100], /* Destination path */
- mode[8], /* Octal file permissions */
- uid[8], /* Octal user ID */
- gid[8], /* Octal group ID */
- size[12], /* Octal size in bytes */
- mtime[12], /* Octal modification time */
- chksum[8], /* Octal checksum value */
- linkflag, /* File type */
- linkname[100], /* Source path for link */
- magic[6], /* Magic string */
- version[2], /* Format version */
- uname[32], /* User name */
- gname[32], /* Group name */
- devmajor[8], /* Octal device major number */
- devminor[8], /* Octal device minor number */
- prefix[155]; /* Prefix for long filenames */
+ char pathname[100], // Destination path
+ mode[8], // Octal file permissions
+ uid[8], // Octal user ID
+ gid[8], // Octal group ID
+ size[12], // Octal size in bytes
+ mtime[12], // Octal modification time
+ chksum[8], // Octal checksum value
+ linkflag, // File type
+ linkname[100], // Source path for link
+ magic[6], // Magic string
+ version[2], // Format version
+ uname[32], // User name
+ gname[32], // Group name
+ devmajor[8], // Octal device major number
+ devminor[8], // Octal device minor number
+ prefix[155]; // Prefix for long filenames
} header;
} tar_rec_t;
typedef struct
{
- cups_array_t *Inodes; /* Inodes of directories we've visited*/
+ cups_array_t *Inodes; // Inodes of directories we've visited
cups_array_t *PPDsByName,
- /* PPD files sorted by filename and name */
+ // PPD files sorted by filename and name
*PPDsByMakeModel;
- /* PPD files sorted by make and model */
- int ChangedPPD; /* Did we change the PPD database? */
+ // PPD files sorted by make and model
+ int ChangedPPD; // Did we change the PPD database?
} ppd_list_t;
//typedef int (*cupsd_compare_func_t)(const void *, const void *);
-/*
- * Globals...
- */
+//
+// Globals...
+//
-static const char * const PPDTypes[] = /* ppd-type values */
+static const char * const PPDTypes[] = // ppd-type values
{
"postscript",
"pdf",
};
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static ppd_info_t *add_ppd(const char *filename, const char *name,
const char *language, const char *make,
cf_logfunc_t log, void *ld);
-/*
- * 'ppdCollectionListPPDs()' - List PPD files.
- */
+//
+// 'ppdCollectionListPPDs()' - List PPD files.
+//
-cups_array_t * /* O - List of PPD files */
+cups_array_t * // O - List of PPD files
ppdCollectionListPPDs(
- cups_array_t *ppd_collections, /* I - Directories to search for PPDs
- in */
- int limit, /* I - Limit */
- int num_options, /* I - Number of options */
- cups_option_t *options, /* I - Options */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ cups_array_t *ppd_collections, // I - Directories to search for PPDs
+ // in
+ int limit, // I - Limit
+ int num_options, // I - Number of options
+ cups_option_t *options, // I - Options
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- int i; /* Looping var */
- ppd_collection_t *col; /* Pointer to PPD collection */
- int count; /* Number of PPDs to list */
- ppd_info_t *ppd, /* Current PPD file */
- *newppd; /* Copy of current PPD */
- cups_file_t *fp; /* ppds.dat file */
- cups_array_t *include, /* PPD schemes to include */
- *exclude; /* PPD schemes to exclude */
- const char *cachename, /* Cache file name */
- *only_makes, /* Do we only want a list of makes? */
- *device_id, /* ppd-device-id option */
- *language, /* ppd-natural-language option */
- *make, /* ppd-make option */
- *make_and_model, /* ppd-make-and-model option */
- *model_number_str, /* ppd-model-number option */
- *product, /* ppd-product option */
- *psversion, /* ppd-psversion option */
- *type_str; /* ppd-type option */
- int model_number, /* ppd-model-number value */
- type; /* ppd-type value */
- size_t make_and_model_len, /* Length of ppd-make-and-model */
- product_len; /* Length of ppd-product */
- regex_t *device_id_re, /* Regular expression for matching
- device ID */
- *make_and_model_re; /* Regular expression for matching make
- and model */
- regmatch_t re_matches[6]; /* Regular expression matches */
- cups_array_t *matches, /* Matching PPDs */
- *result; /* Resulting PPD list */
- ppd_list_t ppdlist; /* Lists of all available PPDs */
+ int i; // Looping var
+ ppd_collection_t *col; // Pointer to PPD collection
+ int count; // Number of PPDs to list
+ ppd_info_t *ppd, // Current PPD file
+ *newppd; // Copy of current PPD
+ cups_file_t *fp; // ppds.dat file
+ cups_array_t *include, // PPD schemes to include
+ *exclude; // PPD schemes to exclude
+ const char *cachename, // Cache file name
+ *only_makes, // Do we only want a list of makes?
+ *device_id, // ppd-device-id option
+ *language, // ppd-natural-language option
+ *make, // ppd-make option
+ *make_and_model, // ppd-make-and-model option
+ *model_number_str, // ppd-model-number option
+ *product, // ppd-product option
+ *psversion, // ppd-psversion option
+ *type_str; // ppd-type option
+ int model_number, // ppd-model-number value
+ type; // ppd-type value
+ size_t make_and_model_len, // Length of ppd-make-and-model
+ product_len; // Length of ppd-product
+ regex_t *device_id_re, // Regular expression for matching
+ // device ID
+ *make_and_model_re; // Regular expression for matching make
+ // and model
+ regmatch_t re_matches[6]; // Regular expression matches
+ cups_array_t *matches, // Matching PPDs
+ *result; // Resulting PPD list
+ ppd_list_t ppdlist; // Lists of all available PPDs
int matches_array_created = 0;
- /*
- * Initialize PPD list...
- */
+ //
+ // Initialize PPD list...
+ //
ppdlist.PPDsByName = cupsArrayNew((cups_array_func_t)compare_names,
NULL);
ppdlist.ChangedPPD = 0;
- /*
- * See if we have a PPD database file...
- */
+ //
+ // See if we have a PPD database file...
+ //
cachename = cupsGetOption("ppd-cache", num_options, options);
if (cachename && cachename[0] &&
- load_ppds_dat(cachename, 1, &ppdlist, log, ld)) {
+ load_ppds_dat(cachename, 1, &ppdlist, log, ld))
+ {
free_ppdlist(&ppdlist);
return(NULL);
}
- /*
- * Load all PPDs in the specified directories and below...
- */
+ //
+ // Load all PPDs in the specified directories and below...
+ //
ppdlist.Inodes = cupsArrayNew((cups_array_func_t)compare_inodes, NULL);
if (cachename && cachename[0])
{
- /*
- * Cull PPD files that are no longer present...
- */
+ //
+ // Cull PPD files that are no longer present...
+ //
for (ppd = (ppd_info_t *)cupsArrayFirst(ppdlist.PPDsByName), i = 0;
ppd;
ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByName), i ++)
if (!ppd->found)
{
- /*
- * Remove this PPD file from the list...
- */
+ //
+ // Remove this PPD file from the list...
+ //
cupsArrayRemove(ppdlist.PPDsByName, ppd);
cupsArrayRemove(ppdlist.PPDsByMakeModel, ppd);
ppdlist.ChangedPPD = 1;
}
- /*
- * Write the new ppds.dat file...
- */
+ //
+ // Write the new ppds.dat file...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] ChangedPPD=%d",
if (ppdlist.ChangedPPD)
{
- char newname[1024]; /* New filename */
+ char newname[1024]; // New filename
snprintf(newname, sizeof(newname), "%s.%d", cachename, (int)getpid());
if ((fp = cupsFileOpen(newname, "w")) != NULL)
{
- unsigned ppdsync = PPD_SYNC; /* Sync word */
+ unsigned ppdsync = PPD_SYNC; // Sync word
cupsFileWrite(fp, (char *)&ppdsync, sizeof(ppdsync));
"libppd: [PPD Collections] No new or changed PPDs...");
}
- /*
- * Lists for inclusion and exclusion of certain PPD sources...
- */
+ //
+ // Lists for inclusion and exclusion of certain PPD sources...
+ //
exclude = CreateStringsArray(cupsGetOption("exclude-schemes",
num_options, options));
include = CreateStringsArray(cupsGetOption("include-schemes",
num_options, options));
- /*
- * Read further options...
- */
+ //
+ // Read further options...
+ //
only_makes = cupsGetOption("only-makes", num_options, options);
device_id = cupsGetOption("device-id", num_options, options);
ppd;
ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByMakeModel))
{
- /*
- * Filter PPDs based on make, model, product, language, model number,
- * and/or device ID using the "matches" score value. An exact match
- * for product, make-and-model, or device-id adds 3 to the score.
- * Partial matches for make-and-model yield 1 or 2 points, and matches
- * for the make and language add a single point. Results are then sorted
- * by score, highest score first.
- */
+ //
+ // Filter PPDs based on make, model, product, language, model number,
+ // and/or device ID using the "matches" score value. An exact match
+ // for product, make-and-model, or device-id adds 3 to the score.
+ // Partial matches for make-and-model yield 1 or 2 points, and matches
+ // for the make and language add a single point. Results are then sorted
+ // by score, highest score first.
+ //
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
ppd->record.type >= PPD_TYPE_DRV)
(size_t)(sizeof(re_matches) / sizeof(re_matches[0])),
re_matches, 0))
{
- /*
- * Add the number of matching values from the device ID - it will be
- * at least 2 (manufacturer and model), and as much as 3 (command set).
- */
+ //
+ // Add the number of matching values from the device ID - it will be
+ // at least 2 (manufacturer and model), and as much as 3 (command set).
+ //
for (i = 1; i < (int)(sizeof(re_matches) / sizeof(re_matches[0])); i ++)
if (re_matches[i].rm_so >= 0)
break;
}
else if (!_ppd_strncasecmp(ppd->record.products[i], product,
- product_len))
+ product_len))
{
ppd->matches += 2;
break;
ppd;
ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByMakeModel))
{
- /*
- * Filter PPDs based on the include/exclude lists.
- */
+ //
+ // Filter PPDs based on the include/exclude lists.
+ //
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
ppd->record.type >= PPD_TYPE_DRV)
count > 0 && ppd;
ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByMakeModel), i ++)
{
- /*
- * Skip invalid PPDs...
- */
+ //
+ // Skip invalid PPDs...
+ //
if (ppd->record.type < PPD_TYPE_POSTSCRIPT ||
ppd->record.type >= PPD_TYPE_DRV)
continue;
- /*
- * Output this PPD...
- */
+ //
+ // Output this PPD...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] Sending %s (%s)...",
cupsArrayAdd(result, newppd);
}
- /*
- * If we have only requested the make, then skip
- * the remaining PPDs with this make...
- */
+ //
+ // If we have only requested the make, then skip
+ // the remaining PPDs with this make...
+ //
if (only_makes)
{
- const char *this_make; /* This ppd-make */
+ const char *this_make; // This ppd-make
for (this_make = ppd->record.make,
}
-/*
- * 'ppdCollectionGetPPD()' - Copy a PPD file to stdout.
- */
+//
+// 'ppdCollectionGetPPD()' - Copy a PPD file to stdout.
+//
cups_file_t *
ppdCollectionGetPPD(
- const char *name, /* I - PPD URI of the desired PPD */
- cups_array_t *ppd_collections, /* I - Directories to search for PPDs
- in */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ const char *name, // I - PPD URI of the desired PPD
+ cups_array_t *ppd_collections, // I - Directories to search for PPDs
+ // in
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- ppd_collection_t *col; /* Pointer to PPD collection */
- cups_file_t *fp; /* Archive file pointer */
+ ppd_collection_t *col; // Pointer to PPD collection
+ cups_file_t *fp; // Archive file pointer
int fd;
- int cpid; /* Process ID for driver program */
- int epid; /* Process ID for logging process */
+ int cpid; // Process ID for driver program
+ int epid; // Process ID for logging process
int bytes;
int is_archive = 0;
int is_drv = 0;
- char realname[1024], /* Scheme from PPD name */
- buffer[8192], /* Copy buffer */
- tempname[1024], /* Temp file name */
- *ptr, /* Pointer into string */
+ char realname[1024], // Scheme from PPD name
+ buffer[8192], // Copy buffer
+ tempname[1024], // Temp file name
+ *ptr, // Pointer into string
*ppdname,
- ppduri[1024]; /* PPD URI */
+ ppduri[1024]; // PPD URI
- /*
- * Figure out if this is a static or dynamic PPD file...
- */
+ //
+ // Figure out if this is a static or dynamic PPD file...
+ //
if (strstr(name, "../"))
{
return(cat_static(realname, log, ld));
else
{
- /*
- * Dynamic PPD, see if we have a driver program to support it...
- */
+ //
+ // Dynamic PPD, see if we have a driver program to support it...
+ //
- char *argv[4]; /* Arguments for program */
+ char *argv[4]; // Arguments for program
ptr = strrchr(realname, '/');
if (ptr == NULL)
ptr = ppduri + (ptr - realname);
if (access(realname, X_OK))
{
- /*
- * File does not exist or is not executable...
- */
+ //
+ // File does not exist or is not executable...
+ //
if (log) log(ld, CF_LOGLEVEL_ERROR,
"libppd: [PPD Collections] Unable to access \"%s\" - %s",
return(NULL);
}
- /*
- * Yes, let it cat the PPD file...
- */
+ //
+ // Yes, let it cat the PPD file...
+ //
+
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] Grabbing PPD via command: \"%s cat %s\"",
realname, ptr);
}
}
- /*
- * Exit with no errors...
- */
+ //
+ // Exit with no errors...
+ //
return(fp);
}
-/*
- * 'ppdCollectionDumpCache()' - Dump the contents of the ppds.dat file.
- */
+//
+// 'ppdCollectionDumpCache()' - Dump the contents of the ppds.dat file.
+//
int
-ppdCollectionDumpCache(const char *filename, /* I - Filename */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log
- function */
+ppdCollectionDumpCache(const char *filename, // I - Filename
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log
+ // function
{
- ppd_info_t *ppd; /* Current PPD */
- ppd_list_t ppdlist; /* Lists of all available PPDs */
+ ppd_info_t *ppd; // Current PPD
+ ppd_list_t ppdlist; // Lists of all available PPDs
- /*
- * Initialize PPD list...
- */
+ //
+ // Initialize PPD list...
+ //
ppdlist.Inodes = NULL;
ppdlist.PPDsByName = cupsArrayNew((cups_array_func_t)compare_names,
ppdlist.ChangedPPD = 0;
- /*
- * See if we a PPD database file...
- */
+ //
+ // See if we a PPD database file...
+ //
if (load_ppds_dat(filename, 0, &ppdlist, log, ld)) {
free_ppdlist(&ppdlist);
}
-/*
- * 'add_ppd()' - Add a PPD file.
- */
-
-static ppd_info_t * /* O - PPD */
-add_ppd(const char *filename, /* I - PPD filename */
- const char *name, /* I - PPD name */
- const char *language, /* I - LanguageVersion */
- const char *make, /* I - Manufacturer */
- const char *make_and_model, /* I - NickName/ModelName */
- const char *device_id, /* I - 1284DeviceID */
- const char *product, /* I - Product */
- const char *psversion, /* I - PSVersion */
- time_t mtime, /* I - Modification time */
- size_t size, /* I - File size */
- int model_number, /* I - Model number */
- int type, /* I - Driver type */
- const char *scheme, /* I - PPD scheme */
+//
+// 'add_ppd()' - Add a PPD file.
+//
+
+static ppd_info_t * // O - PPD
+add_ppd(const char *filename, // I - PPD filename
+ const char *name, // I - PPD name
+ const char *language, // I - LanguageVersion
+ const char *make, // I - Manufacturer
+ const char *make_and_model, // I - NickName/ModelName
+ const char *device_id, // I - 1284DeviceID
+ const char *product, // I - Product
+ const char *psversion, // I - PSVersion
+ time_t mtime, // I - Modification time
+ size_t size, // I - File size
+ int model_number, // I - Model number
+ int type, // I - Driver type
+ const char *scheme, // I - PPD scheme
ppd_list_t *ppdlist,
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- ppd_info_t *ppd; /* PPD */
+ ppd_info_t *ppd; // PPD
- /*
- * Add a new PPD file...
- */
+ //
+ // Add a new PPD file...
+ //
if ((ppd = (ppd_info_t *)calloc(1, sizeof(ppd_info_t))) == NULL)
{
return (NULL);
}
- /*
- * Zero-out the PPD data and copy the values over...
- */
+ //
+ // Zero-out the PPD data and copy the values over...
+ //
ppd->found = 1;
ppd->record.mtime = mtime;
strlcpy(ppd->record.device_id, device_id, sizeof(ppd->record.device_id));
strlcpy(ppd->record.scheme, scheme, sizeof(ppd->record.scheme));
- /*
- * Add the PPD to the PPD arrays...
- */
+ //
+ // Add the PPD to the PPD arrays...
+ //
cupsArrayAdd(ppdlist->PPDsByName, ppd);
cupsArrayAdd(ppdlist->PPDsByMakeModel, ppd);
- /*
- * Return the new PPD pointer...
- */
+ //
+ // Return the new PPD pointer...
+ //
return (ppd);
}
-/*
- * 'cat_drv()' - Generate a PPD from a driver info file.
- */
+//
+// 'cat_drv()' - Generate a PPD from a driver info file.
+//
-static cups_file_t * /* O - Pointer to PPD file */
-cat_drv(const char *filename, /* I - *.drv file name */
- char *ppdname, /* I - PPD name in the *.drv file */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+static cups_file_t * // O - Pointer to PPD file
+cat_drv(const char *filename, // I - *.drv file name
+ char *ppdname, // I - PPD name in the *.drv file
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
cups_file_t *fp; // File pointer
int fd;
return (NULL);
}
- /* Eliminate any output to stderr, to get rid of the error messages of
- the *.drv file parser */
+ // Eliminate any output to stderr, to get rid of the error messages of
+ // the *.drv file parser
fd1 = dup(2);
fd2 = open("/dev/null", O_WRONLY);
dup2(fd2, 2);
src->release();
cupsFileClose(fp);
- /* Re-activate stderr output */
+ // Re-activate stderr output
dup2(fd1, 2);
close(fd1);
}
-/*
- * 'cat_static()' - Return pointer to static PPD file
- */
+//
+// 'cat_static()' - Return pointer to static PPD file
+//
-static cups_file_t * /* O - Pointer to PPD file */
-cat_static(const char *name, /* I - PPD name */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+static cups_file_t * // O - Pointer to PPD file
+cat_static(const char *name, // I - PPD name
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
cups_file_t *fp;
}
-/*
- * 'cat_tar()' - Copy an archived PPD file to temp file.
- */
+//
+// 'cat_tar()' - Copy an archived PPD file to temp file.
+//
-static cups_file_t * /* O - Pointer to PPD file */
-cat_tar(const char *filename, /* I - Archive name */
- char *ppdname, /* I - PPD name in the archive */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+static cups_file_t * // O - Pointer to PPD file
+cat_tar(const char *filename, // I - Archive name
+ char *ppdname, // I - PPD name in the archive
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- cups_file_t *fp; /* Archive file pointer */
+ cups_file_t *fp; // Archive file pointer
int fd;
- char tempname[1024], /* Name for the temporary file */
- curname[256], /* Current name in archive */
- buffer[8192]; /* Copy buffer */
- struct stat curinfo; /* Current file info in archive */
- off_t total, /* Total bytes copied */
- next; /* Offset for next record in archive */
- ssize_t bytes; /* Bytes read */
+ char tempname[1024], // Name for the temporary file
+ curname[256], // Current name in archive
+ buffer[8192]; // Copy buffer
+ struct stat curinfo; // Current file info in archive
+ off_t total, // Total bytes copied
+ next; // Offset for next record in archive
+ ssize_t bytes; // Bytes read
- /*
- * Open the archive file...
- */
+ //
+ // Open the archive file...
+ //
if ((fp = cupsFileOpen(filename, "r")) == NULL)
{
return (NULL);
}
- /*
- * Scan the archive for the PPD...
- */
+ //
+ // Scan the archive for the PPD...
+ //
while (read_tar(fp, curname, sizeof(curname), &curinfo, log, ld))
{
if ((bytes = cupsFileRead(fp, buffer, (size_t)bytes)) < 0)
{
if (errno == EINTR || errno == EAGAIN)
- {
bytes = 0;
- }
else
{
if (log) log(ld, CF_LOGLEVEL_ERROR,
}
-/*
- * 'compare_inodes()' - Compare two inodes.
- */
+//
+// 'compare_inodes()' - Compare two inodes.
+//
-static int /* O - Result of comparison */
-compare_inodes(struct stat *a, /* I - First inode */
- struct stat *b) /* I - Second inode */
+static int // O - Result of comparison
+compare_inodes(struct stat *a, // I - First inode
+ struct stat *b) // I - Second inode
{
if (a->st_dev != b->st_dev)
return (a->st_dev - b->st_dev);
}
-/*
- * 'compare_matches()' - Compare PPD match scores for sorting.
- */
+//
+// 'compare_matches()' - Compare PPD match scores for sorting.
+//
static int
-compare_matches(const ppd_info_t *p0, /* I - First PPD */
- const ppd_info_t *p1) /* I - Second PPD */
+compare_matches(const ppd_info_t *p0, // I - First PPD
+ const ppd_info_t *p1) // I - Second PPD
{
if (p1->matches != p0->matches)
return (p1->matches - p0->matches);
}
-/*
- * 'compare_names()' - Compare PPD filenames for sorting.
- */
+//
+// 'compare_names()' - Compare PPD filenames for sorting.
+//
-static int /* O - Result of comparison */
-compare_names(const ppd_info_t *p0, /* I - First PPD file */
- const ppd_info_t *p1) /* I - Second PPD file */
+static int // O - Result of comparison
+compare_names(const ppd_info_t *p0, // I - First PPD file
+ const ppd_info_t *p1) // I - Second PPD file
{
- int diff; /* Difference between strings */
+ int diff; // Difference between strings
if ((diff = strcmp(p0->record.filename, p1->record.filename)) != 0)
}
-/*
- * 'compare_ppds()' - Compare PPD file make and model names for sorting.
- */
+//
+// 'compare_ppds()' - Compare PPD file make and model names for sorting.
+//
-static int /* O - Result of comparison */
-compare_ppds(const ppd_info_t *p0, /* I - First PPD file */
- const ppd_info_t *p1) /* I - Second PPD file */
+static int // O - Result of comparison
+compare_ppds(const ppd_info_t *p0, // I - First PPD file
+ const ppd_info_t *p1) // I - Second PPD file
{
- int diff; /* Difference between strings */
+ int diff; // Difference between strings
- /*
- * First compare manufacturers...
- */
+ //
+ // First compare manufacturers...
+ //
if ((diff = _ppd_strcasecmp(p0->record.make, p1->record.make)) != 0)
return (diff);
}
-/*
- * 'free_array()' - Free an array of strings.
- */
+//
+// 'free_array()' - Free an array of strings.
+//
static void
-free_array(cups_array_t *a) /* I - Array to free */
+free_array(cups_array_t *a) // I - Array to free
{
- char *ptr; /* Pointer to string */
+ char *ptr; // Pointer to string
for (ptr = (char *)cupsArrayFirst(a);
}
-/*
- * 'free_ppdlist()' - Free the PPD list arrays.
- */
+//
+// 'free_ppdlist()' - Free the PPD list arrays.
+//
static void
-free_ppdlist(ppd_list_t *ppdlist) /* I - PPD list to free */
+free_ppdlist(ppd_list_t *ppdlist) // I - PPD list to free
{
- struct stat *dinfoptr; /* Pointer to Inode info */
- ppd_info_t *ppd; /* Pointer to PPD info */
+ struct stat *dinfoptr; // Pointer to Inode info
+ ppd_info_t *ppd; // Pointer to PPD info
for (dinfoptr = (struct stat *)cupsArrayFirst(ppdlist->Inodes);
}
-/*
- * 'load_driver()' - Load driver-generated PPD files.
- */
+//
+// 'load_driver()' - Load driver-generated PPD files.
+//
-static int /* O - 1 on success, 0 on failure */
-load_driver(const char *filename, /* I - Driver excutable file name */
- const char *name, /* I - Name to the rest of the world */
+static int // O - 1 on success, 0 on failure
+load_driver(const char *filename, // I - Driver excutable file name
+ const char *name, // I - Name to the rest of the world
ppd_list_t *ppdlist,
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- int i; /* Looping var */
- char *start, /* Start of value */
- *ptr; /* Pointer into string */
- const char *scheme = NULL; /* Scheme for this driver */
- int cpid; /* Process ID for driver program */
- int epid; /* Process ID for logging process */
- cups_file_t *fp; /* Pipe to driver program */
- char *argv[3], /* Arguments for command */
- line[2048], /* Line from driver */
- ppd_name[256], /* ppd-name */
- make[128], /* ppd-make */
- make_and_model[128], /* ppd-make-and-model */
- device_id[256], /* ppd-device-id */
- languages[128], /* ppd-natural-language */
- product[128], /* ppd-product */
- psversion[128], /* ppd-psversion */
- type_str[128]; /* ppd-type */
- int type; /* PPD type */
- ppd_info_t *ppd; /* Newly added PPD */
-
-
- /*
- * Run the driver with the "list" argument and collect the output...
- */
+ int i; // Looping var
+ char *start, // Start of value
+ *ptr; // Pointer into string
+ const char *scheme = NULL; // Scheme for this driver
+ int cpid; // Process ID for driver program
+ int epid; // Process ID for logging process
+ cups_file_t *fp; // Pipe to driver program
+ char *argv[3], // Arguments for command
+ line[2048], // Line from driver
+ ppd_name[256], // ppd-name
+ make[128], // ppd-make
+ make_and_model[128], // ppd-make-and-model
+ device_id[256], // ppd-device-id
+ languages[128], // ppd-natural-language
+ product[128], // ppd-product
+ psversion[128], // ppd-psversion
+ type_str[128]; // ppd-type
+ int type; // PPD type
+ ppd_info_t *ppd; // Newly added PPD
+
+
+ //
+ // Run the driver with the "list" argument and collect the output...
+ //
argv[0] = (char *)filename;
argv[1] = (char *)"list";
{
while (cupsFileGets(fp, line, sizeof(line)))
{
- /*
- * Each line is of the form:
- *
- * "ppd-name" ppd-natural-language "ppd-make" "ppd-make-and-model" \
- * "ppd-device-id" "ppd-product" "ppd-psversion"
- */
+ //
+ // Each line is of the form:
+ //
+ // "ppd-name" ppd-natural-language "ppd-make" "ppd-make-and-model"
+ // "ppd-device-id" "ppd-product" "ppd-psversion"
+ //
device_id[0] = '\0';
product[0] = '\0';
ppd_name, languages, make, make_and_model,
device_id, product, psversion, type_str) < 4)
{
- /*
- * Bad format; strip trailing newline and write an error message.
- */
+ //
+ // Bad format; strip trailing newline and write an error message.
+ //
if (line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
}
else
{
- /*
- * Add the device to the array of available devices...
- */
+ //
+ // Add the device to the array of available devices...
+ //
if ((start = strchr(languages, ',')) != NULL)
*start++ = '\0';
scheme ++;
memmove(ppd_name + strlen(name), ptr, strlen(ptr) + 1);
memmove(ppd_name, name, strlen(name));
- } else if (strncmp(name, ppd_name, strlen(name)) ||
- *(ppd_name + strlen(name)) != ':')
+ }
+ else if (strncmp(name, ppd_name, strlen(name)) ||
+ *(ppd_name + strlen(name)) != ':')
{
cupsFileClose(fp);
return (0);
}
-/*
- * 'load_drv()' - Load the PPDs from a driver information file.
- */
+//
+// 'load_drv()' - Load the PPDs from a driver information file.
+//
-static int /* O - 1 on success, 0 on failure */
-load_drv(const char *filename, /* I - Actual filename */
- const char *name, /* I - Name to the rest of the world */
- cups_file_t *fp, /* I - File to read from */
- time_t mtime, /* I - Mod time of driver info file */
- off_t size, /* I - Size of driver info file */
+static int // O - 1 on success, 0 on failure
+load_drv(const char *filename, // I - Actual filename
+ const char *name, // I - Name to the rest of the world
+ cups_file_t *fp, // I - File to read from
+ time_t mtime, // I - Mod time of driver info file
+ off_t size, // I - Size of driver info file
ppd_list_t *ppdlist,
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
ppdcSource *src; // Driver information file
ppdcDriver *d; // Current driver
int fd1, fd2;
- /*
- * Eliminate any output to stderr, to get rid of the error messages of
- * the *.drv file parser
- */
+ //
+ // Eliminate any output to stderr, to get rid of the error messages of
+ // the *.drv file parser
+ //
fd1 = dup(2);
fd2 = open("/dev/null", O_WRONLY);
dup2(fd2, 2);
close(fd2);
- /*
- * Load the driver info file...
- */
+ //
+ // Load the driver info file...
+ //
src = new ppdcSource(filename, fp);
"libppd: [PPD Collections] Bad driver information file \"%s\"!\n",
filename);
src->release();
- /* Re-activate stderr output */
+ // Re-activate stderr output
dup2(fd1, 2);
close(fd1);
return (0);
}
- /*
- * Add a dummy entry for the file...
- */
+ //
+ // Add a dummy entry for the file...
+ //
add_ppd(filename, name, "", "", "", "", "", "", mtime, (size_t)size, 0,
PPD_TYPE_DRV, "drv", ppdlist, log, ld);
- /*
- * Then the drivers in the file...
- */
+ //
+ // Then the drivers in the file...
+ //
for (d = (ppdcDriver *)src->drivers->first();
d;
}
for (product = (ppdcAttr *)d->attrs->first(), products_found = 0,
- ppd = NULL;
+ ppd = NULL;
product;
product = (ppdcAttr *)d->attrs->next())
if (!strcmp(product->name->value, "Product"))
src->release();
- /*
- * Re-activate stderr output
- */
+ //
+ // Re-activate stderr output
+ //
dup2(fd1, 2);
close(fd1);
}
-/*
- * 'load_ppd()' - Load a PPD file.
- */
+//
+// 'load_ppd()' - Load a PPD file.
+//
static void
-load_ppd(const char *filename, /* I - Real filename */
- const char *name, /* I - Virtual filename */
- const char *scheme, /* I - PPD scheme */
- struct stat *fileinfo, /* I - File information */
- ppd_info_t *ppd, /* I - Existing PPD file or NULL */
- cups_file_t *fp, /* I - File to read from */
- off_t end, /* I - End of file position or 0 */
+load_ppd(const char *filename, // I - Real filename
+ const char *name, // I - Virtual filename
+ const char *scheme, // I - PPD scheme
+ struct stat *fileinfo, // I - File information
+ ppd_info_t *ppd, // I - Existing PPD file or NULL
+ cups_file_t *fp, // I - File to read from
+ off_t end, // I - End of file position or 0
ppd_list_t *ppdlist,
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- int i; /* Looping var */
- char line[256], /* Line from file */
- *ptr, /* Pointer into line */
- lang_version[64], /* PPD LanguageVersion */
- lang_encoding[64], /* PPD LanguageEncoding */
- country[64], /* Country code */
- manufacturer[256], /* Manufacturer */
- make_model[256], /* Make and Model */
- model_name[256], /* ModelName */
- nick_name[256], /* NickName */
- device_id[256], /* 1284DeviceID */
- product[256], /* Product */
- psversion[256], /* PSVersion */
- temp[512]; /* Temporary make and model */
- int install_group, /* In the installable options group? */
- model_number, /* cupsModelNumber */
- type; /* ppd-type */
- cups_array_t *products, /* Product array */
- *psversions, /* PSVersion array */
- *cups_languages; /* cupsLanguages array */
- int new_ppd; /* Is this a new PPD? */
- struct /* LanguageVersion translation table */
+ int i; // Looping var
+ char line[256], // Line from file
+ *ptr, // Pointer into line
+ lang_version[64], // PPD LanguageVersion
+ lang_encoding[64], // PPD LanguageEncoding
+ country[64], // Country code
+ manufacturer[256], // Manufacturer
+ make_model[256], // Make and Model
+ model_name[256], // ModelName
+ nick_name[256], // NickName
+ device_id[256], // 1284DeviceID
+ product[256], // Product
+ psversion[256], // PSVersion
+ temp[512]; // Temporary make and model
+ int install_group, // In the installable options group?
+ model_number, // cupsModelNumber
+ type; // ppd-type
+ cups_array_t *products, // Product array
+ *psversions, // PSVersion array
+ *cups_languages; // cupsLanguages array
+ int new_ppd; // Is this a new PPD?
+ struct // LanguageVersion translation table
{
- const char *version, /* LanguageVersion string */
- *language; /* Language code */
+ const char *version, // LanguageVersion string
+ *language; // Language code
} languages[] =
{
{ "chinese", "zh" },
};
- /*
- * Now read until we get the required fields...
- */
+ //
+ // Now read until we get the required fields...
+ //
cups_languages = cupsArrayNew(NULL, NULL);
products = cupsArrayNew(NULL, NULL);
{
if (sscanf(line, "%*[^\"]\"(%255[^\"]", product) == 1)
{
- /*
- * Make sure the value ends with a right parenthesis - can't stop at
- * the first right paren since the product name may contain escaped
- * parenthesis...
- */
+ //
+ // Make sure the value ends with a right parenthesis - can't stop at
+ // the first right paren since the product name may contain escaped
+ // parenthesis...
+ //
ptr = product + strlen(product) - 1;
if (ptr > product && *ptr == ')')
{
- /*
- * Yes, ends with a parenthesis, so remove it from the end and
- * add the product to the list...
- */
+ //
+ // Yes, ends with a parenthesis, so remove it from the end and
+ // add the product to the list...
+ //
*ptr = '\0';
cupsArrayAdd(products, strdup(product));
}
else if (!strncmp(line, "*cupsLanguages:", 15))
{
- char *start; /* Start of language */
+ char *start; // Start of language
for (start = line + 15; *start && isspace(*start & 255); start ++);
install_group = 0;
else if (!strncmp(line, "*OpenUI", 7))
{
- /*
- * Stop early if we have a NickName or ModelName attributes
- * before the first non-installable OpenUI...
- */
+ //
+ // Stop early if we have a NickName or ModelName attributes
+ // before the first non-installable OpenUI...
+ //
if (!install_group && (model_name[0] || nick_name[0]) &&
cupsArrayCount(products) > 0 && cupsArrayCount(psversions) > 0)
}
}
- /*
- * See if we got all of the required info...
- */
+ //
+ // See if we got all of the required info...
+ //
if (nick_name[0])
cupsCharsetToUTF8((cups_utf8_t *)make_model, nick_name,
if (!make_model[0] || cupsArrayCount(products) == 0 ||
cupsArrayCount(psversions) == 0)
{
- /*
- * We don't have all the info needed, so skip this file...
- */
+ //
+ // We don't have all the info needed, so skip this file...
+ //
if (!make_model[0])
if (log) log(ld, CF_LOGLEVEL_WARN,
if (model_name[0])
cupsArrayAdd(products, strdup(model_name));
- /*
- * Normalize the make and model string...
- */
+ //
+ // Normalize the make and model string...
+ //
while (isspace(manufacturer[0] & 255))
_ppd_strcpy(manufacturer, manufacturer + 1);
ppdNormalizeMakeAndModel(temp, make_model, sizeof(make_model));
- /*
- * See if we got a manufacturer...
- */
+ //
+ // See if we got a manufacturer...
+ //
if (!manufacturer[0] || !strcmp(manufacturer, "ESP"))
{
- /*
- * Nope, copy the first part of the make and model then...
- */
+ //
+ // Nope, copy the first part of the make and model then...
+ //
strlcpy(manufacturer, make_model, sizeof(manufacturer));
- /*
- * Truncate at the first space, dash, or slash, or make the
- * manufacturer "Other"...
- */
+ //
+ // Truncate at the first space, dash, or slash, or make the
+ // manufacturer "Other"...
+ //
for (ptr = manufacturer; *ptr; ptr ++)
if (*ptr == ' ' || *ptr == '-' || *ptr == '/')
else if (!_ppd_strncasecmp(manufacturer, "Hewlett", 7))
strlcpy(manufacturer, "HP", sizeof(manufacturer));
- /*
- * Fix the lang_version as needed...
- */
+ //
+ // Fix the lang_version as needed...
+ //
if ((ptr = strchr(lang_version, '-')) != NULL)
*ptr++ = '\0';
if (ptr)
{
- /*
- * Setup the country suffix...
- */
+ //
+ // Setup the country suffix...
+ //
country[0] = '_';
_ppd_strcpy(country + 1, ptr);
}
else
{
- /*
- * No country suffix...
- */
+ //
+ // No country suffix...
+ //
country[0] = '\0';
}
if (i < (int)(sizeof(languages) / sizeof(languages[0])))
{
- /*
- * Found a known language...
- */
+ //
+ // Found a known language...
+ //
snprintf(lang_version, sizeof(lang_version), "%s%s",
languages[i].language, country);
}
else
{
- /*
- * Unknown language; use "xx"...
- */
+ //
+ // Unknown language; use "xx"...
+ //
strlcpy(lang_version, "xx", sizeof(lang_version));
}
- /*
- * Record the PPD file...
- */
+ //
+ // Record the PPD file...
+ //
new_ppd = !ppd;
if (new_ppd)
{
- /*
- * Add new PPD file...
- */
+ //
+ // Add new PPD file...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] Adding PPD \"%s\"...", name);
}
else
{
- /*
- * Update existing record...
- */
+ //
+ // Update existing record...
+ //
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] Updating ppd \"%s\"...", name);
strlcpy(ppd->record.scheme, scheme, sizeof(ppd->record.scheme));
}
- /*
- * Add remaining products, versions, and languages...
- */
+ //
+ // Add remaining products, versions, and languages...
+ //
for (i = 1;
i < PPD_MAX_PROD && (ptr = (char *)cupsArrayNext(products)) != NULL;
strlcpy(ppd->record.languages[i], ptr,
sizeof(ppd->record.languages[0]));
- /*
- * Free products, versions, and languages...
- */
+ //
+ // Free products, versions, and languages...
+ //
free_array(cups_languages);
free_array(products);
}
-/*
- * 'load_ppds()' - Load PPD files recursively.
- */
+//
+// 'load_ppds()' - Load PPD files recursively.
+//
-static int /* O - 1 on success, 0 on failure */
-load_ppds(const char *d, /* I - Actual directory */
- const char *p, /* I - Virtual path in name */
- int descend, /* I - Descend into directories? */
+static int // O - 1 on success, 0 on failure
+load_ppds(const char *d, // I - Actual directory
+ const char *p, // I - Virtual path in name
+ int descend, // I - Descend into directories?
ppd_list_t *ppdlist,
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- struct stat dinfo, /* Directory information */
- *dinfoptr; /* Pointer to match */
- cups_file_t *fp; /* Pointer to file */
- cups_dir_t *dir; /* Directory pointer */
- cups_dentry_t *dent; /* Directory entry */
- char filename[1024], /* Name of PPD or directory */
- line[256], /* Line from file */
- *ptr, /* Pointer into name */
- name[1024]; /* Name of PPD file */
- ppd_info_t *ppd, /* New PPD file */
- key; /* Search key */
-
-
- /*
- * See if we've loaded this directory before...
- */
+ struct stat dinfo, // Directory information
+ *dinfoptr; // Pointer to match
+ cups_file_t *fp; // Pointer to file
+ cups_dir_t *dir; // Directory pointer
+ cups_dentry_t *dent; // Directory entry
+ char filename[1024], // Name of PPD or directory
+ line[256], // Line from file
+ *ptr, // Pointer into name
+ name[1024]; // Name of PPD file
+ ppd_info_t *ppd, // New PPD file
+ key; // Search key
+
+
+ //
+ // See if we've loaded this directory before...
+ //
if (stat(d, &dinfo))
{
return (1);
}
- /*
- * Nope, add it to the Inodes array and continue...
- */
+ //
+ // Nope, add it to the Inodes array and continue...
+ //
dinfoptr = (struct stat *)malloc(sizeof(struct stat));
memcpy(dinfoptr, &dinfo, sizeof(struct stat));
cupsArrayAdd(ppdlist->Inodes, dinfoptr);
- /*
- * Check permissions...
- */
+ //
+ // Check permissions...
+ //
//if (_ppdFileCheck(d, _PPD_FILE_CHECK_DIRECTORY, !geteuid(), log, ld))
// return (0);
while ((dent = cupsDirRead(dir)) != NULL)
{
- /*
- * Skip files/directories starting with "."...
- */
+ //
+ // Skip files/directories starting with "."...
+ //
if (dent->filename[0] == '.')
continue;
- /*
- * See if this is a file...
- */
+ //
+ // See if this is a file...
+ //
if (!strcmp(d, "/"))
snprintf(filename, sizeof(filename), "/%s", dent->filename);
if (S_ISDIR(dent->fileinfo.st_mode))
{
- /*
- * Do subdirectory...
- */
+ //
+ // Do subdirectory...
+ //
if (descend)
{
}
else if (strstr(filename, ".plist"))
{
- /*
- * Skip plist files in the PPDs directory...
- */
+ //
+ // Skip plist files in the PPDs directory...
+ //
continue;
}
// log, ld))
// continue;
- /*
- * See if this file has been scanned before...
- */
+ //
+ // See if this file has been scanned before...
+ //
strlcpy(key.record.filename, filename, sizeof(key.record.filename));
strlcpy(key.record.name, name, sizeof(key.record.name));
ppd->record.size == dent->fileinfo.st_size &&
ppd->record.mtime == dent->fileinfo.st_mtime)
{
- /*
- * Rewind to the first entry for this file...
- */
+ //
+ // Rewind to the first entry for this file...
+ //
while ((ppd = (ppd_info_t *)cupsArrayPrev(ppdlist->PPDsByName)) != NULL &&
!strcmp(ppd->record.filename, filename));
- /*
- * Then mark all of the matches for this file as found...
- */
+ //
+ // Then mark all of the matches for this file as found...
+ //
while ((ppd = (ppd_info_t *)cupsArrayNext(ppdlist->PPDsByName)) != NULL &&
!strcmp(ppd->record.filename, filename))
continue;
}
- /*
- * No, file is new/changed, so re-scan it...
- */
+ //
+ // No, file is new/changed, so re-scan it...
+ //
if ((fp = cupsFileOpen(filename, "r")) == NULL)
continue;
- /*
- * Now see if this is a PPD file...
- */
+ //
+ // Now see if this is a PPD file...
+ //
line[0] = '\0';
cupsFileGets(fp, line, sizeof(line));
if (!strncmp(line, "*PPD-Adobe:", 11))
{
- /*
- * Yes, load it...
- */
+ //
+ // Yes, load it...
+ //
load_ppd(filename, name, "file", &dent->fileinfo, ppd, fp, 0, ppdlist,
log, ld);
}
else
{
- /*
- * Nope, treat it as a an archive, a PPD-generating executable, or a
- * driver information file...
- */
+ //
+ // Nope, treat it as a an archive, a PPD-generating executable, or a
+ // driver information file...
+ //
cupsFileRewind(fp);
else if ((dent->fileinfo.st_mode & 0111) &&
S_ISREG(dent->fileinfo.st_mode))
{
- /* File is not a PPD, not an archive, but executable, try whether
- it generates PPDs... */
+ // File is not a PPD, not an archive, but executable, try whether
+ // it generates PPDs...
load_driver(filename, name, ppdlist, log, ld);
}
}
- /*
- * Close the file...
- */
+ //
+ // Close the file...
+ //
cupsFileClose(fp);
}
}
-/*
- * 'load_ppds_dat()' - Load the ppds.dat file.
- */
+//
+// 'load_ppds_dat()' - Load the ppds.dat file.
+//
static int
-load_ppds_dat(const char *filename, /* I - Filename */
- int verbose, /* I - Be verbose? */
+load_ppds_dat(const char *filename, // I - Filename
+ int verbose, // I - Be verbose?
ppd_list_t *ppdlist,
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- ppd_info_t *ppd; /* Current PPD file */
- cups_file_t *fp; /* ppds.dat file */
- struct stat fileinfo; /* ppds.dat information */
+ ppd_info_t *ppd; // Current PPD file
+ cups_file_t *fp; // ppds.dat file
+ struct stat fileinfo; // ppds.dat information
if (filename == NULL || !filename[0])
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
- /*
- * See if we have the right sync word...
- */
+ //
+ // See if we have the right sync word...
+ //
- unsigned ppdsync; /* Sync word */
- int num_ppds; /* Number of PPDs */
+ unsigned ppdsync; // Sync word
+ int num_ppds; // Number of PPDs
if ((size_t)cupsFileRead(fp, (char *)&ppdsync,
sizeof(ppdsync)) == sizeof(ppdsync) &&
(num_ppds = ((size_t)fileinfo.st_size - sizeof(ppdsync)) /
sizeof(ppd_rec_t)) > 0)
{
- /*
- * We have a ppds.dat file, so read it!
- */
+ //
+ // We have a ppds.dat file, so read it!
+ //
for (; num_ppds > 0; num_ppds --)
{
}
-/*
- * 'load_tar()' - Load archived PPD files.
- */
+//
+// 'load_tar()' - Load archived PPD files.
+//
-static int /* O - 1 on success, 0 on failure */
-load_tar(const char *filename, /* I - Actual filename */
- const char *name, /* I - Name to the rest of the world */
- cups_file_t *fp, /* I - File to read from */
- time_t mtime, /* I - Mod time of driver info file */
- off_t size, /* I - Size of driver info file */
+static int // O - 1 on success, 0 on failure
+load_tar(const char *filename, // I - Actual filename
+ const char *name, // I - Name to the rest of the world
+ cups_file_t *fp, // I - File to read from
+ time_t mtime, // I - Mod time of driver info file
+ off_t size, // I - Size of driver info file
ppd_list_t *ppdlist,
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- char curname[256], /* Current archive file name */
- uri[2048]; /* Virtual file URI */
- const char *curext; /* Extension on file */
- struct stat curinfo; /* Current archive file information */
- off_t next; /* Position for next header */
+ char curname[256], // Current archive file name
+ uri[2048]; // Virtual file URI
+ const char *curext; // Extension on file
+ struct stat curinfo; // Current archive file information
+ off_t next; // Position for next header
- /*
- * Add a dummy entry for the file...
- */
+ //
+ // Add a dummy entry for the file...
+ //
add_ppd(filename, name, "", "", "", "", "", "", mtime, (size_t)size, 0,
PPD_TYPE_ARCHIVE, "file", ppdlist, log, ld);
ppdlist->ChangedPPD = 1;
- /*
- * Scan for PPDs in the archive...
- */
+ //
+ // Scan for PPDs in the archive...
+ //
while (read_tar(fp, curname, sizeof(curname), &curinfo, log, ld))
{
}
-/*
- * 'read_tar()' - Read a file header from an archive.
- *
- * This function skips all directories and special files.
- */
+//
+// 'read_tar()' - Read a file header from an archive.
+//
+// This function skips all directories and special files.
+//
-static int /* O - 1 if found, 0 on EOF */
-read_tar(cups_file_t *fp, /* I - Archive to read */
- char *name, /* I - Filename buffer */
- size_t namesize, /* I - Size of filename buffer */
- struct stat *info, /* O - File information */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+static int // O - 1 if found, 0 on EOF
+read_tar(cups_file_t *fp, // I - Archive to read
+ char *name, // I - Filename buffer
+ size_t namesize, // I - Size of filename buffer
+ struct stat *info, // O - File information
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- tar_rec_t record; /* Record from file */
+ tar_rec_t record; // Record from file
while ((size_t)cupsFileRead(fp, (char *)&record,
sizeof(record)) == sizeof(record))
{
- /*
- * Check for a valid tar header...
- */
+ //
+ // Check for a valid tar header...
+ //
if ((memcmp(record.header.magic, TAR_MAGIC, 6) ||
memcmp(record.header.version, TAR_VERSION, 2)) &&
break;
}
- /*
- * Ignore non-files...
- */
+ //
+ // Ignore non-files...
+ //
if (record.header.linkflag != TAR_OLDNORMAL &&
record.header.linkflag != TAR_NORMAL)
continue;
- /*
- * Grab size and name from tar header and return...
- */
+ //
+ // Grab size and name from tar header and return...
+ //
if (record.header.prefix[0])
snprintf(name, namesize, "%s/%s", record.header.prefix,
}
-/*
- * 'regex_device_id()' - Compile a regular expression based on the 1284 device
- * ID.
- */
+//
+// 'regex_device_id()' - Compile a regular expression based on the 1284 device
+// ID.
-static regex_t * /* O - Regular expression */
-regex_device_id(const char *device_id, /* I - IEEE-1284 device ID */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+
+static regex_t * // O - Regular expression
+regex_device_id(const char *device_id, // I - IEEE-1284 device ID
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- char res[2048], /* Regular expression string */
- *ptr; /* Pointer into string */
- regex_t *re; /* Regular expression */
- int cmd; /* Command set string? */
+ char res[2048], // Regular expression string
+ *ptr; // Pointer into string
+ regex_t *re; // Regular expression
+ int cmd; // Command set string?
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] regex_device_id(\"%s\")",
device_id);
- /*
- * Scan the device ID string and insert class, command set, manufacturer, and
- * model attributes to match. We assume that the device ID in the PPD and the
- * device ID reported by the device itself use the same attribute names and
- * order of attributes.
- */
+ //
+ // Scan the device ID string and insert class, command set, manufacturer, and
+ // model attributes to match. We assume that the device ID in the PPD and the
+ // device ID reported by the device itself use the same attribute names and
+ // order of attributes.
+ //
ptr = res;
*ptr++ = '\\';
if (*device_id == ':')
{
- /*
- * KEY:.*value
- */
+ //
+ // KEY:.*value
+ //
*ptr++ = *device_id++;
*ptr++ = '.';
if (*device_id == ';' || !*device_id)
{
- /*
- * KEY:.*value.*;
- */
+ //
+ // KEY:.*value.*;
+ //
*ptr++ = '.';
*ptr++ = '*';
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] regex_device_id: \"%s\"", res);
- /*
- * Compile the regular expression and return...
- */
+ //
+ // Compile the regular expression and return...
+ //
if (res[0] && (re = (regex_t *)calloc(1, sizeof(regex_t))) != NULL)
{
}
-/*
- * 'regex_string()' - Construct a regular expression to compare a simple string.
- */
+//
+// 'regex_string()' - Construct a regular expression to compare a simple string.
+//
-static regex_t * /* O - Regular expression */
-regex_string(const char *s, /* I - String to compare */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Aux. data for log function */
+static regex_t * // O - Regular expression
+regex_string(const char *s, // I - String to compare
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Aux. data for log function
{
- char res[2048], /* Regular expression string */
- *ptr; /* Pointer into string */
- regex_t *re; /* Regular expression */
+ char res[2048], // Regular expression string
+ *ptr; // Pointer into string
+ regex_t *re; // Regular expression
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] regex_string(\"%s\")", s);
- /*
- * Convert the string to a regular expression, escaping special characters
- * as needed.
- */
+ //
+ // Convert the string to a regular expression, escaping special characters
+ // as needed.
+ //
ptr = res;
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] regex_string: \"%s\"", res);
- /*
- * Create a case-insensitive regular expression...
- */
+ //
+ // Create a case-insensitive regular expression...
+ //
if (res[0] && (re = (regex_t *)calloc(1, sizeof(regex_t))) != NULL)
{
}
-/*
- * 'CompareNames()' - Compare two names.
- *
- * This function basically does a _ppd_strcasecmp() of the two strings,
- * but is also aware of numbers so that "a2" < "a100".
- */
+//
+// 'CompareNames()' - Compare two names.
+//
+// This function basically does a _ppd_strcasecmp() of the two strings,
+// but is also aware of numbers so that "a2" < "a100".
+//
-int /* O - Result of comparison */
-CompareNames(const char *s, /* I - First string */
- const char *t) /* I - Second string */
+int // O - Result of comparison
+CompareNames(const char *s, // I - First string
+ const char *t) // I - Second string
{
- int diff, /* Difference between digits */
- digits; /* Number of digits */
+ int diff, // Difference between digits
+ digits; // Number of digits
- /*
- * Loop through both names, returning only when a difference is
- * seen. Also, compare whole numbers rather than just characters, too!
- */
+ //
+ // Loop through both names, returning only when a difference is
+ // seen. Also, compare whole numbers rather than just characters, too!
+ //
while (*s && *t)
{
if (isdigit(*s & 255) && isdigit(*t & 255))
{
- /*
- * Got a number; start by skipping leading 0's...
- */
+ //
+ // Got a number; start by skipping leading 0's...
+ //
while (*s == '0')
s ++;
while (*t == '0')
t ++;
- /*
- * Skip equal digits...
- */
+ //
+ // Skip equal digits...
+ //
while (isdigit(*s & 255) && *s == *t)
{
t ++;
}
- /*
- * Bounce out if *s and *t aren't both digits...
- */
+ //
+ // Bounce out if *s and *t aren't both digits...
+ //
if (isdigit(*s & 255) && !isdigit(*t & 255))
return (1);
else
diff = 1;
- /*
- * Figure out how many more digits there are...
- */
+ //
+ // Figure out how many more digits there are...
+ //
digits = 0;
s ++;
t ++;
}
- /*
- * Return if the number or value of the digits is different...
- */
+ //
+ // Return if the number or value of the digits is different...
+ //
if (digits < 0)
return (-1);
}
}
- /*
- * Return the results of the final comparison...
- */
+ //
+ // Return the results of the final comparison...
+ //
if (*s)
return (1);
}
-/*
- * 'CreateStringsArray()' - Create a CUPS array of strings.
- */
+//
+// 'CreateStringsArray()' - Create a CUPS array of strings.
+//
-cups_array_t * /* O - CUPS array */
-CreateStringsArray(const char *s) /* I - Comma-delimited strings */
+cups_array_t * // O - CUPS array
+CreateStringsArray(const char *s) // I - Comma-delimited strings
{
if (!s || !*s)
return (NULL);
}
-/*
- * 'ExecCommand()' - Run a program with the correct environment.
- *
- * On macOS, we need to update the CFProcessPath environment variable that
- * is passed in the environment so the child can access its bundled resources.
- */
+//
+// 'ExecCommand()' - Run a program with the correct environment.
+//
+// On macOS, we need to update the CFProcessPath environment variable that
+// is passed in the environment so the child can access its bundled resources.
+//
-int /* O - exec() status */
-ExecCommand(const char *command, /* I - Full path to program */
- char **argv) /* I - Command-line arguments */
+int // O - exec() status
+ExecCommand(const char *command, // I - Full path to program
+ char **argv) // I - Command-line arguments
{
#ifdef __APPLE__
- int i, j; /* Looping vars */
- char *envp[500], /* Array of environment variables */
- cfprocesspath[1024], /* CFProcessPath environment variable */
- linkpath[1024]; /* Link path for symlinks... */
- int linkbytes; /* Bytes for link path */
+ int i, j; // Looping vars
+ char *envp[500], // Array of environment variables
+ cfprocesspath[1024], // CFProcessPath environment variable
+ linkpath[1024]; // Link path for symlinks...
+ int linkbytes; // Bytes for link path
- /*
- * Some macOS programs are bundled and need the CFProcessPath environment
- * variable defined. If the command is a symlink, resolve the link and point
- * to the resolved location, otherwise, use the command path itself.
- */
+ //
+ // Some macOS programs are bundled and need the CFProcessPath environment
+ // variable defined. If the command is a symlink, resolve the link and point
+ // to the resolved location, otherwise, use the command path itself.
+ //
if ((linkbytes = readlink(command, linkpath, sizeof(linkpath) - 1)) > 0)
{
- /*
- * Yes, this is a symlink to the actual program, nul-terminate and
- * use it...
- */
+ //
+ // Yes, this is a symlink to the actual program, nul-terminate and
+ // use it...
+ //
linkpath[linkbytes] = '\0';
envp[0] = cfprocesspath;
- /*
- * Copy the rest of the environment except for any CFProcessPath that may
- * already be there...
- */
+ //
+ // Copy the rest of the environment except for any CFProcessPath that may
+ // already be there...
+ //
for (i = 1, j = 0;
environ[j] && i < (int)(sizeof(envp) / sizeof(envp[0]) - 1);
envp[i] = NULL;
- /*
- * Use execve() to run the program...
- */
+ //
+ // Use execve() to run the program...
+ //
return (execve(command, argv, envp));
#else
- /*
- * On other operating systems, just call execv() to use the same environment
- * variables as the parent...
- */
+ //
+ // On other operating systems, just call execv() to use the same environment
+ // variables as the parent...
+ //
return (execv(command, argv));
-#endif /* __APPLE__ */
+#endif // __APPLE__
}
-/*
- * 'PipeCommand()' - Read output from a command.
- */
+//
+// 'PipeCommand()' - Read output from a command.
+//
-cups_file_t * /* O - CUPS file or NULL on error */
-PipeCommand(int *cpid, /* O - Process ID or 0 on error */
- int *epid, /* O - Log Process ID or 0 on error */
- const char *command, /* I - Command to run */
- char **argv, /* I - Arguments to pass to command */
- uid_t user, /* I - User to run as or 0 for current*/
+cups_file_t * // O - CUPS file or NULL on error
+PipeCommand(int *cpid, // O - Process ID or 0 on error
+ int *epid, // O - Log Process ID or 0 on error
+ const char *command, // I - Command to run
+ char **argv, // I - Arguments to pass to command
+ uid_t user, // I - User to run as or 0 for current
cf_logfunc_t log,
void *ld)
{
- int fd, /* Temporary file descriptor */
- cfds[2], /* Output Pipe file descriptors */
- efds[2]; /* Error/Log Pipe file descriptors */
+ int fd, // Temporary file descriptor
+ cfds[2], // Output Pipe file descriptors
+ efds[2]; // Error/Log Pipe file descriptors
cups_file_t *outfp, *logfp;
char buf[BUFSIZ];
cf_loglevel_t log_level;
*cpid = *epid = 0;
cfds[0] = cfds[1] = efds[0] = efds[1] = -1;
- /*
- * First create the pipes...
- */
+ //
+ // First create the pipes...
+ //
if (pipe(cfds))
{
return (NULL);
}
- /*
- * Set the "close on exec" flag on each end of the pipes...
- */
+ //
+ // Set the "close on exec" flag on each end of the pipes...
+ //
if (fcntl(cfds[0], F_SETFD, fcntl(cfds[0], F_GETFD) | FD_CLOEXEC))
{
}
}
- /*
- * Then run the command...
- */
+ //
+ // Then run the command...
+ //
if ((*cpid = fork()) < 0)
{
- /*
- * Unable to fork!
- */
+ //
+ // Unable to fork!
+ //
*cpid = 0;
close(cfds[0]);
}
else if (!*cpid)
{
- /*
- * Child (command) comes here...
- */
+ //
+ // Child (command) comes here...
+ //
- if (!getuid() && user && setuid(user) < 0) /* Run as restricted user */
+ if (!getuid() && user && setuid(user) < 0) // Run as restricted user
exit(errno);
if ((fd = open("/dev/null", O_RDONLY)) > 0)
{
- dup2(fd, 0); /* < /dev/null */
+ dup2(fd, 0); // < /dev/null
close(fd);
}
- dup2(cfds[1], 1); /* > command pipe */
+ dup2(cfds[1], 1); // > command pipe
close(cfds[1]);
if (log)
{
- dup2(efds[1], 2); /* 2> error pipe */
+ dup2(efds[1], 2); // 2> error pipe
close(efds[1]);
}
else if ((fd = open("/dev/null", O_WRONLY)) > 0)
{
- dup2(fd, 2); /* 2> /dev/null */
+ dup2(fd, 2); // 2> /dev/null
close(fd);
}
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] Started %s (PID %d)", argv[0], cpid);
- /*
- * Parent comes here ...
- */
+ //
+ // Parent comes here ...
+ //
close(cfds[1]);
- /*
- * Open the input side of the pipe...
- */
+ //
+ // Open the input side of the pipe...
+ //
outfp = cupsFileOpenFd(cfds[0], "r");
- /*
- * Fork the error logging...
- */
+ //
+ // Fork the error logging...
+ //
if (log)
{
if ((*epid = fork()) < 0)
{
- /*
- * Unable to fork!
- */
+ //
+ // Unable to fork!
+ //
*epid = 0;
close(efds[0]);
}
else if (!*epid)
{
- /*
- * Child (logging) comes here...
- */
+ //
+ // Child (logging) comes here...
+ //
close(cfds[0]);
close(efds[1]);
log(ld, log_level, "libppd: [PPD Collections] %s: %s", argv[0], msg);
}
cupsFileClose(logfp);
- /* No need to close the fd errfds[0], as cupsFileClose(fp) does this
- already */
- /* Ignore errors of the logging process */
+ // No need to close the fd errfds[0], as cupsFileClose(fp) does this
+ // already
+ // Ignore errors of the logging process
exit(0);
}
"libppd: [PPD Collections] Started logging for %s (PID %d)",
argv[0], cpid);
- /*
- * Parent comes here ...
- */
+ //
+ // Parent comes here ...
+ //
close(efds[0]);
close(efds[1]);
}
-/*
- * 'ClosePipeCommand()' - Wait for the command called with PipeCommand() to
- * finish and return the status.
- */
+//
+// 'ClosePipeCommand()' - Wait for the command called with PipeCommand() to
+// finish and return the status.
+//
static int
ClosePipeCommand(cups_file_t *fp,
int wstatus;
- /*
- * close the stream...
- */
+ //
+ // close the stream...
+ //
cupsFileClose(fp);
- /*
- * Wait for the child process to exit...
- */
+ //
+ // Wait for the child process to exit...
+ //
while (cpid > 0 || epid > 0) {
- if ((pid = wait(&wstatus)) < 0) {
+ if ((pid = wait(&wstatus)) < 0)
+ {
if (errno == EINTR)
continue;
else
}
}
- /* How did the filter terminate */
- if (wstatus) {
- if (WIFEXITED(wstatus)) {
- /* Via exit() anywhere or return() in the main() function */
+ // How did the filter terminate
+ if (wstatus)
+ {
+ if (WIFEXITED(wstatus))
+ {
+ // Via exit() anywhere or return() in the main() function
if (log) log(ld, CF_LOGLEVEL_ERROR,
"libppd: [PPD Collections] %s (PID %d) stopped with status %d",
(pid == cpid ? "Command" : "Logging"), pid,
WEXITSTATUS(wstatus));
status = WEXITSTATUS(wstatus);
- } else {
- /* Via signal */
+ }
+ else
+ {
+ // Via signal
if (log) log(ld, CF_LOGLEVEL_ERROR,
"libppd: [PPD Collections] %s (PID %d) crashed on signal %d",
(pid == cpid ? "Command" : "Logging"), pid,
WTERMSIG(wstatus));
status = 256 * WTERMSIG(wstatus);
}
- } else {
+ }
+ else
+ {
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"libppd: [PPD Collections] %s (PID %d) exited with no errors.",
(pid == cpid ? "Command" : "Logging"), pid);
epid = -1;
}
- return status;
+ return (status);
}
-/*
- * Option conflict management routines for libppd.
- *
- * Copyright 2007-2018 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Option conflict management routines for libppd.
+//
+// Copyright 2007-2018 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "ppd.h"
#include "debug-internal.h"
-/*
- * Local constants...
- */
+//
+// Local constants...
+//
enum
{
};
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static int ppd_is_installable(ppd_group_t *installable,
const char *option);
int which);
-/*
- * 'ppdGetConflicts()' - Get a list of conflicting options in a marked PPD.
- *
- * This function gets a list of options that would conflict if "option" and
- * "choice" were marked in the PPD. You would typically call this function
- * after marking the currently selected options in the PPD in order to
- * determine whether a new option selection would cause a conflict.
- *
- * The number of conflicting options are returned with "options" pointing to
- * the conflicting options. The returned option array must be freed using
- * @link cupsFreeOptions@.
- *
- * @since CUPS 1.4/macOS 10.6@
- */
-
-int /* O - Number of conflicting options */
+//
+// 'ppdGetConflicts()' - Get a list of conflicting options in a marked PPD.
+//
+// This function gets a list of options that would conflict if "option" and
+// "choice" were marked in the PPD. You would typically call this function
+// after marking the currently selected options in the PPD in order to
+// determine whether a new option selection would cause a conflict.
+//
+// The number of conflicting options are returned with "options" pointing to
+// the conflicting options. The returned option array must be freed using
+// @link cupsFreeOptions@.
+//
+// @since CUPS 1.4/macOS 10.6@
+//
+
+int // O - Number of conflicting options
ppdGetConflicts(
- ppd_file_t *ppd, /* I - PPD file */
- const char *option, /* I - Option to test */
- const char *choice, /* I - Choice to test */
- cups_option_t **options) /* O - Conflicting options */
+ ppd_file_t *ppd, // I - PPD file
+ const char *option, // I - Option to test
+ const char *choice, // I - Choice to test
+ cups_option_t **options) // O - Conflicting options
{
- int i, /* Looping var */
- num_options; /* Number of conflicting options */
- cups_array_t *active; /* Active conflicts */
- ppd_cups_uiconsts_t *c; /* Current constraints */
- ppd_cups_uiconst_t *cptr; /* Current constraint */
- ppd_choice_t *marked; /* Marked choice */
+ int i, // Looping var
+ num_options; // Number of conflicting options
+ cups_array_t *active; // Active conflicts
+ ppd_cups_uiconsts_t *c; // Current constraints
+ ppd_cups_uiconst_t *cptr; // Current constraint
+ ppd_choice_t *marked; // Marked choice
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (options)
*options = NULL;
if (!ppd || !option || !choice || !options)
return (0);
- /*
- * Test for conflicts...
- */
+ //
+ // Test for conflicts...
+ //
active = ppd_test_constraints(ppd, option, choice, 0, NULL,
_PPD_ALL_CONSTRAINTS);
- /*
- * Loop through all of the UI constraints and add any options that conflict...
- */
+ //
+ // Loop through all of the UI constraints and add any options that conflict...
+ //
for (num_options = 0, c = (ppd_cups_uiconsts_t *)cupsArrayFirst(active);
c;
}
-/*
- * 'ppdResolveConflicts()' - Resolve conflicts in a marked PPD.
- *
- * This function attempts to resolve any conflicts in a marked PPD, returning
- * a list of option changes that are required to resolve them. On input,
- * "num_options" and "options" contain any pending option changes that have
- * not yet been marked, while "option" and "choice" contain the most recent
- * selection which may or may not be in "num_options" or "options".
- *
- * On successful return, "num_options" and "options" are updated to contain
- * "option" and "choice" along with any changes required to resolve conflicts
- * specified in the PPD file and 1 is returned.
- *
- * If option conflicts cannot be resolved, "num_options" and "options" are not
- * changed and 0 is returned.
- *
- * When resolving conflicts, @code ppdResolveConflicts@ does not consider
- * changes to the current page size (@code media@, @code PageSize@, and
- * @code PageRegion@) or to the most recent option specified in "option".
- * Thus, if the only way to resolve a conflict is to change the page size
- * or the option the user most recently changed, @code ppdResolveConflicts@
- * will return 0 to indicate it was unable to resolve the conflicts.
- *
- * The @code ppdResolveConflicts@ function uses one of two sources of option
- * constraint information. The preferred constraint information is defined by
- * @code cupsUIConstraints@ and @code cupsUIResolver@ attributes - in this
- * case, the PPD file provides constraint resolution actions.
- *
- * The backup constraint information is defined by the
- * @code UIConstraints@ and @code NonUIConstraints@ attributes. These
- * constraints are resolved algorithmically by first selecting the default
- * choice for the conflicting option, then iterating over all possible choices
- * until a non-conflicting option choice is found.
- *
- * @since CUPS 1.4/macOS 10.6@
- */
-
-int /* O - 1 on success, 0 on failure */
+//
+// 'ppdResolveConflicts()' - Resolve conflicts in a marked PPD.
+//
+// This function attempts to resolve any conflicts in a marked PPD, returning
+// a list of option changes that are required to resolve them. On input,
+// "num_options" and "options" contain any pending option changes that have
+// not yet been marked, while "option" and "choice" contain the most recent
+// selection which may or may not be in "num_options" or "options".
+//
+// On successful return, "num_options" and "options" are updated to contain
+// "option" and "choice" along with any changes required to resolve conflicts
+// specified in the PPD file and 1 is returned.
+//
+// If option conflicts cannot be resolved, "num_options" and "options" are not
+// changed and 0 is returned.
+//
+// When resolving conflicts, @code ppdResolveConflicts@ does not consider
+// changes to the current page size (@code media@, @code PageSize@, and
+// @code PageRegion@) or to the most recent option specified in "option".
+// Thus, if the only way to resolve a conflict is to change the page size
+// or the option the user most recently changed, @code ppdResolveConflicts@
+// will return 0 to indicate it was unable to resolve the conflicts.
+//
+// The @code ppdResolveConflicts@ function uses one of two sources of option
+// constraint information. The preferred constraint information is defined by
+// @code cupsUIConstraints@ and @code cupsUIResolver@ attributes - in this
+// case, the PPD file provides constraint resolution actions.
+//
+// The backup constraint information is defined by the
+// @code UIConstraints@ and @code NonUIConstraints@ attributes. These
+// constraints are resolved algorithmically by first selecting the default
+// choice for the conflicting option, then iterating over all possible choices
+// until a non-conflicting option choice is found.
+//
+// @since CUPS 1.4/macOS 10.6@
+//
+
+int // O - 1 on success, 0 on failure
ppdResolveConflicts(
- ppd_file_t *ppd, /* I - PPD file */
- const char *option, /* I - Newly selected option or @code NULL@ for none */
- const char *choice, /* I - Newly selected choice or @code NULL@ for none */
- int *num_options, /* IO - Number of additional selected options */
- cups_option_t **options) /* IO - Additional selected options */
+ ppd_file_t *ppd, // I - PPD file
+ const char *option, // I - Newly selected option or
+ // @code NULL@ for none
+ const char *choice, // I - Newly selected choice or
+ // @code NULL@ for none
+ int *num_options, // IO - Number of additional selected
+ // options
+ cups_option_t **options) // IO - Additional selected options
{
- int i, /* Looping var */
- tries, /* Number of tries */
- num_newopts; /* Number of new options */
- cups_option_t *newopts; /* New options */
- cups_array_t *active = NULL, /* Active constraints */
- *pass, /* Resolvers for this pass */
- *resolvers, /* Resolvers we have used */
- *test; /* Test array for conflicts */
- ppd_cups_uiconsts_t *consts; /* Current constraints */
- ppd_cups_uiconst_t *constptr; /* Current constraint */
- ppd_attr_t *resolver; /* Current resolver */
- const char *resval; /* Pointer into resolver value */
+ int i, // Looping var
+ tries, // Number of tries
+ num_newopts; // Number of new options
+ cups_option_t *newopts; // New options
+ cups_array_t *active = NULL, // Active constraints
+ *pass, // Resolvers for this pass
+ *resolvers, // Resolvers we have used
+ *test; // Test array for conflicts
+ ppd_cups_uiconsts_t *consts; // Current constraints
+ ppd_cups_uiconst_t *constptr; // Current constraint
+ ppd_attr_t *resolver; // Current resolver
+ const char *resval; // Pointer into resolver value
char resoption[PPD_MAX_NAME],
- /* Current resolver option */
+ // Current resolver option
reschoice[PPD_MAX_NAME],
- /* Current resolver choice */
- *resptr, /* Pointer into option/choice */
- firstpage[255]; /* AP_FIRSTPAGE_Keyword string */
- const char *value; /* Selected option value */
- int changed; /* Did we change anything? */
- ppd_choice_t *marked; /* Marked choice */
+ // Current resolver choice
+ *resptr, // Pointer into option/choice
+ firstpage[255]; // AP_FIRSTPAGE_Keyword string
+ const char *value; // Selected option value
+ int changed; // Did we change anything?
+ ppd_choice_t *marked; // Marked choice
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !num_options || !options || (option == NULL) != (choice == NULL))
return (0);
- /*
- * Build a shadow option array...
- */
+ //
+ // Build a shadow option array...
+ //
num_newopts = 0;
newopts = NULL;
if (option && _ppd_strcasecmp(option, "Collate"))
num_newopts = cupsAddOption(option, choice, num_newopts, &newopts);
- /*
- * Loop until we have no conflicts...
- */
+ //
+ // Loop until we have no conflicts...
+ //
cupsArraySave(ppd->sorted_attrs);
{
if (consts->resolver[0])
{
- /*
- * Look up the resolver...
- */
+ //
+ // Look up the resolver...
+ //
if (cupsArrayFind(pass, consts->resolver))
- continue; /* Already applied this resolver... */
+ continue; // Already applied this resolver...
if (cupsArrayFind(resolvers, consts->resolver))
{
- /*
- * Resolver loop!
- */
+ //
+ // Resolver loop!
+ //
DEBUG_printf(("1ppdResolveConflicts: Resolver loop with %s!",
consts->resolver));
goto error;
}
- /*
- * Add the options from the resolver...
- */
+ //
+ // Add the options from the resolver...
+ //
cupsArrayAdd(pass, consts->resolver);
cupsArrayAdd(resolvers, consts->resolver);
if (!resoption[0] || !reschoice[0])
break;
- /*
- * Is this the option we are changing?
- */
+ //
+ // Is this the option we are changing?
+ //
snprintf(firstpage, sizeof(firstpage), "AP_FIRSTPAGE_%s", resoption);
!_ppd_strcasecmp(resoption, "PageRegion"))))
continue;
- /*
- * Try this choice...
- */
+ //
+ // Try this choice...
+ //
if ((test = ppd_test_constraints(ppd, resoption, reschoice,
num_newopts, newopts,
_PPD_ALL_CONSTRAINTS)) == NULL)
{
- /*
- * That worked...
- */
+ //
+ // That worked...
+ //
changed = 1;
}
else
cupsArrayDelete(test);
- /*
- * Add the option/choice from the resolver regardless of whether it
- * worked; this makes sure that we can cascade several changes to
- * make things resolve...
- */
+ //
+ // Add the option/choice from the resolver regardless of whether it
+ // worked; this makes sure that we can cascade several changes to
+ // make things resolve...
+ //
num_newopts = cupsAddOption(resoption, reschoice, num_newopts,
&newopts);
}
else
{
- /*
- * Try resolving by choosing the default values for non-installable
- * options, then by iterating through the possible choices...
- */
+ //
+ // Try resolving by choosing the default values for non-installable
+ // options, then by iterating through the possible choices...
+ //
- int j; /* Looping var */
- ppd_choice_t *cptr; /* Current choice */
- ppd_size_t *size; /* Current page size */
+ int j; // Looping var
+ ppd_choice_t *cptr; // Current choice
+ ppd_size_t *size; // Current page size
for (i = consts->num_constraints, constptr = consts->constraints;
i > 0 && !changed;
i --, constptr ++)
{
- /*
- * Can't resolve by changing an installable option...
- */
+ //
+ // Can't resolve by changing an installable option...
+ //
if (constptr->installable)
continue;
- /*
- * Is this the option we are changing?
- */
+ //
+ // Is this the option we are changing?
+ //
if (option &&
(!_ppd_strcasecmp(constptr->option->keyword, option) ||
!_ppd_strcasecmp(constptr->option->keyword, "PageSize"))))
continue;
- /*
- * Get the current option choice...
- */
+ //
+ // Get the current option choice...
+ //
if ((value = cupsGetOption(constptr->option->keyword, num_newopts,
newopts)) == NULL)
if (!_ppd_strncasecmp(value, "Custom.", 7))
value = "Custom";
- /*
- * Try the default choice...
- */
+ //
+ // Try the default choice...
+ //
test = NULL;
num_newopts, newopts,
_PPD_OPTION_CONSTRAINTS)) == NULL)
{
- /*
- * That worked...
- */
+ //
+ // That worked...
+ //
num_newopts = cupsAddOption(constptr->option->keyword,
constptr->option->defchoice,
}
else
{
- /*
- * Try each choice instead...
- */
+ //
+ // Try each choice instead...
+ //
for (j = constptr->option->num_choices,
cptr = constptr->option->choices;
(test = ppd_test_constraints(ppd, constptr->option->keyword,
cptr->choice, num_newopts,
newopts,
- _PPD_OPTION_CONSTRAINTS)) == NULL)
+ _PPD_OPTION_CONSTRAINTS)) ==
+ NULL)
{
- /*
- * This choice works...
- */
+ //
+ // This choice works...
+ //
num_newopts = cupsAddOption(constptr->option->keyword,
cptr->choice, num_newopts,
if (tries >= 100)
goto error;
- /*
- * Free the caller's option array...
- */
+ //
+ // Free the caller's option array...
+ //
cupsFreeOptions(*num_options, *options);
- /*
- * If Collate is the option we are testing, add it here. Otherwise, remove
- * any Collate option from the resolve list since the filters automatically
- * handle manual collation...
- */
+ //
+ // If Collate is the option we are testing, add it here. Otherwise, remove
+ // any Collate option from the resolve list since the filters automatically
+ // handle manual collation...
+ //
if (option && !_ppd_strcasecmp(option, "Collate"))
num_newopts = cupsAddOption(option, choice, num_newopts, &newopts);
else
num_newopts = cupsRemoveOption("Collate", num_newopts, &newopts);
- /*
- * Return the new list of options to the caller...
- */
+ //
+ // Return the new list of options to the caller...
+ //
*num_options = num_newopts;
*options = newopts;
for (i = 0; i < num_newopts; i ++)
DEBUG_printf(("1ppdResolveConflicts: options[%d]: %s=%s", i,
newopts[i].name, newopts[i].value));
-#endif /* DEBUG */
+#endif // DEBUG
return (1);
- /*
- * If we get here, we failed to resolve...
- */
+ //
+ // If we get here, we failed to resolve...
+ //
- error:
+ error:
cupsFreeOptions(num_newopts, newopts);
}
-/*
- * 'ppdConflicts()' - Check to see if there are any conflicts among the
- * marked option choices.
- *
- * The returned value is the same as returned by @link ppdMarkOption@.
- */
+//
+// 'ppdConflicts()' - Check to see if there are any conflicts among the
+// marked option choices.
+//
+// The returned value is the same as returned by @link ppdMarkOption@.
+//
-int /* O - Number of conflicts found */
-ppdConflicts(ppd_file_t *ppd) /* I - PPD to check */
+int // O - Number of conflicts found
+ppdConflicts(ppd_file_t *ppd) // I - PPD to check
{
- int i, /* Looping variable */
- conflicts; /* Number of conflicts */
- cups_array_t *active; /* Active conflicts */
- ppd_cups_uiconsts_t *c; /* Current constraints */
- ppd_cups_uiconst_t *cptr; /* Current constraint */
- ppd_option_t *o; /* Current option */
+ int i, // Looping variable
+ conflicts; // Number of conflicts
+ cups_array_t *active; // Active conflicts
+ ppd_cups_uiconsts_t *c; // Current constraints
+ ppd_cups_uiconst_t *cptr; // Current constraint
+ ppd_option_t *o; // Current option
if (!ppd)
return (0);
- /*
- * Clear all conflicts...
- */
+ //
+ // Clear all conflicts...
+ //
cupsArraySave(ppd->options);
cupsArrayRestore(ppd->options);
- /*
- * Test for conflicts...
- */
+ //
+ // Test for conflicts...
+ //
active = ppd_test_constraints(ppd, NULL, NULL, 0, NULL,
_PPD_ALL_CONSTRAINTS);
conflicts = cupsArrayCount(active);
- /*
- * Loop through all of the UI constraints and flag any options
- * that conflict...
- */
+ //
+ // Loop through all of the UI constraints and flag any options
+ // that conflict...
+ //
for (c = (ppd_cups_uiconsts_t *)cupsArrayFirst(active);
c;
cupsArrayDelete(active);
- /*
- * Return the number of conflicts found...
- */
+ //
+ // Return the number of conflicts found...
+ //
return (conflicts);
}
-/*
- * 'ppdInstallableConflict()' - Test whether an option choice conflicts with
- * an installable option.
- *
- * This function tests whether a particular option choice is available based
- * on constraints against options in the "InstallableOptions" group.
- *
- * @since CUPS 1.4/macOS 10.6@
- */
+//
+// 'ppdInstallableConflict()' - Test whether an option choice conflicts with
+// an installable option.
+//
+// This function tests whether a particular option choice is available based
+// on constraints against options in the "InstallableOptions" group.
+//
+// @since CUPS 1.4/macOS 10.6@
+//
-int /* O - 1 if conflicting, 0 if not conflicting */
+int // O - 1 if conflicting, 0 if not conflicting
ppdInstallableConflict(
- ppd_file_t *ppd, /* I - PPD file */
- const char *option, /* I - Option */
- const char *choice) /* I - Choice */
+ ppd_file_t *ppd, // I - PPD file
+ const char *option, // I - Option
+ const char *choice) // I - Choice
{
- cups_array_t *active; /* Active conflicts */
+ cups_array_t *active; // Active conflicts
DEBUG_printf(("2ppdInstallableConflict(ppd=%p, option=\"%s\", choice=\"%s\")",
ppd, option, choice));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !option || !choice)
return (0);
- /*
- * Test constraints using the new option...
- */
+ //
+ // Test constraints using the new option...
+ //
active = ppd_test_constraints(ppd, option, choice, 0, NULL,
_PPD_INSTALLABLE_CONSTRAINTS);
}
-/*
- * 'ppd_is_installable()' - Determine whether an option is in the
- * InstallableOptions group.
- */
+//
+// 'ppd_is_installable()' - Determine whether an option is in the
+// InstallableOptions group.
+//
-static int /* O - 1 if installable, 0 if normal */
+static int // O - 1 if installable, 0 if normal
ppd_is_installable(
- ppd_group_t *installable, /* I - InstallableOptions group */
- const char *name) /* I - Option name */
+ ppd_group_t *installable, // I - InstallableOptions group
+ const char *name) // I - Option name
{
if (installable)
{
- int i; /* Looping var */
- ppd_option_t *option; /* Current option */
+ int i; // Looping var
+ ppd_option_t *option; // Current option
for (i = installable->num_options, option = installable->options;
}
-/*
- * 'ppd_load_constraints()' - Load constraints from a PPD file.
- */
+//
+// 'ppd_load_constraints()' - Load constraints from a PPD file.
+//
static void
-ppd_load_constraints(ppd_file_t *ppd) /* I - PPD file */
+ppd_load_constraints(ppd_file_t *ppd) // I - PPD file
{
- int i; /* Looping var */
- ppd_const_t *oldconst; /* Current UIConstraints data */
- ppd_attr_t *constattr; /* Current cupsUIConstraints attribute */
- ppd_cups_uiconsts_t *consts; /* Current cupsUIConstraints data */
- ppd_cups_uiconst_t *constptr; /* Current constraint */
- ppd_group_t *installable; /* Installable options group */
- const char *vptr; /* Pointer into constraint value */
- char option[PPD_MAX_NAME], /* Option name/MainKeyword */
- choice[PPD_MAX_NAME], /* Choice/OptionKeyword */
- *ptr; /* Pointer into option or choice */
+ int i; // Looping var
+ ppd_const_t *oldconst; // Current UIConstraints data
+ ppd_attr_t *constattr; // Current cupsUIConstraints attribute
+ ppd_cups_uiconsts_t *consts; // Current cupsUIConstraints data
+ ppd_cups_uiconst_t *constptr; // Current constraint
+ ppd_group_t *installable; // Installable options group
+ const char *vptr; // Pointer into constraint value
+ char option[PPD_MAX_NAME], // Option name/MainKeyword
+ choice[PPD_MAX_NAME], // Choice/OptionKeyword
+ *ptr; // Pointer into option or choice
DEBUG_printf(("7ppd_load_constraints(ppd=%p)", ppd));
- /*
- * Create an array to hold the constraint data...
- */
+ //
+ // Create an array to hold the constraint data...
+ //
ppd->cups_uiconstraints = cupsArrayNew(NULL, NULL);
- /*
- * Find the installable options group if it exists...
- */
+ //
+ // Find the installable options group if it exists...
+ //
for (i = ppd->num_groups, installable = ppd->groups;
i > 0;
if (i <= 0)
installable = NULL;
- /*
- * Load old-style [Non]UIConstraints data...
- */
+ //
+ // Load old-style [Non]UIConstraints data...
+ //
for (i = ppd->num_consts, oldconst = ppd->consts; i > 0; i --, oldconst ++)
{
- /*
- * Weed out nearby duplicates, since the PPD spec requires that you
- * define both "*Foo foo *Bar bar" and "*Bar bar *Foo foo"...
- */
+ //
+ // Weed out nearby duplicates, since the PPD spec requires that you
+ // define both "*Foo foo *Bar bar" and "*Bar bar *Foo foo"...
+ //
if (i > 1 &&
!_ppd_strcasecmp(oldconst[0].option1, oldconst[1].option2) &&
!_ppd_strcasecmp(oldconst[0].choice2, oldconst[1].choice1))
continue;
- /*
- * Allocate memory...
- */
+ //
+ // Allocate memory...
+ //
if ((consts = calloc(1, sizeof(ppd_cups_uiconsts_t))) == NULL)
{
return;
}
- /*
- * Fill in the information...
- */
+ //
+ // Fill in the information...
+ //
consts->num_constraints = 2;
consts->constraints = constptr;
consts->installable = constptr[0].installable || constptr[1].installable;
- /*
- * Add it to the constraints array...
- */
+ //
+ // Add it to the constraints array...
+ //
cupsArrayAdd(ppd->cups_uiconstraints, consts);
}
- /*
- * Then load new-style constraints...
- */
+ //
+ // Then load new-style constraints...
+ //
for (constattr = ppdFindAttr(ppd, "cupsUIConstraints", NULL);
constattr;
vptr;
i ++, vptr = strchr(vptr, '*'), constptr ++)
{
- /*
- * Extract "*Option Choice" or just "*Option"...
- */
+ //
+ // Extract "*Option Choice" or just "*Option"...
+ //
for (vptr ++, ptr = option; *vptr && !_ppd_isspace(*vptr); vptr ++)
if (ptr < (option + sizeof(option) - 1))
*ptr = '\0';
}
- if (!_ppd_strncasecmp(option, "Custom", 6) && !_ppd_strcasecmp(choice, "True"))
+ if (!_ppd_strncasecmp(option, "Custom", 6) &&
+ !_ppd_strcasecmp(choice, "True"))
{
_ppd_strcpy(option, option + 6);
strlcpy(choice, "Custom", sizeof(choice));
}
-/*
- * 'ppd_test_constraints()' - See if any constraints are active.
- */
+//
+// 'ppd_test_constraints()' - See if any constraints are active.
+//
-static cups_array_t * /* O - Array of active constraints */
+static cups_array_t * // O - Array of active constraints
ppd_test_constraints(
- ppd_file_t *ppd, /* I - PPD file */
- const char *option, /* I - Current option */
- const char *choice, /* I - Current choice */
- int num_options, /* I - Number of additional options */
- cups_option_t *options, /* I - Additional options */
- int which) /* I - Which constraints to test */
+ ppd_file_t *ppd, // I - PPD file
+ const char *option, // I - Current option
+ const char *choice, // I - Current choice
+ int num_options, // I - Number of additional options
+ cups_option_t *options, // I - Additional options
+ int which) // I - Which constraints to test
{
- int i; /* Looping var */
- ppd_cups_uiconsts_t *consts; /* Current constraints */
- ppd_cups_uiconst_t *constptr; /* Current constraint */
- ppd_choice_t key, /* Search key */
- *marked; /* Marked choice */
- cups_array_t *active = NULL; /* Active constraints */
- const char *value, /* Current value */
- *firstvalue; /* AP_FIRSTPAGE_Keyword value */
- char firstpage[255]; /* AP_FIRSTPAGE_Keyword string */
+ int i; // Looping var
+ ppd_cups_uiconsts_t *consts; // Current constraints
+ ppd_cups_uiconst_t *constptr; // Current constraint
+ ppd_choice_t key, // Search key
+ *marked; // Marked choice
+ cups_array_t *active = NULL; // Active constraints
+ const char *value, // Current value
+ *firstvalue; // AP_FIRSTPAGE_Keyword value
+ char firstpage[255]; // AP_FIRSTPAGE_Keyword string
DEBUG_printf(("7ppd_test_constraints(ppd=%p, option=\"%s\", choice=\"%s\", "
DEBUG_printf(("9ppd_test_constraints: installable=%d, resolver=\"%s\", "
"num_constraints=%d option1=\"%s\", choice1=\"%s\", "
"option2=\"%s\", choice2=\"%s\", ...",
- consts->installable, consts->resolver, consts->num_constraints,
+ consts->installable, consts->resolver,
+ consts->num_constraints,
consts->constraints[0].option->keyword,
consts->constraints[0].choice ?
- consts->constraints[0].choice->choice : "",
+ consts->constraints[0].choice->choice : "",
consts->constraints[1].option->keyword,
consts->constraints[1].choice ?
- consts->constraints[1].choice->choice : ""));
+ consts->constraints[1].choice->choice : ""));
if (consts->installable && which < _PPD_INSTALLABLE_CONSTRAINTS)
- continue; /* Skip installable option constraint */
+ continue; // Skip installable option constraint
if (!consts->installable && which == _PPD_INSTALLABLE_CONSTRAINTS)
- continue; /* Skip non-installable option constraint */
+ continue; // Skip non-installable option constraint
- if ((which == _PPD_OPTION_CONSTRAINTS || which == _PPD_INSTALLABLE_CONSTRAINTS) && option)
+ if ((which == _PPD_OPTION_CONSTRAINTS ||
+ which == _PPD_INSTALLABLE_CONSTRAINTS) && option)
{
- /*
- * Skip constraints that do not involve the current option...
- */
+ //
+ // Skip constraints that do not involve the current option...
+ //
for (i = consts->num_constraints, constptr = consts->constraints;
i > 0;
(!_ppd_strcasecmp(constptr->option->keyword, "PageSize") ||
!_ppd_strcasecmp(constptr->option->keyword, "PageRegion")))
{
- /*
- * PageSize and PageRegion are used depending on the selected input slot
- * and manual feed mode. Validate against the selected page size instead
- * of an individual option...
- */
+ //
+ // PageSize and PageRegion are used depending on the selected
+ // input slot and manual feed mode. Validate against the
+ // selected page size instead of an individual option...
+ //
if (option && choice &&
(!_ppd_strcasecmp(option, "PageSize") ||
}
else if (constptr->choice)
{
- /*
- * Compare against the constrained choice...
- */
+ //
+ // Compare against the constrained choice...
+ //
- if (option && choice && !_ppd_strcasecmp(option, constptr->option->keyword))
+ if (option && choice &&
+ !_ppd_strcasecmp(option, constptr->option->keyword))
{
if (!_ppd_strncasecmp(choice, "Custom.", 7))
value = "Custom";
else
value = NULL;
- /*
- * Now check AP_FIRSTPAGE_option...
- */
+ //
+ // Now check AP_FIRSTPAGE_option...
+ //
snprintf(firstpage, sizeof(firstpage), "AP_FIRSTPAGE_%s",
constptr->option->keyword);
-/*
- * PPD custom option routines for libppd.
- *
- * Copyright 2007-2015 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
-
-/*
- * Include necessary headers.
- */
+//
+// PPD custom option routines for libppd.
+//
+// Copyright 2007-2015 by Apple Inc.
+// Copyright 1997-2006 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
+
+//
+// Include necessary headers.
+//
#include "string-private.h"
#include "ppd.h"
#include "debug-internal.h"
-/*
- * 'ppdFindCustomOption()' - Find a custom option.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdFindCustomOption()' - Find a custom option.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ppd_coption_t * /* O - Custom option or NULL */
-ppdFindCustomOption(ppd_file_t *ppd, /* I - PPD file */
- const char *keyword)/* I - Custom option name */
+ppd_coption_t * // O - Custom option or NULL
+ppdFindCustomOption(ppd_file_t *ppd, // I - PPD file
+ const char *keyword)// I - Custom option name
{
- ppd_coption_t key; /* Custom option search key */
+ ppd_coption_t key; // Custom option search key
if (!ppd)
}
-/*
- * 'ppdFindCustomParam()' - Find a parameter for a custom option.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdFindCustomParam()' - Find a parameter for a custom option.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ppd_cparam_t * /* O - Custom parameter or NULL */
-ppdFindCustomParam(ppd_coption_t *opt, /* I - Custom option */
- const char *name) /* I - Parameter name */
+ppd_cparam_t * // O - Custom parameter or NULL
+ppdFindCustomParam(ppd_coption_t *opt, // I - Custom option
+ const char *name) // I - Parameter name
{
- ppd_cparam_t *param; /* Current custom parameter */
+ ppd_cparam_t *param; // Current custom parameter
if (!opt)
}
-/*
- * 'ppdFirstCustomParam()' - Return the first parameter for a custom option.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdFirstCustomParam()' - Return the first parameter for a custom option.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ppd_cparam_t * /* O - Custom parameter or NULL */
-ppdFirstCustomParam(ppd_coption_t *opt) /* I - Custom option */
+ppd_cparam_t * // O - Custom parameter or NULL
+ppdFirstCustomParam(ppd_coption_t *opt) // I - Custom option
{
if (!opt)
return (NULL);
}
-/*
- * 'ppdNextCustomParam()' - Return the next parameter for a custom option.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdNextCustomParam()' - Return the next parameter for a custom option.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ppd_cparam_t * /* O - Custom parameter or NULL */
-ppdNextCustomParam(ppd_coption_t *opt) /* I - Custom option */
+ppd_cparam_t * // O - Custom parameter or NULL
+ppdNextCustomParam(ppd_coption_t *opt) // I - Custom option
{
if (!opt)
return (NULL);
-/*
- * PPD code emission routines for libppd.
- *
- * Copyright 2007-2019 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// PPD code emission routines for libppd.
+//
+// Copyright 2007-2019 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "debug-internal.h"
# include <io.h>
#else
# include <unistd.h>
-#endif /* _WIN32 || __EMX__ */
+#endif // _WIN32 || __EMX__
#include <errno.h>
#include <ctype.h>
#include <string.h>
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static int ppd_compare_cparams(ppd_cparam_t *a, ppd_cparam_t *b);
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
static const char ppd_custom_code[] =
"pop pop pop\n"
"<</PageSize[5 -2 roll]/ImagingBBox null>>setpagedevice\n";
-/*
- * 'ppdCollect()' - Collect all marked options that reside in the specified
- * section.
- *
- * The choices array should be freed using @code free@ when you are
- * finished with it.
- */
+//
+// 'ppdCollect()' - Collect all marked options that reside in the specified
+// section.
+//
+// The choices array should be freed using @code free@ when you are
+// finished with it.
+//
-int /* O - Number of options marked */
-ppdCollect(ppd_file_t *ppd, /* I - PPD file data */
- ppd_section_t section, /* I - Section to collect */
- ppd_choice_t ***choices) /* O - Pointers to choices */
+int // O - Number of options marked
+ppdCollect(ppd_file_t *ppd, // I - PPD file data
+ ppd_section_t section, // I - Section to collect
+ ppd_choice_t ***choices) // O - Pointers to choices
{
return (ppdCollect2(ppd, section, 0.0, choices));
}
-/*
- * 'ppdCollect2()' - Collect all marked options that reside in the
- * specified section and minimum order.
- *
- * The choices array should be freed using @code free@ when you are
- * finished with it.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
-
-int /* O - Number of options marked */
-ppdCollect2(ppd_file_t *ppd, /* I - PPD file data */
- ppd_section_t section, /* I - Section to collect */
- float min_order, /* I - Minimum OrderDependency value */
- ppd_choice_t ***choices) /* O - Pointers to choices */
+//
+// 'ppdCollect2()' - Collect all marked options that reside in the
+// specified section and minimum order.
+//
+// The choices array should be freed using @code free@ when you are
+// finished with it.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
+
+int // O - Number of options marked
+ppdCollect2(ppd_file_t *ppd, // I - PPD file data
+ ppd_section_t section, // I - Section to collect
+ float min_order, // I - Minimum OrderDependency value
+ ppd_choice_t ***choices) // O - Pointers to choices
{
- ppd_choice_t *c; /* Current choice */
- ppd_section_t csection; /* Current section */
- float corder; /* Current OrderDependency value */
- int count; /* Number of choices collected */
- ppd_choice_t **collect; /* Collected choices */
- float *orders; /* Collected order values */
+ ppd_choice_t *c; // Current choice
+ ppd_section_t csection; // Current section
+ float corder; // Current OrderDependency value
+ int count; // Number of choices collected
+ ppd_choice_t **collect; // Collected choices
+ float *orders; // Collected order values
DEBUG_printf(("ppdCollect2(ppd=%p, section=%d, min_order=%f, choices=%p)",
return (0);
}
- /*
- * Allocate memory for up to N selected choices...
- */
+ //
+ // Allocate memory for up to N selected choices...
+ //
count = 0;
if ((collect = calloc(sizeof(ppd_choice_t *),
return (0);
}
- if ((orders = calloc(sizeof(float), (size_t)cupsArrayCount(ppd->marked))) == NULL)
+ if ((orders = calloc(sizeof(float),
+ (size_t)cupsArrayCount(ppd->marked))) == NULL)
{
*choices = NULL;
free(collect);
return (0);
}
- /*
- * Loop through all options and add choices as needed...
- */
+ //
+ // Loop through all options and add choices as needed...
+ //
for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked);
c;
if (!strcmp(c->choice, "Custom"))
{
- ppd_attr_t *attr; /* NonUIOrderDependency value */
- float aorder; /* Order value */
- char asection[17], /* Section name */
+ ppd_attr_t *attr; // NonUIOrderDependency value
+ float aorder; // Order value
+ char asection[17], // Section name
amain[PPD_MAX_NAME + 1],
aoption[PPD_MAX_NAME];
- /* *CustomFoo and True */
+ // *CustomFoo and True
for (attr = ppdFindAttr(ppd, "NonUIOrderDependency", NULL);
!strncmp(amain, "*Custom", 7) &&
!strcmp(amain + 7, c->option->keyword) && !strcmp(aoption, "True"))
{
- /*
- * Use this NonUIOrderDependency...
- */
+ //
+ // Use this NonUIOrderDependency...
+ //
corder = aorder;
csection = PPD_ORDER_PROLOG;
else
csection = PPD_ORDER_ANY;
-
break;
}
}
}
}
- /*
- * If we have more than 1 marked choice, sort them...
- */
+ //
+ // If we have more than 1 marked choice, sort them...
+ //
if (count > 1)
{
- int i, j; /* Looping vars */
+ int i, j; // Looping vars
for (i = 0; i < (count - 1); i ++)
for (j = i + 1; j < count; j ++)
DEBUG_printf(("2ppdCollect2: %d marked choices...", count));
- /*
- * Return the array and number of choices; if 0, free the array since
- * it isn't needed.
- */
+ //
+ // Return the array and number of choices; if 0, free the array since
+ // it isn't needed.
+ //
if (count > 0)
{
}
-/*
- * 'ppdEmit()' - Emit code for marked options to a file.
- */
+//
+// 'ppdEmit()' - Emit code for marked options to a file.
+//
-int /* O - 0 on success, -1 on failure */
-ppdEmit(ppd_file_t *ppd, /* I - PPD file record */
- FILE *fp, /* I - File to write to */
- ppd_section_t section) /* I - Section to write */
+int // O - 0 on success, -1 on failure
+ppdEmit(ppd_file_t *ppd, // I - PPD file record
+ FILE *fp, // I - File to write to
+ ppd_section_t section) // I - Section to write
{
return (ppdEmitAfterOrder(ppd, fp, section, 0, 0.0));
}
-/*
- * 'ppdEmitAfterOrder()' - Emit a subset of the code for marked options to a file.
- *
- * When "limit" is non-zero, this function only emits options whose
- * OrderDependency value is greater than or equal to "min_order".
- *
- * When "limit" is zero, this function is identical to ppdEmit().
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdEmitAfterOrder()' - Emit a subset of the code for marked options
+// to a file.
+//
+// When "limit" is non-zero, this function only emits options whose
+// OrderDependency value is greater than or equal to "min_order".
+//
+// When "limit" is zero, this function is identical to ppdEmit().
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-int /* O - 0 on success, -1 on failure */
+int // O - 0 on success, -1 on failure
ppdEmitAfterOrder(
- ppd_file_t *ppd, /* I - PPD file record */
- FILE *fp, /* I - File to write to */
- ppd_section_t section, /* I - Section to write */
- int limit, /* I - Non-zero to use min_order */
- float min_order) /* I - Lowest OrderDependency */
+ ppd_file_t *ppd, // I - PPD file record
+ FILE *fp, // I - File to write to
+ ppd_section_t section, // I - Section to write
+ int limit, // I - Non-zero to use min_order
+ float min_order) // I - Lowest OrderDependency
{
- char *buffer; /* Option code */
- int status; /* Return status */
+ char *buffer; // Option code
+ int status; // Return status
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !fp)
return (-1);
- /*
- * Get the string...
- */
+ //
+ // Get the string...
+ //
buffer = ppdEmitString(ppd, section, limit ? min_order : 0.0f);
- /*
- * Write it as needed and return...
- */
+ //
+ // Write it as needed and return...
+ //
if (buffer)
{
}
-/*
- * 'ppdEmitFd()' - Emit code for marked options to a file.
- */
+//
+// 'ppdEmitFd()' - Emit code for marked options to a file.
+//
-int /* O - 0 on success, -1 on failure */
-ppdEmitFd(ppd_file_t *ppd, /* I - PPD file record */
- int fd, /* I - File to write to */
- ppd_section_t section) /* I - Section to write */
+int // O - 0 on success, -1 on failure
+ppdEmitFd(ppd_file_t *ppd, // I - PPD file record
+ int fd, // I - File to write to
+ ppd_section_t section) // I - Section to write
{
- char *buffer, /* Option code */
- *bufptr; /* Pointer into code */
- size_t buflength; /* Length of option code */
- ssize_t bytes; /* Bytes written */
- int status; /* Return status */
+ char *buffer, // Option code
+ *bufptr; // Pointer into code
+ size_t buflength; // Length of option code
+ ssize_t bytes; // Bytes written
+ int status; // Return status
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || fd < 0)
return (-1);
- /*
- * Get the string...
- */
+ //
+ // Get the string...
+ //
buffer = ppdEmitString(ppd, section, 0.0);
- /*
- * Write it as needed and return...
- */
+ //
+ // Write it as needed and return...
+ //
if (buffer)
{
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;
}
-/*
- * 'ppdEmitJCL()' - Emit code for JCL options to a file (for PostScript
- * output).
- */
+//
+// 'ppdEmitJCL()' - Emit code for JCL options to a file (for PostScript
+// output).
+//
-int /* O - 0 on success, -1 on failure */
-ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */
- FILE *fp, /* I - File to write to */
- int job_id, /* I - Job ID */
- const char *user, /* I - Username */
- const char *title) /* I - Title */
+int // O - 0 on success, -1 on failure
+ppdEmitJCL(ppd_file_t *ppd, // I - PPD file record
+ FILE *fp, // I - File to write to
+ int job_id, // I - Job ID
+ const char *user, // I - Username
+ const char *title) // I - Title
{
return ppdEmitJCLPDF(ppd, fp, job_id, user, title, -1, false);
}
-/*
- * 'ppdEmitJCLPDF()' - Emit code for JCL options to a file (for PDF output).
- */
-
-int /* O - 0 on success, -1 on failure */
-ppdEmitJCLPDF(ppd_file_t *ppd, /* I - PPD file record */
- FILE *fp, /* I - File to write to */
- int job_id, /* I - Job ID */
- const char *user, /* I - Username */
- const char *title, /* I - Title */
- int hw_copies, /* I - Number of hardware (device)
- copies, -1: PS mode */
- bool hw_collate) /* I - Do we have hardware (device)
- collate? */
+//
+// 'ppdEmitJCLPDF()' - Emit code for JCL options to a file (for PDF output).
+//
+
+int // O - 0 on success, -1 on failure
+ppdEmitJCLPDF(ppd_file_t *ppd, // I - PPD file record
+ FILE *fp, // I - File to write to
+ int job_id, // I - Job ID
+ const char *user, // I - Username
+ const char *title, // I - Title
+ int hw_copies, // I - Number of hardware (device)
+ // copies, -1: PS mode
+ bool hw_collate) // I - Do we have hardware (device)
+ // collate?
{
- ppd_attr_t *attr; /* PPD attribute */
+ ppd_attr_t *attr; // PPD attribute
const char *jcl_pdf = NULL;
- char *ptr; /* Pointer into JCL string */
- char temp[65], /* Local title string */
- displaymsg[33]; /* Local display string */
-
+ char *ptr; // Pointer into JCL string
+ char temp[65], // Local title string
+ displaymsg[33]; // Local display string
- /*
- * Range check the input...
- */
+ //
+ // Range check the input...
+ //
if (!ppd || !ppd->jcl_begin)
return (0);
(!jcl_pdf && hw_copies >= 0))
return (0);
- /*
- * See if the printer supports HP PJL...
- */
+ //
+ // See if the printer supports HP PJL...
+ //
if (!strncmp(ppd->jcl_begin, "\033%-12345X@", 10))
{
- /*
- * This printer uses HP PJL commands for output; filter the output
- * so that we only have a single "@PJL JOB" command in the header...
- *
- * To avoid bugs in the PJL implementation of certain vendors' products
- * (Xerox in particular), we add a dummy "@PJL" command at the beginning
- * of the PJL commands to initialize PJL processing.
- */
+ //
+ // This printer uses HP PJL commands for output; filter the output
+ // so that we only have a single "@PJL JOB" command in the header...
+ //
+ // To avoid bugs in the PJL implementation of certain vendors' products
+ // (Xerox in particular), we add a dummy "@PJL" command at the beginning
+ // of the PJL commands to initialize PJL processing.
+ //
- ppd_attr_t *charset; /* PJL charset */
- ppd_attr_t *display; /* PJL display command */
+ ppd_attr_t *charset; // PJL charset
+ ppd_attr_t *display; // PJL display command
if ((charset = ppdFindAttr(ppd, "cupsPJLCharset", NULL)) != NULL)
for (ptr = ppd->jcl_begin + 9; *ptr;)
if (!strncmp(ptr, "@PJL JOB", 8))
{
- /*
- * Skip job command...
- */
+ //
+ // Skip job command...
+ //
for (;*ptr; ptr ++)
if (*ptr == '\n')
}
else
{
- /*
- * Copy line...
- */
+ //
+ // Copy line...
+ //
for (;*ptr; ptr ++)
{
ptr ++;
}
- /*
- * Clean up the job title...
- */
+ //
+ // Clean up the job title...
+ //
if (!title)
title = "Unknown";
if ((ptr = strrchr(title, '/')) != NULL)
{
- /*
- * Only show basename of file path...
- */
+ //
+ // Only show basename of file path...
+ //
title = ptr + 1;
}
if (!strncmp(title, "smbprn.", 7))
{
- /*
- * Skip leading smbprn.######## from Samba jobs...
- */
+ //
+ // Skip leading smbprn.######## from Samba jobs...
+ //
for (title += 7; *title && isdigit(*title & 255); title ++);
while (_ppd_isspace(*title))
if ((ptr = strstr(title, " - ")) != NULL)
{
- /*
- * Skip application name in "Some Application - Title of job"...
- */
+ //
+ // Skip application name in "Some Application - Title of job"...
+ //
title = ptr + 3;
}
}
- /*
- * Replace double quotes with single quotes and UTF-8 characters with
- * question marks so that the title does not cause a PJL syntax error.
- */
+ //
+ // Replace double quotes with single quotes and UTF-8 characters with
+ // question marks so that the title does not cause a PJL syntax error.
+ //
strlcpy(temp, title, sizeof(temp));
else if (!charset && (*ptr & 128))
*ptr = '?';
- /*
- * CUPS STR #3125: Long PJL JOB NAME causes problems with some printers
- *
- * Generate the display message, truncating at 32 characters + nul to avoid
- * issues with some printer's PJL implementations...
- */
+ //
+ // CUPS STR #3125: Long PJL JOB NAME causes problems with some printers
+ //
+ // Generate the display message, truncating at 32 characters + nul to avoid
+ // issues with some printer's PJL implementations...
+ //
if (!user)
user = "anonymous";
- snprintf(displaymsg, sizeof(displaymsg), "%d %.8s %.17s", job_id, user, temp);
+ snprintf(displaymsg, sizeof(displaymsg), "%d %.8s %.17s", job_id, user,
+ temp);
- /*
- * Send PJL JOB and PJL RDYMSG commands before we enter PostScript mode...
- */
+ //
+ // Send PJL JOB and PJL RDYMSG commands before we enter PostScript mode...
+ //
if (display && strcmp(display->value, "job"))
fprintf(fp, "@PJL JOB NAME = \"%s\"\n", temp);
fprintf(fp, "@PJL JOB NAME = \"%s\" DISPLAY = \"%s\"\n", temp,
displaymsg);
- /*
- * Replace double quotes with single quotes and UTF-8 characters with
- * question marks so that the user does not cause a PJL syntax error.
- */
+ //
+ // Replace double quotes with single quotes and UTF-8 characters with
+ // question marks so that the user does not cause a PJL syntax error.
+ //
strlcpy(temp, user, sizeof(temp));
ppdEmit(ppd, fp, PPD_ORDER_JCL);
if (hw_copies < 0)
- /* PostScript output */
+ // PostScript output
fputs(ppd->jcl_ps, fp);
else
{
- /* PDF output */
+ // PDF output
int hw_copies_done = 0;
- /* There is a "Copies" option in the PPD file, so this option setting
- always takes care of correct implementation of the copies */
+ // There is a "Copies" option in the PPD file, so this option setting
+ // always takes care of correct implementation of the copies
if (ppdFindOption(ppd,"Copies") != NULL &&
hw_copies > 1)
hw_copies_done = 1;
if (hw_copies > 1 && hw_copies_done == 0 && // HW copies
strncmp(ppd->jcl_begin, "\033%-12345X@", 10) == 0) // PJL
- /* Add a PJL command to implement the hardware copies */
+ // Add a PJL command to implement the hardware copies
fprintf(fp, "@PJL SET %s=%d\n", hw_collate ? "QTY" : "COPIES",
hw_copies);
}
-/*
- * 'ppdEmitJCLEnd()' - Emit JCLEnd code to a file.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdEmitJCLEnd()' - Emit JCLEnd code to a file.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-int /* O - 0 on success, -1 on failure */
-ppdEmitJCLEnd(ppd_file_t *ppd, /* I - PPD file record */
- FILE *fp) /* I - File to write to */
+int // O - 0 on success, -1 on failure
+ppdEmitJCLEnd(ppd_file_t *ppd, // I - PPD file record
+ FILE *fp) // I - File to write to
{
- /*
- * Range check the input...
- */
+ //
+ // Range check the input...
+ //
if (!ppd)
return (0);
return (0);
}
- /*
- * See if the printer supports HP PJL...
- */
+ //
+ // See if the printer supports HP PJL...
+ //
if (!strncmp(ppd->jcl_end, "\033%-12345X@", 10))
{
- /*
- * This printer uses HP PJL commands for output; filter the output
- * so that we only have a single "@PJL JOB" command in the header...
- *
- * To avoid bugs in the PJL implementation of certain vendors' products
- * (Xerox in particular), we add a dummy "@PJL" command at the beginning
- * of the PJL commands to initialize PJL processing.
- */
+ //
+ // This printer uses HP PJL commands for output; filter the output
+ // so that we only have a single "@PJL JOB" command in the header...
+ //
+ // To avoid bugs in the PJL implementation of certain vendors' products
+ // (Xerox in particular), we add a dummy "@PJL" command at the beginning
+ // of the PJL commands to initialize PJL processing.
+ //
fputs("\033%-12345X@PJL\n", fp);
fputs("@PJL RDYMSG DISPLAY = \"\"\n", fp);
}
-/*
- * 'ppdEmitString()' - Get a string containing the code for marked options.
- *
- * When "min_order" is greater than zero, this function only includes options
- * whose OrderDependency value is greater than or equal to "min_order".
- * Otherwise, all options in the specified section are included in the
- * returned string.
- *
- * 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/macOS 10.5@
- */
-
-char * /* O - String containing option code or @code NULL@ if there is no option code */
-ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */
- ppd_section_t section, /* I - Section to write */
- float min_order) /* I - Lowest OrderDependency */
+//
+// 'ppdEmitString()' - Get a string containing the code for marked options.
+//
+// When "min_order" is greater than zero, this function only includes options
+// whose OrderDependency value is greater than or equal to "min_order".
+// Otherwise, all options in the specified section are included in the
+// returned string.
+//
+// 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/macOS 10.5@
+//
+
+char * // O - String containing option code or @code NULL@ if there is no option code
+ppdEmitString(ppd_file_t *ppd, // I - PPD file record
+ ppd_section_t section, // I - Section to write
+ float min_order) // I - Lowest OrderDependency
{
- int i, j, /* Looping vars */
- count; /* Number of choices */
- ppd_choice_t **choices; /* Choices */
- ppd_size_t *size; /* Custom page size */
- ppd_coption_t *coption; /* Custom option */
- ppd_cparam_t *cparam; /* Custom parameter */
- size_t bufsize; /* Size of string buffer needed */
- char *buffer, /* String buffer */
- *bufptr, /* Pointer into buffer */
- *bufend; /* End of buffer */
- struct lconv *loc; /* Locale data */
+ int i, j, // Looping vars
+ count; // Number of choices
+ ppd_choice_t **choices; // Choices
+ ppd_size_t *size; // Custom page size
+ ppd_coption_t *coption; // Custom option
+ ppd_cparam_t *cparam; // Custom parameter
+ size_t bufsize; // Size of string buffer needed
+ char *buffer, // String buffer
+ *bufptr, // Pointer into buffer
+ *bufend; // End of buffer
+ struct lconv *loc; // Locale data
DEBUG_printf(("ppdEmitString(ppd=%p, section=%d, min_order=%f)",
ppd, section, min_order));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd)
return (NULL);
- /*
- * Use PageSize or PageRegion as required...
- */
+ //
+ // Use PageSize or PageRegion as required...
+ //
ppdHandleMedia(ppd);
- /*
- * Collect the options we need to emit...
- */
+ //
+ // Collect the options we need to emit...
+ //
if ((count = ppdCollect2(ppd, section, min_order, &choices)) == 0)
return (NULL);
- /*
- * Count the number of bytes that are required to hold all of the
- * option code...
- */
+ //
+ // Count the number of bytes that are required to hold all of the
+ // option code...
+ //
for (i = 0, bufsize = 1; i < count; i ++)
{
(coption = ppdFindCustomOption(ppd, choices[i]->option->keyword))
!= NULL)
{
- /*
- * Add space to account for custom parameter substitution...
- */
+ //
+ // Add space to account for custom parameter substitution...
+ //
for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params);
cparam;
}
else if (section != PPD_ORDER_EXIT)
{
- bufsize += 3; /* [{\n */
+ bufsize += 3; // [{\n
if ((!_ppd_strcasecmp(choices[i]->option->keyword, "PageSize") ||
!_ppd_strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
{
DEBUG_puts("2ppdEmitString: Custom size set!");
- bufsize += 37; /* %%BeginFeature: *CustomPageSize True\n */
- bufsize += 50; /* Five 9-digit numbers + newline */
+ bufsize += 37; // %%BeginFeature: *CustomPageSize True\n
+ bufsize += 50; // Five 9-digit numbers + newline
}
else if (!_ppd_strcasecmp(choices[i]->choice, "Custom") &&
(coption = ppdFindCustomOption(ppd,
!= NULL)
{
bufsize += 23 + strlen(choices[i]->option->keyword) + 6;
- /* %%BeginFeature: *Customkeyword True\n */
+ // %%BeginFeature: *Customkeyword True\n
for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params);
else
bufsize += 17 + strlen(choices[i]->option->keyword) + 1 +
strlen(choices[i]->choice) + 1;
- /* %%BeginFeature: *keyword choice\n */
+ // %%BeginFeature: *keyword choice\n
- bufsize += 13; /* %%EndFeature\n */
- bufsize += 22; /* } stopped cleartomark\n */
+ bufsize += 13; // %%EndFeature\n
+ bufsize += 22; // } stopped cleartomark\n
}
if (choices[i]->code)
bufsize += strlen(ppd_custom_code);
}
- /*
- * Allocate memory...
- */
+ //
+ // Allocate memory...
+ //
DEBUG_printf(("2ppdEmitString: Allocating %d bytes for string...",
(int)bufsize));
bufend = buffer + bufsize - 1;
loc = localeconv();
- /*
- * Copy the option code to the buffer...
- */
+ //
+ // Copy the option code to the buffer...
+ //
for (i = 0, bufptr = buffer; i < count; i ++, bufptr += strlen(bufptr))
if (section == PPD_ORDER_JCL)
(coption = ppdFindCustomOption(ppd, choices[i]->option->keyword))
!= NULL)
{
- /*
- * Handle substitutions in custom JCL options...
- */
+ //
+ // Handle substitutions in custom JCL options...
+ //
- char *cptr; /* Pointer into code */
- int pnum; /* Parameter number */
+ char *cptr; // Pointer into code
+ int pnum; // Parameter number
for (cptr = choices[i]->code; *cptr && bufptr < bufend;)
if (isdigit(*cptr & 255))
{
- /*
- * Substitute parameter...
- */
+ //
+ // Substitute parameter...
+ //
pnum = *cptr++ - '0';
while (isdigit(*cptr & 255))
break;
case PPD_CUSTOM_INT :
- snprintf(bufptr, (size_t)(bufend - bufptr), "%d", cparam->current.custom_int);
+ snprintf(bufptr, (size_t)(bufend - bufptr), "%d",
+ cparam->current.custom_int);
bufptr += strlen(bufptr);
break;
case PPD_CUSTOM_STRING :
if (cparam->current.custom_string)
{
- strlcpy(bufptr, cparam->current.custom_string, (size_t)(bufend - bufptr));
+ strlcpy(bufptr, cparam->current.custom_string,
+ (size_t)(bufend - bufptr));
bufptr += strlen(bufptr);
}
break;
}
else if (choices[i]->code)
{
- /*
- * Otherwise just copy the option code directly...
- */
+ //
+ // Otherwise just copy the option code directly...
+ //
strlcpy(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
}
else if (section != PPD_ORDER_EXIT)
{
- /*
- * Add wrapper commands to prevent printer errors for unsupported
- * options...
- */
+ //
+ // Add wrapper commands to prevent printer errors for unsupported
+ // options...
+ //
strlcpy(bufptr, "[{\n", (size_t)(bufend - bufptr + 1));
bufptr += 3;
- /*
- * Send DSC comments with option...
- */
+ //
+ // Send DSC comments with option...
+ //
DEBUG_printf(("2ppdEmitString: Adding code for %s=%s...",
choices[i]->option->keyword, choices[i]->choice));
!_ppd_strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
!_ppd_strcasecmp(choices[i]->choice, "Custom"))
{
- /*
- * Variable size; write out standard size options, using the
- * parameter positions defined in the PPD file...
- */
+ //
+ // Variable size; write out standard size options, using the
+ // parameter positions defined in the PPD file...
+ //
- ppd_attr_t *attr; /* PPD attribute */
- int pos, /* Position of custom value */
- orientation; /* Orientation to use */
- float values[5]; /* Values for custom command */
+ ppd_attr_t *attr; // PPD attribute
+ int pos, // Position of custom value
+ orientation; // Orientation to use
+ float values[5]; // Values for custom command
- strlcpy(bufptr, "%%BeginFeature: *CustomPageSize True\n", (size_t)(bufend - bufptr + 1));
+ strlcpy(bufptr, "%%BeginFeature: *CustomPageSize True\n",
+ (size_t)(bufend - bufptr + 1));
bufptr += 37;
size = ppdPageSize(ppd, "Custom");
values[pos] = size->length;
- /*
- * According to the Adobe PPD specification, an orientation of 1
- * will produce a print that comes out upside-down with the X
- * axis perpendicular to the direction of feed, which is exactly
- * what we want to be consistent with non-PS printers.
- *
- * We could also use an orientation of 3 to produce output that
- * comes out rightside-up (this is the default for many large format
- * printer PPDs), however for consistency we will stick with the
- * value 1.
- *
- * If we wanted to get fancy, we could use orientations of 0 or
- * 2 and swap the width and length, however we don't want to get
- * fancy, we just want it to work consistently.
- *
- * The orientation value is range limited by the Orientation
- * parameter definition, so certain non-PS printer drivers that
- * only support an Orientation of 0 will get the value 0 as
- * expected.
- */
+ //
+ // According to the Adobe PPD specification, an orientation of 1
+ // will produce a print that comes out upside-down with the X
+ // axis perpendicular to the direction of feed, which is exactly
+ // what we want to be consistent with non-PS printers.
+ //
+ // We could also use an orientation of 3 to produce output that
+ // comes out rightside-up (this is the default for many large format
+ // printer PPDs), however for consistency we will stick with the
+ // value 1.
+ //
+ // If we wanted to get fancy, we could use orientations of 0 or
+ // 2 and swap the width and length, however we don't want to get
+ // fancy, we just want it to work consistently.
+ //
+ // The orientation value is range limited by the Orientation
+ // parameter definition, so certain non-PS printer drivers that
+ // only support an Orientation of 0 will get the value 0 as
+ // expected.
+ //
orientation = 1;
if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize",
"Orientation")) != NULL)
{
- int min_orient, max_orient; /* Minimum and maximum orientations */
+ int min_orient, max_orient; // Minimum and maximum orientations
if (sscanf(attr->value, "%d%*s%d%d", &pos, &min_orient,
if (!choices[i]->code)
{
- /*
- * This can happen with certain buggy PPD files that don't include
- * a CustomPageSize command sequence... We just use a generic
- * Level 2 command sequence...
- */
+ //
+ // This can happen with certain buggy PPD files that don't include
+ // a CustomPageSize command sequence... We just use a generic
+ // Level 2 command sequence...
+ //
strlcpy(bufptr, ppd_custom_code, (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
(coption = ppdFindCustomOption(ppd, choices[i]->option->keyword))
!= NULL)
{
- /*
- * Custom option...
- */
+ //
+ // Custom option...
+ //
- const char *s; /* Pointer into string value */
- cups_array_t *params; /* Parameters in the correct output order */
+ const char *s; // Pointer into string value
+ cups_array_t *params; // Parameters in the correct output
+ // order
params = cupsArrayNew((cups_array_func_t)ppd_compare_cparams, NULL);
cparam = (ppd_cparam_t *)cupsArrayNext(coption->params))
cupsArrayAdd(params, cparam);
- snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%%%%BeginFeature: *Custom%s True\n", coption->keyword);
+ snprintf(bufptr, (size_t)(bufend - bufptr + 1),
+ "%%%%BeginFeature: *Custom%s True\n", coption->keyword);
bufptr += strlen(bufptr);
for (cparam = (ppd_cparam_t *)cupsArrayFirst(params);
break;
case PPD_CUSTOM_INT :
- snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d\n", cparam->current.custom_int);
+ snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d\n",
+ cparam->current.custom_int);
bufptr += strlen(bufptr);
break;
{
if (*s < ' ' || *s == '(' || *s == ')' || *s >= 127)
{
- snprintf(bufptr, (size_t)(bufend - bufptr + 1), "\\%03o", *s & 255);
+ snprintf(bufptr, (size_t)(bufend - bufptr + 1),
+ "\\%03o", *s & 255);
bufptr += strlen(bufptr);
}
else
}
else
{
- snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%%%%BeginFeature: *%s %s\n", choices[i]->option->keyword, choices[i]->choice);
+ snprintf(bufptr, (size_t)(bufend - bufptr + 1),
+ "%%%%BeginFeature: *%s %s\n",
+ choices[i]->option->keyword, choices[i]->choice);
bufptr += strlen(bufptr);
}
bufptr += strlen(bufptr);
}
- /*
- * Nul-terminate, free, and return...
- */
+ //
+ // Nul-terminate, free, and return...
+ //
*bufptr = '\0';
}
-/*
- * 'ppdHandleMedia()' - Handle media selection...
- */
+//
+// 'ppdHandleMedia()' - Handle media selection...
+//
void
-ppdHandleMedia(ppd_file_t *ppd) /* I - PPD file */
+ppdHandleMedia(ppd_file_t *ppd) // I - PPD file
{
- ppd_choice_t *manual_feed, /* ManualFeed choice, if any */
- *input_slot; /* InputSlot choice, if any */
- ppd_size_t *size; /* Current media size */
- ppd_attr_t *rpr; /* RequiresPageRegion value */
-
-
- /*
- * This function determines what page size code to use, if any, for the
- * current media size, InputSlot, and ManualFeed selections.
- *
- * We use the PageSize code if:
- *
- * 1. A custom media size is selected.
- * 2. ManualFeed and InputSlot are not selected (or do not exist).
- * 3. ManualFeed is selected but is False and InputSlot is not selected or
- * the selection has no code - the latter check done to support "auto" or
- * "printer default" InputSlot options.
- *
- * We use the PageRegion code if:
- *
- * 4. RequiresPageRegion does not exist and the PPD contains cupsFilter
- * keywords, indicating this is a CUPS-based driver.
- * 5. RequiresPageRegion exists for the selected InputSlot (or "All" for any
- * InputSlot or ManualFeed selection) and is True.
- *
- * If none of the 5 conditions are true, no page size code is used and we
- * unmark any existing PageSize or PageRegion choices.
- */
+ ppd_choice_t *manual_feed, // ManualFeed choice, if any
+ *input_slot; // InputSlot choice, if any
+ ppd_size_t *size; // Current media size
+ ppd_attr_t *rpr; // RequiresPageRegion value
+
+
+ //
+ // This function determines what page size code to use, if any, for the
+ // current media size, InputSlot, and ManualFeed selections.
+ //
+ // We use the PageSize code if:
+ //
+ // 1. A custom media size is selected.
+ // 2. ManualFeed and InputSlot are not selected (or do not exist).
+ // 3. ManualFeed is selected but is False and InputSlot is not selected or
+ // the selection has no code - the latter check done to support "auto" or
+ // "printer default" InputSlot options.
+ //
+ // We use the PageRegion code if:
+ //
+ // 4. RequiresPageRegion does not exist and the PPD contains cupsFilter
+ // keywords, indicating this is a CUPS-based driver.
+ // 5. RequiresPageRegion exists for the selected InputSlot (or "All" for any
+ // InputSlot or ManualFeed selection) and is True.
+ //
+ // If none of the 5 conditions are true, no page size code is used and we
+ // unmark any existing PageSize or PageRegion choices.
+ //
if ((size = ppdPageSize(ppd, NULL)) == NULL)
return;
(!input_slot || (input_slot->code && !input_slot->code[0]))) ||
(!rpr && ppd->num_filters > 0))
{
- /*
- * Use PageSize code...
- */
+ //
+ // Use PageSize code...
+ //
ppdMarkOption(ppd, "PageSize", size->name);
}
else if (rpr && rpr->value && !_ppd_strcasecmp(rpr->value, "True"))
{
- /*
- * Use PageRegion code...
- */
+ //
+ // Use PageRegion code...
+ //
ppdMarkOption(ppd, "PageRegion", size->name);
}
else
{
- /*
- * Do not use PageSize or PageRegion code...
- */
+ //
+ // Do not use PageSize or PageRegion code...
+ //
- ppd_choice_t *page; /* PageSize/Region choice, if any */
+ ppd_choice_t *page; // PageSize/Region choice, if any
if ((page = ppdFindMarkedChoice(ppd, "PageSize")) != NULL)
{
- /*
- * Unmark PageSize...
- */
+ //
+ // Unmark PageSize...
+ //
page->marked = 0;
cupsArrayRemove(ppd->marked, page);
if ((page = ppdFindMarkedChoice(ppd, "PageRegion")) != NULL)
{
- /*
- * Unmark PageRegion...
- */
+ //
+ // Unmark PageRegion...
+ //
page->marked = 0;
cupsArrayRemove(ppd->marked, page);
}
-/*
- * 'ppd_compare_cparams()' - Compare the order of two custom parameters.
- */
+//
+// 'ppd_compare_cparams()' - Compare the order of two custom parameters.
+//
-static int /* O - Result of comparison */
-ppd_compare_cparams(ppd_cparam_t *a, /* I - First parameter */
- ppd_cparam_t *b) /* I - Second parameter */
+static int // O - Result of comparison
+ppd_compare_cparams(ppd_cparam_t *a, // I - First parameter
+ ppd_cparam_t *b) // I - Second parameter
{
return (a->order - b->order);
}
-/*
- * Filter functions support for libppd.
- *
- * Copyright © 2020-2022 by Till Kamppeter.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Filter functions support for libppd.
+//
+// Copyright © 2020-2022 by Till Kamppeter.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "config.h"
#include "ppd-filter.h"
extern char **environ;
-/*
- * 'ppdFilterCUPSWrapper()' - Wrapper function to use a filter function as
- * classic CUPS filter
- */
+//
+// 'ppdFilterCUPSWrapper()' - Wrapper function to use a filter function as
+// classic CUPS filter
+//
-int /* O - Exit status */
+int // O - Exit status
ppdFilterCUPSWrapper(
- int argc, /* I - Number of command-line args */
- char *argv[], /* I - Command-line arguments */
- cf_filter_function_t filter, /* I - Filter function */
- void *parameters, /* I - Filter function parameters */
- int *JobCanceled) /* I - Var set to 1 when job canceled */
+ int argc, // I - Number of command-line args
+ char *argv[], // I - Command-line arguments
+ cf_filter_function_t filter, // I - Filter function
+ void *parameters, // I - Filter function parameters
+ int *JobCanceled) // I - Var set to 1 when job canceled
{
- int inputfd; /* Print file descriptor*/
- int inputseekable; /* Is the input seekable (actual file
- not stdin)? */
- int num_options; /* Number of print options */
- cups_option_t *options; /* Print options */
+ int inputfd; // Print file descriptor
+ int inputseekable; // Is the input seekable (actual file
+ // not stdin)?
+ int num_options; // Number of print options
+ cups_option_t *options; // Print options
cf_filter_data_t filter_data;
const char *val;
char buf[256];
int retval = 0;
- /*
- * Make sure status messages are not buffered...
- */
+ //
+ // Make sure status messages are not buffered...
+ //
setbuf(stderr, NULL);
- /*
- * Ignore broken pipe signals...
- */
+ //
+ // Ignore broken pipe signals...
+ //
signal(SIGPIPE, SIG_IGN);
- /*
- * Check command-line...
- */
+ //
+ // Check command-line...
+ //
if (argc < 6 || argc > 7)
{
return (1);
}
- /*
- * 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)
{
- inputfd = 0; /* stdin */
+ inputfd = 0; // stdin
inputseekable = 0;
}
else
{
- /*
- * Try to open the print file...
- */
+ //
+ // Try to open the print file...
+ //
if ((inputfd = open(argv[6], O_RDONLY)) < 0)
{
inputseekable = 1;
}
- /*
- * Process command-line options...
- */
+ //
+ // Process command-line options...
+ //
options = NULL;
num_options = cupsParseOptions(argv[5], 0, &options);
filter_data.copies = atoi(argv[4]);
filter_data.content_type = getenv("CONTENT_TYPE");
filter_data.final_content_type = getenv("FINAL_CONTENT_TYPE");
- filter_data.job_attrs = NULL; /* We use command line options */
- /* The following two will get populated by ppdFilterLoadPPD() */
- filter_data.printer_attrs = NULL; /* We use the queue's PPD file */
- filter_data.header = NULL; /* CUPS Raster header of queue's PPD */
+ filter_data.job_attrs = NULL; // We use command line options
+ // The following two will get populated by ppdFilterLoadPPD()
+ filter_data.printer_attrs = NULL; // We use the queue's PPD file
+ filter_data.header = NULL; // CUPS Raster header of queue's PPD
filter_data.num_options = num_options;
- filter_data.options = options; /* Command line options from 5th arg */
- filter_data.back_pipe[0] = 3; /* CUPS uses file descriptor 3 for */
- filter_data.back_pipe[1] = 3; /* the back channel */
- filter_data.side_pipe[0] = 4; /* CUPS uses file descriptor 4 for */
- filter_data.side_pipe[1] = 4; /* the side channel */
+ filter_data.options = options; // Command line options from 5th arg
+ filter_data.back_pipe[0] = 3; // CUPS uses file descriptor 3 for
+ filter_data.back_pipe[1] = 3; // the back channel
+ filter_data.side_pipe[0] = 4; // CUPS uses file descriptor 4 for
+ filter_data.side_pipe[1] = 4; // the side channel
filter_data.extension = NULL;
- 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 = JobCanceled;
- /*
- * CUPS_FONTPATH (Usually /usr/share/cups/fonts)
- */
+ //
+ // CUPS_FONTPATH (Usually /usr/share/cups/fonts)
+ //
if (cupsGetOption("cups-fontpath",
filter_data.num_options, filter_data.options) == NULL)
filter_data.num_options, &(filter_data.options));
}
- /*
- * Load and prepare the PPD file, also attach it as extension "libppd"
- * to the filter_data structure
- */
+ //
+ // Load and prepare the PPD file, also attach it as extension "libppd"
+ // to the filter_data structure
+ //
retval = ppdFilterLoadPPDFile(&filter_data, getenv("PPD"));
- /*
- * Fire up the filter function (output to stdout, file descriptor 1)
- */
+ //
+ // Fire up the filter function (output to stdout, file descriptor 1)
+ //
if (!retval)
retval = filter(inputfd, 1, inputseekable, &filter_data, parameters);
- /*
- * Clean up
- */
+ //
+ // Clean up
+ //
cupsFreeOptions(filter_data.num_options, filter_data.options);
ppdFilterFreePPDFile(&filter_data);
}
-/*
- * 'ppdFilterLoadPPDFile()' - When preparing the filter data structure
- * for calling one or more filter
- * functions, load the PPD file specified
- * by its file name. If the file name is
- * NULL or empty, do nothing. If the PPD
- * got successfully loaded add its data to
- * the filter data structure as extension
- * named "libppd", so that filters
- * functions designed for using PPDs can
- * access it. Then read out all the
- * relevant data with the
- * ppdFilterLoadPPD() function.
- */
-
-int /* O - Error status */
-ppdFilterLoadPPDFile(cf_filter_data_t *data, /* I/O - Job and printer data */
- const char *ppdfile) /* I - PPD file name */
+//
+// 'ppdFilterLoadPPDFile()' - When preparing the filter data structure
+// for calling one or more filter
+// functions, load the PPD file specified
+// by its file name. If the file name is
+// NULL or empty, do nothing. If the PPD
+// got successfully loaded add its data to
+// the filter data structure as extension
+// named "libppd", so that filters
+// functions designed for using PPDs can
+// access it. Then read out all the
+// relevant data with the
+// ppdFilterLoadPPD() function.
+//
+
+int // O - Error status
+ppdFilterLoadPPDFile(cf_filter_data_t *data, // I/O - Job and printer data
+ const char *ppdfile) // I - PPD file name
{
- ppd_filter_data_ext_t *filter_data_ext; /* Record for "libppd" extension */
- ppd_file_t *ppd; /* PPD data */
- cf_logfunc_t log = data->logfunc; /* Log function */
- void *ld = data->logdata; /* log function data */
+ ppd_filter_data_ext_t *filter_data_ext; // Record for "libppd" extension
+ ppd_file_t *ppd; // PPD data
+ cf_logfunc_t log = data->logfunc; // Log function
+ void *ld = data->logdata; // log function data
if (!ppdfile || !ppdfile[0])
return (-1);
filter_data_ext =
(ppd_filter_data_ext_t *)calloc(1, sizeof(ppd_filter_data_ext_t));
- filter_data_ext->ppdfile = strdup(ppdfile); /* PPD file name */
- filter_data_ext->ppd = ppd; /* PPD data */
+ filter_data_ext->ppdfile = strdup(ppdfile); // PPD file name
+ filter_data_ext->ppd = ppd; // PPD data
cfFilterDataAddExt(data, PPD_FILTER_DATA_EXT, filter_data_ext);
return ppdFilterLoadPPD(data);
}
-/*
- * 'ppdFilterLoadPPD()' - When preparing the filter data structure for
- * calling one or more filter functions, and a
- * PPD file is attached as "libppd" extension,
- * set up the PPD's cache, mark default
- * settings and if supplied in the data
- * structure, also option settings. Then
- * convert the capability and option info in
- * the PPD file into printer IPP attributes and
- * what cannot be represented in IPP as option
- * settings and add these results to the filter
- * data structure. This allows to use the (by
- * itself not PPD-supporting) filter function
- * to do its work for the printer represented
- * by the PPD file. Add the CUPS PPD file data
- * structure with embedded CUPS PPD cache data
- * structure (including PPD option setting
- * presets for all possible print-color-mode,
- * print-quality, and print-content-optimize
- * settings) to the filter data structure for
- * use by libppd's PPD-requiring filter
- * functions.
- */
-
-int /* O - Error status */
-ppdFilterLoadPPD(cf_filter_data_t *data) /* I/O - Job and printer data */
+//
+// 'ppdFilterLoadPPD()' - When preparing the filter data structure for
+// calling one or more filter functions, and a
+// PPD file is attached as "libppd" extension,
+// set up the PPD's cache, mark default
+// settings and if supplied in the data
+// structure, also option settings. Then
+// convert the capability and option info in
+// the PPD file into printer IPP attributes and
+// what cannot be represented in IPP as option
+// settings and add these results to the filter
+// data structure. This allows to use the (by
+// itself not PPD-supporting) filter function
+// to do its work for the printer represented
+// by the PPD file. Add the CUPS PPD file data
+// structure with embedded CUPS PPD cache data
+// structure (including PPD option setting
+// presets for all possible print-color-mode,
+// print-quality, and print-content-optimize
+// settings) to the filter data structure for
+// use by libppd's PPD-requiring filter
+// functions.
+//
+
+int // O - Error status
+ppdFilterLoadPPD(cf_filter_data_t *data) // I/O - Job and printer data
{
int i;
ppd_filter_data_ext_t *filter_data_ext =
char buf[1024];
char cm_qualifier_tmp[1024];
const char *cm_profile_key;
- char *resolution, /* Output resolution */
- *media_type; /* Media type */
- ppd_profile_t *profile; /* Color profile */
- cf_logfunc_t log = data->logfunc; /* Log function */
- void *ld = data->logdata; /* log function data */
+ char *resolution, // Output resolution
+ *media_type; // Media type
+ ppd_profile_t *profile; // Color profile
+ cf_logfunc_t log = data->logfunc; // Log function
+ void *ld = data->logdata; // log function data
if (!filter_data_ext || !filter_data_ext->ppd)
return (-1);
- /*
- * Prepare PPD file and mark options
- */
+ //
+ // Prepare PPD file and mark options
+ //
ppd = filter_data_ext->ppd;
ppd->cache = ppdCacheCreateWithPPD(ppd);
ppdMarkOptions(ppd, data->num_options, data->options);
ppdHandleMedia(ppd);
- /*
- * Pass on PPD attributes
- */
+ //
+ // Pass on PPD attributes
+ //
- /* Pass on "PWGRaster" PPD attribute (for PWG Raster output) */
+ // Pass on "PWGRaster" PPD attribute (for PWG Raster output)
if ((ppd_attr = ppdFindAttr(ppd, "PWGRaster", 0)) != 0 &&
(!strcasecmp(ppd_attr->value, "true") ||
!strcasecmp(ppd_attr->value, "on") ||
data->num_options = cupsAddOption("media-class", "PwgRaster",
data->num_options, &(data->options));
- /* Pass on "cupsEvenDuplex" PPD attribute */
+ // Pass on "cupsEvenDuplex" PPD attribute
if ((ppd_attr = ppdFindAttr(ppd, "cupsEvenDuplex", 0)) != NULL)
data->num_options = cupsAddOption("even-duplex", ppd_attr->value,
data->num_options, &(data->options));
- /* Pass on "cupsBackSide" (or "cupsFlipDuplex") PPD attribute */
+ // Pass on "cupsBackSide" (or "cupsFlipDuplex") PPD attribute
if ((ppd_attr = ppdFindAttr(ppd, "cupsBackSide", 0)) != NULL)
{
- ppd->flip_duplex = 0; /* "cupsBackSide" has priority */
+ ppd->flip_duplex = 0; // "cupsBackSide" has priority
data->num_options = cupsAddOption("back-side-orientation", ppd_attr->value,
data->num_options, &(data->options));
}
- else if (ppd->flip_duplex) /* "cupsFlipDuplex" same as "Rotated" */
+ else if (ppd->flip_duplex) // "cupsFlipDuplex" same as "Rotated"
data->num_options = cupsAddOption("back-side-orientation", "Rotated",
data->num_options, &(data->options));
- /* Pass on "APDuplexRequiresFlippedMargin" PPD attribute */
+ // Pass on "APDuplexRequiresFlippedMargin" PPD attribute
if ((ppd_attr = ppdFindAttr(ppd, "APDuplexRequiresFlippedMargin", 0)) != NULL)
data->num_options = cupsAddOption("duplex-requires-flipped-margin",
ppd_attr->value,
data->num_options, &(data->options));
- /* Pass on "cupsRasterVersion" PPD attribute */
+ // Pass on "cupsRasterVersion" PPD attribute
if ((ppd_attr = ppdFindAttr(ppd,"cupsRasterVersion", 0)) != NULL)
data->num_options = cupsAddOption("cups-raster-version",
ppd_attr->value,
data->num_options, &(data->options));
- /* Pass on "DefaultCenterOfPixel" PPD attribute (for Ghostscript) */
+ // Pass on "DefaultCenterOfPixel" PPD attribute (for Ghostscript)
if ((ppd_attr = ppdFindAttr(ppd,"DefaultCenterOfPixel", 0)) != NULL)
data->num_options = cupsAddOption("center-of-pixel",
ppd_attr->value,
data->num_options, &(data->options));
- /* Set short-edge Duplex when booklet printing is selected */
+ // Set short-edge Duplex when booklet printing is selected
if ((val = cupsGetOption("booklet",
data->num_options, data->options)) != NULL &&
(!strcasecmp(val, "on") || !strcasecmp(val, "yes") ||
ppdMarkOption(ppd, ppd->cache->sides_option,
ppd->cache->sides_2sided_short);
- /* Let the PDF filter do mirrored printing */
+ // Let the PDF filter do mirrored printing
if ((choice = ppdFindMarkedChoice(ppd, "MirrorPrint")) != NULL)
{
choice->marked = 0;
data->num_options, &(data->options));
}
- /*
- * Find out whether we can do hardware copies/collate
- */
+ //
+ // Find out whether we can do hardware copies/collate
+ //
if (data->copies == 1)
{
- /* 1 copy, hardware copies/collate do not make difference */
+ // 1 copy, hardware copies/collate do not make difference
hw_copies = false;
hw_collate = false;
}
else if (!ppd->manual_copies)
{
- /* Hardware copy generation available */
+ // Hardware copy generation available
hw_copies = true;
- /* Check output format (FINAL_CONTENT_TYPE env variable) whether it is
- of a driverless IPP printer (PDF, Apple Raster, PWG Raster, PCLm).
- These printers do always hardware collate if they do hardware copies.
- https://github.com/apple/cups/issues/5433
- This also assumes that if a classic PDF printer (non-IPP printer printing
- with JCL/PJL-controlled PDF) supports hardware copies that it also does
- hardware collate */
+ // Check output format (FINAL_CONTENT_TYPE env variable) whether it is
+ // of a driverless IPP printer (PDF, Apple Raster, PWG Raster, PCLm).
+ // These printers do always hardware collate if they do hardware copies.
+ // https://github.com/apple/cups/issues/5433
+ // This also assumes that if a classic PDF printer (non-IPP printer printing
+ // with JCL/PJL-controlled PDF) supports hardware copies that it also does
+ // hardware collate
if (data->final_content_type &&
(strcasestr(data->final_content_type, "/pdf") ||
strcasestr(data->final_content_type, "/vnd.cups-pdf") ||
strcasestr(data->final_content_type, "/urf") ||
strcasestr(data->final_content_type, "/PCLm")))
{
- /* If PPD has "Collate" option set to not collate, do not set
- hw_collate, especially important to set correct JCL/PJL on
- "classic" PDF printers (they will always collate otherwise) */
+ // If PPD has "Collate" option set to not collate, do not set
+ // hw_collate, especially important to set correct JCL/PJL on
+ // "classic" PDF printers (they will always collate otherwise)
if ((choice = ppdFindMarkedChoice(ppd, "Collate")) != NULL &&
(!strcasecmp(choice->choice, "off") ||
!strcasecmp(choice->choice, "no") ||
}
else
{
- /* Check whether printer hardware-collates with current PPD settings */
+ // Check whether printer hardware-collates with current PPD settings
if ((choice = ppdFindMarkedChoice(ppd, "Collate")) != NULL &&
(!strcasecmp(choice->choice, "on") ||
!strcasecmp(choice->choice, "yes") ||
!strcasecmp(choice->choice, "true")))
{
- /* Printer can collate, but also for the currently marked PPD
- features? */
+ // Printer can collate, but also for the currently marked PPD
+ // features?
ppd_option_t *opt = ppdFindOption(ppd, "Collate");
hw_collate = (opt && !opt->conflicted);
}
}
else
{
- /* We have "*cupsManualCopies: True" =>
- Software copies/collate */
+ // We have "*cupsManualCopies: True" =>
+ // Software copies/collate
hw_copies = false;
hw_collate = false;
}
if (!hw_copies)
{
- /* Software copies */
- /* Make sure any hardware copying is disabled */
+ // Software copies
+ // Make sure any hardware copying is disabled
ppdMarkOption(ppd, "Copies", "1");
ppdMarkOption(ppd, "JCLCopies", "1");
}
else
{
- /* Hardware copies */
- /* If there is a "Copies" option in the PPD file, assure that hardware
- copies are implemented as described by this option */
+ // Hardware copies
+ // If there is a "Copies" option in the PPD file, assure that hardware
+ // copies are implemented as described by this option
snprintf(buf, sizeof(buf), "%d", hw_copies);
ppdMarkOption(ppd, "Copies", buf);
}
- /* Software collate */
+ // Software collate
if (!hw_collate)
- /* Disable any hardware collate (in JCL) */
+ // Disable any hardware collate (in JCL)
ppdMarkOption(ppd, "Collate", "False");
- /* Add options telling whether we want hardware copies/collate or not */
+ // Add options telling whether we want hardware copies/collate or not
data->num_options = cupsAddOption("hardware-copies",
(hw_copies ? "true" : "false"),
data->num_options, &(data->options));
(hw_collate ? "true" : "false"),
data->num_options, &(data->options));
- /*
- * Pass on color management attributes
- */
+ //
+ // Pass on color management attributes
+ //
- /* Get color space */
+ // Get color space
if ((ppd_attr = ppdFindAttr (ppd, "cupsICCQualifier1", NULL)) != NULL &&
ppd_attr->value && ppd_attr->value[0])
choice = ppdFindMarkedChoice(ppd, ppd_attr->value);
else
q1_choice = "";
- /* Get media type */
+ // Get media type
if ((ppd_attr = ppdFindAttr(ppd, "cupsICCQualifier2", NULL)) != NULL &&
ppd_attr->value && ppd_attr->value[0])
choice = ppdFindMarkedChoice(ppd, ppd_attr->value);
else
q2_choice = "";
- /* Get resolution */
+ // Get resolution
if ((ppd_attr = ppdFindAttr(ppd, "cupsICCQualifier3", NULL)) != NULL &&
ppd_attr->value && ppd_attr->value[0])
choice = ppdFindMarkedChoice(ppd, ppd_attr->value);
q3_choice = "";
}
- /* create a string for the option */
+ // create a string for the option
snprintf(cm_qualifier_tmp, sizeof(cm_qualifier_tmp),
"%s.%s.%s", q1_choice, q2_choice, q3_choice);
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterLoadPPD: Color profile qualifier determined from job and PPD data '%s'",
cm_qualifier_tmp);
- /* Supply qualifier as option */
+ // Supply qualifier as option
data->num_options = cupsAddOption("cm-profile-qualifier", cm_qualifier_tmp,
data->num_options, &(data->options));
- /* get profile attr, falling back to CUPS */
+ // get profile attr, falling back to CUPS
cm_profile_key = "APTiogaProfile";
ppd_attr = ppdFindAttr(ppd, cm_profile_key, NULL);
if (ppd_attr == NULL)
if (ppd_attr == NULL)
{
- /* neither */
+ // neither
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterLoadPPD: No ICC profiles specified in PPD");
}
else
{
- /* Try to find a profile that matches the qualifier exactly */
+ // Try to find a profile that matches the qualifier exactly
for (;ppd_attr != NULL;
ppd_attr = ppdFindNextAttr(ppd, cm_profile_key, NULL))
{
- /* Invalid entry */
+ // Invalid entry
if (ppd_attr->spec == NULL || ppd_attr->value == NULL)
continue;
- /* Matches the qualifier */
+ // Matches the qualifier
if (strcmp(cm_qualifier_tmp, ppd_attr->spec) == 0)
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
}
}
- /* No match */
+ // No match
if (ppd_attr == NULL)
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
}
else
{
- /* expand to a full path if not already specified */
+ // expand to a full path if not already specified
if (ppd_attr->value[0] != '/')
{
if ((val = getenv("CUPS_DATADIR")) == NULL)
buf[1023] = '\0';
}
- /* check the file exists */
+ // check the file exists
if (access(buf, 0))
{
if (log) log(ld, CF_LOGLEVEL_ERROR,
}
else
{
- /* Supply path as fallback profile option */
+ // Supply path as fallback profile option
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterLoadPPD: Using ICC profile %s as fallback if colord does not supply another one",
buf);
}
}
- /*
- * Find a color profile matching the current options...
- */
+ //
+ // Find a color profile matching the current options...
+ //
if (cupsGetOption("profile", data->num_options, data->options) == NULL)
{
"ppdFilterLoadPPD: no.");
}
- /*
- * If we found a color profile, use it!
- */
+ //
+ // If we found a color profile, use it!
+ //
if (i >= ppd->num_profiles)
profile = NULL;
data->num_options, &(data->options));
}
- /*
- * Convert the settings and properties in the PPD into printer IPP
- * attributes
- */
+ //
+ // Convert the settings and properties in the PPD into printer IPP
+ // attributes
+ //
data->printer_attrs = ppdLoadAttributes(ppd);
- /*
- * Generate a CUPS Raster sample header, some filters can easily take
- * data from it or make it the base for actual Raster headers. The
- * header is based on the pseudo-PostScript code at the option
- * settings in the PPD file, this is usually the more reliable way to
- * obtain the correct resolution.
- *
- * This only works if the PPD file is actually for a CUPS Raster
- * driver or generated by CUPS for driverless printers via the
- * "everywhere" pseudo-driver, as other PPD files do not contain all
- * resolution, page geometry and color space/depth info in
- * pseudo-PostScript code and the ppdRasterInterpretPPD() function
- * only parses the pseudo-PostScript code not the names of the
- * options and choices.
- *
- * Therefore we create the sample header only if the PPD is actually
- * for a CUPS Raster driver or an "everywhere" PPD from CUPS.
- */
+ //
+ // Generate a CUPS Raster sample header, some filters can easily take
+ // data from it or make it the base for actual Raster headers. The
+ // header is based on the pseudo-PostScript code at the option
+ // settings in the PPD file, this is usually the more reliable way to
+ // obtain the correct resolution.
+ //
+ // This only works if the PPD file is actually for a CUPS Raster
+ // driver or generated by CUPS for driverless printers via the
+ // "everywhere" pseudo-driver, as other PPD files do not contain all
+ // resolution, page geometry and color space/depth info in
+ // pseudo-PostScript code and the ppdRasterInterpretPPD() function
+ // only parses the pseudo-PostScript code not the names of the
+ // options and choices.
+ //
+ // Therefore we create the sample header only if the PPD is actually
+ // for a CUPS Raster driver or an "everywhere" PPD from CUPS.
+ //
data->header = NULL;
for (i = 0; i < ppd->num_filters; i ++)
}
}
- /*
- * Replace the "PageSize" option by a media-col attribute, as this
- * one selects the media much more reliably by numeric size
- * dimensions and margins and not by name.
- *
- * PPDs have special page size names for page size variants (A4,
- * A4.Borderless, A4.Duplex, A4.Transverse) which cannot get mapped
- * into the printer IPP attributes (media-col-database) and so cannot
- * get easily selected by the PPD-support-free core filter functions
- * in libcupsfilters.
- *
- * Usually, the media-col attribute does not need to get copied from
- * printer attributes to job attributes, but having it in the job
- * attributes tells the filters that the user has requested a page
- * size, as at least some filters overtake the sizes of the input
- * pages when the user does not request a page size.
- */
+ //
+ // Replace the "PageSize" option by a media-col attribute, as this
+ // one selects the media much more reliably by numeric size
+ // dimensions and margins and not by name.
+ //
+ // PPDs have special page size names for page size variants (A4,
+ // A4.Borderless, A4.Duplex, A4.Transverse) which cannot get mapped
+ // into the printer IPP attributes (media-col-database) and so cannot
+ // get easily selected by the PPD-support-free core filter functions
+ // in libcupsfilters.
+ //
+ // Usually, the media-col attribute does not need to get copied from
+ // printer attributes to job attributes, but having it in the job
+ // attributes tells the filters that the user has requested a page
+ // size, as at least some filters overtake the sizes of the input
+ // pages when the user does not request a page size.
+ //
page_size = cupsGetOption("PageSize", data->num_options, data->options);
media = cupsGetOption("media", data->num_options, data->options);
(attr = ippFindAttribute(data->printer_attrs, "media-col-default",
IPP_TAG_ZERO)) != NULL)
{
- /* We have already applied the settings of these options to the
- PPD file and converted the PPD option settings into the printer
- IPP attributes. The media size and margins corresponding to the
- name supplied with these options is now included in the printer
- IPP attributes as "media-col-default". Here we remove the
- "PageSize" and "media" options and add "media-col" to the job
- attributes as a copy of "media-col-default" in the printer
- attributes. We do this only if the size specified by "PageSize"
- or "media" is not a custom size ("Custom.XXxYYunit") as a
- custom size cannot get marked in the PPD file and so not set as
- default page size, so it does not make it into
- media-col-default. In this case we only remove "media-col". */
+ // We have already applied the settings of these options to the
+ // PPD file and converted the PPD option settings into the printer
+ // IPP attributes. The media size and margins corresponding to the
+ // name supplied with these options is now included in the printer
+ // IPP attributes as "media-col-default". Here we remove the
+ // "PageSize" and "media" options and add "media-col" to the job
+ // attributes as a copy of "media-col-default" in the printer
+ // attributes. We do this only if the size specified by "PageSize"
+ // or "media" is not a custom size ("Custom.XXxYYunit") as a
+ // custom size cannot get marked in the PPD file and so not set as
+ // default page size, so it does not make it into
+ // media-col-default. In this case we only remove "media-col".
int is_custom = 0;
if (!is_custom)
{
- /* String from IPP attribute for option list */
+ // String from IPP attribute for option list
ippAttributeString(attr, buf, sizeof(buf));
data->num_options = cupsAddOption("media-col", buf,
data->num_options, &(data->options));
- /* Copy the default media-col */
+ // Copy the default media-col
col = ippGetCollection(attr, 0);
ippAddCollection(data->job_attrs, IPP_TAG_PRINTER, "media-col", col);
}
}
- /*
- * Find out whether the PDF filter (cfFilterPDFToPDF() or
- * cfFilterImageToPDF()) should log the pages or whether the last
- * filter (usually the printer driver) should do it.
- */
+ //
+ // Find out whether the PDF filter (cfFilterPDFToPDF() or
+ // cfFilterImageToPDF()) should log the pages or whether the last
+ // filter (usually the printer driver) should do it.
+ //
if ((val = cupsGetOption("pdf-filter-page-logging",
data->num_options, data->options)) == NULL ||
int page_logging = -1;
if (data->final_content_type == NULL)
{
- /* Final data MIME type not known, we cannot determine
- whether we have to log pages, so do not log. */
+ // Final data MIME type not known, we cannot determine
+ // whether we have to log pages, so do not log.
page_logging = 0;
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterLoadPPD: No final data MIME type known, so we "
"cannot determine whether the PDF filter has to log pages "
"or not, so turning off page logging for the PDF filter.");
}
- /* Proceed depending on number of cupsFilter(2) lines in PPD */
+ // Proceed depending on number of cupsFilter(2) lines in PPD
else if (ppd->num_filters == 0)
{
- /* No filter line, manufacturer-supplied PostScript PPD
- In this case cfFilterPSToPS, called by cfFilterPDFToPS, does the
- logging */
+ // No filter line, manufacturer-supplied PostScript PPD
+ // In this case cfFilterPSToPS, called by cfFilterPDFToPS, does the
+ // logging
page_logging = 0;
}
else
{
- /* Filter(s) specified by filter line(s), determine the one which got
- actually used via final data MIME type */
+ // Filter(s) specified by filter line(s), determine the one which got
+ // actually used via final data MIME type
bool cupsfilter2 = (ppdFindAttr(ppd, "cupsFilter2", NULL) != NULL);
for (lastfilter = (char *)cupsArrayFirst(ppd->cache->filters);
lastfilter;
char *p = lastfilter;
if (cupsfilter2)
{
- /* Skip first word as the final content type is the second */
+ // Skip first word as the final content type is the second
while (!isspace(*p)) p ++;
while (isspace(*p)) p ++;
}
{
if (lastfilter)
{
- /* Get the name of the last filter, without mime type and cost */
+ // Get the name of the last filter, without mime type and cost
char *p = lastfilter;
char *q = p + strlen(p) - 1;
while (!isspace(*q) && *q != '/') q --;
lastfilter = q + 1;
- /* Check whether the PDF filter has to log */
+ // Check whether the PDF filter has to log
if (!strcasecmp(lastfilter, "-"))
{
- /* No filter defined in the PPD
- If output data is PDF, cfFilterPDFToPDF() is last
- filter (PDF printer) and has to log
- If output data is Postscript, ppdFilterPSToPS() should log,
- but it only logs with a pure PostScript PPD (no filter definition),
- so the PDF filter has to log
- If output data is Apple/PWG Raster or PCLm, cfFilter*ToRaster() is
- last filter (Driverless IPP printer) and cfFilterPDFToPDF()
- also has to log */
+ // No filter defined in the PPD
+ // If output data is PDF, cfFilterPDFToPDF() is last
+ // filter (PDF printer) and has to log
+ // If output data is Postscript, ppdFilterPSToPS() should log,
+ // but it only logs with a pure PostScript PPD (no filter definition),
+ // so the PDF filter has to log
+ // If output data is Apple/PWG Raster or PCLm, cfFilter*ToRaster() is
+ // last filter (Driverless IPP printer) and cfFilterPDFToPDF()
+ // also has to log
if (strcasestr(data->final_content_type, "/pdf") ||
strcasestr(data->final_content_type, "/vnd.cups-pdf") ||
strcasestr(data->final_content_type, "/postscript") ||
else if (!strcasecmp(lastfilter, "pdftopdf") ||
!strcasecmp(lastfilter, "imagetopdf"))
{
- /* cfFilterPDFToPDF() is last filter (PDF printer) */
+ // cfFilterPDFToPDF() is last filter (PDF printer)
page_logging = 1;
}
else if (!strcasecmp(lastfilter, "gstopxl"))
{
- /* cfFilterGhostscript() with PCL-XL output is last filter,
- this is a Ghostscript-based filter without access to the
- pages of the file to be printed, so the PDF filter has to
- log the pages */
+ // cfFilterGhostscript() with PCL-XL output is last filter,
+ // this is a Ghostscript-based filter without access to the
+ // pages of the file to be printed, so the PDF filter has to
+ // log the pages
page_logging = 1;
}
else if (!strcasecmp(lastfilter + strlen(lastfilter) - 8,
!strcasecmp(lastfilter + strlen(lastfilter) - 5,
"topwg"))
{
- /* On IPP Everywhere printers which accept PWG Raster data one
- of cfFilterGhostscript(), cfFilterPDFToRaster(), or
- cfFilterMuPDFToPWG() is the last filter. These filters do not
- log pages so the PDF filter has to do it */
+ // On IPP Everywhere printers which accept PWG Raster data one
+ // of cfFilterGhostscript(), cfFilterPDFToRaster(), or
+ // cfFilterMuPDFToPWG() is the last filter. These filters do not
+ // log pages so the PDF filter has to do it
page_logging = 1;
}
else if (!strcasecmp(lastfilter, "foomatic-rip"))
{
- /* foomatic-rip is last filter, foomatic-rip is mainly used as
- Ghostscript wrapper to use Ghostscript's built-in printer
- drivers. Here there is also no access to the pages so that we
- delegate the logging to the PDF filter */
+ // foomatic-rip is last filter, foomatic-rip is mainly used as
+ // Ghostscript wrapper to use Ghostscript's built-in printer
+ // drivers. Here there is also no access to the pages so that we
+ // delegate the logging to the PDF filter
page_logging = 1;
}
else if (!strncasecmp(lastfilter + strlen(lastfilter) - 4, "tops", 4))
{
- /* Something-to PostScript filter is the last filter, so output is
- PostScript but these filters only log with pure PostScript PPD
- (no filter definition), so the PDF filter has to log */
+ // Something-to PostScript filter is the last filter, so output is
+ // PostScript but these filters only log with pure PostScript PPD
+ // (no filter definition), so the PDF filter has to log
page_logging = 1;
}
else if (!strcasecmp(lastfilter, "hpps"))
{
- /* hpps is last filter, hpps is part of HPLIP and it is a bug that
- it does not do the page logging. */
+ // hpps is last filter, hpps is part of HPLIP and it is a bug that
+ // it does not do the page logging.
page_logging = 1;
}
else
{
- /* All the other filters (printer drivers) log pages as expected. */
+ // All the other filters (printer drivers) log pages as expected.
page_logging = 0;
}
}
(page_logging == 0 ? "not " : ""));
}
- /* Pass on the result as "pdf-filter-page-logging" option */
+ // Pass on the result as "pdf-filter-page-logging" option
data->num_options = cupsAddOption("pdf-filter-page-logging",
(page_logging == 1 ? "On" : "Off"),
data->num_options, &(data->options));
}
-/*
- * 'ppdFilterFreePPDFile()' - After being done with the filter
- * functions free the memory used by the
- * PPD file data in the data structure. If
- * the pointer to the "libppd" is NULL, do
- * nothing.
- */
+//
+// 'ppdFilterFreePPDFile()' - After being done with the filter
+// functions free the memory used by the
+// PPD file data in the data structure. If
+// the pointer to the "libppd" is NULL, do
+// nothing.
+//
void
-ppdFilterFreePPDFile(cf_filter_data_t *data) /* I - Job and printer data */
+ppdFilterFreePPDFile(cf_filter_data_t *data) // I - Job and printer data
{
ppd_filter_data_ext_t *filter_data_ext =
(ppd_filter_data_ext_t *)cfFilterDataRemoveExt(data,
if (filter_data_ext)
{
if (filter_data_ext->ppd)
- /* ppdClose() frees not only the main data structure but also the cache */
+ // ppdClose() frees not only the main data structure but also the cache
ppdClose(filter_data_ext->ppd);
if (filter_data_ext->ppdfile)
}
-/*
- * 'ppdFilterFreePPD()' - After being done with the filter functions
- * free the memory used by the PPD file data in
- * the data structure. If the pointers to the
- * data extracted from the PPD are NULL, do
- * nothing.
- */
+//
+// 'ppdFilterFreePPD()' - After being done with the filter functions
+// free the memory used by the PPD file data in
+// the data structure. If the pointers to the
+// data extracted from the PPD are NULL, do
+// nothing.
+//
void
-ppdFilterFreePPD(cf_filter_data_t *data) /* I - Job and printer data */
+ppdFilterFreePPD(cf_filter_data_t *data) // I - Job and printer data
{
if (data->printer_attrs)
{
}
-/*
- * 'get_env_var()' - Auxiliary function for ppdFilterExternalCUPS(), gets value of
- * an environment variable in a list of environment variables
- * as used by the execve() function
- */
+//
+// 'get_env_var()' - Auxiliary function for ppdFilterExternalCUPS(),
+// gets value of an environment variable in a list
+// of environment variables as used by the execve()
+// function
+//
-static char * /* O - The value, NULL if variable is not in list */
-get_env_var(char *name, /* I - Name of environment variable to read */
- char **env) /* I - List of environment variable serttings */
+static char * // O - The value, NULL if variable is not in list
+get_env_var(char *name, // I - Name of environment variable to read
+ char **env) // I - List of environment variable serttings
{
int i = 0;
}
-/*
- * 'add_env_var()' - Auxiliary function for ppdFilterExternalCUPS(), adds/sets
- * an environment variable in a list of environment variables
- * as used by the execve() function
- */
+//
+// 'add_env_var()' - Auxiliary function for ppdFilterExternalCUPS(),
+// adds/sets an environment variable in a list of
+// environment variables as used by the execve()
+// function
+//
-static int /* O - Index of where the new value got inserted in
- the list */
-add_env_var(char *name, /* I - Name of environment variable to set */
- char *value, /* I - Value of environment variable to set */
- char ***env) /* I - List of environment variable serttings */
+static int // O - Index of where the new value got inserted in
+ // the list
+add_env_var(char *name, // I - Name of environment variable to set
+ char *value, // I - Value of environment variable to set
+ char ***env) // I - List of environment variable serttings
{
char *p;
int i = 0,
if (!name || !env || !name[0])
return (-1);
- /* Assemble a "VAR=VALUE" string and the string length of "VAR" */
+ // Assemble a "VAR=VALUE" string and the string length of "VAR"
if ((p = strchr(name, '=')) != NULL)
{
- /* User supplied "VAR=VALUE" as name and NULL as value */
+ // User supplied "VAR=VALUE" as name and NULL as value
if (value)
return (-1);
name_len = p - name;
}
else
{
- /* User supplied variable name and value as the name and as the value */
+ // User supplied variable name and value as the name and as the value
name_len = strlen(name);
p = (char *)calloc(strlen(name) + (value ? strlen(value) : 0) + 2,
sizeof(char));
sprintf(p, "%s=%s", name, (value ? value : ""));
}
- /* Check whether we already have this variable in the list and update its
- value if it is there */
+ // Check whether we already have this variable in the list and update its
+ // value if it is there
if (*env)
for (i = 0; (*env)[i]; i ++)
if (strncmp((*env)[i], p, name_len) == 0 && (*env)[i][name_len] == '=')
return (i);
}
- /* Add the variable as new item to the list */
+ // Add the variable as new item to the list
*env = (char **)realloc(*env, (i + 2) * sizeof(char *));
(*env)[i] = p;
(*env)[i + 1] = NULL;
}
-/*
- * 'sanitize_device_uri()' - Remove authentication info from a device URI
- */
+//
+// 'sanitize_device_uri()' - Remove authentication info from a device URI
+//
-static char * /* O - Sanitized URI */
-sanitize_device_uri(const char *uri, /* I - Device URI */
- char *buf, /* I - Buffer for output */
- size_t bufsize) /* I - Size of buffer */
+static char * // O - Sanitized URI
+sanitize_device_uri(const char *uri, // I - Device URI
+ char *buf, // I - Buffer for output
+ size_t bufsize) // I - Size of buffer
{
- char *start, /* Start of data after scheme */
- *slash, /* First slash after scheme:// */
- *ptr; /* Pointer into user@host:port part */
+ char *start, // Start of data after scheme
+ *slash, // First slash after scheme://
+ *ptr; // Pointer into user@host:port part
- /* URI not supplied */
+ // URI not supplied
if (!uri)
return (NULL);
- /* Copy the device URI to a temporary buffer so we can sanitize any auth
- * info in it... */
+ // Copy the device URI to a temporary buffer so we can sanitize any auth
+ // info in it...
strncpy(buf, uri, bufsize);
- /* Find the end of the scheme:// part... */
+ // Find the end of the scheme:// part...
if ((ptr = strchr(buf, ':')) != NULL)
{
for (start = ptr + 1; *start; start ++)
if (*start != '/')
break;
- /* Find the next slash (/) in the URI... */
+ // Find the next slash (/) in the URI...
if ((slash = strchr(start, '/')) == NULL)
- slash = start + strlen(start); /* No slash, point to the end */
+ slash = start + strlen(start); // No slash, point to the end
- /* Check for an @ sign before the slash... */
+ // Check for an @ sign before the slash...
if ((ptr = strchr(start, '@')) != NULL && ptr < slash)
{
- /* Found an @ sign and it is before the resource part, so we have
- an authentication string. Copy the remaining URI over the
- authentication string... */
+ // Found an @ sign and it is before the resource part, so we have
+ // an authentication string. Copy the remaining URI over the
+ // authentication string...
memmove(start, ptr + 1, strlen(ptr + 1) + 1);
}
}
- /* Return the sanitized URI... */
+ // Return the sanitized URI...
return (buf);
}
-/*
- * 'fcntl_add_cloexec()' - Add FD_CLOEXEC flag to the flags
- * of a given file descriptor.
- */
+//
+// 'fcntl_add_cloexec()' - Add FD_CLOEXEC flag to the flags
+// of a given file descriptor.
+//
-static int /* Return value of fcntl() */
-fcntl_add_cloexec(int fd) /* File descriptor to add FD_CLOEXEC to */
+static int // Return value of fcntl()
+fcntl_add_cloexec(int fd) // File descriptor to add FD_CLOEXEC to
{
return fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
}
-/*
- * 'fcntl_add_nonblock()' - Add O_NONBLOCK flag to the flags
- * of a given file descriptor.
- */
+//
+// 'fcntl_add_nonblock()' - Add O_NONBLOCK flag to the flags
+// of a given file descriptor.
-static int /* Return value of fcntl() */
-fcntl_add_nonblock(int fd) /* File descriptor to add O_NONBLOCK to */
+
+static int // Return value of fcntl()
+fcntl_add_nonblock(int fd) // File descriptor to add O_NONBLOCK to
{
return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
}
-/*
- * 'ppdFilterExternalCUPS()' - Filter function which calls an external,
- * classic CUPS filter, for example a
- * (proprietary) printer driver which cannot
- * be converted to a filter function or is to
- * awkward or risky to convert for example
- * when the printer hardware is not available
- * for testing
- */
-
-int /* O - Error status */
-ppdFilterExternalCUPS(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream */
- int inputseekable, /* I - Is input stream seekable? */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters) /* I - Filter-specific parameters */
+//
+// 'ppdFilterExternalCUPS()' - Filter function which calls an
+// external, classic CUPS filter, for
+// example a (proprietary) printer driver
+// which cannot be converted to a filter
+// function or is to awkward or risky to
+// convert for example when the printer
+// hardware is not available for testing
+
+
+int // O - Error status
+ppdFilterExternalCUPS(int inputfd, // I - File descriptor input stream
+ int outputfd, // I - File descriptor output stream
+ int inputseekable, // I - Is input stream seekable?
+ cf_filter_data_t *data, // I - Job and printer data
+ void *parameters) // I - Filter-specific parameters
{
ppd_filter_data_ext_t *filter_data_ext =
(ppd_filter_data_ext_t *)cfFilterDataGetExt(data,
PPD_FILTER_DATA_EXT);
ppd_filter_external_cups_t *params = (ppd_filter_external_cups_t *)parameters;
int i;
- int is_backend = 0; /* Do we call a CUPS backend? */
- int pid, /* Process ID of filter */
- stderrpid, /* Process ID for stderr logging process */
- wpid; /* PID reported as terminated */
- int fd; /* Temporary file descriptor */
- int backfd, sidefd; /* file descriptors for back and side
- channels */
- int stderrpipe[2]; /* Pipe to log stderr */
- cups_file_t *fp; /* File pointer to read log lines */
- char buf[2048]; /* Log line buffer */
- cf_loglevel_t log_level; /* Log level of filter's log message */
+ int is_backend = 0; // Do we call a CUPS backend?
+ int pid, // Process ID of filter
+ stderrpid, // Process ID for stderr logging process
+ wpid; // PID reported as terminated
+ int fd; // Temporary file descriptor
+ int backfd, sidefd; // file descriptors for back and side
+ // channels
+ int stderrpipe[2]; // Pipe to log stderr
+ cups_file_t *fp; // File pointer to read log lines
+ char buf[2048]; // Log line buffer
+ cf_loglevel_t log_level; // Log level of filter's log message
char *ptr1, *ptr2,
- *msg, /* Filter log message */
- *filter_name; /* Filter name for logging */
- char filter_path[1024]; /* Full path of the filter */
- char **argv, /* Command line args for filter */
- **envp = NULL; /* Environment variables for filter */
+ *msg, // Filter log message
+ *filter_name; // Filter name for logging
+ char filter_path[1024]; // Full path of the filter
+ char **argv, // Command line args for filter
+ **envp = NULL; // Environment variables for filter
int num_all_options = 0;
cups_option_t *all_options = NULL;
char job_id_str[16],
copies_str[16],
*options_str = NULL;
cups_option_t *opt;
- int status = 65536;
- int wstatus;
- cf_logfunc_t log = data->logfunc;
+ int status = 65536;
+ int wstatus;
+ cf_logfunc_t log = data->logfunc;
void *ld = data->logdata;
cf_filter_iscanceledfunc_t iscanceled = data->iscanceledfunc;
void *icd = data->iscanceleddata;
- if (!params->filter || !params->filter[0]) {
+ if (!params->filter || !params->filter[0])
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterExternalCUPS: Filter executable path/command not specified");
return (1);
}
- /* Check whether back/side channel FDs are valid and not all-zero
- from calloc'ed filter_data */
+ // Check whether back/side channel FDs are valid and not all-zero
+ // from calloc'ed filter_data
if (data->back_pipe[0] == 0 && data->back_pipe[1] == 0)
data->back_pipe[0] = data->back_pipe[1] = -1;
if (data->side_pipe[0] == 0 && data->side_pipe[1] == 0)
data->side_pipe[0] = data->side_pipe[1] = -1;
- /* Select the correct end of the back/side channel pipes:
- [0] for filters, [1] for backends */
+ // Select the correct end of the back/side channel pipes:
+ // [0] for filters, [1] for backends
is_backend = (params->is_backend ? 1 : 0);
backfd = data->back_pipe[is_backend];
sidefd = data->side_pipe[is_backend];
- /* Filter name for logging */
+ // Filter name for logging
if ((filter_name = strrchr(params->filter, '/')) != NULL)
filter_name ++;
else
filter_name = (char *)params->filter;
- /*
- * Ignore broken pipe signals...
- */
+ //
+ // Ignore broken pipe signals...
+ //
signal(SIGPIPE, SIG_IGN);
- /*
- * Copy the current environment variables and add some important ones
- * needed for correct execution of the CUPS filter (which is not running
- * out of CUPS here)
- */
+ //
+ // Copy the current environment variables and add some important ones
+ // needed for correct execution of the CUPS filter (which is not running
+ // out of CUPS here)
+ //
- /* Some default environment variables from CUPS, will get overwritten
- if also defined in the environment in which the caller is started
- or in the parameters */
+ // Some default environment variables from CUPS, will get overwritten
+ // if also defined in the environment in which the caller is started
+ // or in the parameters
add_env_var("CUPS_DATADIR", CUPS_DATADIR, &envp);
add_env_var("CUPS_SERVERBIN", CUPS_SERVERBIN, &envp);
add_env_var("CUPS_SERVERROOT", CUPS_SERVERROOT, &envp);
add_env_var("CUPS_STATEDIR", CUPS_STATEDIR, &envp);
- add_env_var("SOFTWARE", "CUPS/2.5.99", &envp); /* Last CUPS with PPDs */
+ add_env_var("SOFTWARE", "CUPS/2.5.99", &envp); // Last CUPS with PPDs
if (data->content_type)
add_env_var("CONTENT_TYPE", data->content_type, &envp);
if (data->final_content_type)
add_env_var("FINAL_CONTENT_TYPE", data->final_content_type, &envp);
- /* Copy the environment in which the caller got started */
+ // Copy the environment in which the caller got started
if (environ)
for (i = 0; environ[i]; i ++)
add_env_var(environ[i], NULL, &envp);
- /* Set the environment variables given by the parameters */
+ // Set the environment variables given by the parameters
if (params->envp)
for (i = 0; params->envp[i]; i ++)
add_env_var(params->envp[i], NULL, &envp);
- /* Add CUPS_SERVERBIN to the beginning of PATH */
+ // Add CUPS_SERVERBIN to the beginning of PATH
ptr1 = get_env_var("PATH", envp);
ptr2 = get_env_var("CUPS_SERVERBIN", envp);
if (ptr2 && ptr2[0])
add_env_var("PATH", ptr1, &envp);
}
- if (params->is_backend < 2) /* Not needed in discovery mode of backend */
+ if (params->is_backend < 2) // Not needed in discovery mode of backend
{
- /* Print queue name from filter data */
+ // Print queue name from filter data
if (data->printer)
add_env_var("PRINTER", data->printer, &envp);
else
add_env_var("PRINTER", "Unknown", &envp);
- /* PPD file path/name from filter data, required for most CUPS filters */
+ // PPD file path/name from filter data, required for most CUPS filters
if (filter_data_ext && filter_data_ext->ppdfile)
add_env_var("PPD", filter_data_ext->ppdfile, &envp);
- /* Device URI from parameters */
+ // Device URI from parameters
if (params->is_backend && params->device_uri)
add_env_var("DEVICE_URI", (char *)params->device_uri, &envp);
}
- /* Determine full path for the filter */
+ // Determine full path for the filter
if (params->filter[0] == '/' ||
(ptr1 = get_env_var("CUPS_SERVERBIN", envp)) == NULL || !ptr1[0])
strncpy(filter_path, params->filter, sizeof(filter_path) - 1);
snprintf(filter_path, sizeof(filter_path), "%s/%s/%s", ptr1,
params->is_backend ? "backend" : "filter", params->filter);
- /* Log the resulting list of environment variable settings
- (with any authentication info removed)*/
+ // Log the resulting list of environment variable settings
+ // (with any authentication info removed)
if (log)
{
for (i = 0; envp[i]; i ++)
if (!strncmp(envp[i], "AUTH_", 5))
- log(ld, CF_LOGLEVEL_DEBUG, "ppdFilterExternalCUPS (%s): envp[%d]: AUTH_%c****",
+ log(ld, CF_LOGLEVEL_DEBUG,
+ "ppdFilterExternalCUPS (%s): envp[%d]: AUTH_%c****",
filter_name, i, envp[i][5]);
else if (!strncmp(envp[i], "DEVICE_URI=", 11))
- log(ld, CF_LOGLEVEL_DEBUG, "ppdFilterExternalCUPS (%s): envp[%d]: DEVICE_URI=%s",
+ log(ld, CF_LOGLEVEL_DEBUG,
+ "ppdFilterExternalCUPS (%s): envp[%d]: DEVICE_URI=%s",
filter_name, i, sanitize_device_uri(envp[i] + 11,
buf, sizeof(buf)));
else
filter_name, i, envp[i]);
}
- if (params->is_backend < 2) {
- /*
- * Filter or backend for job execution
- */
+ if (params->is_backend < 2)
+ {
+ //
+ // Filter or backend for job execution
+ //
- /*
- * Join the options from the filter data and from the parameters
- * If an option is present in both filter data and parameters, the
- * value in the filter data has priority
- */
+ //
+ // Join the options from the filter data and from the parameters
+ // If an option is present in both filter data and parameters, the
+ // value in the filter data has priority
+ //
for (i = 0, opt = params->options; i < params->num_options; i ++, opt ++)
num_all_options = cupsAddOption(opt->name, opt->value, num_all_options,
num_all_options = cupsAddOption(opt->name, opt->value, num_all_options,
&all_options);
- /*
- * Create command line arguments for the CUPS filter
- */
+ //
+ // Create command line arguments for the CUPS filter
+ //
argv = (char **)calloc(7, sizeof(char *));
- /* Numeric parameters */
+ // Numeric parameters
snprintf(job_id_str, sizeof(job_id_str) - 1, "%d",
data->job_id > 0 ? data->job_id : 1);
snprintf(copies_str, sizeof(copies_str) - 1, "%d",
data->copies > 0 ? data->copies : 1);
- /* Options, build string of "Name1=Value1 Name2=Value2 ..." but use
- "Name" and "noName" instead for boolean options */
- for (i = 0, opt = all_options; i < num_all_options; i ++, opt ++) {
+ // Options, build string of "Name1=Value1 Name2=Value2 ..." but use
+ // "Name" and "noName" instead for boolean options
+ for (i = 0, opt = all_options; i < num_all_options; i ++, opt ++)
+ {
if (strcasecmp(opt->value, "true") == 0 ||
- strcasecmp(opt->value, "false") == 0) {
+ strcasecmp(opt->value, "false") == 0)
+ {
options_str =
(char *)realloc(options_str,
((options_str ? strlen(options_str) : 0) +
options_str[0] = '\0';
sprintf(options_str + strlen(options_str), " %s%s",
(strcasecmp(opt->value, "false") == 0 ? "no" : ""), opt->name);
- } else {
+ }
+ else
+ {
options_str =
(char *)realloc(options_str,
((options_str ? strlen(options_str) : 0) +
sizeof(char));
if (i == 0)
options_str[0] = '\0';
- sprintf(options_str + strlen(options_str), " %s=%s", opt->name, opt->value);
+ sprintf(options_str + strlen(options_str), " %s=%s", opt->name,
+ opt->value);
}
}
- /* Find DEVICE_URI environment variable */
+ // Find DEVICE_URI environment variable
if (params->is_backend && !params->device_uri)
for (i = 0; envp[i]; i ++)
if (strncmp(envp[i], "DEVICE_URI=", 11) == 0)
break;
- /* Add items to array */
+ // Add items to array
argv[0] = strdup((params->is_backend && params->device_uri ?
(char *)sanitize_device_uri(params->device_uri,
buf, sizeof(buf)) :
argv[5] = options_str ? options_str + 1 : "";
argv[6] = NULL;
- /* Log the arguments */
+ // Log the arguments
if (log)
for (i = 0; argv[i]; i ++)
log(ld, CF_LOGLEVEL_DEBUG, "ppdFilterExternalCUPS (%s): argv[%d]: %s",
filter_name, i, argv[i]);
- } else {
- /*
- * Backend in device discovery mode
- */
+ }
+ else
+ {
+ //
+ // Backend in device discovery mode
+ //
argv = (char **)calloc(2, sizeof(char *));
argv[0] = strdup((char *)params->filter);
argv[1] = NULL;
}
- /*
- * Execute the filter
- */
+ //
+ // Execute the filter
+ //
- if (pipe(stderrpipe) < 0) {
+ if (pipe(stderrpipe) < 0)
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterExternalCUPS (%s): Could not create pipe for stderr: %s",
filter_name, strerror(errno));
return (1);
}
- if ((pid = fork()) == 0) {
- /*
- * Child process goes here...
- *
- * Update stdin/stdout/stderr as needed...
- */
+ if ((pid = fork()) == 0)
+ {
+ //
+ // Child process goes here...
+ //
+ // Update stdin/stdout/stderr as needed...
+ //
- if (inputfd != 0) {
- if (inputfd < 0) {
+ if (inputfd != 0)
+ {
+ if (inputfd < 0)
+ {
inputfd = open("/dev/null", O_RDONLY);
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterExternalCUPS (%s): No input file descriptor supplied for CUPS filter - %s",
- filter_name, strerror(errno));
+ filter_name, strerror(errno));
}
- if (inputfd > 0) {
+ if (inputfd > 0)
+ {
fcntl_add_cloexec(inputfd);
- if (dup2(inputfd, 0) < 0) {
+ if (dup2(inputfd, 0) < 0)
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterExternalCUPS (%s): Failed to connect input file descriptor with CUPS filter's stdin - %s",
filter_name, strerror(errno));
filter_name, inputfd);
close(inputfd);
}
- } else
+ }
+ else
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterExternalCUPS (%s): Input comes from stdin, letting the filter grab stdin directly",
filter_name);
- if (outputfd != 1) {
+ if (outputfd != 1)
+ {
if (outputfd < 0)
outputfd = open("/dev/null", O_WRONLY);
}
}
- if (strcasestr(params->filter, "gziptoany")) {
- /* Send stderr to the Nirwana if we are running gziptoany, as
- gziptoany emits a false "PAGE: 1 1" */
- if ((fd = open("/dev/null", O_RDWR)) > 2) {
+ if (strcasestr(params->filter, "gziptoany"))
+ {
+ // Send stderr to the Nirwana if we are running gziptoany, as
+ // gziptoany emits a false "PAGE: 1 1"
+ if ((fd = open("/dev/null", O_RDWR)) > 2)
+ {
fcntl_add_cloexec(fd);
dup2(fd, 2);
close(fd);
} else
close(fd);
- } else {
- /* Send stderr into pipe for logging */
+ }
+ else
+ {
+ // Send stderr into pipe for logging
fcntl_add_cloexec(stderrpipe[1]);
dup2(stderrpipe[1], 2);
fcntl_add_nonblock(2);
close(stderrpipe[0]);
close(stderrpipe[1]);
- if (params->is_backend < 2) { /* Not needed in discovery mode of backend */
- /* Back channel */
- if (backfd != 3 && backfd >= 0) {
+ if (params->is_backend < 2) // Not needed in discovery mode of backend
+ {
+ // Back channel
+ if (backfd != 3 && backfd >= 0)
+ {
dup2(backfd, 3);
close(backfd);
fcntl_add_nonblock(3);
- } else if (backfd < 0) {
- if ((backfd = open("/dev/null", O_RDWR)) > 3) {
+ }
+ else if (backfd < 0)
+ {
+ if ((backfd = open("/dev/null", O_RDWR)) > 3)
+ {
dup2(backfd, 3);
close(backfd);
- } else
+ }
+ else
close(backfd);
fcntl_add_nonblock(3);
}
- /* Side channel */
- if (sidefd != 4 && sidefd >= 0) {
+ // Side channel
+ if (sidefd != 4 && sidefd >= 0)
+ {
dup2(sidefd, 4);
close(sidefd);
fcntl_add_nonblock(4);
- } else if (sidefd < 0) {
- if ((sidefd = open("/dev/null", O_RDWR)) > 4) {
+ }
+ else if (sidefd < 0)
+ {
+ if ((sidefd = open("/dev/null", O_RDWR)) > 4)
+ {
dup2(sidefd, 4);
close(sidefd);
} else
}
}
- /*
- * Execute command...
- */
+ //
+ // Execute command...
+ //
execve(filter_path, argv, envp);
fd_error:
exit(errno);
- } else if (pid > 0) {
+ }
+ else if (pid > 0)
+ {
if (log) log(ld, CF_LOGLEVEL_INFO,
"ppdFilterExternalCUPS (%s): %s (PID %d) started.",
filter_name, filter_path, pid);
- } else {
+ }
+ else
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterExternalCUPS (%s): Unable to fork process for %s %s",
filter_name, params->is_backend ? "backend" : "filter",
if (outputfd >= 0)
close(outputfd);
- /*
- * Log the filter's stderr
- */
+ //
+ // Log the filter's stderr
+ //
- if ((stderrpid = fork()) == 0) {
- /*
- * Child process goes here...
- */
+ if ((stderrpid = fork()) == 0)
+ {
+ //
+ // Child process goes here...
+ //
close(stderrpipe[1]);
fp = cupsFileOpenFd(stderrpipe[0], "r");
while (cupsFileGets(fp, buf, sizeof(buf)))
- if (log) {
- if (strncmp(buf, "DEBUG: ", 7) == 0) {
+ if (log)
+ {
+ if (strncmp(buf, "DEBUG: ", 7) == 0)
+ {
log_level = CF_LOGLEVEL_DEBUG;
msg = buf + 7;
- } else if (strncmp(buf, "DEBUG2: ", 8) == 0) {
+ }
+ else if (strncmp(buf, "DEBUG2: ", 8) == 0)
+ {
log_level = CF_LOGLEVEL_DEBUG;
msg = buf + 8;
- } else if (strncmp(buf, "INFO: ", 6) == 0) {
+ }
+ else if (strncmp(buf, "INFO: ", 6) == 0)
+ {
log_level = CF_LOGLEVEL_INFO;
msg = buf + 6;
- } else if (strncmp(buf, "WARNING: ", 9) == 0) {
+ }
+ else if (strncmp(buf, "WARNING: ", 9) == 0)
+ {
log_level = CF_LOGLEVEL_WARN;
msg = buf + 9;
- } else if (strncmp(buf, "ERROR: ", 7) == 0) {
+ }
+ else if (strncmp(buf, "ERROR: ", 7) == 0)
+ {
log_level = CF_LOGLEVEL_ERROR;
msg = buf + 7;
- } else if (strncmp(buf, "PAGE: ", 6) == 0 ||
- strncmp(buf, "ATTR: ", 6) == 0 ||
- strncmp(buf, "STATE: ", 7) == 0 ||
- strncmp(buf, "PPD: ", 5) == 0) {
+ }
+ else if (strncmp(buf, "PAGE: ", 6) == 0 ||
+ strncmp(buf, "ATTR: ", 6) == 0 ||
+ strncmp(buf, "STATE: ", 7) == 0 ||
+ strncmp(buf, "PPD: ", 5) == 0)
+ {
log_level = CF_LOGLEVEL_CONTROL;
msg = buf;
- } else {
+ }
+ else
+ {
log_level = CF_LOGLEVEL_DEBUG;
msg = buf;
}
if (log_level == CF_LOGLEVEL_CONTROL)
log(ld, log_level, msg);
else
- log(ld, log_level, "ppdFilterExternalCUPS (%s): %s", filter_name, msg);
+ log(ld, log_level, "ppdFilterExternalCUPS (%s): %s",
+ filter_name, msg);
}
cupsFileClose(fp);
- /* No need to close the fd stderrpipe[0], as cupsFileClose(fp) does this
- already */
- /* Ignore errors of the logging process */
+ // No need to close the fd stderrpipe[0], as cupsFileClose(fp) does this
+ // already
+ // Ignore errors of the logging process
exit(0);
- } else if (stderrpid > 0) {
+ }
+ else if (stderrpid > 0)
+ {
if (log) log(ld, CF_LOGLEVEL_INFO,
"ppdFilterExternalCUPS (%s): Logging (PID %d) started.",
filter_name, stderrpid);
- } else {
+ }
+ else
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterExternalCUPS (%s): Unable to fork process for logging",
filter_name);
close(stderrpipe[0]);
close(stderrpipe[1]);
- /*
- * Wait for filter and logging processes to finish
- */
+ //
+ // Wait for filter and logging processes to finish
+ //
status = 0;
- while (pid > 0 || stderrpid > 0) {
- if ((wpid = wait(&wstatus)) < 0) {
- if (errno == EINTR && iscanceled && iscanceled(icd)) {
+ while (pid > 0 || stderrpid > 0)
+ {
+ if ((wpid = wait(&wstatus)) < 0)
+ {
+ if (errno == EINTR && iscanceled && iscanceled(icd))
+ {
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterExternalCUPS (%s): Job canceled, killing %s ...",
filter_name, params->is_backend ? "backend" : "filter");
kill(stderrpid, SIGTERM);
stderrpid = -1;
break;
- } else
+ }
+ else
continue;
}
- /* How did the filter terminate */
- if (wstatus) {
- if (WIFEXITED(wstatus)) {
- /* Via exit() anywhere or return() in the main() function */
+ // How did the filter terminate
+ if (wstatus)
+ {
+ if (WIFEXITED(wstatus))
+ {
+ // Via exit() anywhere or return() in the main() function
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterExternalCUPS (%s): %s (PID %d) stopped with status %d",
filter_name,
(params->is_backend ? "Backend" : "Filter") :
"Logging"),
wpid, WEXITSTATUS(wstatus));
- } else {
- /* Via signal */
+ }
+ else
+ {
+ // Via signal
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterExternalCUPS (%s): %s (PID %d) crashed on signal %d",
filter_name,
wpid, WTERMSIG(wstatus));
}
status = 1;
- } else {
+ }
+ else
+ {
if (log) log(ld, CF_LOGLEVEL_INFO,
"ppdFilterExternalCUPS (%s): %s (PID %d) exited with no errors.",
filter_name,
stderrpid = -1;
}
- /*
- * Clean up
- */
+ //
+ // Clean up
+ //
out:
cupsFreeOptions(num_all_options, all_options);
}
-/*
- * 'ppdFilterEmitJCL()' - Wrapper for the PDF-generating filter
- * functions to emit JCL (PJL) before and after
- * the PDF output.
- */
+//
+// 'ppdFilterEmitJCL()' - Wrapper for the PDF-generating filter
+// functions to emit JCL (PJL) before and after
+// the PDF output.
+//
-int /* O - Error status */
-ppdFilterEmitJCL(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream */
- int inputseekable, /* I - Is input stream seekable? */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters, /* I - Filter-specific parameters */
+int // O - Error status
+ppdFilterEmitJCL(int inputfd, // I - File descriptor input stream
+ int outputfd, // I - File descriptor output stream
+ int inputseekable, // I - Is input stream seekable?
+ cf_filter_data_t *data, // I - Job and printer data
+ void *parameters, // I - Filter-specific parameters
cf_filter_function_t orig_filter)
{
ppd_filter_data_ext_t *filter_data_ext =
FILE *fp;
int hw_copies = 1;
bool hw_collate = false;
- int status, /* Exit status */
- retval = 1; /* Return value */
+ int status, // Exit status
+ retval = 1; // Return value
cf_logfunc_t log = data->logfunc;
void *ld = data->logdata;
- /*
- * Check whether we are in streaming mode (cfFilterPDFToPDF() only)
- *
- * If we are in streaming mode of cfFilterPDFToPDF() we only apply
- * JCL and do not run the job through cfFilterPDFToPDF() itself (so
- * no page management, form flattening, page size/orientation
- * adjustment, ...)
- */
+ //
+ // Check whether we are in streaming mode (cfFilterPDFToPDF() only)
+ //
+ // If we are in streaming mode of cfFilterPDFToPDF() we only apply
+ // JCL and do not run the job through cfFilterPDFToPDF() itself (so
+ // no page management, form flattening, page size/orientation
+ // adjustment, ...)
+ //
if (orig_filter == cfFilterPDFToPDF &&
(val = cupsGetOption("filter-streaming-mode",
"ppdFilterEmitJCL: Streaming mode: No PDF processing, only adding of JCL");
}
- /*
- * Call the original filter function without forking if we suppress
- * JCL output via option...
- */
+ //
+ // Call the original filter function without forking if we suppress
+ // JCL output via option...
+ //
if ((val = cupsGetOption("emit-jcl",
data->num_options, data->options)) != NULL &&
strcasecmp(val, "no") == 0))
{
if (!streaming)
- /* Call actual filter function from libcupsfilters */
+ // Call actual filter function from libcupsfilters
ret = orig_filter(inputfd, outputfd, inputseekable, data, parameters);
else
{
- /* Just pass through the data unchanged... */
+ // Just pass through the data unchanged...
fp = fdopen(outputfd, "w");
while ((bytes = read(inputfd, buf, sizeof(buf))) > 0)
fwrite(buf, 1, bytes, fp);
if (!streaming)
{
- /*
- * Create pipe for output of original filter function...
- */
+ //
+ // Create pipe for output of original filter function...
+ //
if (pipe(outfds) < 0)
{
return (1);
}
- /*
- * Fork child process for original filter function...
- */
+ //
+ // Fork child process for original filter function...
+ //
if ((pid = fork()) == 0)
{
- /* Send output into pipe for adding JCL */
+ // Send output into pipe for adding JCL
fcntl_add_cloexec(outfds[1]);
close(outfds[0]);
- /* Call actual filter function from libcupsfilters */
+ // Call actual filter function from libcupsfilters
ret = orig_filter(inputfd, outfds[1], inputseekable, data, parameters);
exit(ret);
else
{
if (log) log(ld, CF_LOGLEVEL_ERROR,
- "ppdFilterEmitJCL: Unable to fork process for filter function.");
+ "ppdFilterEmitJCL: Unable to fork process for filter function.");
close(outfds[0]);
close(outfds[1]);
retval = 1;
close(outfds[1]);
}
else
-
- /*
- * In Streaming mode we simply copy the input
- */
+ //
+ // In Streaming mode we simply copy the input
+ //
outfds[0] = inputfd;
- /*
- * Check options for caller's instructions about hardware copies/collate
- */
+ //
+ // Check options for caller's instructions about hardware copies/collate
+ //
hw_copies =
((val = cupsGetOption("hardware-copies",
(strcasecmp(val, "true") == 0 || strcasecmp(val, "on") == 0 ||
strcasecmp(val, "yes") == 0));
- /*
- * Assemble the output: Exit server, JCL preamble, PDF output, JCL postamble
- */
+ //
+ // Assemble the output: Exit server, JCL preamble, PDF output, JCL postamble
+ //
fp = fdopen(outputfd, "w");
if (filter_data_ext)
if (!streaming)
{
- /*
- * Wait for filter process to finish
- */
+ //
+ // Wait for filter process to finish
+ //
retry_wait:
if (waitpid (pid, &status, 0) == -1)
"ppdFilterEmitJCL: Filter function (PID %d) exited with no errors.",
pid);
- /* How did the filter function terminate */
+ // How did the filter function terminate
if (WIFEXITED(status))
- /* Via exit() anywhere or return() in the main() function */
+ // Via exit() anywhere or return() in the main() function
retval = WEXITSTATUS(status);
else if (WIFSIGNALED(status))
- /* Via signal */
+ // Via signal
retval = 256 * WTERMSIG(status);
}
else
}
-/*
- * 'ppdFilterImageToPDF()' - Wrapper for the filter function
- * cfFilterImageToPDF() to add PPD file
- * support to it.
- */
+//
+// 'ppdFilterImageToPDF()' - Wrapper for the filter function
+// cfFilterImageToPDF() to add PPD file
+// support to it.
+//
-int /* O - Error status */
-ppdFilterImageToPDF(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream*/
- int inputseekable, /* I - Is input stream seekable? */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters) /* I - Filter-specific parameters */
+int // O - Error status
+ppdFilterImageToPDF(int inputfd, // I - File descriptor input stream
+ int outputfd, // I - File descriptor output stream
+ int inputseekable, // I - Is input stream seekable?
+ cf_filter_data_t *data, // I - Job and printer data
+ void *parameters) // I - Filter-specific parameters
{
return ppdFilterEmitJCL(inputfd, outputfd, inputseekable, data,
parameters, cfFilterImageToPDF);
}
-/*
- * 'ppdFilterPDFtoPDF()' - Wrapper for the filter function
- * cfFilterPDFtoPDF() to add PPD file
- * support to it.
- */
+//
+// 'ppdFilterPDFtoPDF()' - Wrapper for the filter function
+// cfFilterPDFtoPDF() to add PPD file
+// support to it.
+//
-int /* O - Error status */
-ppdFilterPDFToPDF(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream */
- int inputseekable, /* I - Is input stream seekable? */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters) /* I - Filter-specific parameters */
+int // O - Error status
+ppdFilterPDFToPDF(int inputfd, // I - File descriptor input stream
+ int outputfd, // I - File descriptor output stream
+ int inputseekable, // I - Is input stream seekable?
+ cf_filter_data_t *data, // I - Job and printer data
+ void *parameters) // I - Filter-specific parameters
{
return ppdFilterEmitJCL(inputfd, outputfd, inputseekable, data,
parameters, cfFilterPDFToPDF);
}
-/*
- * 'ppdFilterUniversal()' - Wrapper for the filter function
- * cfFilterUniversal() to add PPD file
- * support to it.
- */
+//
+// 'ppdFilterUniversal()' - Wrapper for the filter function
+// cfFilterUniversal() to add PPD file
+// support to it.
+//
-int /* O - Error status */
-ppdFilterUniversal(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream*/
- int inputseekable, /* I - Is input stream seekable? */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters) /* I - Filter-specific parameters */
+int // O - Error status
+ppdFilterUniversal(int inputfd, // I - File descriptor input stream
+ int outputfd, // I - File descriptor output stream
+ int inputseekable, // I - Is input stream seekable?
+ cf_filter_data_t *data, // I - Job and printer data
+ void *parameters) // I - Filter-specific parameters
{
ppd_filter_data_ext_t *filter_data_ext =
(ppd_filter_data_ext_t *)cfFilterDataGetExt(data,
{
cache = ppd ? ppd->cache : NULL;
- /* Check whether our output format (under CUPS it is taken from
- the FINAL_CONTENT_TYPE env variable) is the destination format
- (2nd word) of a "*cupsFilter2: ..." line (string has 4 words),
- in this case the specified filter (4th word) does the last
- step, converting from the input format (1st word) of the line
- to the destination format and so we only need to convert to the
- input format. In this case we need to correct our output
- format.
-
- If there is more than one line with the given output format and
- an inpout format we can produce, we select the one with the
- lowest cost value (3rd word) as this is the one which CUPS
- should have chosen for this job.
-
- If we have "*cupsFilter: ..." lines (without "2", string with 3
- words) we do not need to do anything special, as the input
- format specified is the FIMAL_CONTENT_TYPE which CUPS supplies
- to us and into which we have to convert. So we quit parsing if
- the first line has only 3 words, as if CUPS uses the
- "*cupsFilter: ..." lines only if there is no "*cupsFilter2:
- ..." line min the PPD, so if we encounter a line with only 3
- words the other lines will have only 3 words, too and nothing
- has to be done. */
+ // Check whether our output format (under CUPS it is taken from
+ // the FINAL_CONTENT_TYPE env variable) is the destination format
+ // (2nd word) of a "*cupsFilter2: ..." line (string has 4 words),
+ // in this case the specified filter (4th word) does the last
+ // step, converting from the input format (1st word) of the line
+ // to the destination format and so we only need to convert to the
+ // input format. In this case we need to correct our output
+ // format.
+ //
+ // If there is more than one line with the given output format and
+ // an inpout format we can produce, we select the one with the
+ // lowest cost value (3rd word) as this is the one which CUPS
+ // should have chosen for this job.
+ //
+ // If we have "*cupsFilter: ..." lines (without "2", string with 3
+ // words) we do not need to do anything special, as the input
+ // format specified is the FIMAL_CONTENT_TYPE which CUPS supplies
+ // to us and into which we have to convert. So we quit parsing if
+ // the first line has only 3 words, as if CUPS uses the
+ // "*cupsFilter: ..." lines only if there is no "*cupsFilter2:
+ // ..." line min the PPD, so if we encounter a line with only 3
+ // words the other lines will have only 3 words, too and nothing
+ // has to be done.
if (ppd && ppd->num_filters && cache)
{
{
char buf[256];
char *ptr,
- *in = NULL,
- *out = NULL,
- *coststr = NULL;
- int cost;
+ *in = NULL,
+ *out = NULL,
+ *coststr = NULL;
+ int cost;
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterUniversal: %s", filter);
- /* String of the "*cupsfilter:" or "*cupsfilter2:" line */
+ // String of the "*cupsfilter:" or "*cupsfilter2:" line
strncpy(buf, filter, sizeof(buf) - 1);
- /* Separate the words */
+ // Separate the words
in = ptr = buf;
while (*ptr && !isspace(*ptr)) ptr ++;
if (!*ptr) goto error;
if (!*ptr) goto error;
cost = atoi(coststr);
- /* Valid "*cupsFilter2: ..." line ... */
- if (/* Must be of lower cost than what we selected before */
+ // Valid "*cupsFilter2: ..." line ...
+ if (// Must be of lower cost than what we selected before
cost < lowest_cost &&
- /* Must have our FINAL_CONTENT_TYPE as output */
+ // Must have our FINAL_CONTENT_TYPE as output
strcasecmp(out, final_output) == 0 &&
- /* Must have as input a format we are able to produce */
+ // Must have as input a format we are able to produce
(strcasecmp(in, "application/vnd.cups-raster") == 0 ||
strcasecmp(in, "application/vnd.cups-pdf") == 0 ||
strcasecmp(in, "application/vnd.cups-postscript") == 0 ||
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterUniversal: --> Selecting this line");
- /* Take the input format of the line as output format for us */
+ // Take the input format of the line as output format for us
strncpy(output, in, sizeof(output));
- /* Update the minimum cost found */
+ // Update the minimum cost found
lowest_cost = cost;
- /* We cannot find a "better" solution ... */
+ // We cannot find a "better" solution ...
if (lowest_cost == 0)
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
if (strstr(output, "postscript"))
{
- /* PostScript output, we need to add libppd's ppdFilterPDFToPS() to
- the end of the chain */
+ // PostScript output, we need to add libppd's ppdFilterPDFToPS() to
+ // the end of the chain
universal_parameters.actual_output_type = "application/vnd.cups-pdf";
extra_filter.function = ppdFilterPDFToPS;
extra_filter.parameters = NULL;
strstr(output, "pdf"))
#endif
{
- /* Classic PDF printer, with job control via JCL/PJL, needs
- libppd's ppdFilterPDFToPDF() filter function which adds PPD's JCL/PJL*/
+ // Classic PDF printer, with job control via JCL/PJL, needs
+ // libppd's ppdFilterPDFToPDF() filter function which adds PPD's JCL/PJL
if (!strncmp(input, "image/", 6) &&
strcmp(input + 6, "urf") && strcmp(input + 6, "pwg-raster"))
- /* Input is an image file: call only ppdFilterImageToPDF() as
- cfFilterImageToPDF() + ppdFilterPDFToPDF() would apply the margins
- twice */
+ // Input is an image file: call only ppdFilterImageToPDF() as
+ // cfFilterImageToPDF() + ppdFilterPDFToPDF() would apply the margins
+ // twice
return ppdFilterImageToPDF(inputfd, outputfd, inputseekable, data, NULL);
else
{
- /* Any other input format: Replace the cfFilterPDFToPDF() call by
- cfFilterUniversal() with a call of ppdFilterPDFToPDF(), so that
- JCL/PJL from the PPD gets added. */
+ // Any other input format: Replace the cfFilterPDFToPDF() call by
+ // cfFilterUniversal() with a call of ppdFilterPDFToPDF(), so that
+ // JCL/PJL from the PPD gets added.
universal_parameters.actual_output_type = "application/pdf";
extra_filter.function = ppdFilterPDFToPDF;
extra_filter.parameters = NULL;
}
}
else
- /* No extra filter needed, cfFilterUniversal() does the job
- correctly with only the filter functions of libcupsfilters */
+ // No extra filter needed, cfFilterUniversal() does the job
+ // correctly with only the filter functions of libcupsfilters
extra_filter.function = NULL;
if (extra_filter.function)
{
- /* Chain cfFilterUniversal() with the extra filter function */
+ // Chain cfFilterUniversal() with the extra filter function
universal_filter.function = cfFilterUniversal;
universal_filter.parameters = &universal_parameters;
universal_filter.name = "universal";
}
-/*
- * 'ppdFilterSetCommonOptions()' - Set common filter options for media size,
- * etc. based on PPD file
- */
+//
+// 'ppdFilterSetCommonOptions()' - Set common filter options for media size,
+// etc. based on PPD file
+//
void
ppdFilterSetCommonOptions(
- ppd_file_t *ppd, /* I - PPD file */
- int num_options, /* I - Number of options */
- cups_option_t *options, /* I - Options */
- int change_size, /* I - Change page size? */
- int *Orientation, /* I/O - Basic page parameters */
+ ppd_file_t *ppd, // I - PPD file
+ int num_options, // I - Number of options
+ cups_option_t *options, // I - Options
+ int change_size, // I - Change page size?
+ int *Orientation, // I/O - Basic page parameters
int *Duplex,
int *LanguageLevel,
int *ColorDevice,
float *PageBottom,
float *PageWidth,
float *PageLength,
- cf_logfunc_t log, /* I - Logging function,
- NULL for no logging */
- void *ld) /* I - User data for logging function,
- can be NULL */
+ cf_logfunc_t log, // I - Logging function,
+ // NULL for no logging
+ void *ld) // I - User data for logging function,
+ // can be NULL
{
- ppd_size_t *pagesize; /* Current page size */
- const char *val; /* Option value */
+ ppd_size_t *pagesize; // Current page size
+ const char *val; // Option value
- *Orientation = 0; /* 0 = portrait, 1 = landscape, etc. */
- *Duplex = 0; /* Duplexed? */
- *LanguageLevel = 1; /* Language level of printer */
- *ColorDevice = 1; /* Color printer? */
- *PageLeft = 18.0f; /* Left margin */
- *PageRight = 594.0f; /* Right margin */
- *PageBottom = 36.0f; /* Bottom margin */
- *PageTop = 756.0f; /* Top margin */
- *PageWidth = 612.0f; /* Total page width */
- *PageLength = 792.0f; /* Total page length */
+ *Orientation = 0; // 0 = portrait, 1 = landscape, etc.
+ *Duplex = 0; // Duplexed?
+ *LanguageLevel = 1; // Language level of printer
+ *ColorDevice = 1; // Color printer?
+ *PageLeft = 18.0f; // Left margin
+ *PageRight = 594.0f; // Right margin
+ *PageBottom = 36.0f; // Bottom margin
+ *PageTop = 756.0f; // Top margin
+ *PageWidth = 612.0f; // Total page width
+ *PageLength = 792.0f; // Total page length
if ((pagesize = ppdPageSize(ppd, NULL)) != NULL)
{
else if ((val = cupsGetOption("orientation-requested",
num_options, options)) != NULL)
{
- /*
- * Map IPP orientation values to 0 to 3:
- *
- * 3 = 0 degrees = 0
- * 4 = 90 degrees = 1
- * 5 = -90 degrees = 3
- * 6 = 180 degrees = 2
- */
+ //
+ // Map IPP orientation values to 0 to 3:
+ //
+ // 3 = 0 degrees = 0
+ // 4 = 90 degrees = 1
+ // 5 = -90 degrees = 3
+ // 6 = 180 degrees = 2
+ //
*Orientation = atoi(val) - 3;
if (*Orientation >= 2)
}
-/*
- * 'ppdFilterUpdatePageVars()' - Update the page variables for the orientation.
- */
+//
+// 'ppdFilterUpdatePageVars()' - Update the page variables for the orientation.
+//
void
ppdFilterUpdatePageVars(int Orientation,
- float *PageLeft, float *PageRight,
- float *PageTop, float *PageBottom,
- float *PageWidth, float *PageLength)
+ float *PageLeft, float *PageRight,
+ float *PageTop, float *PageBottom,
+ float *PageWidth, float *PageLength)
{
- float temp; /* Swapping variable */
+ float temp; // Swapping variable
switch (Orientation & 3)
{
- case 0 : /* Portait */
+ case 0 : // Portait
break;
- case 1 : /* Landscape */
+ case 1 : // Landscape
temp = *PageLeft;
*PageLeft = *PageBottom;
*PageBottom = temp;
*PageLength = temp;
break;
- case 2 : /* Reverse Portrait */
+ case 2 : // Reverse Portrait
temp = *PageWidth - *PageLeft;
*PageLeft = *PageWidth - *PageRight;
*PageRight = temp;
*PageTop = temp;
break;
- case 3 : /* Reverse Landscape */
+ case 3 : // Reverse Landscape
temp = *PageWidth - *PageLeft;
*PageLeft = *PageWidth - *PageRight;
*PageRight = temp;
-/*
- * Filter functions header file for libppd.
- *
- * Copyright © 2020-2022 by Till Kamppeter.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Filter functions API definitions for libppd.
+//
+// Copyright © 2020-2022 by Till Kamppeter.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _PPD_PPD_FILTER_H_
# define _PPD_PPD_FILTER_H_
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
# include <cupsfilters/log.h>
# include <cupsfilters/filter.h>
# else
# include <unistd.h>
# include <fcntl.h>
-# endif /* WIN32 || __EMX__ */
+# endif // WIN32 || __EMX__
# include <cups/cups.h>
# include <cups/raster.h>
# define PPD_FILTER_DATA_EXT "libppd"
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
typedef struct ppd_filter_data_ext_s {
- char *ppdfile; /* PPD file name */
- ppd_file_t *ppd; /* PPD file data */
+ char *ppdfile; // PPD file name
+ ppd_file_t *ppd; // PPD file data
} ppd_filter_data_ext_t;
-typedef struct ppd_filter_external_cups_s { /* Parameters for the
- ppdFilterExternalCUPS() filter
- function */
- const char *filter; /* Path/Name of the CUPS filter to be called by
- this filter function, required */
- int is_backend; /* 0 if we call a filter, 1 if we call a CUPS
- backend, 2 if we call a CUPS backend in
- device discovery mode */
- const char *device_uri; /* Device URI when calling a CUPS Backend for
- processing a job, optional, alternatively
- DEVICE_URI environment variable can get set
- in envp */
- int num_options; /* Extra options for the 5th command line */
- cups_option_t *options; /* argument, options of filter_data have
- priority, 0/NULL if none */
- char **envp; /* Additional environment variables, the already
- defined ones stay valid but can be overwritten
- by these ones, NULL if none */
+typedef struct ppd_filter_external_cups_s { // Parameters for the
+ // ppdFilterExternalCUPS() filter
+ // function
+ const char *filter; // Path/Name of the CUPS filter to be called by
+ // this filter function, required
+ int is_backend; // 0 if we call a filter, 1 if we call a CUPS
+ // backend, 2 if we call a CUPS backend in
+ // device discovery mode
+ const char *device_uri; // Device URI when calling a CUPS Backend for
+ // processing a job, optional, alternatively
+ // DEVICE_URI environment variable can get set
+ // in envp
+ int num_options; // Extra options for the 5th command line
+ cups_option_t *options; // argument, options of filter_data have
+ // priority, 0/NULL if none
+ char **envp; // Additional environment variables, the already
+ // defined ones stay valid but can be overwritten
+ // by these ones, NULL if none
} ppd_filter_external_cups_t;
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
extern int ppdFilterCUPSWrapper(int argc,
char *argv[],
cf_filter_data_t *data,
void *parameters);
-/* Parameters: ppd_filter_external_cups_t*
- Path/Name of the CUPS filter to be called by this filter function,
- specification whether we call a filter or a backend, an in case of
- backend, whether in job processing or discovery mode, extra options
- for the 5th command line argument, and extra environment
- variables */
+// Parameters: ppd_filter_external_cups_t*
+// Path/Name of the CUPS filter to be called by this filter function,
+// specification whether we call a filter or a backend, an in case of
+// backend, whether in job processing or discovery mode, extra options
+// for the 5th command line argument, and extra environment
+// variables
extern int ppdFilterEmitJCL(int inputfd,
cf_filter_data_t *data,
void *parameters);
-/* (Optional) Specification of output format via
- data->final_content_type is used for determining whether this
- filter function does page logging for CUPS (output of "PAGE: XX YY"
- log messages) or not and also to determine whether the printer or
- driver generates copies or whether we have to send the pages
- repeatedly.
-
- Alternatively, the options "pdf-filter-page-logging",
- "hardware-copies", and "hardware-collate" can be used to manually
- do these selections. */
-
+// (Optional) Specification of output format via
+// data->final_content_type is used for determining whether this
+// filter function does page logging for CUPS (output of "PAGE: XX YY"
+// log messages) or not and also to determine whether the printer or
+// driver generates copies or whether we have to send the pages
+// repeatedly.
+//
+// Alternatively, the options "pdf-filter-page-logging",
+// "hardware-copies", and "hardware-collate" can be used to manually
+// do these selections.
extern int ppdFilterPDFToPS(int inputfd,
cf_filter_data_t *data,
void *parameters);
-/* Requires specification of input format via data->content_type and
- job's final output format via data->final_content_type
-
- Parameters: cf_filter_universal_parameter_t
-
- Contains: actual_output_type: Format which the filter should
- actually produce if different from job's final output
- format, or NULL to auto-determine the needed output
- format from the PPDs "cupsFilter2: ..." lines. Default
- is the job's final output format.
- texttopdf_params: parameters for texttopdf */
+// Requires specification of input format via data->content_type and
+// job's final output format via data->final_content_type
+//
+// Parameters: cf_filter_universal_parameter_t
+//
+// Contains: actual_output_type: Format which the filter should
+// actually produce if different from job's final output
+// format, or NULL to auto-determine the needed output
+// format from the PPDs "cupsFilter2: ..." lines. Default
+// is the job's final output format.
+// texttopdf_params: parameters for texttopdf
extern void ppdFilterSetCommonOptions(ppd_file_t *ppd,
# ifdef __cplusplus
}
-# endif /* __cplusplus */
+# endif // __cplusplus
-#endif /* !_PPD_PPD_FILTER_H_ */
+#endif // !_PPD_PPD_FILTER_H_
-/*
- * PWG Raster/Apple Raster/PCLm/PDF/IPP legacy PPD generator
- *
- * Copyright 2016-2019 by Till Kamppeter.
- * Copyright 2017-2019 by Sahil Arora.
- * Copyright 2018-2019 by Deepak Patankar.
- *
- * The PPD generator is based on the PPD generator for the CUPS
- * "lpadmin -m everywhere" functionality in the cups/ppd-cache.c
- * file. The copyright of this file is:
- *
- * Copyright 2010-2016 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.
- */
+//
+// PWG Raster/Apple Raster/PCLm/PDF/IPP legacy PPD generator for libppd.
+//
+// Copyright 2016-2019 by Till Kamppeter.
+// Copyright 2017-2019 by Sahil Arora.
+// Copyright 2018-2019 by Deepak Patankar.
+//
+// The PPD generator is based on the PPD generator for the CUPS
+// "lpadmin -m everywhere" functionality in the cups/ppd-cache.c
+// file. The copyright of this file is:
+//
+// Copyright 2010-2016 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#include <config.h>
#include <limits.h>
#include <cupsfilters/catalog.h>
-/*
- * Include necessary headers.
- */
+//
+// Include necessary headers.
+//
#include <errno.h>
#include <string.h>
#include <cups/pwg.h>
-/*
- * Macros to work around typos in older libcups version
- */
+//
+// Macros to work around typos in older libcups version
+//
#if (CUPS_VERSION_MAJOR < 2) || ((CUPS_VERSION_MAJOR == 2) && ((CUPS_VERSION_MINOR < 3) || ((CUPS_VERSION_MINOR == 3) && (CUPS_VERSION_PATCH < 1))))
#define IPP_FINISHINGS_CUPS_FOLD_ACCORDION IPP_FINISHINGS_CUPS_FOLD_ACCORDIAN
#endif
-/*
- * The code below is borrowed from the CUPS 2.2.x upstream repository
- * (via patches attached to https://www.cups.org/str.php?L4258). This
- * allows for automatic PPD generation already with CUPS versions older
- * than CUPS 2.2.x. We have also an additional test and development
- * platform for this code. Taken from cups/ppd-cache.c,
- * cups/string-private.h, cups/string.c.
- *
- * The advantage of PPD generation instead of working with System V
- * interface scripts is that the print dialogs of the clients do not
- * need to ask the printer for its options via IPP. So we have access
- * to the options with the current PPD-based dialogs and can even share
- * the automatically created print queue to other CUPS-based machines
- * without problems.
- */
+//
+// The code below is borrowed from the CUPS 2.2.x upstream repository
+// (via patches attached to https://www.cups.org/str.php?L4258). This
+// allows for automatic PPD generation already with CUPS versions older
+// than CUPS 2.2.x. We have also an additional test and development
+// platform for this code. Taken from cups/ppd-cache.c,
+// cups/string-private.h, cups/string.c.
+//
+// The advantage of PPD generation instead of working with System V
+// interface scripts is that the print dialogs of the clients do not
+// need to ask the printer for its options via IPP. So we have access
+// to the options with the current PPD-based dialogs and can even share
+// the automatically created print queues to other CUPS-based machines
+// without problems.
+//
char ppdgenerator_msg[1024];
-/*
- * Human-readable strings in the PPDs generated by the PPD generator for
- * using driverless IPP printers with CUPS
- *
- * To allow for translated/localized PPDs we use the standard set
- * of human-readable strings from the PWG:
- *
- * https://ftp.pwg.org/pub/pwg/ipp/examples/ipp.pot
- * https://ftp.pwg.org/pub/pwg/ipp/examples/ipp.strings
- *
- * Creating those with translated human-readable strings would allow us to
- * easily produce PPDs in other languges.
- *
- * Translations are supposed to go here (but none are available yet):
- *
- * https://github.com/istopwg/ippregistry/tree/master/localizations
- *
- * These standard strings are also part of CUPS' translation files:
- *
- * https://github.com/OpenPrinting/cups/tree/master/locale
- *
- * Here translations take actually place as part of the translations
- * of CUPS itself.
- *
- * We take the files from the CUPS installed into the system (as the PPD
- * generator actually does not make sense without CUPS) but currently
- * only use the English version. It is not complicated to check the user
- * language in the printer's IPP response via the
- * attributes-natural-language attribute and then request an appropriate
- * language version of the files if available. The printer-specific
- * strings are downloaded from the printer following the URI in the
- * printer-strings-uri attribute and are in the selected language.
- *
- * It is not clear whether PPD translation will get fixed in the PPD
- * generator as the need of PPDs in CUPS will go away with version
- * 3.x.
- *
- * See also:
- *
- * https://lists.linuxfoundation.org/pipermail/printing-architecture/2021/003992.html
- * https://lists.linuxfoundation.org/pipermail/printing-architecture/2021/003995.html
- */
-
-/*
- * 'ppdCreatePPDFromIPP()' - Create a PPD file describing the capabilities
- * of an IPP printer, using info from DNS-SD record
- * as fallback (for poor IPP responses, especially
- * IPP 1.x legacy)
- */
-
-char * /* O - PPD filename or NULL
- on error */
-ppdCreatePPDFromIPP(char *buffer, /* I - Filename buffer */
- size_t bufsize, /* I - Size of filename
- buffer */
- ipp_t *response, /* I - Get-Printer-Attributes
- response */
- const char *make_model, /* I - Make and model from
- DNS-SD */
- const char *pdl, /* I - List of PDLs from
- DNS-SD */
- int color, /* I - Color printer? (from
- DNS-SD) */
- int duplex, /* I - Duplex printer? (from
- DNS-SD) */
- char *status_msg, /* I - Status message buffer,
- NULL to ignore
- message */
- size_t status_msg_size) /* I - Size of status message
- buffer */
+
+//
+// Human-readable strings in the PPDs generated by the PPD generator for
+// using driverless IPP printers with CUPS
+//
+// To allow for translated/localized PPDs we use the standard set
+// of human-readable strings from the PWG:
+//
+// https://ftp.pwg.org/pub/pwg/ipp/examples/ipp.pot
+// https://ftp.pwg.org/pub/pwg/ipp/examples/ipp.strings
+//
+// Creating those with translated human-readable strings would allow us to
+// easily produce PPDs in other languges.
+//
+// Translations are supposed to go here (but none are available yet):
+//
+// https://github.com/istopwg/ippregistry/tree/master/localizations
+//
+// These standard strings are also part of CUPS' translation files:
+//
+// https://github.com/OpenPrinting/cups/tree/master/locale
+//
+// Here translations take actually place as part of the translations
+// of CUPS itself.
+//
+// We take the files from the CUPS installed into the system (as the PPD
+// generator actually does not make sense without CUPS) but currently
+// only use the English version. It is not complicated to check the user
+// language in the printer's IPP response via the
+// attributes-natural-language attribute and then request an appropriate
+// language version of the files if available. The printer-specific
+// strings are downloaded from the printer following the URI in the
+// printer-strings-uri attribute and are in the selected language.
+//
+// It is not clear whether PPD translation will get fixed in the PPD
+// generator as the need of PPDs in CUPS will go away with version
+// 3.x.
+//
+// See also:
+//
+// https://lists.linuxfoundation.org/pipermail/printing-architecture/2021/003992.html
+// https://lists.linuxfoundation.org/pipermail/printing-architecture/2021/003995.html
+//
+
+
+//
+// 'ppdCreatePPDFromIPP()' - Create a PPD file describing the capabilities
+// of an IPP printer, using info from DNS-SD record
+// as fallback (for poor IPP responses, especially
+// IPP 1.x legacy)
+//
+
+char * // O - PPD filename or NULL
+ // on error
+ppdCreatePPDFromIPP(char *buffer, // I - Filename buffer
+ size_t bufsize, // I - Size of filename
+ // buffer
+ ipp_t *response, // I - Get-Printer-Attributes
+ // response
+ const char *make_model, // I - Make and model from
+ // DNS-SD
+ const char *pdl, // I - List of PDLs from
+ // DNS-SD
+ int color, // I - Color printer? (from
+ // DNS-SD)
+ int duplex, // I - Duplex printer? (from
+ // DNS-SD)
+ char *status_msg, // I - Status message buffer,
+ // NULL to ignore
+ // message
+ size_t status_msg_size) // I - Size of status message
+ // buffer
{
return ppdCreatePPDFromIPP2(buffer, bufsize, response, make_model, pdl,
color, duplex, NULL, NULL, NULL, NULL,
status_msg, status_msg_size);
}
-/*
- * 'ppdCreatePPDFromIPP2()' - Create a PPD file describing the
- * capabilities of an IPP printer, with
- * extra parameters for PPDs from a merged
- * IPP record for printer clusters
- */
-
-char * /* O - PPD filename or NULL
- on error */
-ppdCreatePPDFromIPP2(char *buffer, /* I - Filename buffer */
- size_t bufsize, /* I - Size of filename
- buffer */
- ipp_t *response, /* I - Get-Printer-
- Attributes response*/
- const char *make_model, /* I - Make and model from
- DNS-SD */
- const char *pdl, /* I - List of PDLs from
- DNS-SD */
- int color, /* I - Color printer? (from
- DNS-SD) */
- int duplex, /* I - Duplex printer? (from
- DNS-SD) */
- cups_array_t *conflicts, /* I - Array of
- constraints */
- cups_array_t *sizes, /* I - Media sizes we've
- added */
- char* default_pagesize, /* I - Default page size*/
- const char *default_cluster_color, /* I - cluster def
- color (if cluster's
- attributes are
- returned) */
- char *status_msg, /* I - Status message
- buffer, NULL to
- ignore message */
- size_t status_msg_size) /* I - Size of status
- message buffer */
+//
+// 'ppdCreatePPDFromIPP2()' - Create a PPD file describing the
+// capabilities of an IPP printer, with
+// extra parameters for PPDs from a merged
+// IPP record for printer clusters
+//
+
+char * // O - PPD filename or NULL
+ // on error
+ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer
+ size_t bufsize, // I - Size of filename
+ // buffer
+ ipp_t *response, // I - Get-Printer-
+ // Attributes response
+ const char *make_model, // I - Make and model from
+ // DNS-SD
+ const char *pdl, // I - List of PDLs from
+ // DNS-SD
+ int color, // I - Color printer? (from
+ // DNS-SD)
+ int duplex, // I - Duplex printer? (from
+ // DNS-SD)
+ cups_array_t *conflicts, // I - Array of
+ // constraints
+ cups_array_t *sizes, // I - Media sizes we've
+ // added
+ char* default_pagesize, // I - Default page size
+ const char *default_cluster_color, // I - cluster def
+ // color (if cluster's
+ // attributes are
+ // returned)
+ char *status_msg, // I - Status message
+ // buffer, NULL to
+ // ignore message
+ size_t status_msg_size) // I - Size of status
+ // message buffer
{
- cups_file_t *fp; /* PPD file */
- cups_array_t *printer_sizes; /* Media sizes we've added */
- cups_size_t *size; /* Current media size */
- ipp_attribute_t *attr, /* xxx-supported */
+ cups_file_t *fp; // PPD file
+ cups_array_t *printer_sizes; // Media sizes we've added
+ cups_size_t *size; // Current media size
+ ipp_attribute_t *attr, // xxx-supported
*attr2,
- *defattr, /* xxx-default */
- *quality, /* print-quality-supported */
- *x_dim, *y_dim; /* Media dimensions */
- ipp_t *media_col, /* Media collection */
- *media_size; /* Media size collection */
- char make[256], /* Make and model */
- *model, /* Model name */
+ *defattr, // xxx-default
+ *quality, // print-quality-supported
+ *x_dim, *y_dim; // Media dimensions
+ ipp_t *media_col, // Media collection
+ *media_size; // Media size collection
+ char make[256], // Make and model
+ *model, // Model name
ppdname[PPD_MAX_NAME];
- /* PPD keyword */
- int i, j, /* Looping vars */
- count = 0, /* Number of values */
- bottom, /* Largest bottom margin */
- left, /* Largest left margin */
- right, /* Largest right margin */
- top, /* Largest top margin */
- max_length = 0, /* Maximum custom size */
+ // PPD keyword
+ int i, j, // Looping vars
+ count = 0, // Number of values
+ bottom, // Largest bottom margin
+ left, // Largest left margin
+ right, // Largest right margin
+ top, // Largest top margin
+ max_length = 0, // Maximum custom size
max_width = 0,
min_length = INT_MAX,
- /* Minimum custom size */
+ // Minimum custom size
min_width = INT_MAX,
- is_apple = 0, /* Does the printer support Apple
- Raster? */
- is_pwg = 0, /* Does the printer support PWG
- Raster? */
- is_pclm = 0, /* Does the printer support PCLm? */
- is_pdf = 0; /* Does the printer support PDF? */
- pwg_media_t *pwg; /* PWG media size */
- int xres, yres; /* Resolution values */
- cups_array_t *common_res, /* Common resolutions of all PDLs */
- *current_res, /* Resolutions of current PDL */
- *pdl_list; /* List of PDLs */
- cf_res_t *common_def, /* Common default resolution */
- *current_def, /* Default resolution of current PDL */
- *min_res, /* Minimum common resolution */
- *max_res; /* Maximum common resolution */
+ is_apple = 0, // Does the printer support Apple
+ // Raster?
+ is_pwg = 0, // Does the printer support PWG
+ // Raster?
+ is_pclm = 0, // Does the printer support PCLm?
+ is_pdf = 0; // Does the printer support PDF?
+ pwg_media_t *pwg; // PWG media size
+ int xres, yres; // Resolution values
+ cups_array_t *common_res, // Common resolutions of all PDLs
+ *current_res, // Resolutions of current PDL
+ *pdl_list; // List of PDLs
+ cf_res_t *common_def, // Common default resolution
+ *current_def, // Default resolution of current PDL
+ *min_res, // Minimum common resolution
+ *max_res; // Maximum common resolution
struct lconv *loc = localeconv();
- /* Locale data */
+ // Locale data
cups_array_t *opt_strings_catalog = NULL;
- /* Standard option UI strings */
+ // Standard option UI strings
cups_array_t *printer_opt_strings_catalog = NULL;
- /* Printer-specific option UI strings */
+ // Printer-specific option UI strings
char *human_readable,
*human_readable2;
- const char *keyword; /* Keyword value */
+ const char *keyword; // Keyword value
cups_array_t *fin_options = NULL;
- /* Finishing options */
+ // Finishing options
char buf[256];
char *defaultoutbin = NULL;
const char *outbin;
int manual_copies = -1,
is_fax = 0;
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (buffer)
*buffer = '\0';
- if (!buffer || bufsize < 1) {
+ if (!buffer || bufsize < 1)
+ {
if (status_msg && status_msg_size)
snprintf(status_msg, status_msg_size, "%s", strerror(EINVAL));
return (NULL);
}
- if (!response) {
+ if (!response)
+ {
if (status_msg && status_msg_size)
snprintf(status_msg, status_msg_size, "No IPP attributes.");
return (NULL);
}
- /*
- * Open a temporary file for the PPD...
- */
+ //
+ // Open a temporary file for the PPD...
+ //
- if ((fp = cupsTempFile2(buffer, (int)bufsize)) == NULL) {
+ if ((fp = cupsTempFile2(buffer, (int)bufsize)) == NULL)
+ {
if (status_msg && status_msg_size)
snprintf(status_msg, status_msg_size, "%s", strerror(errno));
return (NULL);
}
- /*
- * Standard stuff for PPD file...
- */
+ //
+ // Standard stuff for PPD file...
+ //
cupsFilePuts(fp, "*PPD-Adobe: \"4.3\"\n");
cupsFilePuts(fp, "*FormatVersion: \"4.3\"\n");
strlcpy(make, "Unknown Printer", sizeof(make));
if (!strncasecmp(make, "Hewlett Packard ", 16) ||
- !strncasecmp(make, "Hewlett-Packard ", 16)) {
+ !strncasecmp(make, "Hewlett-Packard ", 16))
+ {
model = make + 16;
strlcpy(make, "HP", sizeof(make));
}
make, model, (is_fax ? "Fax, " : ""), VERSION);
cupsFilePrintf(fp, "*ShortNickName: \"%s %s\"\n", make, model);
- /* Which is the default output bin? */
+ // Which is the default output bin?
if ((attr = ippFindAttribute(response, "output-bin-default", IPP_TAG_ZERO))
!= NULL)
defaultoutbin = strdup(ippGetString(attr, 0, NULL));
- /* Find out on which position of the list of output bins the default one is,
- if there is no default bin, take the first of this list */
+ // Find out on which position of the list of output bins the default one is,
+ // if there is no default bin, take the first of this list
i = 0;
if ((attr = ippFindAttribute(response, "output-bin-supported",
- IPP_TAG_ZERO)) != NULL) {
+ IPP_TAG_ZERO)) != NULL)
+ {
count = ippGetCount(attr);
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
outbin = ippGetString(attr, i, NULL);
if (outbin == NULL)
continue;
- if (defaultoutbin == NULL) {
+ if (defaultoutbin == NULL)
+ {
defaultoutbin = strdup(outbin);
break;
} else if (strcasecmp(outbin, defaultoutbin) == 0)
}
if ((attr = ippFindAttribute(response, "printer-output-tray",
IPP_TAG_STRING)) != NULL &&
- i < ippGetCount(attr)) {
+ i < ippGetCount(attr))
+ {
outbin_properties_octet = ippGetOctetString(attr, i, &octet_str_len);
memset(outbin_properties, 0, sizeof(outbin_properties));
memcpy(outbin_properties, outbin_properties_octet,
((size_t)octet_str_len < sizeof(outbin_properties) - 1 ?
(size_t)octet_str_len : sizeof(outbin_properties) - 1));
- if (strcasestr(outbin_properties, "pagedelivery=faceUp")) {
+ if (strcasestr(outbin_properties, "pagedelivery=faceUp"))
+ {
outputorderinfofound = 1;
faceupdown = -1;
}
else
cupsFilePuts(fp, "*DefaultOutputOrder: Normal\n");
- /* Do we have a color printer? */
+ // Do we have a color printer?
if (((attr = ippFindAttribute(response,
"color-supported", IPP_TAG_BOOLEAN)) != NULL &&
ippGetBoolean(attr, 0)) ||
cupsFilePrintf(fp, "*cupsChargeInfoURI: \"%s\"\n", ippGetString(attr, 0,
NULL));
- /* Message catalogs for UI strings */
+ // Message catalogs for UI strings
opt_strings_catalog = cfCatalogOptionArrayNew();
cfCatalogLoad(NULL, opt_strings_catalog);
if ((attr = ippFindAttribute(response, "printer-strings-uri",
- IPP_TAG_URI)) != NULL) {
+ IPP_TAG_URI)) != NULL)
+ {
printer_opt_strings_catalog = cfCatalogOptionArrayNew();
cfCatalogLoad(ippGetString(attr, 0, NULL),
printer_opt_strings_catalog);
NULL));
}
- /*
- * Accounting...
- */
+ //
+ // Accounting...
+ //
if (ippGetBoolean(ippFindAttribute(response, "job-account-id-supported",
IPP_TAG_BOOLEAN), 0))
IPP_TAG_BOOLEAN), 0))
cupsFilePuts(fp, "*cupsJobAccountingUserId: True\n");
- if ((attr = ippFindAttribute(response, "printer-privacy-policy-uri", IPP_TAG_URI)) != NULL)
- cupsFilePrintf(fp, "*cupsPrivacyURI: \"%s\"\n", ippGetString(attr, 0, NULL));
+ if ((attr = ippFindAttribute(response, "printer-privacy-policy-uri",
+ IPP_TAG_URI)) != NULL)
+ cupsFilePrintf(fp, "*cupsPrivacyURI: \"%s\"\n",
+ ippGetString(attr, 0, NULL));
- if ((attr = ippFindAttribute(response, "printer-mandatory-job-attributes", IPP_TAG_KEYWORD)) != NULL)
+ if ((attr = ippFindAttribute(response, "printer-mandatory-job-attributes",
+ IPP_TAG_KEYWORD)) != NULL)
{
char prefix = '\"'; // Prefix for string
{
keyword = ippGetString(attr, i, NULL);
- if (strcmp(keyword, "attributes-charset") && strcmp(keyword, "attributes-natural-language") && strcmp(keyword, "printer-uri"))
+ if (strcmp(keyword, "attributes-charset") &&
+ strcmp(keyword, "attributes-natural-language") &&
+ strcmp(keyword, "printer-uri"))
{
cupsFilePrintf(fp, "%c%s", prefix, keyword);
prefix = ',';
cupsFilePuts(fp, "\"\n");
}
- if ((attr = ippFindAttribute(response, "printer-requested-job-attributes", IPP_TAG_KEYWORD)) != NULL)
+ if ((attr = ippFindAttribute(response, "printer-requested-job-attributes",
+ IPP_TAG_KEYWORD)) != NULL)
{
char prefix = '\"'; // Prefix for string
{
keyword = ippGetString(attr, i, NULL);
- if (strcmp(keyword, "attributes-charset") && strcmp(keyword, "attributes-natural-language") && strcmp(keyword, "printer-uri"))
+ if (strcmp(keyword, "attributes-charset") &&
+ strcmp(keyword, "attributes-natural-language") &&
+ strcmp(keyword, "printer-uri"))
{
cupsFilePrintf(fp, "%c%s", prefix, keyword);
prefix = ',';
cupsFilePuts(fp, "\"\n");
}
- /*
- * Password/PIN printing...
- */
+ //
+ // Password/PIN printing...
+ //
if ((attr = ippFindAttribute(response, "job-password-supported",
- IPP_TAG_INTEGER)) != NULL) {
- char pattern[33]; /* Password pattern */
+ IPP_TAG_INTEGER)) != NULL)
+ {
+ char pattern[33]; // Password pattern
int maxlen = ippGetInteger(attr, 0);
- /* Maximum length */
+ // Maximum length
const char *repertoire =
ippGetString(ippFindAttribute(response,
"job-password-repertoire-configured",
IPP_TAG_KEYWORD), 0, NULL);
- /* Type of password */
+ // Type of password
if (maxlen > (int)(sizeof(pattern) - 1))
maxlen = (int)sizeof(pattern) - 1;
cupsFilePrintf(fp, "*cupsJobPassword: \"%s\"\n", pattern);
}
-
-
- /*
- * PDLs and common resolutions ...
- */
+ //
+ // PDLs and common resolutions ...
+ //
common_res = NULL;
current_res = NULL;
current_def = NULL;
min_res = NULL;
max_res = NULL;
- /* Put all available PDls into a simple case-insensitevely searchable
- sorted string list */
+ // Put all available PDls into a simple case-insensitevely searchable
+ // sorted string list
if ((pdl_list = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
(cups_acopy_func_t)strdup,
(cups_afree_func_t)free)) == NULL)
if (((attr = ippFindAttribute(response, "document-format-supported",
IPP_TAG_MIMETYPE)) != NULL) ||
- (pdl && pdl[0] != '\0')) {
+ (pdl && pdl[0] != '\0'))
+ {
const char *format = pdl;
i = 0;
count = ippGetCount(attr);
- while ((attr && i < count) || /* Go through formats in attribute */
- (!attr && pdl && pdl[0] != '\0' && format[0] != '\0')) {
- /* Go through formats in pdl string (from DNS-SD record) */
+ while ((attr && i < count) || // Go through formats in attribute
+ (!attr && pdl && pdl[0] != '\0' && format[0] != '\0'))
+ {
+ // Go through formats in pdl string (from DNS-SD record)
- /* Pick next format from attribute */
+ // Pick next format from attribute
if (attr) format = ippGetString(attr, i, NULL);
- /* Add format to list of supported PDLs, skip duplicates */
+ // Add format to list of supported PDLs, skip duplicates
if (!cupsArrayFind(pdl_list, (void *)format))
cupsArrayAdd(pdl_list, (void *)format);
if (attr)
- /* Next format in attribute */
+ // Next format in attribute
i ++;
else {
- /* Find the next format in the string pdl, if there is none left,
- go to the terminating zero */
+ // Find the next format in the string pdl, if there is none left,
+ // go to the terminating zero
while (!isspace(*format) && *format != ',' && *format != '\0')
format ++;
while ((isspace(*format) || *format == ',') && *format != '\0')
}
}
- /*
- * Fax
- */
+ //
+ // Fax
+ //
if (is_fax)
{
cupsFilePuts(fp, "*cupsIPPFaxOut: True\n");
}
- /* Check for each CUPS/cups-filters-supported PDL, starting with the
- most desirable going to the least desirable. If a PDL requires a
- certain set of resolutions (the raster-based PDLs), find the
- resolutions and find out which are the common resolutions of all
- supported PDLs. Choose the default resolution from the most
- desirable of all resolution-requiring PDLs if it is common in all
- of them. Skip a resolution-requiring PDL if its resolution list
- attribute is missing or contains only broken entries. Use the
- general resolution list and default resolution of the printer
- only if it does not support any resolution-requiring PDL. Use 300
- dpi if there is no resolution info at all in the attributes.
- In case of PDF as PDL check whether also the
- "application/vnd.cups-pdf" MIME type is accepted. In this case
- our printer is a remote CUPS queue which already runs the
- pdftopdf filter on the server, so let the PPD take
- "application/pdf" as input format so that pdftopdf does not also
- get executed on the client, applying option settings twice. See
- https://github.com/apple/cups/issues/5361 */
+ //
+ // Check for each CUPS/cups-filters-supported PDL, starting with the
+ // most desirable going to the least desirable. If a PDL requires a
+ // certain set of resolutions (the raster-based PDLs), find the
+ // resolutions and find out which are the common resolutions of all
+ // supported PDLs. Choose the default resolution from the most
+ // desirable of all resolution-requiring PDLs if it is common in all
+ // of them. Skip a resolution-requiring PDL if its resolution list
+ // attribute is missing or contains only broken entries. Use the
+ // general resolution list and default resolution of the printer
+ // only if it does not support any resolution-requiring PDL. Use 300
+ // dpi if there is no resolution info at all in the attributes.
+ // In case of PDF as PDL check whether also the
+ // "application/vnd.cups-pdf" MIME type is accepted. In this case
+ // our printer is a remote CUPS queue which already runs the
+ // pdftopdf filter on the server, so let the PPD take
+ // "application/pdf" as input format so that pdftopdf does not also
+ // get executed on the client, applying option settings twice. See
+ // https://github.com/apple/cups/issues/5361
+ //
+
if (cupsArrayFind(pdl_list, "application/vnd.cups-pdf"))
{
- /* Remote CUPS queue */
+ // Remote CUPS queue
cupsFilePuts(fp, "*cupsFilter2: \"application/pdf application/pdf 0 -\"\n");
manual_copies = 0;
formatfound = 1;
else if (cupsArrayFind(pdl_list, "image/urf"))
{
if ((attr = ippFindAttribute(response, "urf-supported",
- IPP_TAG_KEYWORD)) != NULL) {
- int lowdpi = 0, hidpi = 0; /* Lower and higher resolution */
- for (i = 0, count = ippGetCount(attr); i < count; i ++) {
- const char *rs = ippGetString(attr, i, NULL); /* RS value */
+ IPP_TAG_KEYWORD)) != NULL)
+ {
+ int lowdpi = 0, hidpi = 0; // Lower and higher resolution
+ for (i = 0, count = ippGetCount(attr); i < count; i ++)
+ {
+ const char *rs = ippGetString(attr, i, NULL); // RS value
if (strncasecmp(rs, "RS", 2))
continue;
lowdpi = atoi(rs + 2);
hidpi = lowdpi;
break;
}
- if (lowdpi == 0) {
- /* Invalid "urf-supported" value... */
+ if (lowdpi == 0)
+ {
+ // Invalid "urf-supported" value...
goto bad_ppd;
- } else {
- if ((current_res = cfNewResolutionArray()) != NULL) {
+ }
+ else
+ {
+ if ((current_res = cfNewResolutionArray()) != NULL)
+ {
if ((current_def = cfNewResolution(lowdpi, lowdpi)) != NULL)
{
cupsArrayAdd(current_res, current_def);
#endif
else if (cupsArrayFind(pdl_list, "application/pdf"))
{
- /* PDF printer */
+ // PDF printer
cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-pdf application/pdf 0 -\"\n");
manual_copies = 0;
formatfound = 1;
{
if ((attr = ippFindAttribute(response,
"pwg-raster-document-resolution-supported",
- IPP_TAG_RESOLUTION)) != NULL) {
+ IPP_TAG_RESOLUTION)) != NULL)
+ {
current_def = NULL;
if ((current_res = cfIPPAttrToResolutionArray(attr)) != NULL &&
cfJoinResolutionArrays(&common_res, ¤t_res, &common_def,
- ¤t_def)) {
+ ¤t_def))
+ {
cupsFilePuts(fp, "*cupsFilter2: \"image/pwg-raster image/pwg-raster 0 -\"\n");
if (formatfound == 0) manual_copies = 1;
formatfound = 1;
else if (cupsArrayFind(pdl_list, "application/PCLm"))
{
if ((attr = ippFindAttribute(response, "pclm-source-resolution-supported",
- IPP_TAG_RESOLUTION)) != NULL) {
+ IPP_TAG_RESOLUTION)) != NULL)
+ {
if ((defattr = ippFindAttribute(response,
"pclm-source-resolution-default",
IPP_TAG_RESOLUTION)) != NULL)
current_def = NULL;
if ((current_res = cfIPPAttrToResolutionArray(attr)) != NULL &&
cfJoinResolutionArrays(&common_res, ¤t_res, &common_def,
- ¤t_def)) {
+ ¤t_def))
+ {
cupsFilePuts(fp, "*cupsFilter2: \"application/PCLm application/PCLm 0 -\"\n");
if (formatfound == 0) manual_copies = 1;
formatfound = 1;
}
}
}
- /* Legacy formats only if we have no driverless format */
+ // Legacy formats only if we have no driverless format
else if (cupsArrayFind(pdl_list, "application/vnd.hp-pclxl"))
{
cupsFilePrintf(fp, "*cupsFilter2: \"application/vnd.cups-pdf application/vnd.hp-pclxl 100 gstopxl\"\n");
- if (formatfound == 0) manual_copies = 1;
+ if (formatfound == 0)
+ manual_copies = 1;
formatfound = 1;
}
else if (cupsArrayFind(pdl_list, "application/postscript"))
{
- /* Higher cost value as PostScript interpreters are often buggy */
+ // Higher cost value as PostScript interpreters are often buggy
cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-postscript application/postscript 0 -\"\n");
- if (formatfound == 0) manual_copies = 0;
+ if (formatfound == 0)
+ manual_copies = 0;
formatfound = 1;
}
else if (cupsArrayFind(pdl_list, "application/vnd.hp-pcl"))
{
cupsFilePrintf(fp, "*cupsFilter2: \"application/vnd.cups-raster application/vnd.hp-pcl 100 rastertopclx\"\n");
- if (formatfound == 0) manual_copies = 1;
+ if (formatfound == 0)
+ manual_copies = 1;
formatfound = 1;
}
if (cupsArrayFind(pdl_list, "image/jpeg"))
if (cupsArrayFind(pdl_list, "image/png"))
cupsFilePuts(fp, "*cupsFilter2: \"image/png image/png 0 -\"\n");
cupsArrayDelete(pdl_list);
- if (manual_copies < 0) manual_copies = 1;
+ if (manual_copies < 0)
+ manual_copies = 1;
if (formatfound == 0)
goto bad_ppd;
- /* For the case that we will print in a raster format and not in a high-level
- format, we need to create multiple copies on the client. We add a line to
- the PPD which tells the pdftopdf filter to generate the copies */
+ // For the case that we will print in a raster format and not in a high-level
+ // format, we need to create multiple copies on the client. We add a line to
+ // the PPD which tells the pdftopdf filter to generate the copies
if (manual_copies == 1)
cupsFilePuts(fp, "*cupsManualCopies: True\n");
- /* No resolution requirements by any of the supported PDLs?
- Use "printer-resolution-supported" attribute */
- if (common_res == NULL) {
+ // No resolution requirements by any of the supported PDLs?
+ // Use "printer-resolution-supported" attribute
+ if (common_res == NULL)
+ {
if ((attr = ippFindAttribute(response, "printer-resolution-supported",
- IPP_TAG_RESOLUTION)) != NULL) {
+ IPP_TAG_RESOLUTION)) != NULL)
+ {
if ((defattr = ippFindAttribute(response, "printer-resolution-default",
IPP_TAG_RESOLUTION)) != NULL)
current_def = cfIPPResToResolution(defattr, 0);
¤t_def);
}
}
- /* Still no resolution found? Default to 300 dpi */
- if (common_res == NULL) {
- if ((common_res = cfNewResolutionArray()) != NULL) {
+ // Still no resolution found? Default to 300 dpi
+ if (common_res == NULL)
+ {
+ if ((common_res = cfNewResolutionArray()) != NULL)
+ {
if ((current_def = cfNewResolution(300, 300)) != NULL)
{
cupsArrayAdd(common_res, current_def);
} else
goto bad_ppd;
}
- /* No default resolution determined yet */
- if (common_def == NULL) {
+ // No default resolution determined yet
+ if (common_def == NULL)
+ {
if ((defattr = ippFindAttribute(response, "printer-resolution-default",
- IPP_TAG_RESOLUTION)) != NULL) {
+ IPP_TAG_RESOLUTION)) != NULL)
+ {
common_def = cfIPPResToResolution(defattr, 0);
- if (!cupsArrayFind(common_res, common_def)) {
+ if (!cupsArrayFind(common_res, common_def))
+ {
free(common_def);
common_def = NULL;
}
}
if (common_def == NULL) {
count = cupsArrayCount(common_res);
- common_def = cfCopyResolution(cupsArrayIndex(common_res, count / 2), NULL);
+ common_def =
+ cfCopyResolution(cupsArrayIndex(common_res, count / 2), NULL);
}
}
- /* Get minimum and maximum resolution */
+ // Get minimum and maximum resolution
min_res = cfCopyResolution(cupsArrayFirst(common_res), NULL);
max_res = cfCopyResolution(cupsArrayLast(common_res), NULL);
cupsArrayDelete(common_res);
- /*
- * Generically check for Raster-format-related attributes in IPP
- * response and ppdize them one by one
- */
+ //
+ // Generically check for Raster-format-related attributes in IPP
+ // response and ppdize them one by one
+ //
- attr = ippFirstAttribute(response); /* first attribute */
- while (attr) { /* loop through all the attributes */
+ attr = ippFirstAttribute(response); // first attribute
+ while (attr) // loop through all the attributes
+ {
if ((is_apple && strncasecmp(ippGetName(attr), "urf-", 4) == 0) ||
- (is_pwg && strncasecmp(ippGetName(attr), "pwg-raster-", 11) == 0)
- || (is_pclm && strncasecmp(ippGetName(attr), "pclm-", 5) == 0)
- ) {
+ (is_pwg && strncasecmp(ippGetName(attr), "pwg-raster-", 11) == 0) ||
+ (is_pclm && strncasecmp(ippGetName(attr), "pclm-", 5) == 0))
+ {
ppdPwgPpdizeName(ippGetName(attr), ppdname, sizeof(ppdname));
cupsFilePrintf(fp, "*cups%s: ", ppdname);
ipp_tag_t tag = ippGetValueTag(attr);
count = ippGetCount(attr);
- if (tag == IPP_TAG_RESOLUTION) { /* ppdize values of type resolution */
- if ((current_res = cfIPPAttrToResolutionArray(attr)) != NULL) {
+ if (tag == IPP_TAG_RESOLUTION) // ppdize values of type resolution
+ {
+ if ((current_res = cfIPPAttrToResolutionArray(attr)) != NULL)
+ {
count = cupsArrayCount(current_res);
if (count > 1)
cupsFilePuts(fp, "\"");
for (i = 0, current_def = cupsArrayFirst(current_res);
current_def;
- i ++, current_def = cupsArrayNext(current_res)) {
+ i ++, current_def = cupsArrayNext(current_res))
+ {
int x = current_def->x;
int y = current_def->y;
if (x == y)
} else
cupsFilePuts(fp, "\"\"\n");
cupsArrayDelete(current_res);
- } else {
+ }
+ else
+ {
ippAttributeString(attr, buf, sizeof(buf));
- if (count > 1 || /* quotes around multi-valued and string
- attributes */
+ if (count > 1 || // quotes around multi-valued and string
+ // attributes
tag == IPP_TAG_STRING ||
tag == IPP_TAG_TEXT ||
tag == IPP_TAG_TEXTLANG)
attr = ippNextAttribute(response);
}
- /*
- * PageSize/PageRegion/ImageableArea/PaperDimension
- */
+ //
+ // PageSize/PageRegion/ImageableArea/PaperDimension
+ //
+
cfGenerateSizes(response, CF_GEN_SIZES_DEFAULT, &printer_sizes, &defattr,
NULL, NULL, NULL, NULL, NULL, NULL,
&min_width, &min_length,
&max_width, &max_length,
&left, &bottom, &right, &top, ppdname, NULL);
- if (sizes==NULL) {
+ if (sizes == NULL)
sizes = printer_sizes;
- } else
+ else
strcpy(ppdname, default_pagesize);
- if (cupsArrayCount(sizes) > 0) {
- /*
- * List all of the standard sizes...
- */
-
- char tleft[256], /* Left string */
- tbottom[256], /* Bottom string */
- tright[256], /* Right string */
- ttop[256], /* Top string */
- twidth[256], /* Width string */
- tlength[256], /* Length string */
+ if (cupsArrayCount(sizes) > 0)
+ {
+ //
+ // List all of the standard sizes...
+ //
+
+ char tleft[256], // Left string
+ tbottom[256], // Bottom string
+ tright[256], // Right string
+ ttop[256], // Top string
+ twidth[256], // Width string
+ tlength[256], // Length string
ppdsizename[128];
char *ippsizename,
*suffix;
int all_borderless = 1;
- /* Find a page size without ".Borderless" suffix */
- /* (if all are ".Borderless" we drop the suffix in the PPD) */
+ // Find a page size without ".Borderless" suffix
+ // (if all are ".Borderless" we drop the suffix in the PPD)
for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
size = (cups_size_t *)cupsArrayNext(sizes))
if (strcasestr(size->media, ".Borderless") == NULL)
if (size)
all_borderless = 0;
- if (all_borderless) {
+ if (all_borderless)
+ {
suffix = strcasestr(ppdname, ".Borderless");
if (suffix)
*suffix = '\0';
"*OrderDependency: 10 AnySetup *PageSize\n"
"*DefaultPageSize: %s\n", "Media Size", ppdname);
for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
- size = (cups_size_t *)cupsArrayNext(sizes)) {
+ size = (cups_size_t *)cupsArrayNext(sizes))
+ {
cfStrFormatd(twidth, twidth + sizeof(twidth),
size->width * 72.0 / 2540.0, loc);
cfStrFormatd(tlength, tlength + sizeof(tlength),
size->length * 72.0 / 2540.0, loc);
strlcpy(ppdsizename, size->media, sizeof(ppdsizename));
- if ((ippsizename = strchr(ppdsizename, ' ')) != NULL) {
+ if ((ippsizename = strchr(ppdsizename, ' ')) != NULL)
+ {
*ippsizename = '\0';
ippsizename ++;
}
printer_opt_strings_catalog);
else
human_readable = NULL;
- if (!human_readable) {
+ if (!human_readable)
+ {
pwg = pwgMediaForSize(size->width, size->length);
if (pwg)
human_readable = cfCatalogLookUpChoice((char *)pwg->pwg, "media",
printer_opt_strings_catalog);
}
- if (all_borderless) {
+ if (all_borderless)
+ {
suffix = strcasestr(ppdsizename, ".Borderless");
if (suffix)
*suffix = '\0';
"*OrderDependency: 10 AnySetup *PageRegion\n"
"*DefaultPageRegion: %s\n", "Media Size", ppdname);
for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
- size = (cups_size_t *)cupsArrayNext(sizes)) {
+ size = (cups_size_t *)cupsArrayNext(sizes))
+ {
cfStrFormatd(twidth, twidth + sizeof(twidth),
size->width * 72.0 / 2540.0, loc);
cfStrFormatd(tlength, tlength + sizeof(tlength),
size->length * 72.0 / 2540.0, loc);
strlcpy(ppdsizename, size->media, sizeof(ppdsizename));
- if ((ippsizename = strchr(ppdsizename, ' ')) != NULL) {
+ if ((ippsizename = strchr(ppdsizename, ' ')) != NULL)
+ {
*ippsizename = '\0';
ippsizename ++;
}
printer_opt_strings_catalog);
else
human_readable = NULL;
- if (!human_readable) {
+ if (!human_readable)
+ {
pwg = pwgMediaForSize(size->width, size->length);
if (pwg)
human_readable = cfCatalogLookUpChoice((char *)pwg->pwg, "media",
printer_opt_strings_catalog);
}
- if (all_borderless) {
+ if (all_borderless)
+ {
suffix = strcasestr(ppdsizename, ".Borderless");
if (suffix)
*suffix = '\0';
"*DefaultPaperDimension: %s\n", ppdname, ppdname);
for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
- size = (cups_size_t *)cupsArrayNext(sizes)) {
+ size = (cups_size_t *)cupsArrayNext(sizes))
+ {
cfStrFormatd(tleft, tleft + sizeof(tleft),
size->left * 72.0 / 2540.0, loc);
cfStrFormatd(tbottom, tbottom + sizeof(tbottom),
if ((ippsizename = strchr(ppdsizename, ' ')) != NULL)
*ippsizename = '\0';
- if (all_borderless) {
+ if (all_borderless)
+ {
suffix = strcasestr(ppdsizename, ".Borderless");
if (suffix)
*suffix = '\0';
twidth, tlength);
}
- /*
- * Custom size support...
- */
+ //
+ // Custom size support...
+ //
if (max_width > 0 && min_width < INT_MAX && max_length > 0 &&
- min_length < INT_MAX) {
- char tmax[256], tmin[256]; /* Min/max values */
+ min_length < INT_MAX)
+ {
+ char tmax[256], tmin[256]; // Min/max values
cfStrFormatd(tleft, tleft + sizeof(tleft), left * 72.0 / 2540.0, loc);
cfStrFormatd(tbottom, tbottom + sizeof(tbottom),
- bottom * 72.0 / 2540.0, loc);
+ bottom * 72.0 / 2540.0, loc);
cfStrFormatd(tright, tright + sizeof(tright), right * 72.0 / 2540.0,
- loc);
+ loc);
cfStrFormatd(ttop, ttop + sizeof(ttop), top * 72.0 / 2540.0, loc);
cupsFilePrintf(fp, "*HWMargins: \"%s %s %s %s\"\n", tleft, tbottom,
tright, ttop);
cfStrFormatd(tmax, tmax + sizeof(tmax), max_width * 72.0 / 2540.0,
- loc);
+ loc);
cfStrFormatd(tmin, tmin + sizeof(tmin), min_width * 72.0 / 2540.0,
- loc);
+ loc);
cupsFilePrintf(fp, "*ParamCustomPageSize Width: 1 points %s %s\n", tmin,
tmax);
cfStrFormatd(tmax, tmax + sizeof(tmax), max_length * 72.0 / 2540.0,
- loc);
+ loc);
cfStrFormatd(tmin, tmin + sizeof(tmin), min_length * 72.0 / 2540.0,
- loc);
+ loc);
cupsFilePrintf(fp, "*ParamCustomPageSize Height: 2 points %s %s\n", tmin,
tmax);
cupsFilePuts(fp, "*ParamCustomPageSize Orientation: 5 int 0 3\n");
cupsFilePuts(fp, "*CustomPageSize True: \"pop pop pop <</PageSize[5 -2 roll]/ImagingBBox null>>setpagedevice\"\n");
}
- } else {
+ }
+ else
+ {
cupsFilePrintf(fp,
"*%% Printer did not supply page size info via IPP, using defaults\n"
"*OpenUI *PageSize/Media Size: PickOne\n"
cupsArrayDelete(printer_sizes);
- /*
- * InputSlot...
- */
+ //
+ // InputSlot...
+ //
if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source",
IPP_TAG_KEYWORD)) != NULL)
if ((attr = ippFindAttribute(response, "media-source-supported",
IPP_TAG_KEYWORD)) != NULL &&
- (count = ippGetCount(attr)) > 1) {
+ (count = ippGetCount(attr)) > 1)
+ {
int have_default = ppdname[0] != '\0';
- /* Do we have a default InputSlot? */
+ // Do we have a default InputSlot?
static const char * const sources[] =
- { /* Standard "media-source" strings */
+ { // Standard "media-source" strings
"auto",
"main",
"alternate",
(human_readable ? human_readable : "Media Source"));
if (have_default)
cupsFilePrintf(fp, "*DefaultInputSlot: %s\n", ppdname);
- for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++)
+ {
keyword = ippGetString(attr, i, NULL);
ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname));
cupsFilePuts(fp, "*CloseUI: *InputSlot\n");
}
- /*
- * MediaType...
- */
+ //
+ // MediaType...
+ //
if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-type",
IPP_TAG_ZERO)) != NULL)
if ((attr = ippFindAttribute(response, "media-type-supported",
IPP_TAG_ZERO)) != NULL &&
- (count = ippGetCount(attr)) > 1) {
+ (count = ippGetCount(attr)) > 1)
+ {
human_readable = cfCatalogLookUpOption("media-type", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *MediaType/%s: PickOne\n"
"*DefaultMediaType: %s\n",
(human_readable ? human_readable : "Media Type"),
ppdname);
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
keyword = ippGetString(attr, i, NULL);
ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname));
cupsFilePuts(fp, "*CloseUI: *MediaType\n");
}
- /*
- * ColorModel...
- */
+ //
+ // ColorModel...
+ //
+
if ((defattr = ippFindAttribute(response, "print-color-mode-default",
IPP_TAG_KEYWORD)) == NULL)
defattr = ippFindAttribute(response, "output-mode-default",
human_readable = cfCatalogLookUpOption("print-color-mode",
opt_strings_catalog,
printer_opt_strings_catalog);
- if (attr && ippGetCount(attr) > 0) {
- const char *default_color = NULL; /* Default */
+ if (attr && ippGetCount(attr) > 0)
+ {
+ const char *default_color = NULL; // Default
int first_choice = 1;
if ((keyword = ippGetString(defattr, 0, NULL)) != NULL)
cupsFilePrintf(fp, "*%% ColorModel from %s\n", ippGetName(attr));
- for (i = 0, count = ippGetCount(attr); i < count; i ++) {
- keyword = ippGetString(attr, i, NULL); /* Keyword for color/bit depth */
+ for (i = 0, count = ippGetCount(attr); i < count; i ++)
+ {
+ keyword = ippGetString(attr, i, NULL); // Keyword for color/bit depth
- if (!strcmp(keyword, "bi-level")) {
- if (first_choice) {
+ if (!strcmp(keyword, "bi-level"))
+ {
+ if (first_choice)
+ {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *ColorModel\n",
if (!default_color)
default_color = "FastGray";
- } else if (!strcmp(keyword, "process-bi-level")) {
- if (first_choice) {
+ }
+ else if (!strcmp(keyword, "process-bi-level"))
+ {
+ if (first_choice)
+ {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *ColorModel\n",
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*ColorModel ProcessFastGray/%s: \"\"\n",
(human_readable2 ? human_readable2 : "Process Text"));
- } else if (!strcmp(keyword, "auto-monochrome")) {
- if (first_choice) {
+ }
+ else if (!strcmp(keyword, "auto-monochrome"))
+ {
+ if (first_choice)
+ {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *ColorModel\n",
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*ColorModel AutoGray/%s: \"\"\n",
(human_readable2 ? human_readable2 : "Auto Monochrome"));
- } else if (!strcmp(keyword, "monochrome")) {
- if (first_choice) {
+ }
+ else if (!strcmp(keyword, "monochrome"))
+ {
+ if (first_choice)
+ {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *ColorModel\n",
if (!default_color || (!defattr && !strcmp(default_color, "FastGray")))
default_color = "Gray";
- } else if (!strcmp(keyword, "process-monochrome")) {
- if (first_choice) {
+ }
+ else if (!strcmp(keyword, "process-monochrome"))
+ {
+ if (first_choice)
+ {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *ColorModel\n",
cupsFilePrintf(fp, "*ColorModel ProcessGray/%s: \"\"\n",
(human_readable2 ? human_readable2 :
"Process Monochrome"));
- } else if (!strcmp(keyword, "color")) {
- if (first_choice) {
+ }
+ else if (!strcmp(keyword, "color"))
+ {
+ if (first_choice)
+ {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *ColorModel\n",
if (!defattr)
default_color = "RGB";
- /* Apparently some printers only advertise color support, so make sure
- we also do grayscale for these printers... */
+ // Apparently some printers only advertise color support, so make sure
+ // we also do grayscale for these printers...
if (!ippContainsString(attr, "monochrome") &&
!ippContainsString(attr, "auto-monochrome") &&
!ippContainsString(attr, "process-monochrome") &&
!ippContainsString(attr, "bi-level") &&
- !ippContainsString(attr, "process-bi-level")) {
+ !ippContainsString(attr, "process-bi-level"))
+ {
human_readable2 = cfCatalogLookUpChoice("monochrome",
"print-color-mode",
opt_strings_catalog,
}
}
- if (default_pagesize != NULL && (!default_color || !defattr)) {
- /* Here we are dealing with a cluster, if the default cluster color
- is not supplied we set it Gray*/
- if (default_cluster_color != NULL) {
+ if (default_pagesize != NULL && (!default_color || !defattr))
+ {
+ // Here we are dealing with a cluster, if the default cluster color
+ // is not supplied we set it Gray
+ if (default_cluster_color != NULL)
default_color = default_cluster_color;
- } else
+ else
default_color = "Gray";
}
cupsFilePrintf(fp, "*DefaultColorModel: %s\n", default_color);
if (!first_choice)
cupsFilePuts(fp, "*CloseUI: *ColorModel\n");
- } else {
+ }
+ else
+ {
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *ColorModel\n",
(human_readable ? human_readable : "Color Mode"));
- if (color) {
- /* Color printer according to DNS-SD (or unknown) */
+ if (color)
+ {
+ // Color printer according to DNS-SD (or unknown)
cupsFilePrintf(fp, "*DefaultColorModel: RGB\n");
cupsFilePuts(fp, "*ColorModel RGB/Color: \"\"\n");
- } else {
- cupsFilePrintf(fp, "*DefaultColorModel: Gray\n");
}
+ else
+ cupsFilePrintf(fp, "*DefaultColorModel: Gray\n");
cupsFilePuts(fp, "*ColorModel FastGray/Fast Grayscale: \"\"\n");
cupsFilePuts(fp, "*ColorModel Gray/Grayscale: \"\"\n");
cupsFilePuts(fp, "*CloseUI: *ColorModel\n");
}
- /*
- * Duplex...
- */
+ //
+ // Duplex...
+ //
if (((attr = ippFindAttribute(response, "sides-supported",
IPP_TAG_KEYWORD)) != NULL &&
ippContainsString(attr, "two-sided-long-edge")) ||
- (attr == NULL && duplex)) {
+ (attr == NULL && duplex))
+ {
human_readable = cfCatalogLookUpOption("sides", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *Duplex/%s: PickOne\n"
cupsFilePrintf(fp, "*CloseUI: *Duplex\n");
if ((attr = ippFindAttribute(response, "urf-supported",
- IPP_TAG_KEYWORD)) != NULL) {
- for (i = 0, count = ippGetCount(attr); i < count; i ++) {
- const char *dm = ippGetString(attr, i, NULL); /* DM value */
+ IPP_TAG_KEYWORD)) != NULL)
+ {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++)
+ {
+ const char *dm = ippGetString(attr, i, NULL); // DM value
- if (!strcasecmp(dm, "DM1")) {
+ if (!strcasecmp(dm, "DM1"))
+ {
cupsFilePuts(fp, "*cupsBackSide: Normal\n");
break;
- } else if (!strcasecmp(dm, "DM2")) {
+ }
+ else if (!strcasecmp(dm, "DM2"))
+ {
cupsFilePuts(fp, "*cupsBackSide: Flipped\n");
break;
- } else if (!strcasecmp(dm, "DM3")) {
+ }
+ else if (!strcasecmp(dm, "DM3"))
+ {
cupsFilePuts(fp, "*cupsBackSide: Rotated\n");
break;
- } else if (!strcasecmp(dm, "DM4")) {
+ }
+ else if (!strcasecmp(dm, "DM4"))
+ {
cupsFilePuts(fp, "*cupsBackSide: ManualTumble\n");
break;
}
}
- } else if ((attr = ippFindAttribute(response,
- "pwg-raster-document-sheet-back",
- IPP_TAG_KEYWORD)) != NULL) {
- keyword = ippGetString(attr, 0, NULL); /* Keyword value */
+ }
+ else if ((attr = ippFindAttribute(response,
+ "pwg-raster-document-sheet-back",
+ IPP_TAG_KEYWORD)) != NULL)
+ {
+ keyword = ippGetString(attr, 0, NULL); // Keyword value
if (!strcmp(keyword, "flipped"))
cupsFilePuts(fp, "*cupsBackSide: Flipped\n");
}
}
- /*
- * Output bin...
- */
+ //
+ // Output bin...
+ //
if ((attr = ippFindAttribute(response, "output-bin-default",
IPP_TAG_ZERO)) != NULL)
if ((attr = ippFindAttribute(response, "output-bin-supported",
IPP_TAG_ZERO)) != NULL &&
- (count = ippGetCount(attr)) > 0) {
+ (count = ippGetCount(attr)) > 0)
+ {
human_readable = cfCatalogLookUpOption("output-bin", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *OutputBin/%s: PickOne\n"
(human_readable ? human_readable : "Output Bin"),
ppdname);
attr2 = ippFindAttribute(response, "printer-output-tray", IPP_TAG_STRING);
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
keyword = ippGetString(attr, i, NULL);
ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname));
outputorderinfofound = 0;
faceupdown = 1;
firsttolast = 1;
- if (attr2 && i < ippGetCount(attr2)) {
+ if (attr2 && i < ippGetCount(attr2))
+ {
outbin_properties_octet = ippGetOctetString(attr2, i, &octet_str_len);
memset(outbin_properties, 0, sizeof(outbin_properties));
memcpy(outbin_properties, outbin_properties_octet,
((size_t)octet_str_len < sizeof(outbin_properties) - 1 ?
(size_t)octet_str_len : sizeof(outbin_properties) - 1));
- if (strcasestr(outbin_properties, "pagedelivery=faceUp")) {
+ if (strcasestr(outbin_properties, "pagedelivery=faceUp"))
+ {
outputorderinfofound = 1;
faceupdown = -1;
- } else if (strcasestr(outbin_properties, "pagedelivery=faceDown")) {
+ }
+ else if (strcasestr(outbin_properties, "pagedelivery=faceDown"))
+ {
outputorderinfofound = 1;
faceupdown = 1;
}
- if (strcasestr(outbin_properties, "stackingorder=lastToFirst")) {
+ if (strcasestr(outbin_properties, "stackingorder=lastToFirst"))
+ {
outputorderinfofound = 1;
firsttolast = -1;
- } else if (strcasestr(outbin_properties, "stackingorder=firstToLast")) {
+ }
+ else if (strcasestr(outbin_properties, "stackingorder=firstToLast"))
+ {
outputorderinfofound = 1;
firsttolast = 1;
}
}
if (outputorderinfofound == 0) {
- if (strcasestr(keyword, "face-up")) {
+ if (strcasestr(keyword, "face-up"))
+ {
outputorderinfofound = 1;
faceupdown = -1;
}
- if (strcasestr(keyword, "face-down")) {
+ if (strcasestr(keyword, "face-down"))
+ {
outputorderinfofound = 1;
faceupdown = 1;
}
cupsFilePuts(fp, "*CloseUI: *OutputBin\n");
}
- /*
- * Finishing options...
- */
+ //
+ // Finishing options...
+ //
if ((attr = ippFindAttribute(response, "finishings-supported",
- IPP_TAG_ENUM)) != NULL) {
- int value; /* Enum value */
- const char *ppd_keyword; /* PPD keyword for enum */
- cups_array_t *names; /* Names we've added */
+ IPP_TAG_ENUM)) != NULL)
+ {
+ int value; // Enum value
+ const char *ppd_keyword; // PPD keyword for enum
+ cups_array_t *names; // Names we've added
static const char * const base_keywords[] =
- { /* Base STD 92 keywords */
- NULL, /* none */
- "SingleAuto", /* staple */
- "SingleAuto", /* punch */
- NULL, /* cover */
- "BindAuto", /* bind */
- "SaddleStitch", /* saddle-stitch */
- "EdgeStitchAuto", /* edge-stitch */
- "Auto", /* fold */
- NULL, /* trim */
- NULL, /* bale */
- NULL, /* booklet-maker */
- NULL, /* jog-offset */
- NULL, /* coat */
- NULL /* laminate */
+ { // Base STD 92 keywords
+ NULL, // none
+ "SingleAuto", // staple
+ "SingleAuto", // punch
+ NULL, // cover
+ "BindAuto", // bind
+ "SaddleStitch", // saddle-stitch
+ "EdgeStitchAuto", // edge-stitch
+ "Auto", // fold
+ NULL, // trim
+ NULL, // bale
+ NULL, // booklet-maker
+ NULL, // jog-offset
+ NULL, // coat
+ NULL // laminate
};
count = ippGetCount(attr);
(cups_acopy_func_t)strdup, (cups_afree_func_t)free);
fin_options = cupsArrayNew((cups_array_func_t)strcmp, NULL);
- /*
- * Staple/Bind/Stitch
- */
+ //
+ // Staple/Bind/Stitch
+ //
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
value = ippGetInteger(attr, i);
keyword = ippEnumString("finishings", value);
break;
}
- if (i < count) {
+ if (i < count)
+ {
static const char * const staple_keywords[] =
- { /* StapleLocation keywords */
+ { // StapleLocation keywords
"SinglePortrait",
"SingleRevLandscape",
"SingleLandscape",
"TripleRevLandscape"
};
static const char * const bind_keywords[] =
- { /* StapleLocation binding keywords */
+ { // StapleLocation binding keywords
"BindPortrait",
"BindLandscape",
"BindRevPortrait",
cupsFilePrintf(fp, "*StapleLocation None/%s: \"\"\n",
(human_readable ? human_readable : "None"));
- for (; i < count; i ++) {
+ for (; i < count; i ++)
+ {
value = ippGetInteger(attr, i);
keyword = ippEnumString("finishings", value);
continue;
if (cupsArrayFind(names, (char *)keyword))
- continue; /* Already did this finishing template */
+ continue; // Already did this finishing template
cupsArrayAdd(names, (char *)keyword);
cupsFilePuts(fp, "*CloseUI: *StapleLocation\n");
}
- /*
- * Fold
- */
+ //
+ // Fold
+ //
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
value = ippGetInteger(attr, i);
keyword = ippEnumString("finishings", value);
break;
}
- if (i < count) {
+ if (i < count)
+ {
static const char * const fold_keywords[] =
- { /* FoldType keywords */
+ { // FoldType keywords
"Accordion",
"DoubleGate",
"Gate",
cupsFilePrintf(fp, "*FoldType None/%s: \"\"\n",
(human_readable ? human_readable : "None"));
- for (; i < count; i ++) {
+ for (; i < count; i ++)
+ {
value = ippGetInteger(attr, i);
keyword = ippEnumString("finishings", value);
continue;
if (cupsArrayFind(names, (char *)keyword))
- continue; /* Already did this finishing template */
+ continue; // Already did this finishing template
cupsArrayAdd(names, (char *)keyword);
cupsFilePuts(fp, "*CloseUI: *FoldType\n");
}
- /*
- * Punch
- */
+ //
+ // Punch
+ //
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
value = ippGetInteger(attr, i);
keyword = ippEnumString("finishings", value);
break;
}
- if (i < count) {
+ if (i < count)
+ {
static const char * const punch_keywords[] =
- { /* PunchMedia keywords */
+ { // PunchMedia keywords
"SinglePortrait",
"SingleRevLandscape",
"SingleLandscape",
cupsFilePrintf(fp, "*PunchMedia None/%s: \"\"\n",
(human_readable ? human_readable : "None"));
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
value = ippGetInteger(attr, i);
keyword = ippEnumString("finishings", value);
continue;
if (cupsArrayFind(names, (char *)keyword))
- continue; /* Already did this finishing template */
+ continue; // Already did this finishing template
cupsArrayAdd(names, (char *)keyword);
cupsFilePuts(fp, "*CloseUI: *PunchMedia\n");
}
- /*
- * Booklet
- */
+ //
+ // Booklet
+ //
- if (ippContainsInteger(attr, IPP_FINISHINGS_BOOKLET_MAKER)) {
+ if (ippContainsInteger(attr, IPP_FINISHINGS_BOOKLET_MAKER))
+ {
cupsArrayAdd(fin_options, "*Booklet");
human_readable = cfCatalogLookUpChoice("booklet-maker",
cupsFilePuts(fp, "*CloseUI: *Booklet\n");
}
- /*
- * CutMedia
- */
+ //
+ // CutMedia
+ //
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
value = ippGetInteger(attr, i);
keyword = ippEnumString("finishings", value);
break;
}
- if (i < count) {
+ if (i < count)
+ {
static const char * const trim_keywords[] =
- { /* CutMedia keywords */
+ { // CutMedia keywords
"EndOfPage",
"EndOfDoc",
"EndOfSet",
cupsFilePrintf(fp, "*CutMedia None/%s: \"\"\n",
(human_readable ? human_readable : "None"));
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
value = ippGetInteger(attr, i);
keyword = ippEnumString("finishings", value);
continue;
if (cupsArrayFind(names, (char *)keyword))
- continue; /* Already did this finishing template */
+ continue; // Already did this finishing template
cupsArrayAdd(names, (char *)keyword);
}
if ((attr = ippFindAttribute(response, "finishings-col-database",
- IPP_TAG_BEGIN_COLLECTION)) != NULL) {
- ipp_t *finishing_col; /* Current finishing collection */
- ipp_attribute_t *finishing_attr; /* Current finishing member attribute */
- cups_array_t *templates; /* Finishing templates */
+ IPP_TAG_BEGIN_COLLECTION)) != NULL)
+ {
+ ipp_t *finishing_col; // Current finishing collection
+ ipp_attribute_t *finishing_attr; // Current finishing member attribute
+ cups_array_t *templates; // Finishing templates
human_readable = cfCatalogLookUpOption("finishing-template",
opt_strings_catalog,
templates = cupsArrayNew((cups_array_func_t)strcmp, NULL);
count = ippGetCount(attr);
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
finishing_col = ippGetCollection(attr, i);
keyword = ippGetString(ippFindAttribute(finishing_col,
"finishing-template",
finishing_attr = ippNextAttribute(finishing_col)) {
if (ippGetValueTag(finishing_attr) == IPP_TAG_BEGIN_COLLECTION) {
const char *name = ippGetName(finishing_attr);
- /* Member attribute name */
+ // Member attribute name
if (strcmp(name, "media-size"))
cupsFilePrintf(fp, "%% %s\n", name);
cupsFilePuts(fp, "*CloseUI: *cupsFinishingTemplate\n");
- if (cupsArrayCount(fin_options)) {
- const char *fin_option; /* Current finishing option */
+ if (cupsArrayCount(fin_options))
+ {
+ const char *fin_option; // Current finishing option
cupsFilePuts(fp, "*cupsUIConstraint finishing-template: \"*cupsFinishingTemplate");
for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option;
cupsArrayDelete(fin_options);
- /*
- * DefaultResolution...
- */
+ //
+ // DefaultResolution...
+ //
xres = common_def->x;
yres = common_def->y;
else
cupsFilePrintf(fp, "*DefaultResolution: %dx%ddpi\n", xres, yres);
- /*
- * cupsPrintQuality...
- */
+ //
+ // cupsPrintQuality...
+ //
if ((quality =
ippFindAttribute(response, "print-quality-supported",
- IPP_TAG_ENUM)) != NULL) {
+ IPP_TAG_ENUM)) != NULL)
+ {
human_readable = cfCatalogLookUpOption("print-quality", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *cupsPrintQuality/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *cupsPrintQuality\n"
"*DefaultcupsPrintQuality: Normal\n",
(human_readable ? human_readable : "Print Quality"));
- if (ippContainsInteger(quality, IPP_QUALITY_DRAFT)) {
+ if (ippContainsInteger(quality, IPP_QUALITY_DRAFT))
+ {
human_readable = cfCatalogLookUpChoice("3", "print-quality",
opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*cupsPrintQuality Normal/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n",
(human_readable ? human_readable : "Normal"),
common_def->x, common_def->y);
- if (ippContainsInteger(quality, IPP_QUALITY_HIGH)) {
+ if (ippContainsInteger(quality, IPP_QUALITY_HIGH))
+ {
human_readable = cfCatalogLookUpChoice("5", "print-quality",
opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePuts(fp, "*CloseUI: *cupsPrintQuality\n");
}
- /* Only add these options if jobs get sent to the printer as PDF,
- PWG Raster, or Apple Raster, as only then arbitrary IPP
- attributes get passed through from the filter command line
- to the printer by the "ipp" CUPS backend. */
- if (is_pdf || is_pwg || is_apple) {
- /*
- * Print Optimization ...
- */
+ // Only add these options if jobs get sent to the printer as PDF,
+ // PWG Raster, or Apple Raster, as only then arbitrary IPP
+ // attributes get passed through from the filter command line
+ // to the printer by the "ipp" CUPS backend.
+ if (is_pdf || is_pwg || is_apple)
+ {
+ //
+ // Print Optimization ...
+ //
if ((attr = ippFindAttribute(response, "print-content-optimize-default",
IPP_TAG_ZERO)) != NULL)
if ((attr = ippFindAttribute(response, "print-content-optimize-supported",
IPP_TAG_ZERO)) != NULL &&
- (count = ippGetCount(attr)) > 1) {
+ (count = ippGetCount(attr)) > 1)
+ {
human_readable = cfCatalogLookUpOption("print-content-optimize",
opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePuts(fp, "*CloseUI: *print-content-optimize\n");
}
- /*
- * Print Rendering Intent ...
- */
+ //
+ // Print Rendering Intent ...
+ //
if ((attr = ippFindAttribute(response, "print-rendering-intent-default",
IPP_TAG_ZERO)) != NULL)
if ((attr = ippFindAttribute(response, "print-rendering-intent-supported",
IPP_TAG_ZERO)) != NULL &&
- (count = ippGetCount(attr)) > 1) {
+ (count = ippGetCount(attr)) > 1)
+ {
human_readable = cfCatalogLookUpOption("print-rendering-intent",
opt_strings_catalog,
printer_opt_strings_catalog);
(human_readable ? human_readable :
"Print Rendering Intent"),
ppdname);
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
keyword = ippGetString(attr, i, NULL);
human_readable = cfCatalogLookUpChoice((char *)keyword,
cupsFilePuts(fp, "*CloseUI: *cupsRenderingIntent\n");
}
- /*
- * Print Scaling ...
- */
+ //
+ // Print Scaling ...
+ //
if ((attr = ippFindAttribute(response, "print-scaling-default",
IPP_TAG_ZERO)) != NULL)
if ((attr = ippFindAttribute(response, "print-scaling-supported",
IPP_TAG_ZERO)) != NULL &&
- (count = ippGetCount(attr)) > 1) {
+ (count = ippGetCount(attr)) > 1)
+ {
human_readable = cfCatalogLookUpOption("print-scaling",
opt_strings_catalog,
printer_opt_strings_catalog);
"*Defaultprint-scaling: %s\n",
(human_readable ? human_readable : "Print Scaling"),
ppdname);
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i ++)
+ {
keyword = ippGetString(attr, i, NULL);
human_readable = cfCatalogLookUpChoice((char *)keyword, "print-scaling",
}
}
- /*
- * Phone Options for Fax..
- */
+ //
+ // Phone Options for Fax..
+ //
- if (is_fax) {
+ if (is_fax)
+ {
human_readable = cfCatalogLookUpOption("Phone", opt_strings_catalog,
printer_opt_strings_catalog);
"*ParamCustomfaxPrefix Text: 1 string 0 64\n");
}
- /*
- * Presets...
- */
+ //
+ // Presets...
+ //
if ((attr = ippFindAttribute(response, "job-presets-supported",
- IPP_TAG_BEGIN_COLLECTION)) != NULL) {
- for (i = 0, count = ippGetCount(attr); i < count; i ++) {
- ipp_t *preset = ippGetCollection(attr, i); /* Preset collection */
- const char *preset_name = /* Preset name */
+ IPP_TAG_BEGIN_COLLECTION)) != NULL)
+ {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++)
+ {
+ ipp_t *preset = ippGetCollection(attr, i); // Preset collection
+ const char *preset_name = // Preset name
ippGetString(ippFindAttribute(preset,
"preset-name", IPP_TAG_ZERO), 0, NULL),
- *localized_name; /* Localized preset name */
- ipp_attribute_t *member; /* Member attribute in preset */
- const char *member_name; /* Member attribute name */
- char member_value[256]; /* Member attribute value */
+ *localized_name; // Localized preset name
+ ipp_attribute_t *member; // Member attribute in preset
+ const char *member_name; // Member attribute name
+ char member_value[256]; // Member attribute value
if (!preset || !preset_name)
continue;
localized_name);
for (member = ippFirstAttribute(preset); member;
- member = ippNextAttribute(preset)) {
+ member = ippNextAttribute(preset))
+ {
member_name = ippGetName(member);
if (!member_name || !strcmp(member_name, "preset-name"))
continue;
- if (!strcmp(member_name, "finishings")) {
- for (i = 0, count = ippGetCount(member); i < count; i ++) {
- const char *option = NULL; /* PPD option name */
+ if (!strcmp(member_name, "finishings"))
+ {
+ for (i = 0, count = ippGetCount(member); i < count; i ++)
+ {
+ const char *option = NULL; // PPD option name
keyword = ippEnumString("finishings", ippGetInteger(member, i));
- if (!strcmp(keyword, "booklet-maker")) {
+ if (!strcmp(keyword, "booklet-maker"))
+ {
option = "Booklet";
keyword = "True";
- } else if (!strncmp(keyword, "fold-", 5))
+ }
+ else if (!strncmp(keyword, "fold-", 5))
option = "FoldType";
else if (!strncmp(keyword, "punch-", 6))
option = "PunchMedia";
if (option && keyword)
cupsFilePrintf(fp, "*%s %s\n", option, keyword);
}
- } else if (!strcmp(member_name, "finishings-col")) {
- ipp_t *fin_col; /* finishings-col value */
+ }
+ else if (!strcmp(member_name, "finishings-col"))
+ {
+ ipp_t *fin_col; // finishings-col value
- for (i = 0, count = ippGetCount(member); i < count; i ++) {
+ for (i = 0, count = ippGetCount(member); i < count; i ++)
+ {
fin_col = ippGetCollection(member, i);
if ((keyword =
IPP_TAG_ZERO), 0, NULL)) != NULL)
cupsFilePrintf(fp, "*cupsFinishingTemplate %s\n", keyword);
}
- } else if (!strcmp(member_name, "media")) {
- /*
- * Map media to PageSize...
- */
+ }
+ else if (!strcmp(member_name, "media"))
+ {
+ //
+ // Map media to PageSize...
+ //
if ((pwg = pwgMediaForPWG(ippGetString(member, 0, NULL))) != NULL &&
pwg->ppd)
cupsFilePrintf(fp, "*PageSize %s\n", pwg->ppd);
- } else if (!strcmp(member_name, "media-col")) {
+ }
+ else if (!strcmp(member_name, "media-col"))
+ {
media_col = ippGetCollection(member, 0);
if ((media_size =
ippGetCollection(ippFindAttribute(media_col,
"media-size",
IPP_TAG_BEGIN_COLLECTION),
- 0)) != NULL) {
+ 0)) != NULL)
+ {
x_dim = ippFindAttribute(media_size, "x-dimension",
IPP_TAG_INTEGER);
y_dim = ippFindAttribute(media_size, "y-dimension",
if ((keyword = ippGetString(ippFindAttribute(media_col,
"media-source",
IPP_TAG_ZERO), 0,
- NULL)) != NULL) {
+ NULL)) != NULL)
+ {
ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname));
cupsFilePrintf(fp, "*InputSlot %s\n", keyword);
}
if ((keyword = ippGetString(ippFindAttribute(media_col, "media-type",
IPP_TAG_ZERO), 0,
- NULL)) != NULL) {
+ NULL)) != NULL)
+ {
ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname));
cupsFilePrintf(fp, "*MediaType %s\n", keyword);
}
- } else if (!strcmp(member_name, "print-quality")) {
- /*
- * Map print-quality to cupsPrintQuality...
- */
+ }
+ else if (!strcmp(member_name, "print-quality"))
+ {
+ //
+ // Map print-quality to cupsPrintQuality...
+ //
int qval = ippGetInteger(member, 0);
- /* print-quality value */
+ // print-quality value
static const char * const qualities[] = { "Draft", "Normal", "High" };
- /* cupsPrintQuality values */
+ // cupsPrintQuality values
if (qval >= IPP_QUALITY_DRAFT && qval <= IPP_QUALITY_HIGH)
cupsFilePrintf(fp, "*cupsPrintQuality %s\n",
qualities[qval - IPP_QUALITY_DRAFT]);
- } else if (!strcmp(member_name, "output-bin")) {
+ }
+ else if (!strcmp(member_name, "output-bin"))
+ {
ppdPwgPpdizeName(ippGetString(member, 0, NULL), ppdname,
sizeof(ppdname));
cupsFilePrintf(fp, "*OutputBin %s\n", ppdname);
- } else if (!strcmp(member_name, "sides")) {
+ }
+ else if (!strcmp(member_name, "sides"))
+ {
keyword = ippGetString(member, 0, NULL);
if (keyword && !strcmp(keyword, "one-sided"))
cupsFilePuts(fp, "*Duplex None\n");
cupsFilePuts(fp, "*Duplex DuplexNoTumble\n");
else if (keyword && !strcmp(keyword, "two-sided-short-edge"))
cupsFilePuts(fp, "*Duplex DuplexTumble\n");
- } else {
- /*
- * Add attribute name and value as-is...
- */
+ }
+ else
+ {
+ //
+ // Add attribute name and value as-is...
+ //
ippAttributeString(member, member_value, sizeof(member_value));
cupsFilePrintf(fp, "*%s %s\n", member_name, member_value);
}
}
- /*
- * constraints
- */
- if (conflicts != NULL) {
+ //
+ // constraints
+ //
+
+ if (conflicts != NULL)
+ {
char* constraint;
for (constraint = (char *)cupsArrayFirst(conflicts); constraint;
- constraint = (char *)cupsArrayNext(conflicts)) {
+ constraint = (char *)cupsArrayNext(conflicts))
cupsFilePrintf(fp, "%s", constraint);
- }
}
- /*
- * Close up and return...
- */
+ //
+ // Clean up and return...
+ //
free(common_def);
free(min_res);
return (buffer);
- /*
- * If we get here then there was a problem creating the PPD...
- */
+ //
+ // If we get here then there was a problem creating the PPD...
+ //
bad_ppd:
-/*
- * PPD file routines for libppd.
- *
- * Copyright © 2007-2019 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
-
-/*
- * Include necessary headers.
- */
+//
+// PPD options <-> IPP attributes routines for libppd.
+//
+// Copyright © 2007-2019 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
+
+//
+// Include necessary headers.
+//
#include "ppd.h"
#include "debug-internal.h"
#include <errno.h>
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
-static ipp_t *create_media_col(const char *media, const char *source, const char *type, int width, int length, int bottom, int left, int right, int top);
+static ipp_t *create_media_col(const char *media, const char *source,
+ const char *type, int width,
+ int length, int bottom, int left,
+ int right, int top);
static ipp_t *create_media_size(int width, int length);
-static ipp_t *create_media_size_ranges(int min_width, int min_length, int max_width, int max_length);
-
-
-/*
- * 'ppdGetOptions()' - Get the PPD options corresponding to the IPP Job Template
- * attributes for a printer with given PPD and given
- * printer attributes (generated by ppdLoadAttributes()).
- */
-
-int /* O - Number of options */
-ppdGetOptions(cups_option_t **options, /* O - Options */
- ipp_t *printer_attrs, /* I - Printer attributes, from
- ppdLoadAttributes() */
- ipp_t *job_attrs, /* I - Job attributes */
- ppd_file_t *ppd) /* I - PPD file data */
+static ipp_t *create_media_size_ranges(int min_width, int min_length,
+ int max_width,
+ int max_length);
+
+
+//
+// 'ppdGetOptions()' - Get the PPD options corresponding to the IPP Job Template
+// attributes for a printer with given PPD and given
+// printer attributes (generated by ppdLoadAttributes()).
+//
+
+int // O - Number of options
+ppdGetOptions(cups_option_t **options, // O - Options
+ ipp_t *printer_attrs, // I - Printer attributes, from
+ // ppdLoadAttributes()
+ ipp_t *job_attrs, // I - Job attributes
+ ppd_file_t *ppd) // I - PPD file data
{
- ppd_cache_t *ppd_cache; /* IPP to PPD cache data */
- int num_options = 0; /* Number of options */
- ipp_attribute_t *attr; /* Job attribute */
- char valstr[8192]; /* Attribute value string */
- const char *value; /* Option value */
- pwg_media_t *media = NULL; /* Media mapping */
- int num_media_col = 0; /* Number of media-col values */
- cups_option_t *media_col = NULL; /* media-col values */
- const char *choice; /* PPD choice */
+ ppd_cache_t *ppd_cache; // IPP to PPD cache data
+ int num_options = 0; // Number of options
+ ipp_attribute_t *attr; // Job attribute
+ char valstr[8192]; // Attribute value string
+ const char *value; // Option value
+ pwg_media_t *media = NULL; // Media mapping
+ int num_media_col = 0; // Number of media-col values
+ cups_option_t *media_col = NULL; // media-col values
+ const char *choice; // PPD choice
- /*
- * No options to start...
- */
+ //
+ // No options to start...
+ //
*options = NULL;
- /*
- * Media...
- */
+ //
+ // Media...
+ //
if ((attr = ippFindAttribute(job_attrs, "media", IPP_TAG_ZERO)) == NULL)
if ((attr = ippFindAttribute(job_attrs, "media-col", IPP_TAG_ZERO)) == NULL)
if (*value == '{')
{
- /*
- * media-col value...
- */
+ //
+ // media-col value...
+ //
num_media_col = cupsParseOptions(value, 0, &media_col);
}
else
{
- /*
- * media value - map to media-col.media-size-name...
- */
+ //
+ // media value - map to media-col.media-size-name...
+ //
num_media_col = cupsAddOption("media-size-name", value, 0, &media_col);
}
else if ((value = cupsGetOption("media-size", num_media_col, media_col))
!= NULL)
{
- int num_media_size; /* Number of media-size values */
- cups_option_t *media_size; /* media-size values */
- const char *x_dimension, /* x-dimension value */
- *y_dimension; /* y-dimension value */
+ int num_media_size; // Number of media-size values
+ cups_option_t *media_size; // media-size values
+ const char *x_dimension, // x-dimension value
+ *y_dimension; // y-dimension value
num_media_size = cupsParseOptions(value, 0, &media_size);
- if ((x_dimension = cupsGetOption("x-dimension", num_media_size, media_size)) != NULL && (y_dimension = cupsGetOption("y-dimension", num_media_size, media_size)) != NULL)
+ if ((x_dimension = cupsGetOption("x-dimension",
+ num_media_size, media_size)) != NULL &&
+ (y_dimension = cupsGetOption("y-dimension",
+ num_media_size, media_size)) != NULL)
media = pwgMediaForSize(atoi(x_dimension), atoi(y_dimension));
cupsFreeOptions(num_media_size, media_size);
if (media)
num_options = cupsAddOption("PageSize", media->ppd, num_options, options);
- /*
- * Generate PPD's corresponding IPP <-> PPD cache data...
- */
+ //
+ // Generate PPD's corresponding IPP <-> PPD cache data...
+ //
if (ppd)
{
else
ppd_cache = ppd->cache;
- /* TODO: Fix me - values are names, not numbers... Also need to support
- finishings-col */
+ // TODO: Fix me - values are names, not numbers... Also need to support
+ // finishings-col
if ((attr = ippFindAttribute(job_attrs, "finishings", IPP_TAG_ZERO))
== NULL)
attr = ippFindAttribute(printer_attrs, "finishings-default",
if (attr)
{
- char *ptr; /* Pointer into value */
- int fin; /* Current value */
+ char *ptr; // Pointer into value
+ int fin; // Current value
ippAttributeString(attr, valstr, sizeof(valstr));
value = valstr;
for (fin = strtol(value, &ptr, 10); fin > 0; fin = strtol(ptr + 1, &ptr, 10))
{
- num_options = ppdCacheGetFinishingOptions(ppd_cache, NULL, (ipp_finishings_t)fin, num_options, options);
+ num_options =
+ ppdCacheGetFinishingOptions(ppd_cache, NULL,
+ (ipp_finishings_t)fin,
+ num_options, options);
if (*ptr != ',')
break;
}
}
- if ((value = cupsGetOption("media-source", num_media_col, media_col)) != NULL)
+ if ((value = cupsGetOption("media-source",
+ num_media_col, media_col)) != NULL)
{
if ((choice = ppdCacheGetInputSlot(ppd_cache, NULL, value)) != NULL)
num_options = cupsAddOption("InputSlot", choice, num_options, options);
ippAttributeString(attr, valstr, sizeof(valstr));
value = valstr;
if (!strcmp(value, "one-sided") && ppd_cache->sides_1sided)
- num_options = cupsAddOption(ppd_cache->sides_option, ppd_cache->sides_1sided, num_options, options);
- else if (!strcmp(value, "two-sided-long-edge") && ppd_cache->sides_2sided_long)
- num_options = cupsAddOption(ppd_cache->sides_option, ppd_cache->sides_2sided_long, num_options, options);
- else if (!strcmp(value, "two-sided-short-edge") && ppd_cache->sides_2sided_short)
- num_options = cupsAddOption(ppd_cache->sides_option, ppd_cache->sides_2sided_short, num_options, options);
+ num_options = cupsAddOption(ppd_cache->sides_option,
+ ppd_cache->sides_1sided,
+ num_options, options);
+ else if (!strcmp(value, "two-sided-long-edge") &&
+ ppd_cache->sides_2sided_long)
+ num_options = cupsAddOption(ppd_cache->sides_option,
+ ppd_cache->sides_2sided_long,
+ num_options, options);
+ else if (!strcmp(value, "two-sided-short-edge") &&
+ ppd_cache->sides_2sided_short)
+ num_options = cupsAddOption(ppd_cache->sides_option,
+ ppd_cache->sides_2sided_short,
+ num_options, options);
}
if ((attr = ippFindAttribute(job_attrs, "print-quality", IPP_TAG_ZERO))
if (attr)
{
- int i; /* Looping var */
- int pq; /* Print quality (0-2) */
- int pcm = 1; /* Print color model (0 = mono, 1 = color) */
- int num_presets; /* Number of presets */
- cups_option_t *presets; /* Presets */
+ int i; // Looping var
+ int pq; // Print quality (0-2)
+ int pcm = 1; // Print color model
+ // (0 = mono, 1 = color)
+ int num_presets; // Number of presets
+ cups_option_t *presets; // Presets
ippAttributeString(attr, valstr, sizeof(valstr));
value = valstr;
presets = ppd_cache->presets[pcm][pq];
for (i = 0; i < num_presets; i ++)
- num_options = cupsAddOption(presets[i].name, presets[i].value, num_options, options);
+ num_options = cupsAddOption(presets[i].name, presets[i].value,
+ num_options, options);
}
- /*
- * Mark the PPD with the options...
- */
+ //
+ // Mark the PPD with the options...
+ //
ppdMarkDefaults(ppd);
ppdMarkOptions(ppd, num_options, *options);
}
-/*
- * 'ppdLoadAttributes()' - Load IPP attributes from a PPD file to
- * create printer IPP attriutes which describe
- * the capabilities of the printer. Note that
- * this is for telling filters and drivers how
- * to print a job on the printer and NOT for a
- * PPD retro-fitting Printer Application (or
- * any other PPD-supporting IPP print server)
- * to answer a get-printer-attributes IPP
- * request.
- */
-
-ipp_t * /* O - IPP attributes or `NULL`
- on error */
+//
+// 'ppdLoadAttributes()' - Load IPP attributes from a PPD file to
+// create printer IPP attriutes which describe
+// the capabilities of the printer. Note that
+// this is for telling filters and drivers how
+// to print a job on the printer and NOT for a
+// PPD retro-fitting Printer Application (or
+// any other PPD-supporting IPP print server)
+// to answer a get-printer-attributes IPP
+// request.
+//
+
+ipp_t * // O - IPP attributes or `NULL`
+ // on error
ppdLoadAttributes(
- ppd_file_t *ppd) /* I - PPD file data */
+ ppd_file_t *ppd) // I - PPD file data
{
- int i, j; /* Looping vars */
+ int i, j; // Looping vars
char *ptr;
- cups_array_t *docformats; /* document-format-supported
- values */
- ipp_t *attrs; /* Attributes */
- ipp_attribute_t *attr; /* Current attribute */
- ipp_attribute_t *aux_attr; /* Auxiliary attribute */
- ipp_t *col; /* Current collection value */
- ppd_attr_t *ppd_attr; /* PPD attribute */
- ppd_option_t *ppd_option; /* PPD option */
- ppd_choice_t *ppd_choice; /* PPD choice */
- ppd_size_t *ppd_size; /* Default PPD size */
- pwg_size_t *pwg_size, /* Current PWG size */
- *default_size = NULL; /* Default PWG size */
- const char *default_source = NULL, /* Default media source */
- *default_type = NULL, /* Default media type */
- *default_output_bin = NULL, /* Default output bin */
- *default_output_order = NULL; /* Default output order */
- pwg_map_t *pwg_map; /* Mapping from PWG to PPD keywords */
- ppd_cache_t *pc; /* PPD cache */
- ppd_pwg_finishings_t *finishings; /* Current finishings value */
- const char *template; /* Current finishings-template value */
- int num_margins; /* Number of media-xxx-margin-supported values */
- int margins[10]; /* media-xxx-margin-supported values */
- int xres = 0, /* Default horizontal resolution */
- yres = 0; /* Default vertical resolution */
+ cups_array_t *docformats; // document-format-supported
+ // values
+ ipp_t *attrs; // Attributes
+ ipp_attribute_t *attr; // Current attribute
+ ipp_attribute_t *aux_attr; // Auxiliary attribute
+ ipp_t *col; // Current collection value
+ ppd_attr_t *ppd_attr; // PPD attribute
+ ppd_option_t *ppd_option; // PPD option
+ ppd_choice_t *ppd_choice; // PPD choice
+ ppd_size_t *ppd_size; // Default PPD size
+ pwg_size_t *pwg_size, // Current PWG size
+ *default_size = NULL; // Default PWG size
+ const char *default_source = NULL, // Default media source
+ *default_type = NULL, // Default media type
+ *default_output_bin = NULL, // Default output bin
+ *default_output_order = NULL; // Default output order
+ pwg_map_t *pwg_map; // Mapping from PWG to PPD keywords
+ ppd_cache_t *pc; // PPD cache
+ ppd_pwg_finishings_t *finishings; // Current finishings value
+ const char *template; // Current finishings-template value
+ int num_margins; // Number of media-xxx-margin-supported
+ // values
+ int margins[10]; // media-xxx-margin-supported values
+ int xres = 0, // Default horizontal resolution
+ yres = 0; // Default vertical resolution
int is_texttotext;
- int num_items; /* Number of IPP attribute values */
- const char *items[20]; /* IPP attribute values */
- char item_buf[64]; /* RS value */
+ int num_items; // Number of IPP attribute values
+ const char *items[20]; // IPP attribute values
+ char item_buf[64]; // RS value
int res_x[20], res_y[20], int_item[20];
char *val,
*def_output_bin = NULL,
buf[1024],
- cmd[256], /* Device ID CMD: string */
+ cmd[256], // Device ID CMD: string
*cmdptr;
int def_found,
order,
have_custom_size = 0;
cups_page_header2_t header;
static const char * const pdls[][2] =
- { /* MIME media type to command set mapping */
+ { // MIME media type to command set
+ // mapping
{ "application/postscript", "POSTSCRIPT,PS" },
{ "application/vnd.cups-postscript", "POSTSCRIPT,PS" },
{ "application/pdf", "PDF" },
{ "image/tiff", "TIFF" }
};
static const int orientation_requested_supported[4] =
- { /* orientation-requested-supported values */
+ { // orientation-requested-supported
+ // values
IPP_ORIENT_PORTRAIT,
IPP_ORIENT_LANDSCAPE,
IPP_ORIENT_REVERSE_LANDSCAPE,
IPP_ORIENT_REVERSE_PORTRAIT
};
static const char * const overrides_supported[] =
- { /* overrides-supported */
+ { // overrides-supported
"document-numbers",
"media",
"media-col",
"pages"
};
static const char * const print_color_mode_supported[] =
- { /* print-color-mode-supported values */
+ { // print-color-mode-supported values
"monochrome"
};
static const char * const print_color_mode_supported_color[] =
- { /* print-color-mode-supported values */
+ { // print-color-mode-supported values
"auto",
"color",
"monochrome"
};
static const int print_quality_supported[] =
- { /* print-quality-supported values */
+ { // print-quality-supported values
IPP_QUALITY_DRAFT,
IPP_QUALITY_NORMAL,
IPP_QUALITY_HIGH
};
static const char * const print_content_optimize_supported[] =
- { /* print-content-optimize-supported values */
+ { // print-content-optimize-supported
+ // values
"auto",
"text",
"graphic",
"photo"
};
static const char * const sides_supported[] =
- { /* sides-supported values */
+ { // sides-supported values
"one-sided",
"two-sided-long-edge",
"two-sided-short-edge"
};
- /*
- * Open the PPD file...
- */
+ //
+ // Open the PPD file...
+ //
if (ppd == NULL)
return (NULL);
if ((ppd_size = ppdPageSize(ppd, NULL)) != NULL)
{
- /*
- * Look up default size...
- */
+ //
+ // Look up default size...
+ //
for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
{
if (!default_size)
{
- /*
- * Default to A4 or Letter...
- */
+ //
+ // Default to A4 or Letter...
+ //
for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
{
- if (!strcmp(pwg_size->map.ppd, "Letter") || !strcmp(pwg_size->map.ppd, "A4"))
+ if (!strcmp(pwg_size->map.ppd, "Letter") ||
+ !strcmp(pwg_size->map.ppd, "A4"))
{
default_size = pwg_size;
break;
}
if (!default_size)
- default_size = pc->sizes; /* Last resort: first size */
+ default_size = pc->sizes; // Last resort: first size
}
if ((ppd_choice = ppdFindMarkedChoice(ppd, "InputSlot")) != NULL)
if (default_output_order == NULL)
default_output_order = "Normal";
- /*
- * Data formats which the printer understands, if the PPD specifies
- * a driver in a "*cupsFilter(2): ..." line, we add the input format
- * of the driver, as this is what our filter need to produce.
- */
+ //
+ // Data formats which the printer understands, if the PPD specifies
+ // a driver in a "*cupsFilter(2): ..." line, we add the input format
+ // of the driver, as this is what our filter need to produce.
+ //
docformats = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, NULL,
(cups_afree_func_t)free);
filter;
filter = (char *)cupsArrayNext(pc->filters))
{
- /* String of the "*cupsfilter:" or "*cupsfilter2:" line */
+ // String of the "*cupsfilter:" or "*cupsfilter2:" line
strncpy(buf, filter, sizeof(buf) - 1);
- /* Do not count in "comandto..." filters */
+ // Do not count in "comandto..." filters
if (strstr(buf, " commandto"))
continue;
- /* Is the PPD file using the "texttotext" filter? */
+ // Is the PPD file using the "texttotext" filter?
if (strcmp(buf + strlen(buf) - 10, "texttotext") == 0)
is_texttotext = 1;
- /* Separate the first word */
+ // Separate the first word
ptr = buf;
while (*ptr && !isspace(*ptr)) ptr ++;
if (*ptr)
*ptr = '\0';
- /* Check whether the second word is not the cost value, then we have
- a "*cupsFilter2:* line and the second word is the printer's input
- format */
+ // Check whether the second word is not the cost value, then we have
+ // a "*cupsFilter2:* line and the second word is the printer's input
+ // format
ptr ++;
while (*ptr && isspace(*ptr)) ptr ++;
if (!isdigit(*ptr))
*ptr = '\0';
}
- /* Add it to the list of output formats */
+ // Add it to the list of output formats
cupsArrayAdd(docformats, strdup(buf));
- /* Add it to the CMD: string for the device ID */
+ // Add it to the CMD: string for the device ID
if (!ppdFindAttr(ppd, "1284DeviceId", NULL))
{
- /* See if it is a known MIME media type and map to the corresponding
- 1284 command-set name... */
+ // See if it is a known MIME media type and map to the corresponding
+ // 1284 command-set name...
for (i = 0; i < (sizeof(pdls) / sizeof(pdls[0])); i ++)
{
if (!strcasecmp(buf, pdls[i][0]) &&
strlen(pdls[i][1]) < sizeof(cmd) - (size_t)(cmdptr - cmd) - 3)
{
- /* MIME media type matches, append this CMD value... */
+ // MIME media type matches, append this CMD value...
if (cmdptr > cmd + 4)
*cmdptr++ = ',';
strcpy(cmdptr, pdls[i][1]);
strcpy(cmd, "CMD:POSTSCRIPT,PS;");
}
- /*
- * Create the attributes...
- */
+ //
+ // Create the attributes...
+ //
attrs = ippNew();
- /*
- * Properties of supported Raster formats: Convert from strings
- * in the PPD files (from driverless PPD auto-generator) into
- * printer IPP attributes
- */
+ //
+ // Properties of supported Raster formats: Convert from strings
+ // in the PPD files (from driverless PPD auto-generator) into
+ // printer IPP attributes
+ //
for (i = 0; i < ppd->num_attrs; i ++)
{
(cupsArrayFind(docformats, (void *)"application/PCLm") &&
strncasecmp(ppd_attr->name, "cupsPclm", 8) == 0))
{
- /* Convert PPD-style names into IPP-style names */
+ // Convert PPD-style names into IPP-style names
ppdPwgUnppdizeName(ppd_attr->name + 4, item_buf, sizeof(item_buf), NULL);
- /* Make array from comma-separated list */
+ // Make array from comma-separated list
strncpy(buf, ppd_attr->value, sizeof(buf) - 1);
num_items = 0;
char *p = buf;
*p = '\0';
p ++;
}
- /* Default resolution via urf-supported */
+ // Default resolution via urf-supported
if (!strcmp(item_buf, "urf-supported") &&
- (xres == 0 && yres == 0) &&/* Default resolution not found in
- other raster-format-related PPD
- attribute yet, use first resolution in
- urf-supported */
+ (xres == 0 && yres == 0) &&// Default resolution not found in
+ // other raster-format-related PPD
+ // attribute yet, use first resolution in
+ // urf-supported
items[num_items - 1][0] == 'R' && items[num_items - 1][1] == 'S')
xres = yres = atoi(items[num_items - 1] + 2);
}
strncasecmp(items[0] + strlen(items[0]) - 3, "dpi", 3) == 0 &&
isdigit(*(items[0] + strlen(items[0]) - 4)))
{
- /* Resolutions */
+ // Resolutions
for (j = 0; j < num_items; j ++)
if (sscanf(items[j], "%dx%d", &res_x[j], &res_y[j]) == 1)
res_y[j] = res_x[j];
- ippAddResolutions(attrs, IPP_TAG_PRINTER, item_buf, num_items, IPP_RES_PER_INCH, res_x, res_y);
- /* Default resolution? */
- if ((xres == 0 && yres == 0) || /* Take first in list if there is no
- separate PPD attribute providing a
- default resolution */
- strstr(item_buf, "default")) /* PPD attribute with default
- resolution, take it, even if we
- already had the list from which we
- have taken the first item. */
+ ippAddResolutions(attrs, IPP_TAG_PRINTER, item_buf, num_items,
+ IPP_RES_PER_INCH, res_x, res_y);
+ // Default resolution?
+ if ((xres == 0 && yres == 0) || // Take first in list if there is no
+ // separate PPD attribute providing a
+ // default resolution
+ strstr(item_buf, "default")) // PPD attribute with default
+ // resolution, take it, even if we
+ // already had the list from which we
+ // have taken the first item.
{
xres = res_x[0];
yres = res_y[0];
}
}
else if (strlen(items[0]) > 0 &&
- ((int)(strtol(items[0], &p, 10) * 0) || (errno == 0 && *p == '\0')))
+ ((int)(strtol(items[0], &p, 10) * 0) ||
+ (errno == 0 && *p == '\0')))
{
- /* Integer number(s) */
+ // Integer number(s)
for (j = 0; j < num_items; j ++)
int_item[j] = (int)strtol(items[j], NULL, 10);
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, item_buf, num_items, int_item);
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, item_buf,
+ num_items, int_item);
}
else
- /* General */
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, item_buf, num_items, NULL, items);
+ // General
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, item_buf,
+ num_items, NULL, items);
}
}
- /*
- * Resolution
- */
+ //
+ // Resolution
+ //
if (xres == 0 && yres == 0)
{
- /* Ignore error exits of ppdRasterInterpretPPD(), if it found a resolution
- setting before erroring it is OK for us */
+ // Ignore error exits of ppdRasterInterpretPPD(), if it found a resolution
+ // setting before erroring it is OK for us
ppdRasterInterpretPPD(&header, ppd, 0, NULL, NULL);
- /* 100 dpi is default, this means that if we have 100 dpi here this
- method failed to find the printing resolution */
+ // 100 dpi is default, this means that if we have 100 dpi here this
+ // method failed to find the printing resolution
buf[0] = '\0';
if (header.HWResolution[0] != 100 || header.HWResolution[1] != 100)
{
else if ((ppd_attr = ppdFindAttr(ppd, "DefaultResolution", NULL)) != NULL)
strncpy(buf, ppd_attr->value, sizeof(buf) - 1);
else
- /* Use default of 300dpi... */
+ // Use default of 300dpi...
xres = yres = 300;
buf[sizeof(buf) - 1] = '\0';
if (buf[0])
{
- /* Use the marked resolution or the default resolution in the PPD... */
+ // Use the marked resolution or the default resolution in the PPD...
if ((i = sscanf(buf, "%dx%d", &xres, &yres)) == 1)
yres = xres;
else if (i <= 0)
}
}
- /* Fax out PPD? */
+ // Fax out PPD?
if (((ppd_attr = ppdFindAttr(ppd, "cupsFax", NULL)) != NULL &&
strcasecmp(ppd_attr->value, "True") == 0) ||
((ppd_attr = ppdFindAttr(ppd, "cupsIPPFaxOut", NULL)) != NULL &&
strcasecmp(ppd_attr->value, "True") == 0))
{
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "ipp-features-supported", NULL, "faxout");
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_URI), "printer-uri-supported", NULL, "ipp://localhost/ipp/faxout");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "ipp-features-supported", NULL, "faxout");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_URI),
+ "printer-uri-supported", NULL, "ipp://localhost/ipp/faxout");
}
- /* color-supported */
- ippAddBoolean(attrs, IPP_TAG_PRINTER, "color-supported", (char)ppd->color_device);
+ // color-supported
+ ippAddBoolean(attrs, IPP_TAG_PRINTER, "color-supported",
+ (char)ppd->color_device);
- /* copies-default */
+ // copies-default
if (((ppd_choice = ppdFindMarkedChoice(ppd, "Copies")) == NULL ||
(i = atoi(ppd_choice->choice)) <= 0) &&
((ppd_attr = ppdFindAttr(ppd, "DefaultCopies", NULL)) == NULL ||
i = 1;
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "copies-default", i);
- /* copies-supported */
+ // copies-supported
ippAddRange(attrs, IPP_TAG_PRINTER, "copies-supported", 1,
pc->max_copies > 0 ? pc->max_copies : 999);
- /* document-format-supported */
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "document-format-supported", cupsArrayCount(docformats), NULL, NULL);
+ // document-format-supported
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "document-format-supported",
+ cupsArrayCount(docformats), NULL, NULL);
for (ptr = (char *)cupsArrayFirst(docformats), i = 0; ptr;
ptr = (char *)cupsArrayNext(docformats), i ++)
ippSetString(attrs, &attr, i, ptr);
- /* finishing-template-supported */
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template-supported", cupsArrayCount(pc->templates) + 1, NULL, NULL);
+ // finishing-template-supported
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "finishing-template-supported",
+ cupsArrayCount(pc->templates) + 1, NULL, NULL);
ippSetString(attrs, &attr, 0, "none");
- for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
+ for (i = 1, template = (const char *)cupsArrayFirst(pc->templates);
+ template; i ++, template = (const char *)cupsArrayNext(pc->templates))
ippSetString(attrs, &attr, i, template);
- /* finishings-col-database */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-database", cupsArrayCount(pc->templates) + 1, NULL);
+ // finishings-col-database
+ attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-database",
+ cupsArrayCount(pc->templates) + 1, NULL);
col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template",
+ NULL, "none");
ippSetCollection(attrs, &attr, 0, col);
ippDelete(col);
- for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
+ for (i = 1, template = (const char *)cupsArrayFirst(pc->templates);
+ template; i ++, template = (const char *)cupsArrayNext(pc->templates))
{
col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, template);
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template",
+ NULL, template);
ippSetCollection(attrs, &attr, i, col);
ippDelete(col);
}
- /* finishings-col-default */
+ // finishings-col-default
col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template",
+ NULL, "none");
ippAddCollection(attrs, IPP_TAG_PRINTER, "finishings-col-default", col);
ippDelete(col);
- /* finishings-col-ready */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-ready", cupsArrayCount(pc->templates) + 1, NULL);
+ // finishings-col-ready
+ attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-ready",
+ cupsArrayCount(pc->templates) + 1, NULL);
col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template",
+ NULL, "none");
ippSetCollection(attrs, &attr, 0, col);
ippDelete(col);
- for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
+ for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template;
+ i ++, template = (const char *)cupsArrayNext(pc->templates))
{
col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, template);
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template",
+ NULL, template);
ippSetCollection(attrs, &attr, i, col);
ippDelete(col);
}
- /* finishings-col-supported */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "finishings-col-supported", NULL, "finishing-template");
+ // finishings-col-supported
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "finishings-col-supported", NULL, "finishing-template");
- /* finishings-default */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-default", IPP_FINISHINGS_NONE);
+ // finishings-default
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-default",
+ IPP_FINISHINGS_NONE);
- /* finishings-ready */
- attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-ready", cupsArrayCount(pc->finishings) + 1, NULL);
+ // finishings-ready
+ attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
+ "finishings-ready",
+ cupsArrayCount(pc->finishings) + 1, NULL);
ippSetInteger(attrs, &attr, 0, IPP_FINISHINGS_NONE);
- for (i = 1, finishings = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings); finishings; i ++, finishings = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings))
+ for (i = 1,
+ finishings = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings);
+ finishings;
+ i ++,
+ finishings = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings))
ippSetInteger(attrs, &attr, i, (int)finishings->value);
- /* finishings-supported */
- attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-supported", cupsArrayCount(pc->finishings) + 1, NULL);
+ // finishings-supported
+ attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
+ "finishings-supported",
+ cupsArrayCount(pc->finishings) + 1, NULL);
ippSetInteger(attrs, &attr, 0, IPP_FINISHINGS_NONE);
- for (i = 1, finishings = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings); finishings; i ++, finishings = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings))
+ for (i = 1,
+ finishings = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings);
+ finishings;
+ i ++,
+ finishings = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings))
ippSetInteger(attrs, &attr, i, (int)finishings->value);
- /* media-bottom-margin-supported */
- for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
+ // media-bottom-margin-supported
+ for (i = 0, num_margins = 0, pwg_size = pc->sizes;
+ i < pc->num_sizes &&
+ num_margins < (int)(sizeof(margins) / sizeof(margins[0]));
+ i ++, pwg_size ++)
{
for (j = 0; j < num_margins; j ++)
{
}
}
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin-supported", num_margins, margins);
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-bottom-margin-supported", num_margins, margins);
- /* landscape-orientation-requested-preferred */
- if (ppd->landscape < 0) /* Direction the printer rotates landscape
- (-90) */
+ // landscape-orientation-requested-preferred
+ if (ppd->landscape < 0) // Direction the printer rotates landscape
+ // (-90)
{
- /* Rotate clockwise (reverse landscape)*/
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "landscape-orientation-requested-preferred", 5);
+ // Rotate clockwise (reverse landscape)
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
+ "landscape-orientation-requested-preferred", 5);
}
- else if (ppd->landscape > 0) /* (+90) */
+ else if (ppd->landscape > 0) // (+90)
{
- /* Rotate counter-clockwise (landscape) */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "landscape-orientation-requested-preferred", 4);
+ // Rotate counter-clockwise (landscape)
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
+ "landscape-orientation-requested-preferred", 4);
}
- /* media-col-database, media-col-default, media-col-ready, media-default,
- media-ready */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-col-database", pc->num_sizes, NULL);
+ // media-col-database, media-col-default, media-col-ready, media-default,
+ // media-ready
+ attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-col-database",
+ pc->num_sizes, NULL);
if (strncasecmp(ppd_size->name, "Custom", 6) == 0)
{
- /* media-col-default - Custom size */
+ // media-col-default - Custom size
int w = (int)(ppd_size->width / 72.0 * 2540.0);
int l = (int)(ppd_size->length / 72.0 * 2540.0);
if (w >= pc->custom_min_width && w <= pc->custom_max_width &&
ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-default", col);
ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-ready", col);
ippDelete(col);
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default", NULL, buf);
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-ready", NULL, buf);
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default",
+ NULL, buf);
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-ready",
+ NULL, buf);
have_custom_size = 1;
}
}
+
for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
{
if ((ptr = strchr(pwg_size->map.ppd, '.')) != NULL)
{
- /* Page size variant, use original size's PWG name but PPD's
- dimensions and margins.
-
- This way we can associate extra size for overspraying when
- printing borderless with the original page size, for example
- for cfFilterPWGToRaster() to correct original-sized PWG
- Raster to overspray-sized CUPS Raster (for HPLIP for
- example). Filters can also switch to overspray size if the
- original size plus zero margins is requested for a job */
+ // Page size variant, use original size's PWG name but PPD's
+ // dimensions and margins.
+ //
+ // This way we can associate extra size for overspraying when
+ // printing borderless with the original page size, for example
+ // for cfFilterPWGToRaster() to correct original-sized PWG
+ // Raster to overspray-sized CUPS Raster (for HPLIP for
+ // example). Filters can also switch to overspray size if the
+ // original size plus zero margins is requested for a job
pwg_size_t *size;
memmove(buf, pwg_size->map.ppd, ptr - pwg_size->map.ppd);
buf[ptr - pwg_size->map.ppd] = '\0';
for (j = 0, size = pc->sizes; j < pc->num_sizes; j ++, size ++)
- /* Find entry of original size */
+ // Find entry of original size
if (strcasecmp(buf, size->map.ppd) == 0)
{
ptr = size->map.pwg;
}
else
ptr = pwg_size->map.pwg;
- col = create_media_col(ptr, NULL, NULL, pwg_size->width, pwg_size->length, pwg_size->bottom, pwg_size->left, pwg_size->right, pwg_size->top);
+ col = create_media_col(ptr, NULL, NULL, pwg_size->width, pwg_size->length,
+ pwg_size->bottom, pwg_size->left, pwg_size->right,
+ pwg_size->top);
if (is_texttotext)
{
- /* Add info about the number of lines and number of columns defined in
- the PPD for each page size to the appropriate media-col-database
- entries */
+ // Add info about the number of lines and number of columns defined in
+ // the PPD for each page size to the appropriate media-col-database
+ // entries
snprintf(buf, sizeof(buf), "%sNumColumns", pwg_size->map.ppd);
if ((ppd_choice = ppdFindMarkedChoice(ppd, buf)) != NULL &&
(j = atoi(ppd_choice->choice)) > 0)
ippDelete(col);
if (!have_custom_size && pwg_size == default_size)
{
- /* media-col-default - Standard size */
- col = create_media_col(ptr, default_source, default_type, pwg_size->width, pwg_size->length, pwg_size->bottom, pwg_size->left, pwg_size->right, pwg_size->top);
+ // media-col-default - Standard size
+ col = create_media_col(ptr, default_source, default_type,
+ pwg_size->width, pwg_size->length,
+ pwg_size->bottom, pwg_size->left,
+ pwg_size->right, pwg_size->top);
ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-default", col);
ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-ready", col);
ippDelete(col);
}
}
- /* media-left-margin-supported */
- for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
+ // media-left-margin-supported
+ for (i = 0, num_margins = 0, pwg_size = pc->sizes;
+ i < pc->num_sizes &&
+ num_margins < (int)(sizeof(margins) / sizeof(margins[0]));
+ i ++, pwg_size ++)
{
for (j = 0; j < num_margins; j ++)
{
}
}
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-left-margin-supported", num_margins, margins);
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-left-margin-supported", num_margins, margins);
- /* media-right-margin-supported */
- for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
+ // media-right-margin-supported
+ for (i = 0, num_margins = 0, pwg_size = pc->sizes;
+ i < pc->num_sizes &&
+ num_margins < (int)(sizeof(margins) / sizeof(margins[0]));
+ i ++, pwg_size ++)
{
for (j = 0; j < num_margins; j ++)
{
}
}
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-right-margin-supported", num_margins, margins);
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-right-margin-supported", num_margins, margins);
- /* media-supported */
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-supported", pc->num_sizes + (ppd->variable_sizes ? 2 : 0), NULL, NULL);
+ // media-supported
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "media-supported",
+ pc->num_sizes + (ppd->variable_sizes ? 2 : 0),
+ NULL, NULL);
for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
ippSetString(attrs, &attr, i, pwg_size->map.pwg);
if (ppd->variable_sizes)
ippSetString(attrs, &attr, pc->num_sizes + 1, pc->custom_max_keyword);
}
- /* media-size-supported */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-size-supported", pc->num_sizes + (ppd->variable_sizes ? 1 : 0), NULL);
+ // media-size-supported
+ attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-size-supported",
+ pc->num_sizes + (ppd->variable_sizes ? 1 : 0), NULL);
for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
{
col = create_media_size(pwg_size->width, pwg_size->length);
ippDelete(col);
}
- /* media-source-supported */
+ // media-source-supported
if (pc->num_sources > 0)
{
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-source-supported", pc->num_sources, NULL, NULL);
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "media-source-supported", pc->num_sources,
+ NULL, NULL);
for (i = 0, pwg_map = pc->sources; i < pc->num_sources; i ++, pwg_map ++)
ippSetString(attrs, &attr, i, pwg_map->pwg);
}
else
{
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-source-supported", NULL, "auto");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "media-source-supported", NULL, "auto");
}
- /* media-top-margin-supported */
- for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
+ // media-top-margin-supported
+ for (i = 0, num_margins = 0, pwg_size = pc->sizes;
+ i < pc->num_sizes &&
+ num_margins < (int)(sizeof(margins) / sizeof(margins[0]));
+ i ++, pwg_size ++)
{
for (j = 0; j < num_margins; j ++)
{
}
}
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-top-margin-supported", num_margins, margins);
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-top-margin-supported", num_margins, margins);
- /* media-type-supported */
+ // media-type-supported
if (pc->num_types > 0)
{
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-type-supported", pc->num_types, NULL, NULL);
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "media-type-supported", pc->num_types, NULL, NULL);
for (i = 0, pwg_map = pc->types; i < pc->num_types; i ++, pwg_map ++)
ippSetString(attrs, &attr, i, pwg_map->pwg);
}
else
{
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-type-supported", NULL, "auto");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "media-type-supported", NULL, "auto");
}
- /* orientation-requested-default */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-default", IPP_ORIENT_PORTRAIT);
+ // orientation-requested-default
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
+ "orientation-requested-default", IPP_ORIENT_PORTRAIT);
- /* orientation-requested-supported */
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-supported", (int)(sizeof(orientation_requested_supported) / sizeof(orientation_requested_supported[0])), orientation_requested_supported);
+ // orientation-requested-supported
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
+ "orientation-requested-supported",
+ (int)(sizeof(orientation_requested_supported) /
+ sizeof(orientation_requested_supported[0])),
+ orientation_requested_supported);
- /* output-bin-supported and output-bin-default */
+ // output-bin-supported and output-bin-default
def_found = 0;
if (pc->num_bins > 0)
{
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "output-bin-supported", pc->num_bins, NULL, NULL);
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-supported", pc->num_bins, NULL, NULL);
for (i = 0, pwg_map = pc->bins; i < pc->num_bins; i ++, pwg_map ++)
{
ippSetString(attrs, &attr, i, pwg_map->pwg);
}
if (face_up == 0 && order != 0)
face_up = -order;
- snprintf(buf, sizeof(buf), "type=unknown;maxcapacity=-2;remaining=-2;status=5;stackingorder=%s;pagedelivery=%s;name=%s",
+ snprintf(buf, sizeof(buf),
+ "type=unknown;maxcapacity=-2;remaining=-2;status=5;stackingorder=%s;pagedelivery=%s;name=%s",
(order == -1 ? "lastToFirst" :
(order == 1 ? "firstToLast" :
"unknown")),
order = (strcasecmp(default_output_order, "Normal") == 0 ? 1 :
(strcasecmp(default_output_order, "Reverse") == 0 ? -1 : 1));
def_output_bin = (order == 1 ? "face-down" : "face-up");
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "output-bin-supported", NULL, def_output_bin);
- snprintf(buf, sizeof(buf), "type=unknown;maxcapacity=-2;remaining=-2;status=5;stackingorder=%s;pagedelivery=%s;name=%s",
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-supported", NULL, def_output_bin);
+ snprintf(buf, sizeof(buf),
+ "type=unknown;maxcapacity=-2;remaining=-2;status=5;stackingorder=%s;pagedelivery=%s;name=%s",
(order == -1 ? "lastToFirst" : "firstToLast"),
(order == -1 ? "faceUp" : "faceDown"),
def_output_bin);
ippAddOctetString(attrs, IPP_TAG_PRINTER,
"printer-output-tray", buf, strlen(buf));
}
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "output-bin-default", NULL, def_output_bin);
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-default", NULL, def_output_bin);
- /* overrides-supported */
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "overrides-supported", (int)(sizeof(overrides_supported) / sizeof(overrides_supported[0])), NULL, overrides_supported);
+ // overrides-supported
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "overrides-supported",
+ (int)(sizeof(overrides_supported) /
+ sizeof(overrides_supported[0])),
+ NULL, overrides_supported);
- /* page-ranges-supported */
+ // page-ranges-supported
ippAddBoolean(attrs, IPP_TAG_PRINTER, "page-ranges-supported", 1);
- /* pages-per-minute */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "pages-per-minute", ppd->throughput);
+ // pages-per-minute
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "pages-per-minute",
+ ppd->throughput);
- /* pages-per-minute-color */
+ // pages-per-minute-color
if (ppd->color_device)
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "pages-per-minute-color", ppd->throughput);
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "pages-per-minute-color", ppd->throughput);
- /* print-color-mode-default */
+ // print-color-mode-default
bool mono =
(ppd->color_device &&
(((ppd_choice = ppdFindMarkedChoice(ppd, "ColorModel")) != NULL &&
strcasestr(ppd_choice->choice, "bw") ||
strcasestr(ppd_choice->choice, "bi-level") ||
strcasestr(ppd_choice->choice, "bi_level")))));
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "print-color-mode-default", NULL, ppd->color_device && !mono ? "auto" : "monochrome");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-color-mode-default", NULL,
+ ppd->color_device && !mono ? "auto" : "monochrome");
- /* print-color-mode-supported */
+ // print-color-mode-supported
if (ppd->color_device)
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-color-mode-supported", (int)(sizeof(print_color_mode_supported_color) / sizeof(print_color_mode_supported_color[0])), NULL, print_color_mode_supported_color);
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "print-color-mode-supported",
+ (int)(sizeof(print_color_mode_supported_color) /
+ sizeof(print_color_mode_supported_color[0])),
+ NULL, print_color_mode_supported_color);
else
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-color-mode-supported", (int)(sizeof(print_color_mode_supported) / sizeof(print_color_mode_supported[0])), NULL, print_color_mode_supported);
-
- /* print-content-optimize-default */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-content-optimize-default", NULL, "auto");
-
- /* print-content-optimize-supported */
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-content-optimize-supported", (int)(sizeof(print_content_optimize_supported) / sizeof(print_content_optimize_supported[0])), NULL, print_content_optimize_supported);
-
- /* print-quality-default */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-default", IPP_QUALITY_NORMAL);
-
- /* print-quality-supported */
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-supported", (int)(sizeof(print_quality_supported) / sizeof(print_quality_supported[0])), print_quality_supported);
-
- /* print-rendering-intent-default */
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "print-color-mode-supported",
+ (int)(sizeof(print_color_mode_supported) /
+ sizeof(print_color_mode_supported[0])),
+ NULL, print_color_mode_supported);
+
+ // print-content-optimize-default
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "print-content-optimize-default", NULL, "auto");
+
+ // print-content-optimize-supported
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "print-content-optimize-supported",
+ (int)(sizeof(print_content_optimize_supported) /
+ sizeof(print_content_optimize_supported[0])),
+ NULL, print_content_optimize_supported);
+
+ // print-quality-default
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-default",
+ IPP_QUALITY_NORMAL);
+
+ // print-quality-supported
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
+ "print-quality-supported",
+ (int)(sizeof(print_quality_supported) /
+ sizeof(print_quality_supported[0])),
+ print_quality_supported);
+
+ // print-rendering-intent-default
if ((ppd_choice =
ppdFindMarkedChoice(ppd, "cupsRenderingIntent")) != NULL ||
(ppd_choice =
ppdFindMarkedChoice(ppd, "print-rendering-intent")) != NULL)
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "print-rendering-intent-default", NULL, ppd_choice->choice);
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-rendering-intent-default", NULL, ppd_choice->choice);
else
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-rendering-intent-default", NULL, "auto");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "print-rendering-intent-default", NULL, "auto");
- /* print-rendering-intent-supported */
+ // print-rendering-intent-supported
if (((ppd_option = ppdFindOption(ppd, "cupsRenderingIntent")) != NULL ||
(ppd_option = ppdFindOption(ppd, "print-rendering-intent")) != NULL) &&
ppd_option->num_choices > 0)
{
for (i = 0; i < ppd_option->num_choices && i < sizeof(items); i ++)
items[i] = ppd_option->choices[i].choice;
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "print-rendering-intent-supported", i, NULL, items);
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-rendering-intent-supported", i, NULL, items);
}
else
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-rendering-intent-supported", NULL, "auto");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "print-rendering-intent-supported", NULL, "auto");
- /* printer-device-id */
+ // printer-device-id
if ((ppd_attr = ppdFindAttr(ppd, "1284DeviceId", NULL)) != NULL)
{
- /*
- * Use the device ID string from the PPD...
- */
+ //
+ // Use the device ID string from the PPD...
+ //
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, ppd_attr->value);
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id",
+ NULL, ppd_attr->value);
}
else
{
- /*
- * Synthesize a device ID string...
- */
+ //
+ // Synthesize a device ID string...
+ //
- char device_id[1024]; /* Device ID string */
+ char device_id[1024]; // Device ID string
- snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;%s", ppd->manufacturer, ppd->modelname, cmd);
+ snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;%s",
+ ppd->manufacturer, ppd->modelname, cmd);
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, device_id);
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id",
+ NULL, device_id);
}
- /* printer-info */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info", NULL, ppd->nickname);
+ // printer-info
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info", NULL,
+ ppd->nickname);
- /* printer-input-tray */
+ // printer-input-tray
if (pc->num_sources > 0)
{
for (i = 0, attr = NULL; i < pc->num_sources; i ++)
{
- char input_tray[1024]; /* printer-input-tray value */
+ char input_tray[1024]; // printer-input-tray value
- if (!strcmp(pc->sources[i].pwg, "manual") || strstr(pc->sources[i].pwg, "-man") != NULL)
- snprintf(input_tray, sizeof(input_tray), "type=sheetFeedManual;mediafeed=0;mediaxfeed=0;maxcapacity=1;level=-2;status=0;name=%s", pc->sources[i].pwg);
+ if (!strcmp(pc->sources[i].pwg, "manual") ||
+ strstr(pc->sources[i].pwg, "-man") != NULL)
+ snprintf(input_tray, sizeof(input_tray),
+ "type=sheetFeedManual;mediafeed=0;mediaxfeed=0;maxcapacity=1;level=-2;status=0;name=%s",
+ pc->sources[i].pwg);
else
- snprintf(input_tray, sizeof(input_tray), "type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=250;level=125;status=0;name=%s", pc->sources[i].pwg);
+ snprintf(input_tray, sizeof(input_tray),
+ "type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=250;level=125;status=0;name=%s",
+ pc->sources[i].pwg);
if (attr)
ippSetOctetString(attrs, &attr, i, input_tray, (int)strlen(input_tray));
else
- attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray", input_tray, (int)strlen(input_tray));
+ attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray",
+ input_tray, (int)strlen(input_tray));
}
}
else
{
- static const char *printer_input_tray = "type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=-2;level=-2;status=0;name=auto";
+ static const char *printer_input_tray =
+ "type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=-2;level=-2;status=0;name=auto";
- ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray", printer_input_tray, (int)strlen(printer_input_tray));
+ ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray",
+ printer_input_tray, (int)strlen(printer_input_tray));
}
- /* printer-make-andXS-model */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-make-and-model", NULL, ppd->nickname);
+ // printer-make-andXS-model
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-make-and-model",
+ NULL, ppd->nickname);
- /* printer-resolution-default */
- ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-default", IPP_RES_PER_INCH, xres, yres);
+ // printer-resolution-default
+ ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-default",
+ IPP_RES_PER_INCH, xres, yres);
- /* printer-resolution-supported */
- ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-supported", IPP_RES_PER_INCH, xres, yres);
+ // printer-resolution-supported
+ ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-supported",
+ IPP_RES_PER_INCH, xres, yres);
- /* sides-default */
+ // sides-default
if (pc->sides_option && pc->sides_2sided_long &&
ppdIsMarked(ppd, pc->sides_option, pc->sides_2sided_long))
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-default", NULL, "two-sided-long-edge");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "sides-default", NULL, "two-sided-long-edge");
else if (pc->sides_option && pc->sides_2sided_short &&
ppdIsMarked(ppd, pc->sides_option, pc->sides_2sided_short))
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-default", NULL, "two-sided-long-short");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "sides-default", NULL, "two-sided-long-short");
else
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-default", NULL, "one-sided");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "sides-default", NULL, "one-sided");
- /* sides-supported */
+ // sides-supported
if (pc->sides_option && pc->sides_2sided_long)
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-supported", (int)(sizeof(sides_supported) / sizeof(sides_supported[0])), NULL, sides_supported);
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "sides-supported",
+ (int)(sizeof(sides_supported) / sizeof(sides_supported[0])),
+ NULL, sides_supported);
else
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-supported", NULL, "one-sided");
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ "sides-supported", NULL, "one-sided");
- /* Extra attributes for "texttotext" filter */
+ // Extra attributes for "texttotext" filter
if (is_texttotext)
{
if ((ppd_choice = ppdFindMarkedChoice(ppd, "OverLongLines")) != NULL &&
}
- /* Clean up */
+ // Clean up
cupsArrayDelete(docformats);
return (attrs);
}
-/*
- * 'create_media_col()' - Create a media-col value.
- */
-
-static ipp_t * /* O - media-col collection */
-create_media_col(const char *media, /* I - Media name */
- const char *source, /* I - Media source, if any */
- const char *type, /* I - Media type, if any */
- int width, /* I - x-dimension in 2540ths */
- int length, /* I - y-dimension in 2540ths */
- int bottom, /* I - Bottom margin in 2540ths */
- int left, /* I - Left margin in 2540ths */
- int right, /* I - Right margin in 2540ths */
- int top) /* I - Top margin in 2540ths */
+//
+// 'create_media_col()' - Create a media-col value.
+//
+
+static ipp_t * // O - media-col collection
+create_media_col(const char *media, // I - Media name
+ const char *source, // I - Media source, if any
+ const char *type, // I - Media type, if any
+ int width, // I - x-dimension in 2540ths
+ int length, // I - y-dimension in 2540ths
+ int bottom, // I - Bottom margin in 2540ths
+ int left, // I - Left margin in 2540ths
+ int right, // I - Right margin in 2540ths
+ int top) // I - Top margin in 2540ths
{
- ipp_t *media_col = ippNew(), /* media-col value */
+ ipp_t *media_col = ippNew(), // media-col value
*media_size = create_media_size(width, length);
- /* media-size value */
- char media_key[256]; /* media-key value */
- const char *media_key_suffix = ""; /* media-key suffix */
+ // media-size value
+ char media_key[256]; // media-key value
+ const char *media_key_suffix = ""; // media-key suffix
if (bottom == 0 && left == 0 && right == 0 && top == 0)
media_key_suffix = "_borderless";
if (type && source)
- snprintf(media_key, sizeof(media_key), "%s_%s_%s%s", media, source, type, media_key_suffix);
+ snprintf(media_key, sizeof(media_key), "%s_%s_%s%s", media, source,
+ type, media_key_suffix);
else if (type)
- snprintf(media_key, sizeof(media_key), "%s__%s%s", media, type, media_key_suffix);
+ snprintf(media_key, sizeof(media_key), "%s__%s%s", media, type,
+ media_key_suffix);
else if (source)
- snprintf(media_key, sizeof(media_key), "%s_%s%s", media, source, media_key_suffix);
+ snprintf(media_key, sizeof(media_key), "%s_%s%s", media, source,
+ media_key_suffix);
else
snprintf(media_key, sizeof(media_key), "%s%s", media, media_key_suffix);
- ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-key", NULL, media_key);
+ ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-key",
+ NULL, media_key);
ippAddCollection(media_col, IPP_TAG_PRINTER, "media-size", media_size);
- ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-size-name", NULL, media);
+ ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "media-size-name", NULL, media);
if (bottom >= 0)
- ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin", bottom);
+ ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-bottom-margin", bottom);
if (left >= 0)
- ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-left-margin", left);
+ ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-left-margin", left);
if (right >= 0)
- ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-right-margin", right);
+ ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-right-margin", right);
if (top >= 0)
- ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-top-margin", top);
+ ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-top-margin", top);
if (source)
- ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-source", NULL, source);
+ ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "media-source", NULL, source);
if (type)
- ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-type", NULL, type);
+ ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "media-type", NULL, type);
ippDelete(media_size);
}
-/*
- * 'create_media_size()' - Create a media-size value.
- */
+//
+// 'create_media_size()' - Create a media-size value.
+//
-static ipp_t * /* O - media-col collection */
-create_media_size(int width, /* I - x-dimension in 2540ths */
- int length) /* I - y-dimension in 2540ths */
+static ipp_t * // O - media-col collection
+create_media_size(int width, // I - x-dimension in 2540ths
+ int length) // I - y-dimension in 2540ths
{
- ipp_t *media_size = ippNew(); /* media-size value */
+ ipp_t *media_size = ippNew(); // media-size value
- ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "x-dimension", width);
- ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "y-dimension", length);
+ ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "x-dimension",
+ width);
+ ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "y-dimension",
+ length);
return (media_size);
}
-/*
- * 'create_media_size_range()' - Create a media-size range for custom sizes.
- */
+//
+// 'create_media_size_range()' - Create a media-size range for custom sizes.
+//
-static ipp_t * /* O - media-col collection */
-create_media_size_ranges(int min_width, /* I - min x dim in 2540ths */
- int min_length, /* I - nin y dim in 2540ths */
- int max_width, /* I - max x dim in 2540ths */
- int max_length) /* I - max y dim in 2540ths */
+static ipp_t * // O - media-col collection
+create_media_size_ranges(int min_width, // I - min x dim in 2540ths
+ int min_length, // I - nin y dim in 2540ths
+ int max_width, // I - max x dim in 2540ths
+ int max_length) // I - max y dim in 2540ths
{
- ipp_t *media_size_ranges = ippNew(); /* media-size value */
+ ipp_t *media_size_ranges = ippNew(); // media-size value
- ippAddRange(media_size_ranges, IPP_TAG_PRINTER, "x-dimension", min_width, max_width);
- ippAddRange(media_size_ranges, IPP_TAG_PRINTER, "y-dimension", min_length, max_length);
+ ippAddRange(media_size_ranges, IPP_TAG_PRINTER, "x-dimension", min_width,
+ max_width);
+ ippAddRange(media_size_ranges, IPP_TAG_PRINTER, "y-dimension", min_length,
+ max_length);
return (media_size_ranges);
}
-/*
- * PPD color profile attribute lookup functions for libppd.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1993-2005 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "COPYING"
- * which should have been included with this file.
- *
- * Contents:
- *
- * ppdFindColorAttr() - Find a PPD attribute based on the colormodel,
- * media, and resolution.
- * ppdLutLoad() - Load a LUT from a PPD file.
- * ppdRGBLoad() - Load a RGB color profile from a PPD file.
- * ppdCMYKLoad() - Load a CMYK color profile from PPD attributes.
- */
-
-/*
- * Include necessary headers.
- */
+//
+// PPD color profile attribute lookup functions for libppd.
+//
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1993-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+// Contents:
+//
+// ppdFindColorAttr() - Find a PPD attribute based on the colormodel,
+// media, and resolution.
+// ppdLutLoad() - Load a LUT from a PPD file.
+// ppdRGBLoad() - Load a RGB color profile from a PPD file.
+// ppdCMYKLoad() - Load a CMYK color profile from PPD attributes.
+//
+
+//
+// Include necessary headers.
+//
#include <config.h>
#include "ppd.h"
#include <ctype.h>
-/*
- * 'ppdFindColorAttr()' - Find a PPD attribute based on the colormodel,
- * media, and resolution.
- */
-
-ppd_attr_t * /* O - Matching attribute or
- NULL */
-ppdFindColorAttr(ppd_file_t *ppd, /* I - PPD file */
- const char *name, /* I - Attribute name */
- const char *colormodel, /* I - Color model */
- const char *media, /* I - Media type */
- const char *resolution, /* I - Resolution */
- char *spec, /* O - Final selection string */
- int specsize, /* I - Size of string buffer */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Log function data */
+//
+// 'ppdFindColorAttr()' - Find a PPD attribute based on the colormodel,
+// media, and resolution.
+//
+
+ppd_attr_t * // O - Matching attribute or
+ // NULL
+ppdFindColorAttr(ppd_file_t *ppd, // I - PPD file
+ const char *name, // I - Attribute name
+ const char *colormodel, // I - Color model
+ const char *media, // I - Media type
+ const char *resolution, // I - Resolution
+ char *spec, // O - Final selection string
+ int specsize, // I - Size of string buffer
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Log function data
{
- ppd_attr_t *attr; /* Attribute */
+ ppd_attr_t *attr; // Attribute
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !name || !colormodel || !media || !resolution || !spec ||
specsize < IPP_MAX_NAME)
return (NULL);
- /*
- * Look for the attribute with the following keywords:
- *
- * ColorModel.MediaType.Resolution
- * ColorModel.Resolution
- * ColorModel
- * MediaType.Resolution
- * MediaType
- * Resolution
- * ""
- */
+ //
+ // Look for the attribute with the following keywords:
+ //
+ // ColorModel.MediaType.Resolution
+ // ColorModel.Resolution
+ // ColorModel
+ // MediaType.Resolution
+ // MediaType
+ // Resolution
+ // ""
+ //
snprintf(spec, specsize, "%s.%s.%s", colormodel, media, resolution);
if (log) log(ld, CF_LOGLEVEL_DEBUG,
}
-/*
- * 'ppdLutLoad()' - Load a LUT from a PPD file.
- */
-
-cf_lut_t * /* O - New lookup table */
-ppdLutLoad(ppd_file_t *ppd, /* I - PPD file */
- const char *colormodel, /* I - Color model */
- const char *media, /* I - Media type */
- const char *resolution, /* I - Resolution */
- const char *ink, /* I - Ink name */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Log function data */
+//
+// 'ppdLutLoad()' - Load a LUT from a PPD file.
+//
+
+cf_lut_t * // O - New lookup table
+ppdLutLoad(ppd_file_t *ppd, // I - PPD file
+ const char *colormodel, // I - Color model
+ const char *media, // I - Media type
+ const char *resolution, // I - Resolution
+ const char *ink, // I - Ink name
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Log function data
{
- char name[PPD_MAX_NAME], /* Attribute name */
- spec[PPD_MAX_NAME]; /* Attribute spec */
- ppd_attr_t *attr; /* Attribute */
- int nvals; /* Number of values */
- float vals[4]; /* Values */
+ char name[PPD_MAX_NAME], // Attribute name
+ spec[PPD_MAX_NAME]; // Attribute spec
+ ppd_attr_t *attr; // Attribute
+ int nvals; // Number of values
+ float vals[4]; // Values
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !colormodel || !media || !resolution || !ink)
return (NULL);
- /*
- * Try to find the LUT values...
- */
+ //
+ // Try to find the LUT values...
+ //
snprintf(name, sizeof(name), "cups%sDither", ink);
}
-/*
- * 'ppdRGBLoad()' - Load a RGB color profile from a PPD file.
- */
+//
+// 'ppdRGBLoad()' - Load a RGB color profile from a PPD file.
+//
-cf_rgb_t * /* O - New color profile */
-ppdRGBLoad(ppd_file_t *ppd, /* I - PPD file */
- const char *colormodel, /* I - Color model */
- const char *media, /* I - Media type */
- const char *resolution, /* I - Resolution */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Log function data */
+cf_rgb_t * // O - New color profile
+ppdRGBLoad(ppd_file_t *ppd, // I - PPD file
+ const char *colormodel, // I - Color model
+ const char *media, // I - Media type
+ const char *resolution, // I - Resolution
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Log function data
{
- int i, /* Looping var */
- cube_size, /* Size of color lookup cube */
- num_channels, /* Number of color channels */
- num_samples; /* Number of color samples */
- cf_sample_t *samples; /* Color samples */
- float values[7]; /* Color sample values */
- char spec[IPP_MAX_NAME]; /* Profile name */
- ppd_attr_t *attr; /* Attribute from PPD file */
- cf_rgb_t *rgbptr; /* RGB color profile */
-
-
- /*
- * Find the following attributes:
- *
- * cupsRGBProfile - Specifies the cube size, number of channels, and
- * number of samples
- * cupsRGBSample - Specifies an RGB to CMYK color sample
- */
+ int i, // Looping var
+ cube_size, // Size of color lookup cube
+ num_channels, // Number of color channels
+ num_samples; // Number of color samples
+ cf_sample_t *samples; // Color samples
+ float values[7]; // Color sample values
+ char spec[IPP_MAX_NAME]; // Profile name
+ ppd_attr_t *attr; // Attribute from PPD file
+ cf_rgb_t *rgbptr; // RGB color profile
+
+
+ //
+ // Find the following attributes:
+ //
+ // cupsRGBProfile - Specifies the cube size, number of channels, and
+ // number of samples
+ // cupsRGBSample - Specifies an RGB to CMYK color sample
+ //
if ((attr = ppdFindColorAttr(ppd, "cupsRGBProfile", colormodel, media,
resolution, spec, sizeof(spec), log, ld)) == NULL)
return (NULL);
}
- /*
- * Allocate memory for the samples and read them...
- */
+ //
+ // Allocate memory for the samples and read them...
+ //
if ((samples = calloc(num_samples, sizeof(cf_sample_t))) == NULL)
{
return (NULL);
}
- /*
- * Read all of the samples...
- */
+ //
+ // Read all of the samples...
+ //
for (i = 0; i < num_samples; i ++)
if ((attr = ppdFindNextAttr(ppd, "cupsRGBSample", spec)) == NULL)
samples[i].colors[3] = (int)(255.0 * values[6] + 0.5);
}
- /*
- * If everything went OK, create the color profile...
- */
+ //
+ // If everything went OK, create the color profile...
+ //
if (i == num_samples)
rgbptr = cfRGBNew(num_samples, samples, cube_size, num_channels);
else
rgbptr = NULL;
- /*
- * Free the temporary sample array and return...
- */
+ //
+ // Free the temporary sample array and return...
+ //
free(samples);
}
-/*
- * 'ppdCMYKLoad()' - Load a CMYK color profile from PPD attributes.
- */
+//
+// 'ppdCMYKLoad()' - Load a CMYK color profile from PPD attributes.
+//
-cf_cmyk_t * /* O - CMYK color separation */
-ppdCMYKLoad(ppd_file_t *ppd, /* I - PPD file */
- const char *colormodel, /* I - ColorModel value */
- const char *media, /* I - MediaType value */
- const char *resolution, /* I - Resolution value */
- cf_logfunc_t log, /* I - Log function */
- void *ld) /* I - Log function data */
+cf_cmyk_t * // O - CMYK color separation
+ppdCMYKLoad(ppd_file_t *ppd, // I - PPD file
+ const char *colormodel, // I - ColorModel value
+ const char *media, // I - MediaType value
+ const char *resolution, // I - Resolution value
+ cf_logfunc_t log, // I - Log function
+ void *ld) // I - Log function data
{
- cf_cmyk_t *cmyk; /* CMYK color separation */
- char spec[IPP_MAX_NAME]; /* Profile name */
- ppd_attr_t *attr; /* Attribute from PPD file */
- int num_channels; /* Number of color components */
- float gamval, /* Gamma correction value */
- density, /* Density value */
- light, /* Light ink limit */
- dark, /* Light ink cut-off */
- lower, /* Start of black ink */
- upper; /* End of color ink */
- int num_xypoints; /* Number of X,Y points */
- float xypoints[100 * 2], /* X,Y points */
- *xyptr; /* Current X,Y point */
-
-
- /*
- * Range check input...
- */
+ cf_cmyk_t *cmyk; // CMYK color separation
+ char spec[IPP_MAX_NAME]; // Profile name
+ ppd_attr_t *attr; // Attribute from PPD file
+ int num_channels; // Number of color components
+ float gamval, // Gamma correction value
+ density, // Density value
+ light, // Light ink limit
+ dark, // Light ink cut-off
+ lower, // Start of black ink
+ upper; // End of color ink
+ int num_xypoints; // Number of X,Y points
+ float xypoints[100 * 2], // X,Y points
+ *xyptr; // Current X,Y point
+
+
+ //
+ // Range check input...
+ //
if (ppd == NULL || colormodel == NULL || resolution == NULL || media == NULL)
return (NULL);
- /*
- * Find the following attributes:
- *
- * cupsAllGamma - Set default curve using gamma + density
- * cupsAllXY - Set default curve using XY points
- * cupsBlackGamma - Set black curve using gamma + density
- * cupsBlackGeneration - Set black generation
- * cupsBlackLightDark - Set black light/dark transition
- * cupsBlackXY - Set black curve using XY points
- * cupsCyanGamma - Set cyan curve using gamma + density
- * cupsCyanLightDark - Set cyan light/dark transition
- * cupsCyanXY - Set cyan curve using XY points
- * cupsInkChannels - Set number of color channels
- * cupsInkLimit - Set total ink limit
- * cupsLightBlackGamma - Set light black curve using gamma + density
- * cupsLightBlackXY - Set light black curve using XY points
- * cupsLightCyanGamma - Set light cyan curve using gamma + density
- * cupsLightCyanXY - Set light cyan curve using XY points
- * cupsLightMagentaGamma - Set light magenta curve using gamma + density
- * cupsLightMagentaXY - Set light magenta curve using XY points
- * cupsMagentaGamma - Set magenta curve using gamma + density
- * cupsMagentaLightDark - Set magenta light/dark transition
- * cupsMagentaXY - Set magenta curve using XY points
- * cupsYellowGamma - Set yellow curve using gamma + density
- * cupsYellowXY - Set yellow curve using XY points
- *
- * The only required attribute is cupsInkChannels.
- *
- * The *XY attributes have precedence over the *Gamma attributes, and
- * the *Light* attributes have precedence over the corresponding
- * *LightDark* attributes.
- */
-
- /*
- * Get the required cupsInkChannels attribute...
- */
-
- if ((attr = ppdFindColorAttr(ppd, "cupsInkChannels", colormodel, media,
- resolution, spec, sizeof(spec), log, ld)) == NULL)
+ //
+ // Find the following attributes:
+ //
+ // cupsAllGamma - Set default curve using gamma + density
+ // cupsAllXY - Set default curve using XY points
+ // cupsBlackGamma - Set black curve using gamma + density
+ // cupsBlackGeneration - Set black generation
+ // cupsBlackLightDark - Set black light/dark transition
+ // cupsBlackXY - Set black curve using XY points
+ // cupsCyanGamma - Set cyan curve using gamma + density
+ // cupsCyanLightDark - Set cyan light/dark transition
+ // cupsCyanXY - Set cyan curve using XY points
+ // cupsInkChannels - Set number of color channels
+ // cupsInkLimit - Set total ink limit
+ // cupsLightBlackGamma - Set light black curve using gamma + density
+ // cupsLightBlackXY - Set light black curve using XY points
+ // cupsLightCyanGamma - Set light cyan curve using gamma + density
+ // cupsLightCyanXY - Set light cyan curve using XY points
+ // cupsLightMagentaGamma - Set light magenta curve using gamma + density
+ // cupsLightMagentaXY - Set light magenta curve using XY points
+ // cupsMagentaGamma - Set magenta curve using gamma + density
+ // cupsMagentaLightDark - Set magenta light/dark transition
+ // cupsMagentaXY - Set magenta curve using XY points
+ // cupsYellowGamma - Set yellow curve using gamma + density
+ // cupsYellowXY - Set yellow curve using XY points
+ //
+ // The only required attribute is cupsInkChannels.
+ //
+ // The *XY attributes have precedence over the *Gamma attributes, and
+ // the *Light* attributes have precedence over the corresponding
+ // *LightDark* attributes.
+ //
+
+ //
+ // Get the required cupsInkChannels attribute...
+ //
+
+ if ((attr =
+ ppdFindColorAttr(ppd, "cupsInkChannels", colormodel, media,
+ resolution, spec, sizeof(spec), log, ld)) == NULL)
return (NULL);
num_channels = atoi(attr->value);
if ((cmyk = cfCMYKNew(num_channels)) == NULL)
return (NULL);
- /*
- * Get the optional cupsInkLimit attribute...
- */
+ //
+ // Get the optional cupsInkLimit attribute...
+ //
if ((attr = ppdFindColorAttr(ppd, "cupsInkLimit", colormodel, media,
resolution, spec, sizeof(spec), log, ld)) != NULL)
cfCMYKSetInkLimit(cmyk, atof(attr->value));
- /*
- * Get the optional cupsBlackGeneration attribute...
- */
+ //
+ // Get the optional cupsBlackGeneration attribute...
+ //
if ((attr = ppdFindColorAttr(ppd, "cupsBlackGeneration", colormodel, media,
resolution, spec, sizeof(spec), log, ld)) != NULL)
cfCMYKSetBlack(cmyk, lower, upper, log, ld);
}
- /*
- * Get the optional cupsBlackXY or cupsBlackGamma attributes...
- */
+ //
+ // Get the optional cupsBlackXY or cupsBlackGamma attributes...
+ //
if (num_channels != 3)
{
if (num_channels > 2)
{
- /*
- * Get the optional cupsCyanXY or cupsCyanGamma attributes...
- */
+ //
+ // Get the optional cupsCyanXY or cupsCyanGamma attributes...
+ //
if ((attr = ppdFindColorAttr(ppd, "cupsCyanXY", colormodel, media,
resolution, spec, sizeof(spec), log, ld)) != NULL)
cfCMYKSetGamma(cmyk, 0, gamval, density, log, ld);
}
- /*
- * Get the optional cupsMagentaXY or cupsMagentaGamma attributes...
- */
+ //
+ // Get the optional cupsMagentaXY or cupsMagentaGamma attributes...
+ //
if ((attr = ppdFindColorAttr(ppd, "cupsMagentaXY", colormodel, media,
resolution, spec, sizeof(spec), log, ld)) != NULL)
break;
}
}
- else if ((attr = ppdFindColorAttr(ppd, "cupsMagentaGamma", colormodel, media,
- resolution, spec, sizeof(spec), log, ld)) !=
+ else if ((attr = ppdFindColorAttr(ppd, "cupsMagentaGamma", colormodel,
+ media, resolution, spec, sizeof(spec),
+ log, ld)) !=
NULL)
{
if (sscanf(attr->value, "%f%f", &gamval, &density) == 2)
}
}
- /*
- * Get the optional cupsYellowXY or cupsYellowGamma attributes...
- */
+ //
+ // Get the optional cupsYellowXY or cupsYellowGamma attributes...
+ //
if ((attr = ppdFindColorAttr(ppd, "cupsYellowXY", colormodel, media,
resolution, spec, sizeof(spec), log, ld)) != NULL)
}
}
- /*
- * Get the optional cupsLightBlackXY, cupsLightBlackGamma, or
- * cupsBlackLtDk attributes...
- */
+ //
+ // Get the optional cupsLightBlackXY, cupsLightBlackGamma, or
+ // cupsBlackLtDk attributes...
+ //
if (num_channels == 2 || num_channels == 7)
{
if (num_channels >= 6)
{
- /*
- * Get the optional cupsLightCyanXY, cupsLightCyanGamma, or
- * cupsCyanLtDk attributes...
- */
+ //
+ // Get the optional cupsLightCyanXY, cupsLightCyanGamma, or
+ // cupsCyanLtDk attributes...
+ //
if ((attr = ppdFindColorAttr(ppd, "cupsLightCyanXY", colormodel, media,
resolution, spec, sizeof(spec), log, ld)) != NULL)
"No light cyan attribute found for %s!",
spec);
- /*
- * Get the optional cupsLightMagentaXY, cupsLightMagentaGamma, or
- * cupsMagentaLtDk attributes...
- */
+ //
+ // Get the optional cupsLightMagentaXY, cupsLightMagentaGamma, or
+ // cupsMagentaLtDk attributes...
+ //
if ((attr = ppdFindColorAttr(ppd, "cupsLightMagentaXY", colormodel, media,
resolution, spec, sizeof(spec), log, ld)) != NULL)
spec);
}
- /*
- * Return the new profile...
- */
+ //
+ // Return the new profile...
+ //
return (cmyk);
}
-/*
- * PPD localization routines for libppd.
- *
- * Copyright 2007-2018 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
-
-/*
- * Include necessary headers.
- */
+//
+// PPD localization routines for libppd.
+//
+// Copyright 2007-2018 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
+
+//
+// Include necessary headers.
+//
#include "string-private.h"
#include "language-private.h"
#include "debug-internal.h"
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static cups_lang_t *ppd_ll_CC(char *ll_CC, size_t ll_CC_size);
-/*
- * 'ppdLocalize()' - Localize the PPD file to the current locale.
- *
- * All groups, options, and choices are localized, as are ICC profile
- * descriptions, printer presets, and custom option parameters. Each
- * localized string uses the UTF-8 character encoding.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdLocalize()' - Localize the PPD file to the current locale.
+//
+// All groups, options, and choices are localized, as are ICC profile
+// descriptions, printer presets, and custom option parameters. Each
+// localized string uses the UTF-8 character encoding.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-int /* O - 0 on success, -1 on error */
-ppdLocalize(ppd_file_t *ppd) /* I - PPD file */
+int // O - 0 on success, -1 on error
+ppdLocalize(ppd_file_t *ppd) // I - PPD file
{
- int i, j, k; /* Looping vars */
- ppd_group_t *group; /* Current group */
- ppd_option_t *option; /* Current option */
- ppd_choice_t *choice; /* Current choice */
- ppd_coption_t *coption; /* Current custom option */
- ppd_cparam_t *cparam; /* Current custom parameter */
- ppd_attr_t *attr, /* Current attribute */
- *locattr; /* Localized attribute */
- char ckeyword[PPD_MAX_NAME], /* Custom keyword */
- ll_CC[6]; /* Language + country locale */
-
-
- /*
- * Range check input...
- */
+ int i, j, k; // Looping vars
+ ppd_group_t *group; // Current group
+ ppd_option_t *option; // Current option
+ ppd_choice_t *choice; // Current choice
+ ppd_coption_t *coption; // Current custom option
+ ppd_cparam_t *cparam; // Current custom parameter
+ ppd_attr_t *attr, // Current attribute
+ *locattr; // Localized attribute
+ char ckeyword[PPD_MAX_NAME], // Custom keyword
+ ll_CC[6]; // Language + country locale
+
+
+ //
+ // Range check input...
+ //
DEBUG_printf(("ppdLocalize(ppd=%p)", ppd));
if (!ppd)
return (-1);
- /*
- * Get the default language...
- */
+ //
+ // Get the default language...
+ //
ppd_ll_CC(ll_CC, sizeof(ll_CC));
- /*
- * Now lookup all of the groups, options, choices, etc.
- */
+ //
+ // Now lookup all of the groups, options, choices, etc.
+ //
for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
{
ll_CC)) != NULL)
strlcpy(group->text, locattr->text, sizeof(group->text));
- for (j = group->num_options, option = group->options; j > 0; j --, option ++)
+ for (j = group->num_options, option = group->options; j > 0;
+ j --, option ++)
{
if ((locattr = ppdLocalizedAttr(ppd, "Translation", option->keyword,
ll_CC)) != NULL)
}
}
- /*
- * Translate any custom parameters...
- */
+ //
+ // Translate any custom parameters...
+ //
for (coption = (ppd_coption_t *)cupsArrayFirst(ppd->coptions);
coption;
}
}
- /*
- * Translate ICC profile names...
- */
+ //
+ // Translate ICC profile names...
+ //
if ((attr = ppdFindAttr(ppd, "APCustomColorMatchingName", NULL)) != NULL)
{
cupsArrayRestore(ppd->sorted_attrs);
}
- /*
- * Translate printer presets...
- */
+ //
+ // Translate printer presets...
+ //
for (attr = ppdFindAttr(ppd, "APPrinterPreset", NULL);
attr;
}
-/*
- * 'ppdLocalizeAttr()' - Localize an attribute.
- *
- * This function uses the current locale to find the localized attribute for
- * the given main and option keywords. If no localized version of the
- * attribute exists for the current locale, the unlocalized version is returned.
- */
-
-ppd_attr_t * /* O - Localized attribute or @code NULL@ if none exists */
-ppdLocalizeAttr(ppd_file_t *ppd, /* I - PPD file */
- const char *keyword, /* I - Main keyword */
- const char *spec) /* I - Option keyword or @code NULL@ for none */
+//
+// 'ppdLocalizeAttr()' - Localize an attribute.
+//
+// This function uses the current locale to find the localized attribute for
+// the given main and option keywords. If no localized version of the
+// attribute exists for the current locale, the unlocalized version is returned.
+//
+
+ppd_attr_t * // O - Localized attribute or
+ // @code NULL@ if none exists
+ppdLocalizeAttr(ppd_file_t *ppd, // I - PPD file
+ const char *keyword, // I - Main keyword
+ const char *spec) // I - Option keyword or @code NULL@
+ // for none
{
- ppd_attr_t *locattr; /* Localized attribute */
- char ll_CC[6]; /* Language + country locale */
+ ppd_attr_t *locattr; // Localized attribute
+ char ll_CC[6]; // Language + country locale
- /*
- * Get the default language...
- */
+ //
+ // Get the default language...
+ //
ppd_ll_CC(ll_CC, sizeof(ll_CC));
- /*
- * Find the localized attribute...
- */
+ //
+ // Find the localized attribute...
+ //
if (spec)
locattr = ppdLocalizedAttr(ppd, keyword, spec, ll_CC);
}
-/*
- * 'ppdLocalizeIPPReason()' - Get the localized version of a cupsIPPReason
- * attribute.
- *
- * This function uses the current locale to find the corresponding reason
- * text or URI from the attribute value. If "scheme" is NULL or "text",
- * the returned value contains human-readable (UTF-8) text from the translation
- * string or attribute value. Otherwise the corresponding URI is returned.
- *
- * If no value of the requested scheme can be found, NULL is returned.
- *
- * @since CUPS 1.3/macOS 10.5@
- */
-
-const char * /* O - Value or NULL if not found */
+//
+// 'ppdLocalizeIPPReason()' - Get the localized version of a cupsIPPReason
+// attribute.
+//
+// This function uses the current locale to find the corresponding reason
+// text or URI from the attribute value. If "scheme" is NULL or "text",
+// the returned value contains human-readable (UTF-8) text from the translation
+// string or attribute value. Otherwise the corresponding URI is returned.
+//
+// If no value of the requested scheme can be found, NULL is returned.
+//
+// @since CUPS 1.3/macOS 10.5@
+//
+
+const char * // O - Value or NULL if not found
ppdLocalizeIPPReason(
- ppd_file_t *ppd, /* I - PPD file */
- const char *reason, /* I - IPP reason keyword to look up */
- const char *scheme, /* I - URI scheme or NULL for text */
- char *buffer, /* I - Value buffer */
- size_t bufsize) /* I - Size of value buffer */
+ ppd_file_t *ppd, // I - PPD file
+ const char *reason, // I - IPP reason keyword to look up
+ const char *scheme, // I - URI scheme or NULL for text
+ char *buffer, // I - Value buffer
+ size_t bufsize) // I - Size of value buffer
{
- cups_lang_t *lang; /* Current language */
- ppd_attr_t *locattr; /* Localized attribute */
- char ll_CC[6], /* Language + country locale */
- *bufptr, /* Pointer into buffer */
- *bufend, /* Pointer to end of buffer */
- *valptr; /* Pointer into value */
- int ch; /* Hex-encoded character */
- size_t schemelen; /* Length of scheme name */
+ cups_lang_t *lang; // Current language
+ ppd_attr_t *locattr; // Localized attribute
+ char ll_CC[6], // Language + country locale
+ *bufptr, // Pointer into buffer
+ *bufend, // Pointer to end of buffer
+ *valptr; // Pointer into value
+ int ch; // Hex-encoded character
+ size_t schemelen; // Length of scheme name
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (buffer)
*buffer = '\0';
!buffer || bufsize < PPD_MAX_TEXT)
return (NULL);
- /*
- * Get the default language...
- */
+ //
+ // Get the default language...
+ //
lang = ppd_ll_CC(ll_CC, sizeof(ll_CC));
- /*
- * Find the localized attribute...
- */
+ //
+ // Find the localized attribute...
+ //
if ((locattr = ppdLocalizedAttr(ppd, "cupsIPPReason", reason,
ll_CC)) == NULL)
{
if (lang && (!scheme || !strcmp(scheme, "text")) && strcmp(reason, "none"))
{
- /*
- * Try to localize a standard printer-state-reason keyword...
- */
+ //
+ // Try to localize a standard printer-state-reason keyword...
+ //
- char msgid[1024], /* State message identifier */
- *ptr; /* Pointer to state suffix */
- const char *message = NULL; /* Localized message */
+ char msgid[1024], // State message identifier
+ *ptr; // Pointer to state suffix
+ const char *message = NULL; // Localized message
snprintf(msgid, sizeof(msgid), "printer-state-reasons.%s", reason);
- if ((ptr = strrchr(msgid, '-')) != NULL && (!strcmp(ptr, "-error") || !strcmp(ptr, "-report") || !strcmp(ptr, "-warning")))
+ if ((ptr = strrchr(msgid, '-')) != NULL &&
+ (!strcmp(ptr, "-error") || !strcmp(ptr, "-report") ||
+ !strcmp(ptr, "-warning")))
*ptr = '\0';
message = _ppdLangString(lang, msgid);
return (NULL);
}
- /*
- * Now find the value we need...
- */
+ //
+ // Now find the value we need...
+ //
bufend = buffer + bufsize - 1;
if (!scheme || !strcmp(scheme, "text"))
{
- /*
- * Copy a text value (either the translation text or text:... URIs from
- * the value...
- */
+ //
+ // Copy a text value (either the translation text or text:... URIs from
+ // the value...
+ //
strlcpy(buffer, locattr->text, bufsize);
{
if (!strncmp(valptr, "text:", 5))
{
- /*
- * Decode text: URI and add to the buffer...
- */
+ //
+ // Decode text: URI and add to the buffer...
+ //
valptr += 5;
if (*valptr == '%' && isxdigit(valptr[1] & 255) &&
isxdigit(valptr[2] & 255))
{
- /*
- * Pull a hex-encoded character from the URI...
- */
+ //
+ // Pull a hex-encoded character from the URI...
+ //
valptr ++;
}
else
{
- /*
- * Skip this URI...
- */
+ //
+ // Skip this URI...
+ //
while (*valptr && !_ppd_isspace(*valptr))
valptr++;
}
- /*
- * Skip whitespace...
- */
+ //
+ // Skip whitespace...
+ //
while (_ppd_isspace(*valptr))
valptr ++;
}
else
{
- /*
- * Copy a URI...
- */
+ //
+ // Copy a URI...
+ //
schemelen = strlen(scheme);
- if (scheme[schemelen - 1] == ':') /* Force scheme to be just the name */
+ if (scheme[schemelen - 1] == ':') // Force scheme to be just the name
schemelen --;
for (valptr = locattr->value, bufptr = buffer; *valptr && bufptr < bufend;)
if ((!strncmp(valptr, scheme, schemelen) && valptr[schemelen] == ':') ||
(*valptr == '/' && !strcmp(scheme, "file")))
{
- /*
- * Copy URI...
- */
+ //
+ // Copy URI...
+ //
while (*valptr && !_ppd_isspace(*valptr) && bufptr < bufend)
*bufptr++ = *valptr++;
}
else
{
- /*
- * Skip this URI...
- */
+ //
+ // Skip this URI...
+ //
while (*valptr && !_ppd_isspace(*valptr))
valptr++;
}
- /*
- * Skip whitespace...
- */
+ //
+ // Skip whitespace...
+ //
while (_ppd_isspace(*valptr))
valptr ++;
}
-/*
- * 'ppdLocalizeMarkerName()' - Get the localized version of a marker-names
- * attribute value.
- *
- * This function uses the current locale to find the corresponding name
- * text from the attribute value. If no localized text for the requested
- * name can be found, @code NULL@ is returned.
- *
- * @since CUPS 1.4/macOS 10.6@
- */
+//
+// 'ppdLocalizeMarkerName()' - Get the localized version of a marker-names
+// attribute value.
+//
+// This function uses the current locale to find the corresponding name
+// text from the attribute value. If no localized text for the requested
+// name can be found, @code NULL@ is returned.
+//
+// @since CUPS 1.4/macOS 10.6@
+//
-const char * /* O - Value or @code NULL@ if not found */
+const char * // O - Value or @code NULL@ if not found
ppdLocalizeMarkerName(
- ppd_file_t *ppd, /* I - PPD file */
- const char *name) /* I - Marker name to look up */
+ ppd_file_t *ppd, // I - PPD file
+ const char *name) // I - Marker name to look up
{
- ppd_attr_t *locattr; /* Localized attribute */
- char ll_CC[6]; /* Language + country locale */
+ ppd_attr_t *locattr; // Localized attribute
+ char ll_CC[6]; // Language + country locale
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !name)
return (NULL);
- /*
- * Get the default language...
- */
+ //
+ // Get the default language...
+ //
ppd_ll_CC(ll_CC, sizeof(ll_CC));
- /*
- * Find the localized attribute...
- */
+ //
+ // Find the localized attribute...
+ //
if ((locattr = ppdLocalizedAttr(ppd, "cupsMarkerName", name,
ll_CC)) == NULL)
}
-/*
- * 'ppdFreeLanguages()' - Free an array of languages from ppdGetLanguages.
- */
+//
+// 'ppdFreeLanguages()' - Free an array of languages from ppdGetLanguages.
+//
void
ppdFreeLanguages(
- cups_array_t *languages) /* I - Languages array */
+ cups_array_t *languages) // I - Languages array
{
- char *language; /* Current language */
+ char *language; // Current language
for (language = (char *)cupsArrayFirst(languages);
}
-/*
- * 'ppdGetLanguages()' - Get an array of languages from a PPD file.
- */
+//
+// 'ppdGetLanguages()' - Get an array of languages from a PPD file.
+//
-cups_array_t * /* O - Languages array */
-ppdGetLanguages(ppd_file_t *ppd) /* I - PPD file */
+cups_array_t * // O - Languages array
+ppdGetLanguages(ppd_file_t *ppd) // I - PPD file
{
- cups_array_t *languages; /* Languages array */
- ppd_attr_t *attr; /* cupsLanguages attribute */
- char *value, /* Copy of attribute value */
- *start, /* Start of current language */
- *ptr; /* Pointer into languages */
+ cups_array_t *languages; // Languages array
+ ppd_attr_t *attr; // cupsLanguages attribute
+ char *value, // Copy of attribute value
+ *start, // Start of current language
+ *ptr; // Pointer into languages
- /*
- * See if we have a cupsLanguages attribute...
- */
+ //
+ // See if we have a cupsLanguages attribute...
+ //
if ((attr = ppdFindAttr(ppd, "cupsLanguages", NULL)) == NULL || !attr->value)
return (NULL);
- /*
- * Yes, load the list...
- */
+ //
+ // Yes, load the list...
+ //
if ((languages = cupsArrayNew((cups_array_func_t)strcmp, NULL)) == NULL)
return (NULL);
for (ptr = value; *ptr;)
{
- /*
- * Skip leading whitespace...
- */
+ //
+ // Skip leading whitespace...
+ //
while (_ppd_isspace(*ptr))
ptr ++;
if (!*ptr)
break;
- /*
- * Find the end of this language name...
- */
+ //
+ // Find the end of this language name...
+ //
for (start = ptr; *ptr && !_ppd_isspace(*ptr); ptr ++);
cupsArrayAdd(languages, strdup(start));
}
- /*
- * Free the temporary string and return either an array with one or more
- * values or a NULL pointer...
- */
+ //
+ // Free the temporary string and return either an array with one or more
+ // values or a NULL pointer...
+ //
free(value);
}
-/*
- * 'ppdHashName()' - Generate a hash value for a device or profile name.
- *
- * This function is primarily used on macOS, but is generally accessible
- * since cupstestppd needs to check for profile name collisions in PPD files...
- */
+//
+// 'ppdHashName()' - Generate a hash value for a device or profile name.
+//
+// This function is primarily used on macOS, but is generally accessible
+// since cupstestppd needs to check for profile name collisions in PPD files...
+//
-unsigned /* O - Hash value */
-ppdHashName(const char *name) /* I - Name to hash */
+unsigned // O - Hash value
+ppdHashName(const char *name) // I - Name to hash
{
- unsigned mult, /* Multiplier */
- hash = 0; /* Hash value */
+ unsigned mult, // Multiplier
+ hash = 0; // Hash value
for (mult = 1; *name && mult <= 128; mult ++, name ++)
}
-/*
- * 'ppdLocalizedAttr()' - Find a localized attribute.
- */
+//
+// 'ppdLocalizedAttr()' - Find a localized attribute.
+//
-ppd_attr_t * /* O - Localized attribute or NULL */
-ppdLocalizedAttr(ppd_file_t *ppd, /* I - PPD file */
- const char *keyword, /* I - Main keyword */
- const char *spec, /* I - Option keyword */
- const char *ll_CC) /* I - Language + country locale */
+ppd_attr_t * // O - Localized attribute or NULL
+ppdLocalizedAttr(ppd_file_t *ppd, // I - PPD file
+ const char *keyword, // I - Main keyword
+ const char *spec, // I - Option keyword
+ const char *ll_CC) // I - Language + country locale
{
- char lkeyword[PPD_MAX_NAME]; /* Localization keyword */
- ppd_attr_t *attr; /* Current attribute */
+ char lkeyword[PPD_MAX_NAME]; // Localization keyword
+ ppd_attr_t *attr; // Current attribute
DEBUG_printf(("4ppdLocalizedAttr(ppd=%p, keyword=\"%s\", spec=\"%s\", "
"ll_CC=\"%s\")", ppd, keyword, spec, ll_CC));
- /*
- * Look for Keyword.ll_CC, then Keyword.ll...
- */
+ //
+ // Look for Keyword.ll_CC, then Keyword.ll...
+ //
snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll_CC, keyword);
if ((attr = ppdFindAttr(ppd, lkeyword, spec)) == NULL)
{
- /*
- * <rdar://problem/22130168>
- *
- * Multiple locales need special handling... Sigh...
- */
+ //
+ // <rdar://problem/22130168>
+ //
+ // Multiple locales need special handling... Sigh...
+ //
if (!strcmp(ll_CC, "zh_HK"))
{
{
if (!strncmp(ll_CC, "ja", 2))
{
- /*
- * Due to a bug in the CUPS DDK 1.1.0 ppdmerge program, Japanese
- * PPD files were incorrectly assigned "jp" as the locale name
- * instead of "ja". Support both the old (incorrect) and new
- * locale names for Japanese...
- */
+ //
+ // Due to a bug in the CUPS DDK 1.1.0 ppdmerge program, Japanese
+ // PPD files were incorrectly assigned "jp" as the locale name
+ // instead of "ja". Support both the old (incorrect) and new
+ // locale names for Japanese...
+ //
snprintf(lkeyword, sizeof(lkeyword), "jp.%s", keyword);
attr = ppdFindAttr(ppd, lkeyword, spec);
}
else if (!strncmp(ll_CC, "nb", 2))
{
- /*
- * Norway has two languages, "Bokmal" (the primary one)
- * and "Nynorsk" (new Norwegian); this code maps from the (currently)
- * recommended "nb" to the previously recommended "no"...
- */
+ //
+ // Norway has two languages, "Bokmal" (the primary one)
+ // and "Nynorsk" (new Norwegian); this code maps from the (currently)
+ // recommended "nb" to the previously recommended "no"...
+ //
snprintf(lkeyword, sizeof(lkeyword), "no.%s", keyword);
attr = ppdFindAttr(ppd, lkeyword, spec);
}
else if (!strncmp(ll_CC, "no", 2))
{
- /*
- * Norway has two languages, "Bokmal" (the primary one)
- * and "Nynorsk" (new Norwegian); we map "no" to "nb" here as
- * recommended by the locale folks...
- */
+ //
+ // Norway has two languages, "Bokmal" (the primary one)
+ // and "Nynorsk" (new Norwegian); we map "no" to "nb" here as
+ // recommended by the locale folks...
+ //
snprintf(lkeyword, sizeof(lkeyword), "nb.%s", keyword);
attr = ppdFindAttr(ppd, lkeyword, spec);
attr->spec, attr->text, attr->value ? attr->value : ""));
else
DEBUG_puts("5ppdLocalizedAttr: NOT FOUND");
-#endif /* DEBUG */
+#endif // DEBUG
return (attr);
}
-/*
- * 'ppd_ll_CC()' - Get the current locale names.
- */
+//
+// 'ppd_ll_CC()' - Get the current locale names.
+//
-static cups_lang_t * /* O - Current language */
-ppd_ll_CC(char *ll_CC, /* O - Country-specific locale name */
- size_t ll_CC_size) /* I - Size of country-specific name */
+static cups_lang_t * // O - Current language
+ppd_ll_CC(char *ll_CC, // O - Country-specific locale name
+ size_t ll_CC_size) // I - Size of country-specific name
{
- cups_lang_t *lang; /* Current language */
+ cups_lang_t *lang; // Current language
- /*
- * Get the current locale...
- */
+ //
+ // Get the current locale...
+ //
if ((lang = cupsLangDefault()) == NULL)
{
return (NULL);
}
- /*
- * Copy the locale name...
- */
+ //
+ // Copy the locale name...
+ //
strlcpy(ll_CC, lang->language, ll_CC_size);
if (strlen(ll_CC) == 2)
{
- /*
- * Map "ll" to primary/origin country locales to have the best
- * chance of finding a match...
- */
+ //
+ // Map "ll" to primary/origin country locales to have the best
+ // chance of finding a match...
+ //
if (!strcmp(ll_CC, "cs"))
strlcpy(ll_CC, "cs_CZ", ll_CC_size);
strlcpy(ll_CC, "ja_JP", ll_CC_size);
else if (!strcmp(ll_CC, "sv"))
strlcpy(ll_CC, "sv_SE", ll_CC_size);
- else if (!strcmp(ll_CC, "zh")) /* Simplified Chinese */
+ else if (!strcmp(ll_CC, "zh")) // Simplified Chinese
strlcpy(ll_CC, "zh_CN", ll_CC_size);
}
-/*
- * Option marking routines for libppd.
- *
- * Copyright © 2007-2019 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Option marking routines for libppd.
+//
+// Copyright © 2007-2019 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "ppd.h"
#include "debug-internal.h"
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
#ifdef DEBUG
static void ppd_debug_marked(ppd_file_t *ppd, const char *title);
#else
# define ppd_debug_marked(ppd,title)
-#endif /* DEBUG */
+#endif // DEBUG
static void ppd_defaults(ppd_file_t *ppd, ppd_group_t *g);
static void ppd_mark_choices(ppd_file_t *ppd, const char *s);
static void ppd_mark_option(ppd_file_t *ppd, const char *option,
const char *choice);
-/*
- * 'ppdMarkOptions()' - Mark command-line options in a PPD file.
- *
- * This function maps the IPP "finishings", "media", "mirror",
- * "multiple-document-handling", "output-bin", "print-color-mode",
- * "print-quality", "printer-resolution", and "sides" attributes to their
- * corresponding PPD options and choices.
- */
+//
+// 'ppdMarkOptions()' - Mark command-line options in a PPD file.
+//
+// This function maps the IPP "finishings", "media", "mirror",
+// "multiple-document-handling", "output-bin", "print-color-mode",
+// "print-quality", "printer-resolution", and "sides" attributes to their
+// corresponding PPD options and choices.
+//
-int /* O - 1 if conflicts exist, 0 otherwise */
+int // O - 1 if conflicts exist, 0 otherwise
ppdMarkOptions(
- ppd_file_t *ppd, /* I - PPD file */
- int num_options, /* I - Number of options */
- cups_option_t *options) /* I - Options */
+ ppd_file_t *ppd, // I - PPD file
+ int num_options, // I - Number of options
+ cups_option_t *options) // I - Options
{
- int i, j; /* Looping vars */
- char *ptr, /* Pointer into string */
- s[255]; /* Temporary string */
- const char *val, /* Pointer into value */
- *media, /* media option */
- *output_bin, /* output-bin option */
- *page_size, /* PageSize option */
- *ppd_keyword, /* PPD keyword */
- *print_color_mode, /* print-color-mode option */
- *print_quality, /* print-quality option */
- *sides; /* sides option */
- cups_option_t *optptr; /* Current option */
- ppd_attr_t *attr; /* PPD attribute */
- ppd_cache_t *cache; /* PPD cache and mapping data */
-
-
- /*
- * Check arguments...
- */
+ int i, j; // Looping vars
+ char *ptr, // Pointer into string
+ s[255]; // Temporary string
+ const char *val, // Pointer into value
+ *media, // media option
+ *output_bin, // output-bin option
+ *page_size, // PageSize option
+ *ppd_keyword, // PPD keyword
+ *print_color_mode, // print-color-mode option
+ *print_quality, // print-quality option
+ *sides; // sides option
+ cups_option_t *optptr; // Current option
+ ppd_attr_t *attr; // PPD attribute
+ ppd_cache_t *cache; // PPD cache and mapping data
+
+
+ //
+ // Check arguments...
+ //
if (!ppd || num_options <= 0 || !options)
return (0);
ppd_debug_marked(ppd, "Before...");
- /*
- * Do special handling for finishings, media, output-bin, output-mode,
- * print-color-mode, print-quality, and PageSize...
- */
+ //
+ // Do special handling for finishings, media, output-bin, output-mode,
+ // print-color-mode, print-quality, and PageSize...
+ //
media = cupsGetOption("media", num_options, options);
output_bin = cupsGetOption("output-bin", num_options, options);
if ((media || output_bin || print_color_mode || print_quality || sides) &&
!ppd->cache)
{
- /*
- * Load PPD cache and mapping data as needed...
- */
+ //
+ // Load PPD cache and mapping data as needed...
+ //
ppd->cache = ppdCacheCreateWithPPD(ppd);
}
if (media)
{
- /*
- * Loop through the option string, separating it at commas and marking each
- * individual option as long as the corresponding PPD option (PageSize,
- * InputSlot, etc.) is not also set.
- *
- * For PageSize, we also check for an empty option value since some versions
- * of macOS use it to specify auto-selection of the media based solely on
- * the size.
- */
+ //
+ // Loop through the option string, separating it at commas and marking each
+ // individual option as long as the corresponding PPD option (PageSize,
+ // InputSlot, etc.) is not also set.
+ //
+ // For PageSize, we also check for an empty option value since some versions
+ // of macOS use it to specify auto-selection of the media based solely on
+ // the size.
+ //
for (val = media; *val;)
{
- /*
- * Extract the sub-option from the string...
- */
+ //
+ // Extract the sub-option from the string...
+ //
for (ptr = s; *val && *val != ',' && (size_t)(ptr - s) < (sizeof(s) - 1);)
*ptr++ = *val++;
if (*val == ',')
val ++;
- /*
- * Mark it...
- */
+ //
+ // Mark it...
+ //
if (!page_size || !page_size[0])
{
if (!_ppd_strncasecmp(s, "Custom.", 7) || ppdPageSize(ppd, s))
ppd_mark_option(ppd, "PageSize", s);
- else if ((ppd_keyword = ppdCacheGetPageSize(cache, NULL, s, NULL)) != NULL)
+ else if ((ppd_keyword = ppdCacheGetPageSize(cache, NULL, s, NULL)) !=
+ NULL)
ppd_mark_option(ppd, "PageSize", ppd_keyword);
}
!cupsGetOption("APPrinterPreset", num_options, options) &&
(print_color_mode || print_quality))
{
- /*
- * Map output-mode and print-quality to a preset...
- */
+ //
+ // Map output-mode and print-quality to a preset...
+ //
- ppd_pwg_print_color_mode_t pwg_pcm;/* print-color-mode index */
- ppd_pwg_print_quality_t pwg_pq; /* print-quality index */
- cups_option_t *preset;/* Current preset option */
+ ppd_pwg_print_color_mode_t pwg_pcm;// print-color-mode index
+ ppd_pwg_print_quality_t pwg_pq; // print-quality index
+ cups_option_t *preset;// Current preset option
if (print_color_mode && !strcmp(print_color_mode, "monochrome"))
pwg_pcm = PPD_PWG_PRINT_COLOR_MODE_MONOCHROME;
if (print_quality)
{
- pwg_pq = (ppd_pwg_print_quality_t)(atoi(print_quality) - IPP_QUALITY_DRAFT);
+ pwg_pq = (ppd_pwg_print_quality_t)(atoi(print_quality) -
+ IPP_QUALITY_DRAFT);
if (pwg_pq < PPD_PWG_PRINT_QUALITY_DRAFT)
pwg_pq = PPD_PWG_PRINT_QUALITY_DRAFT;
else if (pwg_pq > PPD_PWG_PRINT_QUALITY_HIGH)
if (cache->num_presets[pwg_pcm][pwg_pq] == 0)
{
- /*
- * Try to find a preset that works so that we maximize the chances of us
- * getting a good print using IPP attributes.
- */
+ //
+ // Try to find a preset that works so that we maximize the chances of us
+ // getting a good print using IPP attributes.
+ //
if (cache->num_presets[pwg_pcm][PPD_PWG_PRINT_QUALITY_NORMAL] > 0)
pwg_pq = PPD_PWG_PRINT_QUALITY_NORMAL;
if (cache->num_presets[pwg_pcm][pwg_pq] > 0)
{
- /*
- * Copy the preset options as long as the corresponding names are not
- * already defined in the IPP request...
- */
+ //
+ // Copy the preset options as long as the corresponding names are not
+ // already defined in the IPP request...
+ //
for (i = cache->num_presets[pwg_pcm][pwg_pq],
preset = cache->presets[pwg_pcm][pwg_pq];
if (output_bin && !cupsGetOption("OutputBin", num_options, options) &&
(ppd_keyword = ppdCacheGetOutputBin(cache, output_bin)) != NULL)
{
- /*
- * Map output-bin to OutputBin...
- */
+ //
+ // Map output-bin to OutputBin...
+ //
ppd_mark_option(ppd, "OutputBin", ppd_keyword);
}
if (sides && cache->sides_option &&
!cupsGetOption(cache->sides_option, num_options, options))
{
- /*
- * Map sides to duplex option...
- */
+ //
+ // Map sides to duplex option...
+ //
if (!strcmp(sides, "one-sided") && cache->sides_1sided)
ppd_mark_option(ppd, cache->sides_option, cache->sides_1sided);
}
}
- /*
- * Mark other options...
- */
+ //
+ // Mark other options...
+ //
for (i = num_options, optptr = options; i > 0; i --, optptr ++)
{
{
ppd_mark_option(ppd, "Resolution", optptr->value);
ppd_mark_option(ppd, "SetResolution", optptr->value);
- /* Calcomp, Linotype, QMS, Summagraphics, Tektronix, Varityper */
+ // Calcomp, Linotype, QMS, Summagraphics, Tektronix, Varityper
ppd_mark_option(ppd, "JCLResolution", optptr->value);
- /* HP */
+ // HP
ppd_mark_option(ppd, "CNRes_PGP", optptr->value);
- /* Canon */
+ // Canon
}
else if (!_ppd_strcasecmp(optptr->name, "multiple-document-handling"))
{
if (!cupsGetOption("Collate", num_options, options) &&
ppdFindOption(ppd, "Collate"))
{
- if (_ppd_strcasecmp(optptr->value, "separate-documents-uncollated-copies"))
+ if (_ppd_strcasecmp(optptr->value,
+ "separate-documents-uncollated-copies"))
ppd_mark_option(ppd, "Collate", "True");
else
ppd_mark_option(ppd, "Collate", "False");
}
else if (!_ppd_strcasecmp(optptr->name, "finishings"))
{
- /*
- * Lookup cupsIPPFinishings attributes for each value...
- */
+ //
+ // Lookup cupsIPPFinishings attributes for each value...
+
for (ptr = optptr->value; *ptr;)
{
- /*
- * Get the next finishings number...
- */
+ //
+ // Get the next finishings number...
+ //
if (!isdigit(*ptr & 255))
break;
if ((j = (int)strtol(ptr, &ptr, 10)) < 3)
break;
- /*
- * Skip separator as needed...
- */
+ //
+ // Skip separator as needed...
+ //
if (*ptr == ',')
ptr ++;
- /*
- * Look it up in the PPD file...
- */
+ //
+ // Look it up in the PPD file...
+ //
sprintf(s, "%d", j);
if ((attr = ppdFindAttr(ppd, "cupsIPPFinishings", s)) == NULL)
continue;
- /*
- * Apply "*Option Choice" settings from the attribute value...
- */
+ //
+ // Apply "*Option Choice" settings from the attribute value...
+ //
ppd_mark_choices(ppd, attr->value);
}
}
else if (!_ppd_strcasecmp(optptr->name, "APPrinterPreset"))
{
- /*
- * Lookup APPrinterPreset value...
- */
+ //
+ // Lookup APPrinterPreset value...
+ //
if ((attr = ppdFindAttr(ppd, "APPrinterPreset", optptr->value)) != NULL)
{
- /*
- * Apply "*Option Choice" settings from the attribute value...
- */
+ //
+ // Apply "*Option Choice" settings from the attribute value...
+ //
ppd_mark_choices(ppd, attr->value);
}
if (print_quality)
{
- int pq = atoi(print_quality); /* print-quaity value */
+ int pq = atoi(print_quality); // print-quaity value
if (pq == IPP_QUALITY_DRAFT)
ppd_mark_option(ppd, "cupsPrintQuality", "Draft");
}
-/*
- * 'ppdFindChoice()' - Return a pointer to an option choice.
- */
+//
+// 'ppdFindChoice()' - Return a pointer to an option choice.
+//
-ppd_choice_t * /* O - Choice pointer or @code NULL@ */
-ppdFindChoice(ppd_option_t *o, /* I - Pointer to option */
- const char *choice) /* I - Name of choice */
+ppd_choice_t * // O - Choice pointer or @code NULL@
+ppdFindChoice(ppd_option_t *o, // I - Pointer to option
+ const char *choice) // I - Name of choice
{
- int i; /* Looping var */
- ppd_choice_t *c; /* Current choice */
+ int i; // Looping var
+ ppd_choice_t *c; // Current choice
if (!o || !choice)
}
-/*
- * 'ppdFindMarkedChoice()' - Return the marked choice for the specified option.
- */
+//
+// 'ppdFindMarkedChoice()' - Return the marked choice for the specified option.
+//
-ppd_choice_t * /* O - Pointer to choice or @code NULL@ */
-ppdFindMarkedChoice(ppd_file_t *ppd, /* I - PPD file */
- const char *option) /* I - Keyword/option name */
+ppd_choice_t * // O - Pointer to choice or @code NULL@
+ppdFindMarkedChoice(ppd_file_t *ppd, // I - PPD file
+ const char *option) // I - Keyword/option name
{
- ppd_choice_t key, /* Search key for choice */
- *marked; /* Marked choice */
+ ppd_choice_t key, // Search key for choice
+ *marked; // Marked choice
DEBUG_printf(("2ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option));
}
-/*
- * 'ppdFindOption()' - Return a pointer to the specified option.
- */
+//
+// 'ppdFindOption()' - Return a pointer to the specified option.
+//
-ppd_option_t * /* O - Pointer to option or @code NULL@ */
-ppdFindOption(ppd_file_t *ppd, /* I - PPD file data */
- const char *option) /* I - Option/Keyword name */
+ppd_option_t * // O - Pointer to option or @code NULL@
+ppdFindOption(ppd_file_t *ppd, // I - PPD file data
+ const char *option) // I - Option/Keyword name
{
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !option)
return (NULL);
if (ppd->options)
{
- /*
- * Search in the array...
- */
+ //
+ // Search in the array...
+ //
- ppd_option_t key; /* Option search key */
+ ppd_option_t key; // Option search key
strlcpy(key.keyword, option, sizeof(key.keyword));
}
else
{
- /*
- * Search in each group...
- */
+ //
+ // Search in each group...
+ //
- int i, j; /* Looping vars */
- ppd_group_t *group; /* Current group */
- ppd_option_t *optptr; /* Current option */
+ int i, j; // Looping vars
+ ppd_group_t *group; // Current group
+ ppd_option_t *optptr; // Current option
for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
}
-/*
- * 'ppdIsMarked()' - Check to see if an option is marked.
- */
+//
+// 'ppdIsMarked()' - Check to see if an option is marked.
+//
-int /* O - Non-zero if option is marked */
-ppdIsMarked(ppd_file_t *ppd, /* I - PPD file data */
- const char *option, /* I - Option/Keyword name */
- const char *choice) /* I - Choice name */
+int // O - Non-zero if option is marked
+ppdIsMarked(ppd_file_t *ppd, // I - PPD file data
+ const char *option, // I - Option/Keyword name
+ const char *choice) // I - Choice name
{
- ppd_choice_t key, /* Search key */
- *c; /* Choice pointer */
+ ppd_choice_t key, // Search key
+ *c; // Choice pointer
if (!ppd)
}
-/*
- * 'ppdMarkDefaults()' - Mark all default options in the PPD file.
- */
+//
+// 'ppdMarkDefaults()' - Mark all default options in the PPD file.
+//
void
-ppdMarkDefaults(ppd_file_t *ppd) /* I - PPD file record */
+ppdMarkDefaults(ppd_file_t *ppd) // I - PPD file record
{
- int i; /* Looping variables */
- ppd_group_t *g; /* Current group */
- ppd_choice_t *c; /* Current choice */
+ int i; // Looping variables
+ ppd_group_t *g; // Current group
+ ppd_choice_t *c; // Current choice
if (!ppd)
return;
- /*
- * Clean out the marked array...
- */
+ //
+ // Clean out the marked array...
+ //
for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked);
c;
c->marked = 0;
}
- /*
- * Then repopulate it with the defaults...
- */
+ //
+ // Then repopulate it with the defaults...
+ //
for (i = ppd->num_groups, g = ppd->groups; i > 0; i --, g ++)
ppd_defaults(ppd, g);
- /*
- * Finally, tag any conflicts (API compatibility) once at the end.
- */
+ //
+ // Finally, tag any conflicts (API compatibility) once at the end.
+ //
ppdConflicts(ppd);
}
-/*
- * 'ppdMarkOption()' - Mark an option in a PPD file and return the number of
- * conflicts.
- */
+//
+// 'ppdMarkOption()' - Mark an option in a PPD file and return the number of
+// conflicts.
+//
-int /* O - Number of conflicts */
-ppdMarkOption(ppd_file_t *ppd, /* I - PPD file record */
- const char *option, /* I - Keyword */
- const char *choice) /* I - Option name */
+int // O - Number of conflicts
+ppdMarkOption(ppd_file_t *ppd, // I - PPD file record
+ const char *option, // I - Keyword
+ const char *choice) // I - Option name
{
DEBUG_printf(("ppdMarkOption(ppd=%p, option=\"%s\", choice=\"%s\")",
ppd, option, choice));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !option || !choice)
return (0);
- /*
- * Mark the option...
- */
+ //
+ // Mark the option...
+ //
ppd_mark_option(ppd, option, choice);
- /*
- * Return the number of conflicts...
- */
+ //
+ // Return the number of conflicts...
+ //
return (ppdConflicts(ppd));
}
-/*
- * 'ppdFirstOption()' - Return the first option in the PPD file.
- *
- * Options are returned from all groups in ascending alphanumeric order.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdFirstOption()' - Return the first option in the PPD file.
+//
+// Options are returned from all groups in ascending alphanumeric order.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ppd_option_t * /* O - First option or @code NULL@ */
-ppdFirstOption(ppd_file_t *ppd) /* I - PPD file */
+ppd_option_t * // O - First option or @code NULL@
+ppdFirstOption(ppd_file_t *ppd) // I - PPD file
{
if (!ppd)
return (NULL);
}
-/*
- * 'ppdNextOption()' - Return the next option in the PPD file.
- *
- * Options are returned from all groups in ascending alphanumeric order.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdNextOption()' - Return the next option in the PPD file.
+//
+// Options are returned from all groups in ascending alphanumeric order.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ppd_option_t * /* O - Next option or @code NULL@ */
-ppdNextOption(ppd_file_t *ppd) /* I - PPD file */
+ppd_option_t * // O - Next option or @code NULL@
+ppdNextOption(ppd_file_t *ppd) // I - PPD file
{
if (!ppd)
return (NULL);
}
-/*
- * 'ppdParseOptions()' - Parse options from a PPD file.
- *
- * This function looks for strings of the form:
- *
- * *option choice ... *optionN choiceN
- * property value ... propertyN valueN
- *
- * It stops when it finds a string that doesn't match this format.
- */
+//
+// 'ppdParseOptions()' - Parse options from a PPD file.
+//
+// This function looks for strings of the form:
+//
+// *option choice ... *optionN choiceN
+// property value ... propertyN valueN
+//
+// It stops when it finds a string that doesn't match this format.
+//
-int /* O - Number of options */
+int // O - Number of options
ppdParseOptions(
- const char *s, /* I - String to parse */
- int num_options, /* I - Number of options */
- cups_option_t **options, /* IO - Options */
- ppd_parse_t which) /* I - What to parse */
+ const char *s, // I - String to parse
+ int num_options, // I - Number of options
+ cups_option_t **options, // IO - Options
+ ppd_parse_t which) // I - What to parse
{
- char option[PPD_MAX_NAME * 2 + 1], /* Current option/property */
- choice[PPD_MAX_NAME], /* Current choice/value */
- *ptr; /* Pointer into option or choice */
+ char option[PPD_MAX_NAME * 2 + 1], // Current option/property
+ choice[PPD_MAX_NAME], // Current choice/value
+ *ptr; // Pointer into option or choice
if (!s)
return (num_options);
- /*
- * Read all of the "*Option Choice" and "property value" pairs from the
- * string, add them to an options array as we go...
- */
+ //
+ // Read all of the "*Option Choice" and "property value" pairs from the
+ // string, add them to an options array as we go...
+ //
while (*s)
{
- /*
- * Skip leading whitespace...
- */
+ //
+ // Skip leading whitespace...
+ //
while (_ppd_isspace(*s))
s ++;
- /*
- * Get the option/property name...
- */
+ //
+ // Get the option/property name...
+ //
ptr = option;
while (*s && !_ppd_isspace(*s) && ptr < (option + sizeof(option) - 1))
*ptr = '\0';
- /*
- * Get the choice...
- */
+ //
+ // Get the choice...
+ //
while (_ppd_isspace(*s))
s ++;
*ptr = '\0';
- /*
- * Add it to the options array...
- */
+ //
+ // Add it to the options array...
+ //
if (option[0] == '*' && which != PPD_PARSE_PROPERTIES)
num_options = cupsAddOption(option + 1, choice, num_options, options);
#ifdef DEBUG
-/*
- * 'ppd_debug_marked()' - Output the marked array to stdout...
- */
+//
+// 'ppd_debug_marked()' - Output the marked array to stdout...
+//
static void
-ppd_debug_marked(ppd_file_t *ppd, /* I - PPD file data */
- const char *title) /* I - Title for list */
+ppd_debug_marked(ppd_file_t *ppd, // I - PPD file data
+ const char *title) // I - Title for list
{
- ppd_choice_t *c; /* Current choice */
+ ppd_choice_t *c; // Current choice
DEBUG_printf(("2ppdMarkOptions: %s", title));
c = (ppd_choice_t *)cupsArrayNext(ppd->marked))
DEBUG_printf(("2ppdMarkOptions: %s=%s", c->option->keyword, c->choice));
}
-#endif /* DEBUG */
+#endif // DEBUG
-/*
- * 'ppd_defaults()' - Set the defaults for this group and all sub-groups.
- */
+//
+// 'ppd_defaults()' - Set the defaults for this group and all sub-groups.
+//
static void
-ppd_defaults(ppd_file_t *ppd, /* I - PPD file */
- ppd_group_t *g) /* I - Group to default */
+ppd_defaults(ppd_file_t *ppd, // I - PPD file
+ ppd_group_t *g) // I - Group to default
{
- int i; /* Looping var */
- ppd_option_t *o; /* Current option */
- ppd_group_t *sg; /* Current sub-group */
+ int i; // Looping var
+ ppd_option_t *o; // Current option
+ ppd_group_t *sg; // Current sub-group
for (i = g->num_options, o = g->options; i > 0; i --, o ++)
}
-/*
- * 'ppd_mark_choices()' - Mark one or more option choices from a string.
- */
+//
+// 'ppd_mark_choices()' - Mark one or more option choices from a string.
+//
static void
-ppd_mark_choices(ppd_file_t *ppd, /* I - PPD file */
- const char *s) /* I - "*Option Choice ..." string */
+ppd_mark_choices(ppd_file_t *ppd, // I - PPD file
+ const char *s) // I - "*Option Choice ..." string
{
- int i, /* Looping var */
- num_options; /* Number of options */
- cups_option_t *options, /* Options */
- *option; /* Current option */
+ int i, // Looping var
+ num_options; // Number of options
+ cups_option_t *options, // Options
+ *option; // Current option
if (!s)
}
-/*
- * 'ppd_mark_option()' - Quick mark an option without checking for conflicts.
- */
+//
+// 'ppd_mark_option()' - Quick mark an option without checking for conflicts.
+//
static void
-ppd_mark_option(ppd_file_t *ppd, /* I - PPD file */
- const char *option, /* I - Option name */
- const char *choice) /* I - Choice name */
+ppd_mark_option(ppd_file_t *ppd, // I - PPD file
+ const char *option, // I - Option name
+ const char *choice) // I - Choice name
{
- int i, j; /* Looping vars */
- ppd_option_t *o; /* Option pointer */
- ppd_choice_t *c, /* Choice pointer */
- *oldc, /* Old choice pointer */
- key; /* Search key for choice */
- struct lconv *loc; /* Locale data */
+ int i, j; // Looping vars
+ ppd_option_t *o; // Option pointer
+ ppd_choice_t *c, // Choice pointer
+ *oldc, // Old choice pointer
+ key; // Search key for choice
+ struct lconv *loc; // Locale data
DEBUG_printf(("7ppd_mark_option(ppd=%p, option=\"%s\", choice=\"%s\")",
ppd, option, choice));
- /*
- * AP_D_InputSlot is the "default input slot" on macOS, and setting
- * it clears the regular InputSlot choices...
- */
+ //
+ // AP_D_InputSlot is the "default input slot" on macOS, and setting
+ // it clears the regular InputSlot choices...
+ //
if (!_ppd_strcasecmp(option, "AP_D_InputSlot"))
{
cupsArrayRestore(ppd->options);
}
- /*
- * Check for custom options...
- */
+ //
+ // Check for custom options...
+ //
cupsArraySave(ppd->options);
if (!_ppd_strncasecmp(choice, "Custom.", 7))
{
- /*
- * Handle a custom option...
- */
+ //
+ // Handle a custom option...
+ //
if ((c = ppdFindChoice(o, "Custom")) == NULL)
return;
if (!_ppd_strcasecmp(option, "PageSize"))
{
- /*
- * Handle custom page sizes...
- */
+ //
+ // Handle custom page sizes...
+ //
ppdPageSize(ppd, choice);
}
else
{
- /*
- * Handle other custom options...
- */
+ //
+ // Handle other custom options...
+ //
- ppd_coption_t *coption; /* Custom option */
- ppd_cparam_t *cparam; /* Custom parameter */
- char *units; /* Custom points units */
+ ppd_coption_t *coption; // Custom option
+ ppd_cparam_t *cparam; // Custom parameter
+ char *units; // Custom points units
if ((coption = ppdFindCustomOption(ppd, option)) != NULL)
}
}
- /*
- * Make sure that we keep the option marked below...
- */
+ //
+ // Make sure that we keep the option marked below...
+ //
choice = "Custom";
}
else if (choice[0] == '{')
{
- /*
- * Handle multi-value custom options...
- */
+ //
+ // Handle multi-value custom options...
+ //
- ppd_coption_t *coption; /* Custom option */
- ppd_cparam_t *cparam; /* Custom parameter */
- char *units; /* Custom points units */
- int num_vals; /* Number of values */
- cups_option_t *vals, /* Values */
- *val; /* Value */
+ ppd_coption_t *coption; // Custom option
+ ppd_cparam_t *cparam; // Custom parameter
+ char *units; // Custom points units
+ int num_vals; // Number of values
+ cups_option_t *vals, // Values
+ *val; // Value
if ((c = ppdFindChoice(o, "Custom")) == NULL)
return;
}
- /*
- * Option found; mark it and then handle unmarking any other options.
- */
+ //
+ // Option found; mark it and then handle unmarking any other options.
+ //
if (o->ui != PPD_UI_PICKMANY)
{
- /*
- * Unmark all other choices...
- */
+ //
+ // Unmark all other choices...
+ //
if ((oldc = (ppd_choice_t *)cupsArrayFind(ppd->marked, c)) != NULL)
{
cupsArrayRemove(ppd->marked, oldc);
}
- if (!_ppd_strcasecmp(option, "PageSize") || !_ppd_strcasecmp(option, "PageRegion"))
+ if (!_ppd_strcasecmp(option, "PageSize") ||
+ !_ppd_strcasecmp(option, "PageRegion"))
{
- /*
- * Mark current page size...
- */
+ //
+ // Mark current page size...
+ //
for (j = 0; j < ppd->num_sizes; j ++)
ppd->sizes[j].marked = !_ppd_strcasecmp(ppd->sizes[j].name,
choice);
- /*
- * Unmark the current PageSize or PageRegion setting, as
- * appropriate...
- */
+ //
+ // Unmark the current PageSize or PageRegion setting, as
+ // appropriate...
+ //
cupsArraySave(ppd->options);
}
else if (!_ppd_strcasecmp(option, "InputSlot"))
{
- /*
- * Unmark ManualFeed option...
- */
+ //
+ // Unmark ManualFeed option...
+ //
cupsArraySave(ppd->options);
else if (!_ppd_strcasecmp(option, "ManualFeed") &&
!_ppd_strcasecmp(choice, "True"))
{
- /*
- * Unmark InputSlot option...
- */
+ //
+ // Unmark InputSlot option...
+ //
cupsArraySave(ppd->options);
-/*
- * Page size functions for libppd.
- *
- * Copyright 2007-2015 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Page size functions for libppd.
+//
+// Copyright 2007-2015 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#include "debug-internal.h"
#include "ppd.h"
-/*
- * 'ppdPageSize()' - Get the page size record for the named size.
- */
+//
+// 'ppdPageSize()' - Get the page size record for the named size.
+//
-ppd_size_t * /* O - Size record for page or NULL */
-ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */
- const char *name) /* I - Size name */
+ppd_size_t * // O - Size record for page or NULL
+ppdPageSize(ppd_file_t *ppd, // I - PPD file record
+ const char *name) // I - Size name
{
- int i; /* Looping var */
- ppd_size_t *size; /* Current page size */
- double w, l; /* Width and length of page */
- char *nameptr; /* Pointer into name */
- struct lconv *loc; /* Locale data */
- ppd_coption_t *coption; /* Custom option for page size */
- ppd_cparam_t *cparam; /* Custom option parameter */
+ int i; // Looping var
+ ppd_size_t *size; // Current page size
+ double w, l; // Width and length of page
+ char *nameptr; // Pointer into name
+ struct lconv *loc; // Locale data
+ ppd_coption_t *coption; // Custom option for page size
+ ppd_cparam_t *cparam; // Custom option parameter
DEBUG_printf(("2ppdPageSize(ppd=%p, name=\"%s\")", ppd, name));
{
if (!strncmp(name, "Custom.", 7) && ppd->variable_sizes)
{
- /*
- * Find the custom page size...
- */
+ //
+ // Find the custom page size...
+ //
for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
if (!strcmp("Custom", size->name))
return (NULL);
}
- /*
- * Variable size; size name can be one of the following:
- *
- * Custom.WIDTHxLENGTHin - Size in inches
- * Custom.WIDTHxLENGTHft - Size in feet
- * Custom.WIDTHxLENGTHcm - Size in centimeters
- * Custom.WIDTHxLENGTHmm - Size in millimeters
- * Custom.WIDTHxLENGTHm - Size in meters
- * Custom.WIDTHxLENGTH[pt] - Size in points
- */
+ //
+ // Variable size; size name can be one of the following:
+ //
+ // Custom.WIDTHxLENGTHin - Size in inches
+ // Custom.WIDTHxLENGTHft - Size in feet
+ // Custom.WIDTHxLENGTHcm - Size in centimeters
+ // Custom.WIDTHxLENGTHmm - Size in millimeters
+ // Custom.WIDTHxLENGTHm - Size in meters
+ // Custom.WIDTHxLENGTH[pt] - Size in points
+ //
loc = localeconv();
w = _ppdStrScand(name + 7, &nameptr, loc);
size->right = (float)(w - ppd->custom_margins[2]);
size->top = (float)(l - ppd->custom_margins[3]);
- /*
- * Update the custom option records for the page size, too...
- */
+ //
+ // Update the custom option records for the page size, too...
+ //
if ((coption = ppdFindCustomOption(ppd, "PageSize")) != NULL)
{
cparam->current.custom_points = (float)l;
}
- /*
- * Return the page size...
- */
+ //
+ // Return the page size...
+ //
DEBUG_printf(("3ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
size->name, size->width, size->length));
}
else
{
- /*
- * Lookup by name...
- */
+ //
+ // Lookup by name...
+ //
for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
if (!_ppd_strcasecmp(name, size->name))
}
else
{
- /*
- * Find default...
- */
+ //
+ // Find default...
+ //
for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
if (size->marked)
}
-/*
- * 'ppdPageSizeLimits()' - Return the custom page size limits.
- *
- * This function returns the minimum and maximum custom page sizes and printable
- * areas based on the currently-marked (selected) options.
- *
- * If the specified PPD file does not support custom page sizes, both
- * "minimum" and "maximum" are filled with zeroes.
- *
- * @since CUPS 1.4/macOS 10.6@
- */
-
-int /* O - 1 if custom sizes are supported, 0 otherwise */
-ppdPageSizeLimits(ppd_file_t *ppd, /* I - PPD file record */
- ppd_size_t *minimum, /* O - Minimum custom size */
- ppd_size_t *maximum) /* O - Maximum custom size */
+//
+// 'ppdPageSizeLimits()' - Return the custom page size limits.
+//
+// This function returns the minimum and maximum custom page sizes and printable
+// areas based on the currently-marked (selected) options.
+//
+// If the specified PPD file does not support custom page sizes, both
+// "minimum" and "maximum" are filled with zeroes.
+//
+// @since CUPS 1.4/macOS 10.6@
+//
+
+int // O - 1 if custom sizes are supported, 0 otherwise
+ppdPageSizeLimits(ppd_file_t *ppd, // I - PPD file record
+ ppd_size_t *minimum, // O - Minimum custom size
+ ppd_size_t *maximum) // O - Maximum custom size
{
- ppd_choice_t *qualifier2, /* Second media qualifier */
- *qualifier3; /* Third media qualifier */
- ppd_attr_t *attr; /* Attribute */
- float width, /* Min/max width */
- length; /* Min/max length */
- char spec[PPD_MAX_NAME]; /* Selector for min/max */
+ ppd_choice_t *qualifier2, // Second media qualifier
+ *qualifier3; // Third media qualifier
+ ppd_attr_t *attr; // Attribute
+ float width, // Min/max width
+ length; // Min/max length
+ char spec[PPD_MAX_NAME]; // Selector for min/max
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!ppd || !ppd->variable_sizes || !minimum || !maximum)
{
return (0);
}
- /*
- * See if we have the cupsMediaQualifier2 and cupsMediaQualifier3 attributes...
- */
+ //
+ // See if we have the cupsMediaQualifier2 and cupsMediaQualifier3
+ // attributes...
+ //
cupsArraySave(ppd->sorted_attrs);
else
qualifier3 = NULL;
- /*
- * Figure out the current minimum width and length...
- */
+ //
+ // Figure out the current minimum width and length...
+ //
width = ppd->custom_min[0];
length = ppd->custom_min[1];
if (qualifier2)
{
- /*
- * Try getting cupsMinSize...
- */
+ //
+ // Try getting cupsMinSize...
+ //
if (qualifier3)
{
minimum->right = width - ppd->custom_margins[2];
minimum->top = length - ppd->custom_margins[3];
- /*
- * Figure out the current maximum width and length...
- */
+ //
+ // Figure out the current maximum width and length...
+ //
width = ppd->custom_max[0];
length = ppd->custom_max[1];
if (qualifier2)
{
- /*
- * Try getting cupsMaxSize...
- */
+ //
+ // Try getting cupsMaxSize...
+ //
if (qualifier3)
{
maximum->right = width - ppd->custom_margins[2];
maximum->top = length - ppd->custom_margins[3];
- /*
- * Return the min and max...
- */
+ //
+ // Return the min and max...
+ //
cupsArrayRestore(ppd->sorted_attrs);
}
-/*
- * 'ppdPageWidth()' - Get the page width for the given size.
- */
+//
+// 'ppdPageWidth()' - Get the page width for the given size.
+//
-float /* O - Width of page in points or 0.0 */
-ppdPageWidth(ppd_file_t *ppd, /* I - PPD file record */
- const char *name) /* I - Size name */
+float // O - Width of page in points or 0.0
+ppdPageWidth(ppd_file_t *ppd, // I - PPD file record
+ const char *name) // I - Size name
{
- ppd_size_t *size; /* Page size */
+ ppd_size_t *size; // Page size
if ((size = ppdPageSize(ppd, name)) == NULL)
}
-/*
- * 'ppdPageLength()' - Get the page length for the given size.
- */
+//
+// 'ppdPageLength()' - Get the page length for the given size.
+//
-float /* O - Length of page in points or 0.0 */
-ppdPageLength(ppd_file_t *ppd, /* I - PPD file */
- const char *name) /* I - Size name */
+float // O - Length of page in points or 0.0
+ppdPageLength(ppd_file_t *ppd, // I - PPD file
+ const char *name) // I - Size name
{
- ppd_size_t *size; /* Page size */
+ ppd_size_t *size; // Page size
if ((size = ppdPageSize(ppd, name)) == NULL)
-/*
- * PPD file routines for libppd.
- *
- * Copyright © 2007-2019 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
-
-/*
- * Include necessary headers.
- */
+//
+// PPD file routines for libppd.
+//
+// Copyright © 2007-2019 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
+
+//
+// Include necessary headers.
+//
#include "string-private.h"
#include "language-private.h"
#include "debug-internal.h"
-/*
- * Definitions...
- */
+//
+// Definitions...
+//
-#define PPD_KEYWORD 1 /* Line contained a keyword */
-#define PPD_OPTION 2 /* Line contained an option name */
-#define PPD_TEXT 4 /* Line contained human-readable text */
-#define PPD_STRING 8 /* Line contained a string or code */
+#define PPD_KEYWORD 1 // Line contained a keyword
+#define PPD_OPTION 2 // Line contained an option name
+#define PPD_TEXT 4 // Line contained human-readable text
+#define PPD_STRING 8 // Line contained a string or code
-#define PPD_HASHSIZE 512 /* Size of hash */
+#define PPD_HASHSIZE 512 // Size of hash
-/*
- * Line buffer structure...
- */
+//
+// Line buffer structure...
+//
typedef struct _ppd_line_s
{
- char *buffer; /* Pointer to buffer */
- size_t bufsize; /* Size of the buffer */
+ char *buffer; // Pointer to buffer
+ size_t bufsize; // Size of the buffer
} _ppd_line_t;
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
static _ppd_threadkey_t ppd_globals_key = _PPD_THREADKEY_INITIALIZER;
- /* Thread local storage key */
+ // Thread local storage key
#ifdef HAVE_PTHREAD_H
static pthread_once_t ppd_globals_key_once = PTHREAD_ONCE_INIT;
- /* One-time initialization object */
-#endif /* HAVE_PTHREAD_H */
+ // One-time initialization object
+#endif // HAVE_PTHREAD_H
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static ppd_attr_t *ppd_add_attr(ppd_file_t *ppd, const char *name,
const char *spec, const char *text,
static ppd_globals_t *ppd_globals_alloc(void);
#if defined(HAVE_PTHREAD_H) || defined(_WIN32)
static void ppd_globals_free(ppd_globals_t *g);
-#endif /* HAVE_PTHREAD_H || _WIN32 */
+#endif // HAVE_PTHREAD_H || _WIN32
#ifdef HAVE_PTHREAD_H
static void ppd_globals_init(void);
-#endif /* HAVE_PTHREAD_H */
+#endif // HAVE_PTHREAD_H
static int ppd_hash_option(ppd_option_t *option);
static int ppd_read(cups_file_t *fp, _ppd_line_t *line,
char *keyword, char *option, char *text,
ppd_globals_t *pg);
-/*
- * 'ppdClose()' - Free all memory used by the PPD file.
- */
+//
+// 'ppdClose()' - Free all memory used by the PPD file.
+//
void
-ppdClose(ppd_file_t *ppd) /* I - PPD file record */
+ppdClose(ppd_file_t *ppd) // I - PPD file record
{
- int i; /* Looping var */
- ppd_group_t *group; /* Current group */
- char **font; /* Current font */
- ppd_attr_t **attr; /* Current attribute */
- ppd_coption_t *coption; /* Current custom option */
- ppd_cparam_t *cparam; /* Current custom parameter */
+ int i; // Looping var
+ ppd_group_t *group; // Current group
+ char **font; // Current font
+ ppd_attr_t **attr; // Current attribute
+ ppd_coption_t *coption; // Current custom option
+ ppd_cparam_t *cparam; // Current custom parameter
- /*
- * Range check arguments...
- */
+ //
+ // Range check arguments...
+ //
if (!ppd)
return;
- /*
- * Free all strings at the top level...
- */
+ //
+ // Free all strings at the top level...
+ //
free(ppd->lang_encoding);
free(ppd->nickname);
free(ppd->jcl_pdf);
#endif
- /*
- * Free any UI groups, subgroups, and options...
- */
+ //
+ // Free any UI groups, subgroups, and options...
+ //
if (ppd->num_groups > 0)
{
cupsArrayDelete(ppd->options);
cupsArrayDelete(ppd->marked);
- /*
- * Free any page sizes...
- */
+ //
+ // Free any page sizes...
+ //
if (ppd->num_sizes > 0)
free(ppd->sizes);
- /*
- * Free any constraints...
- */
+ //
+ // Free any constraints...
+ //
if (ppd->num_consts > 0)
free(ppd->consts);
- /*
- * Free any filters...
- */
+ //
+ // Free any filters...
+ //
ppd_free_filters(ppd);
- /*
- * Free any fonts...
- */
+ //
+ // Free any fonts...
+ //
if (ppd->num_fonts > 0)
{
free(ppd->fonts);
}
- /*
- * Free any profiles...
- */
+ //
+ // Free any profiles...
+ //
if (ppd->num_profiles > 0)
free(ppd->profiles);
- /*
- * Free any attributes...
- */
+ //
+ // Free any attributes...
+ //
if (ppd->num_attrs > 0)
{
cupsArrayDelete(ppd->sorted_attrs);
- /*
- * Free custom options...
- */
+ //
+ // Free custom options...
+ //
for (coption = (ppd_coption_t *)cupsArrayFirst(ppd->coptions);
coption;
cupsArrayDelete(ppd->coptions);
- /*
- * Free constraints...
- */
+ //
+ // Free constraints...
+ //
if (ppd->cups_uiconstraints)
{
- ppd_cups_uiconsts_t *consts; /* Current constraints */
+ ppd_cups_uiconsts_t *consts; // Current constraints
for (consts = (ppd_cups_uiconsts_t *)cupsArrayFirst(ppd->cups_uiconstraints);
cupsArrayDelete(ppd->cups_uiconstraints);
}
- /*
- * Free any PPD cache/mapping data...
- */
+ //
+ // Free any PPD cache/mapping data...
+ //
if (ppd->cache)
ppdCacheDestroy(ppd->cache);
- /*
- * Free the whole record...
- */
+ //
+ // Free the whole record...
+ //
free(ppd);
}
-/*
- * 'ppdErrorString()' - Returns the text associated with a status.
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'ppdErrorString()' - Returns the text associated with a status.
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
-const char * /* O - Status string */
-ppdErrorString(ppd_status_t status) /* I - PPD status */
+const char * // O - Status string
+ppdErrorString(ppd_status_t status) // I - PPD status
{
- static const char * const messages[] =/* Status messages */
+ static const char * const messages[] =// Status messages
{
_("OK"),
_("Unable to open PPD file"),
}
-/*
- * 'ppdGetEncoding()' - Get the CUPS encoding value for the given
- * LanguageEncoding.
- */
+//
+// 'ppdGetEncoding()' - Get the CUPS encoding value for the given
+// LanguageEncoding.
-cups_encoding_t /* O - CUPS encoding value */
-ppdGetEncoding(const char *name) /* I - LanguageEncoding string */
+
+cups_encoding_t // O - CUPS encoding value
+ppdGetEncoding(const char *name) // I - LanguageEncoding string
{
if (!_ppd_strcasecmp(name, "ISOLatin1"))
return (CUPS_ISO8859_1);
}
-/*
- * 'ppdGlobals()' - Return a pointer to thread local storage
- */
+//
+// 'ppdGlobals()' - Return a pointer to thread local storage
+//
-ppd_globals_t * /* O - Pointer to global data */
+ppd_globals_t * // O - Pointer to global data
ppdGlobals(void)
{
- ppd_globals_t *pg; /* Pointer to global data */
+ ppd_globals_t *pg; // Pointer to global data
#ifdef HAVE_PTHREAD_H
- /*
- * Initialize the global data exactly once...
- */
+ //
+ // Initialize the global data exactly once...
+ //
pthread_once(&ppd_globals_key_once, ppd_globals_init);
-#endif /* HAVE_PTHREAD_H */
+#endif // HAVE_PTHREAD_H
- /*
- * See if we have allocated the data yet...
- */
+ //
+ // See if we have allocated the data yet...
+ //
if ((pg = (ppd_globals_t *)_ppdThreadGetData(ppd_globals_key)) == NULL)
{
- /*
- * No, allocate memory as set the pointer for the key...
- */
+ //
+ // No, allocate memory as set the pointer for the key...
+ //
if ((pg = ppd_globals_alloc()) != NULL)
_ppdThreadSetData(ppd_globals_key, pg);
}
- /*
- * Return the pointer to the data...
- */
+ //
+ // Return the pointer to the data...
+ //
return (pg);
}
-/*
- * 'ppdLastError()' - Return the status from the last ppdOpen*().
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'ppdLastError()' - Return the status from the last ppdOpen*().
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
-ppd_status_t /* O - Status code */
-ppdLastError(int *line) /* O - Line number */
+ppd_status_t // O - Status code
+ppdLastError(int *line) // O - Line number
{
ppd_globals_t *pg = ppdGlobals();
- /* Global data */
+ // Global data
if (line)
}
-/*
- * 'ppdOpenWithLocalization()' - Read a PPD file into memory.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdOpenWithLocalization()' - Read a PPD file into memory.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ppd_file_t * /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
+ppd_file_t * // O - PPD file record or @code NULL@ if the PPD file could not be opened.
ppdOpenWithLocalization(
- cups_file_t *fp, /* I - File to read from */
- ppd_localization_t localization) /* I - Localization to load */
+ cups_file_t *fp, // I - File to read from
+ ppd_localization_t localization) // I - Localization to load
{
- int i, j, k; /* Looping vars */
- _ppd_line_t line; /* Line buffer */
- ppd_file_t *ppd; /* PPD file record */
- ppd_group_t *group, /* Current group */
- *subgroup; /* Current sub-group */
- ppd_option_t *option; /* Current option */
- ppd_choice_t *choice; /* Current choice */
- ppd_const_t *constraint; /* Current constraint */
- ppd_size_t *size; /* Current page size */
- int mask; /* Line data mask */
+ int i, j, k; // Looping vars
+ _ppd_line_t line; // Line buffer
+ ppd_file_t *ppd; // PPD file record
+ ppd_group_t *group, // Current group
+ *subgroup; // Current sub-group
+ ppd_option_t *option; // Current option
+ ppd_choice_t *choice; // Current choice
+ ppd_const_t *constraint; // Current constraint
+ ppd_size_t *size; // Current page size
+ int mask; // Line data mask
char keyword[PPD_MAX_NAME],
- /* Keyword from file */
+ // Keyword from file
name[PPD_MAX_NAME],
- /* Option from file */
+ // Option from file
text[PPD_MAX_LINE],
- /* Human-readable text from file */
- *string, /* Code/text from file */
- *sptr, /* Pointer into string */
- *temp, /* Temporary string pointer */
- **tempfonts; /* Temporary fonts pointer */
- float order; /* Order dependency number */
- ppd_section_t section; /* Order dependency section */
- ppd_profile_t *profile; /* Pointer to color profile */
- char **filter; /* Pointer to filter */
- struct lconv *loc; /* Locale data */
- int ui_keyword; /* Is this line a UI keyword? */
- cups_lang_t *lang; /* Language data */
- cups_encoding_t encoding; /* Encoding of PPD file */
+ // Human-readable text from file
+ *string, // Code/text from file
+ *sptr, // Pointer into string
+ *temp, // Temporary string pointer
+ **tempfonts; // Temporary fonts pointer
+ float order; // Order dependency number
+ ppd_section_t section; // Order dependency section
+ ppd_profile_t *profile; // Pointer to color profile
+ char **filter; // Pointer to filter
+ struct lconv *loc; // Locale data
+ int ui_keyword; // Is this line a UI keyword?
+ cups_lang_t *lang; // Language data
+ cups_encoding_t encoding; // Encoding of PPD file
ppd_globals_t *pg = ppdGlobals();
- /* Global data */
+ // Global data
char custom_name[PPD_MAX_NAME];
- /* CustomFoo attribute name */
- ppd_attr_t *custom_attr; /* CustomFoo attribute */
- char ll[7], /* Base language + '.' */
- ll_CC[7]; /* Language w/country + '.' */
- size_t ll_len = 0, /* Base language length */
- ll_CC_len = 0; /* Language w/country length */
+ // CustomFoo attribute name
+ ppd_attr_t *custom_attr; // CustomFoo attribute
+ char ll[7], // Base language + '.'
+ ll_CC[7]; // Language w/country + '.'
+ size_t ll_len = 0, // Base language length
+ ll_CC_len = 0; // Language w/country length
static const char * const ui_keywords[] =
{
#ifdef CUPS_USE_FULL_UI_KEYWORDS_LIST
- /*
- * Adobe defines some 41 keywords as "UI", meaning that they are
- * user interface elements and that they should be treated as such
- * even if the PPD creator doesn't use Open/CloseUI around them.
- *
- * Since this can cause previously invisible options to appear and
- * confuse users, the default is to only treat the PageSize and
- * PageRegion keywords this way.
- */
- /* Boolean keywords */
+ //
+ // Adobe defines some 41 keywords as "UI", meaning that they are
+ // user interface elements and that they should be treated as such
+ // even if the PPD creator doesn't use Open/CloseUI around them.
+ //
+ // Since this can cause previously invisible options to appear and
+ // confuse users, the default is to only treat the PageSize and
+ // PageRegion keywords this way.
+ //
+
+ // Boolean keywords
"BlackSubstitution",
"Booklet",
"Collate",
"Sorter",
"TraySwitch",
- /* PickOne keywords */
+ // PickOne keywords
"AdvanceMedia",
"BindColor",
"BindEdge",
"StapleWhen",
"StapleX",
"StapleY"
-#else /* !CUPS_USE_FULL_UI_KEYWORDS_LIST */
+#else // !CUPS_USE_FULL_UI_KEYWORDS_LIST
"PageRegion",
"PageSize"
-#endif /* CUPS_USE_FULL_UI_KEYWORDS_LIST */
+#endif // CUPS_USE_FULL_UI_KEYWORDS_LIST
};
- static const char * const color_keywords[] = /* Keywords associated with color profiles */
+ static const char * const color_keywords[] = // Keywords associated with
+ // color profiles
{
".cupsICCProfile",
".ColorModel",
DEBUG_printf(("ppdOpenWithLocalization(fp=%p)", fp));
- /*
- * Default to "OK" status...
- */
+ //
+ // Default to "OK" status...
+ //
pg->ppd_status = PPD_OK;
pg->ppd_line = 0;
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (fp == NULL)
{
return (NULL);
}
- /*
- * If only loading a single localization set up the strings to match...
- */
+ //
+ // If only loading a single localization set up the strings to match...
+ //
if (localization == PPD_LOCALIZATION_DEFAULT)
{
snprintf(ll_CC, sizeof(ll_CC), "%.5s.", lang->language);
- /*
- * <rdar://problem/22130168>
- * <rdar://problem/27245567>
- *
- * Need to use a different base language for some locales...
- */
+ //
+ // <rdar://problem/22130168>
+ // <rdar://problem/27245567>
+ //
+ // Need to use a different base language for some locales...
+ //
if (!strcmp(lang->language, "zh_HK"))
- { /* Traditional Chinese + variants */
+ { // Traditional Chinese + variants
strlcpy(ll_CC, "zh_TW.", sizeof(ll_CC));
strlcpy(ll, "zh_", sizeof(ll));
}
else if (!strncmp(lang->language, "zh", 2))
- strlcpy(ll, "zh_", sizeof(ll)); /* Any Chinese variant */
+ strlcpy(ll, "zh_", sizeof(ll)); // Any Chinese variant
else if (!strncmp(lang->language, "jp", 2))
- { /* Any Japanese variant */
+ { // Any Japanese variant
strlcpy(ll_CC, "ja", sizeof(ll_CC));
strlcpy(ll, "jp", sizeof(ll));
}
- else if (!strncmp(lang->language, "nb", 2) || !strncmp(lang->language, "no", 2))
- { /* Any Norwegian variant */
+ else if (!strncmp(lang->language, "nb", 2) ||
+ !strncmp(lang->language, "no", 2))
+ { // Any Norwegian variant
strlcpy(ll_CC, "nb", sizeof(ll_CC));
strlcpy(ll, "no", sizeof(ll));
}
ll_CC, ll));
}
- /*
- * Grab the first line and make sure it reads '*PPD-Adobe: "major.minor"'...
- */
+ //
+ // Grab the first line and make sure it reads '*PPD-Adobe: "major.minor"'...
+ //
line.buffer = NULL;
line.bufsize = 0;
mask = ppd_read(fp, &line, keyword, name, text, &string, 0, pg);
- DEBUG_printf(("2ppdOpenWithLocalization: mask=%x, keyword=\"%s\"...", mask, keyword));
+ DEBUG_printf(("2ppdOpenWithLocalization: mask=%x, keyword=\"%s\"...",
+ mask, keyword));
if (mask == 0 ||
strcmp(keyword, "PPD-Adobe") ||
string == NULL || string[0] != '4')
{
- /*
- * Either this is not a PPD file, or it is not a 4.x PPD file.
- */
+ //
+ // Either this is not a PPD file, or it is not a 4.x PPD file.
+ //
if (pg->ppd_status == PPD_OK)
pg->ppd_status = PPD_MISSING_PPDADOBE4;
return (NULL);
}
- DEBUG_printf(("2ppdOpenWithLocalization: keyword=%s, string=%p", keyword, string));
+ DEBUG_printf(("2ppdOpenWithLocalization: keyword=%s, string=%p",
+ keyword, string));
- /*
- * Allocate memory for the PPD file record...
- */
+ //
+ // Allocate memory for the PPD file record...
+ //
if ((ppd = calloc(1, sizeof(ppd_file_t))) == NULL)
{
ppd->color_device = 0;
ppd->colorspace = PPD_CS_N;
ppd->landscape = -90;
- ppd->coptions = cupsArrayNew((cups_array_func_t)ppd_compare_coptions, NULL);
+ ppd->coptions = cupsArrayNew((cups_array_func_t)ppd_compare_coptions,
+ NULL);
- /*
- * Read lines from the PPD file and add them to the file record...
- */
+ //
+ // Read lines from the PPD file and add them to the file record...
+ //
group = NULL;
subgroup = NULL;
if (strncmp(keyword, "Default", 7) && !string &&
pg->ppd_conform != PPD_CONFORM_RELAXED)
{
- /*
- * Need a string value!
- */
+ //
+ // Need a string value!
+ //
pg->ppd_status = PPD_MISSING_VALUE;
else if (!string)
continue;
- /*
- * Certain main keywords (as defined by the PPD spec) may be used
- * without the usual OpenUI/CloseUI stuff. Presumably this is just
- * so that Adobe wouldn't completely break compatibility with PPD
- * files prior to v4.0 of the spec, but it is hopelessly
- * inconsistent... Catch these main keywords and automatically
- * create the corresponding option, as needed...
- */
+ //
+ // Certain main keywords (as defined by the PPD spec) may be used
+ // without the usual OpenUI/CloseUI stuff. Presumably this is just
+ // so that Adobe wouldn't completely break compatibility with PPD
+ // files prior to v4.0 of the spec, but it is hopelessly
+ // inconsistent... Catch these main keywords and automatically
+ // create the corresponding option, as needed...
+ //
if (ui_keyword)
{
- /*
- * Previous line was a UI keyword...
- */
+ //
+ // Previous line was a UI keyword...
+ //
option = NULL;
ui_keyword = 0;
}
- /*
- * If we are filtering out keyword localizations, see if this line needs to
- * be used...
- */
+ //
+ // If we are filtering out keyword localizations, see if this line needs to
+ // be used...
+ //
if (localization != PPD_LOCALIZATION_ALL &&
(temp = strchr(keyword, '.')) != NULL &&
strncmp(ll_CC, keyword, ll_CC_len) &&
strncmp(ll, keyword, ll_len)))
{
- DEBUG_printf(("2ppdOpenWithLocalization: Ignoring localization: \"%s\"\n", keyword));
+ DEBUG_printf(("2ppdOpenWithLocalization: Ignoring localization: \"%s\"\n",
+ keyword));
free(string);
string = NULL;
continue;
}
else if (localization == PPD_LOCALIZATION_ICC_PROFILES)
{
- /*
- * Only load localizations for the color profile related keywords...
- */
+ //
+ // Only load localizations for the color profile related keywords...
+ //
for (i = 0;
i < (int)(sizeof(color_keywords) / sizeof(color_keywords[0]));
if (i < (int)(sizeof(ui_keywords) / sizeof(ui_keywords[0])))
{
- /*
- * Create the option in the appropriate group...
- */
+ //
+ // Create the option in the appropriate group...
+ //
ui_keyword = 1;
encoding)) == NULL)
goto error;
- DEBUG_printf(("2ppdOpenWithLocalization: Adding to group %s...", group->text));
+ DEBUG_printf(("2ppdOpenWithLocalization: Adding to group %s...",
+ group->text));
option = ppd_get_option(group, keyword);
group = NULL;
}
goto error;
}
- /*
- * Now fill in the initial information for the option...
- */
+ //
+ // Now fill in the initial information for the option...
+ //
if (!strncmp(keyword, "JCL", 3))
option->section = PPD_ORDER_JCL;
ppd->language_level = atoi(string);
else if (!strcmp(keyword, "LanguageEncoding"))
{
- /*
- * Say all PPD files are UTF-8, since we convert to UTF-8...
- */
+ //
+ // Say all PPD files are UTF-8, since we convert to UTF-8...
+ //
ppd->lang_encoding = strdup("UTF-8");
encoding = ppdGetEncoding(string);
{
if (encoding != CUPS_UTF8)
{
- cups_utf8_t utf8[256]; /* UTF-8 version of NickName */
+ cups_utf8_t utf8[256]; // UTF-8 version of NickName
cupsCharsetToUTF8(utf8, string, sizeof(utf8), encoding);
else if (!strcmp(keyword, "JCLBegin"))
{
ppd->jcl_begin = strdup(string);
- ppd_decode(ppd->jcl_begin); /* Decode quoted string */
+ ppd_decode(ppd->jcl_begin); // Decode quoted string
}
else if (!strcmp(keyword, "JCLEnd"))
{
ppd->jcl_end = strdup(string);
- ppd_decode(ppd->jcl_end); /* Decode quoted string */
+ ppd_decode(ppd->jcl_end); // Decode quoted string
}
else if (!strcmp(keyword, "JCLToPSInterpreter"))
{
ppd->jcl_ps = strdup(string);
- ppd_decode(ppd->jcl_ps); /* Decode quoted string */
+ ppd_decode(ppd->jcl_ps); // Decode quoted string
}
#if HAVE_CUPS_3_X
else if (!strcmp(keyword, "JCLToPDFInterpreter"))
{
ppd->jcl_pdf = strdup(string);
- ppd_decode(ppd->jcl_pdf); /* Decode quoted string */
+ ppd_decode(ppd->jcl_pdf); // Decode quoted string
}
#endif
else if (!strcmp(keyword, "AccurateScreensSupport"))
if (ppd->num_profiles == 0)
profile = malloc(sizeof(ppd_profile_t));
else
- profile = realloc(ppd->profiles, sizeof(ppd_profile_t) * (size_t)(ppd->num_profiles + 1));
+ profile = realloc(ppd->profiles, sizeof(ppd_profile_t) *
+ (size_t)(ppd->num_profiles + 1));
if (!profile)
{
if (ppd->num_filters == 0)
filter = malloc(sizeof(char *));
else
- filter = realloc(ppd->filters, sizeof(char *) * (size_t)(ppd->num_filters + 1));
+ filter = realloc(ppd->filters, sizeof(char *) *
+ (size_t)(ppd->num_filters + 1));
if (filter == NULL)
{
filter += ppd->num_filters;
ppd->num_filters ++;
- /*
- * Make a copy of the filter string...
- */
+ //
+ // Make a copy of the filter string...
+ //
*filter = strdup(string);
}
ppd->throughput = atoi(string);
else if (!strcmp(keyword, "Font"))
{
- /*
- * Add this font to the list of available fonts...
- */
+ //
+ // Add this font to the list of available fonts...
+ //
if (ppd->num_fonts == 0)
tempfonts = (char **)malloc(sizeof(char *));
else
- tempfonts = (char **)realloc(ppd->fonts, sizeof(char *) * (size_t)(ppd->num_fonts + 1));
+ tempfonts = (char **)realloc(ppd->fonts, sizeof(char *) *
+ (size_t)(ppd->num_fonts + 1));
if (tempfonts == NULL)
{
}
else if (!strncmp(keyword, "ParamCustom", 11))
{
- ppd_coption_t *coption; /* Custom option */
- ppd_cparam_t *cparam; /* Custom parameter */
- int corder; /* Order number */
- char ctype[33], /* Data type */
- cminimum[65], /* Minimum value */
- cmaximum[65]; /* Maximum value */
+ ppd_coption_t *coption; // Custom option
+ ppd_cparam_t *cparam; // Custom parameter
+ int corder; // Order number
+ char ctype[33], // Data type
+ cminimum[65], // Minimum value
+ cmaximum[65]; // Maximum value
- /*
- * Get the custom option and parameter...
- */
+ //
+ // Get the custom option and parameter...
+ //
if ((coption = ppd_get_coption(ppd, keyword + 11)) == NULL)
{
goto error;
}
- /*
- * Get the parameter data...
- */
+ //
+ // Get the parameter data...
+ //
if (!string ||
sscanf(string, "%d%32s%64s%64s", &corder, ctype, cminimum,
else if (!strcmp(ctype, "invcurve"))
{
cparam->type = PPD_CUSTOM_INVCURVE;
- cparam->minimum.custom_invcurve = (float)_ppdStrScand(cminimum, NULL, loc);
- cparam->maximum.custom_invcurve = (float)_ppdStrScand(cmaximum, NULL, loc);
+ cparam->minimum.custom_invcurve = (float)_ppdStrScand(cminimum, NULL,
+ loc);
+ cparam->maximum.custom_invcurve = (float)_ppdStrScand(cmaximum, NULL,
+ loc);
}
else if (!strcmp(ctype, "passcode"))
{
else if (!strcmp(ctype, "points"))
{
cparam->type = PPD_CUSTOM_POINTS;
- cparam->minimum.custom_points = (float)_ppdStrScand(cminimum, NULL, loc);
- cparam->maximum.custom_points = (float)_ppdStrScand(cmaximum, NULL, loc);
+ cparam->minimum.custom_points = (float)_ppdStrScand(cminimum, NULL,
+ loc);
+ cparam->maximum.custom_points = (float)_ppdStrScand(cmaximum, NULL,
+ loc);
}
else if (!strcmp(ctype, "real"))
{
goto error;
}
- /*
- * Now special-case for CustomPageSize...
- */
+ //
+ // Now special-case for CustomPageSize...
+ //
if (!strcmp(coption->keyword, "PageSize"))
{
}
else if (!strncmp(keyword, "Custom", 6) && !strcmp(name, "True") && !option)
{
- ppd_option_t *custom_option; /* Custom option */
+ ppd_option_t *custom_option; // Custom option
DEBUG_puts("2ppdOpenWithLocalization: Processing Custom option...");
- /*
- * Get the option and custom option...
- */
+ //
+ // Get the option and custom option...
+ //
if (!ppd_get_coption(ppd, keyword + 6))
{
if (custom_option)
{
- /*
- * Add the "custom" option...
- */
+ //
+ // Add the "custom" option...
+ //
if ((choice = ppdFindChoice(custom_option, "Custom")) == NULL)
if ((choice = ppd_add_choice(custom_option, "Custom")) == NULL)
ppd_decode(choice->code);
}
- /*
- * Now process custom page sizes specially...
- */
+ //
+ // Now process custom page sizes specially...
+ //
if (!strcmp(keyword, "CustomPageSize"))
{
- /*
- * Add a "Custom" page size entry...
- */
+ //
+ // Add a "Custom" page size entry...
+ //
ppd->variable_sizes = 1;
else if (!strcmp(string, "Plus90"))
ppd->landscape = 90;
}
- else if (!strcmp(keyword, "Emulators") && string && ppd->num_emulations == 0)
+ else if (!strcmp(keyword, "Emulators") && string &&
+ ppd->num_emulations == 0)
{
- /*
- * Issue #5562: Samsung printer drivers incorrectly use Emulators keyword
- * to configure themselves
- *
- * The Emulators keyword was loaded but never used by anything in CUPS,
- * and has no valid purpose in CUPS. The old code was removed due to a
- * memory leak (Issue #5475), so the following (new) code supports a single
- * name for the Emulators keyword, allowing these drivers to work until we
- * remove PPD and driver support entirely in a future version of CUPS.
- */
+ //
+ // Issue #5562: Samsung printer drivers incorrectly use Emulators keyword
+ // to configure themselves
+ //
+ // The Emulators keyword was loaded but never used by anything
+ // in CUPS, and has no valid purpose in CUPS. The old code was
+ // removed due to a memory leak (Issue #5475), so the following
+ // (new) code supports a single name for the Emulators keyword,
+ // allowing these drivers to work until we remove PPD and driver
+ // support entirely in a future version of CUPS.
+ //
ppd->num_emulations = 1;
ppd->emulations = calloc(1, sizeof(ppd_emul_t));
}
else if (!strcmp(keyword, "JobPatchFile"))
{
- /*
- * CUPS STR #3421: Check for "*JobPatchFile: int: string"
- */
+ //
+ // CUPS STR #3421: Check for "*JobPatchFile: int: string"
+ //
if (isdigit(*string & 255))
{
if (*sptr == ':')
{
- /*
- * Found "*JobPatchFile: int: string"...
- */
+ //
+ // Found "*JobPatchFile: int: string"...
+ //
pg->ppd_status = PPD_BAD_VALUE;
if (!name[0] && pg->ppd_conform == PPD_CONFORM_STRICT)
{
- /*
- * Found "*JobPatchFile: string"...
- */
+ //
+ // Found "*JobPatchFile: string"...
+ //
pg->ppd_status = PPD_MISSING_OPTION_KEYWORD;
}
else if (!strcmp(keyword, "OpenUI"))
{
- /*
- * Don't allow nesting of options...
- */
+ //
+ // Don't allow nesting of options...
+ //
if (option && pg->ppd_conform == PPD_CONFORM_STRICT)
{
goto error;
}
- /*
- * Add an option record to the current sub-group, group, or file...
- */
+ //
+ // Add an option record to the current sub-group, group, or file...
+ //
- DEBUG_printf(("2ppdOpenWithLocalization: name=\"%s\" (%d)", name, (int)strlen(name)));
+ DEBUG_printf(("2ppdOpenWithLocalization: name=\"%s\" (%d)",
+ name, (int)strlen(name)));
if (name[0] == '*')
- _ppd_strcpy(name, name + 1); /* Eliminate leading asterisk */
+ _ppd_strcpy(name, name + 1); // Eliminate leading asterisk
for (i = (int)strlen(name) - 1; i > 0 && _ppd_isspace(name[i]); i --)
- name[i] = '\0'; /* Eliminate trailing spaces */
+ name[i] = '\0'; // Eliminate trailing spaces
- DEBUG_printf(("2ppdOpenWithLocalization: OpenUI of %s in group %s...", name,
- group ? group->text : "(null)"));
+ DEBUG_printf(("2ppdOpenWithLocalization: OpenUI of %s in group %s...",
+ name, group ? group->text : "(null)"));
if (subgroup != NULL)
option = ppd_get_option(subgroup, name);
encoding)) == NULL)
goto error;
- DEBUG_printf(("2ppdOpenWithLocalization: Adding to group %s...", group->text));
+ DEBUG_printf(("2ppdOpenWithLocalization: Adding to group %s...",
+ group->text));
option = ppd_get_option(group, name);
group = NULL;
}
goto error;
}
- /*
- * Now fill in the initial information for the option...
- */
+ //
+ // Now fill in the initial information for the option...
+ //
if (string && !strcmp(string, "PickMany"))
option->ui = PPD_UI_PICKMANY;
free(string);
string = NULL;
- /*
- * Add a custom option choice if we have already seen a CustomFoo
- * attribute...
- */
+ //
+ // Add a custom option choice if we have already seen a CustomFoo
+ // attribute...
+ //
if (!_ppd_strcasecmp(name, "PageRegion"))
strlcpy(custom_name, "CustomPageSize", sizeof(custom_name));
}
else if (!strcmp(keyword, "JCLOpenUI"))
{
- /*
- * Don't allow nesting of options...
- */
+ //
+ // Don't allow nesting of options...
+ //
if (option && pg->ppd_conform == PPD_CONFORM_STRICT)
{
goto error;
}
- /*
- * Find the JCL group, and add if needed...
- */
+ //
+ // Find the JCL group, and add if needed...
+ //
group = ppd_get_group(ppd, "JCL", _("JCL"), pg, encoding);
if (group == NULL)
goto error;
- /*
- * Add an option record to the current JCLs...
- */
+ //
+ // Add an option record to the current JCLs...
+ //
if (name[0] == '*')
_ppd_strcpy(name, name + 1);
goto error;
}
- /*
- * Now fill in the initial information for the option...
- */
+ //
+ // Now fill in the initial information for the option...
+ //
if (string && !strcmp(string, "PickMany"))
option->ui = PPD_UI_PICKMANY;
free(string);
string = NULL;
- /*
- * Add a custom option choice if we have already seen a CustomFoo
- * attribute...
- */
+ //
+ // Add a custom option choice if we have already seen a CustomFoo
+ // attribute...
+ //
snprintf(custom_name, sizeof(custom_name), "Custom%.34s", name);
}
else if (!strcmp(keyword, "CloseUI"))
{
- if ((!option || option->section == PPD_ORDER_JCL) && pg->ppd_conform == PPD_CONFORM_STRICT)
+ if ((!option || option->section == PPD_ORDER_JCL) &&
+ pg->ppd_conform == PPD_CONFORM_STRICT)
{
pg->ppd_status = PPD_BAD_CLOSE_UI;
}
else if (!strcmp(keyword, "JCLCloseUI"))
{
- if ((!option || option->section != PPD_ORDER_JCL) && pg->ppd_conform == PPD_CONFORM_STRICT)
+ if ((!option || option->section != PPD_ORDER_JCL) &&
+ pg->ppd_conform == PPD_CONFORM_STRICT)
{
pg->ppd_status = PPD_BAD_CLOSE_UI;
}
else if (!strcmp(keyword, "OpenGroup"))
{
- /*
- * Open a new group...
- */
+ //
+ // Open a new group...
+ //
if (group != NULL)
{
goto error;
}
- /*
- * Separate the group name from the text (name/text)...
- */
+ //
+ // Separate the group name from the text (name/text)...
+ //
if ((sptr = strchr(string, '/')) != NULL)
*sptr++ = '\0';
else
sptr = string;
- /*
- * Fix up the text...
- */
+ //
+ // Fix up the text...
+ //
ppd_decode(sptr);
- /*
- * Find/add the group...
- */
+ //
+ // Find/add the group...
+ //
group = ppd_get_group(ppd, string, sptr, pg, encoding);
ppd_group_t *gtemp;
- /*
- * Only valid for Non-UI options...
- */
+ //
+ // Only valid for Non-UI options...
+ //
for (i = ppd->num_groups, gtemp = ppd->groups; i > 0; i --, gtemp ++)
if (gtemp->text[0] == '\0')
if (string == NULL)
continue;
- /*
- * Drop UI text, if any, from value...
- */
+ //
+ // Drop UI text, if any, from value...
+ //
if (strchr(string, '/') != NULL)
*strchr(string, '/') = '\0';
- /*
- * Assign the default value as appropriate...
- */
+ //
+ // Assign the default value as appropriate...
+ //
if (!strcmp(keyword, "DefaultColorSpace"))
{
- /*
- * Set default colorspace...
- */
+ //
+ // Set default colorspace...
+ //
if (!strcmp(string, "CMY"))
ppd->colorspace = PPD_CS_CMY;
}
else if (option && !strcmp(keyword + 7, option->keyword))
{
- /*
- * Set the default as part of the current option...
- */
+ //
+ // Set the default as part of the current option...
+ //
- DEBUG_printf(("2ppdOpenWithLocalization: Setting %s to %s...", keyword, string));
+ DEBUG_printf(("2ppdOpenWithLocalization: Setting %s to %s...",
+ keyword, string));
strlcpy(option->defchoice, string, sizeof(option->defchoice));
- DEBUG_printf(("2ppdOpenWithLocalization: %s is now %s...", keyword, option->defchoice));
+ DEBUG_printf(("2ppdOpenWithLocalization: %s is now %s...",
+ keyword, option->defchoice));
}
else
{
- /*
- * Lookup option and set if it has been defined...
- */
+ //
+ // Lookup option and set if it has been defined...
+ //
- ppd_option_t *toption; /* Temporary option */
+ ppd_option_t *toption; // Temporary option
if ((toption = ppdFindOption(ppd, keyword + 7)) != NULL)
{
- DEBUG_printf(("2ppdOpenWithLocalization: Setting %s to %s...", keyword, string));
+ DEBUG_printf(("2ppdOpenWithLocalization: Setting %s to %s...",
+ keyword, string));
strlcpy(toption->defchoice, string, sizeof(toption->defchoice));
}
}
if (ppd->num_consts == 0)
constraint = calloc(2, sizeof(ppd_const_t));
else
- constraint = realloc(ppd->consts, (size_t)(ppd->num_consts + 2) * sizeof(ppd_const_t));
+ constraint = realloc(ppd->consts, (size_t)(ppd->num_consts + 2) *
+ sizeof(ppd_const_t));
if (constraint == NULL)
{
constraint->choice1, constraint->option2,
constraint->choice2))
{
- default : /* Error */
+ default : // Error
pg->ppd_status = PPD_BAD_UI_CONSTRAINTS;
goto error;
- case 2 : /* Two options... */
- /*
- * Check for broken constraints like "* Option"...
- */
+ case 2 : // Two options...
+ //
+ // Check for broken constraints like "* Option"...
+ //
if (pg->ppd_conform == PPD_CONFORM_STRICT &&
(!strcmp(constraint->option1, "*") ||
goto error;
}
- /*
- * The following strcpy's are safe, as optionN and
- * choiceN are all the same size (size defined by PPD spec...)
- */
+ //
+ // The following strcpy's are safe, as optionN and
+ // choiceN are all the same size (size defined by PPD spec...)
+ //
if (constraint->option1[0] == '*')
_ppd_strcpy(constraint->option1, constraint->option1 + 1);
constraint->choice2[0] = '\0';
break;
- case 3 : /* Two options, one choice... */
- /*
- * Check for broken constraints like "* Option"...
- */
+ case 3 : // Two options, one choice...
+ //
+ // Check for broken constraints like "* Option"...
+ //
if (pg->ppd_conform == PPD_CONFORM_STRICT &&
(!strcmp(constraint->option1, "*") ||
goto error;
}
- /*
- * The following _ppd_strcpy's are safe, as optionN and
- * choiceN are all the same size (size defined by PPD spec...)
- */
+ //
+ // The following _ppd_strcpy's are safe, as optionN and
+ // choiceN are all the same size (size defined by PPD spec...)
+ //
if (constraint->option1[0] == '*')
_ppd_strcpy(constraint->option1, constraint->option1 + 1);
}
break;
- case 4 : /* Two options, two choices... */
- /*
- * Check for broken constraints like "* Option"...
- */
+ case 4 : // Two options, two choices...
+ //
+ // Check for broken constraints like "* Option"...
+ //
if (pg->ppd_conform == PPD_CONFORM_STRICT &&
(!strcmp(constraint->option1, "*") ||
break;
}
- /*
- * Don't add this one as an attribute...
- */
+ //
+ // Don't add this one as an attribute...
+ //
free(string);
string = NULL;
}
else if (!strcmp(keyword, "PaperDimension"))
{
- if (!_ppd_strcasecmp(name, "custom") || !_ppd_strncasecmp(name, "custom.", 7))
+ if (!_ppd_strcasecmp(name, "custom") ||
+ !_ppd_strncasecmp(name, "custom.", 7))
{
- char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */
+ char cname[PPD_MAX_NAME]; // Rewrite with a leading underscore
snprintf(cname, sizeof(cname), "_%.39s", name);
strlcpy(name, cname, sizeof(name));
}
if (size == NULL)
{
- /*
- * Unable to add or find size!
- */
+ //
+ // Unable to add or find size!
+ //
pg->ppd_status = PPD_ALLOC_ERROR;
{
if (!_ppd_strcasecmp(name, "custom") || !_ppd_strncasecmp(name, "custom.", 7))
{
- char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */
+ char cname[PPD_MAX_NAME]; // Rewrite with a leading underscore
snprintf(cname, sizeof(cname), "_%.39s", name);
strlcpy(name, cname, sizeof(name));
}
if (size == NULL)
{
- /*
- * Unable to add or find size!
- */
+ //
+ // Unable to add or find size!
+ //
pg->ppd_status = PPD_ALLOC_ERROR;
if (!_ppd_strcasecmp(name, "custom") || !_ppd_strncasecmp(name, "custom.", 7))
{
- char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */
+ char cname[PPD_MAX_NAME]; // Rewrite with a leading underscore
snprintf(cname, sizeof(cname), "_%.39s", name);
strlcpy(name, cname, sizeof(name));
}
if (!strcmp(keyword, "PageSize"))
{
- /*
- * Add a page size...
- */
+ //
+ // Add a page size...
+ //
if (ppdPageSize(ppd, name) == NULL)
ppd_add_size(ppd, name);
}
- /*
- * Add the option choice...
- */
+ //
+ // Add the option choice...
+ //
if ((choice = ppd_add_choice(option, name)) == NULL)
{
strlcpy(choice->text, name, sizeof(choice->text));
if (option->section == PPD_ORDER_JCL)
- ppd_decode(string); /* Decode quoted string */
+ ppd_decode(string); // Decode quoted string
choice->code = string;
- string = NULL; /* Don't add as an attribute below */
+ string = NULL; // Don't add as an attribute below
}
- /*
- * Add remaining lines with keywords and string values as attributes...
- */
+ //
+ // Add remaining lines with keywords and string values as attributes...
+ //
if (string &&
(mask & (PPD_KEYWORD | PPD_STRING)) == (PPD_KEYWORD | PPD_STRING))
free(string);
}
- /*
- * Check for a missing CloseUI/JCLCloseUI...
- */
+ //
+ // Check for a missing CloseUI/JCLCloseUI...
+ //
if (option && pg->ppd_conform == PPD_CONFORM_STRICT)
{
goto error;
}
- /*
- * Check for a missing CloseGroup...
- */
+ //
+ // Check for a missing CloseGroup...
+ //
if (group && pg->ppd_conform == PPD_CONFORM_STRICT)
{
free(line.buffer);
- /*
- * Reset language preferences...
- */
+ //
+ // Reset language preferences...
+ //
#ifdef DEBUG
if (!cupsFileEOF(fp))
DEBUG_printf(("1ppdOpenWithLocalization: Premature EOF at %lu...\n",
(unsigned long)cupsFileTell(fp)));
-#endif /* DEBUG */
+#endif // DEBUG
if (pg->ppd_status != PPD_OK)
{
- /*
- * Had an error reading the PPD file, cannot continue!
- */
+ //
+ // Had an error reading the PPD file, cannot continue!
+ //
ppdClose(ppd);
return (NULL);
}
- /*
- * Update the filters array as needed...
- */
+ //
+ // Update the filters array as needed...
+ //
if (!ppd_update_filters(ppd, pg))
{
return (NULL);
}
- /*
- * Create the sorted options array and set the option back-pointer for
- * each choice and custom option...
- */
+ //
+ // Create the sorted options array and set the option back-pointer for
+ // each choice and custom option...
+ //
ppd->options = cupsArrayNew2((cups_array_func_t)ppd_compare_options, NULL,
(cups_ahash_func_t)ppd_hash_option,
j > 0;
j --, option ++)
{
- ppd_coption_t *coption; /* Custom option */
+ ppd_coption_t *coption; // Custom option
cupsArrayAdd(ppd->options, option);
}
}
- /*
- * Create an array to track the marked choices...
- */
+ //
+ // Create an array to track the marked choices...
+ //
ppd->marked = cupsArrayNew((cups_array_func_t)ppd_compare_choices, NULL);
- /*
- * Return the PPD file structure...
- */
+ //
+ // Return the PPD file structure...
+ //
return (ppd);
- /*
- * Common exit point for errors to save code size...
- */
+ //
+ // Common exit point for errors to save code size...
+ //
- error:
+ error:
free(string);
free(line.buffer);
}
-/*
- * 'ppdOpen()' - Read a PPD file into memory.
- */
+//
+// 'ppdOpen()' - Read a PPD file into memory.
+//
-ppd_file_t * /* O - PPD file record */
-ppdOpen(FILE *fp) /* I - File to read from */
+ppd_file_t * // O - PPD file record
+ppdOpen(FILE *fp) // I - File to read from
{
- ppd_file_t *ppd; /* PPD file record */
- cups_file_t *cf; /* CUPS file */
+ ppd_file_t *ppd; // PPD file record
+ cups_file_t *cf; // CUPS file
- /*
- * Reopen the stdio file as a CUPS file...
- */
+ //
+ // Reopen the stdio file as a CUPS file...
+ //
if ((cf = cupsFileOpenFd(fileno(fp), "r")) == NULL)
return (NULL);
- /*
- * Load the PPD file using the newer API...
- */
+ //
+ // Load the PPD file using the newer API...
+ //
ppd = ppdOpenWithLocalization(cf, PPD_LOCALIZATION_DEFAULT);
- /*
- * Close the CUPS file and return the PPD...
- */
+ //
+ // Close the CUPS file and return the PPD...
+ //
cupsFileClose(cf);
}
-/*
- * 'ppdOpen2()' - Read a PPD file into memory.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ppdOpen2()' - Read a PPD file into memory.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ppd_file_t * /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
-ppdOpen2(cups_file_t *fp) /* I - File to read from */
+ppd_file_t * // O - PPD file record or @code NULL@
+ // if the PPD file could not be
+ // opened.
+ppdOpen2(cups_file_t *fp) // I - File to read from
{
return ppdOpenWithLocalization(fp, PPD_LOCALIZATION_DEFAULT);
}
-/*
- * 'ppdOpenFd()' - Read a PPD file into memory.
- */
+//
+// 'ppdOpenFd()' - Read a PPD file into memory.
+//
-ppd_file_t * /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
-ppdOpenFd(int fd) /* I - File to read from */
+ppd_file_t * // O - PPD file record or @code NULL@
+ // if the PPD file could not be
+ // opened.
+ppdOpenFd(int fd) // I - File to read from
{
- cups_file_t *fp; /* CUPS file pointer */
- ppd_file_t *ppd; /* PPD file record */
- ppd_globals_t *pg = ppdGlobals();
- /* Global data */
+ cups_file_t *fp; // CUPS file pointer
+ ppd_file_t *ppd; // PPD file record
+ ppd_globals_t *pg = ppdGlobals(); // Global data
- /*
- * Set the line number to 0...
- */
+ //
+ // Set the line number to 0...
+ //
pg->ppd_line = 0;
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (fd < 0)
{
return (NULL);
}
- /*
- * Try to open the file and parse it...
- */
+ //
+ // Try to open the file and parse it...
+ //
if ((fp = cupsFileOpenFd(fd, "r")) != NULL)
{
}
-/*
- * 'ppdOpenFileWithLocalization()' - Read a PPD file into memory.
- */
+//
+// 'ppdOpenFileWithLocalization()' - Read a PPD file into memory.
+//
-ppd_file_t * /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
-ppdOpenFileWithLocalization(const char *filename, /* I - File to read from */
- ppd_localization_t localization) /* I - Localization to load */
+ppd_file_t * // O - PPD file record or @code NULL@
+ // if the PPD file could not be
+ // opened.
+ppdOpenFileWithLocalization(
+ const char *filename, // I - File to read from
+ ppd_localization_t localization) // I - Localization to load
{
- cups_file_t *fp; /* File pointer */
- ppd_file_t *ppd; /* PPD file record */
- ppd_globals_t *pg = ppdGlobals();
- /* Global data */
+ cups_file_t *fp; // File pointer
+ ppd_file_t *ppd; // PPD file record
+ ppd_globals_t *pg = ppdGlobals(); // Global data
- /*
- * Set the line number to 0...
- */
+ //
+ // Set the line number to 0...
+ //
pg->ppd_line = 0;
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (filename == NULL)
{
return (NULL);
}
- /*
- * Try to open the file and parse it...
- */
+ //
+ // Try to open the file and parse it...
+ //
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
}
-/*
- * 'ppdOpenFile()' - Read a PPD file into memory.
- */
+//
+// 'ppdOpenFile()' - Read a PPD file into memory.
+//
-ppd_file_t * /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
-ppdOpenFile(const char *filename) /* I - File to read from */
+ppd_file_t * // O - PPD file record or @code NULL@
+ // if the PPD file could not be
+ // opened.
+ppdOpenFile(const char *filename) // I - File to read from
{
return ppdOpenFileWithLocalization(filename, PPD_LOCALIZATION_DEFAULT);
}
-/*
- * 'ppdSetConformance()' - Set the conformance level for PPD files.
- *
- * @since CUPS 1.1.20/macOS 10.4@
- */
+//
+// 'ppdSetConformance()' - Set the conformance level for PPD files.
+//
+// @since CUPS 1.1.20/macOS 10.4@
+//
void
-ppdSetConformance(ppd_conform_t c) /* I - Conformance level */
+ppdSetConformance(ppd_conform_t c) // I - Conformance level
{
- ppd_globals_t *pg = ppdGlobals();
- /* Global data */
+ ppd_globals_t *pg = ppdGlobals(); // Global data
pg->ppd_conform = c;
}
-/*
- * 'ppd_add_attr()' - Add an attribute to the PPD data.
- */
+//
+// 'ppd_add_attr()' - Add an attribute to the PPD data.
+//
-static ppd_attr_t * /* O - New attribute */
-ppd_add_attr(ppd_file_t *ppd, /* I - PPD file data */
- const char *name, /* I - Attribute name */
- const char *spec, /* I - Specifier string, if any */
- const char *text, /* I - Text string, if any */
- const char *value) /* I - Value of attribute */
+static ppd_attr_t * // O - New attribute
+ppd_add_attr(ppd_file_t *ppd, // I - PPD file data
+ const char *name, // I - Attribute name
+ const char *spec, // I - Specifier string, if any
+ const char *text, // I - Text string, if any
+ const char *value) // I - Value of attribute
{
- ppd_attr_t **ptr, /* New array */
- *temp; /* New attribute */
+ ppd_attr_t **ptr, // New array
+ *temp; // New attribute
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (ppd == NULL || name == NULL || spec == NULL)
return (NULL);
- /*
- * Create the array as needed...
- */
+ //
+ // Create the array as needed...
+ //
if (!ppd->sorted_attrs)
ppd->sorted_attrs = cupsArrayNew((cups_array_func_t)ppd_compare_attrs,
NULL);
- /*
- * Allocate memory for the new attribute...
- */
+ //
+ // Allocate memory for the new attribute...
+ //
if (ppd->num_attrs == 0)
ptr = malloc(sizeof(ppd_attr_t *));
else
- ptr = realloc(ppd->attrs, (size_t)(ppd->num_attrs + 1) * sizeof(ppd_attr_t *));
+ ptr = realloc(ppd->attrs, (size_t)(ppd->num_attrs + 1) *
+ sizeof(ppd_attr_t *));
if (ptr == NULL)
return (NULL);
ppd->num_attrs ++;
- /*
- * Copy data over...
- */
+ //
+ // Copy data over...
+ //
strlcpy(temp->name, name, sizeof(temp->name));
strlcpy(temp->spec, spec, sizeof(temp->spec));
strlcpy(temp->text, text, sizeof(temp->text));
temp->value = (char *)value;
- /*
- * Add the attribute to the sorted array...
- */
+ //
+ // Add the attribute to the sorted array...
+ //
cupsArrayAdd(ppd->sorted_attrs, temp);
- /*
- * Return the attribute...
- */
+ //
+ // Return the attribute...
+ //
return (temp);
}
-/*
- * 'ppd_add_choice()' - Add a choice to an option.
- */
+//
+// 'ppd_add_choice()' - Add a choice to an option.
+//
-static ppd_choice_t * /* O - Named choice */
-ppd_add_choice(ppd_option_t *option, /* I - Option */
- const char *name) /* I - Name of choice */
+static ppd_choice_t * // O - Named choice
+ppd_add_choice(ppd_option_t *option, // I - Option
+ const char *name) // I - Name of choice
{
- ppd_choice_t *choice; /* Choice */
+ ppd_choice_t *choice; // Choice
if (option->num_choices == 0)
choice = malloc(sizeof(ppd_choice_t));
else
- choice = realloc(option->choices, sizeof(ppd_choice_t) * (size_t)(option->num_choices + 1));
+ choice = realloc(option->choices, sizeof(ppd_choice_t) *
+ (size_t)(option->num_choices + 1));
if (choice == NULL)
return (NULL);
}
-/*
- * 'ppd_add_size()' - Add a page size.
- */
+//
+// 'ppd_add_size()' - Add a page size.
+//
-static ppd_size_t * /* O - Named size */
-ppd_add_size(ppd_file_t *ppd, /* I - PPD file */
- const char *name) /* I - Name of size */
+static ppd_size_t * // O - Named size
+ppd_add_size(ppd_file_t *ppd, // I - PPD file
+ const char *name) // I - Name of size
{
- ppd_size_t *size; /* Size */
+ ppd_size_t *size; // Size
if (ppd->num_sizes == 0)
size = malloc(sizeof(ppd_size_t));
else
- size = realloc(ppd->sizes, sizeof(ppd_size_t) * (size_t)(ppd->num_sizes + 1));
+ size = realloc(ppd->sizes, sizeof(ppd_size_t) *
+ (size_t)(ppd->num_sizes + 1));
if (size == NULL)
return (NULL);
}
-/*
- * 'ppd_compare_attrs()' - Compare two attributes.
- */
+//
+// 'ppd_compare_attrs()' - Compare two attributes.
+//
-static int /* O - Result of comparison */
-ppd_compare_attrs(ppd_attr_t *a, /* I - First attribute */
- ppd_attr_t *b) /* I - Second attribute */
+static int // O - Result of comparison
+ppd_compare_attrs(ppd_attr_t *a, // I - First attribute
+ ppd_attr_t *b) // I - Second attribute
{
return (_ppd_strcasecmp(a->name, b->name));
}
-/*
- * 'ppd_compare_choices()' - Compare two choices...
- */
+//
+// 'ppd_compare_choices()' - Compare two choices...
+//
-static int /* O - Result of comparison */
-ppd_compare_choices(ppd_choice_t *a, /* I - First choice */
- ppd_choice_t *b) /* I - Second choice */
+static int // O - Result of comparison
+ppd_compare_choices(ppd_choice_t *a, // I - First choice
+ ppd_choice_t *b) // I - Second choice
{
return (strcmp(a->option->keyword, b->option->keyword));
}
-/*
- * 'ppd_compare_coptions()' - Compare two custom options.
- */
+//
+// 'ppd_compare_coptions()' - Compare two custom options.
+//
-static int /* O - Result of comparison */
-ppd_compare_coptions(ppd_coption_t *a, /* I - First option */
- ppd_coption_t *b) /* I - Second option */
+static int // O - Result of comparison
+ppd_compare_coptions(ppd_coption_t *a, // I - First option
+ ppd_coption_t *b) // I - Second option
{
return (_ppd_strcasecmp(a->keyword, b->keyword));
}
-/*
- * 'ppd_compare_options()' - Compare two options.
- */
+//
+// 'ppd_compare_options()' - Compare two options.
+//
-static int /* O - Result of comparison */
-ppd_compare_options(ppd_option_t *a, /* I - First option */
- ppd_option_t *b) /* I - Second option */
+static int // O - Result of comparison
+ppd_compare_options(ppd_option_t *a, // I - First option
+ ppd_option_t *b) // I - Second option
{
return (_ppd_strcasecmp(a->keyword, b->keyword));
}
-/*
- * 'ppd_decode()' - Decode a string value...
- */
+//
+// 'ppd_decode()' - Decode a string value...
+//
-static int /* O - Length of decoded string */
-ppd_decode(char *string) /* I - String to decode */
+static int // O - Length of decoded string
+ppd_decode(char *string) // I - String to decode
{
- char *inptr, /* Input pointer */
- *outptr; /* Output pointer */
+ char *inptr, // Input pointer
+ *outptr; // Output pointer
inptr = string;
while (*inptr != '\0')
if (*inptr == '<' && isxdigit(inptr[1] & 255))
{
- /*
- * Convert hex to 8-bit values...
- */
+ //
+ // Convert hex to 8-bit values...
+ //
inptr ++;
while (isxdigit(*inptr & 255))
}
-/*
- * 'ppd_free_filters()' - Free the filters array.
- */
+//
+// 'ppd_free_filters()' - Free the filters array.
+//
static void
-ppd_free_filters(ppd_file_t *ppd) /* I - PPD file */
+ppd_free_filters(ppd_file_t *ppd) // I - PPD file
{
- int i; /* Looping var */
- char **filter; /* Current filter */
+ int i; // Looping var
+ char **filter; // Current filter
if (ppd->num_filters > 0)
}
-/*
- * 'ppd_free_group()' - Free a single UI group.
- */
+//
+// 'ppd_free_group()' - Free a single UI group.
+//
static void
-ppd_free_group(ppd_group_t *group) /* I - Group to free */
+ppd_free_group(ppd_group_t *group) // I - Group to free
{
- int i; /* Looping var */
- ppd_option_t *option; /* Current option */
- ppd_group_t *subgroup; /* Current sub-group */
+ int i; // Looping var
+ ppd_option_t *option; // Current option
+ ppd_group_t *subgroup; // Current sub-group
if (group->num_options > 0)
}
-/*
- * 'ppd_free_option()' - Free a single option.
- */
+//
+// 'ppd_free_option()' - Free a single option.
+//
static void
-ppd_free_option(ppd_option_t *option) /* I - Option to free */
+ppd_free_option(ppd_option_t *option) // I - Option to free
{
- int i; /* Looping var */
- ppd_choice_t *choice; /* Current choice */
+ int i; // Looping var
+ ppd_choice_t *choice; // Current choice
if (option->num_choices > 0)
}
-/*
- * 'ppd_get_coption()' - Get a custom option record.
- */
+//
+// 'ppd_get_coption()' - Get a custom option record.
+//
-static ppd_coption_t * /* O - Custom option... */
-ppd_get_coption(ppd_file_t *ppd, /* I - PPD file */
- const char *name) /* I - Name of option */
+static ppd_coption_t * // O - Custom option...
+ppd_get_coption(ppd_file_t *ppd, // I - PPD file
+ const char *name) // I - Name of option
{
- ppd_coption_t *copt; /* New custom option */
+ ppd_coption_t *copt; // New custom option
- /*
- * See if the option already exists...
- */
+ //
+ // See if the option already exists...
+ //
if ((copt = ppdFindCustomOption(ppd, name)) != NULL)
return (copt);
- /*
- * Not found, so create the custom option record...
- */
+ //
+ // Not found, so create the custom option record...
+ //
if ((copt = calloc(1, sizeof(ppd_coption_t))) == NULL)
return (NULL);
cupsArrayAdd(ppd->coptions, copt);
- /*
- * Return the new record...
- */
+ //
+ // Return the new record...
+ //
return (copt);
}
-/*
- * 'ppd_get_cparam()' - Get a custom parameter record.
- */
+//
+// 'ppd_get_cparam()' - Get a custom parameter record.
+//
-static ppd_cparam_t * /* O - Extended option... */
-ppd_get_cparam(ppd_coption_t *opt, /* I - PPD file */
- const char *param, /* I - Name of parameter */
- const char *text) /* I - Human-readable text */
+static ppd_cparam_t * // O - Extended option...
+ppd_get_cparam(ppd_coption_t *opt, // I - PPD file
+ const char *param, // I - Name of parameter
+ const char *text) // I - Human-readable text
{
- ppd_cparam_t *cparam; /* New custom parameter */
+ ppd_cparam_t *cparam; // New custom parameter
- /*
- * See if the parameter already exists...
- */
+ //
+ // See if the parameter already exists...
+ //
if ((cparam = ppdFindCustomParam(opt, param)) != NULL)
return (cparam);
- /*
- * Not found, so create the custom parameter record...
- */
+ //
+ // Not found, so create the custom parameter record...
+ //
if ((cparam = calloc(1, sizeof(ppd_cparam_t))) == NULL)
return (NULL);
strlcpy(cparam->name, param, sizeof(cparam->name));
strlcpy(cparam->text, text[0] ? text : param, sizeof(cparam->text));
- /*
- * Add this record to the array...
- */
+ //
+ // Add this record to the array...
+ //
cupsArrayAdd(opt->params, cparam);
- /*
- * Return the new record...
- */
+ //
+ // Return the new record...
+ //
return (cparam);
}
-/*
- * 'ppd_get_group()' - Find or create the named group as needed.
- */
+//
+// 'ppd_get_group()' - Find or create the named group as needed.
+//
-static ppd_group_t * /* O - Named group */
-ppd_get_group(ppd_file_t *ppd, /* I - PPD file */
- const char *name, /* I - Name of group */
- const char *text, /* I - Text for group */
- ppd_globals_t *pg, /* I - Global data */
- cups_encoding_t encoding) /* I - Encoding of text */
+static ppd_group_t * // O - Named group
+ppd_get_group(ppd_file_t *ppd, // I - PPD file
+ const char *name, // I - Name of group
+ const char *text, // I - Text for group
+ ppd_globals_t *pg, // I - Global data
+ cups_encoding_t encoding) // I - Encoding of text
{
- int i; /* Looping var */
- ppd_group_t *group; /* Group */
+ int i; // Looping var
+ ppd_group_t *group; // Group
DEBUG_printf(("7ppd_get_group(ppd=%p, name=\"%s\", text=\"%s\", cg=%p)",
{
DEBUG_printf(("8ppd_get_group: Adding group %s...", name));
- if (pg->ppd_conform == PPD_CONFORM_STRICT && strlen(text) >= sizeof(group->text))
+ if (pg->ppd_conform == PPD_CONFORM_STRICT &&
+ strlen(text) >= sizeof(group->text))
{
pg->ppd_status = PPD_ILLEGAL_TRANSLATION;
if (ppd->num_groups == 0)
group = malloc(sizeof(ppd_group_t));
else
- group = realloc(ppd->groups, (size_t)(ppd->num_groups + 1) * sizeof(ppd_group_t));
+ group = realloc(ppd->groups, (size_t)(ppd->num_groups + 1) *
+ sizeof(ppd_group_t));
if (group == NULL)
{
}
-/*
- * 'ppd_get_option()' - Find or create the named option as needed.
- */
+//
+// 'ppd_get_option()' - Find or create the named option as needed.
+//
-static ppd_option_t * /* O - Named option */
-ppd_get_option(ppd_group_t *group, /* I - Group */
- const char *name) /* I - Name of option */
+static ppd_option_t * // O - Named option
+ppd_get_option(ppd_group_t *group, // I - Group
+ const char *name) // I - Name of option
{
- int i; /* Looping var */
- ppd_option_t *option; /* Option */
+ int i; // Looping var
+ ppd_option_t *option; // Option
DEBUG_printf(("7ppd_get_option(group=%p(\"%s\"), name=\"%s\")",
if (group->num_options == 0)
option = malloc(sizeof(ppd_option_t));
else
- option = realloc(group->options, (size_t)(group->num_options + 1) * sizeof(ppd_option_t));
+ option = realloc(group->options, (size_t)(group->num_options + 1) *
+ sizeof(ppd_option_t));
if (option == NULL)
return (NULL);
}
-/*
- * 'ppd_globals_alloc()' - Allocate and initialize global data.
- */
+//
+// 'ppd_globals_alloc()' - Allocate and initialize global data.
+//
-static ppd_globals_t * /* O - Pointer to global data */
+static ppd_globals_t * // O - Pointer to global data
ppd_globals_alloc(void)
{
return ((ppd_globals_t *)calloc(1, sizeof(ppd_globals_t)));
}
-/*
- * 'ppd_globals_free()' - Free global data.
- */
+//
+// 'ppd_globals_free()' - Free global data.
+//
#if defined(HAVE_PTHREAD_H) || defined(_WIN32)
static void
-ppd_globals_free(ppd_globals_t *pg) /* I - Pointer to global data */
+ppd_globals_free(ppd_globals_t *pg) // I - Pointer to global data
{
free(pg);
}
-#endif /* HAVE_PTHREAD_H || _WIN32 */
+#endif // HAVE_PTHREAD_H || _WIN32
#ifdef HAVE_PTHREAD_H
-/*
- * 'ppd_globals_init()' - Initialize per-thread globals...
- */
+//
+// 'ppd_globals_init()' - Initialize per-thread globals...
+//
static void
ppd_globals_init(void)
{
- /*
- * Register the global data for this thread...
- */
+ //
+ // Register the global data for this thread...
+ //
pthread_key_create(&ppd_globals_key, (void (*)(void *))ppd_globals_free);
}
-#endif /* HAVE_PTHREAD_H */
+#endif // HAVE_PTHREAD_H
-/*
- * 'ppd_hash_option()' - Generate a hash of the option name...
- */
+//
+// 'ppd_hash_option()' - Generate a hash of the option name...
+//
-static int /* O - Hash index */
-ppd_hash_option(ppd_option_t *option) /* I - Option */
+static int // O - Hash index
+ppd_hash_option(ppd_option_t *option) // I - Option
{
- int hash = 0; /* Hash index */
- const char *k; /* Pointer into keyword */
+ int hash = 0; // Hash index
+ const char *k; // Pointer into keyword
for (hash = option->keyword[0], k = option->keyword + 1; *k;)
}
-/*
- * 'ppd_read()' - Read a line from a PPD file, skipping comment lines as
- * necessary.
- */
-
-static int /* O - Bitmask of fields read */
-ppd_read(cups_file_t *fp, /* I - File to read from */
- _ppd_line_t *line, /* I - Line buffer */
- char *keyword, /* O - Keyword from line */
- char *option, /* O - Option from line */
- char *text, /* O - Human-readable text from line */
- char **string, /* O - Code/string data */
- int ignoreblank, /* I - Ignore blank lines? */
- ppd_globals_t *pg) /* I - Global data */
+//
+// 'ppd_read()' - Read a line from a PPD file, skipping comment lines as
+// necessary.
+//
+
+static int // O - Bitmask of fields read
+ppd_read(cups_file_t *fp, // I - File to read from
+ _ppd_line_t *line, // I - Line buffer
+ char *keyword, // O - Keyword from line
+ char *option, // O - Option from line
+ char *text, // O - Human-readable text from line
+ char **string, // O - Code/string data
+ int ignoreblank, // I - Ignore blank lines?
+ ppd_globals_t *pg) // I - Global data
{
- int ch, /* Character from file */
- col, /* Column in line */
- colon, /* Colon seen? */
- endquote, /* Waiting for an end quote */
- mask, /* Mask to be returned */
- startline, /* Start line */
- textlen; /* Length of text */
- char *keyptr, /* Keyword pointer */
- *optptr, /* Option pointer */
- *textptr, /* Text pointer */
- *strptr, /* Pointer into string */
- *lineptr; /* Current position in line buffer */
-
-
- /*
- * Now loop until we have a valid line...
- */
+ int ch, // Character from file
+ col, // Column in line
+ colon, // Colon seen?
+ endquote, // Waiting for an end quote
+ mask, // Mask to be returned
+ startline, // Start line
+ textlen; // Length of text
+ char *keyptr, // Keyword pointer
+ *optptr, // Option pointer
+ *textptr, // Text pointer
+ *strptr, // Pointer into string
+ *lineptr; // Current position in line buffer
+
+
+ //
+ // Now loop until we have a valid line...
+ //
*string = NULL;
col = 0;
do
{
- /*
- * Read the line...
- */
+ //
+ // Read the line...
+ //
lineptr = line->buffer;
endquote = 0;
{
if (lineptr >= (line->buffer + line->bufsize - 1))
{
- /*
- * Expand the line buffer...
- */
+ //
+ // Expand the line buffer...
+ //
- char *temp; /* Temporary line pointer */
+ char *temp; // Temporary line pointer
line->bufsize += 1024;
if (line->bufsize > 262144)
{
- /*
- * Don't allow lines longer than 256k!
- */
+ //
+ // Don't allow lines longer than 256k!
+ //
pg->ppd_line = startline;
pg->ppd_status = PPD_LINE_TOO_LONG;
if (ch == '\r' || ch == '\n')
{
- /*
- * Line feed or carriage return...
- */
+ //
+ // Line feed or carriage return...
+ //
pg->ppd_line ++;
col = 0;
if (ch == '\r')
{
- /*
- * Check for a trailing line feed...
- */
+ //
+ // Check for a trailing line feed...
+ //
if ((ch = cupsFilePeekChar(fp)) == EOF)
{
}
if (lineptr == line->buffer && ignoreblank)
- continue; /* Skip blank lines */
+ continue; // Skip blank lines
ch = '\n';
- if (!endquote) /* Continue for multi-line text */
+ if (!endquote) // Continue for multi-line text
break;
*lineptr++ = '\n';
}
else if (ch < ' ' && ch != '\t' && pg->ppd_conform == PPD_CONFORM_STRICT)
{
- /*
- * Other control characters...
- */
+ //
+ // Other control characters...
+ //
pg->ppd_line = startline;
pg->ppd_status = PPD_ILLEGAL_CHARACTER;
}
else if (ch != 0x1a)
{
- /*
- * Any other character...
- */
+ //
+ // Any other character...
+ //
*lineptr++ = (char)ch;
col ++;
if (col > (PPD_MAX_LINE - 1))
{
- /*
- * Line is too long...
- */
+ //
+ // Line is too long...
+ //
pg->ppd_line = startline;
pg->ppd_status = PPD_LINE_TOO_LONG;
if (endquote)
{
- /*
- * Didn't finish this quoted string...
- */
+ //
+ // Didn't finish this quoted string...
+ //
while ((ch = cupsFileGetChar(fp)) != EOF)
if (ch == '\"')
if (ch == '\r')
{
- /*
- * Check for a trailing line feed...
- */
+ //
+ // Check for a trailing line feed...
+ //
if ((ch = cupsFilePeekChar(fp)) == EOF)
break;
cupsFileGetChar(fp);
}
}
- else if (ch < ' ' && ch != '\t' && pg->ppd_conform == PPD_CONFORM_STRICT)
+ else if (ch < ' ' && ch != '\t' &&
+ pg->ppd_conform == PPD_CONFORM_STRICT)
{
- /*
- * Other control characters...
- */
+ //
+ // Other control characters...
+ //
pg->ppd_line = startline;
pg->ppd_status = PPD_ILLEGAL_CHARACTER;
if (col > (PPD_MAX_LINE - 1))
{
- /*
- * Line is too long...
- */
+ //
+ // Line is too long...
+ //
pg->ppd_line = startline;
pg->ppd_status = PPD_LINE_TOO_LONG;
if (ch != '\n')
{
- /*
- * Didn't finish this line...
- */
+ //
+ // Didn't finish this line...
+ //
while ((ch = cupsFileGetChar(fp)) != EOF)
if (ch == '\r' || ch == '\n')
{
- /*
- * Line feed or carriage return...
- */
+ //
+ // Line feed or carriage return...
+ //
pg->ppd_line ++;
col = 0;
if (ch == '\r')
{
- /*
- * Check for a trailing line feed...
- */
+ //
+ // Check for a trailing line feed...
+ //
if ((ch = cupsFilePeekChar(fp)) == EOF)
break;
break;
}
- else if (ch < ' ' && ch != '\t' && pg->ppd_conform == PPD_CONFORM_STRICT)
+ else if (ch < ' ' && ch != '\t' &&
+ pg->ppd_conform == PPD_CONFORM_STRICT)
{
- /*
- * Other control characters...
- */
+ //
+ // Other control characters...
+ //
pg->ppd_line = startline;
pg->ppd_status = PPD_ILLEGAL_CHARACTER;
if (col > (PPD_MAX_LINE - 1))
{
- /*
- * Line is too long...
- */
+ //
+ // Line is too long...
+ //
pg->ppd_line = startline;
pg->ppd_status = PPD_LINE_TOO_LONG;
DEBUG_printf(("9ppd_read: LINE=\"%s\"", line->buffer));
- /*
- * The dynamically created PPDs for older style macOS
- * drivers include a large blob of data inserted as comments
- * at the end of the file. As an optimization we can stop
- * reading the PPD when we get to the start of this data.
- */
+ //
+ // The dynamically created PPDs for older style macOS
+ // drivers include a large blob of data inserted as comments
+ // at the end of the file. As an optimization we can stop
+ // reading the PPD when we get to the start of this data.
+ //
if (!strcmp(line->buffer, "*%APLWORKSET START"))
return (0);
if (ch == EOF && lineptr == line->buffer)
return (0);
- /*
- * Now parse it...
- */
+ //
+ // Now parse it...
+ //
mask = 0;
lineptr = line->buffer + 1;
text[0] = '\0';
*string = NULL;
- if ((!line->buffer[0] || /* Blank line */
- !strncmp(line->buffer, "*%", 2) || /* Comment line */
- !strcmp(line->buffer, "*End")) && /* End of multi-line string */
- ignoreblank) /* Ignore these? */
+ if ((!line->buffer[0] || // Blank line
+ !strncmp(line->buffer, "*%", 2) || // Comment line
+ !strcmp(line->buffer, "*End")) && // End of multi-line string
+ ignoreblank) // Ignore these?
{
startline = pg->ppd_line + 1;
continue;
}
- if (!strcmp(line->buffer, "*")) /* (Bad) comment line */
+ if (!strcmp(line->buffer, "*")) // (Bad) comment line
{
if (pg->ppd_conform == PPD_CONFORM_RELAXED)
{
}
}
- if (line->buffer[0] != '*') /* All lines start with an asterisk */
+ if (line->buffer[0] != '*') // All lines start with an asterisk
{
- /*
- * Allow lines consisting of just whitespace...
- */
+ //
+ // Allow lines consisting of just whitespace...
+ //
for (lineptr = line->buffer; *lineptr; lineptr ++)
if (*lineptr && !_ppd_isspace(*lineptr))
return (0);
}
- /*
- * Get a keyword...
- */
+ //
+ // Get a keyword...
+ //
keyptr = keyword;
if (_ppd_isspace(*lineptr))
{
- /*
- * Get an option name...
- */
+ //
+ // Get an option name...
+ //
while (_ppd_isspace(*lineptr))
lineptr ++;
if (*lineptr == '/')
{
- /*
- * Get human-readable text...
- */
+ //
+ // Get human-readable text...
+ //
lineptr ++;
if (*lineptr == ':')
{
- /*
- * Get string after triming leading and trailing whitespace...
- */
+ //
+ // Get string after triming leading and trailing whitespace...
+ //
lineptr ++;
while (_ppd_isspace(*lineptr))
if (*strptr == '\"')
{
- /*
- * Quoted string by itself, remove quotes...
- */
+ //
+ // Quoted string by itself, remove quotes...
+ //
*strptr = '\0';
lineptr ++;
}
-/*
- * 'ppd_update_filters()' - Update the filters array as needed.
- *
- * This function re-populates the filters array with cupsFilter2 entries that
- * have been stripped of the destination MIME media types and any maxsize hints.
- *
- * (All for backwards-compatibility)
- */
+//
+// 'ppd_update_filters()' - Update the filters array as needed.
+//
+// This function re-populates the filters array with cupsFilter2 entries that
+// have been stripped of the destination MIME media types and any maxsize hints.
+//
+// (All for backwards-compatibility)
+//
-static int /* O - 1 on success, 0 on failure */
-ppd_update_filters(ppd_file_t *ppd, /* I - PPD file */
- ppd_globals_t *pg) /* I - Global data */
+static int // O - 1 on success, 0 on failure
+ppd_update_filters(ppd_file_t *ppd, // I - PPD file
+ ppd_globals_t *pg) // I - Global data
{
- ppd_attr_t *attr; /* Current cupsFilter2 value */
- char srcsuper[16], /* Source MIME media type */
+ ppd_attr_t *attr; // Current cupsFilter2 value
+ char srcsuper[16], // Source MIME media type
srctype[256],
- dstsuper[16], /* Destination MIME media type */
+ dstsuper[16], // Destination MIME media type
dsttype[256],
- *ptr, /* Pointer into command to run */
- buffer[2048], /* Re-written cupsFilter value */
- **filter; /* Current filter */
- int cost; /* Cost of filter */
- char program[1024] = { 0 }; /* Command to run */
+ *ptr, // Pointer into command to run
+ buffer[2048], // Re-written cupsFilter value
+ **filter; // Current filter
+ int cost; // Cost of filter
+ char program[1024] = { 0 }; // Command to run
DEBUG_printf(("4ppd_update_filters(ppd=%p, cg=%p)", ppd, pg));
- /*
- * See if we have any cupsFilter2 lines...
- */
+ //
+ // See if we have any cupsFilter2 lines...
+ //
if ((attr = ppdFindAttr(ppd, "cupsFilter2", NULL)) == NULL)
{
return (1);
}
- /*
- * Yes, free the cupsFilter-defined filters and re-build...
- */
+ //
+ // Yes, free the cupsFilter-defined filters and re-build...
+ //
ppd_free_filters(ppd);
do
{
- /*
- * Parse the cupsFilter2 string:
- *
- * src/type dst/type cost program
- * src/type dst/type cost maxsize(n) program
- */
+ //
+ // Parse the cupsFilter2 string:
+ //
+ // src/type dst/type cost program
+ // src/type dst/type cost maxsize(n) program
+ //
DEBUG_printf(("5ppd_update_filters: cupsFilter2=\"%s\"", attr->value));
DEBUG_printf(("5ppd_update_filters: New program=\"%s\"", program));
}
- /*
- * Convert to cupsFilter format:
- *
- * src/type cost program
- */
+ //
+ // Convert to cupsFilter format:
+ //
+ // src/type cost program
+ //
snprintf(buffer, sizeof(buffer), "%s/%s %d %s", srcsuper, srctype, cost,
program);
DEBUG_printf(("5ppd_update_filters: Adding \"%s\".", buffer));
- /*
- * Add a cupsFilter-compatible string to the filters array.
- */
+ //
+ // Add a cupsFilter-compatible string to the filters array.
+ //
if (ppd->num_filters == 0)
filter = malloc(sizeof(char *));
-/*
- * PostScript Printer Description definitions for libppd.
- *
- * PPD FILES ARE DEPRECATED. libppd IS ONLY INTENDED FOR LEGACY IMPORT OF
- * CLASSIC CUPS DRIVERS AND POSTSCRIPT PRINTER PPD FILES.
- *
- * Copyright © 2007-2019 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
+//
+// Main PPD file handling API definitions for libppd.
+//
+// PPD FILES ARE DEPRECATED. libppd IS ONLY INTENDED FOR LEGACY IMPORT OF
+// CLASSIC CUPS DRIVERS AND POSTSCRIPT PRINTER PPD FILES.
+//
+// Copyright © 2007-2019 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
#ifndef _PPD_PPD_H_
# define _PPD_PPD_H_
-/*
- * Include necessary headers...
- */
-
-/* We do not depend on libcupsfilters here, we only share the call scheme
- for log functions, so that the same log functions can be used with all
- libraries of the cups-filters project */
-# include <cupsfilters/log.h>
+//
+// Include necessary headers...
+//
# include <stdio.h>
# include <stdbool.h>
# include <cups/raster.h>
+# include <cupsfilters/log.h>
# include <cupsfilters/driver.h>
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
+
+//
+// Constants...
+//
-/*
- * Constants...
- */
+# define PPD_CACHE_VERSION 20 // Version number in cache file
-# define PPD_CACHE_VERSION 20 /* Version number in cache file */
+//
+// PPD version...
+//
-/*
- * PPD version...
- */
+# define PPD_VERSION 4.3 // Kept in sync with Adobe version
+ // number
-# define PPD_VERSION 4.3 /* Kept in sync with Adobe version
- number */
+//
+// PPD size limits (defined in Adobe spec)
+//
-/*
- * PPD size limits (defined in Adobe spec)
- */
+# define PPD_MAX_NAME 41 // Maximum size of name + 1 for nul
+# define PPD_MAX_TEXT 81 // Maximum size of text + 1 for nul
+# define PPD_MAX_LINE 256 // Maximum size of line + 1 for nul
-# define PPD_MAX_NAME 41 /* Maximum size of name + 1 for nul */
-# define PPD_MAX_TEXT 81 /* Maximum size of text + 1 for nul */
-# define PPD_MAX_LINE 256 /* Maximum size of line + 1 for nul */
+// **** New in cups-filters 2.0.0: Ovetaken from cups-driverd ****
-/**** New in cups-filters 2.0.0: Ovetaken from cups-driverd ****/
-/*
- * PPD collection entry data
- */
+//
+// PPD collection entry data
+//
-# define PPD_SYNC 0x50504441 /* Sync word for ppds.dat (PPDA) */
-# define PPD_MAX_LANG 32 /* Maximum languages */
-# define PPD_MAX_PROD 32 /* Maximum products */
-# define PPD_MAX_VERS 32 /* Maximum versions */
+# define PPD_SYNC 0x50504441 // Sync word for ppds.dat (PPDA)
+# define PPD_MAX_LANG 32 // Maximum languages
+# define PPD_MAX_PROD 32 // Maximum products
+# define PPD_MAX_VERS 32 // Maximum versions
-# define PPD_TYPE_POSTSCRIPT 0 /* PostScript PPD */
-# define PPD_TYPE_PDF 1 /* PDF PPD */
-# define PPD_TYPE_RASTER 2 /* CUPS raster PPD */
-# define PPD_TYPE_FAX 3 /* Facsimile/MFD PPD */
-# define PPD_TYPE_UNKNOWN 4 /* Other/hybrid PPD */
-# define PPD_TYPE_DRV 5 /* Driver info file */
-# define PPD_TYPE_ARCHIVE 6 /* Archive file */
+# define PPD_TYPE_POSTSCRIPT 0 // PostScript PPD
+# define PPD_TYPE_PDF 1 // PDF PPD
+# define PPD_TYPE_RASTER 2 // CUPS raster PPD
+# define PPD_TYPE_FAX 3 // Facsimile/MFD PPD
+# define PPD_TYPE_UNKNOWN 4 // Other/hybrid PPD
+# define PPD_TYPE_DRV 5 // Driver info file
+# define PPD_TYPE_ARCHIVE 6 // Archive file
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
typedef int (*cups_interpret_cb_t)(cups_page_header2_t *header, int preferred_bits);
- /**** cupsRasterInterpretPPD callback
- function
- *
- * This function is called by
- * @link cupsRasterInterpretPPD@ to
- * validate (and update, as needed)
- * the page header attributes. The
- * "preferred_bits" argument provides
- * the value of the
- * @code cupsPreferredBitsPerColor@
- * key from the PostScript page device
- * dictionary and is 0 if undefined.
- ****/
-
-typedef enum ppd_ui_e /**** UI Types ****/
-{
- PPD_UI_BOOLEAN, /* True or False option */
- PPD_UI_PICKONE, /* Pick one from a list */
- PPD_UI_PICKMANY /* Pick zero or more from a list */
+ // **** cupsRasterInterpretPPD callback
+ // function ****
+ //
+ // This function is called by
+ // @link cupsRasterInterpretPPD@ to
+ // validate (and update, as needed)
+ // the page header attributes. The
+ // "preferred_bits" argument provides
+ // the value of the
+ // @code cupsPreferredBitsPerColor@
+ // key from the PostScript page device
+ // dictionary and is 0 if undefined.
+ //
+
+typedef enum ppd_ui_e // **** UI Types ****
+{
+ PPD_UI_BOOLEAN, // True or False option
+ PPD_UI_PICKONE, // Pick one from a list
+ PPD_UI_PICKMANY // Pick zero or more from a list
} ppd_ui_t;
-typedef enum ppd_section_e /**** Order dependency sections ****/
-{
- PPD_ORDER_ANY, /* Option code can be anywhere in the
- file */
- PPD_ORDER_DOCUMENT, /* ... must be in the DocumentSetup
- section */
- PPD_ORDER_EXIT, /* ... must be sent prior to the
- document */
- PPD_ORDER_JCL, /* ... must be sent as a JCL command */
- PPD_ORDER_PAGE, /* ... must be in the PageSetup
- section */
- PPD_ORDER_PROLOG /* ... must be in the Prolog section */
+typedef enum ppd_section_e // *** Order dependency sections ****
+{
+ PPD_ORDER_ANY, // Option code can be anywhere in the
+ // file
+ PPD_ORDER_DOCUMENT, // ... must be in the DocumentSetup
+ // section
+ PPD_ORDER_EXIT, // ... must be sent prior to the
+ // document
+ PPD_ORDER_JCL, // ... must be sent as a JCL command
+ PPD_ORDER_PAGE, // ... must be in the PageSetup
+ // section
+ PPD_ORDER_PROLOG // ... must be in the Prolog section
} ppd_section_t;
-typedef enum ppd_cs_e /**** Colorspaces ****/
+typedef enum ppd_cs_e // **** Colorspaces ****
{
- PPD_CS_CMYK = -4, /* CMYK colorspace */
- PPD_CS_CMY, /* CMY colorspace */
- PPD_CS_GRAY = 1, /* Grayscale colorspace */
- PPD_CS_RGB = 3, /* RGB colorspace */
- PPD_CS_RGBK, /* RGBK (K = gray) colorspace */
- PPD_CS_N /* DeviceN colorspace */
+ PPD_CS_CMYK = -4, // CMYK colorspace
+ PPD_CS_CMY, // CMY colorspace
+ PPD_CS_GRAY = 1, // Grayscale colorspace
+ PPD_CS_RGB = 3, // RGB colorspace
+ PPD_CS_RGBK, // RGBK (K = gray) colorspace
+ PPD_CS_N // DeviceN colorspace
} ppd_cs_t;
-typedef enum ppd_status_e /**** Status Codes ****/
-{
- PPD_OK = 0, /* OK */
- PPD_FILE_OPEN_ERROR, /* Unable to open PPD file */
- PPD_NULL_FILE, /* NULL PPD file pointer */
- PPD_ALLOC_ERROR, /* Memory allocation error */
- PPD_MISSING_PPDADOBE4, /* Missing PPD-Adobe-4.x header */
- PPD_MISSING_VALUE, /* Missing value string */
- PPD_INTERNAL_ERROR, /* Internal error */
- PPD_BAD_OPEN_GROUP, /* Bad OpenGroup */
- PPD_NESTED_OPEN_GROUP, /* OpenGroup without a CloseGroup
- first */
- PPD_BAD_OPEN_UI, /* Bad OpenUI/JCLOpenUI */
- PPD_NESTED_OPEN_UI, /* OpenUI/JCLOpenUI without a
- CloseUI/JCLCloseUI first */
- PPD_BAD_ORDER_DEPENDENCY, /* Bad OrderDependency */
- PPD_BAD_UI_CONSTRAINTS, /* Bad UIConstraints */
- PPD_MISSING_ASTERISK, /* Missing asterisk in column 0 */
- PPD_LINE_TOO_LONG, /* Line longer than 255 chars */
- PPD_ILLEGAL_CHARACTER, /* Illegal control character */
- PPD_ILLEGAL_MAIN_KEYWORD, /* Illegal main keyword string */
- PPD_ILLEGAL_OPTION_KEYWORD, /* Illegal option keyword string */
- PPD_ILLEGAL_TRANSLATION, /* Illegal translation string */
- PPD_ILLEGAL_WHITESPACE, /* Illegal whitespace character */
- PPD_BAD_CUSTOM_PARAM, /* Bad custom parameter */
- PPD_MISSING_OPTION_KEYWORD, /* Missing option keyword */
- PPD_BAD_VALUE, /* Bad value string */
- PPD_MISSING_CLOSE_GROUP, /* Missing CloseGroup */
- PPD_BAD_CLOSE_UI, /* Bad CloseUI/JCLCloseUI */
- PPD_MISSING_CLOSE_UI, /* Missing CloseUI/JCLCloseUI */
- PPD_MAX_STATUS /* @private@ */
+typedef enum ppd_status_e // **** Status Codes ****
+{
+ PPD_OK = 0, // OK
+ PPD_FILE_OPEN_ERROR, // Unable to open PPD file
+ PPD_NULL_FILE, // NULL PPD file pointer
+ PPD_ALLOC_ERROR, // Memory allocation error
+ PPD_MISSING_PPDADOBE4, // Missing PPD-Adobe-4.x header
+ PPD_MISSING_VALUE, // Missing value string
+ PPD_INTERNAL_ERROR, // Internal error
+ PPD_BAD_OPEN_GROUP, // Bad OpenGroup
+ PPD_NESTED_OPEN_GROUP, // OpenGroup without a CloseGroup
+ // first
+ PPD_BAD_OPEN_UI, // Bad OpenUI/JCLOpenUI
+ PPD_NESTED_OPEN_UI, // OpenUI/JCLOpenUI without a
+ // CloseUI/JCLCloseUI first
+ PPD_BAD_ORDER_DEPENDENCY, // Bad OrderDependency
+ PPD_BAD_UI_CONSTRAINTS, // Bad UIConstraints
+ PPD_MISSING_ASTERISK, // Missing asterisk in column 0
+ PPD_LINE_TOO_LONG, // Line longer than 255 chars
+ PPD_ILLEGAL_CHARACTER, // Illegal control character
+ PPD_ILLEGAL_MAIN_KEYWORD, // Illegal main keyword string
+ PPD_ILLEGAL_OPTION_KEYWORD, // Illegal option keyword string
+ PPD_ILLEGAL_TRANSLATION, // Illegal translation string
+ PPD_ILLEGAL_WHITESPACE, // Illegal whitespace character
+ PPD_BAD_CUSTOM_PARAM, // Bad custom parameter
+ PPD_MISSING_OPTION_KEYWORD, // Missing option keyword
+ PPD_BAD_VALUE, // Bad value string
+ PPD_MISSING_CLOSE_GROUP, // Missing CloseGroup
+ PPD_BAD_CLOSE_UI, // Bad CloseUI/JCLCloseUI
+ PPD_MISSING_CLOSE_UI, // Missing CloseUI/JCLCloseUI
+ PPD_MAX_STATUS // @private@
} ppd_status_t;
-enum ppd_conform_e /**** Conformance Levels ****/
+enum ppd_conform_e // **** Conformance Levels ****
{
- PPD_CONFORM_RELAXED, /* Relax whitespace and control char */
- PPD_CONFORM_STRICT /* Require strict conformance */
+ PPD_CONFORM_RELAXED, // Relax whitespace and control char
+ PPD_CONFORM_STRICT // Require strict conformance
};
typedef enum ppd_conform_e ppd_conform_t;
- /**** Conformance Levels ****/
+ // **** Conformance Levels ****
-typedef struct ppd_attr_s /**** PPD Attribute Structure ****/
+typedef struct ppd_attr_s // **** PPD Attribute Structure ****
{
- char name[PPD_MAX_NAME]; /* Name of attribute (cupsXYZ) */
- char spec[PPD_MAX_NAME]; /* Specifier string, if any */
- char text[PPD_MAX_TEXT]; /* Human-readable text, if any */
- char *value; /* Value string */
+ char name[PPD_MAX_NAME]; // Name of attribute (cupsXYZ)
+ char spec[PPD_MAX_NAME]; // Specifier string, if any
+ char text[PPD_MAX_TEXT]; // Human-readable text, if any
+ char *value; // Value string
} ppd_attr_t;
typedef struct ppd_option_s ppd_option_t;
- /**** Options ****/
+ // **** Options ****
-typedef struct ppd_choice_s /**** Option choices ****/
+typedef struct ppd_choice_s // **** Option choices ****
{
- char marked; /* 0 if not selected, 1 otherwise */
- char choice[PPD_MAX_NAME]; /* Computer-readable option name */
- char text[PPD_MAX_TEXT]; /* Human-readable option name */
- char *code; /* Code to send for this option */
- ppd_option_t *option; /* Pointer to parent option structure */
+ char marked; // 0 if not selected, 1 otherwise
+ char choice[PPD_MAX_NAME]; // Computer-readable option name
+ char text[PPD_MAX_TEXT]; // Human-readable option name
+ char *code; // Code to send for this option
+ ppd_option_t *option; // Pointer to parent option structure
} ppd_choice_t;
-struct ppd_option_s /**** Options ****/
-{
- char conflicted; /* 0 if no conflicts exist, 1
- otherwise */
- char keyword[PPD_MAX_NAME]; /* Option keyword name ("PageSize",
- etc.) */
- char defchoice[PPD_MAX_NAME];/* Default option choice */
- char text[PPD_MAX_TEXT]; /* Human-readable text */
- ppd_ui_t ui; /* Type of UI option */
- ppd_section_t section; /* Section for command */
- float order; /* Order number */
- int num_choices; /* Number of option choices */
- ppd_choice_t *choices; /* Option choices */
+struct ppd_option_s // **** Options ****
+{
+ char conflicted; // 0 if no conflicts exist, 1
+ // otherwise
+ char keyword[PPD_MAX_NAME]; // Option keyword name ("PageSize",
+ // etc.)
+ char defchoice[PPD_MAX_NAME];// Default option choice
+ char text[PPD_MAX_TEXT]; // Human-readable text
+ ppd_ui_t ui; // Type of UI option
+ ppd_section_t section; // Section for command
+ float order; // Order number
+ int num_choices; // Number of option choices
+ ppd_choice_t *choices; // Option choices
};
-typedef struct ppd_group_s /**** Groups ****/
+typedef struct ppd_group_s // **** Groups ****
{
- /**** Group text strings are limited to 39 chars + nul in order to
- **** preserve binary compatibility and allow applications to get
- **** the group's keyword name.
- ****/
+ // **** Group text strings are limited to 39 chars + nul in order to
+ // **** preserve binary compatibility and allow applications to get
+ // **** the group's keyword name.
+
char text[PPD_MAX_TEXT - PPD_MAX_NAME];
- /* Human-readable group name */
- char name[PPD_MAX_NAME]; /* Group name @since CUPS 1.1.18/macOS
- 10.3@ */
- int num_options; /* Number of options */
- ppd_option_t *options; /* Options */
- int num_subgroups; /* Number of sub-groups */
- struct ppd_group_s *subgroups; /* Sub-groups (max depth = 1) */
+ // Human-readable group name
+ char name[PPD_MAX_NAME]; // Group name @since CUPS 1.1.18/macOS
+ // 10.3@
+ int num_options; // Number of options
+ ppd_option_t *options; // Options
+ int num_subgroups; // Number of sub-groups
+ struct ppd_group_s *subgroups; // Sub-groups (max depth = 1)
} ppd_group_t;
-typedef struct ppd_const_s /**** Constraints ****/
+typedef struct ppd_const_s // **** Constraints ****
{
- char option1[PPD_MAX_NAME]; /* First keyword */
- char choice1[PPD_MAX_NAME]; /* First option/choice (blank for all) */
- char option2[PPD_MAX_NAME]; /* Second keyword */
- char choice2[PPD_MAX_NAME]; /* Second option/choice (blank for all) */
+ char option1[PPD_MAX_NAME]; // First keyword
+ char choice1[PPD_MAX_NAME]; // First option/choice (blank for all)
+ char option2[PPD_MAX_NAME]; // Second keyword
+ char choice2[PPD_MAX_NAME]; // Second option/choice (blank for all)
} ppd_const_t;
-typedef struct ppd_size_s /**** Page Sizes ****/
+typedef struct ppd_size_s // **** Page Sizes ****
{
- int marked; /* Page size selected? */
- char name[PPD_MAX_NAME]; /* Media size option */
- float width; /* Width of media in points */
- float length; /* Length of media in points */
- float left; /* Left printable margin in points */
- float bottom; /* Bottom printable margin in points */
- float right; /* Right printable margin in points */
- float top; /* Top printable margin in points */
+ int marked; // Page size selected?
+ char name[PPD_MAX_NAME]; // Media size option
+ float width; // Width of media in points
+ float length; // Length of media in points
+ float left; // Left printable margin in points
+ float bottom; // Bottom printable margin in points
+ float right; // Right printable margin in points
+ float top; // Top printable margin in points
} ppd_size_t;
-typedef struct ppd_emul_s /**** Emulators ****/
+typedef struct ppd_emul_s // **** Emulators ****
{
- char name[PPD_MAX_NAME]; /* Emulator name */
- char *start; /* Code to switch to this emulation */
- char *stop; /* Code to stop this emulation */
+ char name[PPD_MAX_NAME]; // Emulator name
+ char *start; // Code to switch to this emulation
+ char *stop; // Code to stop this emulation
} ppd_emul_t;
-typedef struct ppd_profile_s /**** sRGB Color Profiles ****/
+typedef struct ppd_profile_s // **** sRGB Color Profiles ****
{
char resolution[PPD_MAX_NAME];
- /* Resolution or "-" */
+ // Resolution or "-"
char media_type[PPD_MAX_NAME];
- /* Media type or "-" */
- float density; /* Ink density to use */
- float gamma; /* Gamma correction to use */
- float matrix[3][3]; /* Transform matrix */
+ // Media type or "-"
+ float density; // Ink density to use
+ float gamma; // Gamma correction to use
+ float matrix[3][3]; // Transform matrix
} ppd_profile_t;
-/**** New in CUPS 1.2/macOS 10.5 ****/
-typedef enum ppd_cptype_e /**** Custom Parameter Type ****/
-{
- PPD_CUSTOM_UNKNOWN = -1, /* Unknown type (error) */
- PPD_CUSTOM_CURVE, /* Curve value for f(x) = x^value */
- PPD_CUSTOM_INT, /* Integer number value */
- PPD_CUSTOM_INVCURVE, /* Curve value for f(x) = x^(1/value) */
- PPD_CUSTOM_PASSCODE, /* String of (hidden) numbers */
- PPD_CUSTOM_PASSWORD, /* String of (hidden) characters */
- PPD_CUSTOM_POINTS, /* Measurement value in points */
- PPD_CUSTOM_REAL, /* Real number value */
- PPD_CUSTOM_STRING /* String of characters */
+// **** New in CUPS 1.2/macOS 10.5 ****
+typedef enum ppd_cptype_e // **** Custom Parameter Type ****
+{
+ PPD_CUSTOM_UNKNOWN = -1, // Unknown type (error)
+ PPD_CUSTOM_CURVE, // Curve value for f(x) = x^value
+ PPD_CUSTOM_INT, // Integer number value
+ PPD_CUSTOM_INVCURVE, // Curve value for f(x) = x^(1/value)
+ PPD_CUSTOM_PASSCODE, // String of (hidden) numbers
+ PPD_CUSTOM_PASSWORD, // String of (hidden) characters
+ PPD_CUSTOM_POINTS, // Measurement value in points
+ PPD_CUSTOM_REAL, // Real number value
+ PPD_CUSTOM_STRING // String of characters
} ppd_cptype_t;
-typedef union ppd_cplimit_u /**** Custom Parameter Limit ****/
+typedef union ppd_cplimit_u // **** Custom Parameter Limit ****
{
- float custom_curve; /* Gamma value */
- int custom_int; /* Integer value */
- float custom_invcurve; /* Gamma value */
- int custom_passcode; /* Passcode length */
- int custom_password; /* Password length */
- float custom_points; /* Measurement value */
- float custom_real; /* Real value */
- int custom_string; /* String length */
+ float custom_curve; // Gamma value
+ int custom_int; // Integer value
+ float custom_invcurve; // Gamma value
+ int custom_passcode; // Passcode length
+ int custom_password; // Password length
+ float custom_points; // Measurement value
+ float custom_real; // Real value
+ int custom_string; // String length
} ppd_cplimit_t;
-typedef union ppd_cpvalue_u /**** Custom Parameter Value ****/
+typedef union ppd_cpvalue_u // **** Custom Parameter Value ****
{
- float custom_curve; /* Gamma value */
- int custom_int; /* Integer value */
- float custom_invcurve; /* Gamma value */
- char *custom_passcode; /* Passcode value */
- char *custom_password; /* Password value */
- float custom_points; /* Measurement value */
- float custom_real; /* Real value */
- char *custom_string; /* String value */
+ float custom_curve; // Gamma value
+ int custom_int; // Integer value
+ float custom_invcurve; // Gamma value
+ char *custom_passcode; // Passcode value
+ char *custom_password; // Password value
+ float custom_points; // Measurement value
+ float custom_real; // Real value
+ char *custom_string; // String value
} ppd_cpvalue_t;
-typedef struct ppd_cparam_s /**** Custom Parameter ****/
+typedef struct ppd_cparam_s // **** Custom Parameter ****
{
- char name[PPD_MAX_NAME]; /* Parameter name */
- char text[PPD_MAX_TEXT]; /* Human-readable text */
- int order; /* Order (0 to N) */
- ppd_cptype_t type; /* Parameter type */
- ppd_cplimit_t minimum, /* Minimum value */
- maximum; /* Maximum value */
- ppd_cpvalue_t current; /* Current value */
+ char name[PPD_MAX_NAME]; // Parameter name
+ char text[PPD_MAX_TEXT]; // Human-readable text
+ int order; // Order (0 to N)
+ ppd_cptype_t type; // Parameter type
+ ppd_cplimit_t minimum, // Minimum value
+ maximum; // Maximum value
+ ppd_cpvalue_t current; // Current value
} ppd_cparam_t;
-typedef struct ppd_coption_s /**** Custom Option ****/
+typedef struct ppd_coption_s // **** Custom Option ****
{
- char keyword[PPD_MAX_NAME]; /* Name of option that is being
- extended... */
- ppd_option_t *option; /* Option that is being extended... */
- int marked; /* Extended option is marked */
- cups_array_t *params; /* Parameters */
+ char keyword[PPD_MAX_NAME]; // Name of option that is being
+ // extended...
+ ppd_option_t *option; // Option that is being extended...
+ int marked; // Extended option is marked
+ cups_array_t *params; // Parameters
} ppd_coption_t;
-typedef struct ppd_globals_s /**** CUPS PPD global state data ****/
+typedef struct ppd_globals_s // **** CUPS PPD global state data ****
{
- /* ppd.c */
- ppd_status_t ppd_status; /* Status of last ppdOpen*() */
- int ppd_line; /* Current line number */
- ppd_conform_t ppd_conform; /* Level of conformance required */
+ // ppd.c
+ ppd_status_t ppd_status; // Status of last ppdOpen*()
+ int ppd_line; // Current line number
+ ppd_conform_t ppd_conform; // Level of conformance required
- /* ppd-util.c */
+ // ppd-util.c
char ppd_filename[HTTP_MAX_URI];
- /* PPD filename */
+ // PPD filename
} ppd_globals_t;
-typedef enum ppd_localization_e /**** Selector for ppdOpenWithLocalization ****/
+typedef enum ppd_localization_e// **** Selector for ppdOpenWithLocalization ****
{
- PPD_LOCALIZATION_DEFAULT, /* Load only the default localization */
- PPD_LOCALIZATION_ICC_PROFILES, /* Load only the color profile
- localization */
- PPD_LOCALIZATION_NONE, /* Load no localizations */
- PPD_LOCALIZATION_ALL /* Load all localizations */
+ PPD_LOCALIZATION_DEFAULT, // Load only the default localization
+ PPD_LOCALIZATION_ICC_PROFILES, // Load only the color profile
+ // localization
+ PPD_LOCALIZATION_NONE, // Load no localizations
+ PPD_LOCALIZATION_ALL // Load all localizations
} ppd_localization_t;
-typedef enum ppd_parse_e /**** Selector for ppdParseOptions ****/
+typedef enum ppd_parse_e // **** Selector for ppdParseOptions ****
{
- PPD_PARSE_OPTIONS, /* Parse only the options */
- PPD_PARSE_PROPERTIES, /* Parse only the properties */
- PPD_PARSE_ALL /* Parse everything */
+ PPD_PARSE_OPTIONS, // Parse only the options
+ PPD_PARSE_PROPERTIES, // Parse only the properties
+ PPD_PARSE_ALL // Parse everything
} ppd_parse_t;
-typedef struct ppd_cups_uiconst_s /**** Constraint from cupsUIConstraints ****/
+typedef struct ppd_cups_uiconst_s // **** Constraint from
+ // cupsUIConstraints ****
{
- ppd_option_t *option; /* Constrained option */
- ppd_choice_t *choice; /* Constrained choice or @code NULL@ */
- int installable; /* Installable option? */
+ ppd_option_t *option; // Constrained option
+ ppd_choice_t *choice; // Constrained choice or @code NULL@
+ int installable; // Installable option?
} ppd_cups_uiconst_t;
-typedef struct ppd_cups_uiconsts_s /**** cupsUIConstraints ****/
+typedef struct ppd_cups_uiconsts_s // **** cupsUIConstraints ****
{
- char resolver[PPD_MAX_NAME]; /* Resolver name */
- int installable, /* Constrained against any installable
- options? */
- num_constraints; /* Number of constraints */
- ppd_cups_uiconst_t *constraints; /* Constraints */
+ char resolver[PPD_MAX_NAME]; // Resolver name
+ int installable, // Constrained against any installable
+ // options?
+ num_constraints; // Number of constraints
+ ppd_cups_uiconst_t *constraints; // Constraints
} ppd_cups_uiconsts_t;
-typedef enum ppd_pwg_print_color_mode_e /**** PWG print-color-mode indices ****/
+typedef enum ppd_pwg_print_color_mode_e// **** PWG print-color-mode indices ****
{
- PPD_PWG_PRINT_COLOR_MODE_MONOCHROME = 0, /* print-color-mode=monochrome*/
- PPD_PWG_PRINT_COLOR_MODE_COLOR, /* print-color-mode=color */
- /* Other values are not supported by CUPS yet. */
+ PPD_PWG_PRINT_COLOR_MODE_MONOCHROME = 0, // print-color-mode=monochrome
+ PPD_PWG_PRINT_COLOR_MODE_COLOR, // print-color-mode=color
+ // Other values are not supported by CUPS yet.
PPD_PWG_PRINT_COLOR_MODE_MAX
} ppd_pwg_print_color_mode_t;
-typedef enum ppd_pwg_print_quality_e /**** PWG print-quality values ****/
+typedef enum ppd_pwg_print_quality_e // **** PWG print-quality values ****
{
- PPD_PWG_PRINT_QUALITY_DRAFT = 0, /* print-quality=3 */
- PPD_PWG_PRINT_QUALITY_NORMAL, /* print-quality=4 */
- PPD_PWG_PRINT_QUALITY_HIGH, /* print-quality=5 */
+ PPD_PWG_PRINT_QUALITY_DRAFT = 0, // print-quality=3
+ PPD_PWG_PRINT_QUALITY_NORMAL, // print-quality=4
+ PPD_PWG_PRINT_QUALITY_HIGH, // print-quality=5
PPD_PWG_PRINT_QUALITY_MAX
} ppd_pwg_print_quality_t;
-typedef enum ppd_pwg_print_content_optimize_e /** PWG print-content-optimize **/
+typedef enum ppd_pwg_print_content_optimize_e // * PWG print-content-optimize *
{
- PPD_PWG_PRINT_CONTENT_OPTIMIZE_AUTO = 0, /* print-content-optimize=auto */
- PPD_PWG_PRINT_CONTENT_OPTIMIZE_PHOTO, /* print-content-optimize=photo */
- PPD_PWG_PRINT_CONTENT_OPTIMIZE_GRAPHICS,/* print-content-optimize=graphics */
- PPD_PWG_PRINT_CONTENT_OPTIMIZE_TEXT, /* print-content-optimize=text */
- PPD_PWG_PRINT_CONTENT_OPTIMIZE_TEXT_AND_GRAPHICS, /* ...=text-and-graphics */
+ PPD_PWG_PRINT_CONTENT_OPTIMIZE_AUTO = 0, // print-content-optimize=auto
+ PPD_PWG_PRINT_CONTENT_OPTIMIZE_PHOTO, // print-content-optimize=photo
+ PPD_PWG_PRINT_CONTENT_OPTIMIZE_GRAPHICS,// print-content-optimize=graphics
+ PPD_PWG_PRINT_CONTENT_OPTIMIZE_TEXT, // print-content-optimize=text
+ PPD_PWG_PRINT_CONTENT_OPTIMIZE_TEXT_AND_GRAPHICS, // ...=text-and-graphics
PPD_PWG_PRINT_CONTENT_OPTIMIZE_MAX
} ppd_pwg_print_content_optimize_t;
-typedef struct ppd_pwg_finishings_s /**** PWG finishings mapping data ****/
+typedef struct ppd_pwg_finishings_s // **** PWG finishings mapping data ****
{
- ipp_finishings_t value; /* finishings value */
- int num_options; /* Number of options to apply */
- cups_option_t *options; /* Options to apply */
+ ipp_finishings_t value; // finishings value
+ int num_options; // Number of options to apply
+ cups_option_t *options; // Options to apply
} ppd_pwg_finishings_t;
-struct ppd_cache_s /**** PPD cache and PWG conversion data ****/
-{
- int num_bins; /* Number of output bins */
- pwg_map_t *bins; /* Output bins */
- int num_sizes; /* Number of media sizes */
- pwg_size_t *sizes; /* Media sizes */
- int custom_max_width, /* Maximum custom width in 2540ths */
- custom_max_length, /* Maximum custom length in 2540ths */
- custom_min_width, /* Minimum custom width in 2540ths */
- custom_min_length; /* Minimum custom length in 2540ths */
- char *custom_max_keyword, /* Maximum custom size PWG keyword */
- *custom_min_keyword, /* Minimum custom size PWG keyword */
- custom_ppd_size[41]; /* Custom PPD size name */
- pwg_size_t custom_size; /* Custom size record */
- char *source_option; /* PPD option for media source */
- int num_sources; /* Number of media sources */
- pwg_map_t *sources; /* Media sources */
- int num_types; /* Number of media types */
- pwg_map_t *types; /* Media types */
+struct ppd_cache_s // **** PPD cache and PWG conversion data ****
+{
+ int num_bins; // Number of output bins
+ pwg_map_t *bins; // Output bins
+ int num_sizes; // Number of media sizes
+ pwg_size_t *sizes; // Media sizes
+ int custom_max_width, // Maximum custom width in 2540ths
+ custom_max_length, // Maximum custom length in 2540ths
+ custom_min_width, // Minimum custom width in 2540ths
+ custom_min_length; // Minimum custom length in 2540ths
+ char *custom_max_keyword, // Maximum custom size PWG keyword
+ *custom_min_keyword, // Minimum custom size PWG keyword
+ custom_ppd_size[41]; // Custom PPD size name
+ pwg_size_t custom_size; // Custom size record
+ char *source_option; // PPD option for media source
+ int num_sources; // Number of media sources
+ pwg_map_t *sources; // Media sources
+ int num_types; // Number of media types
+ pwg_map_t *types; // Media types
int num_presets[PPD_PWG_PRINT_COLOR_MODE_MAX][PPD_PWG_PRINT_QUALITY_MAX];
- /* Number of print-color-mode/
- print-quality options */
+ // Number of print-color-mode/
+ // print-quality options
cups_option_t *presets[PPD_PWG_PRINT_COLOR_MODE_MAX][PPD_PWG_PRINT_QUALITY_MAX];
- /* print-color-mode/
- print-quality options */
+ // print-color-mode/
+ // print-quality options
int num_optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_MAX];
- /* Number of print-content-optimize
- options */
+ // Number of print-content-optimize
+ // options
cups_option_t *optimize_presets[PPD_PWG_PRINT_CONTENT_OPTIMIZE_MAX];
- /* print-content-optimize options */
- char *sides_option, /* PPD option for sides */
- *sides_1sided, /* Choice for one-sided */
- *sides_2sided_long, /* Choice for two-sided-long-edge */
- *sides_2sided_short; /* Choice for two-sided-short-edge */
- char *product; /* Product value */
- cups_array_t *filters, /* cupsFilter/cupsFilter2 values */
- *prefilters; /* cupsPreFilter values */
- int single_file; /* cupsSingleFile value */
- cups_array_t *finishings; /* cupsIPPFinishings values */
- cups_array_t *templates; /* cupsFinishingTemplate values */
- int max_copies, /* cupsMaxCopies value */
- account_id, /* cupsJobAccountId value */
- accounting_user_id; /* cupsJobAccountingUserId value */
- char *password; /* cupsJobPassword value */
- cups_array_t *mandatory; /* cupsMandatory value */
- char *charge_info_uri; /* cupsChargeInfoURI value */
- cups_array_t *strings; /* Localization strings */
- cups_array_t *support_files; /* Support files - ICC profiles, etc. */
+ // print-content-optimize options
+ char *sides_option, // PPD option for sides
+ *sides_1sided, // Choice for one-sided
+ *sides_2sided_long, // Choice for two-sided-long-edge
+ *sides_2sided_short; // Choice for two-sided-short-edge
+ char *product; // Product value
+ cups_array_t *filters, // cupsFilter/cupsFilter2 values
+ *prefilters; // cupsPreFilter values
+ int single_file; // cupsSingleFile value
+ cups_array_t *finishings; // cupsIPPFinishings values
+ cups_array_t *templates; // cupsFinishingTemplate values
+ int max_copies, // cupsMaxCopies value
+ account_id, // cupsJobAccountId value
+ accounting_user_id; // cupsJobAccountingUserId value
+ char *password; // cupsJobPassword value
+ cups_array_t *mandatory; // cupsMandatory value
+ char *charge_info_uri; // cupsChargeInfoURI value
+ cups_array_t *strings; // Localization strings
+ cups_array_t *support_files; // Support files - ICC profiles, etc.
};
typedef struct ppd_cache_s ppd_cache_t;
- /**** PPD cache and mapping data ****/
-
-typedef struct ppd_file_s /**** PPD File ****/
-{
- int language_level; /* Language level of device */
- int color_device; /* 1 = color device, 0 = grayscale */
- int variable_sizes; /* 1 = supports variable sizes,
- 0 = doesn't */
- int accurate_screens; /* 1 = supports accurate screens,
- 0 = not */
- int contone_only; /* 1 = continuous tone only, 0 = not */
- int landscape; /* -90 or 90 */
- int model_number; /* Device-specific model number */
- int manual_copies; /* 1 = Copies done manually,
- 0 = hardware */
- int throughput; /* Pages per minute */
- ppd_cs_t colorspace; /* Default colorspace */
- char *patches; /* Patch commands to be sent to
- printer */
- int num_emulations; /* Number of emulations supported
- (no longer supported) @private@ */
- ppd_emul_t *emulations; /* Emulations and the code to invoke
- them (no longer supported)
- @private@ */
- char *jcl_begin; /* Start JCL commands */
- char *jcl_ps; /* Enter PostScript interpreter */
+ // **** PPD cache and mapping data ****
+
+typedef struct ppd_file_s // **** PPD File ****
+{
+ int language_level; // Language level of device
+ int color_device; // 1 = color device, 0 = grayscale
+ int variable_sizes; // 1 = supports variable sizes,
+ // 0 = doesn't
+ int accurate_screens; // 1 = supports accurate screens,
+ // 0 = not
+ int contone_only; // 1 = continuous tone only, 0 = not
+ int landscape; // -90 or 90
+ int model_number; // Device-specific model number
+ int manual_copies; // 1 = Copies done manually,
+ // 0 = hardware
+ int throughput; // Pages per minute
+ ppd_cs_t colorspace; // Default colorspace
+ char *patches; // Patch commands to be sent to
+ // printer
+ int num_emulations; // Number of emulations supported
+ // (no longer supported) @private@
+ ppd_emul_t *emulations; // Emulations and the code to invoke
+ // them (no longer supported)
+ // @private@
+ char *jcl_begin; // Start JCL commands
+ char *jcl_ps; // Enter PostScript interpreter
#if HAVE_CUPS_3_X
- char *jcl_pdf; /* Enter PDF interpreter */
+ char *jcl_pdf; // Enter PDF interpreter
#endif
- char *jcl_end; /* End JCL commands */
- char *lang_encoding; /* Language encoding */
- char *lang_version; /* Language version (English, Spanish,
- etc.) */
- char *modelname; /* Model name (general) */
- char *ttrasterizer; /* Truetype rasterizer */
- char *manufacturer; /* Manufacturer name */
- char *product; /* Product name (from PS
- RIP/interpreter) */
- char *nickname; /* Nickname (specific) */
- char *shortnickname; /* Short version of nickname */
- int num_groups; /* Number of UI groups */
- ppd_group_t *groups; /* UI groups */
- int num_sizes; /* Number of page sizes */
- ppd_size_t *sizes; /* Page sizes */
- float custom_min[2]; /* Minimum variable page size */
- float custom_max[2]; /* Maximum variable page size */
- float custom_margins[4]; /* Margins around page */
- int num_consts; /* Number of UI/Non-UI constraints */
- ppd_const_t *consts; /* UI/Non-UI constraints */
- int num_fonts; /* Number of pre-loaded fonts */
- char **fonts; /* Pre-loaded fonts */
- int num_profiles; /* Number of sRGB color profiles */
- ppd_profile_t *profiles; /* sRGB color profiles */
- int num_filters; /* Number of filters */
- char **filters; /* Filter strings... */
-
- /**** New in CUPS 1.1 ****/
- int flip_duplex; /* 1 = Flip page for back sides */
-
- /**** New in CUPS 1.1.19 ****/
- char *protocols; /* Protocols (BCP, TBCP) string
- @since CUPS 1.1.19/macOS 10.3@ */
- char *pcfilename; /* PCFileName string @since
- CUPS 1.1.19/macOS 10.3@ */
- int num_attrs; /* Number of attributes @since
- CUPS 1.1.19/macOS 10.3@ @private@ */
- int cur_attr; /* Current attribute @since
- CUPS 1.1.19/macOS 10.3@ @private@ */
- ppd_attr_t **attrs; /* Attributes @since CUPS 1.1.19/macOS
- 10.3@ @private@ */
-
- /**** New in CUPS 1.2/macOS 10.5 ****/
- cups_array_t *sorted_attrs; /* Attribute lookup array @since
- CUPS 1.2/macOS 10.5@ @private@ */
- cups_array_t *options; /* Option lookup array @since
- CUPS 1.2/macOS 10.5@ @private@ */
- cups_array_t *coptions; /* Custom options array @since
- CUPS 1.2/macOS 10.5@ @private@ */
-
- /**** New in CUPS 1.3/macOS 10.5 ****/
- cups_array_t *marked; /* Marked choices
- @since CUPS 1.3/macOS 10.5@
- @private@ */
-
- /**** New in CUPS 1.4/macOS 10.6 ****/
- cups_array_t *cups_uiconstraints; /* cupsUIConstraints @since
- CUPS 1.4/macOS 10.6@ @private@ */
-
- /**** New in CUPS 1.5 ****/
- ppd_cache_t *cache; /* PPD cache and mapping data @since
- CUPS 1.5/macOS 10.7@ @private@ */
+ char *jcl_end; // End JCL commands
+ char *lang_encoding; // Language encoding
+ char *lang_version; // Language version (English, Spanish,
+ // etc.)
+ char *modelname; // Model name (general)
+ char *ttrasterizer; // Truetype rasterizer
+ char *manufacturer; // Manufacturer name
+ char *product; // Product name (from PS
+ // RIP/interpreter)
+ char *nickname; // Nickname (specific)
+ char *shortnickname; // Short version of nickname
+ int num_groups; // Number of UI groups
+ ppd_group_t *groups; // UI groups
+ int num_sizes; // Number of page sizes
+ ppd_size_t *sizes; // Page sizes
+ float custom_min[2]; // Minimum variable page size
+ float custom_max[2]; // Maximum variable page size
+ float custom_margins[4]; // Margins around page
+ int num_consts; // Number of UI/Non-UI constraints
+ ppd_const_t *consts; // UI/Non-UI constraints
+ int num_fonts; // Number of pre-loaded fonts
+ char **fonts; // Pre-loaded fonts
+ int num_profiles; // Number of sRGB color profiles
+ ppd_profile_t *profiles; // sRGB color profiles
+ int num_filters; // Number of filters
+ char **filters; // Filter strings...
+
+ // *** New in CUPS 1.1 ****
+ int flip_duplex; // 1 = Flip page for back sides
+
+ // **** New in CUPS 1.1.19 ****
+ char *protocols; // Protocols (BCP, TBCP) string
+ // @since CUPS 1.1.19/macOS 10.3@
+ char *pcfilename; // PCFileName string @since
+ // CUPS 1.1.19/macOS 10.3@
+ int num_attrs; // Number of attributes @since
+ // CUPS 1.1.19/macOS 10.3@ @private@
+ int cur_attr; // Current attribute @since
+ // CUPS 1.1.19/macOS 10.3@ @private@
+ ppd_attr_t **attrs; // Attributes @since CUPS 1.1.19/macOS
+ // 10.3@ @private@
+
+ // **** New in CUPS 1.2/macOS 10.5 ****
+ cups_array_t *sorted_attrs; // Attribute lookup array @since
+ // CUPS 1.2/macOS 10.5@ @private@
+ cups_array_t *options; // Option lookup array @since
+ // CUPS 1.2/macOS 10.5@ @private@
+ cups_array_t *coptions; // Custom options array @since
+ // CUPS 1.2/macOS 10.5@ @private@
+
+ // **** New in CUPS 1.3/macOS 10.5 ****
+ cups_array_t *marked; // Marked choices
+ // @since CUPS 1.3/macOS 10.5@
+ // @private@
+
+ // **** New in CUPS 1.4/macOS 10.6 ****
+ cups_array_t *cups_uiconstraints; // cupsUIConstraints @since
+ // CUPS 1.4/macOS 10.6@ @private@
+
+ // **** New in CUPS 1.5 ****
+ ppd_cache_t *cache; // PPD cache and mapping data @since
+ // CUPS 1.5/macOS 10.7@ @private@
} ppd_file_t;
-/**** New in cups-filters 2.0.0: Ovetaken from cups-driverd ****/
-typedef struct /**** PPD record ****/
+// **** New in cups-filters 2.0.0: Ovetaken from cups-driverd ****
+typedef struct // **** PPD record ****
{
- time_t mtime; /* Modification time */
- off_t size; /* Size in bytes */
- int model_number; /* cupsModelNumber */
- int type; /* ppd-type */
- char filename[512], /* Filename */
- name[256], /* PPD name */
+ time_t mtime; // Modification time
+ off_t size; // Size in bytes
+ int model_number; // cupsModelNumber
+ int type; // ppd-type
+ char filename[512], // Filename
+ name[256], // PPD name
languages[PPD_MAX_LANG][6],
- /* LanguageVersion/cupsLanguages */
+ // LanguageVersion/cupsLanguages
products[PPD_MAX_PROD][128],
- /* Product strings */
+ // Product strings
psversions[PPD_MAX_VERS][32],
- /* PSVersion strings */
- make[128], /* Manufacturer */
- make_and_model[128], /* NickName/ModelName */
- device_id[256], /* IEEE 1284 Device ID */
- scheme[128]; /* PPD scheme */
+ // PSVersion strings
+ make[128], // Manufacturer
+ make_and_model[128], // NickName/ModelName
+ device_id[256], // IEEE 1284 Device ID
+ scheme[128]; // PPD scheme
} ppd_rec_t;
-typedef struct /**** In-memory record ****/
+typedef struct // **** In-memory record ****
{
- int found; /* 1 if PPD is found */
- int matches; /* Match count */
- ppd_rec_t record; /* PPDs.dat record */
+ int found; // 1 if PPD is found
+ int matches; // Match count
+ ppd_rec_t record; // PPDs.dat record
} ppd_info_t;
typedef struct
{
- char *name; /* Name for PPD collection */
- char *path; /* Directory where PPD collection is
- located */
+ char *name; // Name for PPD collection
+ char *path; // Directory where PPD collection is
+ // located
} ppd_collection_t;
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
-/* cupsMarkOptions replaced by ppdMarkOptions in libppd */
-/* extern int cupsMarkOptions(ppd_file_t *ppd, int num_options,
- cups_option_t *options); */
-/* Definition for backward compatibility, will be removed soon */
+// cupsMarkOptions replaced by ppdMarkOptions in libppd
+// extern int cupsMarkOptions(ppd_file_t *ppd, int num_options,
+// cups_option_t *options);
+// Definition for backward compatibility, will be removed soon
#define cupsMarkOptions cupsMarkOptions_USE_ppdMarkOptions_INSTEAD
extern void ppdClose(ppd_file_t *ppd);
extern ppd_size_t *ppdPageSize(ppd_file_t *ppd, const char *name);
extern float ppdPageWidth(ppd_file_t *ppd, const char *name);
-/**** New in CUPS 1.1.19 ****/
+// **** New in CUPS 1.1.19 ****
extern const char *ppdErrorString(ppd_status_t status);
extern ppd_attr_t *ppdFindAttr(ppd_file_t *ppd, const char *name,
const char *spec);
const char *spec);
extern ppd_status_t ppdLastError(int *line);
-/**** New in CUPS 1.1.20 ****/
+// **** New in CUPS 1.1.20 ****
extern void ppdSetConformance(ppd_conform_t c);
-/**** New in CUPS 1.2 ****/
-/* cupsRasterInterpretPPD replaced by ppdRasterInterpretPPD in libppd */
-/* extern int cupsRasterInterpretPPD(cups_page_header2_t *h,
- ppd_file_t *ppd,
- int num_options,
- cups_option_t *options,
- cups_interpret_cb_t func); */
-/* Definition for backward compatibility, will be removed soon */
+// **** New in CUPS 1.2 ****
+// cupsRasterInterpretPPD replaced by ppdRasterInterpretPPD in libppd
+// extern int cupsRasterInterpretPPD(cups_page_header2_t *h,
+// ppd_file_t *ppd,
+// int num_options,
+// cups_option_t *options,
+// cups_interpret_cb_t func);
+// Definition for backward compatibility, will be removed soon
#define cupsRasterInterpretPPD cupsRasterInterpretPPD_USE_ppdRasterInterpretPPD_INSTEAD
extern int ppdCollect2(ppd_file_t *ppd, ppd_section_t section,
extern int ppdLocalize(ppd_file_t *ppd);
extern ppd_file_t *ppdOpen2(cups_file_t *fp);
-/**** New in CUPS 1.3/macOS 10.5 ****/
+// **** New in CUPS 1.3/macOS 10.5 ****
extern const char *ppdLocalizeIPPReason(ppd_file_t *ppd,
const char *reason,
const char *scheme,
char *buffer,
size_t bufsize);
-/**** New in CUPS 1.4/macOS 10.6 ****/
-/* cupsGetConflicts replaced by ppdGetConflicts in libppd */
-/* extern int cupsGetConflicts(ppd_file_t *ppd, const char *option,
- const char *choice,
- cups_option_t **options); */
-/* Definition for backward compatibility, will be removed soon */
+// **** New in CUPS 1.4/macOS 10.6 ****
+// cupsGetConflicts replaced by ppdGetConflicts in libppd
+// extern int cupsGetConflicts(ppd_file_t *ppd, const char *option,
+// const char *choice,
+// cups_option_t **options);
+// Definition for backward compatibility, will be removed soon
#define cupsGetConflicts cupsGetConflicts_USE_ppdGetConflicts_INSTEAD
-/* cupsResolveConflicts replaced by ppdResolveConflicts in libppd */
-/* extern int cupsResolveConflicts(ppd_file_t *ppd,
- const char *option,
- const char *choice,
- int *num_options,
- cups_option_t **options); */
-/* Definition for backward compatibility, will be removed soon */
+// cupsResolveConflicts replaced by ppdResolveConflicts in libppd
+// extern int cupsResolveConflicts(ppd_file_t *ppd,
+// const char *option,
+// const char *choice,
+// int *num_options,
+// cups_option_t **options);
+// Definition for backward compatibility, will be removed soon
#define cupsResolveConflicts cupsResolveConflicts_USE_ppdResolveConflicts_INSTEAD
extern int ppdInstallableConflict(ppd_file_t *ppd,
ppd_size_t *minimum,
ppd_size_t *maximum);
-/**** New in cups-filters 2.0.0: Renamed functions from original CUPS API ****/
+// **** New in cups-filters 2.0.0: Renamed functions from original CUPS API ****
extern int ppdMarkOptions(ppd_file_t *ppd,
int num_options,
cups_option_t *options);
int *num_options,
cups_option_t **options);
-/**** New in cups-filters 2.0.0: Formerly CUPS-private functions ****/
+// **** New in cups-filters 2.0.0: Formerly CUPS-private functions ****
extern int ppdConvertOptions(ipp_t *request,
ppd_file_t *ppd,
ppd_cache_t *pc,
size_t namesize,
const char *dashchars);
-/**** New in cups-filters 2.0.0: Overtaken from ippeveprinter ****/
+// **** New in cups-filters 2.0.0: Overtaken from ippeveprinter ****
extern ipp_t *ppdLoadAttributes(ppd_file_t *ppd);
-/**** New in cups-filters 2.0.0: Overtaken from ippeveps ****/
+// **** New in cups-filters 2.0.0: Overtaken from ippeveps ****
extern int ppdGetOptions(cups_option_t **options,
ipp_t *printer_attrs,
ipp_t *job_attrs,
ppd_file_t *ppd);
-/**** New in cups-filters 2.0.0: Added for pclmtoraster filter ****/
+// **** New in cups-filters 2.0.0: Added for pclmtoraster filter ****
extern int ppdRasterMatchPPDSize(cups_page_header2_t *header,
ppd_file_t *ppd,
double margins[4],
int *image_fit,
int *landscape);
-/**** New in cups-filters 2.0.0: Ovetaken from cups-driverd ****/
+// **** New in cups-filters 2.0.0: Ovetaken from cups-driverd ****
extern cups_array_t *ppdCollectionListPPDs(cups_array_t *ppd_collections,
int limit,
int num_options,
cf_logfunc_t log,
void *ld);
-/**** New in cups-filters 2.0.0: For PPD retro-fit Printer Applications ****/
+// **** New in cups-filters 2.0.0: For PPD retro-fit Printer Applications ****
extern void ppdCacheAssignPresets(ppd_file_t *ppd, ppd_cache_t *pc);
-/**** New in cups-filters 2.0.0: JCL for PDF printers, for
- ppdFilterPDFToPDF() and ppdFilterImageToPDF() ****/
+// **** New in cups-filters 2.0.0: JCL for PDF printers, for
+// ppdFilterPDFToPDF() and ppdFilterImageToPDF() ****
extern int ppdEmitJCLPDF(ppd_file_t *ppd, FILE *fp,
int job_id, const char *user,
const char *title,
int hw_copies, bool hw_collate);
-/**** New in cups-filters 2.0.0: PPD file generator for CUPS queues for
- driverless printers, compared to the one of CUPS this one supports
- also clusters composed of different printers as composed by
- cups-browsed, was cfCreatePPDFromIPP(2)() in libcupsfilters before ****/
+// **** New in cups-filters 2.0.0: PPD file generator for CUPS queues for
+// driverless printers, compared to the one of CUPS this one supports
+// also clusters composed of different printers as composed by
+// cups-browsed, was ppdCreateFromIPP(2)() in libcupsfilters 1.x ****
char *ppdCreatePPDFromIPP(char *buffer, size_t bufsize,
ipp_t *response, const char *make_model,
const char *pdl, int color, int duplex,
const char *default_cluster_color,
char *status_msg, size_t status_msg_size);
-/**** New in cups-filters 2.0.0: Functions to load color profile data from
- PPD files, from driver.h ****/
+// **** New in cups-filters 2.0.0: Functions to load color profile data from
+// PPD files, from driver.h ****
extern ppd_attr_t *ppdFindColorAttr(ppd_file_t *ppd, const char *name,
const char *colormodel,
const char *media,
void *ld);
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_PPD_PPD_H_ */
+# endif // __cplusplus
+#endif // !_PPD_PPD_H_
//
-// Array class for the CUPS PPD Compiler.
+// Array class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2019 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Attribute class for the CUPS PPD Compiler.
+// Attribute class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Shared message catalog class for the CUPS PPD Compiler.
+// Shared message catalog class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2017 by Apple Inc.
// Copyright 2002-2006 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
char pofile[1024]; // Message catalog file
const char *c;
- /* Determine CUPS datadir (usually /usr/share/cups) */
+ // Determine CUPS datadir (usually /usr/share/cups)
if ((c = getenv("CUPS_DATADIR")) == NULL)
c = CUPS_DATADIR;
goto unknown_load_format;
else if (!strcmp(ptr, ".strings"))
{
- /*
- * Read messages in macOS ".strings" format, which are either UTF-8/UTF-16
- * text files of the format:
- *
- * "id" = "str";
- *
- * Strings files can also contain C-style comments.
- */
+ //
+ // Read messages in macOS ".strings" format, which are either UTF-8/UTF-16
+ // text files of the format:
+ //
+ // "id" = "str";
+ //
+ // Strings files can also contain C-style comments.
+ //
ppdc_cs_t cs = PPDC_CS_AUTO; // Character set for file
int ch; // Current character from file
}
else if (!strcmp(ptr, ".po") || !strcmp(ptr, ".gz"))
{
- /*
- * Read messages from the catalog file until EOF...
- *
- * The format is the GNU gettext .po format, which is fairly simple:
- *
- * msgid "some text"
- * msgstr "localized text"
- *
- * The ID and localized text can span multiple lines using the form:
- *
- * msgid ""
- * "some long text"
- * msgstr ""
- * "localized text spanning "
- * "multiple lines"
- */
+ //
+ // Read messages from the catalog file until EOF...
+ //
+ // The format is the GNU gettext .po format, which is fairly simple:
+ //
+ // msgid "some text"
+ // msgstr "localized text"
+ //
+ // The ID and localized text can span multiple lines using the form:
+ //
+ // msgid ""
+ // "some long text"
+ // msgstr ""
+ // "localized text spanning "
+ // "multiple lines"
+ //
int which, // In msgid?
haveid, // Did we get a msgid string?
else
goto unknown_load_format;
- /*
- * Close the file and return...
- */
+ //
+ // Close the file and return...
+ //
cupsFileClose(fp);
return (0);
- /*
- * Unknown format error...
- */
+ //
+ // Unknown format error...
+ //
unknown_load_format:
//
-// Option choice class for the CUPS PPD Compiler.
+// Option choice class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Contraint class for the CUPS PPD Compiler.
+// Contraint class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// PPD file compiler definitions for the CUPS PPD Compiler.
+// PPD file compiler definitions for the CUPS PPD Compiler in libppd.
//
// Copyright © 2007-2019 by Apple Inc.
// Copyright © 2002-2006 by Easy Software Products.
//
-// File class for the CUPS PPD Compiler.
+// File class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2010 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Filter class for the CUPS PPD Compiler.
+// Filter class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Shared font class for the CUPS PPD Compiler.
+// Shared font class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Group class for the CUPS PPD Compiler.
+// Group class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2011 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// PPD file import methods for the CUPS PPD Compiler.
+// PPD file import methods for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2011 by Apple Inc.
// Copyright 2002-2006 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Shared media size class for the CUPS PPD Compiler.
+// Shared media size class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Shared message class for the CUPS PPD Compiler.
+// Shared message class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Option class for the CUPS PPD Compiler.
+// Option class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2011 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Private definitions for the CUPS PPD Compiler.
+// Private definitions for the CUPS PPD Compilerin libppd.
//
// Copyright 2009-2010 by Apple Inc.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
#ifndef _PPDC_PRIVATE_H_
# define PPDC_NEWVAL(s)
# define PPDC_DELETE
# define PPDC_DELETEVAL(s)
-# endif /* PPDC_DEBUG */
+# endif // PPDC_DEBUG
-/*
- * Macro for localized text...
- */
+//
+// Macro for localized text...
+//
# define _(x) x
//
-// Color profile class for the CUPS PPD Compiler.
+// Color profile class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Shared data class for the CUPS PPD Compiler.
+// Shared data class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
fprintf(stderr, "ERROR: Over-release of %s: %p\n", class_name(), this);
abort();
}
-#endif /* DEBUG */
+#endif // DEBUG
if (use == 0)
delete this;
//
-// Source class for the CUPS PPD Compiler.
+// Source class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2018 by Apple Inc.
// Copyright 2002-2007 by Easy Software Products.
// NAME logicop value
for (newv = (char *)v + 1;
*newv && (isalnum(*newv & 255) || *newv == '_');
- newv ++)
- /* do nothing */;
+ newv ++);
+ // do nothing
ch = *newv;
*newv = '\0';
if (size == 'L')
bytes += cupsFilePrintf(fp, tformat, va_arg(ap, long long));
else
-# endif /* HAVE_LONG_LONG */
+# endif // HAVE_LONG_LONG
if (size == 'l')
bytes += cupsFilePrintf(fp, tformat, va_arg(ap, long));
else
//
-// Shared string class for the CUPS PPD Compiler.
+// Shared string class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2012 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// Variable class for the CUPS PPD Compiler.
+// Variable class for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2009 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// PPD file compiler main entry for the CUPS PPD Compiler.
+// PPD file compiler main entry for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2014 by Apple Inc.
// Copyright 2002-2007 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
fprintf(stdout, _("%s: Writing %s.\n"), progname, filename);
}
- /*
- * Write the PPD file...
- */
+ //
+ // Write the PPD file...
+ //
ppdcArray *templocales = locales;
//
-// Definitions for the CUPS PPD Compiler.
+// API definitions for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2019 by Apple Inc.
// Copyright 2002-2007 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
#ifndef _PPDC_H_
//
-// PPD to HTML utility for the CUPS PPD Compiler.
+// PPD to HTML utility for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2015 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// PPD file import utility for the CUPS PPD Compiler.
+// PPD file import utility for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2011 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
//
-// PPD file merge utility for the CUPS PPD Compiler.
+// PPD file merge utility for the CUPS PPD Compiler in libppd.
//
// Copyright © 2007-2018 by Apple Inc.
// Copyright © 2002-2007 by Easy Software Products.
static char locale[256]; // Locale string
static struct // LanguageVersion translation table
{
- const char *version, // LanguageVersion string */
- *language; // Language code */
+ const char *version, // LanguageVersion string
+ *language; // Language code
} languages[] =
{
{ "chinese", "zh" },
//
-// PPD file message catalog program for the CUPS PPD Compiler.
+// PPD file message catalog program for the CUPS PPD Compiler in libppd.
//
// Copyright 2007-2015 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
-/*
- * Raster error handling for libppd.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Raster error handling for libppd.
+//
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "raster-private.h"
#include "debug-internal.h"
-typedef struct _ppd_raster_error_s /**** Error buffer structure ****/
+typedef struct _ppd_raster_error_s // **** Error buffer structure ****
{
- char *start, /* Start of buffer */
- *current, /* Current position in buffer */
- *end; /* End of buffer */
+ char *start, // Start of buffer
+ *current, // Current position in buffer
+ *end; // End of buffer
} _ppd_raster_error_t;
static _ppd_raster_error_t *buf = NULL;
-/*
- * '_ppdRasterAddError()' - Add an error message to the error buffer.
- */
+//
+// '_ppdRasterAddError()' - Add an error message to the error buffer.
+//
void
-_ppdRasterAddError(const char *f, /* I - Printf-style error message */
- ...) /* I - Additional arguments as needed */
+_ppdRasterAddError(const char *f, // I - Printf-style error message
+ ...) // I - Additional arguments as needed
{
- va_list ap; /* Pointer to additional arguments */
- char s[2048]; /* Message string */
- ssize_t bytes; /* Bytes in message string */
+ va_list ap; // Pointer to additional arguments
+ char s[2048]; // Message string
+ ssize_t bytes; // Bytes in message string
DEBUG_printf(("_ppdRasterAddError(f=\"%s\", ...)", f));
if (bytes > (ssize_t)(buf->end - buf->current))
{
- /*
- * Allocate more memory...
- */
+ //
+ // Allocate more memory...
+ //
- char *temp; /* New buffer */
- size_t size; /* Size of buffer */
+ char *temp; // New buffer
+ size_t size; // Size of buffer
size = (size_t)(buf->end - buf->start + 2 * bytes + 1024);
if (!temp)
return;
- /*
- * Update pointers...
- */
+ //
+ // Update pointers...
+ //
buf->end = temp + size;
buf->current = temp + (buf->current - buf->start);
buf->start = temp;
}
- /*
- * Append the message to the end of the current string...
- */
+ //
+ // Append the message to the end of the current string...
+ //
memcpy(buf->current, s, (size_t)bytes);
buf->current += bytes - 1;
}
-/*
- * '_ppdRasterClearError()' - Clear the error buffer.
- */
+//
+// '_ppdRasterClearError()' - Clear the error buffer.
+//
void
_ppdRasterClearError(void)
{
- if (buf == NULL) {
+ if (buf == NULL)
+ {
buf = malloc(sizeof(_ppd_raster_error_t));
buf->start = NULL;
buf->end = NULL;
}
-/*
- * '_ppdRasterErrorString()' - Return the last error from a raster function.
- *
- * If there are no recent errors, NULL is returned.
- *
- * @since CUPS 1.3/macOS 10.5@
- */
+//
+// '_ppdRasterErrorString()' - Return the last error from a raster function.
+//
+// If there are no recent errors, NULL is returned.
+//
+// @since CUPS 1.3/macOS 10.5@
+//
-const char * /* O - Last error */
+const char * // O - Last error
_ppdRasterErrorString(void)
{
if (buf->current == buf->start)
-/*
- * PPD command interpreter for libppd.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1993-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// PPD command interpreter for libppd.
+//
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1993-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "raster-private.h"
#include "ppd.h"
#include <math.h>
-/*
- * Stack values for the PostScript mini-interpreter...
- */
+//
+// Stack values for the PostScript mini-interpreter...
+//
typedef enum
{
typedef struct
{
- _ppd_ps_type_t type; /* Object type */
+ _ppd_ps_type_t type; // Object type
union
{
- int boolean; /* Boolean value */
- char name[64]; /* Name value */
- double number; /* Number value */
- char other[64]; /* Other operator */
- char string[64]; /* Sring value */
- } value; /* Value */
+ int boolean; // Boolean value
+ char name[64]; // Name value
+ double number; // Number value
+ char other[64]; // Other operator
+ char string[64]; // Sring value
+ } value; // Value
} _ppd_ps_obj_t;
typedef struct
{
- int num_objs, /* Number of objects on stack */
- alloc_objs; /* Number of allocated objects */
- _ppd_ps_obj_t *objs; /* Objects in stack */
+ int num_objs, // Number of objects on stack
+ alloc_objs; // Number of allocated objects
+ _ppd_ps_obj_t *objs; // Objects in stack
} _ppd_ps_stack_t;
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static int ppd_cleartomark_stack(_ppd_ps_stack_t *st);
static int ppd_copy_stack(_ppd_ps_stack_t *st, int count);
#ifdef DEBUG
static void ppd_DEBUG_object(const char *prefix, _ppd_ps_obj_t *obj);
static void ppd_DEBUG_stack(const char *prefix, _ppd_ps_stack_t *st);
-#endif /* DEBUG */
-
-
-/*
- * 'ppdRasterInterpretPPD()' - Interpret PPD commands to create a page header.
- *
- * This function is used by raster image processing (RIP) filters like
- * cgpdftoraster and imagetoraster when writing CUPS raster data for a page.
- * It is not used by raster printer driver filters which only read CUPS
- * raster data.
- *
- *
- * @code ppdRasterInterpretPPD@ does not mark the options in the PPD using
- * the "num_options" and "options" arguments. Instead, mark the options with
- * @code ppdMarkOptions@ and @code ppdMarkOption@ prior to calling it -
- * this allows for per-page options without manipulating the options array.
- *
- * The "func" argument specifies an optional callback function that is
- * called prior to the computation of the final raster data. The function
- * can make changes to the @link cups_page_header2_t@ data as needed to use a
- * supported raster format and then returns 0 on success and -1 if the
- * requested attributes cannot be supported.
- *
- *
- * @code ppdRasterInterpretPPD@ supports a subset of the PostScript language.
- * Currently only the @code [@, @code ]@, @code <<@, @code >>@, @code {@,
- * @code }@, @code cleartomark@, @code copy@, @code dup@, @code index@,
- * @code pop@, @code roll@, @code setpagedevice@, and @code stopped@ operators
- * are supported.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
-
-int /* O - 0 on success, -1 on failure */
+#endif // DEBUG
+
+
+//
+// 'ppdRasterInterpretPPD()' - Interpret PPD commands to create a page header.
+//
+// This function is used by raster image processing (RIP) filters like
+// cgpdftoraster and imagetoraster when writing CUPS raster data for a page.
+// It is not used by raster printer driver filters which only read CUPS
+// raster data.
+//
+//
+// @code ppdRasterInterpretPPD@ does not mark the options in the PPD using
+// the "num_options" and "options" arguments. Instead, mark the options with
+// @code ppdMarkOptions@ and @code ppdMarkOption@ prior to calling it -
+// this allows for per-page options without manipulating the options array.
+//
+// The "func" argument specifies an optional callback function that is
+// called prior to the computation of the final raster data. The function
+// can make changes to the @link cups_page_header2_t@ data as needed to use a
+// supported raster format and then returns 0 on success and -1 if the
+// requested attributes cannot be supported.
+//
+//
+// @code ppdRasterInterpretPPD@ supports a subset of the PostScript language.
+// Currently only the @code [@, @code ]@, @code <<@, @code >>@, @code {@,
+// @code }@, @code cleartomark@, @code copy@, @code dup@, @code index@,
+// @code pop@, @code roll@, @code setpagedevice@, and @code stopped@ operators
+// are supported.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
+
+int // O - 0 on success, -1 on failure
ppdRasterInterpretPPD(
- cups_page_header2_t *h, /* O - Page header to create */
- ppd_file_t *ppd, /* I - PPD file */
- int num_options, /* I - Number of options */
- cups_option_t *options, /* I - Options */
- cups_interpret_cb_t func) /* I - Optional page header callback (@code NULL@ for none) */
+ cups_page_header2_t *h, // O - Page header to create
+ ppd_file_t *ppd, // I - PPD file
+ int num_options, // I - Number of options
+ cups_option_t *options, // I - Options
+ cups_interpret_cb_t func) // I - Optional page header callback
+ // (@code NULL@ for none)
{
- int status; /* Cummulative status */
- char *code; /* Code to run */
- const char *val; /* Option value */
- ppd_size_t *size; /* Current size */
- float left, /* Left position */
- bottom, /* Bottom position */
- right, /* Right position */
- top, /* Top position */
- temp1, temp2; /* Temporary variables for swapping */
- int preferred_bits; /* Preferred bits per color */
-
-
- /*
- * Range check input...
- */
+ int status; // Cummulative status
+ char *code; // Code to run
+ const char *val; // Option value
+ ppd_size_t *size; // Current size
+ float left, // Left position
+ bottom, // Bottom position
+ right, // Right position
+ top, // Top position
+ temp1, temp2; // Temporary variables for swapping
+ int preferred_bits; // Preferred bits per color
+
+
+ //
+ // Range check input...
+ //
_ppdRasterClearError();
return (-1);
}
- /*
- * Reset the page header to the defaults...
- */
+ //
+ // Reset the page header to the defaults...
+ //
memset(h, 0, sizeof(cups_page_header2_t));
strlcpy(h->cupsPageSizeName, "Letter", sizeof(h->cupsPageSizeName));
#ifdef __APPLE__
- /*
- * cupsInteger0 is also used for the total page count on macOS; set an
- * uncommon default value so we can tell if the driver is using cupsInteger0.
- */
+ //
+ // cupsInteger0 is also used for the total page count on macOS; set an
+ // uncommon default value so we can tell if the driver is using cupsInteger0.
+ //
h->cupsInteger[0] = 0x80000000;
-#endif /* __APPLE__ */
+#endif // __APPLE__
- /*
- * Apply patches and options to the page header...
- */
+ //
+ // Apply patches and options to the page header...
+ //
status = 0;
preferred_bits = 0;
if (ppd)
{
- /*
- * Apply any patch code (used to override the defaults...)
- */
+ //
+ // Apply any patch code (used to override the defaults...)
+ //
if (ppd->patches)
status |= ppdRasterExecPS(h, &preferred_bits, ppd->patches);
- /*
- * Then apply printer options in the proper order...
- */
+ //
+ // Then apply printer options in the proper order...
+ //
if ((code = ppdEmitString(ppd, PPD_ORDER_DOCUMENT, 0.0)) != NULL)
{
}
}
- /*
- * Allow option override for page scaling...
- */
+ //
+ // Allow option override for page scaling...
+ //
if ((val = cupsGetOption("cupsBorderlessScalingFactor", num_options,
options)) != NULL)
{
- double sc = atof(val); /* Scale factor */
+ double sc = atof(val); // Scale factor
if (sc >= 0.1 && sc <= 2.0)
h->cupsBorderlessScalingFactor = (float)sc;
}
- /*
- * Get the margins for the current size...
- */
+ //
+ // Get the margins for the current size...
+ //
if ((size = ppdPageSize(ppd, NULL)) != NULL)
{
- /*
- * Use the margins from the PPD file...
- */
+ //
+ // Use the margins from the PPD file...
+ //
left = size->left;
bottom = size->bottom;
}
else
{
- /*
- * Use the default margins...
- */
+ //
+ // Use the default margins...
+ //
left = 0.0f;
bottom = 0.0f;
top = 792.0f;
}
- /*
- * Handle orientation...
- */
+ //
+ // Handle orientation...
+ //
switch (h->Orientation)
{
case CUPS_ORIENT_0 :
default :
- /* Do nothing */
+ // Do nothing
break;
case CUPS_ORIENT_90 :
h->cupsImagingBBox[2] = (float)right;
h->cupsImagingBBox[3] = (float)top;
- /*
- * Use the callback to validate the page header...
- */
+ //
+ // Use the callback to validate the page header...
+ //
if (func && (*func)(h, preferred_bits))
{
return (-1);
}
- /*
- * Check parameters...
- */
+ //
+ // Check parameters...
+ //
if (!h->HWResolution[0] || !h->HWResolution[1] ||
!h->PageSize[0] || !h->PageSize[1] ||
return (-1);
}
- /*
- * Compute the bitmap parameters...
- */
+ //
+ // Compute the bitmap parameters...
+ //
h->cupsWidth = (unsigned)((right - left) * h->cupsBorderlessScalingFactor *
- h->HWResolution[0] / 72.0f + 0.5f);
+ h->HWResolution[0] / 72.0f + 0.5f);
h->cupsHeight = (unsigned)((top - bottom) * h->cupsBorderlessScalingFactor *
- h->HWResolution[1] / 72.0f + 0.5f);
+ h->HWResolution[1] / 72.0f + 0.5f);
switch (h->cupsColorSpace)
{
break;
default :
- /*
- * Ensure that colorimetric colorspaces use at least 8 bits per
- * component...
- */
+ //
+ // Ensure that colorimetric colorspaces use at least 8 bits per
+ // component...
+
if (h->cupsColorSpace >= CUPS_CSPACE_CIEXYZ &&
h->cupsBitsPerColor < 8)
h->cupsBitsPerColor = 8;
- /*
- * Figure out the number of bits per pixel...
- */
+ //
+ // Figure out the number of bits per pixel...
+ //
if (h->cupsColorOrder == CUPS_ORDER_CHUNKED)
{
break;
}
- /*
- * Fall through to CMYK code...
- */
+ //
+ // Fall through to CMYK code...
+ //
case CUPS_CSPACE_RGBA :
case CUPS_CSPACE_RGBW :
return (status);
}
-/*
- * 'ppdRasterMatchPageSize()' - Match PPD page size to header page size.
- */
+//
+// 'ppdRasterMatchPageSize()' - Match PPD page size to header page size.
+//
-int /* O - 0 on success, -1 on failure */
+int // O - 0 on success, -1 on failure
ppdRasterMatchPPDSize(
- cups_page_header2_t *header, /* I - Page header to match */
- ppd_file_t *ppd, /* I - PPD file */
- double margins[4], /* O - Margins of media in points */
- double dimensions[2], /* O - Width and Length of media in points */
- int *image_fit, /* O - Imageable Area Fit */
- int *landscape) /* O - Landscape / Portrait Fit */
+ cups_page_header2_t *header, // I - Page header to match
+ ppd_file_t *ppd, // I - PPD file
+ double margins[4], // O - Margins of media in points
+ double dimensions[2], // O - Width and Length of media in points
+ int *image_fit, // O - Imageable Area Fit
+ int *landscape) // O - Landscape / Portrait Fit
{
- ppd_size_t *size, /* Current size */
- *size_matched = NULL; /* Matched size */
- int i = 0; /* Loop variable */
- char pageSizeRequested[64]; /* Requested PageSize */
+ ppd_size_t *size, // Current size
+ *size_matched = NULL; // Matched size
+ int i = 0; // Loop variable
+ char pageSizeRequested[64]; // Requested PageSize
if (!header)
{
return (-1);
}
- strncpy(pageSizeRequested, header->cupsPageSizeName, 64); /* Prefer user-selected page size. */
+ strncpy(pageSizeRequested, header->cupsPageSizeName, 64);
+ // Prefer user-selected page size.
memset(dimensions, 0, sizeof(double)*2);
memset(margins, 0, sizeof(double)*4);
size_matched = NULL;
for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
{
- /* Skip page sizes which conflict with settings of the other options */
- /* Find size of document's page under the PPD page sizes */
+ // Skip page sizes which conflict with settings of the other options
+ // Find size of document's page under the PPD page sizes
if (fabs(header->PageSize[1] - size->length) / size->length < 0.01 &&
fabs(header->PageSize[0] - size->width) / size->width < 0.01 &&
(size_matched == NULL || !strcasecmp(pageSizeRequested, size->name)))
}
if (size_matched == NULL)
- /* Input page size does not fit any of the PPD's sizes, try to fit
- the input page size into the imageable areas of the PPD's sizes */
- for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
- {
- if (fabs(header->PageSize[1] - size->top + size->bottom) / size->length < 0.01 &&
- fabs(header->PageSize[0] - size->right + size->left) / size->width < 0.01 &&
- (size_matched == NULL || !strcasecmp(pageSizeRequested, size->name)))
+ // Input page size does not fit any of the PPD's sizes, try to fit
+ // the input page size into the imageable areas of the PPD's sizes
+ for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
{
- DEBUG_puts("Imageable area fit\n");
- size_matched = size;
- if (landscape) *landscape = 0;
- if (image_fit) *image_fit = 1;
+ if (fabs(header->PageSize[1] -
+ size->top + size->bottom) / size->length < 0.01 &&
+ fabs(header->PageSize[0] -
+ size->right + size->left) / size->width < 0.01 &&
+ (size_matched == NULL || !strcasecmp(pageSizeRequested, size->name)))
+ {
+ DEBUG_puts("Imageable area fit\n");
+ size_matched = size;
+ if (landscape) *landscape = 0;
+ if (image_fit) *image_fit = 1;
+ }
}
- }
if (size_matched)
{
- /*
- * Standard size...
- */
+ //
+ // Standard size...
+ //
+
DEBUG_printf(("PPD matched size = %s", size_matched->name));
size = size_matched;
dimensions[0] = size->width;
}
else
{
- /*
- * No matching portrait size; look for a matching size in
- * landscape orientation...
- */
+ //
+ // No matching portrait size; look for a matching size in
+ // landscape orientation...
+ //
+
size_matched = 0;
for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
if (fabs(header->PageSize[0] - size->length) / size->length < 0.01 &&
}
if (size_matched == NULL)
- /* Input page size does not fit any of the PPD's sizes, try to fit
- the input page size into the imageable areas of the PPD's sizes */
- for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
- {
- if (fabs(header->PageSize[0] - size->top + size->bottom) / size->length < 0.01 &&
- fabs(header->PageSize[1] - size->right + size->left) / size->width < 0.01 &&
- (size_matched == NULL || !strcasecmp(pageSizeRequested, size->name)))
+ // Input page size does not fit any of the PPD's sizes, try to fit
+ // the input page size into the imageable areas of the PPD's sizes
+ for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
{
- DEBUG_puts("Imageable area fit\n");
- size_matched = size;
- if (landscape) *landscape = 1;
- if (image_fit) *image_fit = 1;
+ if (fabs(header->PageSize[0] -
+ size->top + size->bottom) / size->length < 0.01 &&
+ fabs(header->PageSize[1] -
+ size->right + size->left) / size->width < 0.01 &&
+ (size_matched == NULL ||
+ !strcasecmp(pageSizeRequested, size->name)))
+ {
+ DEBUG_puts("Imageable area fit\n");
+ size_matched = size;
+ if (landscape) *landscape = 1;
+ if (image_fit) *image_fit = 1;
+ }
}
- }
}
if (size_matched)
{
- /*
- * Standard size in landscape orientation...
- */
+ //
+ // Standard size in landscape orientation...
+ //
+
size = size_matched;
DEBUG_printf(("landscape size = %s", size->name));
dimensions[0] = size->width;
}
else
{
- /*
- * Custom size...
- */
+ //
+ // Custom size...
+ //
+
DEBUG_puts("size = Custom\n");
for (i = 0; i < 2; i ++)
dimensions[i] = header->PageSize[i];
for (i = 0; i < 4; i ++)
margins[i] = ppd->custom_margins[i];
- snprintf(header->cupsPageSizeName, 64, "Custom.%dx%d", header->PageSize[0], header->PageSize[1]);
+ snprintf(header->cupsPageSizeName, 64, "Custom.%dx%d",
+ header->PageSize[0], header->PageSize[1]);
}
return 0;
}
-/*
- * 'ppdRasterExecPS()' - Execute PostScript code to initialize a page header.
- */
+//
+// 'ppdRasterExecPS()' - Execute PostScript code to initialize a page header.
+//
-int /* O - 0 on success, -1 on error */
+int // O - 0 on success, -1 on error
ppdRasterExecPS(
- cups_page_header2_t *h, /* O - Page header */
- int *preferred_bits,/* O - Preferred bits per color */
- const char *code) /* I - PS code to execute */
+ cups_page_header2_t *h, // O - Page header
+ int *preferred_bits,// O - Preferred bits per color
+ const char *code) // I - PS code to execute
{
- int error = 0; /* Error condition? */
- _ppd_ps_stack_t *st; /* PostScript value stack */
- _ppd_ps_obj_t *obj; /* Object from top of stack */
- char *codecopy, /* Copy of code */
- *codeptr; /* Pointer into copy of code */
+ int error = 0; // Error condition?
+ _ppd_ps_stack_t *st; // PostScript value stack
+ _ppd_ps_obj_t *obj; // Object from top of stack
+ char *codecopy, // Copy of code
+ *codeptr; // Pointer into copy of code
DEBUG_printf(("ppdRasterExecPS(h=%p, preferred_bits=%p, code=\"%s\")\n",
h, preferred_bits, code));
- /*
- * Copy the PostScript code and create a stack...
- */
+ //
+ // Copy the PostScript code and create a stack...
+ //
if ((codecopy = strdup(code)) == NULL)
{
return (-1);
}
- /*
- * Parse the PS string until we run out of data...
- */
+ //
+ // Parse the PS string until we run out of data...
+ //
codeptr = codecopy;
#ifdef DEBUG
DEBUG_printf(("ppdRasterExecPS: Stack (%d objects)", st->num_objs));
ppd_DEBUG_object("ppdRasterExecPS", obj);
-#endif /* DEBUG */
+#endif // DEBUG
switch (obj->type)
{
default :
- /* Do nothing for regular values */
+ // Do nothing for regular values
break;
case PPD_PS_CLEARTOMARK :
#ifdef DEBUG
DEBUG_puts("1_ppdRasterExecPS: dup");
ppd_DEBUG_stack("ppdRasterExecPS", st);
-#endif /* DEBUG */
+#endif // DEBUG
break;
case PPD_PS_COPY :
#ifdef DEBUG
DEBUG_puts("ppdRasterExecPS: copy");
ppd_DEBUG_stack("ppdRasterExecPS", st);
-#endif /* DEBUG */
+#endif // DEBUG
}
break;
#ifdef DEBUG
DEBUG_puts("ppdRasterExecPS: dup");
ppd_DEBUG_stack("ppdRasterExecPS", st);
-#endif /* DEBUG */
+#endif // DEBUG
break;
case PPD_PS_INDEX :
#ifdef DEBUG
DEBUG_puts("ppdRasterExecPS: index");
ppd_DEBUG_stack("ppdRasterExecPS", st);
-#endif /* DEBUG */
+#endif // DEBUG
}
break;
#ifdef DEBUG
DEBUG_puts("ppdRasterExecPS: pop");
ppd_DEBUG_stack("ppdRasterExecPS", st);
-#endif /* DEBUG */
+#endif // DEBUG
break;
case PPD_PS_ROLL :
ppd_pop_stack(st);
if ((obj = ppd_pop_stack(st)) != NULL)
{
- int c; /* Count */
+ int c; // Count
c = (int)obj->value.number;
#ifdef DEBUG
DEBUG_puts("ppdRasterExecPS: roll");
ppd_DEBUG_stack("ppdRasterExecPS", st);
-#endif /* DEBUG */
+#endif // DEBUG
}
}
break;
#ifdef DEBUG
DEBUG_puts("ppdRasterExecPS: setpagedevice");
ppd_DEBUG_stack("ppdRasterExecPS", st);
-#endif /* DEBUG */
+#endif // DEBUG
break;
case PPD_PS_START_PROC :
break;
}
- /*
- * Cleanup...
- */
+ //
+ // Cleanup...
+ //
free(codecopy);
#ifdef DEBUG
DEBUG_puts("ppdRasterExecPS: Stack not empty");
ppd_DEBUG_stack("ppdRasterExecPS", st);
-#endif /* DEBUG */
+#endif // DEBUG
ppd_delete_stack(st);
ppd_delete_stack(st);
- /*
- * Return success...
- */
+ //
+ // Return success...
+ //
return (0);
}
-/*
- * 'ppd_cleartomark_stack()' - Clear to the last mark ([) on the stack.
- */
+//
+// 'ppd_cleartomark_stack()' - Clear to the last mark ([) on the stack.
+//
-static int /* O - 0 on success, -1 on error */
-ppd_cleartomark_stack(_ppd_ps_stack_t *st) /* I - Stack */
+static int // O - 0 on success, -1 on error
+ppd_cleartomark_stack(_ppd_ps_stack_t *st) // I - Stack
{
- _ppd_ps_obj_t *obj; /* Current object on stack */
+ _ppd_ps_obj_t *obj; // Current object on stack
while ((obj = ppd_pop_stack(st)) != NULL)
}
-/*
- * 'ppd_copy_stack()' - Copy the top N stack objects.
- */
+//
+// 'ppd_copy_stack()' - Copy the top N stack objects.
+//
-static int /* O - 0 on success, -1 on error */
-ppd_copy_stack(_ppd_ps_stack_t *st, /* I - Stack */
- int c) /* I - Number of objects to copy */
+static int // O - 0 on success, -1 on error
+ppd_copy_stack(_ppd_ps_stack_t *st, // I - Stack
+ int c) // I - Number of objects to copy
{
- int n; /* Index */
+ int n; // Index
if (c < 0)
}
-/*
- * 'ppd_delete_stack()' - Free memory used by a stack.
- */
+//
+// 'ppd_delete_stack()' - Free memory used by a stack.
+//
static void
-ppd_delete_stack(_ppd_ps_stack_t *st) /* I - Stack */
+ppd_delete_stack(_ppd_ps_stack_t *st) // I - Stack
{
free(st->objs);
free(st);
}
-/*
- * 'ppd_error_object()' - Add an object's value to the current error message.
- */
+//
+// 'ppd_error_object()' - Add an object's value to the current error message.
+//
static void
-ppd_error_object(_ppd_ps_obj_t *obj) /* I - Object to add */
+ppd_error_object(_ppd_ps_obj_t *obj) // I - Object to add
{
switch (obj->type)
{
}
-/*
- * 'ppd_error_stack()' - Add a stack to the current error message...
- */
+//
+// 'ppd_error_stack()' - Add a stack to the current error message...
+//
static void
-ppd_error_stack(_ppd_ps_stack_t *st, /* I - Stack */
- const char *title) /* I - Title string */
+ppd_error_stack(_ppd_ps_stack_t *st, // I - Stack
+ const char *title) // I - Title string
{
- int c; /* Looping var */
- _ppd_ps_obj_t *obj; /* Current object on stack */
+ int c; // Looping var
+ _ppd_ps_obj_t *obj; // Current object on stack
_ppdRasterAddError("%s", title);
}
-/*
- * 'ppd_index_stack()' - Copy the Nth value on the stack.
- */
+//
+// 'ppd_index_stack()' - Copy the Nth value on the stack.
+//
-static _ppd_ps_obj_t * /* O - New object */
-ppd_index_stack(_ppd_ps_stack_t *st, /* I - Stack */
- int n) /* I - Object index */
+static _ppd_ps_obj_t * // O - New object
+ppd_index_stack(_ppd_ps_stack_t *st, // I - Stack
+ int n) // I - Object index
{
if (n < 0 || (n = st->num_objs - n - 1) < 0)
return (NULL);
}
-/*
- * 'ppd_new_stack()' - Create a new stack.
- */
+//
+// 'ppd_new_stack()' - Create a new stack.
+//
-static _ppd_ps_stack_t * /* O - New stack */
+static _ppd_ps_stack_t * // O - New stack
ppd_new_stack(void)
{
- _ppd_ps_stack_t *st; /* New stack */
+ _ppd_ps_stack_t *st; // New stack
if ((st = calloc(1, sizeof(_ppd_ps_stack_t))) == NULL)
}
-/*
- * 'pop_stock()' - Pop the top object off the stack.
- */
+//
+// 'pop_stock()' - Pop the top object off the stack.
+//
-static _ppd_ps_obj_t * /* O - Object */
-ppd_pop_stack(_ppd_ps_stack_t *st) /* I - Stack */
+static _ppd_ps_obj_t * // O - Object
+ppd_pop_stack(_ppd_ps_stack_t *st) // I - Stack
{
if (st->num_objs > 0)
{
}
-/*
- * 'ppd_push_stack()' - Push an object on the stack.
- */
+//
+// 'ppd_push_stack()' - Push an object on the stack.
+//
-static _ppd_ps_obj_t * /* O - New object */
-ppd_push_stack(_ppd_ps_stack_t *st, /* I - Stack */
- _ppd_ps_obj_t *obj) /* I - Object */
+static _ppd_ps_obj_t * // O - New object
+ppd_push_stack(_ppd_ps_stack_t *st, // I - Stack
+ _ppd_ps_obj_t *obj) // I - Object
{
- _ppd_ps_obj_t *temp; /* New object */
+ _ppd_ps_obj_t *temp; // New object
if (st->num_objs >= st->alloc_objs)
{
-
-
st->alloc_objs += 32;
if ((temp = realloc(st->objs, (size_t)st->alloc_objs *
}
-/*
- * 'ppd_roll_stack()' - Rotate stack objects.
- */
+//
+// 'ppd_roll_stack()' - Rotate stack objects.
+//
-static int /* O - 0 on success, -1 on error */
-ppd_roll_stack(_ppd_ps_stack_t *st, /* I - Stack */
- int c, /* I - Number of objects */
- int s) /* I - Amount to shift */
+static int // O - 0 on success, -1 on error
+ppd_roll_stack(_ppd_ps_stack_t *st, // I - Stack
+ int c, // I - Number of objects
+ int s) // I - Amount to shift
{
- _ppd_ps_obj_t *temp; /* Temporary array of objects */
- int n; /* Index into array */
+ _ppd_ps_obj_t *temp; // Temporary array of objects
+ int n; // Index into array
DEBUG_printf(("3roll_stack(st=%p, s=%d, c=%d)", st, s, c));
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (c < 0)
return (-1);
if (s == 0)
return (0);
- /*
- * Copy N objects and move things around...
- */
+ //
+ // Copy N objects and move things around...
+ //
if (s < 0)
{
- /*
- * Shift down...
- */
+ //
+ // Shift down...
+ //
s = -s;
return (-1);
memcpy(temp, st->objs + n, (size_t)s * sizeof(_ppd_ps_obj_t));
- memmove(st->objs + n, st->objs + n + s, (size_t)(c - s) * sizeof(_ppd_ps_obj_t));
+ memmove(st->objs + n, st->objs + n + s,
+ (size_t)(c - s) * sizeof(_ppd_ps_obj_t));
memcpy(st->objs + n + c - s, temp, (size_t)s * sizeof(_ppd_ps_obj_t));
}
else
{
- /*
- * Shift up...
- */
+ //
+ // Shift up...
+ //
if ((temp = calloc((size_t)s, sizeof(_ppd_ps_obj_t))) == NULL)
return (-1);
memcpy(temp, st->objs + n + c - s, (size_t)s * sizeof(_ppd_ps_obj_t));
- memmove(st->objs + n + s, st->objs + n, (size_t)(c - s) * sizeof(_ppd_ps_obj_t));
+ memmove(st->objs + n + s, st->objs + n,
+ (size_t)(c - s) * sizeof(_ppd_ps_obj_t));
memcpy(st->objs + n, temp, (size_t)s * sizeof(_ppd_ps_obj_t));
}
}
-/*
- * 'ppd_scan_ps()' - Scan a string for the next PS object.
- */
+//
+// 'ppd_scan_ps()' - Scan a string for the next PS object.
+//
-static _ppd_ps_obj_t * /* O - New object or NULL on EOF */
-ppd_scan_ps(_ppd_ps_stack_t *st, /* I - Stack */
- char **ptr) /* IO - String pointer */
+static _ppd_ps_obj_t * // O - New object or NULL on EOF
+ppd_scan_ps(_ppd_ps_stack_t *st, // I - Stack
+ char **ptr) // IO - String pointer
{
- _ppd_ps_obj_t obj; /* Current object */
- char *start, /* Start of object */
- *cur, /* Current position */
- *valptr, /* Pointer into value string */
- *valend; /* End of value string */
- int parens; /* Parenthesis nesting level */
+ _ppd_ps_obj_t obj; // Current object
+ char *start, // Start of object
+ *cur, // Current position
+ *valptr, // Pointer into value string
+ *valend; // End of value string
+ int parens; // Parenthesis nesting level
- /*
- * Skip leading whitespace...
- */
+ //
+ // Skip leading whitespace...
+ //
for (cur = *ptr; *cur; cur ++)
{
if (*cur == '%')
{
- /*
- * Comment, skip to end of line...
- */
+ //
+ // Comment, skip to end of line...
+ //
for (cur ++; *cur && *cur != '\n' && *cur != '\r'; cur ++);
return (NULL);
}
- /*
- * See what we have...
- */
+ //
+ // See what we have...
+ //
memset(&obj, 0, sizeof(obj));
switch (*cur)
{
- case '(' : /* (string) */
+ case '(' : // (string)
obj.type = PPD_PS_STRING;
start = cur;
if (*cur == '\\')
{
- /*
- * Decode escaped character...
- */
+ //
+ // Decode escaped character...
+ //
cur ++;
cur ++;
break;
- case '[' : /* Start array */
+ case '[' : // Start array
obj.type = PPD_PS_START_ARRAY;
cur ++;
break;
- case ']' : /* End array */
+ case ']' : // End array
obj.type = PPD_PS_END_ARRAY;
cur ++;
break;
- case '<' : /* Start dictionary or hex string */
+ case '<' : // Start dictionary or hex string
if (cur[1] == '<')
{
obj.type = PPD_PS_START_DICT;
*cur;
cur ++)
{
- int ch; /* Current character */
-
-
+ int ch; // Current character
if (*cur == '>')
break;
}
break;
- case '>' : /* End dictionary? */
+ case '>' : // End dictionary?
if (cur[1] == '>')
{
obj.type = PPD_PS_END_DICT;
}
break;
- case '{' : /* Start procedure */
+ case '{' : // Start procedure
obj.type = PPD_PS_START_PROC;
cur ++;
break;
- case '}' : /* End procedure */
+ case '}' : // End procedure
obj.type = PPD_PS_END_PROC;
cur ++;
break;
- case '-' : /* Possible number */
+ case '-' : // Possible number
case '+' :
if (!isdigit(cur[1] & 255) && cur[1] != '.')
{
break;
}
- case '0' : /* Number */
+ case '0' : // Number
case '1' :
case '2' :
case '3' :
if (*cur == '#')
{
- /*
- * Integer with radix...
- */
+ //
+ // Integer with radix...
+ //
obj.value.number = strtol(cur + 1, &cur, atoi(start));
break;
}
else if (strchr(".Ee()<>[]{}/%", *cur) || isspace(*cur & 255))
{
- /*
- * Integer or real number...
- */
+ //
+ // Integer or real number...
+ //
obj.value.number = _ppdStrScand(start, &cur, localeconv());
break;
else
cur = start;
- default : /* Operator/variable name */
+ default : // Operator/variable name
start = cur;
if (*cur == '/')
break;
}
- /*
- * Save the current position in the string and return the new object...
- */
+ //
+ // Save the current position in the string and return the new object...
+ //
*ptr = cur;
}
-/*
- * 'ppd_setpagedevice()' - Simulate the PostScript setpagedevice operator.
- */
+//
+// 'ppd_setpagedevice()' - Simulate the PostScript setpagedevice operator.
+//
-static int /* O - 0 on success, -1 on error */
+static int // O - 0 on success, -1 on error
ppd_setpagedevice(
- _ppd_ps_stack_t *st, /* I - Stack */
- cups_page_header2_t *h, /* O - Page header */
- int *preferred_bits)/* O - Preferred bits per color */
+ _ppd_ps_stack_t *st, // I - Stack
+ cups_page_header2_t *h, // O - Page header
+ int *preferred_bits)// O - Preferred bits per color
{
- int i; /* Index into array */
- _ppd_ps_obj_t *obj, /* Current object */
- *end; /* End of dictionary */
- const char *name; /* Attribute name */
+ int i; // Index into array
+ _ppd_ps_obj_t *obj, // Current object
+ *end; // End of dictionary
+ const char *name; // Attribute name
- /*
- * Make sure we have a dictionary on the stack...
- */
+ //
+ // Make sure we have a dictionary on the stack...
+ //
if (st->num_objs == 0)
return (-1);
if (obj < st->objs)
return (-1);
- /*
- * Found the start of the dictionary, empty the stack to this point...
- */
+ //
+ // Found the start of the dictionary, empty the stack to this point...
+ //
st->num_objs = (int)(obj - st->objs);
- /*
- * Now pull /name and value pairs from the dictionary...
- */
+ //
+ // Now pull /name and value pairs from the dictionary...
+ //
DEBUG_puts("3ppd_setpagedevice: Dictionary:");
for (obj ++; obj < end; obj ++)
{
- /*
- * Grab the name...
- */
+ //
+ // Grab the name...
+ //
if (obj->type != PPD_PS_NAME)
return (-1);
#ifdef DEBUG
DEBUG_printf(("4ppd_setpagedevice: /%s ", name));
ppd_DEBUG_object("setpagedevice", obj);
-#endif /* DEBUG */
+#endif // DEBUG
- /*
- * Then grab the value...
- */
+ //
+ // Then grab the value...
+ //
if (!strcmp(name, "MediaClass") && obj->type == PPD_PS_STRING)
strlcpy(h->MediaClass, obj->value.string, sizeof(h->MediaClass));
else if ((!strcmp(name, "cupsMediaPosition") ||
!strcmp(name, "MediaPosition")) && obj->type == PPD_PS_NUMBER)
{
- /*
- * cupsMediaPosition is supported for backwards compatibility only.
- * We added it back in the Ghostscript 5.50 days to work around a
- * bug in Ghostscript WRT handling of MediaPosition and setpagedevice.
- *
- * All new development should set MediaPosition...
- */
+ //
+ // cupsMediaPosition is supported for backwards compatibility only.
+ // We added it back in the Ghostscript 5.50 days to work around a
+ // bug in Ghostscript WRT handling of MediaPosition and setpagedevice.
+ //
+ // All new development should set MediaPosition...
+ //
h->MediaPosition = (unsigned)obj->value.number;
}
sizeof(h->cupsRenderingIntent));
else
{
- /*
- * Ignore unknown name+value...
- */
+ //
+ // Ignore unknown name+value...
+ //
- DEBUG_printf(("4ppd_setpagedevice: Unknown name (\"%s\") or value...\n", name));
+ DEBUG_printf(("4ppd_setpagedevice: Unknown name (\"%s\") or value...\n",
+ name));
while (obj[1].type != PPD_PS_NAME && obj < end)
obj ++;
#ifdef DEBUG
-/*
- * 'ppd_DEBUG_object()' - Print an object's value...
- */
+//
+// 'ppd_DEBUG_object()' - Print an object's value...
+//
static void
-ppd_DEBUG_object(const char *prefix, /* I - Prefix string */
- _ppd_ps_obj_t *obj) /* I - Object to print */
+ppd_DEBUG_object(const char *prefix, // I - Prefix string
+ _ppd_ps_obj_t *obj) // I - Object to print
{
switch (obj->type)
{
}
-/*
- * 'ppd_DEBUG_stack()' - Print a stack...
- */
+//
+// 'ppd_DEBUG_stack()' - Print a stack...
+//
static void
-ppd_DEBUG_stack(const char *prefix, /* I - Prefix string */
- _ppd_ps_stack_t *st) /* I - Stack */
+ppd_DEBUG_stack(const char *prefix, // I - Prefix string
+ _ppd_ps_stack_t *st) // I - Stack
{
- int c; /* Looping var */
- _ppd_ps_obj_t *obj; /* Current object on stack */
+ int c; // Looping var
+ _ppd_ps_obj_t *obj; // Current object on stack
for (obj = st->objs, c = st->num_objs; c > 0; c --, obj ++)
ppd_DEBUG_object(prefix, obj);
}
-#endif /* DEBUG */
+#endif // DEBUG
-/*
- * Private image library definitions for libppd.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1993-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private image library definitions for libppd.
+//
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1993-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+
#ifndef _PPD_RASTER_PRIVATE_H_
# define _PPD_RASTER_PRIVATE_H_
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
# include <cups/raster.h>
# include "debug-private.h"
# include "string-private.h"
# ifdef _WIN32
# include <io.h>
-# include <winsock2.h> /* for htonl() definition */
+# include <winsock2.h> // for htonl() definition
# else
# include <unistd.h>
# include <fcntl.h>
-# endif /* _WIN32 */
+# endif // _WIN32
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
extern void _ppdRasterAddError(const char *f, ...);
extern void _ppdRasterClearError(void);
# ifdef __cplusplus
}
-# endif /* __cplusplus */
+# endif // __cplusplus
-#endif /* !_PPD_RASTER_PRIVATE_H_ */
+#endif // !_PPD_RASTER_PRIVATE_H_
-/*
- * Include necessary headers...
- */
+//
+// Raster file to PostScript filter function for libppd.
+//
+// Copyright © 2020 by Till Kamppeter
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1993-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include <cupsfilters/colormanager.h>
#include <cupsfilters/filter.h>
#include "debug-internal.h"
#include <zlib.h>
-/*
- * Types...
- */
-typedef struct rastertops_doc_s { /**** Document information ****/
- cups_file_t *inputfp; /* Temporary file, if any */
- FILE *outputfp; /* Temporary file, if any */
- cf_logfunc_t logfunc; /* Logging function, NULL for no
- logging */
- void *logdata; /* User data for logging function, can
- be NULL */
- cf_filter_iscanceledfunc_t iscanceledfunc; /* Function returning 1 when
- job is canceled, NULL for not
- supporting stop on cancel */
- void *iscanceleddata; /* User data for is-canceled
- function, can be NULL */
+//
+// Types...
+//
+
+typedef struct rastertops_doc_s // **** Document information ****
+{
+ cups_file_t *inputfp; // Temporary file, if any
+ FILE *outputfp; // Temporary file, if any
+ cf_logfunc_t logfunc; // Logging function, NULL for no
+ // logging
+ void *logdata; // User data for logging function, can
+ // be NULL
+ cf_filter_iscanceledfunc_t iscanceledfunc; // Function returning 1 when
+ // job is canceled, NULL for not
+ // supporting stop on cancel
+ void *iscanceleddata; // User data for is-canceled
+ // function, can be NULL
} rastertops_doc_t;
-/*
- * 'write_prolog()' - Writing the PostScript prolog for the file
- */
+//
+// 'write_prolog()' - Writing the PostScript prolog for the file
+//
static void
-write_prolog(int width, /* I - width of the image in points */
- int height, /* I - height of the image in points */
- rastertops_doc_t *doc) /* I - Document information */
+write_prolog(int width, // I - width of the image in points
+ int height, // I - height of the image in points
+ rastertops_doc_t *doc) // I - Document information
{
- /* Document header... */
+ // Document header...
fprintf(doc->outputfp, "%%!PS-Adobe-3.0\n");
fprintf(doc->outputfp, "%%%%BoundingBox: %d %d %d %d\n", 0, 0, width, height);
fprintf(doc->outputfp, "%%%%Creator: cups-filters\n");
fprintf(doc->outputfp, "%%%%EndProlog\n");
}
-/*
- * 'write_start_page()' - Write the basic page setup
- */
+
+//
+// 'write_start_page()' - Write the basic page setup
+//
static void
-write_start_page(int page, /* I - Page to write */
- int width, /* I - Page width in points */
- int length, /* I - Page length in points */
- rastertops_doc_t *doc) /* I - Document information */
+write_start_page(int page, // I - Page to write
+ int width, // I - Page width in points
+ int length, // I - Page length in points
+ rastertops_doc_t *doc) // I - Document information
{
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_CONTROL,
"PAGE: %d %d", page, 1);
fprintf(doc->outputfp, "%%%%EndPageSetup\n");
}
-/*
- * 'find_bits()' - Finding the number of bits per color
- */
-static int /* O - Exit status */
-find_bits(cups_cspace_t mode, /* I - Color space of data */
- int bpc) /* I - Original bits per color of data */
+//
+// 'find_bits()' - Finding the number of bits per color
+//
+
+static int // O - Exit status
+find_bits(cups_cspace_t mode, // I - Color space of data
+ int bpc) // I - Original bits per color of data
{
if (bpc == 1 &&
(mode == CUPS_CSPACE_RGB ||
mode == CUPS_CSPACE_ADOBERGB ||
mode == CUPS_CSPACE_SRGB ||
mode == CUPS_CSPACE_CMY))
- return 8;
+ return (8);
if (bpc == 16)
- return 8;
+ return (8);
- return bpc;
+ return (bpc);
}
-/*
- * 'write_image()' - Write the information regarding the image
- */
+
+//
+// 'write_image()' - Write the information regarding the image
+//
static void
-write_image(int pagewidth, /* I - width of page in points */
- int pageheight, /* I - height of page in points */
- int bpc, /* I - bits per color */
- int pixwidth, /* I - width of image in pixels */
- int pixheight, /* I - height of image in pixels */
- cups_cspace_t mode, /* I - color model of image */
- rastertops_doc_t *doc) /* I - Document information */
+write_image(int pagewidth, // I - width of page in points
+ int pageheight, // I - height of page in points
+ int bpc, // I - bits per color
+ int pixwidth, // I - width of image in pixels
+ int pixheight, // I - height of image in pixels
+ cups_cspace_t mode, // I - color model of image
+ rastertops_doc_t *doc) // I - Document information
{
fprintf(doc->outputfp, "gsave\n");
switch (mode)
{
- case CUPS_CSPACE_RGB:
- case CUPS_CSPACE_CMY:
- case CUPS_CSPACE_SRGB:
- case CUPS_CSPACE_ADOBERGB:
- fprintf(doc->outputfp, "/DeviceRGB setcolorspace\n");
- break;
-
- case CUPS_CSPACE_CMYK:
- fprintf(doc->outputfp, "/DeviceCMYK setcolorspace\n");
- break;
-
- default:
- case CUPS_CSPACE_K:
- case CUPS_CSPACE_W:
- case CUPS_CSPACE_SW:
- fprintf(doc->outputfp, "/DeviceGray setcolorspace\n");
- break;
+ case CUPS_CSPACE_RGB:
+ case CUPS_CSPACE_CMY:
+ case CUPS_CSPACE_SRGB:
+ case CUPS_CSPACE_ADOBERGB:
+ fprintf(doc->outputfp, "/DeviceRGB setcolorspace\n");
+ break;
+
+ case CUPS_CSPACE_CMYK:
+ fprintf(doc->outputfp, "/DeviceCMYK setcolorspace\n");
+ break;
+
+ default:
+ case CUPS_CSPACE_K:
+ case CUPS_CSPACE_W:
+ case CUPS_CSPACE_SW:
+ fprintf(doc->outputfp, "/DeviceGray setcolorspace\n");
+ break;
}
if (bpc == 16)
switch (mode)
{
- case CUPS_CSPACE_RGB:
- case CUPS_CSPACE_CMY:
- case CUPS_CSPACE_SRGB:
- case CUPS_CSPACE_ADOBERGB:
- fprintf(doc->outputfp, "/Decode [0 1 0 1 0 1]\n");
- break;
+ case CUPS_CSPACE_RGB:
+ case CUPS_CSPACE_CMY:
+ case CUPS_CSPACE_SRGB:
+ case CUPS_CSPACE_ADOBERGB:
+ fprintf(doc->outputfp, "/Decode [0 1 0 1 0 1]\n");
+ break;
- case CUPS_CSPACE_CMYK:
- fprintf(doc->outputfp, "/Decode [0 1 0 1 0 1 0 1]\n");
- break;
+ case CUPS_CSPACE_CMYK:
+ fprintf(doc->outputfp, "/Decode [0 1 0 1 0 1 0 1]\n");
+ break;
- case CUPS_CSPACE_SW:
- fprintf(doc->outputfp, "/Decode [0 1]\n");
+ case CUPS_CSPACE_SW:
+ fprintf(doc->outputfp, "/Decode [0 1]\n");
break;
- default:
- case CUPS_CSPACE_K:
- case CUPS_CSPACE_W:
- fprintf(doc->outputfp, "/Decode [1 0]\n");
- break;
+ default:
+ case CUPS_CSPACE_K:
+ case CUPS_CSPACE_W:
+ fprintf(doc->outputfp, "/Decode [1 0]\n");
+ break;
}
- if(bpc==16)
+ if (bpc == 16)
fprintf(doc->outputfp,
"/DataSource {3 string 0 1 2 {1 index exch Input read {pop}"
- "if Input read pop put } for} bind\n");
+ "if Input read pop put } for} bind\n");
else
fprintf(doc->outputfp, "/DataSource currentfile /FlateDecode filter\n");
fprintf(doc->outputfp, "/ImageMatrix [%d 0 0 %d 0 %d]\n", pixwidth,
- -1*pixheight, pixheight);
+ -1 * pixheight, pixheight);
fprintf(doc->outputfp, ">> image\n");
}
-/*
- * 'convert_pixels()'- Convert 1 bpc to 8 bpc
- */
+
+//
+// 'convert_pixels()'- Convert 1 bpc to 8 bpc
+//
static void
-convert_pixels(unsigned char *pixdata, /* I - Original pixel data */
- unsigned char *convertedpix, /* I - Buffer for converted data */
- int width) /* I - Width of data */
+convert_pixels(unsigned char *pixdata, // I - Original pixel data
+ unsigned char *convertedpix, // I - Buffer for converted data
+ int width) // I - Width of data
{
- int j, k = 0; /* Variables for iteration */
- unsigned int mask; /* Variable for per byte iteration */
- unsigned char temp; /* temporary character */
+ int j, k = 0; // Variables for iteration
+ unsigned int mask; // Variable for per byte iteration
+ unsigned char temp; // temporary character
for(j = 0; j < width; ++j)
{
}
}
-/*
- * 'write_flate()' - Write the image data in flate encoded format
- */
-static int /* O - Error value */
-write_flate(cups_raster_t *ras, /* I - Image data */
- cups_page_header2_t header, /* I - Bytes Per Line */
- rastertops_doc_t *doc) /* I - Document information */
+//
+// 'write_flate()' - Write the image data in flate encoded format
+//
+
+static int // O - Error value
+write_flate(cups_raster_t *ras, // I - Image data
+ cups_page_header2_t header, // I - Bytes Per Line
+ rastertops_doc_t *doc) // I - Document information
{
- int ret, /* Return value of this
- function */
- flush, /* Check the end of image
- data */
- curr_line=1, /* Maitining the working
- line of pixels */
+ int ret, // Return value of this
+ // function
+ flush, // Check the end of image
+ // data
+ curr_line=1, // Maitining the working
+ // line of pixels
alloc,
flag = 0;
- unsigned have; /* Bytes available in
- output buffer */
- z_stream strm; /* Structure required
- by deflate */
+ unsigned have; // Bytes available in
+ // output buffer
+ z_stream strm; // Structure required
+ // by deflate
unsigned char *pixdata,
*convertedpix;
- unsigned char in[header.cupsBytesPerLine * 6], /* Input data buffer */
- out[header.cupsBytesPerLine * 6]; /* Output data buffer */
+ unsigned char in[header.cupsBytesPerLine * 6], // Input data buffer
+ out[header.cupsBytesPerLine * 6]; // Output data buffer
- /* allocate deflate state */
+ // allocate deflate state
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, -1);
if (ret != Z_OK)
- return ret;
+ return (ret);
- if(header.cupsBitsPerColor == 1 &&
- (header.cupsColorSpace == CUPS_CSPACE_RGB ||
- header.cupsColorSpace == CUPS_CSPACE_ADOBERGB ||
- header.cupsColorSpace == CUPS_CSPACE_SRGB))
+ if (header.cupsBitsPerColor == 1 &&
+ (header.cupsColorSpace == CUPS_CSPACE_RGB ||
+ header.cupsColorSpace == CUPS_CSPACE_ADOBERGB ||
+ header.cupsColorSpace == CUPS_CSPACE_SRGB))
flag = 1;
- /* compress until end of file */
- do {
+ // compress until end of file
+ do
+ {
pixdata = malloc(header.cupsBytesPerLine);
cupsRasterReadPixels(ras, pixdata, header.cupsBytesPerLine);
if (flag)
strm.avail_in = alloc;
strm.next_in = in;
- /* run deflate() on input until output buffer not full, finish
- * compression if all of source has been read in */
- do {
+ // run deflate() on input until output buffer not full, finish
+ // compression if all of source has been read in
+ do
+ {
strm.avail_out = alloc;
strm.next_out = out;
- /* Run the deflate algorithm on the data */
+ // Run the deflate algorithm on the data
ret = deflate(&strm, flush);
- /* check whether state is not clobbered */
+ // check whether state is not clobbered
DEBUG_assert(ret != Z_STREAM_ERROR);
have = alloc - strm.avail_out;
if (fwrite(out, 1, have, doc->outputfp) != have)
(void)deflateEnd(&strm);
if (convertedpix != NULL)
free(convertedpix);
- return Z_ERRNO;
+ return (Z_ERRNO);
}
- } while (strm.avail_out == 0);
+ }
+ while (strm.avail_out == 0);
- /* all input will be used */
+ // all input will be used
DEBUG_assert(strm.avail_in == 0);
- /* done when last data in file processed */
+ // done when last data in file processed
free(pixdata);
free(convertedpix);
- } while (flush != Z_FINISH);
+ }
+ while (flush != Z_FINISH);
- /* stream will be complete */
+ // stream will be complete
DEBUG_assert(ret == Z_STREAM_END);
- /* clean up and return */
+ // clean up and return
(void)deflateEnd(&strm);
- return Z_OK;
+ return (Z_OK);
}
-/*
- * 'z_error()' - Report a zlib or i/o error
- */
+//
+// 'z_error()' - Report a zlib or i/o error
+//
static void
-z_error(int ret, /* I - Return status of deflate */
- rastertops_doc_t *doc) /* I - Document information */
+z_error(int ret, // I - Return status of deflate
+ rastertops_doc_t *doc) // I - Document information
{
- switch (ret) {
- case Z_ERRNO:
- if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "ppdFilterRasterToPS: zpipe - error in source data or output file");
- break;
- case Z_STREAM_ERROR:
- if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "ppdFilterRasterToPS: zpipe - invalid compression level");
- break;
- case Z_DATA_ERROR:
- if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "ppdFilterRasterToPS: zpipe - invalid or incomplete deflate data");
- break;
- case Z_MEM_ERROR:
- if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "ppdFilterRasterToPS: zpipe - out of memory");
- break;
- case Z_VERSION_ERROR:
- if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "ppdFilterRasterToPS: zpipe - zlib version mismatch!");
+ switch (ret)
+ {
+ case Z_ERRNO:
+ if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
+ "ppdFilterRasterToPS: zpipe - error in source data or output file");
+ break;
+ case Z_STREAM_ERROR:
+ if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
+ "ppdFilterRasterToPS: zpipe - invalid compression level");
+ break;
+ case Z_DATA_ERROR:
+ if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
+ "ppdFilterRasterToPS: zpipe - invalid or incomplete deflate data");
+ break;
+ case Z_MEM_ERROR:
+ if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
+ "ppdFilterRasterToPS: zpipe - out of memory");
+ break;
+ case Z_VERSION_ERROR:
+ if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
+ "ppdFilterRasterToPS: zpipe - zlib version mismatch!");
}
}
-/*
- * 'write_end_page()' - Show the current page.
- */
+
+//
+// 'write_end_page()' - Show the current page.
+//
static void
-write_end_page(rastertops_doc_t *doc) /* I - Document information */
+write_end_page(rastertops_doc_t *doc) // I - Document information
{
fprintf(doc->outputfp, "\ngrestore\n");
fprintf(doc->outputfp, "showpage\n");
fprintf(doc->outputfp, "%%%%PageTrailer\n");
}
-/*
- * 'write_trailer()' - Write the PostScript trailer.
- */
+//
+// 'write_trailer()' - Write the PostScript trailer.
+//
static void
-write_trailer(int pages, /* I - Number of pages */
- rastertops_doc_t *doc) /* I - Document information */
+write_trailer(int pages, // I - Number of pages
+ rastertops_doc_t *doc) // I - Document information
{
fprintf(doc->outputfp, "%%%%Trailer\n");
fprintf(doc->outputfp, "%%%%Pages: %d\n", pages);
fprintf(doc->outputfp, "%%%%EOF\n");
}
-/*
- * 'ppdFilterRasterToPS()' - Filter function to convert PWG raster input
- * to PostScript
- */
-
-int /* O - Error status */
-ppdFilterRasterToPS(int inputfd, /* I - File descriptor input stream */
- int outputfd, /* I - File descriptor output stream */
- int inputseekable, /* I - Is input stream seekable? (unused) */
- cf_filter_data_t *data, /* I - Job and printer data */
- void *parameters) /* I - Filter-specific parameters (unused) */
+//
+// 'ppdFilterRasterToPS()' - Filter function to convert PWG raster input
+// to PostScript
+//
+
+int // O - Error status
+ppdFilterRasterToPS(int inputfd, // I - File descriptor input stream
+ int outputfd, // I - File descriptor output stream
+ int inputseekable, // I - Is input stream seekable?
+ // (unused)
+ cf_filter_data_t *data, // I - Job and printer data
+ void *parameters) // I - Filter-specific parameters
+ // (unused)
{
- rastertops_doc_t doc; /* Document information */
- cups_file_t *inputfp; /* Print file */
- FILE *outputfp; /* Output data stream */
- cups_raster_t *ras; /* Raster stream for printing */
- cups_page_header2_t header; /* Page header from file */
- int empty, /* Is the input empty? */
- Page = 0, /* variable for counting the pages */
- ret; /* Return value of deflate compression */
- cf_logfunc_t log = data->logfunc;
+ rastertops_doc_t doc; // Document information
+ cups_file_t *inputfp; // Print file
+ FILE *outputfp; // Output data stream
+ cups_raster_t *ras; // Raster stream for printing
+ cups_page_header2_t header; // Page header from file
+ int empty, // Is the input empty?
+ Page = 0, // variable for counting the pages
+ ret; // Return value of deflate compression
+ cf_logfunc_t log = data->logfunc;
void *ld = data->logdata;
cf_filter_iscanceledfunc_t iscanceled = data->iscanceledfunc;
void *icd = data->iscanceleddata;
(void)inputseekable;
(void)parameters;
- /*
- * Open the input data stream specified by the inputfd...
- */
+ //
+ // Open the input data stream specified by the inputfd...
+ //
if ((inputfp = cupsFileOpenFd(inputfd, "r")) == NULL)
{
return (1);
}
- /*
- * Open the output data stream specified by the outputfd...
- */
+ //
+ // Open the output data stream specified by the outputfd...
+ //
if ((outputfp = fdopen(outputfd, "w")) == NULL)
{
doc.inputfp = inputfp;
doc.outputfp = outputfp;
- /* Logging function */
+ // Logging function
doc.logfunc = log;
doc.logdata = ld;
- /* Job-is-canceled function */
+ // Job-is-canceled function
doc.iscanceledfunc = iscanceled;
doc.iscanceleddata = icd;
ras = cupsRasterOpen(inputfd, CUPS_RASTER_READ);
- /*
- * Process pages as needed...
- */
+ //
+ // Process pages as needed...
+ //
+
Page = 0;
empty = 1;
break;
}
- /*
- * Write the prolog for PS only once
- */
+ //
+ // Write the prolog for PS only once
+ //
if (empty)
{
write_prolog(header.PageSize[0], header.PageSize[1], &doc);
}
- /*
- * Write a status message with the page number and number of copies.
- */
+ //
+ // Write a status message with the page number and number of copies.
+ //
Page ++;
if (log) log(ld, CF_LOGLEVEL_INFO,
"ppdFilterRasterToPS: Starting page %d.", Page);
- /*
- * Write the starting of the page
- */
+ //
+ // Write the starting of the page
+ //
+
write_start_page(Page, header.PageSize[0], header.PageSize[1], &doc);
- /*
- * write the information regarding the image
- */
+ //
+ // Write the information regarding the image
+ //
+
write_image(header.PageSize[0], header.PageSize[1],
- header.cupsBitsPerColor,
- header.cupsWidth, header.cupsHeight,
- header.cupsColorSpace, &doc);
+ header.cupsBitsPerColor,
+ header.cupsWidth, header.cupsHeight,
+ header.cupsColorSpace, &doc);
- /* Write the compressed image data*/
+ // Write the compressed image data
ret = write_flate(ras, header, &doc);
if (ret != Z_OK)
z_error(ret, &doc);
if (empty)
{
- if (log) log(ld, CF_LOGLEVEL_DEBUG,
- "ppdFilterRasterToPS: Input is empty, outputting empty file.");
- cupsRasterClose(ras);
- return 0;
+ if (log) log(ld, CF_LOGLEVEL_DEBUG,
+ "ppdFilterRasterToPS: Input is empty, outputting empty file.");
+ cupsRasterClose(ras);
+ return (0);
}
write_trailer(Page, &doc);
fclose(outputfp);
close(outputfd);
- return 0;
+ return (0);
}
-/*
- * snprintf functions for libppd.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// snprintf functions for libppd.
+//
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "string-private.h"
#ifndef HAVE_VSNPRINTF
-/*
- * '_ppd_vsnprintf()' - Format a string into a fixed size buffer.
- */
-
-int /* O - Number of bytes formatted */
-_ppd_vsnprintf(char *buffer, /* O - Output buffer */
- size_t bufsize, /* O - Size of output buffer */
- const char *format, /* I - printf-style format string */
- va_list ap) /* I - Pointer to additional arguments */
+//
+// '_ppd_vsnprintf()' - Format a string into a fixed size buffer.
+//
+
+int // O - Number of bytes formatted
+_ppd_vsnprintf(char *buffer, // O - Output buffer
+ size_t bufsize, // O - Size of output buffer
+ const char *format, // I - printf-style format string
+ va_list ap) // I - Pointer to additional arguments
{
- char *bufptr, /* Pointer to position in buffer */
- *bufend, /* Pointer to end of buffer */
- sign, /* Sign of format width */
- type; /* Format type character */
- int width, /* Width of field */
- prec; /* Number of characters of precision */
- char tformat[100], /* Temporary format string for sprintf() */
- *tptr, /* Pointer into temporary format */
- temp[1024]; /* Buffer for formatted numbers */
- size_t templen; /* Length of "temp" */
- char *s; /* Pointer to string */
- int slen; /* Length of string */
- int bytes; /* Total number of bytes needed */
-
-
- /*
- * Loop through the format string, formatting as needed...
- */
+ char *bufptr, // Pointer to position in buffer
+ *bufend, // Pointer to end of buffer
+ sign, // Sign of format width
+ type; // Format type character
+ int width, // Width of field
+ prec; // Number of characters of precision
+ char tformat[100], // Temporary format string for sprintf()
+ *tptr, // Pointer into temporary format
+ temp[1024]; // Buffer for formatted numbers
+ size_t templen; // Length of "temp"
+ char *s; // Pointer to string
+ int slen; // Length of string
+ int bytes; // Total number of bytes needed
+
+
+ //
+ // Loop through the format string, formatting as needed...
+ //
bufptr = buffer;
bufend = buffer + bufsize - 1;
if (*format == '*')
{
- /*
- * Get width from argument...
- */
+ //
+ // Get width from argument...
+ //
format ++;
width = va_arg(ap, int);
if (*format == '*')
{
- /*
- * Get precision from argument...
- */
+ //
+ // Get precision from argument...
+ //
format ++;
prec = va_arg(ap, int);
switch (type)
{
- case 'E' : /* Floating point formats */
+ case 'E' : // Floating point formats
case 'G' :
case 'e' :
case 'f' :
}
break;
- case 'B' : /* Integer formats */
+ case 'B' : // Integer formats
case 'X' :
case 'b' :
case 'd' :
}
break;
- case 'p' : /* Pointer value */
+ case 'p' : // Pointer value
if ((width + 2) > sizeof(temp))
break;
}
break;
- case 'c' : /* Character or character array */
+ case 'c' : // Character or character array
bytes += width;
if (bufptr)
}
break;
- case 's' : /* String */
+ case 's' : // String
if ((s = va_arg(ap, char *)) == NULL)
s = "(null)";
}
break;
- case 'n' : /* Output number of chars so far */
+ case 'n' : // Output number of chars so far
*(va_arg(ap, int *)) = bytes;
break;
}
}
}
- /*
- * Nul-terminate the string and return the number of characters needed.
- */
+ //
+ // Nul-terminate the string and return the number of characters needed.
+ //
*bufptr = '\0';
return (bytes);
}
-#endif /* !HAVE_VSNPRINT */
+#endif // !HAVE_VSNPRINT
#ifndef HAVE_SNPRINTF
-/*
- * '_ppd_snprintf()' - Format a string into a fixed size buffer.
- */
-
-int /* O - Number of bytes formatted */
-_ppd_snprintf(char *buffer, /* O - Output buffer */
- size_t bufsize, /* O - Size of output buffer */
- const char *format, /* I - printf-style format string */
- ...) /* I - Additional arguments as needed */
+//
+// '_ppd_snprintf()' - Format a string into a fixed size buffer.
+//
+
+int // O - Number of bytes formatted
+_ppd_snprintf(char *buffer, // O - Output buffer
+ size_t bufsize, // O - Size of output buffer
+ const char *format, // I - printf-style format string
+ ...) // I - Additional arguments as needed
{
- int bytes; /* Number of bytes formatted */
- va_list ap; /* Pointer to additional arguments */
+ int bytes; // Number of bytes formatted
+ va_list ap; // Pointer to additional arguments
va_start(ap, format);
return (bytes);
}
-#endif /* !HAVE_SNPRINTF */
+#endif // !HAVE_SNPRINTF
-/*
- * Private string definitions for libppd.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private string definitions for libppd.
+//
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _PPD_STRING_PRIVATE_H_
# define _PPD_STRING_PRIVATE_H_
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
# include "config.h"
# include <stdio.h>
# ifdef HAVE_STRING_H
# include <string.h>
-# endif /* HAVE_STRING_H */
+# endif // HAVE_STRING_H
# ifdef HAVE_STRINGS_H
# include <strings.h>
-# endif /* HAVE_STRINGS_H */
+# endif // HAVE_STRINGS_H
# ifdef HAVE_BSTRING_H
# include <bstring.h>
-# endif /* HAVE_BSTRING_H */
+# endif // HAVE_BSTRING_H
# if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
# define __CUPS_SSIZE_T_DEFINED
# include <stddef.h>
-/* Windows does not support the ssize_t type, so map it to long... */
-typedef long ssize_t; /* @private@ */
-# endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */
+// Windows does not support the ssize_t type, so map it to long...
+typedef long ssize_t; // @private@
+# endif // _WIN32 && !__CUPS_SSIZE_T_DEFINED
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * String pool structures...
- */
+//
+// String pool structures...
+//
# define _PPD_STR_GUARD 0x56788765
-typedef struct _ppd_sp_item_s /**** String Pool Item ****/
+typedef struct _ppd_sp_item_s // **** String Pool Item ****
{
# ifdef DEBUG_GUARDS
- unsigned int guard; /* Guard word */
-# endif /* DEBUG_GUARDS */
- unsigned int ref_count; /* Reference count */
- char str[1]; /* String */
+ unsigned int guard; // Guard word
+# endif // DEBUG_GUARDS
+ unsigned int ref_count; // Reference count
+ char str[1]; // String
} _ppd_sp_item_t;
-/*
- * Replacements for the ctype macros that are not affected by locale, since we
- * really only care about testing for ASCII characters when parsing files, etc.
- *
- * The _PPD_INLINE definition controls whether we get an inline function body,
- * and external function body, or an external definition.
- */
+//
+// Replacements for the ctype macros that are not affected by locale, since we
+// really only care about testing for ASCII characters when parsing files, etc.
+//
+// The _PPD_INLINE definition controls whether we get an inline function body,
+// and external function body, or an external definition.
+//
# if defined(__GNUC__) || __STDC_VERSION__ >= 199901L
# define _PPD_INLINE static inline
# define _PPD_INLINE static __inline
# elif defined(_PPD_STRING_C_)
# define _PPD_INLINE
-# endif /* __GNUC__ || __STDC_VERSION__ */
+# endif // __GNUC__ || __STDC_VERSION__
# ifdef _PPD_INLINE
-_PPD_INLINE int /* O - 1 on match, 0 otherwise */
-_ppd_isalnum(int ch) /* I - Character to test */
+_PPD_INLINE int // O - 1 on match, 0 otherwise
+_ppd_isalnum(int ch) // I - Character to test
{
return ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'Z') ||
(ch >= 'a' && ch <= 'z'));
}
-_PPD_INLINE int /* O - 1 on match, 0 otherwise */
-_ppd_isalpha(int ch) /* I - Character to test */
+_PPD_INLINE int // O - 1 on match, 0 otherwise
+_ppd_isalpha(int ch) // I - Character to test
{
return ((ch >= 'A' && ch <= 'Z') ||
(ch >= 'a' && ch <= 'z'));
}
-_PPD_INLINE int /* O - 1 on match, 0 otherwise */
-_ppd_islower(int ch) /* I - Character to test */
+_PPD_INLINE int // O - 1 on match, 0 otherwise
+_ppd_islower(int ch) // I - Character to test
{
return (ch >= 'a' && ch <= 'z');
}
-_PPD_INLINE int /* O - 1 on match, 0 otherwise */
-_ppd_isspace(int ch) /* I - Character to test */
+_PPD_INLINE int // O - 1 on match, 0 otherwise
+_ppd_isspace(int ch) // I - Character to test
{
return (ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch == '\t' ||
ch == '\v');
}
-_PPD_INLINE int /* O - 1 on match, 0 otherwise */
-_ppd_isupper(int ch) /* I - Character to test */
+_PPD_INLINE int // O - 1 on match, 0 otherwise
+_ppd_isupper(int ch) // I - Character to test
{
return (ch >= 'A' && ch <= 'Z');
}
-_PPD_INLINE int /* O - Converted character */
-_ppd_tolower(int ch) /* I - Character to convert */
+_PPD_INLINE int // O - Converted character
+_ppd_tolower(int ch) // I - Character to convert
{
return (_ppd_isupper(ch) ? ch - 'A' + 'a' : ch);
}
-_PPD_INLINE int /* O - Converted character */
-_ppd_toupper(int ch) /* I - Character to convert */
+_PPD_INLINE int // O - Converted character
+_ppd_toupper(int ch) // I - Character to convert
{
return (_ppd_islower(ch) ? ch - 'a' + 'A' : ch);
}
extern int _ppd_isupper(int ch);
extern int _ppd_tolower(int ch);
extern int _ppd_toupper(int ch);
-# endif /* _PPD_INLINE */
+# endif // _PPD_INLINE
-/*
- * Prototypes...
- */
+//
+// Prototypes...
+//
-extern ssize_t _ppd_safe_vsnprintf(char *buffer, size_t bufsize, const char *format, va_list args);
+extern ssize_t _ppd_safe_vsnprintf(char *buffer, size_t bufsize,
+ const char *format, va_list args);
extern void _ppd_strcpy(char *dst, const char *src);
# ifndef HAVE_STRDUP
extern char *_ppd_strdup(const char *);
# define strdup _ppd_strdup
-# endif /* !HAVE_STRDUP */
+# endif // !HAVE_STRDUP
extern int _ppd_strcasecmp(const char *, const char *);
# ifndef HAVE_STRLCAT
extern size_t _ppd_strlcat(char *, const char *, size_t);
# define strlcat _ppd_strlcat
-# endif /* !HAVE_STRLCAT */
+# endif // !HAVE_STRLCAT
# ifndef HAVE_STRLCPY
extern size_t _ppd_strlcpy(char *, const char *, size_t);
# define strlcpy _ppd_strlcpy
-# endif /* !HAVE_STRLCPY */
+# endif // !HAVE_STRLCPY
# ifndef HAVE_SNPRINTF
extern int _ppd_snprintf(char *, size_t, const char *, ...);
# define snprintf _ppd_snprintf
-# endif /* !HAVE_SNPRINTF */
+# endif // !HAVE_SNPRINTF
# ifndef HAVE_VSNPRINTF
extern int _ppd_vsnprintf(char *, size_t, const char *, va_list);
# define vsnprintf _ppd_vsnprintf
-# endif /* !HAVE_VSNPRINTF */
+# endif // !HAVE_VSNPRINTF
-/*
- * String pool functions...
- */
+
+//
+// String pool functions...
+//
extern char *_ppdStrAlloc(const char *s);
extern void _ppdStrFlush(void);
extern size_t _ppdStrStatistics(size_t *alloc_bytes, size_t *total_bytes);
-/*
- * Floating point number functions...
- */
+//
+// Floating point number functions...
+//
extern char *_ppdStrFormatd(char *buf, char *bufend, double number,
- struct lconv *loc);
+ struct lconv *loc);
extern double _ppdStrScand(const char *buf, char **bufptr,
- struct lconv *loc);
+ struct lconv *loc);
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
}
-# endif /* __cplusplus */
+# endif // __cplusplus
-#endif /* !_PPD_STRING_H_ */
+#endif // !_PPD_STRING_H_
-/*
- * String functions for libppd.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// String functions for libppd.
+//
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#define _PPD_STRING_C_
#include "string-private.h"
#include <limits.h>
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
static _ppd_mutex_t sp_mutex = _PPD_MUTEX_INITIALIZER;
- /* Mutex to control access to pool */
+ // Mutex to control access to pool
static cups_array_t *stringpool = NULL;
- /* Global string pool */
+ // Global string pool
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static int ppd_compare_sp_items(_ppd_sp_item_t *a, _ppd_sp_item_t *b);
-/*
- * '_ppdStrAlloc()' - Allocate/reference a string.
- */
+//
+// '_ppdStrAlloc()' - Allocate/reference a string.
+//
-char * /* O - String pointer */
-_ppdStrAlloc(const char *s) /* I - String */
+char * // O - String pointer
+_ppdStrAlloc(const char *s) // I - String
{
- size_t slen; /* Length of string */
- _ppd_sp_item_t *item, /* String pool item */
- *key; /* Search key */
+ size_t slen; // Length of string
+ _ppd_sp_item_t *item, // String pool item
+ *key; // Search key
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!s)
return (NULL);
- /*
- * Get the string pool...
- */
+ //
+ // Get the string pool...
+ //
_ppdMutexLock(&sp_mutex);
return (NULL);
}
- /*
- * See if the string is already in the pool...
- */
+ //
+ // See if the string is already in the pool...
+ //
key = (_ppd_sp_item_t *)(s - offsetof(_ppd_sp_item_t, str));
if ((item = (_ppd_sp_item_t *)cupsArrayFind(stringpool, key)) != NULL)
{
- /*
- * Found it, return the cached string...
- */
+ //
+ // Found it, return the cached string...
+ //
item->ref_count ++;
_ppdMutexUnlock(&sp_mutex);
abort();
}
-#endif /* DEBUG_GUARDS */
+#endif // DEBUG_GUARDS
_ppdMutexUnlock(&sp_mutex);
return (item->str);
}
- /*
- * Not found, so allocate a new one...
- */
+ //
+ // Not found, so allocate a new one...
+ //
slen = strlen(s);
item = (_ppd_sp_item_t *)calloc(1, sizeof(_ppd_sp_item_t) + slen);
DEBUG_printf(("5_ppdStrAlloc: Created string %p(%s) for \"%s\", guard=%08x, "
"ref_count=%d", item, item->str, s, item->guard,
item->ref_count));
-#endif /* DEBUG_GUARDS */
+#endif // DEBUG_GUARDS
- /*
- * Add the string to the pool and return it...
- */
+ //
+ // Add the string to the pool and return it...
+ //
cupsArrayAdd(stringpool, item);
}
-/*
- * '_ppdStrFlush()' - Flush the string pool.
- */
+//
+// '_ppdStrFlush()' - Flush the string pool.
+//
void
_ppdStrFlush(void)
{
- _ppd_sp_item_t *item; /* Current item */
+ _ppd_sp_item_t *item; // Current item
DEBUG_printf(("4_ppdStrFlush: %d strings in array",
}
-/*
- * '_ppdStrFormatd()' - Format a floating-point number.
- */
+//
+// '_ppdStrFormatd()' - Format a floating-point number.
+//
-char * /* O - Pointer to end of string */
-_ppdStrFormatd(char *buf, /* I - String */
- char *bufend, /* I - End of string buffer */
- double number, /* I - Number to format */
- struct lconv *loc) /* I - Locale data */
+char * // O - Pointer to end of string
+_ppdStrFormatd(char *buf, // I - String
+ char *bufend, // I - End of string buffer
+ double number, // I - Number to format
+ struct lconv *loc) // I - Locale data
{
- char *bufptr, /* Pointer into buffer */
- temp[1024], /* Temporary string */
- *tempdec, /* Pointer to decimal point */
- *tempptr; /* Pointer into temporary string */
- const char *dec; /* Decimal point */
- int declen; /* Length of decimal point */
+ char *bufptr, // Pointer into buffer
+ temp[1024], // Temporary string
+ *tempdec, // Pointer to decimal point
+ *tempptr; // Pointer into temporary string
+ const char *dec; // Decimal point
+ int declen; // Length of decimal point
- /*
- * Format the number using the "%.12f" format and then eliminate
- * unnecessary trailing 0's.
- */
+ //
+ // Format the number using the "%.12f" format and then eliminate
+ // unnecessary trailing 0's.
+ //
snprintf(temp, sizeof(temp), "%.12f", number);
for (tempptr = temp + strlen(temp) - 1;
tempptr > temp && *tempptr == '0';
*tempptr-- = '\0');
- /*
- * Next, find the decimal point...
- */
+ //
+ // Next, find the decimal point...
+ //
if (loc && loc->decimal_point)
{
else
tempdec = strstr(temp, dec);
- /*
- * Copy everything up to the decimal point...
- */
+ //
+ // Copy everything up to the decimal point...
+ //
if (tempdec)
{
}
-/*
- * '_ppdStrFree()' - Free/dereference a string.
- */
+//
+// '_ppdStrFree()' - Free/dereference a string.
+//
void
-_ppdStrFree(const char *s) /* I - String to free */
+_ppdStrFree(const char *s) // I - String to free
{
- _ppd_sp_item_t *item, /* String pool item */
- *key; /* Search key */
+ _ppd_sp_item_t *item, // String pool item
+ *key; // Search key
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!s)
return;
- /*
- * Check the string pool...
- *
- * We don't need to lock the mutex yet, as we only want to know if
- * the stringpool is initialized. The rest of the code will still
- * work if it is initialized before we lock...
- */
+ //
+ // Check the string pool...
+ //
+ // We don't need to lock the mutex yet, as we only want to know if
+ // the stringpool is initialized. The rest of the code will still
+ // work if it is initialized before we lock...
+ //
if (!stringpool)
return;
- /*
- * See if the string is already in the pool...
- */
+ //
+ // See if the string is already in the pool...
+ //
_ppdMutexLock(&sp_mutex);
if ((item = (_ppd_sp_item_t *)cupsArrayFind(stringpool, key)) != NULL &&
item == key)
{
- /*
- * Found it, dereference...
- */
+ //
+ // Found it, dereference...
+ //
#ifdef DEBUG_GUARDS
if (key->guard != _PPD_STR_GUARD)
_ppdMutexUnlock(&sp_mutex);
abort();
}
-#endif /* DEBUG_GUARDS */
+#endif // DEBUG_GUARDS
item->ref_count --;
if (!item->ref_count)
{
- /*
- * Remove and free...
- */
+ //
+ // Remove and free...
+ //
cupsArrayRemove(stringpool, item);
}
-/*
- * '_ppdStrRetain()' - Increment the reference count of a string.
- *
- * Note: This function does not verify that the passed pointer is in the
- * string pool, so any calls to it MUST know they are passing in a
- * good pointer.
- */
+//
+// '_ppdStrRetain()' - Increment the reference count of a string.
+//
+// Note: This function does not verify that the passed pointer is in the
+// string pool, so any calls to it MUST know they are passing in a
+// good pointer.
+//
-char * /* O - Pointer to string */
-_ppdStrRetain(const char *s) /* I - String to retain */
+char * // O - Pointer to string
+_ppdStrRetain(const char *s) // I - String to retain
{
- _ppd_sp_item_t *item; /* Pointer to string pool item */
+ _ppd_sp_item_t *item; // Pointer to string pool item
if (s)
"ref_count=%d", item, s, item->guard, item->ref_count));
abort();
}
-#endif /* DEBUG_GUARDS */
+#endif // DEBUG_GUARDS
_ppdMutexLock(&sp_mutex);
}
-/*
- * '_ppdStrScand()' - Scan a string for a floating-point number.
- *
- * This function handles the locale-specific BS so that a decimal
- * point is always the period (".")...
- */
+//
+// '_ppdStrScand()' - Scan a string for a floating-point number.
+//
+// This function handles the locale-specific BS so that a decimal
+// point is always the period (".")...
+//
-double /* O - Number */
-_ppdStrScand(const char *buf, /* I - Pointer to number */
- char **bufptr, /* O - New pointer or NULL on error */
- struct lconv *loc) /* I - Locale data */
+double // O - Number
+_ppdStrScand(const char *buf, // I - Pointer to number
+ char **bufptr, // O - New pointer or NULL on error
+ struct lconv *loc) // I - Locale data
{
- char temp[1024], /* Temporary buffer */
- *tempptr; /* Pointer into temporary buffer */
+ char temp[1024], // Temporary buffer
+ *tempptr; // Pointer into temporary buffer
- /*
- * Range check input...
- */
+ //
+ // Range check input...
+ //
if (!buf)
return (0.0);
- /*
- * Skip leading whitespace...
- */
+ //
+ // Skip leading whitespace...
+ //
while (_ppd_isspace(*buf))
buf ++;
- /*
- * Copy leading sign, numbers, period, and then numbers...
- */
+ //
+ // Copy leading sign, numbers, period, and then numbers...
+ //
tempptr = temp;
if (*buf == '-' || *buf == '+')
if (*buf == '.')
{
- /*
- * Read fractional portion of number...
- */
+ //
+ // Read fractional portion of number...
+ //
buf ++;
if (loc && loc->decimal_point)
{
- strlcpy(tempptr, loc->decimal_point, sizeof(temp) - (size_t)(tempptr - temp));
+ strlcpy(tempptr, loc->decimal_point,
+ sizeof(temp) - (size_t)(tempptr - temp));
tempptr += strlen(tempptr);
}
else if (tempptr < (temp + sizeof(temp) - 1))
if (*buf == 'e' || *buf == 'E')
{
- /*
- * Read exponent...
- */
+ //
+ // Read exponent...
+ //
if (tempptr < (temp + sizeof(temp) - 1))
*tempptr++ = *buf++;
}
}
- /*
- * Nul-terminate the temporary string and return the value...
- */
+ //
+ // Nul-terminate the temporary string and return the value...
+ //
if (bufptr)
*bufptr = (char *)buf;
}
-/*
- * '_ppdStrStatistics()' - Return allocation statistics for string pool.
- */
+//
+// '_ppdStrStatistics()' - Return allocation statistics for string pool.
+//
-size_t /* O - Number of strings */
-_ppdStrStatistics(size_t *alloc_bytes, /* O - Allocated bytes */
- size_t *total_bytes) /* O - Total string bytes */
+size_t // O - Number of strings
+_ppdStrStatistics(size_t *alloc_bytes, // O - Allocated bytes
+ size_t *total_bytes) // O - Total string bytes
{
- size_t count, /* Number of strings */
- abytes, /* Allocated string bytes */
- tbytes, /* Total string bytes */
- len; /* Length of string */
- _ppd_sp_item_t *item; /* Current item */
+ size_t count, // Number of strings
+ abytes, // Allocated string bytes
+ tbytes, // Total string bytes
+ len; // Length of string
+ _ppd_sp_item_t *item; // Current item
- /*
- * Loop through strings in pool, counting everything up...
- */
+ //
+ // Loop through strings in pool, counting everything up...
+ //
_ppdMutexLock(&sp_mutex);
for (count = 0, abytes = 0, tbytes = 0,
- item = (_ppd_sp_item_t *)cupsArrayFirst(stringpool);
+ item = (_ppd_sp_item_t *)cupsArrayFirst(stringpool);
item;
item = (_ppd_sp_item_t *)cupsArrayNext(stringpool))
{
- /*
- * Count allocated memory, using a 64-bit aligned buffer as a basis.
- */
+ //
+ // Count allocated memory, using a 64-bit aligned buffer as a basis.
+ //
count += item->ref_count;
len = (strlen(item->str) + 8) & (size_t)~7;
_ppdMutexUnlock(&sp_mutex);
- /*
- * Return values...
- */
+ //
+ // Return values...
+ //
if (alloc_bytes)
*alloc_bytes = abytes;
}
-/*
- * '_ppd_strcpy()' - Copy a string allowing for overlapping strings.
- */
+//
+// '_ppd_strcpy()' - Copy a string allowing for overlapping strings.
+//
void
-_ppd_strcpy(char *dst, /* I - Destination string */
- const char *src) /* I - Source string */
+_ppd_strcpy(char *dst, // I - Destination string
+ const char *src) // I - Source string
{
while (*src)
*dst++ = *src++;
}
-/*
- * '_ppd_strdup()' - Duplicate a string.
- */
+//
+// '_ppd_strdup()' - Duplicate a string.
+//
#ifndef HAVE_STRDUP
-char * /* O - New string pointer */
-_ppd_strdup(const char *s) /* I - String to duplicate */
+char * // O - New string pointer
+_ppd_strdup(const char *s) // I - String to duplicate
{
- char *t; /* New string pointer */
- size_t slen; /* Length of string */
+ char *t; // New string pointer
+ size_t slen; // Length of string
if (!s)
return (memcpy(t, s, slen + 1));
}
-#endif /* !HAVE_STRDUP */
+#endif // !HAVE_STRDUP
-/*
- * '_ppd_strcasecmp()' - Do a case-insensitive comparison.
- */
+//
+// '_ppd_strcasecmp()' - Do a case-insensitive comparison.
+//
-int /* O - Result of comparison (-1, 0, or 1) */
-_ppd_strcasecmp(const char *s, /* I - First string */
- const char *t) /* I - Second string */
+int // O - Result of comparison (-1, 0, or 1)
+_ppd_strcasecmp(const char *s, // I - First string
+ const char *t) // I - Second string
{
while (*s != '\0' && *t != '\0')
{
return (-1);
}
-/*
- * '_ppd_strncasecmp()' - Do a case-insensitive comparison on up to N chars.
- */
-int /* O - Result of comparison (-1, 0, or 1) */
-_ppd_strncasecmp(const char *s, /* I - First string */
- const char *t, /* I - Second string */
- size_t n) /* I - Maximum number of characters to compare */
+//
+// '_ppd_strncasecmp()' - Do a case-insensitive comparison on up to N chars.
+//
+
+int // O - Result of comparison
+ // (-1, 0, or 1)
+_ppd_strncasecmp(const char *s, // I - First string
+ const char *t, // I - Second string
+ size_t n) // I - Maximum number of characters to
+ // compare
{
while (*s != '\0' && *t != '\0' && n > 0)
{
#ifndef HAVE_STRLCAT
-/*
- * '_ppd_strlcat()' - Safely concatenate two strings.
- */
-
-size_t /* O - Length of string */
-_ppd_strlcat(char *dst, /* O - Destination string */
- const char *src, /* I - Source string */
- size_t size) /* I - Size of destination string buffer */
+//
+// '_ppd_strlcat()' - Safely concatenate two strings.
+//
+
+size_t // O - Length of string
+_ppd_strlcat(char *dst, // O - Destination string
+ const char *src, // I - Source string
+ size_t size) // I - Size of destination string buffer
{
- size_t srclen; /* Length of source string */
- size_t dstlen; /* Length of destination string */
+ size_t srclen; // Length of source string
+ size_t dstlen; // Length of destination string
- /*
- * Figure out how much room is left...
- */
+ //
+ // Figure out how much room is left...
+ //
dstlen = strlen(dst);
if (size < (dstlen + 1))
- return (dstlen); /* No room, return immediately... */
+ return (dstlen); // No room, return immediately...
size -= dstlen + 1;
- /*
- * Figure out how much room is needed...
- */
+ //
+ // Figure out how much room is needed...
+ //
srclen = strlen(src);
- /*
- * Copy the appropriate amount...
- */
+ //
+ // Copy the appropriate amount...
+ //
if (srclen > size)
srclen = size;
return (dstlen + srclen);
}
-#endif /* !HAVE_STRLCAT */
+#endif // !HAVE_STRLCAT
#ifndef HAVE_STRLCPY
-/*
- * '_ppd_strlcpy()' - Safely copy two strings.
- */
-
-size_t /* O - Length of string */
-_ppd_strlcpy(char *dst, /* O - Destination string */
- const char *src, /* I - Source string */
- size_t size) /* I - Size of destination string buffer */
+//
+// '_ppd_strlcpy()' - Safely copy two strings.
+//
+
+size_t // O - Length of string
+_ppd_strlcpy(char *dst, // O - Destination string
+ const char *src, // I - Source string
+ size_t size) // I - Size of destination string buffer
{
- size_t srclen; /* Length of source string */
+ size_t srclen; // Length of source string
- /*
- * Figure out how much room is needed...
- */
+ //
+ // Figure out how much room is needed...
+ //
size --;
srclen = strlen(src);
- /*
- * Copy the appropriate amount...
- */
+ //
+ // Copy the appropriate amount...
+ //
if (srclen > size)
srclen = size;
return (srclen);
}
-#endif /* !HAVE_STRLCPY */
+#endif // !HAVE_STRLCPY
-/*
- * 'ppd_compare_sp_items()' - Compare two string pool items...
- */
+//
+// 'ppd_compare_sp_items()' - Compare two string pool items...
+//
-static int /* O - Result of comparison */
-ppd_compare_sp_items(_ppd_sp_item_t *a, /* I - First item */
- _ppd_sp_item_t *b) /* I - Second item */
+static int // O - Result of comparison
+ppd_compare_sp_items(_ppd_sp_item_t *a, // I - First item
+ _ppd_sp_item_t *b) // I - Second item
{
return (strcmp(a->str, b->str));
}
-/*
- * Sample/test driver interface program for CUPS.
- *
- * This program handles listing and installing both static PPD files
- * in CUPS_DATADIR/model and dynamically generated PPD files using
- * the driver helper programs in CUPS_SERVERBIN/driver.
- *
- * Copyright 2007-2010 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "COPYING"
- * which should have been included with this file.
- *
- * Contents:
- *
- * main() - Enumerate or display PPD files.
- * cat_ppd() - Display a PPD file.
- * list_ppds() - List PPDs.
- *
- * Compile with:gcc -o testdriver testdriver.c -I.. -lppd -lcups
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Sample/test driver interface program for libppd.
+//
+// This program handles listing and installing both static PPD files
+// in CUPS_DATADIR/model and dynamically generated PPD files using
+// the driver helper programs in CUPS_SERVERBIN/driver.
+//
+// Copyright 2007-2010 by Apple Inc.
+// Copyright 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+// Contents:
+//
+// main() - Enumerate or display PPD files.
+// cat_ppd() - Display a PPD file.
+// list_ppds() - List PPDs.
+//
+// Compile with:gcc -o testdriver testdriver.c -I.. -lppd -lcups
+//
+
+//
+// Include necessary headers...
+//
#include <ppd/ppd.h>
#include <ppd/string-private.h>
#include <cups/cups.h>
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static int cat_ppd(const char *uri);
static int list_ppds(const char *name);
-/*
- * Sample data...
- */
+//
+// Sample data...
+//
static const char *models[][2] =
{
};
-/*
- * 'main()' - Enumerate or display PPD files.
- */
+//
+// 'main()' - Enumerate or display PPD files.
+//
-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
{
if (argc == 2 && !strcmp(argv[1], "list"))
return (list_ppds(argv[0]));
}
-/*
- * 'cat_ppd()' - Display a PPD file.
- */
+//
+// 'cat_ppd()' - Display a PPD file.
+//
-static int /* O - Exit status */
-cat_ppd(const char *uri) /* I - PPD URI */
+static int // O - Exit status
+cat_ppd(const char *uri) // I - PPD URI
{
- int i; /* Looping var */
- char scheme[255], /* URI scheme */
- userpass[255], /* Username/password (unused) */
- hostname[255], /* Hostname (unused) */
- resource[1024]; /* Resource name */
- int port; /* Port (unused) */
- const char *name; /* Pointer to name in URI */
+ int i; // Looping var
+ char scheme[255], // URI scheme
+ userpass[255], // Username/password (unused)
+ hostname[255], // Hostname (unused)
+ resource[1024]; // Resource name
+ int port; // Port (unused)
+ const char *name; // Pointer to name in URI
if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme),
for (i = 0 ; i < (int)(sizeof(models) / sizeof(models[0])); i ++)
if (!strcmp(name, models[i][0]))
{
- /*
- * Actually display the PPD file...
- */
+ //
+ // Actually display the PPD file...
+ //
+
puts("*PPD-Adobe: \"4.3\"");
puts("*LanguageEncoding: ISOLatin1");
}
-/*
- * 'list_ppds()' - List PPDs.
- */
+//
+// 'list_ppds()' - List PPDs.
+//
-static int /* O - Exit status */
-list_ppds(const char *name) /* I - Program name */
+static int // O - Exit status
+list_ppds(const char *name) // I - Program name
{
- int i; /* Looping var */
- const char *base; /* Base name of program */
+ int i; // Looping var
+ const char *base; // Base name of program
if ((base = strrchr(name, '/')) != NULL)
return (0);
}
-
-/*
- * PPD test program for libppd.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// PPD test program for libppd.
+//
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "ppd.h"
#include "array-private.h"
#else
# include <unistd.h>
# include <fcntl.h>
-#endif /* _WIN32 */
+#endif // _WIN32
#include <math.h>
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
-static int do_ppd_tests(const char *filename, int num_options, cups_option_t *options);
+static int do_ppd_tests(const char *filename, int num_options,
+ cups_option_t *options);
static int do_ps_tests(void);
static void print_changes(cups_page_header2_t *header, cups_page_header2_t *expected);
-/*
- * Test data...
- */
+//
+// Test data...
+//
static const char *dsc_code =
"[{\n"
static cups_page_header2_t setpagedevice_header =
{
- "Media Class", /* MediaClass */
- "(Media Color)", /* MediaColor */
- "Media\\Type", /* MediaType */
- "Abc", /* OutputType */
- 1000, /* AdvanceDistance */
- CUPS_ADVANCE_FILE, /* AdvanceMedia */
- CUPS_FALSE, /* Collate */
- CUPS_CUT_JOB, /* CutMedia */
- CUPS_TRUE, /* Duplex */
- { 100, 200 }, /* HWResolution */
- { 0, 0, 0, 0 }, /* ImagingBoundingBox */
- CUPS_TRUE, /* InsertSheet */
- CUPS_JOG_SET, /* Jog */
- CUPS_EDGE_RIGHT, /* LeadingEdge */
- { 0, 0 }, /* Margins */
- CUPS_TRUE, /* ManualFeed */
- 0777, /* MediaPosition */
- 0xfe01, /* MediaWeight */
- CUPS_TRUE, /* MirrorPrint */
- CUPS_TRUE, /* NegativePrint */
- 1, /* NumCopies */
- CUPS_ORIENT_90, /* Orientation */
- CUPS_TRUE, /* OutputFaceUp */
- { 612, 792 }, /* PageSize */
- CUPS_TRUE, /* Separations */
- CUPS_TRUE, /* TraySwitch */
- CUPS_TRUE, /* Tumble */
- 0, /* cupsWidth */
- 0, /* cupsHeight */
- 2, /* cupsMediaType */
- 0, /* cupsBitsPerColor */
- 0, /* cupsBitsPerPixel */
- 0, /* cupsBytesPerLine */
- CUPS_ORDER_BANDED, /* cupsColorOrder */
- CUPS_CSPACE_RGB, /* cupsColorSpace */
- 1, /* cupsCompression */
- 1, /* cupsRowCount */
- 1, /* cupsRowFeed */
- 1, /* cupsRowStep */
- 0, /* cupsNumColors */
- 1.001f, /* cupsBorderlessScalingFactor */
- { 612.0f, 792.1f }, /* cupsPageSize */
- { 0.0f, 0.0f, 0.0f, 0.0f }, /* cupsImagingBBox */
+ "Media Class", // MediaClass
+ "(Media Color)", // MediaColor
+ "Media\\Type", // MediaType
+ "Abc", // OutputType
+ 1000, // AdvanceDistance
+ CUPS_ADVANCE_FILE, // AdvanceMedia
+ CUPS_FALSE, // Collate
+ CUPS_CUT_JOB, // CutMedia
+ CUPS_TRUE, // Duplex
+ { 100, 200 }, // HWResolution
+ { 0, 0, 0, 0 }, // ImagingBoundingBox
+ CUPS_TRUE, // InsertSheet
+ CUPS_JOG_SET, // Jog
+ CUPS_EDGE_RIGHT, // LeadingEdge
+ { 0, 0 }, // Margins
+ CUPS_TRUE, // ManualFeed
+ 0777, // MediaPosition
+ 0xfe01, // MediaWeight
+ CUPS_TRUE, // MirrorPrint
+ CUPS_TRUE, // NegativePrint
+ 1, // NumCopies
+ CUPS_ORIENT_90, // Orientation
+ CUPS_TRUE, // OutputFaceUp
+ { 612, 792 }, // PageSize
+ CUPS_TRUE, // Separations
+ CUPS_TRUE, // TraySwitch
+ CUPS_TRUE, // Tumble
+ 0, // cupsWidth
+ 0, // cupsHeight
+ 2, // cupsMediaType
+ 0, // cupsBitsPerColor
+ 0, // cupsBitsPerPixel
+ 0, // cupsBytesPerLine
+ CUPS_ORDER_BANDED, // cupsColorOrder
+ CUPS_CSPACE_RGB, // cupsColorSpace
+ 1, // cupsCompression
+ 1, // cupsRowCount
+ 1, // cupsRowFeed
+ 1, // cupsRowStep
+ 0, // cupsNumColors
+ 1.001f, // cupsBorderlessScalingFactor
+ { 612.0f, 792.1f }, // cupsPageSize
+ { 0.0f, 0.0f, 0.0f, 0.0f }, // cupsImagingBBox
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
- /* cupsInteger[16] */
- { 1.1f, 2.1f, 3.1f, 4.1f, 5.1f, 6.1f, 7.1f, 8.1f, 9.1f, 10.1f, 11.1f, 12.1f, 13.1f, 14.1f, 15.1f, 16.1f }, /* cupsReal[16] */
+ // cupsInteger[16]
+ { 1.1f, 2.1f, 3.1f, 4.1f, 5.1f, 6.1f, 7.1f, 8.1f, 9.1f, 10.1f, 11.1f, 12.1f, 13.1f, 14.1f, 15.1f, 16.1f }, // cupsReal[16]
{ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
- "14", "15", "16" }, /* cupsString[16] */
- "Marker Type", /* cupsMarkerType */
- "Rendering Intent", /* cupsRenderingIntent */
- "Letter" /* cupsPageSizeName */
+ "14", "15", "16" }, // cupsString[16]
+ "Marker Type", // cupsMarkerType
+ "Rendering Intent", // cupsRenderingIntent
+ "Letter" // cupsPageSizeName
};
static const char *default_code =
"} stopped cleartomark\n";
-/*
- * '_ppdRasterColorSpaceString()' - Return the colorspace name for a
- * cupsColorSpace value.
- */
+//
+// '_ppdRasterColorSpaceString()' - Return the colorspace name for a
+// cupsColorSpace value.
+//
const char *
_ppdRasterColorSpaceString(
- cups_cspace_t cspace) /* I - cupsColorSpace value */
+ cups_cspace_t cspace) // I - cupsColorSpace value
{
static const char * const cups_color_spaces[] =
- { /* Color spaces */
+ { // Color spaces
"W",
"RGB",
"RGBA",
return (cups_color_spaces[cspace]);
}
-/*
- * '_log()' - Simple log function
- */
+
+//
+// '_log()' - Simple log function
+//
void
_log(void *data,
{
va_list arglist;
- (void)data; /* No extra data needed */
+ (void)data; // No extra data needed
switch(level)
{
}
-/*
- * 'main()' - Main entry.
- */
+//
+// 'main()' - Main entry.
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
{
- int i; /* Looping var */
- ppd_file_t *ppd = NULL; /* PPD file loaded from disk */
- int status; /* Status of tests (0 = success, 1 = fail) */
- int conflicts; /* Number of conflicts */
- char *s; /* String */
- char buffer[8192]; /* String buffer */
- const char *text, /* Localized text */
- *val; /* Option value */
- int num_options; /* Number of options */
- cups_option_t *options; /* Options */
- ppd_size_t minsize, /* Minimum size */
- maxsize, /* Maximum size */
- *size; /* Current size */
- ppd_attr_t *attr; /* Current attribute */
- ppd_cache_t *pc; /* PPD cache */
+ int i; // Looping var
+ ppd_file_t *ppd = NULL; // PPD file loaded from disk
+ int status; // Status of tests (0 = success, 1 = fail)
+ int conflicts; // Number of conflicts
+ char *s; // String
+ char buffer[8192]; // String buffer
+ const char *text, // Localized text
+ *val; // Option value
+ int num_options; // Number of options
+ cups_option_t *options; // Options
+ ppd_size_t minsize, // Minimum size
+ maxsize, // Maximum size
+ *size; // Current size
+ ppd_attr_t *attr; // Current attribute
+ ppd_cache_t *pc; // PPD cache
status = 0;
if (argc == 1)
{
- /*
- * Setup directories for locale stuff...
- */
+ //
+ // Setup directories for locale stuff...
+ //
if (access("locale", 0))
{
putenv("LOCALEDIR=locale");
putenv("SOFTWARE=CUPS");
- /*
- * Do tests with test.ppd...
- */
+ //
+ // Do tests with test.ppd...
+ //
fputs("ppdOpenFile(\"ppd/test.ppd\"): ", stdout);
puts("PASS");
else
{
- ppd_status_t err; /* Last error in file */
- int line; /* Line number in file */
+ ppd_status_t err; // Last error in file
+ int line; // Line number in file
status ++;
fputs("ppdEmitString (custom size and string): ", stdout);
ppdMarkOption(ppd, "PageSize", "Custom.400x500");
- ppdMarkOption(ppd, "StringOption", "{String1=\"value 1\" String2=value(2)}");
+ ppdMarkOption(ppd, "StringOption",
+ "{String1=\"value 1\" String2=value(2)}");
if ((s = ppdEmitString(ppd, PPD_ORDER_ANY, 0.0)) != NULL &&
!strcmp(s, custom_code))
if (s)
free(s);
- /*
- * Test constraints...
- */
+ //
+ // Test constraints...
+ //
fputs("ppdGetConflicts(InputSlot=Envelope): ", stdout);
ppdMarkOption(ppd, "PageSize", "Letter");
status ++;
}
- /*
- * ppdPageSizeLimits
- */
+ //
+ // ppdPageSizeLimits
+ //
fputs("ppdPageSizeLimits: ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (fabs(minsize.width - 36.0) > 0.001 || fabs(minsize.length - 36.0) > 0.001 ||
- fabs(maxsize.width - 1080.0) > 0.001 || fabs(maxsize.length - 86400.0) > 0.001)
+ if (fabs(minsize.width - 36.0) > 0.001 ||
+ fabs(minsize.length - 36.0) > 0.001 ||
+ fabs(maxsize.width - 1080.0) > 0.001 ||
+ fabs(maxsize.length - 86400.0) > 0.001)
{
printf("FAIL (got min=%.3fx%.3f, max=%.3fx%.3f, "
"expected min=36x36, max=1080x86400)\n", minsize.width,
status ++;
}
- /*
- * ppdMarkOptions with PWG and IPP size names.
- */
+ //
+ // ppdMarkOptions with PWG and IPP size names.
+ //
fputs("ppdMarkOptions(media=iso-a4): ", stdout);
num_options = cupsAddOption("media", "iso-a4", 0, &options);
else
puts("PASS");
- /*
- * Custom sizes...
- */
+ //
+ // Custom sizes...
+ //
fputs("ppdMarkOptions(media=Custom.8x10in): ", stdout);
num_options = cupsAddOption("media", "Custom.8x10in", 0, &options);
else
puts("PASS");
- /*
- * Test localization...
- */
+ //
+ // Test localization...
+ //
fputs("ppdLocalizeIPPReason(text): ", stdout);
if (ppdLocalizeIPPReason(ppd, "foo", NULL, buffer, sizeof(buffer)) &&
printf("FAIL (\"%s\" instead of \"Number 1 Foo Reason\")\n", buffer);
}
- /*
- * cupsMarkerName localization...
- */
+ //
+ // cupsMarkerName localization...
+ //
putenv("LANG=en");
putenv("LC_ALL=en");
ppdClose(ppd);
- /*
- * Test new constraints...
- */
+ //
+ // Test new constraints...
+ //
fputs("ppdOpenFile(\"ppd/test2.ppd\"): ", stdout);
puts("PASS");
else
{
- ppd_status_t err; /* Last error in file */
- int line; /* Line number in file */
+ ppd_status_t err; // Last error in file
+ int line; // Line number in file
status ++;
status ++;
}
- /*
- * ppdPageSizeLimits
- */
+ //
+ // ppdPageSizeLimits
+ //
ppdMarkDefaults(ppd);
fputs("ppdPageSizeLimits(default): ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (fabs(minsize.width - 36.0) > 0.001 || fabs(minsize.length - 36.0) > 0.001 ||
- fabs(maxsize.width - 1080.0) > 0.001 || fabs(maxsize.length - 86400.0) > 0.001)
+ if (fabs(minsize.width - 36.0) > 0.001 ||
+ fabs(minsize.length - 36.0) > 0.001 ||
+ fabs(maxsize.width - 1080.0) > 0.001 ||
+ fabs(maxsize.length - 86400.0) > 0.001)
{
printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
"expected min=36x36, max=1080x86400)\n", minsize.width,
fputs("ppdPageSizeLimits(InputSlot=Manual): ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (fabs(minsize.width - 100.0) > 0.001 || fabs(minsize.length - 100.0) > 0.001 ||
- fabs(maxsize.width - 1000.0) > 0.001 || fabs(maxsize.length - 1000.0) > 0.001)
+ if (fabs(minsize.width - 100.0) > 0.001 ||
+ fabs(minsize.length - 100.0) > 0.001 ||
+ fabs(maxsize.width - 1000.0) > 0.001 ||
+ fabs(maxsize.length - 1000.0) > 0.001)
{
printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
"expected min=100x100, max=1000x1000)\n", minsize.width,
fputs("ppdPageSizeLimits(Quality=Photo): ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (fabs(minsize.width - 200.0) > 0.001 || fabs(minsize.length - 200.0) > 0.001 ||
- fabs(maxsize.width - 1000.0) > 0.001 || fabs(maxsize.length - 1000.0) > 0.001)
+ if (fabs(minsize.width - 200.0) > 0.001 ||
+ fabs(minsize.length - 200.0) > 0.001 ||
+ fabs(maxsize.width - 1000.0) > 0.001 ||
+ fabs(maxsize.length - 1000.0) > 0.001)
{
printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
"expected min=200x200, max=1000x1000)\n", minsize.width,
fputs("ppdPageSizeLimits(Quality=Photo): ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (fabs(minsize.width - 300.0) > 0.001 || fabs(minsize.length - 300.0) > 0.001 ||
- fabs(maxsize.width - 1080.0) > 0.001 || fabs(maxsize.length - 86400.0) > 0.001)
+ if (fabs(minsize.width - 300.0) > 0.001 ||
+ fabs(minsize.length - 300.0) > 0.001 ||
+ fabs(maxsize.width - 1080.0) > 0.001 ||
+ fabs(maxsize.length - 86400.0) > 0.001)
{
printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
"expected min=300x300, max=1080x86400)\n", minsize.width,
(s = strcasestr(argv[1], ".ppd")) == NULL ||
s[4] != '\0')
{
- /* First argument is not FILE.ppd but DIR or DIR,DIR,... ->
- PPD directory list -> See whether we have valid PPD collection */
+ // First argument is not FILE.ppd but DIR or DIR,DIR,... ->
+ // PPD directory list -> See whether we have valid PPD collection
cups_array_t *dirlist = _ppdArrayNewStrings(argv[1], ',');
cups_array_t *ppd_collections = cupsArrayNew(NULL, NULL);
if ((ppd = ppdOpen2(ppdCollectionGetPPD(testname, ppd_collections,
_log, NULL))) == NULL)
{
- ppd_status_t err; /* Last error in file */
- int line; /* Line number in file */
+ ppd_status_t err; // Last error in file
+ int line; // Line number in file
status ++;
err = ppdLastError(&line);
}
else
{
- const char *name; /* PPD name */
- char *filename; /* Name of actual file containing PPD */
- struct stat fileinfo; /* File information */
+ const char *name; // PPD name
+ char *filename; // Name of actual file containing PPD
+ struct stat fileinfo; // File information
name = argv[1];
filename = strdup(name);
if (S_ISLNK(fileinfo.st_mode))
{
- char realfile[1024]; /* Real file path */
- ssize_t realsize; /* Size of real file path */
+ char realfile[1024]; // Real file path
+ ssize_t realsize; // Size of real file path
if ((realsize = readlink(filename, realfile, sizeof(realfile) - 1)) < 0)
if ((ppd = ppdOpen2(ppdCollectionGetPPD(name, NULL, _log, NULL))) ==
NULL)
{
- ppd_status_t err; /* Last error in file */
- int line; /* Line number in file */
+ ppd_status_t err; // Last error in file
+ int line; // Line number in file
status ++;
}
else
{
- int j, k; /* Looping vars */
- ppd_group_t *group; /* Option group */
- ppd_option_t *option; /* Option */
- ppd_coption_t *coption; /* Custom option */
- ppd_cparam_t *cparam; /* Custom parameter */
- ppd_const_t *c; /* UIConstraints */
- char lang[255], /* LANG environment variable */
- lc_all[255], /* LC_ALL environment variable */
- lc_ctype[255], /* LC_CTYPE environment variable */
- lc_messages[255];/* LC_MESSAGES environment variable */
+ int j, k; // Looping vars
+ ppd_group_t *group; // Option group
+ ppd_option_t *option; // Option
+ ppd_coption_t *coption; // Custom option
+ ppd_cparam_t *cparam; // Custom parameter
+ ppd_const_t *c; // UIConstraints
+ char lang[255], // LANG environment variable
+ lc_all[255], // LC_ALL environment variable
+ lc_ctype[255], // LC_CTYPE environment variable
+ lc_messages[255];// LC_MESSAGES environment variable
if (argc > 2)
switch (cparam->type)
{
case PPD_CUSTOM_UNKNOWN :
- printf(" %s(%s): PPD_CUSTOM_UNKNOWN (error)\n", cparam->name, cparam->text);
+ printf(" %s(%s): PPD_CUSTOM_UNKNOWN (error)\n",
+ cparam->name, cparam->text);
break;
case PPD_CUSTOM_CURVE :
#ifdef __APPLE__
if (getenv("MallocStackLogging") && getenv("MallocStackLoggingNoCompact"))
{
- char command[1024]; /* malloc_history command */
+ char command[1024]; // malloc_history command
snprintf(command, sizeof(command), "malloc_history %d -all_by_size",
getpid());
fflush(stdout);
system(command);
}
-#endif /* __APPLE__ */
+#endif // __APPLE__
ppdClose(ppd);
}
-/*
- * 'do_ppd_tests()' - Test the default option commands in a PPD file.
- */
+//
+// 'do_ppd_tests()' - Test the default option commands in a PPD file.
+//
-static int /* O - Number of errors */
-do_ppd_tests(const char *filename, /* I - PPD file */
- int num_options, /* I - Number of options */
- cups_option_t *options) /* I - Options */
+static int // O - Number of errors
+do_ppd_tests(const char *filename, // I - PPD file
+ int num_options, // I - Number of options
+ cups_option_t *options) // I - Options
{
- ppd_file_t *ppd; /* PPD file data */
- cups_page_header2_t header; /* Page header */
+ ppd_file_t *ppd; // PPD file data
+ cups_page_header2_t header; // Page header
printf("\"%s\": ", filename);
if ((ppd = ppdOpenFile(filename)) == NULL)
{
- ppd_status_t status; /* Status from PPD loader */
- int line; /* Line number containing error */
+ ppd_status_t status; // Status from PPD loader
+ int line; // Line number containing error
status = ppdLastError(&line);
}
-/*
- * 'do_ps_tests()' - Test standard PostScript commands.
- */
+//
+// 'do_ps_tests()' - Test standard PostScript commands.
+//
static int
do_ps_tests(void)
{
- cups_page_header2_t header; /* Page header */
- int preferred_bits; /* Preferred bits */
- int errors = 0; /* Number of errors */
+ cups_page_header2_t header; // Page header
+ int preferred_bits; // Preferred bits
+ int errors = 0; // Number of errors
- /*
- * Test PS exec code...
- */
+ //
+ // Test PS exec code...
+ //
fputs("ppdRasterExecPS(\"setpagedevice\"): ", stdout);
fflush(stdout);
}
-
-
-/*
- * 'print_changes()' - Print differences in the page header.
- */
+//
+// 'print_changes()' - Print differences in the page header.
+//
static void
print_changes(
- cups_page_header2_t *header, /* I - Actual page header */
- cups_page_header2_t *expected) /* I - Expected page header */
+ cups_page_header2_t *header, // I - Actual page header
+ cups_page_header2_t *expected) // I - Expected page header
{
- int i; /* Looping var */
+ int i; // Looping var
if (strcmp(header->MediaClass, expected->MediaClass))
expected->cupsColorOrder);
if (header->cupsColorSpace != expected->cupsColorSpace)
- printf(" cupsColorSpace %s, expected %s\n", _ppdRasterColorSpaceString(header->cupsColorSpace),
+ printf(" cupsColorSpace %s, expected %s\n",
+ _ppdRasterColorSpaceString(header->cupsColorSpace),
_ppdRasterColorSpaceString(expected->cupsColorSpace));
if (header->cupsCompression != expected->cupsCompression)
printf(" cupsNumColors %d, expected %d\n", header->cupsNumColors,
expected->cupsNumColors);
- if (fabs(header->cupsBorderlessScalingFactor - expected->cupsBorderlessScalingFactor) > 0.001)
+ if (fabs(header->cupsBorderlessScalingFactor -
+ expected->cupsBorderlessScalingFactor) > 0.001)
printf(" cupsBorderlessScalingFactor %g, expected %g\n",
header->cupsBorderlessScalingFactor,
expected->cupsBorderlessScalingFactor);
-/*
- * Private threading definitions for libppd.
- *
- * Copyright 2009-2017 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Private threading definitions for libppd.
+//
+// Copyright 2009-2017 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _PPD_THREAD_PRIVATE_H_
# define _PPD_THREAD_PRIVATE_H_
-/*
- * Include necessary headers...
- */
+//
+// Include necessary headers...
+//
# include "config.h"
-/*
- * C++ magic...
- */
+//
+// C++ magic...
+//
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-# ifdef HAVE_PTHREAD_H /* POSIX threading */
+# ifdef HAVE_PTHREAD_H // POSIX threading
# include <pthread.h>
typedef pthread_mutex_t _ppd_mutex_t;
typedef pthread_key_t _ppd_threadkey_t;
# define _ppdThreadGetData(k) pthread_getspecific(k)
# define _ppdThreadSetData(k,p) pthread_setspecific(k,p)
-# elif defined(_WIN32) /* Windows threading */
+# elif defined(_WIN32) // Windows threading
# include <winsock2.h>
# include <windows.h>
typedef struct _ppd_mutex_s
{
- int m_init; /* Flag for on-demand initialization */
+ int m_init; // Flag for on-demand initialization
CRITICAL_SECTION m_criticalSection;
- /* Win32 Critical Section */
+ // Win32 Critical Section
} _ppd_mutex_t;
typedef DWORD _ppd_threadkey_t;
# define _PPD_MUTEX_INITIALIZER { 0, 0 }
# define _ppdThreadGetData(k) TlsGetValue(k)
# define _ppdThreadSetData(k,p) TlsSetValue(k,p)
-# else /* No threading */
+# else // No threading
typedef char _ppd_mutex_t;
typedef void *_ppd_threadkey_t;
# define _PPD_MUTEX_INITIALIZER 0
# define _PPD_THREADKEY_INITIALIZER (void *)0
# define _ppdThreadGetData(k) k
# define _ppdThreadSetData(k,p) k=p
-# endif /* HAVE_PTHREAD_H */
+# endif // HAVE_PTHREAD_H
-/*
- * Functions...
- */
+//
+// Functions...
+//
extern void _ppdMutexInit(_ppd_mutex_t *mutex);
extern void _ppdMutexLock(_ppd_mutex_t *mutex);
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_PPD_THREAD_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_PPD_THREAD_PRIVATE_H_
-/*
- * Threading primitives for libppd.
- *
- * Copyright © 2009-2018 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Threading primitives for libppd.
+//
+// Copyright © 2009-2018 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include "thread-private.h"
#if defined(HAVE_PTHREAD_H)
-/*
- * '_ppdMutexInit()' - Initialize a mutex.
- */
+//
+// '_ppdMutexInit()' - Initialize a mutex.
+//
void
-_ppdMutexInit(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexInit(_ppd_mutex_t *mutex) // I - Mutex
{
pthread_mutex_init(mutex, NULL);
}
-/*
- * '_ppdMutexLock()' - Lock a mutex.
- */
+//
+// '_ppdMutexLock()' - Lock a mutex.
+//
void
-_ppdMutexLock(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexLock(_ppd_mutex_t *mutex) // I - Mutex
{
pthread_mutex_lock(mutex);
}
-/*
- * '_ppdMutexUnlock()' - Unlock a mutex.
- */
+//
+// '_ppdMutexUnlock()' - Unlock a mutex.
+//
void
-_ppdMutexUnlock(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexUnlock(_ppd_mutex_t *mutex) // I - Mutex
{
pthread_mutex_unlock(mutex);
}
# include <process.h>
static _ppd_mutex_t ppd_global_mutex = _CUPS_MUTEX_INITIALIZER;
- /* Global critical section */
+ // Global critical section
-/*
- * '_ppdMutexInit()' - Initialize a mutex.
- */
+//
+// '_ppdMutexInit()' - Initialize a mutex.
+//
void
-_ppdMutexInit(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexInit(_ppd_mutex_t *mutex) // I - Mutex
{
InitializeCriticalSection(&mutex->m_criticalSection);
mutex->m_init = 1;
}
-/*
- * '_ppdMutexLock()' - Lock a mutex.
- */
+//
+// '_ppdMutexLock()' - Lock a mutex.
+//
void
-_ppdMutexLock(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexLock(_ppd_mutex_t *mutex) // I - Mutex
{
if (!mutex->m_init)
{
}
-/*
- * '_ppdMutexUnlock()' - Unlock a mutex.
- */
+//
+// '_ppdMutexUnlock()' - Unlock a mutex.
+//
void
-_ppdMutexUnlock(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexUnlock(_ppd_mutex_t *mutex) // I - Mutex
{
LeaveCriticalSection(&mutex->m_criticalSection);
}
-#else /* No threading */
+#else // No threading
-/*
- * '_ppdMutexInit()' - Initialize a mutex.
- */
+//
+// '_ppdMutexInit()' - Initialize a mutex.
+//
void
-_ppdMutexInit(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexInit(_ppd_mutex_t *mutex) // I - Mutex
{
(void)mutex;
}
-/*
- * '_ppdMutexLock()' - Lock a mutex.
- */
+//
+// '_ppdMutexLock()' - Lock a mutex.
+//
void
-_ppdMutexLock(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexLock(_ppd_mutex_t *mutex) // I - Mutex
{
(void)mutex;
}
-/*
- * '_ppdMutexUnlock()' - Unlock a mutex.
- */
+//
+// '_ppdMutexUnlock()' - Unlock a mutex.
+//
void
-_ppdMutexUnlock(_ppd_mutex_t *mutex) /* I - Mutex */
+_ppdMutexUnlock(_ppd_mutex_t *mutex) // I - Mutex
{
(void)mutex;
}
-#endif /* HAVE_PTHREAD_H */
+#endif // HAVE_PTHREAD_H