]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/client.c
Import CUPS 1.4svn r7023 into easysw/current.
[thirdparty/cups.git] / scheduler / client.c
index f0a1225e51f9b8e85934249dd471b3b53141fd25..f6c106a78039455e17ce82e0051f4e45fb00c914 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: client.c 6799 2007-08-15 19:33:36Z mike $"
+ * "$Id: client.c 6999 2007-09-28 19:46:53Z mike $"
  *
  *   Client routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -3245,11 +3245,11 @@ get_file(cupsd_client_t *con,           /* I  - Client connection */
     snprintf(filename, len, "%s%s", ServerRoot, con->uri + 11);
   else if (!strncmp(con->uri, "/admin/log/", 11))
   {
-    if (!strcmp(con->uri + 11, "access_log") && AccessLog[0] == '/')
+    if (!strncmp(con->uri + 11, "access_log", 10) && AccessLog[0] == '/')
       strlcpy(filename, AccessLog, len);
-    else if (!strcmp(con->uri + 11, "error_log") && ErrorLog[0] == '/')
+    else if (!strncmp(con->uri + 11, "error_log", 9) && ErrorLog[0] == '/')
       strlcpy(filename, ErrorLog, len);
-    else if (!strcmp(con->uri + 11, "page_log") && PageLog[0] == '/')
+    else if (!strncmp(con->uri + 11, "page_log", 8) && PageLog[0] == '/')
       strlcpy(filename, PageLog, len);
     else
       return (NULL);
@@ -4235,6 +4235,7 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
                script_name[1024],      /* SCRIPT_NAME environment variable */
                server_name[1024],      /* SERVER_NAME environment variable */
                server_port[1024];      /* SERVER_PORT environment variable */
+  ipp_attribute_t *attr;               /* attributes-natural-language attribute */
 
 
  /*
@@ -4370,8 +4371,45 @@ pipe_command(cupsd_client_t *con,        /* I - Client connection */
   else
     auth_type[0] = '\0';
 
-  if (con->language)
-    snprintf(lang, sizeof(lang), "LANG=%s.UTF-8", con->language->language);
+  if (con->request &&
+      (attr = ippFindAttribute(con->request, "attributes-natural-language",
+                               IPP_TAG_LANGUAGE)) != NULL)
+  {
+    switch (strlen(attr->values[0].string.text))
+    {
+      default :
+        /*
+         * This is an unknown or badly formatted language code; use
+         * the POSIX locale...
+         */
+
+         strcpy(lang, "LANG=C");
+         break;
+
+      case 2 :
+        /*
+         * Just the language code (ll)...
+         */
+
+         snprintf(lang, sizeof(lang), "LANG=%s.UTF8",
+                  attr->values[0].string.text);
+         break;
+
+      case 5 :
+        /*
+         * Language and country code (ll-cc)...
+         */
+
+         snprintf(lang, sizeof(lang), "LANG=%c%c_%c%c.UTF8",
+                  attr->values[0].string.text[0],
+                  attr->values[0].string.text[1],
+                  toupper(attr->values[0].string.text[3] & 255),
+                  toupper(attr->values[0].string.text[4] & 255));
+         break;
+    }
+  }
+  else if (con->language)
+    snprintf(lang, sizeof(lang), "LANG=%s.UTF8", con->language->language);
   else
     strcpy(lang, "LANG=C");
 
@@ -4614,5 +4652,5 @@ write_pipe(cupsd_client_t *con)           /* I - Client connection */
 
 
 /*
- * End of "$Id: client.c 6799 2007-08-15 19:33:36Z mike $".
+ * End of "$Id: client.c 6999 2007-09-28 19:46:53Z mike $".
  */