]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Make PWG media handling APIs public (STR #4267)
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 11 Mar 2013 16:19:48 +0000 (16:19 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 11 Mar 2013 16:19:48 +0000 (16:19 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10895 7a7537e8-13f0-0310-91df-b6672ffda945

13 files changed:
CHANGES.txt
cups/Makefile
cups/cups-private.h
cups/cups.h
cups/dest-options.c
cups/dest.c
cups/ppd-cache.c
cups/ppd-private.h
cups/pwg-media.c
cups/pwg-private.h
cups/pwg.h [new file with mode: 0644]
cups/testpwg.c
systemv/cupstestppd.c

index 40b67344c9e5b0aa9598a37b63f7d90ed229f232..17d27122cd6d7324cf5edac0b59b46235adceb09 100644 (file)
@@ -1,9 +1,10 @@
-CHANGES.txt - 1.7b1 - 2013-01-30
+CHANGES.txt - 1.7b1 - 2013-03-11
 --------------------------------
 
 CHANGES IN CUPS V1.7b1
 
        - Added a new "-x" option to the cancel command (STR #4103)
+       - Made the PWG media handling APIs public (STR #4267)
        - Added new ippCreateRequestedArray API for generating a array of
          attributes from the requested-attributes attribute.
        - The ipptool utility now supports compression, conditional tests based
index ce9af10eb6fe7eab814cb9fd5304057fa8ac3e95..55bdf313c0444c841978b7dbd706b0af1413a2f0 100644 (file)
@@ -113,6 +113,7 @@ HEADERS     =       \
                ipp.h \
                language.h \
                ppd.h \
+               pwg.h \
                raster.h \
                sidechannel.h \
                transcode.h \
@@ -527,8 +528,8 @@ apihelp:
                --css ../doc/cups-printable.css \
                --header api-cups.header --intro api-cups.shtml \
                api-cups.xml \
-               cups.h adminutil.c dest*.c language.c notify.c \
-               options.c tempfile.c usersys.c \
+               cups.h pwg.h adminutil.c dest*.c language.c notify.c \
+               options.c pwg-media.c tempfile.c usersys.c \
                util.c >../doc/help/api-cups.html
        mxmldoc --tokens help/api-cups.html api-cups.xml >../doc/help/api-cups.tokens
        $(RM) api-cups.xml
index 433ee0c93c1597a798515342e36e7e7bb3b72cd6..3d6b60f4ab5f4142c113e3f6eb78b763408c78f6 100644 (file)
@@ -131,7 +131,7 @@ typedef struct _cups_globals_s              /**** CUPS global state data ****/
   cups_array_t         *leg_size_lut,  /* Lookup table for legacy names */
                        *ppd_size_lut,  /* Lookup table for PPD names */
                        *pwg_size_lut;  /* Lookup table for PWG names */
-  _pwg_media_t         pwg_media;      /* PWG media data for custom size */
+  pwg_media_t          pwg_media;      /* PWG media data for custom size */
   char                 pwg_name[65];   /* PWG media name for custom size */
 
   /* request.c */
index 78645d3838996c020e3fe3d27a5dc5b90585435f..b2443b0b8fe46c240879079a0cfdbbc1e67a3201 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   API definitions for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -37,6 +37,7 @@ typedef off_t ssize_t;                        /* @private@ */
 #  include "file.h"
 #  include "ipp.h"
 #  include "language.h"
+#  include "pwg.h"
 
 
 /*
index 873d2e2cd19c924df3a90a71dce369b7d337c7bf..eab6076f63a69af941a4f039ce8978f3bd92ea52 100644 (file)
@@ -61,7 +61,7 @@ static void           cups_create_defaults(cups_dinfo_t *dinfo);
 static void            cups_create_media_db(cups_dinfo_t *dinfo);
 static void            cups_free_media_db(_cups_media_db_t *mdb);
 static int             cups_get_media_db(cups_dinfo_t *dinfo,
-                                         _pwg_media_t *pwg, unsigned flags,
+                                         pwg_media_t *pwg, unsigned flags,
                                          cups_size_t *size);
 static int             cups_is_close_media_db(_cups_media_db_t *a,
                                               _cups_media_db_t *b);
@@ -133,7 +133,7 @@ cupsCheckDestSupported(
     * Check range of custom media sizes...
     */
 
-    _pwg_media_t       *pwg;           /* Current PWG media size info */
+    pwg_media_t        *pwg;           /* Current PWG media size info */
     int                        min_width,      /* Minimum width */
                        min_length,     /* Minimum length */
                        max_width,      /* Maximum width */
@@ -151,13 +151,13 @@ cupsCheckDestSupported(
         i --, attrval ++)
     {
       if (!strncmp(attrval->string.text, "custom_min_", 11) &&
-          (pwg = _pwgMediaForPWG(attrval->string.text)) != NULL)
+          (pwg = pwgMediaForPWG(attrval->string.text)) != NULL)
       {
         min_width  = pwg->width;
         min_length = pwg->length;
       }
       else if (!strncmp(attrval->string.text, "custom_max_", 11) &&
-              (pwg = _pwgMediaForPWG(attrval->string.text)) != NULL)
+              (pwg = pwgMediaForPWG(attrval->string.text)) != NULL)
       {
         max_width  = pwg->width;
         max_length = pwg->length;
@@ -169,7 +169,7 @@ cupsCheckDestSupported(
     */
 
     if (min_width < INT_MAX && max_width > 0 &&
-        (pwg = _pwgMediaForPWG(value)) != NULL &&
+        (pwg = pwgMediaForPWG(value)) != NULL &&
         pwg->width >= min_width && pwg->width <= max_width &&
         pwg->length >= min_length && pwg->length <= max_length)
       return (1);
@@ -742,7 +742,7 @@ cupsGetDestMediaByName(
     unsigned     flags,                        /* I - Media matching flags */
     cups_size_t  *size)                        /* O - Media size information */
 {
-  _pwg_media_t         *pwg;           /* PWG media info */
+  pwg_media_t          *pwg;           /* PWG media info */
 
 
  /*
@@ -762,8 +762,8 @@ cupsGetDestMediaByName(
   * Lookup the media size name...
   */
 
-  if ((pwg = _pwgMediaForPWG(media)) == NULL)
-    if ((pwg = _pwgMediaForLegacy(media)) == NULL)
+  if ((pwg = pwgMediaForPWG(media)) == NULL)
+    if ((pwg = pwgMediaForLegacy(media)) == NULL)
     {
       DEBUG_printf(("1cupsGetDestMediaByName: Unknown size '%s'.", media));
       _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unknown media size name."), 1);
@@ -810,7 +810,7 @@ cupsGetDestMediaBySize(
     unsigned     flags,                        /* I - Media matching flags */
     cups_size_t  *size)                        /* O - Media size information */
 {
-  _pwg_media_t         *pwg;           /* PWG media info */
+  pwg_media_t          *pwg;           /* PWG media info */
 
 
  /*
@@ -830,7 +830,7 @@ cupsGetDestMediaBySize(
   * Lookup the media size name...
   */
 
-  if ((pwg = _pwgMediaForSize(width, length)) == NULL)
+  if ((pwg = pwgMediaForSize(width, length)) == NULL)
   {
     DEBUG_printf(("1cupsGetDestMediaBySize: Invalid size %dx%d.", width,
                   length));
@@ -1044,7 +1044,7 @@ cups_create_media_db(
                        *media_attr,    /* media-xxx */
                        *x_dimension,   /* x-dimension */
                        *y_dimension;   /* y-dimension */
-  _pwg_media_t         *pwg;           /* PWG media info */
+  pwg_media_t          *pwg;           /* PWG media info */
   _cups_media_db_t     mdb;            /* Media entry */
 
 
@@ -1222,8 +1222,8 @@ cups_create_media_db(
          i > 0;
          i --, val ++)
     {
-      if ((pwg = _pwgMediaForPWG(val->string.text)) == NULL)
-        if ((pwg = _pwgMediaForLegacy(val->string.text)) == NULL)
+      if ((pwg = pwgMediaForPWG(val->string.text)) == NULL)
+        if ((pwg = pwgMediaForLegacy(val->string.text)) == NULL)
        {
          DEBUG_printf(("3cups_create_media_db: Ignoring unknown size '%s'.",
                        val->string.text));
@@ -1285,7 +1285,7 @@ cups_free_media_db(
 
 static int                             /* O - 1 on match, 0 on failure */
 cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */
-                  _pwg_media_t *pwg,   /* I - PWG media info */
+                  pwg_media_t *pwg,    /* I - PWG media info */
                   unsigned     flags,  /* I - Media matching flags */
                   cups_size_t *size)   /* O - Media size/margin/name info */
 {
index 3b14effd737db7f2ff4b3daafdbfed97979b1585..0af7ebaa613ee2b495724a85a2df1577676932c4 100644 (file)
@@ -2458,7 +2458,7 @@ appleGetPaperSize(char *name,             /* I - Paper size name buffer */
                   int  namesize)       /* I - Size of buffer */
 {
   CFStringRef  defaultPaperID;         /* Default paper ID */
-  _pwg_media_t *pwgmedia;              /* PWG media size */
+  pwg_media_t  *pwgmedia;              /* PWG media size */
 
 
   defaultPaperID = _cupsAppleCopyDefaultPaperID();
@@ -2467,7 +2467,7 @@ appleGetPaperSize(char *name,             /* I - Paper size name buffer */
       !CFStringGetCString(defaultPaperID, name, namesize,
                          kCFStringEncodingUTF8))
     name[0] = '\0';
-  else if ((pwgmedia = _pwgMediaForLegacy(name)) != NULL)
+  else if ((pwgmedia = pwgMediaForLegacy(name)) != NULL)
     strlcpy(name, pwgmedia->pwg, namesize);
 
   if (defaultPaperID)
index c1febfa9d4919d9efacf22ddd1511372bc921ae6..2f0fbc6d8bb2ff4a24cc05ccd7dd0cfb1794d9b1 100644 (file)
@@ -38,7 +38,7 @@
  *   _ppdCacheWriteFile()      - Write PWG mapping data to a file.
  *   _pwgInputSlotForSource()  - Get the InputSlot name for the given PWG
  *                               media-source.
- *   _pwgMediaTypeForType()    - Get the MediaType name for the given PWG
+ *   pwgMediaTypeForType()    - Get the MediaType name for the given PWG
  *                               media-type.
  *   _pwgPageSizeForMedia()    - Get the PageSize name for the given media.
  *   pwg_ppdize_name()         - Convert an IPP keyword to a PPD keyword.
@@ -88,8 +88,8 @@ _ppdCacheCreateWithFile(
 {
   cups_file_t  *fp;                    /* File */
   _ppd_cache_t *pc;                    /* PWG mapping data */
-  _pwg_size_t  *size;                  /* Current size */
-  _pwg_map_t   *map;                   /* Current map */
+  pwg_size_t   *size;                  /* Current size */
+  pwg_map_t    *map;                   /* Current map */
   _pwg_finishings_t *finishings;       /* Current finishings option */
   int          linenum,                /* Current line number */
                num_bins,               /* Number of bins in file */
@@ -290,7 +290,7 @@ _ppdCacheCreateWithFile(
        goto create_error;
       }
 
-      if ((pc->bins = calloc(num_bins, sizeof(_pwg_map_t))) == NULL)
+      if ((pc->bins = calloc(num_bins, sizeof(pwg_map_t))) == NULL)
       {
         DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d bins.",
                      num_sizes));
@@ -340,7 +340,7 @@ _ppdCacheCreateWithFile(
 
       if (num_sizes > 0)
       {
-       if ((pc->sizes = calloc(num_sizes, sizeof(_pwg_size_t))) == NULL)
+       if ((pc->sizes = calloc(num_sizes, sizeof(pwg_size_t))) == NULL)
        {
          DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sizes.",
                        num_sizes));
@@ -398,12 +398,12 @@ _ppdCacheCreateWithFile(
        goto create_error;
       }
 
-      _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
-                      pc->custom_max_width, pc->custom_max_length);
+      pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
+                       pc->custom_max_width, pc->custom_max_length, NULL);
       pc->custom_max_keyword = _cupsStrAlloc(pwg_keyword);
 
-      _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
-                      pc->custom_min_width, pc->custom_min_length);
+      pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
+                       pc->custom_min_width, pc->custom_min_length, NULL);
       pc->custom_min_keyword = _cupsStrAlloc(pwg_keyword);
     }
     else if (!_cups_strcasecmp(line, "SourceOption"))
@@ -428,7 +428,7 @@ _ppdCacheCreateWithFile(
        goto create_error;
       }
 
-      if ((pc->sources = calloc(num_sources, sizeof(_pwg_map_t))) == NULL)
+      if ((pc->sources = calloc(num_sources, sizeof(pwg_map_t))) == NULL)
       {
         DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sources.",
                      num_sources));
@@ -477,7 +477,7 @@ _ppdCacheCreateWithFile(
        goto create_error;
       }
 
-      if ((pc->types = calloc(num_types, sizeof(_pwg_map_t))) == NULL)
+      if ((pc->types = calloc(num_types, sizeof(pwg_map_t))) == NULL)
       {
         DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d types.",
                      num_types));
@@ -654,24 +654,24 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
                        *color_model,   /* ColorModel option */
                        *duplex;        /* Duplex option */
   ppd_choice_t         *choice;        /* Current InputSlot/MediaType */
-  _pwg_map_t           *map;           /* Current source/type map */
+  pwg_map_t            *map;           /* Current source/type map */
   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 */
+  pwg_size_t           *pwg_size;      /* Current PWG size */
   char                 pwg_keyword[3 + PPD_MAX_NAME + 1 + 12 + 1 + 12 + 3],
                                        /* 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 */
+  pwg_media_t          *pwg_media;     /* PWG media data */
   _pwg_print_color_mode_t pwg_print_color_mode;
                                        /* print-color-mode index */
   _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 */
+  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 */
@@ -684,7 +684,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)     /* I - PPD file */
                        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 */
+  pwg_size_t           *new_size;      /* New size to add, if any */
   const char           *filter;        /* Current filter */
   _pwg_finishings_t    *finishings;    /* Current finishings value */
 
@@ -714,10 +714,10 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
 
   if (ppd->num_sizes > 0)
   {
-    if ((pc->sizes = calloc(ppd->num_sizes, sizeof(_pwg_size_t))) == NULL)
+    if ((pc->sizes = calloc(ppd->num_sizes, sizeof(pwg_size_t))) == NULL)
     {
       DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
-                   "_pwg_size_t's.", ppd->num_sizes));
+                   "pwg_size_t's.", ppd->num_sizes));
       goto create_error;
     }
 
@@ -736,7 +736,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)     /* I - PPD file */
       * Convert the PPD size name to the corresponding PWG keyword name.
       */
 
-      if ((pwg_media = _pwgMediaForPPD(ppd_size->name)) != NULL)
+      if ((pwg_media = pwgMediaForPPD(ppd_size->name)) != NULL)
       {
        /*
        * Standard name, do we have conflicts?
@@ -771,9 +771,9 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)     /* I - PPD file */
        new_known_pwg = 0;
 
        pwg_unppdize_name(ppd_size->name, ppd_name, sizeof(ppd_name), "_.");
-       _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), NULL, ppd_name,
-                        _PWG_FROMPTS(ppd_size->width),
-                        _PWG_FROMPTS(ppd_size->length));
+       pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), NULL, ppd_name,
+                         PWG_FROM_POINTS(ppd_size->width),
+                         PWG_FROM_POINTS(ppd_size->length), NULL);
       }
 
      /*
@@ -782,16 +782,16 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
       * dimensions that are <= 0...
       */
 
-      if ((pwg_media = _pwgMediaForSize(_PWG_FROMPTS(ppd_size->width),
-                                       _PWG_FROMPTS(ppd_size->length))) == NULL)
+      if ((pwg_media = pwgMediaForSize(PWG_FROM_POINTS(ppd_size->width),
+                                       PWG_FROM_POINTS(ppd_size->length))) == NULL)
        continue;
 
       new_width      = pwg_media->width;
       new_length     = pwg_media->length;
-      new_left       = _PWG_FROMPTS(ppd_size->left);
-      new_bottom     = _PWG_FROMPTS(ppd_size->bottom);
-      new_right      = _PWG_FROMPTS(ppd_size->width - ppd_size->right);
-      new_top        = _PWG_FROMPTS(ppd_size->length - ppd_size->top);
+      new_left       = PWG_FROM_POINTS(ppd_size->left);
+      new_bottom     = PWG_FROM_POINTS(ppd_size->bottom);
+      new_right      = PWG_FROM_POINTS(ppd_size->width - ppd_size->right);
+      new_top        = PWG_FROM_POINTS(ppd_size->length - ppd_size->top);
       new_imageable  = new_length - new_top - new_bottom;
       new_borderless = new_bottom == 0 && new_top == 0 &&
                       new_left == 0 && new_right == 0;
@@ -860,24 +860,24 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
     * Generate custom size data...
     */
 
-    _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
-                    _PWG_FROMPTS(ppd->custom_max[0]),
-                    _PWG_FROMPTS(ppd->custom_max[1]));
+    pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
+                     PWG_FROM_POINTS(ppd->custom_max[0]),
+                     PWG_FROM_POINTS(ppd->custom_max[1]), NULL);
     pc->custom_max_keyword = _cupsStrAlloc(pwg_keyword);
