]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/pap.c
Merge changes from CUPS 1.3.1.
[thirdparty/cups.git] / backend / pap.c
index 79ce16058ca051cdf18d6bbb9d489a42d71cd719..7f04214fa07100a0465b2289071ec7a2641f9e1b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-* "$Id: pap.c 6559 2007-06-18 21:09:03Z mike $"
+* "$Id: pap.c 6911 2007-09-04 20:35:08Z mike $"
 *
 * © Copyright 2004 Apple Computer, Inc. All rights reserved.
 * 
@@ -242,7 +242,9 @@ int main (int argc, const char * argv[])
     /* Try to open the print file... */
     if ((fp = fopen(argv[6], "rb")) == NULL)
     {
-      fprintf(stderr, "ERROR: unable to open print file \"%s\": %s\n", argv[6], strerror(errno));
+      _cupsLangPrintf(stderr,
+                      _("ERROR: Unable to open print file \"%s\": %s\n"),
+                     argv[6], strerror(errno));
       return (1);
     }
 
@@ -1363,9 +1365,9 @@ static int parseUri(const char* argv0, char* name, char* type, char* zone)
         *resourcePtr,
         *typePtr,
         *options,              /* Pointer to options */
-        optionName[255],       /* Name of option */
-        value[255],            /* Value of option */
-        *ptr;                  /* Pointer into name or value */
+        *optionName,           /* Name of option */
+        *value,                        /* Value of option */
+        sep;                   /* Separator character */
   int   port;                  /* Port number (not used) */
   int   statusInterval;                /* */
 
@@ -1393,53 +1395,54 @@ static int parseUri(const char* argv0, char* name, char* type, char* zone)
 
     while (*options != '\0')
     {
-      /*
+     /*
       * Get the name...
       */
-      for (ptr = optionName; *options && *options != '=' && *options != '+'; )
-        *ptr++ = *options++;
 
-      *ptr = '\0';
-      value[0] = '\0';
+      optionName = options;
 
-      if (*options == '=')
-      {
-        /*
-        * Get the value...
-        */
-        
+      while (*options && *options != '=' && *options != '+' && *options != '&')
         options ++;
-        
-        for (ptr = value; *options && *options != '+';)
-          *ptr++ = *options++;
-
-        *ptr = '\0';
-        
-        if (*options == '+')
-          options ++;
-      }
-      else if (*options == '+')
+
+      if ((sep = *options) != '\0')
+        *options++ = '\0';
+
+      if (sep == '=')
       {
-        options ++;
+       /*
+        * Get the value...
+       */
+
+        value = options;
+
+       while (*options && *options != '+' && *options != '&')
+         options ++;
+
+        if (*options)
+         *options++ = '\0';
       }
+      else
+        value = (char *)"";
 
-      /*
+     /*
       * Process the option...
       */
-      if (strcasecmp(optionName, "waiteof") == 0)
+
+      if (!strcasecmp(optionName, "waiteof"))
       {
-        /*
-        * Set the banner...
+       /*
+        * Wait for the end of the print file?
         */
-        if (strcasecmp(value, "on") == 0 ||
-          strcasecmp(value, "yes") == 0 ||
-          strcasecmp(value, "true") == 0)
+
+        if (!strcasecmp(value, "on") ||
+            !strcasecmp(value, "yes") ||
+            !strcasecmp(value, "true"))
         {
           gWaitEOF = true;
         }
-        else if (strcasecmp(value, "off") == 0 ||
-            strcasecmp(value, "no") == 0 ||
-            strcasecmp(value, "false") == 0)
+        else if (!strcasecmp(value, "off") ||
+                 !strcasecmp(value, "no") ||
+                 !strcasecmp(value, "false"))
         {
           gWaitEOF = false;
         }
@@ -1448,13 +1451,17 @@ static int parseUri(const char* argv0, char* name, char* type, char* zone)
           fprintf(stderr, "WARNING: Boolean expected for waiteof option \"%s\"\n", value);
         }
       }
-      else if (strcasecmp(optionName, "status") == 0)
+      else if (!strcasecmp(optionName, "status"))
       {
+       /*
+        * Set status reporting interval...
+       */
+
         statusInterval = atoi(value);
-        if (value[0] < '0' || value[0] > '9' || 
-          statusInterval < 0)
+        if (value[0] < '0' || value[0] > '9' || statusInterval < 0)
         {
-          fprintf(stderr, "WARNING: number expected for status option \"%s\"\n", value);
+          fprintf(stderr, "WARNING: number expected for status option \"%s\"\n",
+                 value);
         }
         else
         {
@@ -1469,20 +1476,24 @@ static int parseUri(const char* argv0, char* name, char* type, char* zone)
   if (*resourcePtr == '/')
     resourcePtr++;
 
-        /* If the resource has a slash we assume the slash seperates the AppleTalk object
-         * name from the AppleTalk type. If the slash is not present we assume the AppleTalk
-         * type is LaserWriter.
-         */
-        typePtr = strchr(resourcePtr, '/');
-        if (typePtr != NULL) {
-            *typePtr++ = '\0';
-        } else {
-            typePtr = "LaserWriter";
-        }
+ /* If the resource has a slash we assume the slash seperates the AppleTalk object
+  * name from the AppleTalk type. If the slash is not present we assume the AppleTalk
+  * type is LaserWriter.
+  */
+
+  typePtr = strchr(resourcePtr, '/');
+  if (typePtr != NULL)
+  {
+    *typePtr++ = '\0';
+  }
+  else
+  {
+    typePtr = "LaserWriter";
+  }
 
-  removePercentEscapes(hostname,    zone, NBP_NVE_STR_SIZE + 1);
-  removePercentEscapes(resourcePtr,  name, NBP_NVE_STR_SIZE + 1);
-  removePercentEscapes(typePtr,     type, NBP_NVE_STR_SIZE + 1);
+  removePercentEscapes(hostname, zone, NBP_NVE_STR_SIZE + 1);
+  removePercentEscapes(resourcePtr, name, NBP_NVE_STR_SIZE + 1);
+  removePercentEscapes(typePtr, type, NBP_NVE_STR_SIZE + 1);
 
   return 0;
 }