about summary refs log tree commit diff
path: root/converter/pbm/pbmtoppa
diff options
context:
space:
mode:
Diffstat (limited to 'converter/pbm/pbmtoppa')
-rw-r--r--converter/pbm/pbmtoppa/cutswath.c619
-rw-r--r--converter/pbm/pbmtoppa/cutswath.h2
-rw-r--r--converter/pbm/pbmtoppa/pbm.c12
-rw-r--r--converter/pbm/pbmtoppa/ppa.c179
-rw-r--r--converter/pbm/pbmtoppa/ppa.h2
-rw-r--r--converter/pbm/pbmtoppa/ppapbm.h2
6 files changed, 410 insertions, 406 deletions
diff --git a/converter/pbm/pbmtoppa/cutswath.c b/converter/pbm/pbmtoppa/cutswath.c
index d3f15c03..bc7139b9 100644
--- a/converter/pbm/pbmtoppa/cutswath.c
+++ b/converter/pbm/pbmtoppa/cutswath.c
@@ -12,6 +12,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "mallocvar.h"
+#include "pm.h"
+
 #include "ppa.h"
 #include "ppapbm.h"
 #include "cutswath.h"
@@ -20,343 +23,321 @@ extern int Width;
 extern int Height;
 extern int Pwidth;
 
