]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/raster.c
Load cups into easysw/current.
[thirdparty/cups.git] / filter / raster.c
index 32155073bfdd49a45babe4be201820f10f914891..77abfcb7923753d595f69fa99f329965975e8203 100644 (file)
@@ -1,27 +1,18 @@
 /*
- * "$Id: raster.c 6274 2007-02-13 21:05:28Z mike $"
+ * "$Id: raster.c 6649 2007-07-11 21:46:42Z mike $"
  *
  *   Raster file routines for the Common UNIX Printing System (CUPS).
  *
+ *   Copyright 2007 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   This file is part of the CUPS Imaging library.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products and are protected by Federal
- *   copyright law.  Distribution and use rights are outlined in the file
- *   "LICENSE.txt" which should have been included with this file.  If this
- *   file is missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   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.
  *
@@ -182,6 +173,8 @@ cupsRasterOpen(int         fd,              /* I - File descriptor */
         r->sync == CUPS_RASTER_REVSYNCv1 ||
         r->sync == CUPS_RASTER_REVSYNCv2)
       r->swapped = 1;
+
+    DEBUG_printf(("r->swapped=%d, r->sync=%08x\n", r->swapped, r->sync));
   }
   else
   {
@@ -547,10 +540,8 @@ cupsRasterWritePixels(cups_raster_t *r,    /* I - Raster stream */
   unsigned     remaining;              /* Bytes remaining */
 
 
-#ifdef DEBUG
-  fprintf(stderr, "cupsRasterWritePixels(r=%p, p=%p, len=%u), remaining=%u\n",
-          r, p, len, r->remaining);
-#endif /* DEBUG */
+  DEBUG_printf(("cupsRasterWritePixels(r=%p, p=%p, len=%u), remaining=%u\n",
+               r, p, len, r->remaining));
 
   if (r == NULL || r->mode != CUPS_RASTER_WRITE || r->remaining == 0)
     return (0);
@@ -673,12 +664,7 @@ static unsigned                            /* O - 1 on success, 0 on fail */
 cups_raster_read_header(
     cups_raster_t *r)                  /* I - Raster stream */
 {
-  int          len;                    /* Number of words to swap */
-  union swap_s                         /* Swapping structure */
-  {
-    unsigned char      b[4];
-    unsigned           v;
-  }            *s;
+  int  len;                            /* Length for read/swap */
 
 
   if (r == NULL || r->mode != CUPS_RASTER_READ)
@@ -707,10 +693,28 @@ cups_raster_read_header(
   */
 
   if (r->swapped)
-    for (len = 81, s = (union swap_s *)&(r->header.AdvanceDistance);
+  {
+    unsigned   *s,                     /* Current word */
+               temp;                   /* Temporary copy */
+
+
+    DEBUG_puts("Swapping header bytes...");
+
+    for (len = 81, s = &(r->header.AdvanceDistance);
         len > 0;
         len --, s ++)
-      s->v = (((((s->b[3] << 8) | s->b[2]) << 8) | s->b[1]) << 8) | s->b[0];
+    {
+      DEBUG_printf(("%08x =>", *s));
+
+      temp = *s;
+      *s   = ((temp & 0xff) << 24) |
+             ((temp & 0xff00) << 8) |
+             ((temp & 0xff0000) >> 8) |
+             ((temp & 0xff000000) >> 24);
+
+      DEBUG_printf((" %08x\n", *s));
+    }
+  }
 
  /*
   * Update the header and row count...
@@ -981,9 +985,7 @@ cups_raster_write(
                        maxrun;         /* Maximum run of 128 * bpp */
 
 
-#ifdef DEBUG
-  fprintf(stderr, "cups_raster_write(r=%p, pixels=%p)\n", r, pixels);
-#endif /* DEBUG */
+  DEBUG_printf(("cups_raster_write(r=%p, pixels=%p)\n", r, pixels));
 
  /*
   * Allocate a write buffer as needed...
@@ -1165,5 +1167,5 @@ cups_write(int                 fd,        /* I - File descriptor */
 
 
 /*
- * End of "$Id: raster.c 6274 2007-02-13 21:05:28Z mike $".
+ * End of "$Id: raster.c 6649 2007-07-11 21:46:42Z mike $".
  */