]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Update libcupsimage to properly use DEBUG_ macros.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 24 Jun 2015 13:28:36 +0000 (13:28 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 24 Jun 2015 13:28:36 +0000 (13:28 +0000)
Add additional debug stuff for raster.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12746 a1ca3aef-8c08-0410-bb20-df032aa958be

filter/error.c
filter/interpret.c
filter/raster.c
filter/testraster.c
xcode/CUPS.xcodeproj/project.pbxproj

index 26d8511d46aceface0c02fe0f95e091345beb4bc..8fca072caa967d421ff25da917c6b91af8636285 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Raster error handling for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
@@ -185,7 +185,7 @@ get_error_buffer(void)
   * Initialize the global data exactly once...
   */
 
-  DEBUG_puts("get_error_buffer()");
+  DEBUG_puts("3get_error_buffer()");
 
   pthread_once(&raster_key_once, raster_init);
 
@@ -196,7 +196,7 @@ get_error_buffer(void)
   if ((buf = (_cups_raster_error_t *)pthread_getspecific(raster_key))
           == NULL)
   {
-    DEBUG_puts("get_error_buffer: allocating memory for thread...");
+    DEBUG_puts("4get_error_buffer: allocating memory for thread.");
 
    /*
     * No, allocate memory as set the pointer for the key...
@@ -205,7 +205,7 @@ get_error_buffer(void)
     buf = calloc(1, sizeof(_cups_raster_error_t));
     pthread_setspecific(raster_key, buf);
 
-    DEBUG_printf(("    buf=%p\n", buf));
+    DEBUG_printf(("4get_error_buffer: buf=%p", buf));
   }
 
  /*
@@ -225,8 +225,7 @@ raster_init(void)
 {
   pthread_key_create(&raster_key, raster_destructor);
 
-  DEBUG_printf(("raster_init(): raster_key=%x(%u)\n", (unsigned)raster_key,
-                (unsigned)raster_key));
+  DEBUG_printf(("3raster_init(): raster_key=%x(%u)", (unsigned)raster_key, (unsigned)raster_key));
 }
 
 
@@ -241,7 +240,7 @@ raster_destructor(void *value)              /* I - Data to free */
                                        /* Error buffer */
 
 
-  DEBUG_printf(("raster_destructor(value=%p)\n", value));
+  DEBUG_printf(("3raster_destructor(value=%p)", value));
 
   if (buf->start)
     free(buf->start);
index 380fa1d5587e2a76d882a1ddc8c7cf9cc5063dcc..c2bdc0315254069f0929ee221c0cc9f914b62247 100644 (file)
@@ -3,7 +3,7 @@
  *
  * PPD command interpreter for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1993-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
@@ -91,8 +91,8 @@ static int            setpagedevice(_cups_ps_stack_t *st,
                                        cups_page_header2_t *h,
                                        int *preferred_bits);
 #ifdef DEBUG
-static void            DEBUG_object(_cups_ps_obj_t *obj);
-static void            DEBUG_stack(_cups_ps_stack_t *st);
+static void            DEBUG_object(const char *prefix, _cups_ps_obj_t *obj);
+static void            DEBUG_stack(const char *prefix, _cups_ps_stack_t *st);
 #endif /* DEBUG */
 
 
@@ -547,8 +547,8 @@ _cupsRasterExecPS(
   while ((obj = scan_ps(st, &codeptr)) != NULL)
   {
 #ifdef DEBUG
-    DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)\n", st->num_objs));
-    DEBUG_object(obj);
+    DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)", st->num_objs));
+    DEBUG_object("_cupsRasterExecPS", obj);
 #endif /* DEBUG */
 
     switch (obj->type)
@@ -561,11 +561,11 @@ _cupsRasterExecPS(
           pop_stack(st);
 
          if (cleartomark_stack(st))
-           _cupsRasterAddError("cleartomark: Stack underflow!\n");
+           _cupsRasterAddError("cleartomark: Stack underflow.\n");
 
 #ifdef DEBUG
-          DEBUG_puts("    dup: ");
-         DEBUG_stack(st);
+          DEBUG_puts("1_cupsRasterExecPS:    dup");
+         DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           break;
 
@@ -577,7 +577,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
             DEBUG_puts("_cupsRasterExecPS: copy");
-           DEBUG_stack(st);
+           DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           }
           break;
@@ -588,7 +588,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
           DEBUG_puts("_cupsRasterExecPS: dup");
-         DEBUG_stack(st);
+         DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           break;
 
@@ -600,7 +600,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
             DEBUG_puts("_cupsRasterExecPS: index");
-           DEBUG_stack(st);
+           DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           }
           break;
@@ -611,7 +611,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
           DEBUG_puts("_cupsRasterExecPS: pop");
-         DEBUG_stack(st);
+         DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           break;
 
@@ -630,7 +630,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
               DEBUG_puts("_cupsRasterExecPS: roll");
-             DEBUG_stack(st);
+             DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
             }
          }