-/* sweep_data->direction must be set already */
-/* Upon successful completion, sweep_data->image_data and
-   sweep_data->nozzle_data have been set to pointers which this routine
-   malloc()'d. */
-/* Upon successful completion, all members of *sweep_data have been set
-   except direction, vertical_pos, and next. */
-/* Returns: 0 if unsuccessful
+
+
+int
+cut_pbm_swath(pbm_stat *       const pbmP,
+              ppa_stat *       const prnP,
+              int              const maxlines,
+              ppa_sweep_data * const sweepDataP) {
+/*----------------------------------------------------------------------------
+   sweepDataP->direction must be set already
+
+   Upon successful completion, sweepDataP->image_data and
+   sweepDataP->nozzle_data have been set to pointers which this routine
+   malloc()'d.
+
+   Upon successful completion, all members of *sweepDataP have been set
+   except direction, vertical_pos, and next.
+
+   Returns: 0 if unsuccessful
             1 if successful, but with non-printing result (end of page)
-            2 if successful, with printing result */
-int 
-cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_data)
-{
-  unsigned char *data, *ppa, *place, *maxplace;
-  int p_width, width8, p_width8;
-  int i, j, left, right, got_nonblank, numlines;
-  int horzpos, hp2;
-  int shift;
-  ppa_nozzle_data nozzles[2];
-
-  ppa = NULL;
-
-  /* shift = 6 if DPI==300  */
-  /* shift = 12 if DPI==600 */ 
-  shift = ( prn->DPI == 300 ? 6:12 ) ;
-  
-  /* safeguard against the user freeing these */
-  sweep_data->image_data  = NULL;
-  sweep_data->nozzle_data = NULL;
-
-  /* read the data from the input file */
-  width8 = (pbm->width + 7) / 8;
- 
-/* 
-  fprintf(stderr,"cutswath(): width=%u\n",pbm->width);
-  fprintf(stderr,"cutswath(): height=%u\n",pbm->height);
-*/
-
-  if ((data=malloc(width8*maxlines)) == NULL)
-  {
-    fprintf(stderr,"cutswath(): could not malloc data storage\n");
-    return 0;
-  }
-
-  /* ignore lines that are above the upper margin */
-  while(pbm->current_line < prn->top_margin)
-    if(!pbm_readline(pbm,data))
-    {
-      fprintf(stderr,"cutswath(): A-could not read top margin\n");
-      free (data); data=NULL;
-      return 0;
+            2 if successful, with printing result
+-----------------------------------------------------------------------------*/
+    int const shift = prnP->DPI == 300 ? 6 : /* DPI=600 */ 12;
+
+    unsigned char *data, *ppa, *place, *maxplace;
+    int pWidth, width8, pWidth8;
+    int i, left, right, gotNonblank, numlines;
+    int horzpos, hp2;
+    ppa_nozzle_data nozzles[2];
+
+    ppa = NULL;
+
+    /* Safeguard against the user freeing these */
+    sweepDataP->image_data  = NULL;
+    sweepDataP->nozzle_data = NULL;
+
+    /* Read the data from the input file */
+    width8 = (pbmP->width + 7) / 8;
+
+    MALLOCARRAY(data, width8 * maxlines);
+    if (!data) {
+        pm_message("could not malloc data storage");
+        return 0;
+    }
+
+    /* Ignore lines that are above the upper margin */
+    while (pbmP->current_line < prnP->top_margin) {
+        if (!pbm_readline(pbmP, data)) {
+            pm_message("could not read top margin");
+            free(data); data=NULL;
+            return 0;
+        }
+    }
+
+    /* Eat all lines that are below the lower margin */
+    if (pbmP->current_line >= Height - prnP->bottom_margin) {
+        while (pbmP->current_line < pbmP->height) {
+            if (!pbm_readline(pbmP, data)) {
+                pm_message("could not clear bottom margin");
+                free(data); data=NULL;
+                return 0;
+            }
+        }
+        free(data); data=NULL;
+        return 1;
     }
 
-  /* eat all lines that are below the lower margin */
-  if(pbm->current_line >= Height - prn->bottom_margin)
-  {
-    while(pbm->current_line < pbm->height)
-      if(!pbm_readline(pbm,data))
-      {
-	fprintf(stderr,"cutswath(): could not clear bottom margin\n");
-	free (data); data=NULL;
-	return 0;
-      }
-    free (data); data=NULL;
-    return 1;
-  }
-
-  left = Pwidth-prn->right_margin/8;
-  right = prn->left_margin/8;
-
-  /* eat all beginning blank lines and then up to maxlines or lower margin */
-  got_nonblank=numlines=0;
-  while( (pbm->current_line < Height-prn->bottom_margin) &&
-	 (numlines < maxlines) )
-  {
-    if(!pbm_readline(pbm,data+width8*numlines))
-    {
-      fprintf(stderr,"cutswath(): B-could not read next line\n");
-      free (data); data=NULL;
-      return 0;
+    left  = Pwidth - prnP->right_margin / 8;
+    right = prnP->left_margin / 8;
+
+    /* Eat all beginning blank lines and then up to maxlines or lower margin */
+    gotNonblank = numlines = 0;
+    while ((pbmP->current_line < Height-prnP->bottom_margin) &&
+           (numlines < maxlines)) {
+        if (!pbm_readline(pbmP, data + width8 * numlines)) {
+            pm_message("could not read next line");
+            free(data); data=NULL;
+            return 0;
+        }
+        if (!gotNonblank) {
+            unsigned int j;
+            for (j = prnP->left_margin / 8; j < left; ++j) {
+                if (data[j]) {
+                  left = j;
+                  gotNonblank=1;
+                  break;
+                }
+            }
+        }
+        if (gotNonblank) {
+            int newleft, newright;
+            unsigned int i;
+
+            /* Find left-most nonblank */
+            for (i = prnP->left_margin / 8, newleft = left; i < left; ++i) {
+                if (data[width8 * numlines + i]) {
+                    newleft = i;
+                    break;
+                }
+            }
+            /* Find right-most nonblank */
+            for (i = Pwidth - prnP->right_margin / 8 - 1, newright = right;
+                 i >= right;
+                 --i) {
+              if (data[width8 * numlines + i]) {
+                  newright = i;
+                  break;
+              }
+            }
+            ++numlines;
+
+            if (newright < newleft) {
+                pm_message("Ack! newleft=%d, newright=%d, left=%d, right=%d",
+                           newleft, newright, left, right);
+                free(data); data=NULL;
+                return 0;
+            }
+
+            /* If the next line might push us over the buffer size, stop here!
+               ignore this test for the 720 right now.  Will add better
+               size-guessing for compressed data in the near future!
+            */
+            if (numlines % 2 == 1 && prnP->version != HP720) {
+                int l = newleft;
+                int r = newright;
+                int w;
+
+                --l;
+                r += 2;
+                l *= 8;
+                r *= 8;
+                w = r-l;
+                w = (w + 7) / 8;
+
+                if ((w + 2 * shift) * numlines > prnP->bufsize) {
+                    --numlines;
+                    pbm_unreadline(pbmP, data + width8 * numlines);
+                    break;
+                } else {
+                    left  = newleft;
+                    right = newright;
+                }
+            } else {
+                left  = newleft;
+                right = newright;
+            }
+        }
     }
-    if(!got_nonblank)
-      for(j=prn->left_margin/8; j<left; j++)
-	if(data[j])
-	{
-	  left = j;
-	  got_nonblank=1;
-	  break;
-	}
-    if(got_nonblank)
-      {
-	int newleft = left, newright = right;
-
-	/* find left-most nonblank */
-	for (i = prn->left_margin/8; i < left; i++)
-	  if (data[width8*numlines+i])
-	    {
-	      newleft = i;
-	      break;
-	    }
-	/* find right-most nonblank */
-	for (i = Pwidth-prn->right_margin/8-1; i >= right; i--)
-	  if (data[width8*numlines+i])
-	    {
-	      newright = i;
-	      break;
-	    }
-	numlines++;
-
-	if (newright < newleft)
-	  {
-	    fprintf (stderr, "Ack! newleft=%d, newright=%d, left=%d, right=%d\n",
-		     newleft, newright, left, right);
-	    free (data); data=NULL;
-	    return 0;
-	  }
-
-	/* if the next line might push us over the buffer size, stop here! */
-	/* ignore this test for the 720 right now.  Will add better */
-	/* size-guessing for compressed data in the near future! */
-	if (numlines % 2 == 1 && prn->version != HP720)
-	  {
-	    int l = newleft, r = newright, w;
-	    
-	    l--;
-	    r+=2;
-	    l*=8;
-	    r*=8;
-	    w = r-l;
-	    w = (w+7)/8;
-	    
-	    if ((w+2*shift)*numlines > prn->bufsize)
-	      {
-		numlines--;
-		pbm_unreadline (pbm, data+width8*numlines);
-		break;
-	      }
-	    else
-	      {
-		left = newleft;
-		right = newright;
-	      }
-	  }
-	else
-	  {
-	    left = newleft;
-	    right = newright;
-	  }
-      }
-  }
-
-  if(!got_nonblank)
-  {
-    /* eat all lines that are below the lower margin */
-    if(pbm->current_line >= Height - prn->bottom_margin)
-    {
-      while(pbm->current_line < pbm->height)
-	if(!pbm_readline(pbm,data))
-	{
-	  fprintf(stderr,"cutswath(): could not clear bottom margin\n");
-	  free (data); data=NULL;
-	  return 0;
-	}
-      free (data); data=NULL;
-      return 1;
+
+    if (!gotNonblank) {
+        /* Eat all lines that are below the lower margin */
+        if (pbmP->current_line >= Height - prnP->bottom_margin) {
+            while (pbmP->current_line < pbmP->height) {
+                if (!pbm_readline(pbmP, data)) {
+                    pm_message("could not clear bottom margin");
+                    free(data); data = NULL;
+                    return 0;
+                }
+            }
+            free(data); data = NULL;
+            return 1;
+        }
+        free(data); data = NULL;
+        return 0; /* error, since didn't get to lower margin, yet blank */
     }
-    free (data); data=NULL;
-    return 0; /* error, since didn't get to lower margin, yet blank */
-  }
-
-  /* make sure numlines is even and >= 2 (b/c we have to pass the printer 
-     HALF of the number of pins used */
-  if (numlines == 1)
-    {
-      /* there's no way that we only have 1 line and not enough memory, so
-	 we're safe to increase numlines here.  Also, the bottom margin should
-	 be > 0 so we have some lines to read */
-      if(!pbm_readline(pbm,data+width8*numlines))
-	{
-	  fprintf(stderr,"cutswath(): C-could not read next line\n");
-	  free (data); data=NULL;
-	  return 0;
-	}
-      numlines++;
+
+    /* Make sure numlines is even and >= 2 (b/c we have to pass the printer
+       HALF of the number of pins used
+    */
+    if (numlines == 1) {
+        /* There's no way that we only have 1 line and not enough memory, so
+           we're safe to increase numlines here.  Also, the bottom margin
+           should be > 0 so we have some lines to read
+        */
+        if (!pbm_readline(pbmP, data + width8 * numlines)) {
+            pm_message("could not read next line");
+            free(data); data = NULL;
+            return 0;
+        }
+        ++numlines;
     }
-  if (numlines % 2 == 1)
-    {
-      /* decrease instead of increasing so we don't max out the buffer */
-      numlines--;
-      pbm_unreadline (pbm, data+width8*numlines);
+    if (numlines % 2 == 1) {
+      /* Decrease instead of increasing so we don't max out the buffer */
+        --numlines;
+        pbm_unreadline(pbmP, data + width8 * numlines);
     }
 
-  /* calculate vertical position */
-  sweep_data->vertical_pos = pbm->current_line;
+    sweepDataP->vertical_pos = pbmP->current_line;
 
-  /* change sweep params */
-  left--;
-  right+=2;
-  left *= 8;
-  right *= 8;
+    /* Change sweep params */
+    left  -= 1;
+    right += 2;
+    left  *= 8;
+    right *= 8;
 
-  /* construct the sweep data */
-  p_width = right - left;
-  p_width8 = (p_width + 7) / 8;
+    /* Construct the sweep data */
+    pWidth = right - left;
+    pWidth8 = (pWidth + 7) / 8;
 
-  if ((ppa = malloc ((p_width8+2*shift) * numlines)) == NULL)
-    {
-      fprintf(stderr,"cutswath(): could not malloc ppa storage\n");
-      free (data); data=NULL;
-      return 0;
+    MALLOCARRAY(ppa, (pWidth8 + 2 * shift) * numlines);
+    if (!ppa) {
+        pm_message("could not malloc ppa storage");
+        free(data); data = NULL;
+        return 0;
     }
 
-  place = ppa;
-
-  /* place 0's in the first 12 columns */
-  memset (place, 0, numlines/2 * shift);
-  place += numlines/2 * shift;
-
-
-  if(sweep_data->direction == right_to_left)  /* right-to-left */
-  {
-    for (i = p_width8+shift-1; i >= 0; i--)
-    {
-      if (i >= shift)
-      {
-	for (j = 0; j < numlines/2; j++)
-	  *place++ = data[j*2*width8 + i + left/8-shift];
-      }
-      else
-      {
-	memset (place, 0, numlines/2);
-	place += numlines/2;
-      }
-
-      if (i < p_width8)
-      {
-	for (j = 0; j < numlines/2; j++)
-	  *place++ = data[(j*2+1)*width8 + i + left/8];
-      }
-      else
-      {
-	memset (place, 0, numlines/2);
-	place += numlines/2;
-      }
-    }
-  }
-  else /* sweep_data->direction == left_to_right */
-  {
-    for (i = 0; i < p_width8+shift; i++)
-    {
-      if (i < p_width8)
-      {
-	for (j = 0; j < numlines/2; j++)
-	  *place++ = data[(j*2+1)*width8 + i + left/8];
-      }
-      else
-      {
-	memset (place, 0, numlines/2);
-	place += numlines/2;
-      }
-
-      if (i >= shift)
-      {
-	for (j = 0; j < numlines/2; j++)
-	  *place++ = data[j*2*width8 + i + left/8 - shift];
-      }
-      else
-      {
-	memset (place, 0, numlines/2);
-	place += numlines/2;
-      }
+    place = ppa;
+
+    /* Place 0's in the first 12 columns */
+    memset(place, 0, numlines/2 * shift);
+    place += numlines/2 * shift;
+
+    if (sweepDataP->direction == right_to_left) { /* right-to-left */
+        int i;
+
+        for (i = pWidth8 + shift - 1; i >= 0; --i) {
+            if (i >= shift) {
+                unsigned int j;
+
+                for (j = 0; j < numlines/2; ++j)
+                    *place++ = data[j * 2 * width8 + i + left / 8 - shift];
+            } else {
+                memset(place, 0, numlines/2);
+                place += numlines/2;
+            }
+
+            if (i < pWidth8) {
+                unsigned int j;
+
+                for (j = 0; j < numlines/2; ++j)
+                    *place++ = data[(j * 2 + 1) * width8 + i + left / 8];
+            } else {
+                memset(place, 0, numlines/2);
+                place += numlines/2;
+            }
+        }
+    } else {
+        /* sweep_data->direction == left_to_right */
+        unsigned int i;
+        for (i = 0; i < pWidth8 + shift; ++i) {
+            if (i < pWidth8) {
+                unsigned int j;
+                for (j = 0; j < numlines/2; ++j)
+                    *place++ = data[(j * 2 + 1) * width8 + i + left / 8];
+            } else {
+                memset(place, 0, numlines/2);
+                place += numlines/2;
+            }
+
+            if (i >= shift) {
+                unsigned int j;
+                for (j = 0; j < numlines/2; ++j)
+                    *place++ = data[j * 2 * width8 + i + left / 8 - shift];
+            } else {
+                memset(place, 0, numlines/2);
+                place += numlines/2;
+            }
+        }
     }
-  }
-
-  /* done with data */
-  free (data); data=NULL;
-
-  /* place 0's in the last 12 columns */
-  memset (place, 0, numlines/2 * shift);
-  place += numlines/2 * shift;
-  maxplace = place;
-
-  /* create sweep data */
-  sweep_data->image_data = ppa;
-  sweep_data->data_size = maxplace-ppa;
-  sweep_data->in_color = False;
-
-  /*
-  horzpos = left*600/prn->DPI + (sweep_data->direction==left_to_right ? 0*600/prn->DPI : 0);
-  */
-  horzpos = left * 600/prn->DPI;
-
-  hp2 = horzpos + ( p_width8 + 2*shift )*8 * 600/prn->DPI;
-  
- 
-  sweep_data->left_margin = horzpos;
-  sweep_data->right_margin = hp2 + prn->marg_diff;
-
-  
-  for (i = 0; i < 2; i++)
-  {
-    nozzles[i].DPI = prn->DPI;
-        
-    nozzles[i].pins_used_d2 = numlines/2;
-    nozzles[i].unused_pins_p1 = 301-numlines;
-    nozzles[i].first_pin = 1;
-    if (i == 0)
-    {
-      nozzles[i].left_margin = horzpos + prn->marg_diff;
-      nozzles[i].right_margin = hp2 + prn->marg_diff;
-      if(sweep_data->direction == right_to_left)
-       /* 0 */
-	nozzles[i].nozzle_delay=prn->right_to_left_delay[0];
-      else
-       /* 6 */
-	nozzles[i].nozzle_delay=prn->left_to_right_delay[0];
-    }
-    else
-    {
-      nozzles[i].left_margin = horzpos;
-      nozzles[i].right_margin = hp2;
-      if(sweep_data->direction == right_to_left)
-       /* 2 */
-	nozzles[i].nozzle_delay=prn->right_to_left_delay[1];
-      else
-       /* 0 */
-	nozzles[i].nozzle_delay=prn->left_to_right_delay[1];
 
+    /* Done with data */
+    free(data); data=NULL;
+
+    /* Place 0's in the last 12 columns */
+    memset(place, 0, numlines/2 * shift);
+    place += numlines/2 * shift;
+    maxplace = place;
+
+    /* Create sweep data */
+    sweepDataP->image_data = ppa;
+    sweepDataP->data_size  = maxplace-ppa;
+    sweepDataP->in_color   = False;
+
+    /*
+      horzpos = left*600/prn->DPI + (sweep_data->direction==left_to_right ? 0*600/prn->DPI : 0);
+    */
+    horzpos = left * 600 / prnP->DPI;
+
+    hp2 = horzpos + (pWidth8 + 2 * shift) * 8 * 600 /prnP->DPI;
+
+    sweepDataP->left_margin  = horzpos;
+    sweepDataP->right_margin = hp2 + prnP->marg_diff;
+
+    for (i = 0; i < 2; ++i) {
+        nozzles[i].DPI = prnP->DPI;
+
+        nozzles[i].pins_used_d2 = numlines/2;
+        nozzles[i].unused_pins_p1 = 301 - numlines;
+        nozzles[i].first_pin = 1;
+
+        if (i == 0) {
+            nozzles[i].left_margin  = horzpos + prnP->marg_diff;
+            nozzles[i].right_margin = hp2 + prnP->marg_diff;
+            if (sweepDataP->direction == right_to_left)  /* 0 */
+
+                nozzles[i].nozzle_delay = prnP->right_to_left_delay[0];
+            else  /* 6 */
+                nozzles[i].nozzle_delay = prnP->left_to_right_delay[0];
+        } else {
+            nozzles[i].left_margin  = horzpos;
+            nozzles[i].right_margin = hp2;
+
+            if (sweepDataP->direction == right_to_left)  /* 2 */
+                nozzles[i].nozzle_delay = prnP->right_to_left_delay[1];
+            else  /* 0 */
+                nozzles[i].nozzle_delay = prnP->left_to_right_delay[1];
+        }
     }
-  }
 
-  sweep_data->nozzle_data_size = 2;
-  sweep_data->nozzle_data = malloc(sizeof(nozzles));
-  if(sweep_data->nozzle_data == NULL)
-    return 0;
-  memcpy(sweep_data->nozzle_data,nozzles,sizeof(nozzles));
+    sweepDataP->nozzle_data_size = 2;
+    MALLOCARRAY_NOFAIL(sweepDataP->nozzle_data, 2);
+    sweepDataP->nozzle_data[0] = nozzles[0];
+    sweepDataP->nozzle_data[1] = nozzles[1];
 
-  return 2;
+    return 2;
 }
 
 
+
diff --git a/converter/pbm/pbmtoppa/cutswath.h b/converter/pbm/pbmtoppa/cutswath.h
index 430558de..347510cf 100644
--- a/converter/pbm/pbmtoppa/cutswath.h
+++ b/converter/pbm/pbmtoppa/cutswath.h
@@ -1,4 +1,4 @@
-int 
+int
 cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,
               ppa_sweep_data* sweep_data);
 
diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c
index ae36e0d2..403ca95c 100644
--- a/converter/pbm/pbmtoppa/pbm.c
+++ b/converter/pbm/pbmtoppa/pbm.c
@@ -15,8 +15,11 @@
 
 #include "pm.h"
 #include "nstring.h"
+
 #include "ppapbm.h"
 
+
+
 int
 make_pbm_stat(pbm_stat * const pbmStatP,
               FILE *     const ifP) {
@@ -61,15 +64,15 @@ make_pbm_stat(pbm_stat * const pbmStatP,
                     if (pbmStatP->width < 0) {
                         pm_message("Image has negative width");
                         retval = 0;
-                    } else if (pbmStatP->width > INT_MAX/2) {
-                        pm_message("Uncomputeably large width: %d",
+                    } else if (pbmStatP->width > INT_MAX/2 - 10) {
+                        pm_message("Uncomputably large width: %d",
                                    pbmStatP->width);
                         retval = 0;
                     } else if (pbmStatP->height < 0) {
                         pm_message("Image has negative height");
                         retval = 0;
-                    } else if (pbmStatP->height > INT_MAX/2) {
-                        pm_message("Uncomputeably large height: %d",
+                    } else if (pbmStatP->height > INT_MAX/2 - 10) {
+                        pm_message("Uncomputably large height: %d",
                                    pbmStatP->height);
                         retval = 0;
                     } else
@@ -193,3 +196,4 @@ pbm_unreadline(pbm_stat * const pbmStatP,
 }
 
 
+
diff --git a/converter/pbm/pbmtoppa/ppa.c b/converter/pbm/pbmtoppa/ppa.c
index 69e7bb79..0f75aa1e 100644
--- a/converter/pbm/pbmtoppa/ppa.c
+++ b/converter/pbm/pbmtoppa/ppa.c
@@ -31,7 +31,7 @@
   (*): responses, autostatus, and pacing are communicated from the printer to
        the computer, and may be safely ignored.
 */
-static void 
+static void
 vlink_put(FILE *fptr, int channel, int length, void *data)
 {
   fputc ('$', fptr);
@@ -40,6 +40,8 @@ vlink_put(FILE *fptr, int channel, int length, void *data)
   fwrite (data, length, 1, fptr);
 }
 
+
+
 /*
   SCP packet structure:
 
@@ -60,9 +62,9 @@ vlink_put(FILE *fptr, int channel, int length, void *data)
        19       1     Handle Media
        18       1     Print Sweep
 */
-static void 
+static void
 scp_put(FILE *fptr, int comspec, int comref, int priority,
-	     int length, void *data)
+             int length, void *data)
 {
   /* encapsulate the vlink_put call in here, to avoid a memcpy */
   fputc ('$', fptr);
@@ -79,6 +81,7 @@ scp_put(FILE *fptr, int comspec, int comref, int priority,
 }
 
 
+
 /*
   SCP2 packet structure:
 
@@ -101,10 +104,10 @@ scp_put(FILE *fptr, int comspec, int comref, int priority,
      0x181      1     Handle Media
      0x180      1     Print Sweep
 */
-static void 
+static void
 scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
-	      unsigned char priority,unsigned short comref,unsigned data_len,
-	      void *data)
+              unsigned char priority,unsigned short comref,unsigned data_len,
+              void *data)
 {
   /* encapsulate the vlink_put call in here, to avoid a memcpy */
   fputc ('$', fptr);
@@ -128,6 +131,7 @@ scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
 }
 
 
+
 /*
   SCP3 packet structure:
 
@@ -152,10 +156,10 @@ scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
      0x181      1     Handle Media
      0x180      1     Print Sweep
 */
-static void 
+static void
 scp3_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
-	      unsigned char priority,unsigned short comref,unsigned data_len,
-	      void *data)
+              unsigned char priority,unsigned short comref,unsigned data_len,
+              void *data)
 {
   /* encapsulate the vlink_put call in here, to avoid a memcpy */
   fputc ('$', fptr);
@@ -179,6 +183,7 @@ scp3_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
 }
 
 
+
 void ppa_init_job(ppa_stat* prn)
 {
   unsigned char init1[8] = { 0x00, 0x00, 0x01, 0xf4, 0x01, 0x00, 0x00, 0x00 };
@@ -211,6 +216,8 @@ void ppa_init_job(ppa_stat* prn)
   }
 }
 
+
+
 void ppa_end_print(ppa_stat* prn)
 {
   unsigned char pageA[4] = { 0x05, 0x01, 0x03, 0x84 };
@@ -219,12 +226,14 @@ void ppa_end_print(ppa_stat* prn)
     scp3_put (prn->fptr, 0x0181, sizeof(pageA), 7, 2, 0, pageA);
 }
 
+
+
 void ppa_init_page(ppa_stat* prn)
 {
   unsigned char pageA[16] = {0x28, 0x2d, 0x00, 0x41, 0x29, 0x2e, 0x00, 0x42,
-			     0x29, 0x2e, 0x00, 0x42, 0x29, 0x2e, 0x00, 0x42 };
+                             0x29, 0x2e, 0x00, 0x42, 0x29, 0x2e, 0x00, 0x42 };
   unsigned char pageB[16] = {0x28, 0x2d, 0x00, 0x41, 0x2d, 0x32, 0x00, 0x46,
-			     0x2d, 0x32, 0x00, 0x46, 0x2d, 0x32, 0x00, 0x46 };
+                             0x2d, 0x32, 0x00, 0x46, 0x2d, 0x32, 0x00, 0x46 };
 
   switch(prn->version)
   {
@@ -242,6 +251,8 @@ void ppa_init_page(ppa_stat* prn)
   }
 }
 
+
+
 void ppa_load_page(ppa_stat* prn)
 {
   unsigned char loadA[4] = {0x01, 0x01, 0x09, 0x60 };
@@ -264,6 +275,8 @@ void ppa_load_page(ppa_stat* prn)
   }
 }
 
+
+
 void ppa_eject_page(ppa_stat* prn)
 {
   unsigned char loadA[4] = {0x02, 0x01, 0x09, 0x60 };
@@ -288,8 +301,8 @@ void ppa_eject_page(ppa_stat* prn)
 
 
 
-static int 
-compress(unsigned char *in, int num_lines_d2, int final_len, 
+static int
+compress(unsigned char *in, int num_lines_d2, int final_len,
              unsigned char *iout)
 {
   unsigned char* out = iout;
@@ -301,89 +314,91 @@ compress(unsigned char *in, int num_lines_d2, int final_len,
       /* Find the size of duplicate values */
       int dup_len = 0;
       while ((i + dup_len < len)
-	     && (in[i + dup_len] == in[i])) {
-	dup_len++;
+             && (in[i + dup_len] == in[i])) {
+        dup_len++;
       }
       /* See if we have enough zeros to be worth compressing. */
       /* I figure one is enough. */
       if ((dup_len >= 1) && (in[i] == 0)) {
-	/* Output run of zeros. */
-	while (dup_len >= 128) {
-	  /* Max is 128 */
-	  *out++ = 0x00;
-	  i += 128;
-	  dup_len -= 128;
-	}
-	if (dup_len >= 1)
-	{
-	  *out++ = dup_len;
-	  i += dup_len;
-	}
-	/* See if we have enough non-zeros to be worth compressing. */
-	/* Here two should be enough. */
+        /* Output run of zeros. */
+        while (dup_len >= 128) {
+          /* Max is 128 */
+          *out++ = 0x00;
+          i += 128;
+          dup_len -= 128;
+        }
+        if (dup_len >= 1)
+        {
+          *out++ = dup_len;
+          i += dup_len;
+        }
+        /* See if we have enough non-zeros to be worth compressing. */
+        /* Here two should be enough. */
       }
       else if (dup_len >= 2)
       {
-	/* Output run of duplicates. */
-	while (dup_len >= 64) {
-	  /* Max is 64 */
-	  *out++ = 0x80;
-	  *out++ = in[i];
-	  i += 64;
-	  dup_len -= 64;
-	}
-	if (dup_len >= 2)
-	{
-	  *out++ = dup_len + 0x80;
-	  *out++ = in[i];
-	  i += dup_len;
-	}
+        /* Output run of duplicates. */
+        while (dup_len >= 64) {
+          /* Max is 64 */
+          *out++ = 0x80;
+          *out++ = in[i];
+          i += 64;
+          dup_len -= 64;
+        }
+        if (dup_len >= 2)
+        {
+          *out++ = dup_len + 0x80;
+          *out++ = in[i];
+          i += dup_len;
+        }
       }
       else
       {
-	/* Look for two zeros, or three duplicates to end literal run. */
-	/* Note this is one more than the number to start a run. */
-	int lit_len = -1;
-	int add_more = 1;
-	while (add_more) {
-	  lit_len++;
-	  if (i + lit_len == len) add_more = 0;
-	  /* Always add more if we are near the very end. */
-	  if (i + lit_len < len - 3) {
-	    char a = in[i + lit_len + 0];
-	    char b = in[i + lit_len + 1];
-	    char c = in[i + lit_len + 2];
-	    /* See if there are enough zeros */
-	    if ((a == b) && (b == 0)) add_more = 0;
-	    /* See if there are enough duplicates */
-	    if ((a == b) && (b == c)) add_more = 0;
-	  }
-	}
-	/* Output run of literals. */
-	while (lit_len >= 64) {
-	  /* Max is 64 */
-	  int j;
-	  *out++ = 0xc0;
-	  for (j = i; j < i + 64; j++) {
-	    *out++ = in[j];
-	  }
-	  i += 64;
-	  lit_len -= 64;
-	} 
-	if (lit_len) {
-	  int j;
-	  *out++ = lit_len + 0xc0;
-	  for (j = i; j < i + lit_len; j++) {
-	    *out++ = in[j];
-	  }
-	  i += lit_len;
-	}
+        /* Look for two zeros, or three duplicates to end literal run. */
+        /* Note this is one more than the number to start a run. */
+        int lit_len = -1;
+        int add_more = 1;
+        while (add_more) {
+          lit_len++;
+          if (i + lit_len == len) add_more = 0;
+          /* Always add more if we are near the very end. */
+          if (i + lit_len < len - 3) {
+            char a = in[i + lit_len + 0];
+            char b = in[i + lit_len + 1];
+            char c = in[i + lit_len + 2];
+            /* See if there are enough zeros */
+            if ((a == b) && (b == 0)) add_more = 0;
+            /* See if there are enough duplicates */
+            if ((a == b) && (b == c)) add_more = 0;
+          }
+        }
+        /* Output run of literals. */
+        while (lit_len >= 64) {
+          /* Max is 64 */
+          int j;
+          *out++ = 0xc0;
+          for (j = i; j < i + 64; j++) {
+            *out++ = in[j];
+          }
+          i += 64;
+          lit_len -= 64;
+        }
+        if (lit_len) {
+          int j;
+          *out++ = lit_len + 0xc0;
+          for (j = i; j < i + lit_len; j++) {
+            *out++ = in[j];
+          }
+          i += lit_len;
+        }
       }
     }
   }
   return out-iout;
 }
 
+
+
 static void __inline__ place_2bytes(int x,unsigned char* y)
 { y[0]=x>>8; y[1]=x; }
 static void __inline__ place_4bytes(int x,unsigned char* y)
@@ -519,9 +534,13 @@ void ppa_print_sweep(ppa_stat* prn,ppa_sweep_data* data)
 }
 
 
+
 void ppa_print_sweeps(ppa_stat* prn,ppa_sweep_data* data)
 {
   ppa_sweep_data* current_sweep;
   for(current_sweep=data; current_sweep; current_sweep=current_sweep->next)
     ppa_print_sweep(prn,current_sweep);
 }
+
+
+
diff --git a/converter/pbm/pbmtoppa/ppa.h b/converter/pbm/pbmtoppa/ppa.h
index 1c7e6f18..cfa18c11 100644
--- a/converter/pbm/pbmtoppa/ppa.h
+++ b/converter/pbm/pbmtoppa/ppa.h
@@ -32,7 +32,7 @@ typedef struct
 } ppa_stat;
 
 typedef struct
-{ 
+{
   int DPI;
   int right;
   int left;
diff --git a/converter/pbm/pbmtoppa/ppapbm.h b/converter/pbm/pbmtoppa/ppapbm.h
index 1ffc093b..10ef4233 100644
--- a/converter/pbm/pbmtoppa/ppapbm.h
+++ b/converter/pbm/pbmtoppa/ppapbm.h
@@ -22,7 +22,7 @@ typedef struct
 } pbm_stat;
 
 int make_pbm_stat(pbm_stat*,FILE*);
-int pbm_readline(pbm_stat*,unsigned char*); 
+int pbm_readline(pbm_stat*,unsigned char*);
   /* reads a single line into char* */
 void pbm_unreadline(pbm_stat*,void*); /* pushes a single line back */