]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/hpgl-input.c
Load cups into easysw/current.
[thirdparty/cups.git] / filter / hpgl-input.c
index d6363e6fb2596bc72b87f2e4f882762bbb1616f1..abfb633104ebe3f33d0e50b1aff3f10d90c83153 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: hpgl-input.c 4494 2005-02-18 02:18:11Z mike $"
+ * "$Id: hpgl-input.c 5150 2006-02-22 19:21:50Z mike $"
  *
  *   HP-GL/2 input processing for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1993-2005 by Easy Software Products.
+ *   Copyright 1993-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Easy Software Products and are protected by Federal
@@ -125,6 +125,9 @@ ParseCommand(FILE    *fp,   /* I - File to read from */
 
         default : /* HP RTL/PCL control */
             while ((i = getc(fp)) != EOF && !isupper(i & 255));
+
+           if (i == EOF)
+             return (-1);
             break;
       }
   } while (ch < ' ');
@@ -133,7 +136,19 @@ ParseCommand(FILE    *fp,  /* I - File to read from */
   name[1] = getc(fp);
   name[2] = '\0';
 
-  if (strcasecmp(name, "LB") == 0)
+  if (name[1] < ' ')
+  {
+   /*
+    * If we get here, then more than likely we are faced with a raw PCL
+    * file which we can't handle - abort!
+    */
+
+    fputs("ERROR: Invalid HP-GL/2 command seen, unable to print file!\n",
+          stderr);
+    return (-1);
+  }
+
+  if (!strcasecmp(name, "LB"))
   {
     bufptr = buf;
     while ((ch = getc(fp)) != StringTerminator)
@@ -145,7 +160,7 @@ ParseCommand(FILE    *fp,   /* I - File to read from */
     p[num_params].value.string = strdup(buf);
     num_params ++;
   }
-  else if (strcasecmp(name, "SM") == 0)
+  else if (!strcasecmp(name, "SM"))
   {
     buf[0] = getc(fp);
     buf[1] = '\0';
@@ -153,7 +168,7 @@ ParseCommand(FILE    *fp,   /* I - File to read from */
     p[num_params].value.string = strdup(buf);
     num_params ++;
   }
-  else if (strcasecmp(name, "DT") == 0)
+  else if (!strcasecmp(name, "DT"))
   {
     if ((buf[0] = getc(fp)) != ';')
     {
@@ -163,7 +178,7 @@ ParseCommand(FILE    *fp,   /* I - File to read from */
       num_params ++;
     }
   }
-  else if (strcasecmp(name, "PE") == 0)
+  else if (!strcasecmp(name, "PE"))
   {
     bufptr = buf;
     while ((ch = getc(fp)) != ';')
@@ -254,5 +269,5 @@ FreeParameters(int     num_params,  /* I - Number of parameters */
 
 
 /*
- * End of "$Id: hpgl-input.c 4494 2005-02-18 02:18:11Z mike $".
+ * End of "$Id: hpgl-input.c 5150 2006-02-22 19:21:50Z mike $".
  */