@@ -642,7 +642,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
           DEBUG_puts("_cupsRasterExecPS: setpagedevice");
-         DEBUG_stack(st);
+         DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           break;
 
@@ -653,10 +653,9 @@ _cupsRasterExecPS(
          break;
 
       case CUPS_PS_OTHER :
-          _cupsRasterAddError("Unknown operator \"%s\"!\n", obj->value.other);
+          _cupsRasterAddError("Unknown operator \"%s\".\n", obj->value.other);
          error = 1;
-          DEBUG_printf(("_cupsRasterExecPS: Unknown operator \"%s\"!\n",
-                       obj->value.other));
+          DEBUG_printf(("_cupsRasterExecPS: Unknown operator \"%s\".", obj->value.other));
           break;
     }
 
@@ -675,8 +674,8 @@ _cupsRasterExecPS(
     error_stack(st, "Stack not empty:");
 
 #ifdef DEBUG
-    DEBUG_puts("_cupsRasterExecPS: Stack not empty:");
-    DEBUG_stack(st);
+    DEBUG_puts("_cupsRasterExecPS: Stack not empty");
+    DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
 
     delete_stack(st);
@@ -977,7 +976,7 @@ roll_stack(_cups_ps_stack_t *st,    /* I - Stack */
   int                  n;              /* Index into array */
 
 
-  DEBUG_printf(("    roll_stack(st=%p, s=%d, c=%d)\n", st, s, c));
+  DEBUG_printf(("3roll_stack(st=%p, s=%d, c=%d)", st, s, c));
 
  /*
   * Range check input...
@@ -1435,7 +1434,7 @@ setpagedevice(
   * Now pull /name and value pairs from the dictionary...
   */
 
-  DEBUG_puts("setpagedevice: Dictionary:");
+  DEBUG_puts("3setpagedevice: Dictionary:");
 
   for (obj ++; obj < end; obj ++)
   {
@@ -1450,8 +1449,8 @@ setpagedevice(
     obj ++;
 
 #ifdef DEBUG
-    DEBUG_printf(("setpagedevice: /%s ", name));
-    DEBUG_object(obj);
+    DEBUG_printf(("4setpagedevice: /%s ", name));
+    DEBUG_object("setpagedevice", obj);
 #endif /* DEBUG */
 
    /*
@@ -1601,7 +1600,7 @@ setpagedevice(
       * Ignore unknown name+value...
       */
 
-      DEBUG_printf(("    Unknown name (\"%s\") or value...\n", name));
+      DEBUG_printf(("4setpagedevice: Unknown name (\"%s\") or value...\n", name));
 
       while (obj[1].type != CUPS_PS_NAME && obj < end)
         obj ++;
@@ -1618,91 +1617,92 @@ setpagedevice(
  */
 
 static void
-DEBUG_object(_cups_ps_obj_t *obj)      /* I - Object to print */
+DEBUG_object(const char *prefix,       /* I - Prefix string */
+             _cups_ps_obj_t *obj)      /* I - Object to print */
 {
   switch (obj->type)
   {
     case CUPS_PS_NAME :
-       DEBUG_printf(("/%s\n", obj->value.name));
+       DEBUG_printf(("4%s: /%s\n", prefix, obj->value.name));
        break;
 
     case CUPS_PS_NUMBER :
-       DEBUG_printf(("%g\n", obj->value.number));
+       DEBUG_printf(("4%s: %g\n", prefix, obj->value.number));
        break;
 
     case CUPS_PS_STRING :
-       DEBUG_printf(("(%s)\n", obj->value.string));
+       DEBUG_printf(("4%s: (%s)\n", prefix, obj->value.string));
        break;
 
     case CUPS_PS_BOOLEAN :
        if (obj->value.boolean)
-         DEBUG_puts("true");
+         DEBUG_printf(("4%s: true", prefix));
        else
-         DEBUG_puts("false");
+         DEBUG_printf(("4%s: false", prefix));
        break;
 
     case CUPS_PS_NULL :
-       DEBUG_puts("null");
+       DEBUG_printf(("4%s: null", prefix));
        break;
 
     case CUPS_PS_START_ARRAY :
-       DEBUG_puts("[");
+       DEBUG_printf(("4%s: [", prefix));
        break;
 
     case CUPS_PS_END_ARRAY :
-       DEBUG_puts("]");
+       DEBUG_printf(("4%s: ]", prefix));
        break;
 
     case CUPS_PS_START_DICT :
-       DEBUG_puts("<<");
+       DEBUG_printf(("4%s: <<", prefix));
        break;
 
     case CUPS_PS_END_DICT :
-       DEBUG_puts(">>");
+       DEBUG_printf(("4%s: >>", prefix));
        break;
 
     case CUPS_PS_START_PROC :
-       DEBUG_puts("{");
+       DEBUG_printf(("4%s: {", prefix));
        break;
 
     case CUPS_PS_END_PROC :
-       DEBUG_puts("}");
+       DEBUG_printf(("4%s: }", prefix));
        break;
 
     case CUPS_PS_CLEARTOMARK :
-       DEBUG_puts("--cleartomark--");
+       DEBUG_printf(("4%s: --cleartomark--", prefix));
         break;
 
     case CUPS_PS_COPY :
-       DEBUG_puts("--copy--");
+       DEBUG_printf(("4%s: --copy--", prefix));
         break;
 
     case CUPS_PS_DUP :
-       DEBUG_puts("--dup--");
+       DEBUG_printf(("4%s: --dup--", prefix));
         break;
 
     case CUPS_PS_INDEX :
-       DEBUG_puts("--index--");
+       DEBUG_printf(("4%s: --index--", prefix));
         break;
 
     case CUPS_PS_POP :
-       DEBUG_puts("--pop--");
+       DEBUG_printf(("4%s: --pop--", prefix));
         break;
 
     case CUPS_PS_ROLL :
-       DEBUG_puts("--roll--");
+       DEBUG_printf(("4%s: --roll--", prefix));
         break;
 
     case CUPS_PS_SETPAGEDEVICE :
-       DEBUG_puts("--setpagedevice--");
+       DEBUG_printf(("4%s: --setpagedevice--", prefix));
         break;
 
     case CUPS_PS_STOPPED :
-       DEBUG_puts("--stopped--");
+       DEBUG_printf(("4%s: --stopped--", prefix));
         break;
 
     case CUPS_PS_OTHER :
-       DEBUG_printf(("--%s--\n", obj->value.other));
+       DEBUG_printf(("4%s: --%s--", prefix, obj->value.other));
        break;
   }
 }
@@ -1713,14 +1713,15 @@ DEBUG_object(_cups_ps_obj_t *obj)       /* I - Object to print */
  */
 
 static void
-DEBUG_stack(_cups_ps_stack_t *st)      /* I - Stack */
+DEBUG_stack(const char       *prefix,  /* I - Prefix string */
+            _cups_ps_stack_t *st)      /* I - Stack */
 {
   int                  c;              /* Looping var */
   _cups_ps_obj_t       *obj;           /* Current object on stack */
 
 
   for (obj = st->objs, c = st->num_objs; c > 0; c --, obj ++)
-    DEBUG_object(obj);
+    DEBUG_object(prefix, obj);
 }
 #endif /* DEBUG */
 
index 66a0d64a24a26c98e9bf9e211445dcf46c9dcc93..ff729a956b3ab70f2885224c037cadb485a74cee 100644 (file)
@@ -50,6 +50,9 @@ struct _cups_raster_s                 /**** Raster stream data ****/
                        *bufptr,        /* Current (read) position in buffer */
                        *bufend;        /* End of current (read) buffer */
   size_t               bufsize;        /* Buffer size */
+#ifdef DEBUG
+  size_t               iocount;        /* Number of bytes read/written */
+#endif /* DEBUG */
 };
 
 
@@ -193,7 +196,7 @@ cupsRasterOpenIO(
         r->sync == CUPS_RASTER_REVSYNCv2)
       r->swapped = 1;
 
-    DEBUG_printf(("r->swapped=%d, r->sync=%08x\n", r->swapped, r->sync));
+    DEBUG_printf(("1cupsRasterOpenIO: r->swapped=%d, r->sync=%08x\n", r->swapped, r->sync));
   }
   else
   {
@@ -944,6 +947,8 @@ cups_raster_read_header(
   if (r == NULL || r->mode != CUPS_RASTER_READ)
     return (0);
 
+  DEBUG_printf(("4cups_raster_read_header: r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
+
  /*
   * Get the length of the raster header...
   */
@@ -963,7 +968,7 @@ cups_raster_read_header(
 
   if (cups_raster_read(r, (unsigned char *)&(r->header), len) < (ssize_t)len)
   {
-    DEBUG_puts("4cups_raster_read_header: EOF");
+    DEBUG_printf(("4cups_raster_read_header: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
     return (0);
   }
 
@@ -1030,6 +1035,10 @@ cups_raster_io(cups_raster_t *r, /* I - Raster stream */
       return (0);
     else if (count < 0)
       return (-1);
+
+#ifdef DEBUG
+    r->iocount += (size_t)count;
+#endif /* DEBUG */
   }
 
   return (total);
@@ -1060,6 +1069,8 @@ cups_raster_read(cups_raster_t *r,        /* I - Raster stream */
   */
 
   count = (ssize_t)(2 * r->header.cupsBytesPerLine);
+  if (count < 65536)
+    count = 65536;
 
   if ((size_t)count > r->bufsize)
   {
@@ -1108,6 +1119,10 @@ cups_raster_read(cups_raster_t *r,       /* I - Raster stream */
 
        r->bufptr = r->buffer;
        r->bufend = r->buffer + remaining;
+
+#ifdef DEBUG
+        r->iocount += (size_t)remaining;
+#endif /* DEBUG */
       }
       else
       {
@@ -1120,6 +1135,10 @@ cups_raster_read(cups_raster_t *r,       /* I - Raster stream */
        if (count <= 0)
          return (0);
 
+#ifdef DEBUG
+        r->iocount += (size_t)count;
+#endif /* DEBUG */
+
        continue;
       }
     }
@@ -1435,7 +1454,12 @@ cups_read_fd(void          *ctx, /* I - File descriptor as pointer */
   while ((count = read(fd, buf, bytes)) < 0)
 #endif /* WIN32 */
     if (errno != EINTR && errno != EAGAIN)
+    {
+      DEBUG_printf(("4cups_read_fd: %s", strerror(errno)));
       return (-1);
+    }
+
+  DEBUG_printf(("4cups_read_fd: Returning %d bytes.", (int)count));
 
   return (count);
 }
index efecfddd309d913fc2fdd11b1ac9b4653bac97d7..42f377c2f6d2b58e50bfaa3f5d50fc18d316d3b3 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Raster test program routines for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
index 37c0a31101fcd5af687746741fed2ac3485728b4..6f85ea915268045a901fe26ea58a6ca1a16db7d5 100644 (file)
                278C58E8136B64B000836530 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
                27A0347B1A8BDB1300650675 /* lpadmin */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lpadmin; sourceTree = BUILT_PRODUCTS_DIR; };
                27D3037D134148CB00F022B1 /* libcups2.def */ = {isa = PBXFileReference; lastKnownFileType = text; name = libcups2.def; path = ../cups/libcups2.def; sourceTree = "<group>"; };
+               27F89DA21B3AC43B00E5A4B7 /* testraster.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testraster.c; path = ../filter/testraster.c; sourceTree = "<group>"; };
                720DD6C21358FD5F0064AA82 /* snmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = snmp; sourceTree = BUILT_PRODUCTS_DIR; };
                720DD6D21358FDDE0064AA82 /* snmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = snmp.c; path = ../backend/snmp.c; sourceTree = "<group>"; };
                72220EAE1333047D00FCA411 /* libcups.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcups.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
                                727EF049192E3544001EF690 /* testoptions.c */,
                                727EF04A192E3544001EF690 /* testppd.c */,
                                727EF04B192E3544001EF690 /* testpwg.c */,
+                               27F89DA21B3AC43B00E5A4B7 /* testraster.c */,
                                727EF04C192E3544001EF690 /* testsnmp.c */,
                                727EF04E192E3602001EF690 /* testspeed.c */,
                                727EF04F192E3602001EF690 /* testsub.c */,