-    pc->custom_max_width   = _PWG_FROMPTS(ppd->custom_max[0]);
-    pc->custom_max_length  = _PWG_FROMPTS(ppd->custom_max[1]);
+    pc->custom_max_width   = PWG_FROM_POINTS(ppd->custom_max[0]);
+    pc->custom_max_length  = PWG_FROM_POINTS(ppd->custom_max[1]);
 
-    _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
-                    _PWG_FROMPTS(ppd->custom_min[0]),
-                    _PWG_FROMPTS(ppd->custom_min[1]));
+    pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
+                     PWG_FROM_POINTS(ppd->custom_min[0]),
+                     PWG_FROM_POINTS(ppd->custom_min[1]), NULL);
     pc->custom_min_keyword = _cupsStrAlloc(pwg_keyword);
-    pc->custom_min_width   = _PWG_FROMPTS(ppd->custom_min[0]);
-    pc->custom_min_length  = _PWG_FROMPTS(ppd->custom_min[1]);
+    pc->custom_min_width   = PWG_FROM_POINTS(ppd->custom_min[0]);
+    pc->custom_min_length  = PWG_FROM_POINTS(ppd->custom_min[1]);
 
-    pc->custom_size.left   = _PWG_FROMPTS(ppd->custom_margins[0]);
-    pc->custom_size.bottom = _PWG_FROMPTS(ppd->custom_margins[1]);
-    pc->custom_size.right  = _PWG_FROMPTS(ppd->custom_margins[2]);
-    pc->custom_size.top    = _PWG_FROMPTS(ppd->custom_margins[3]);
+    pc->custom_size.left   = PWG_FROM_POINTS(ppd->custom_margins[0]);
+    pc->custom_size.bottom = PWG_FROM_POINTS(ppd->custom_margins[1]);
+    pc->custom_size.right  = PWG_FROM_POINTS(ppd->custom_margins[2]);
+    pc->custom_size.top    = PWG_FROM_POINTS(ppd->custom_margins[3]);
   }
 
  /*
@@ -892,10 +892,10 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
     pc->source_option = _cupsStrAlloc(input_slot->keyword);
 
     if ((pc->sources = calloc(input_slot->num_choices,
-                               sizeof(_pwg_map_t))) == NULL)
+                               sizeof(pwg_map_t))) == NULL)
     {
       DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
-                    "_pwg_map_t's for InputSlot.", input_slot->num_choices));
+                    "pwg_map_t's for InputSlot.", input_slot->num_choices));
       goto create_error;
     }
 
@@ -954,10 +954,10 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
   if ((media_type = ppdFindOption(ppd, "MediaType")) != NULL)
   {
     if ((pc->types = calloc(media_type->num_choices,
-                             sizeof(_pwg_map_t))) == NULL)
+                             sizeof(pwg_map_t))) == NULL)
     {
       DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
-                    "_pwg_map_t's for MediaType.", media_type->num_choices));
+                    "pwg_map_t's for MediaType.", media_type->num_choices));
       goto create_error;
     }
 
@@ -1019,10 +1019,10 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
   if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL)
   {
     if ((pc->bins = calloc(output_bin->num_choices,
-                             sizeof(_pwg_map_t))) == NULL)
+                             sizeof(pwg_map_t))) == NULL)
     {
       DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
-                    "_pwg_map_t's for OutputBin.", output_bin->num_choices));
+                    "pwg_map_t's for OutputBin.", output_bin->num_choices));
       goto create_error;
     }
 
@@ -1456,8 +1456,8 @@ void
 _ppdCacheDestroy(_ppd_cache_t *pc)     /* I - PPD cache and mapping data */
 {
   int          i;                      /* Looping var */
-  _pwg_map_t   *map;                   /* Current map */
-  _pwg_size_t  *size;                  /* Current size */
+  pwg_map_t    *map;                   /* Current map */
+  pwg_size_t   *size;                  /* Current size */
 
 
  /*
@@ -1720,7 +1720,7 @@ _ppdCacheGetInputSlot(
 
     ipp_attribute_t    *media_col,     /* media-col attribute */
                        *media_source;  /* media-source attribute */
-    _pwg_size_t                size;           /* Dimensional size */
+    pwg_size_t         size;           /* Dimensional size */
     int                        margins_set;    /* Were the margins set? */
 
     media_col = ippFindAttribute(job, "media-col", IPP_TAG_BEGIN_COLLECTION);
@@ -1735,7 +1735,7 @@ _ppdCacheGetInputSlot(
 
       keyword = ippGetString(media_source, 0, NULL);
     }
-    else if (_pwgInitSize(&size, job, &margins_set))
+    else if (pwgInitSize(&size, job, &margins_set))
     {
      /*
       * For media <= 5x7, look for a photo tray...
@@ -1859,7 +1859,7 @@ _ppdCacheGetPageSize(
     int          *exact)               /* O - 1 if exact match, 0 otherwise */
 {
   int          i;                      /* Looping var */
-  _pwg_size_t  *size,                  /* Current size */
+  pwg_size_t   *size,                  /* Current size */
                *closest,               /* Closest size */
                jobsize;                /* Size data from job */
   int          margins_set,            /* Were the margins set? */
@@ -1947,7 +1947,7 @@ _ppdCacheGetPageSize(
     * media-col.
     */
 
-    if (!_pwgInitSize(&jobsize, job, &margins_set))
+    if (!pwgInitSize(&jobsize, job, &margins_set))
       return (NULL);
   }
   else
@@ -1956,12 +1956,12 @@ _ppdCacheGetPageSize(
     * Get the size using a media keyword...
     */
 
-    _pwg_media_t       *media;         /* Media definition */
+    pwg_media_t        *media;         /* Media definition */
 
 
-    if ((media = _pwgMediaForPWG(keyword)) == NULL)
-      if ((media = _pwgMediaForLegacy(keyword)) == NULL)
-        if ((media = _pwgMediaForPPD(keyword)) == NULL)
+    if ((media = pwgMediaForPWG(keyword)) == NULL)
+      if ((media = pwgMediaForLegacy(keyword)) == NULL)
+        if ((media = pwgMediaForPPD(keyword)) == NULL)
          return (NULL);
 
     jobsize.width  = media->width;
@@ -2054,7 +2054,7 @@ _ppdCacheGetPageSize(
     */
 
     snprintf(pc->custom_ppd_size, sizeof(pc->custom_ppd_size), "Custom.%dx%d",
-             (int)_PWG_TOPTS(jobsize.width), (int)_PWG_TOPTS(jobsize.length));
+             (int)PWG_TO_POINTS(jobsize.width), (int)PWG_TO_POINTS(jobsize.length));
 
     if (margins_set && exact)
     {
@@ -2090,14 +2090,14 @@ _ppdCacheGetPageSize(
  * '_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 */
 {
   int          i;                      /* Looping var */
-  _pwg_media_t *media;                 /* Media */
-  _pwg_size_t  *size;                  /* Current size */
+  pwg_media_t  *media;                 /* Media */
+  pwg_size_t   *size;                  /* Current size */
 
 
  /*
@@ -2183,9 +2183,9 @@ _ppdCacheGetSize(
   * Look up standard sizes...
   */
 
-  if ((media = _pwgMediaForPPD(page_size)) == NULL)
-    if ((media = _pwgMediaForLegacy(page_size)) == NULL)
-      media = _pwgMediaForPWG(page_size);
+  if ((media = pwgMediaForPPD(page_size)) == NULL)
+    if ((media = pwgMediaForLegacy(page_size)) == NULL)
+      media = pwgMediaForPWG(page_size);
 
   if (media)
   {
@@ -2210,7 +2210,7 @@ _ppdCacheGetSource(
     const char   *input_slot)          /* I - PPD InputSlot */
 {
   int          i;                      /* Looping var */
-  _pwg_map_t   *source;                /* Current source */
+  pwg_map_t    *source;                /* Current source */
 
 
  /*
@@ -2239,7 +2239,7 @@ _ppdCacheGetType(
     const char   *media_type)          /* I - PPD MediaType */
 {
   int          i;                      /* Looping var */
-  _pwg_map_t   *type;                  /* Current type */
+  pwg_map_t    *type;                  /* Current type */
 
 
  /*
@@ -2269,8 +2269,8 @@ _ppdCacheWriteFile(
 {
   int                  i, j, k;        /* Looping vars */
   cups_file_t          *fp;            /* Output file */
-  _pwg_size_t          *size;          /* Current size */
-  _pwg_map_t           *map;           /* Current map */
+  pwg_size_t           *size;          /* Current size */
+  pwg_map_t            *map;           /* Current map */
   _pwg_finishings_t    *f;             /* Current finishing option */
   cups_option_t                *option;        /* Current option */
   const char           *value;         /* Filter/pre-filter value */
@@ -2530,12 +2530,12 @@ _pwgInputSlotForSource(
 
 
 /*
- * '_pwgMediaTypeForType()' - Get the MediaType name for the given PWG
+ * 'pwgMediaTypeForType()' - Get the MediaType name for the given PWG
  *                            media-type.
  */
 
 const char *                           /* O - MediaType name */
-_pwgMediaTypeForType(
+pwgMediaTypeForType(
     const char *media_type,            /* I - PWG media-type */
     char       *name,                  /* I - Name buffer */
     size_t     namesize)               /* I - Size of name buffer */
@@ -2584,7 +2584,7 @@ _pwgMediaTypeForType(
 
 const char *                           /* O - PageSize name */
 _pwgPageSizeForMedia(
-    _pwg_media_t *media,               /* I - Media */
+    pwg_media_t *media,                /* I - Media */
     char         *name,                        /* I - PageSize name buffer */
     size_t       namesize)             /* I - Size of name buffer */
 {
@@ -2620,8 +2620,8 @@ _pwgPageSizeForMedia(
     * Use a name of the form "wNNNhNNN"...
     */
 
-    snprintf(name, namesize, "w%dh%d", (int)_PWG_TOPTS(media->width),
-             (int)_PWG_TOPTS(media->length));
+    snprintf(name, namesize, "w%dh%d", (int)PWG_TO_POINTS(media->width),
+             (int)PWG_TO_POINTS(media->length));
   }
   else
   {
index 28016d632437d9f6bb049295b156265291805733..c6c25325bdcc32af068259a26b22fbe2fcf91da3 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Private PPD definitions for CUPS.
  *
- *   Copyright 2007-2011 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -112,9 +112,9 @@ typedef struct _pwg_finishings_s    /**** PWG finishings mapping data ****/
 struct _ppd_cache_s                    /**** PPD cache and PWG conversion data ****/
 {
   int          num_bins;               /* Number of output bins */
-  _pwg_map_t   *bins;                  /* Output bins */
+  pwg_map_t    *bins;                  /* Output bins */
   int          num_sizes;              /* Number of media sizes */
-  _pwg_size_t  *sizes;                 /* 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 */
@@ -122,12 +122,12 @@ struct _ppd_cache_s                       /**** PPD cache and PWG conversion data ****/
   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 */
+  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 */
+  pwg_map_t    *sources;               /* Media sources */
   int          num_types;              /* Number of media types */
-  _pwg_map_t   *types;                 /* Media types */
+  pwg_map_t    *types;                 /* Media types */
   int          num_presets[_PWG_PRINT_COLOR_MODE_MAX][_PWG_PRINT_QUALITY_MAX];
                                        /* Number of print-color-mode/print-quality options */
   cups_option_t        *presets[_PWG_PRINT_COLOR_MODE_MAX][_PWG_PRINT_QUALITY_MAX];
@@ -179,7 +179,7 @@ extern const char   *_ppdCacheGetOutputBin(_ppd_cache_t *pc,
                                               const char *keyword);
 extern const char      *_ppdCacheGetPageSize(_ppd_cache_t *pc, ipp_t *job,
                                              const char *keyword, int *exact);
-extern _pwg_size_t     *_ppdCacheGetSize(_ppd_cache_t *pc,
+extern pwg_size_t      *_ppdCacheGetSize(_ppd_cache_t *pc,
                                          const char *page_size);
 extern const char      *_ppdCacheGetSource(_ppd_cache_t *pc,
                                            const char *input_slot);
@@ -207,7 +207,7 @@ extern const char   *_pwgInputSlotForSource(const char *media_source,
                                                char *name, size_t namesize);
 extern const char      *_pwgMediaTypeForType(const char *media_type,
                                              char *name, size_t namesize);
-extern const char      *_pwgPageSizeForMedia(_pwg_media_t *media,
+extern const char      *_pwgPageSizeForMedia(pwg_media_t *media,
                                              char *name, size_t namesize);
 
 
index 1c2940bf8824089b429cdfa9ef56ababe3ad21a4..cd392ef980220d8ad0d7e94c900fc3076607bbaf 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   PWG media name API implementation for CUPS.
  *
- *   Copyright 2009-2012 by Apple Inc.
+ *   Copyright 2009-2013 by Apple Inc.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Apple Inc. and are protected by Federal copyright
  *
  * Contents:
  *
- *   _pwgFormatInches()      - Convert and format PWG units as inches.
- *   _pwgFormatMillimeters() - Convert and format PWG units as millimeters.
- *   _pwgGenerateSize()      - Generate a PWG size keyword.
- *   _pwgInitSize()         - Initialize a PWG size using IPP job template
- *                            attributes.
- *   _pwgMediaForLegacy()    - Find a PWG media size by ISO/IPP legacy name.
- *   _pwgMediaForPPD()      - Find a PWG media size by Adobe PPD name.
- *   _pwgMediaForPWG()      - Find a PWG media size by 5101.1 self-describing
- *                            name.
- *   _pwgMediaForSize()      - Get the PWG media name for a given size.
- *   pwg_compare_legacy()    - Compare two sizes using the legacy names.
- *   pwg_compare_ppd()      - Compare two sizes using the PPD names.
- *   pwg_compare_pwg()      - Compare two sizes using the PWG names.
+ *   pwgFormatSizeName()      - Generate a PWG self-describing media size name.
+ *   pwgInitSize()           - Initialize a pwg_size_t structure using IPP Job
+ *                             Template attributes.
+ *   pwgMediaForLegacy()      - Find a PWG media size by ISO/IPP legacy name.
+ *   pwgMediaForPPD()        - Find a PWG media size by Adobe PPD name.
+ *   pwgMediaForPWG()        - Find a PWG media size by 5101.1 self-describing
+ *                             name.
+ *   pwgMediaForSize()       - Get the PWG media size for the given
+ *                             dimensions.
+ *   pwg_compare_legacy()     - Compare two sizes using the legacy names.
+ *   pwg_compare_ppd()       - Compare two sizes using the PPD names.
+ *   pwg_compare_pwg()       - Compare two sizes using the PWG names.
+ *   pwg_format_inches()      - Convert and format PWG units as inches.
+ *   pwg_format_millimeters() - Convert and format PWG units as millimeters.
  */
 
 /*
  * Local functions...
  */
 
-static int     pwg_compare_legacy(_pwg_media_t *a, _pwg_media_t *b);
-static int     pwg_compare_pwg(_pwg_media_t *a, _pwg_media_t *b);
-static int     pwg_compare_ppd(_pwg_media_t *a, _pwg_media_t *b);
+static int     pwg_compare_legacy(pwg_media_t *a, pwg_media_t *b);
+static int     pwg_compare_pwg(pwg_media_t *a, pwg_media_t *b);
+static int     pwg_compare_ppd(pwg_media_t *a, pwg_media_t *b);
+static char    *pwg_format_inches(char *buf, size_t bufsize, int val);
+static char    *pwg_format_millimeters(char *buf, size_t bufsize, int val);
 
 
 /*
  * Local globals...
  */
 
-static _pwg_media_t const cups_pwg_media[] =
+static pwg_media_t const cups_pwg_media[] =
 {                                      /* Media size lookup table */
   /* North American Standard Sheet Media Sizes */
   _PWG_MEDIA_IN("na_index-3x5_3x5in", NULL, "3x5", 3, 5),
@@ -255,126 +258,122 @@ static _pwg_media_t const cups_pwg_media[] =
 
 
 /*
- * '_pwgFormatInches()' - Convert and format PWG units as inches.
+ * 'pwgFormatSizeName()' - Generate a PWG self-describing media size name.
+ *
+ * This function generates a PWG self-describing media size name of the form
+ * "prefix_name_WIDTHxLENGTHunits".  The prefix is typically "custom" or "roll"
+ * for user-supplied sizes but can also be "disc", "iso", "jis", "jpn", "na",
+ * "oe", "om", "prc", or "roc".  A value of @code NULL@ automatically chooses
+ * "oe" or "om" depending on the units.
+ *
+ * The size name may only contain lowercase letters, numbers, "-", and ".".  If
+ * @code NULL@ is passed, the size name will contain the formatted dimensions.
+ *
+ * The width and length are specified in hundredths of millimeters, equivalent
+ * to 1/100000th of a meter or 1/2540th of an inch.  The width, length, and
+ * units used for the generated size name are calculated automatically if the
+ * units string is @code NULL@, otherwise inches ("in") or millimeters ("mm")
+ * are used.
+ *
+ * @since CUPS 1.7@
  */
 
-char *                                 /* O - String */
-_pwgFormatInches(char   *buf,          /* I - Buffer */
-                 size_t bufsize,       /* I - Size of buffer */
-                 int    val)           /* I - Value in hundredths of millimeters */
+int                                    /* O - 1 on success, 0 on failure */
+pwgFormatSizeName(char       *keyword, /* I - Keyword buffer */
+                 size_t     keysize,   /* I - Size of keyword buffer */
+                 const char *prefix,   /* I - Prefix for PWG size or @code NULL@ for automatic */
+                 const char *name,     /* I - Size name or @code NULL@ */
+                 int        width,     /* I - Width of page in 2540ths */
+                 int        length,    /* I - Length of page in 2540ths */
+                 const char *units)    /* I - Units - "in", "mm", or @code NULL@ for automatic */
 {
-  int  thousandths,                    /* Thousandths of inches */
-       integer,                        /* Integer portion */
-       fraction;                       /* Fractional portion */
+  char         usize[12 + 1 + 12 + 3], /* Unit size: NNNNNNNNNNNNxNNNNNNNNNNNNuu */
+               *uptr;                  /* Pointer into unit size */
+  char         *(*format)(char *, size_t, int);
+                                       /* Formatting function */
 
 
  /*
-  * Convert hundredths of millimeters to thousandths of inches and round to
-  * the nearest thousandth.
+  * Range check input...
   */
 
-  thousandths = (val * 1000 + 1270) / 2540;
-  integer     = thousandths / 1000;
-  fraction    = thousandths % 1000;
+  DEBUG_printf(("pwgFormatSize(keyword=%p, keysize=" CUPS_LLFMT
+                ", prefix=\"%s\", name=\"%s\", width=%d, length=%d, "
+                "units=\"%s\")", keyword, CUPS_LLCAST keysize, prefix, name,
+                width, length, units));
 
- /*
-  * Format as a pair of integers (avoids locale stuff), avoiding trailing
-  * zeros...
-  */
+  if (keyword)
+    *keyword = '\0';
 
-  if (fraction == 0)
-    snprintf(buf, bufsize, "%d", integer);
-  else if (fraction % 10)
-    snprintf(buf, bufsize, "%d.%03d", integer, fraction);
-  else if (fraction % 100)
-    snprintf(buf, bufsize, "%d.%02d", integer, fraction / 10);
-  else
-    snprintf(buf, bufsize, "%d.%01d", integer, fraction / 100);
-
-  return (buf);
-}
-
-
-/*
- * '_pwgFormatMillimeters()' - Convert and format PWG units as millimeters.
- */
-
-char *                                 /* O - String */
-_pwgFormatMillimeters(char   *buf,     /* I - Buffer */
-                      size_t bufsize,  /* I - Size of buffer */
-                      int    val)      /* I - Value in hundredths of millimeters */
-{
-  int  integer,                        /* Integer portion */
-       fraction;                       /* Fractional portion */
-
-
- /*
-  * Convert hundredths of millimeters to integer and fractional portions.
-  */
+  if (!keyword || keysize < 32 || width < 0 || length < 0 ||
+      (units && strcmp(units, "in") && strcmp(units, "mm")))
+  {
+    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid media name arguments."),
+                  1);
+    return (0);
+  }
 
-  integer     = val / 100;
-  fraction    = val % 100;
+  if (name)
+  {
+   /*
+    * Validate name...
+    */
 
- /*
-  * Format as a pair of integers (avoids locale stuff), avoiding trailing
-  * zeros...
-  */
+    const char *nameptr;               /* Pointer into name */
 
-  if (fraction == 0)
-    snprintf(buf, bufsize, "%d", integer);
-  else if (fraction % 10)
-    snprintf(buf, bufsize, "%d.%02d", integer, fraction);
+    for (nameptr = name; *nameptr; nameptr ++)
+      if (!(*nameptr >= 'a' && *nameptr <= 'z') &&
+          !(*nameptr >= '0' && *nameptr <= '9') &&
+          *nameptr != '.' && *nameptr != '-')
+      {
+        _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
+                      _("Invalid media name arguments."), 1);
+        return (0);
+      }
+  }
   else
-    snprintf(buf, bufsize, "%d.%01d", integer, fraction / 10);
-
-  return (buf);
-}
+    name = usize;
 
 
-/*
- * '_pwgGenerateSize()' - Generate a PWG size keyword.
- */
+  if (!units)
+  {
+    if ((width % 635) == 0 && (length % 635) == 0)
+    {
+     /*
+      * Use inches since the size is a multiple of 1/4 inch.
+      */
 
-void
-_pwgGenerateSize(char       *keyword,  /* I - Keyword buffer */
-                 size_t     keysize,   /* I - Size of keyword buffer */
-                const char *prefix,    /* I - Prefix for PWG size or NULL */
-                const char *name,      /* I - Size name or NULL */
-                int        width,      /* I - Width of page in 2540ths */
-                int        length)     /* I - Length of page in 2540ths */
-{
-  const char   *units;                 /* Units to report */
-  char         usize[12 + 1 + 12 + 3], /* Unit size: NNNNNNNNNNNNxNNNNNNNNNNNNuu */
-               *uptr;                  /* Pointer into unit size */
-  char         *(*format)(char *, size_t, int);
-                                       /* Formatting function */
+      units = "in";
+    }
+    else
+    {
+     /*
+      * Use millimeters since the size is not a multiple of 1/4 inch.
+      */
 
+      units = "mm";
+    }
+  }
 
-  if ((width % 635) == 0 && (length % 635) == 0)
+  if (!strcmp(units, "in"))
   {
-   /*
-    * Use inches since the size is a multiple of 1/4 inch.
-    */
-
-    units   = "in";
-    format  = _pwgFormatInches;
+    format = pwg_format_inches;
 
     if (!prefix)
       prefix = "oe";
   }
   else
   {
-   /*
-    * Use millimeters since the size is not a multiple of 1/4 inch.
-    */
-
-    units   = "mm";
-    format  = _pwgFormatMillimeters;
+    format = pwg_format_millimeters;
 
     if (!prefix)
       prefix = "om";
   }
 
+ /*
+  * Format the size string...
+  */
+
   uptr = usize;
   (*format)(uptr, sizeof(usize) - (uptr - usize), width);
   uptr += strlen(uptr);
@@ -388,25 +387,40 @@ _pwgGenerateSize(char       *keyword,     /* I - Keyword buffer */
 
   memcpy(uptr, units, 3);
 
-  if (!name)
-    name = usize;
-
  /*
   * Format the name...
   */
 
   snprintf(keyword, keysize, "%s_%s_%s", prefix, name, usize);
+
+  return (1);
 }
 
+/* For OS X 10.8 and earlier... */
+void _pwgGenerateSize(char *keyword, size_t keysize, const char *prefix,
+                     const char *name, int width, int length)
+{ pwgFormatSizeName(keyword, keysize, prefix, name, width, length, NULL); }
+
 
 /*
- * '_pwgInitSize()' - Initialize a PWG size using IPP job template attributes.
+ * 'pwgInitSize()' - Initialize a pwg_size_t structure using IPP Job Template
+ *                   attributes.
+ *
+ * This function initializes a pwg_size_t structure from an IPP "media" or
+ * "media-col" attribute in the specified IPP message.  0 is returned if neither
+ * attribute is found in the message or the values are not valid.
+ *
+ * The "margins_set" variable is initialized to 1 if any "media-xxx-margin"
+ * member attribute was specified in the "media-col" Job Template attribute,
+ * otherwise it is initialized to 0.
+ *
+ * @since CUPS 1.7@
  */
 
-int                                    /* O - 1 if size was initialize, 0 otherwise */
-_pwgInitSize(_pwg_size_t *size,                /* I - Size to initialize */
-             ipp_t       *job,         /* I - Job template attributes */
-            int         *margins_set)  /* O - 1 if margins were set, 0 otherwise */
+int                                    /* O - 1 if size was initialized, 0 otherwise */
+pwgInitSize(pwg_size_t *size,          /* I - Size to initialize */
+           ipp_t      *job,            /* I - Job template attributes */
+           int        *margins_set)    /* O - 1 if margins were set, 0 otherwise */
 {
   ipp_attribute_t *media,              /* media attribute */
                *media_bottom_margin,   /* media-bottom-margin member attribute */
@@ -417,7 +431,7 @@ _pwgInitSize(_pwg_size_t *size,             /* I - Size to initialize */
                *media_top_margin,      /* media-top-margin member attribute */
                *x_dimension,           /* x-dimension member attribute */
                *y_dimension;           /* y-dimension member attribute */
-  _pwg_media_t *pwg;                   /* PWG media value */
+  pwg_media_t  *pwg;                   /* PWG media value */
 
 
  /*
@@ -431,7 +445,7 @@ _pwgInitSize(_pwg_size_t *size,             /* I - Size to initialize */
   * Look for media-col and then media...
   */
 
-  memset(size, 0, sizeof(_pwg_size_t));
+  memset(size, 0, sizeof(pwg_size_t));
   *margins_set = 0;
 
   if ((media_col = ippFindAttribute(job, "media-col",
@@ -515,13 +529,13 @@ _pwgInitSize(_pwg_size_t *size,           /* I - Size to initialize */
       const char *name = media->values[0].string.text;
                                        /* Name string */
 
-      if ((pwg = _pwgMediaForPWG(name)) == NULL)
+      if ((pwg = pwgMediaForPWG(name)) == NULL)
       {
        /*
         * Not a PWG name, try a legacy name...
        */
 
-       if ((pwg = _pwgMediaForLegacy(name)) == NULL)
+       if ((pwg = pwgMediaForLegacy(name)) == NULL)
        {
         /*
          * Not a legacy name, try a PPD name...
@@ -529,7 +543,7 @@ _pwgInitSize(_pwg_size_t *size,             /* I - Size to initialize */
 
          const char    *suffix;        /* Suffix on media string */
 
-         pwg = _pwgMediaForPPD(name);
+         pwg = pwgMediaForPPD(name);
          if (pwg &&
              (suffix = name + strlen(name) - 10 /* .FullBleed */) > name &&
              !_cups_strcasecmp(suffix, ".FullBleed"))
@@ -564,16 +578,24 @@ _pwgInitSize(_pwg_size_t *size,           /* I - Size to initialize */
   return (1);
 }
 
+/* For OS X 10.8 and earlier */
+int _pwgInitSize(pwg_size_t *size, ipp_t *job, int *margins_set)
+{ return (pwgInitSize(size, job, margins_set)); }
+
 
 /*
- * '_pwgMediaForLegacy()' - Find a PWG media size by ISO/IPP legacy name.
+ * 'pwgMediaForLegacy()' - Find a PWG media size by ISO/IPP legacy name.
+ *
+ * The "name" argument specifies the legacy ISO media size name, for example
+ * "iso-a4" or "na-letter".
+ *
+ * @since CUPS 1.7@
  */
 
-_pwg_media_t *                         /* O - Matching size or NULL */
-_pwgMediaForLegacy(
-    const char *legacy)                        /* I - Legacy size name */
+pwg_media_t *                          /* O - Matching size or NULL */
+pwgMediaForLegacy(const char *legacy)  /* I - Legacy size name */
 {
-  _pwg_media_t key;                    /* Search key */
+  pwg_media_t  key;                    /* Search key */
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
 
@@ -591,13 +613,13 @@ _pwgMediaForLegacy(
   if (!cg->leg_size_lut)
   {
     int                        i;              /* Looping var */
-    _pwg_media_t       *size;          /* Current size */
+    pwg_media_t        *size;          /* Current size */
 
     cg->leg_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_legacy,
                                     NULL);
 
     for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
-             size = (_pwg_media_t *)cups_pwg_media;
+             size = (pwg_media_t *)cups_pwg_media;
         i > 0;
         i --, size ++)
       if (size->legacy)
@@ -609,18 +631,33 @@ _pwgMediaForLegacy(
   */
 
   key.legacy = legacy;
-  return ((_pwg_media_t *)cupsArrayFind(cg->leg_size_lut, &key));
+  return ((pwg_media_t *)cupsArrayFind(cg->leg_size_lut, &key));
 }
 
+/* For OS X 10.8 and earlier */
+pwg_media_t *_pwgMediaForLegacy(const char *legacy)
+{ return (pwgMediaForLegacy(legacy)); }
+
 
 /*
- * '_pwgMediaForPPD()' - Find a PWG media size by Adobe PPD name.
+ * 'pwgMediaForPPD()' - Find a PWG media size by Adobe PPD name.
+ *
+ * The "ppd" argument specifies an Adobe page size name as defined in Table B.1
+ * of the Adobe PostScript Printer Description File Format Specification Version
+ * 4.3.
+ *
+ * If the name is non-standard, the returned PWG media size is stored in
+ * thread-local storage and is overwritten by each call to the function in the
+ * thread.  Custom names can be of the form "Custom.WIDTHxLENGTH[units]" or
+ * "WIDTHxLENGTH[units]".
+ *
+ * @since CUPS 1.7@
  */
 
-_pwg_media_t *                         /* O - Matching size or NULL */
-_pwgMediaForPPD(const char *ppd)       /* I - PPD size name */
+pwg_media_t *                          /* O - Matching size or NULL */
+pwgMediaForPPD(const char *ppd)                /* I - PPD size name */
 {
-  _pwg_media_t key,                    /* Search key */
+  pwg_media_t  key,                    /* Search key */
                *size;                  /* Matching size */
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
@@ -643,7 +680,7 @@ _pwgMediaForPPD(const char *ppd)    /* I - PPD size name */
     cg->ppd_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_ppd, NULL);
 
     for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
-             size = (_pwg_media_t *)cups_pwg_media;
+             size = (pwg_media_t *)cups_pwg_media;
         i > 0;
         i --, size ++)
       if (size->ppd)
@@ -655,7 +692,7 @@ _pwgMediaForPPD(const char *ppd)    /* I - PPD size name */
   */
 
   key.ppd = ppd;
-  if ((size = (_pwg_media_t *)cupsArrayFind(cg->ppd_size_lut, &key)) == NULL)
+  if ((size = (pwg_media_t *)cupsArrayFind(cg->ppd_size_lut, &key)) == NULL)
   {
    /*
     * See if the name is of the form:
@@ -737,9 +774,9 @@ _pwgMediaForPPD(const char *ppd)    /* I - PPD size name */
        size->length = (int)(l * factor);
        size->pwg    = cg->pwg_name;
 
-       _pwgGenerateSize(cg->pwg_name, sizeof(cg->pwg_name),
-                        custom ? "custom" : NULL, custom ? ppd + 7 : NULL,
-                        size->width, size->length);
+       pwgFormatSizeName(cg->pwg_name, sizeof(cg->pwg_name),
+                         custom ? "custom" : NULL, custom ? ppd + 7 : NULL,
+                         size->width, size->length, NULL);
       }
     }
   }
@@ -747,16 +784,29 @@ _pwgMediaForPPD(const char *ppd)  /* I - PPD size name */
   return (size);
 }
 
+/* For OS X 10.8 and earlier */
+pwg_media_t *_pwgMediaForPPD(const char *ppd)
+{ return (pwgMediaForPPD(ppd)); }
+
 
 /*
- * '_pwgMediaForPWG()' - Find a PWG media size by 5101.1 self-describing name.
+ * 'pwgMediaForPWG()' - Find a PWG media size by 5101.1 self-describing name.
+ *
+ * The "pwg" argument specifies a self-describing media size name of the form
+ * "prefix_name_WIDTHxLENGTHunits" as defined in PWG 5101.1.
+ *
+ * If the name is non-standard, the returned PWG media size is stored in
+ * thread-local storage and is overwritten by each call to the function in the
+ * thread.
+ *
+ * @since CUPS 1.7@
  */
 
-_pwg_media_t *                         /* O - Matching size or NULL */
-_pwgMediaForPWG(const char *pwg)       /* I - PWG size name */
+pwg_media_t *                          /* O - Matching size or NULL */
+pwgMediaForPWG(const char *pwg)                /* I - PWG size name */
 {
   char         *ptr;                   /* Pointer into name */
-  _pwg_media_t key,                    /* Search key */
+  pwg_media_t  key,                    /* Search key */
                *size;                  /* Matching size */
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
@@ -779,7 +829,7 @@ _pwgMediaForPWG(const char *pwg)    /* I - PWG size name */
     cg->pwg_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_pwg, NULL);
 
     for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
-             size = (_pwg_media_t *)cups_pwg_media;
+             size = (pwg_media_t *)cups_pwg_media;
         i > 0;
         i --, size ++)
       cupsArrayAdd(cg->pwg_size_lut, size);
@@ -790,7 +840,7 @@ _pwgMediaForPWG(const char *pwg)    /* I - PWG size name */
   */
 
   key.pwg = pwg;
-  if ((size = (_pwg_media_t *)cupsArrayFind(cg->pwg_size_lut, &key)) == NULL &&
+  if ((size = (pwg_media_t *)cupsArrayFind(cg->pwg_size_lut, &key)) == NULL &&
       (ptr = (char *)strchr(pwg, '_')) != NULL &&
       (ptr = (char *)strchr(ptr + 1, '_')) != NULL)
   {
@@ -836,17 +886,30 @@ _pwgMediaForPWG(const char *pwg)  /* I - PWG size name */
   return (size);
 }
 
+/* For OS X 10.8 and earlier */
+pwg_media_t *_pwgMediaForPWG(const char *pwg)
+{ return (pwgMediaForPWG(pwg)); }
+
 
 /*
- * '_pwgMediaForSize()' - Get the PWG media name for a given size.
+ * 'pwgMediaForSize()' - Get the PWG media size for the given dimensions.
+ *
+ * The "width" and "length" are in hundredths of millimeters, equivalent to
+ * 1/100000th of a meter or 1/2540th of an inch.
+ *
+ * If the dimensions are non-standard, the returned PWG media size is stored in
+ * thread-local storage and is overwritten by each call to the function in the
+ * thread.
+ *
+ * @since CUPS 1.7@
  */
 
-_pwg_media_t *                         /* O - PWG media name */
-_pwgMediaForSize(int width,            /* I - Width in 2540ths */
-                int length)            /* I - Length in 2540ths */
+pwg_media_t *                          /* O - PWG media name */
+pwgMediaForSize(int width,             /* I - Width in hundredths of millimeters */
+               int length)             /* I - Length in hundredths of millimeters */
 {
   int          i;                      /* Looping var */
-  _pwg_media_t *media,                 /* Current media */
+  pwg_media_t  *media,                 /* Current media */
                *best_media = NULL;     /* Best match */
   int          dw, dl,                 /* Difference in width and length */
                best_dw = 999,          /* Best difference in width and length */
@@ -866,7 +929,7 @@ _pwgMediaForSize(int width,         /* I - Width in 2540ths */
   */
 
   for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
-          media = (_pwg_media_t *)cups_pwg_media;
+          media = (pwg_media_t *)cups_pwg_media;
        i > 0;
        i --, media ++)
   {
@@ -900,8 +963,8 @@ _pwgMediaForSize(int width,         /* I - Width in 2540ths */
   *     custom_WIDTHxHEIGHTuu_WIDTHxHEIGHTuu
   */
 
-  _pwgGenerateSize(cg->pwg_name, sizeof(cg->pwg_name), "custom", NULL, width,
-                   length);
+  pwgFormatSizeName(cg->pwg_name, sizeof(cg->pwg_name), "custom", NULL, width,
+                    length, NULL);
 
   cg->pwg_media.pwg    = cg->pwg_name;
   cg->pwg_media.width  = width;
@@ -910,14 +973,18 @@ _pwgMediaForSize(int width,               /* I - Width in 2540ths */
   return (&(cg->pwg_media));
 }
 
+/* For OS X 10.8 and earlier */
+pwg_media_t *_pwgMediaForSize(int width, int length)
+{ return (pwgMediaForSize(width, length)); }
+
 
 /*
  * 'pwg_compare_legacy()' - Compare two sizes using the legacy names.
  */
 
 static int                             /* O - Result of comparison */
-pwg_compare_legacy(_pwg_media_t *a,    /* I - First size */
-                   _pwg_media_t *b)    /* I - Second size */
+pwg_compare_legacy(pwg_media_t *a,     /* I - First size */
+                   pwg_media_t *b)     /* I - Second size */
 {
   return (strcmp(a->legacy, b->legacy));
 }
@@ -928,8 +995,8 @@ pwg_compare_legacy(_pwg_media_t *a, /* I - First size */
  */
 
 static int                             /* O - Result of comparison */
-pwg_compare_ppd(_pwg_media_t *a,       /* I - First size */
-                _pwg_media_t *b)       /* I - Second size */
+pwg_compare_ppd(pwg_media_t *a,        /* I - First size */
+                pwg_media_t *b)        /* I - Second size */
 {
   return (strcmp(a->ppd, b->ppd));
 }
@@ -940,13 +1007,90 @@ pwg_compare_ppd(_pwg_media_t *a, /* I - First size */
  */
 
 static int                             /* O - Result of comparison */
-pwg_compare_pwg(_pwg_media_t *a,       /* I - First size */
-                _pwg_media_t *b)       /* I - Second size */
+pwg_compare_pwg(pwg_media_t *a,        /* I - First size */
+                pwg_media_t *b)        /* I - Second size */
 {
   return (strcmp(a->pwg, b->pwg));
 }
 
 
+/*
+ * 'pwg_format_inches()' - Convert and format PWG units as inches.
+ */
+
+static char *                          /* O - String */
+pwg_format_inches(char   *buf,         /* I - Buffer */
+                 size_t bufsize,       /* I - Size of buffer */
+                 int    val)           /* I - Value in hundredths of millimeters */
+{
+  int  thousandths,                    /* Thousandths of inches */
+       integer,                        /* Integer portion */
+       fraction;                       /* Fractional portion */
+
+
+ /*
+  * Convert hundredths of millimeters to thousandths of inches and round to
+  * the nearest thousandth.
+  */
+
+  thousandths = (val * 1000 + 1270) / 2540;
+  integer     = thousandths / 1000;
+  fraction    = thousandths % 1000;
+
+ /*
+  * Format as a pair of integers (avoids locale stuff), avoiding trailing
+  * zeros...
+  */
+
+  if (fraction == 0)
+    snprintf(buf, bufsize, "%d", integer);
+  else if (fraction % 10)
+    snprintf(buf, bufsize, "%d.%03d", integer, fraction);
+  else if (fraction % 100)
+    snprintf(buf, bufsize, "%d.%02d", integer, fraction / 10);
+  else
+    snprintf(buf, bufsize, "%d.%01d", integer, fraction / 100);
+
+  return (buf);
+}
+
+
+/*
+ * 'pwg_format_millimeters()' - Convert and format PWG units as millimeters.
+ */
+
+static char *                          /* O - String */
+pwg_format_millimeters(char   *buf,    /* I - Buffer */
+                      size_t bufsize,  /* I - Size of buffer */
+                      int    val)      /* I - Value in hundredths of millimeters */
+{
+  int  integer,                        /* Integer portion */
+       fraction;                       /* Fractional portion */
+
+
+ /*
+  * Convert hundredths of millimeters to integer and fractional portions.
+  */
+
+  integer     = val / 100;
+  fraction    = val % 100;
+
+ /*
+  * Format as a pair of integers (avoids locale stuff), avoiding trailing
+  * zeros...
+  */
+
+  if (fraction == 0)
+    snprintf(buf, bufsize, "%d", integer);
+  else if (fraction % 10)
+    snprintf(buf, bufsize, "%d.%02d", integer, fraction);
+  else
+    snprintf(buf, bufsize, "%d.%01d", integer, fraction / 10);
+
+  return (buf);
+}
+
+
 /*
  * End of "$Id$".
  */
index 33361c1c04f59a53fe28d5ba4019b0c445a3eef4..ad097bf531b96387cdf4b279c480bdf43575f6e1 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Private PWG media API definitions for CUPS.
  *
- *   Copyright 2009-2012 by Apple Inc.
+ *   Copyright 2009-2013 by Apple Inc.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Apple Inc. and are protected by Federal copyright
@@ -35,63 +35,36 @@ extern "C" {
 
 
 /*
- * Macros...
+ * Deprecated stuff for prior users of the private PWG media API...
  */
 
-/* Convert from points to 2540ths */
-#  define _PWG_FROMPTS(n)      (int)(((n) * 2540 + 36) / 72)
-/* Convert from 2540ths to points */
-#  define _PWG_TOPTS(n)                ((n) * 72.0 / 2540.0)
-
-
-/*
- * Types and structures...
- */
-
-typedef struct _pwg_map_s              /**** Map element - PPD to/from PWG */
-{
-  char         *pwg,                   /* PWG media keyword */
-               *ppd;                   /* PPD option keyword */
-} _pwg_map_t;
-
-typedef struct _pwg_media_s            /**** Common media size data ****/
-{
-  const char   *pwg,                   /* PWG 5101.1 "self describing" name */
-               *legacy,                /* IPP/ISO legacy name */
-               *ppd;                   /* Standard Adobe PPD name */
-  int          width,                  /* Width in 2540ths */
-               length;                 /* Length in 2540ths */
-} _pwg_media_t;
-
-typedef struct _pwg_size_s             /**** Size element - PPD to/from PWG */
-{
-  _pwg_map_t   map;                    /* Map element */
-  int          width,                  /* Width in 2540ths */
-               length,                 /* Length in 2540ths */
-               left,                   /* Left margin in 2540ths */
-               bottom,                 /* Bottom margin in 2540ths */
-               right,                  /* Right margin in 2540ths */
-               top;                    /* Top margin in 2540ths */
-} _pwg_size_t;
+#  ifndef _CUPS_NO_DEPRECATED
+typedef struct pwg_map_s _pwg_map_t;
+typedef struct pwg_media_s _pwg_media_t;
+typedef struct pwg_size_s _pwg_size_t;
+#  endif /* _CUPS_NO_DEPRECATED */
 
 
 /*
  * Functions...
  */
 
-extern char            *_pwgFormatInches(char *buf, size_t bufsize, int val);
-extern char            *_pwgFormatMillimeters(char *buf, size_t bufsize,
-                                              int val);
 extern void            _pwgGenerateSize(char *keyword, size_t keysize,
                                         const char *prefix,
                                         const char *name,
-                                        int width, int length);
-extern int             _pwgInitSize(_pwg_size_t *size, ipp_t *job,
-                                    int *margins_set);
-extern _pwg_media_t    *_pwgMediaForLegacy(const char *legacy);
-extern _pwg_media_t    *_pwgMediaForPPD(const char *ppd);
-extern _pwg_media_t    *_pwgMediaForPWG(const char *pwg);
-extern _pwg_media_t    *_pwgMediaForSize(int width, int length);
+                                        int width, int length)
+                                        _CUPS_INTERNAL_MSG("Use pwgFormatSizeName instead.");
+extern int             _pwgInitSize(pwg_size_t *size, ipp_t *job,
+                                    int *margins_set)
+                                    _CUPS_INTERNAL_MSG("Use pwgInitSize instead.");
+extern pwg_media_t     *_pwgMediaForLegacy(const char *legacy)
+                           _CUPS_INTERNAL_MSG("Use pwgMediaForLegacy instead.");
+extern pwg_media_t     *_pwgMediaForPPD(const char *ppd)
+                           _CUPS_INTERNAL_MSG("Use pwgMediaForPPD instead.");
+extern pwg_media_t     *_pwgMediaForPWG(const char *pwg)
+                           _CUPS_INTERNAL_MSG("Use pwgMediaForPWG instead.");
+extern pwg_media_t     *_pwgMediaForSize(int width, int length)
+                           _CUPS_INTERNAL_MSG("Use pwgMediaForSize instead.");
 
 #  ifdef __cplusplus
 }
diff --git a/cups/pwg.h b/cups/pwg.h
new file mode 100644 (file)
index 0000000..505778e
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * "$Id$"
+ *
+ *   PWG media API definitions for CUPS.
+ *
+ *   Copyright 2009-2013 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 "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ *   This file is subject to the Apple OS-Developed Software exception.
+ */
+
+#ifndef _CUPS_PWG_H_
+#  define _CUPS_PWG_H_
+
+
+/*
+ * C++ magic...
+ */
+
+#  ifdef __cplusplus
+extern "C" {
+#  endif /* __cplusplus */
+
+
+/*
+ * Macros...
+ */
+
+/* Convert from points to hundredths of millimeters */
+#  define PWG_FROM_POINTS(n)   (int)(((n) * 2540 + 36) / 72)
+/* Convert from hundredths of millimeters to points */
+#  define PWG_TO_POINTS(n)     ((n) * 72.0 / 2540.0)
+
+
+/*
+ * Types and structures...
+ */
+
+typedef struct pwg_map_s               /**** Map element - PPD to/from PWG */
+{
+  char         *pwg,                   /* PWG media keyword */
+               *ppd;                   /* PPD option keyword */
+} pwg_map_t;
+
+typedef struct pwg_media_s             /**** Common media size data ****/
+{
+  const char   *pwg,                   /* PWG 5101.1 "self describing" name */
+               *legacy,                /* IPP/ISO legacy name */
+               *ppd;                   /* Standard Adobe PPD name */
+  int          width,                  /* Width in 2540ths */
+               length;                 /* Length in 2540ths */
+} pwg_media_t;
+
+typedef struct pwg_size_s              /**** Size element - PPD to/from PWG */
+{
+  pwg_map_t    map;                    /* Map element */
+  int          width,                  /* Width in 2540ths */
+               length,                 /* Length in 2540ths */
+               left,                   /* Left margin in 2540ths */
+               bottom,                 /* Bottom margin in 2540ths */
+               right,                  /* Right margin in 2540ths */
+               top;                    /* Top margin in 2540ths */
+} pwg_size_t;
+
+
+/*
+ * Functions...
+ */
+
+extern int             pwgFormatSizeName(char *keyword, size_t keysize,
+                                         const char *prefix, const char *name,
+                                         int width, int length,
+                                         const char *units) _CUPS_API_1_7;
+extern int             pwgInitSize(pwg_size_t *size, ipp_t *job,
+                                   int *margins_set) _CUPS_API_1_7;
+extern pwg_media_t     *pwgMediaForLegacy(const char *legacy) _CUPS_API_1_7;
+extern pwg_media_t     *pwgMediaForPPD(const char *ppd) _CUPS_API_1_7;
+extern pwg_media_t     *pwgMediaForPWG(const char *pwg) _CUPS_API_1_7;
+extern pwg_media_t     *pwgMediaForSize(int width, int length) _CUPS_API_1_7;
+
+#  ifdef __cplusplus
+}
+#  endif /* __cplusplus */
+
+#endif /* !_CUPS_PWG_H_ */
+
+/*
+ * End of "$Id$".
+ */
index a352f9ffc9192b6c1ae1be3ecb1799be2483a3b7..b3d5cead52fddfcca1949036e30e32e1639552a1 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   PWG test program for CUPS.
  *
- *   Copyright 2009-2012 by Apple Inc.
+ *   Copyright 2009-2013 by Apple Inc.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Apple Inc. and are protected by Federal copyright
@@ -49,7 +49,7 @@ main(int  argc,                               /* I - Number of command-line args */
   const char   *ppdfile;               /* PPD filename */
   ppd_file_t   *ppd;                   /* PPD file */
   _ppd_cache_t *pc;                    /* PPD cache and PWG mapping data */
-  _pwg_media_t *pwgmedia;              /* PWG media size */
+  pwg_media_t  *pwgmedia;              /* PWG media size */
 
 
   status = 0;
@@ -151,8 +151,8 @@ main(int  argc,                             /* I - Number of command-line args */
     puts("PASS");
   }
 
-  fputs("_pwgMediaForPWG(\"iso_a4_210x297mm\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForPWG("iso_a4_210x297mm")) == NULL)
+  fputs("pwgMediaForPWG(\"iso_a4_210x297mm\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPWG("iso_a4_210x297mm")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -170,8 +170,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForLegacy(\"na-letter\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForLegacy("na-letter")) == NULL)
+  fputs("pwgMediaForLegacy(\"na-letter\"): ", stdout);
+  if ((pwgmedia = pwgMediaForLegacy("na-letter")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -189,8 +189,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForPPD(\"4x6\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForPPD("4x6")) == NULL)
+  fputs("pwgMediaForPPD(\"4x6\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPPD("4x6")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -208,8 +208,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForPPD(\"10x15cm\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForPPD("10x15cm")) == NULL)
+  fputs("pwgMediaForPPD(\"10x15cm\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPPD("10x15cm")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -227,8 +227,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForPPD(\"Custom.10x15cm\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForPPD("Custom.10x15cm")) == NULL)
+  fputs("pwgMediaForPPD(\"Custom.10x15cm\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPPD("Custom.10x15cm")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -246,8 +246,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForSize(29700, 42000): ", stdout);
-  if ((pwgmedia = _pwgMediaForSize(29700, 42000)) == NULL)
+  fputs("pwgMediaForSize(29700, 42000): ", stdout);
+  if ((pwgmedia = pwgMediaForSize(29700, 42000)) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -260,8 +260,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForSize(9842, 19050): ", stdout);
-  if ((pwgmedia = _pwgMediaForSize(9842, 19050)) == NULL)
+  fputs("pwgMediaForSize(9842, 19050): ", stdout);
+  if ((pwgmedia = pwgMediaForSize(9842, 19050)) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -274,8 +274,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     printf("PASS (%s)\n", pwgmedia->pwg);
 
-  fputs("_pwgMediaForSize(9800, 19000): ", stdout);
-  if ((pwgmedia = _pwgMediaForSize(9800, 19000)) == NULL)
+  fputs("pwgMediaForSize(9800, 19000): ", stdout);
+  if ((pwgmedia = pwgMediaForSize(9800, 19000)) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -361,9 +361,9 @@ test_ppd_cache(_ppd_cache_t *pc,    /* I - PWG mapping data */
   int          i,                      /* Looping var */
                status = 0;             /* Return status */
   _ppd_cache_t *pc2;                   /* Loaded data */
-  _pwg_size_t  *size,                  /* Size from original */
+  pwg_size_t   *size,                  /* Size from original */
                *size2;                 /* Size from saved */
-  _pwg_map_t   *map,                   /* Map from original */
+  pwg_map_t    *map,                   /* Map from original */
                *map2;                  /* Map from saved */
 
 
index 9487fe8d3489ae3aa6ad431efa39635c2e7de94f..bc07bdd73b615afcbb87b4ae5751a10a57bac707 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   PPD test program for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -3210,11 +3210,11 @@ check_sizes(ppd_file_t *ppd,            /* I - PPD file */
     {
       is_ok          = 1;
       width_2540ths  = (size->length > size->width) ?
-                           _PWG_FROMPTS(size->width) :
-                          _PWG_FROMPTS(size->length);
+                           PWG_FROM_POINTS(size->width) :
+                          PWG_FROM_POINTS(size->length);
       length_2540ths = (size->length > size->width) ?
-                           _PWG_FROMPTS(size->length) :
-                          _PWG_FROMPTS(size->width);
+                           PWG_FROM_POINTS(size->length) :
+                          PWG_FROM_POINTS(size->width);
       pwg_media      = _pwgMediaForSize(width_2540ths, length_2540ths);
 
       if (pwg_media &&