- Auto-typing of PWG Raster files did not work (STR #4417)
- IPP queues using hardcoded credentials would ask for credentials
(STR #4371)
+ - Dates in non-UTF-8 locales did not display correctly (STR #4388)
CHANGES IN CUPS V1.7.2
*nameptr, /* Pointer into name */
value[16384], /* Value(s) */
*valptr; /* Pointer into value */
- struct tm *date; /* Date information */
fprintf(stderr, "DEBUG2: cgiSetIPPObjectVars(obj=%p, prefix=\"%s\", "
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
if (strncmp(name, "time_at_", 8) == 0)
- {
- time_t t; /* Temporary time value */
-
- t = (time_t)attr->values[i].integer;
- date = localtime(&t);
-
- strftime(valptr, sizeof(value) - (size_t)(valptr - value), "%c", date);
- }
+ _cupsStrDate(valptr, sizeof(value) - (size_t)(valptr - value), (time_t)ippGetInteger(attr, i));
else
- snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
- "%d", attr->values[i].integer);
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value), "%d", ippGetInteger(attr, i));
break;
case IPP_TAG_BOOLEAN :
_cupsSetError\r
_cupsSetLocale\r
_cupsStrAlloc\r
+_cupsStrDate\r
_cupsStrFlush\r
_cupsStrFormatd\r
_cupsStrFree\r
/*
* "$Id$"
*
- * Private string definitions for CUPS.
+ * Private string definitions for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
#ifndef _CUPS_STRING_PRIVATE_H_
# include <ctype.h>
# include <errno.h>
# include <locale.h>
+# include <time.h>
# include "config.h"
struct lconv *loc);
+/*
+ * Date function...
+ */
+
+extern char *_cupsStrDate(char *buf, size_t bufsize, time_t timeval);
+
+
/*
* C++ magic...
*/
*/
#define _CUPS_STRING_C_
-#include "string-private.h"
-#include "debug-private.h"
-#include "thread-private.h"
-#include "array.h"
+#include "cups-private.h"
#include <stddef.h>
#include <limits.h>
}
+/*
+ * '_cupsStrDate()' - Return a localized date for a given time value.
+ *
+ * This function works around the locale encoding issues of strftime...
+ */
+
+char * /* O - Buffer */
+_cupsStrDate(char *buf, /* I - Buffer */
+ size_t bufsize, /* I - Size of buffer */
+ time_t timeval) /* I - Time value */
+{
+ struct tm *dateval; /* Local date/time */
+ char temp[1024]; /* Temporary buffer */
+ _cups_globals_t *cg = _cupsGlobals(); /* Per-thread globals */
+
+
+ if (!cg->lang_default)
+ cg->lang_default = cupsLangDefault();
+
+ dateval = localtime(&timeval);
+
+ if (cg->lang_default->encoding != CUPS_UTF8)
+ {
+ strftime(temp, sizeof(temp), "%c", dateval);
+ cupsCharsetToUTF8((cups_utf8_t *)buf, temp, (int)bufsize, cg->lang_default->encoding);
+ }
+ else
+ strftime(buf, bufsize, "%c", dateval);
+
+ return (buf);
+}
+
+
/*
* '_cupsStrFlush()' - Flush the string pool.
*/
case IPP_TAG_DATE :
{
- time_t vtime; /* Date/Time value */
- struct tm *vdate; /* Date info */
char vstring[256]; /* Formatted time */
for (i = 0, val = attr->values; i < attr->num_values; i ++, val ++)
- {
- vtime = ippDateToTime(val->date);
- vdate = localtime(&vtime);
- strftime(vstring, sizeof(vstring), "%c", vdate);
- printf(" (%s)", vstring);
- }
+ printf(" (%s)", _cupsStrDate(vstring, sizeof(vstring), ippDateToTime(val->date)));
}
putchar('\n');
break;
case IPP_TAG_DATE :
{
- time_t vtime; /* Date/Time value */
- struct tm *vdate; /* Date info */
char vstring[256]; /* Formatted time */
for (i = 0, val = attr->values; i < attr->num_values; i ++, val ++)
- {
- vtime = ippDateToTime(val->date);
- vdate = localtime(&vtime);
- strftime(vstring, sizeof(vstring), "%c", vdate);
- printf(" (%s)", vstring);
- }
+ printf(" (%s)", _cupsStrDate(vstring, sizeof(vstring), ippDateToTime(val->date)));
}
putchar('\n');
break;
*message; /* Printer device URI */
int accepting; /* Accepting requests? */
time_t ptime; /* Printer state time */
- struct tm *pdate; /* Printer state date & time */
char printer_state_time[255];/* Printer state time */
static const char *pattrs[] = /* Attributes we need for printers... */
{
if (match_list(printers, printer))
{
- pdate = localtime(&ptime);
- strftime(printer_state_time, sizeof(printer_state_time), "%c", pdate);
+ _cupsStrDate(printer_state_time, sizeof(printer_state_time), ptime);
if (accepting)
_cupsLangPrintf(stdout, _("%s accepting requests since %s"),
jobid, /* job-id */
size; /* job-k-octets */
time_t jobtime; /* time-at-creation */
- struct tm *jobdate; /* Date & time */
char temp[255], /* Temporary buffer */
date[255]; /* Date buffer */
static const char *jattrs[] = /* Attributes we need for jobs... */
if (match_list(dests, dest) && match_list(users, username))
{
- jobdate = localtime(&jobtime);
snprintf(temp, sizeof(temp), "%s-%d", dest, jobid);
- if (long_status == 3)
- {
- /*
- * Show the consolidated output format for the SGI tools...
- */
+ _cupsStrDate(date, sizeof(date), jobtime);
- if (!strftime(date, sizeof(date), "%b %d %H:%M", jobdate))
- strlcpy(date, "Unknown", sizeof(date));
-
- _cupsLangPrintf(stdout, "%s;%s;%d;%s;%s",
- temp, username ? username : "unknown",
- size, title ? title : "unknown", date);
- }
+ if (ranking)
+ _cupsLangPrintf(stdout, "%3d %-21s %-13s %8.0f %s",
+ rank, temp, username ? username : "unknown",
+ 1024.0 * size, date);
else
+ _cupsLangPrintf(stdout, "%-23s %-13s %8.0f %s",
+ temp, username ? username : "unknown",
+ 1024.0 * size, date);
+ if (long_status)
{
- if (!strftime(date, sizeof(date), "%c", jobdate))
- strlcpy(date, "Unknown", sizeof(date));
-
- if (ranking)
- _cupsLangPrintf(stdout, "%3d %-21s %-13s %8.0f %s",
- rank, temp, username ? username : "unknown",
- 1024.0 * size, date);
- else
- _cupsLangPrintf(stdout, "%-23s %-13s %8.0f %s",
- temp, username ? username : "unknown",
- 1024.0 * size, date);
- if (long_status)
- {
- if (message)
- _cupsLangPrintf(stdout, _("\tStatus: %s"), message);
-
- if (reasons)
- {
- char alerts[1024], /* Alerts string */
- *aptr; /* Pointer into alerts string */
+ if (message)
+ _cupsLangPrintf(stdout, _("\tStatus: %s"), message);
- for (i = 0, aptr = alerts; i < reasons->num_values; i ++)
- {
- if (i)
- snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text);
- else
- strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts));
+ if (reasons)
+ {
+ char alerts[1024], /* Alerts string */
+ *aptr; /* Pointer into alerts string */
- aptr += strlen(aptr);
- }
+ for (i = 0, aptr = alerts; i < reasons->num_values; i ++)
+ {
+ if (i)
+ snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text);
+ else
+ strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts));
- _cupsLangPrintf(stdout, _("\tAlerts: %s"), alerts);
+ aptr += strlen(aptr);
}
- _cupsLangPrintf(stdout, _("\tqueued for %s"), dest);
+ _cupsLangPrintf(stdout, _("\tAlerts: %s"), alerts);
}
+
+ _cupsLangPrintf(stdout, _("\tqueued for %s"), dest);
}
}
ipp_pstate_t pstate; /* Printer state */
cups_ptype_t ptype; /* Printer type */
time_t ptime; /* Printer state time */
- struct tm *pdate; /* Printer state date & time */
int jobid; /* Job ID of current job */
char printer_uri[HTTP_MAX_URI],
/* Printer URI */
* Display it...
*/
- pdate = localtime(&ptime);
- strftime(printer_state_time, sizeof(printer_state_time), "%c", pdate);
+ _cupsStrDate(printer_state_time, sizeof(printer_state_time), ptime);
switch (pstate)
{
7271882313746EA8001A2036 /* rastertolabel.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = rastertolabel.c; path = ../filter/rastertolabel.c; sourceTree = "<group>"; };
7271883C1374AB14001A2036 /* mime-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "mime-private.h"; path = "../scheduler/mime-private.h"; sourceTree = "<group>"; };
727AD5B619100A58009F6862 /* tls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tls.c; path = ../cups/tls.c; sourceTree = "<group>"; };
+ 727EF02F192E3498001EF690 /* admin.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = admin.c; path = "../cgi-bin/admin.c"; sourceTree = "<group>"; };
+ 727EF030192E3498001EF690 /* cgi-private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "cgi-private.h"; path = "../cgi-bin/cgi-private.h"; sourceTree = "<group>"; };
+ 727EF031192E3498001EF690 /* cgi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = cgi.h; path = "../cgi-bin/cgi.h"; sourceTree = "<group>"; };
+ 727EF032192E3498001EF690 /* classes.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = classes.c; path = "../cgi-bin/classes.c"; sourceTree = "<group>"; };
+ 727EF033192E3498001EF690 /* help-index.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "help-index.c"; path = "../cgi-bin/help-index.c"; sourceTree = "<group>"; };
+ 727EF034192E3498001EF690 /* help-index.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "help-index.h"; path = "../cgi-bin/help-index.h"; sourceTree = "<group>"; };
+ 727EF035192E3498001EF690 /* help.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = help.c; path = "../cgi-bin/help.c"; sourceTree = "<group>"; };
+ 727EF036192E3498001EF690 /* html.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = html.c; path = "../cgi-bin/html.c"; sourceTree = "<group>"; };
+ 727EF037192E3498001EF690 /* ipp-var.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "ipp-var.c"; path = "../cgi-bin/ipp-var.c"; sourceTree = "<group>"; };
+ 727EF038192E3498001EF690 /* jobs.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = jobs.c; path = "../cgi-bin/jobs.c"; sourceTree = "<group>"; };
+ 727EF039192E3498001EF690 /* makedocset.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = makedocset.c; path = "../cgi-bin/makedocset.c"; sourceTree = "<group>"; };
+ 727EF03A192E3498001EF690 /* printers.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = printers.c; path = "../cgi-bin/printers.c"; sourceTree = "<group>"; };
+ 727EF03B192E3498001EF690 /* search.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = search.c; path = "../cgi-bin/search.c"; sourceTree = "<group>"; };
+ 727EF03C192E3498001EF690 /* template.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = template.c; path = "../cgi-bin/template.c"; sourceTree = "<group>"; };
+ 727EF03D192E3498001EF690 /* testcgi.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testcgi.c; path = "../cgi-bin/testcgi.c"; sourceTree = "<group>"; };
+ 727EF03E192E3498001EF690 /* testhi.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testhi.c; path = "../cgi-bin/testhi.c"; sourceTree = "<group>"; };
+ 727EF03F192E3498001EF690 /* testtemplate.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testtemplate.c; path = "../cgi-bin/testtemplate.c"; sourceTree = "<group>"; };
+ 727EF040192E3498001EF690 /* var.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = var.c; path = "../cgi-bin/var.c"; sourceTree = "<group>"; };
+ 727EF041192E3544001EF690 /* testadmin.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testadmin.c; path = ../cups/testadmin.c; sourceTree = "<group>"; };
+ 727EF042192E3544001EF690 /* testarray.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testarray.c; path = ../cups/testarray.c; sourceTree = "<group>"; };
+ 727EF043192E3544001EF690 /* testcache.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testcache.c; path = ../cups/testcache.c; sourceTree = "<group>"; };
+ 727EF044192E3544001EF690 /* testconflicts.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testconflicts.c; path = ../cups/testconflicts.c; sourceTree = "<group>"; };
+ 727EF045192E3544001EF690 /* testfile.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testfile.c; path = ../cups/testfile.c; sourceTree = "<group>"; };
+ 727EF046192E3544001EF690 /* testi18n.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testi18n.c; path = ../cups/testi18n.c; sourceTree = "<group>"; };
+ 727EF047192E3544001EF690 /* testipp.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testipp.c; path = ../cups/testipp.c; sourceTree = "<group>"; };
+ 727EF048192E3544001EF690 /* testlang.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testlang.c; path = ../cups/testlang.c; sourceTree = "<group>"; };
+ 727EF049192E3544001EF690 /* testoptions.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testoptions.c; path = ../cups/testoptions.c; sourceTree = "<group>"; };
+ 727EF04A192E3544001EF690 /* testppd.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testppd.c; path = ../cups/testppd.c; sourceTree = "<group>"; };
+ 727EF04B192E3544001EF690 /* testpwg.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testpwg.c; path = ../cups/testpwg.c; sourceTree = "<group>"; };
+ 727EF04C192E3544001EF690 /* testsnmp.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testsnmp.c; path = ../cups/testsnmp.c; sourceTree = "<group>"; };
+ 727EF04D192E3602001EF690 /* testlpd.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testlpd.c; path = ../scheduler/testlpd.c; sourceTree = "<group>"; };
+ 727EF04E192E3602001EF690 /* testspeed.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testspeed.c; path = ../scheduler/testspeed.c; sourceTree = "<group>"; };
+ 727EF04F192E3602001EF690 /* testsub.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testsub.c; path = ../scheduler/testsub.c; sourceTree = "<group>"; };
728FB7E0153600FA005426E1 /* tls-darwin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tls-darwin.c"; path = "../scheduler/tls-darwin.c"; sourceTree = "<group>"; };
728FB7E1153600FA005426E1 /* tls-gnutls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tls-gnutls.c"; path = "../scheduler/tls-gnutls.c"; sourceTree = "<group>"; };
728FB7EC1536161C005426E1 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
273BF6B81333B4A90022CAAB /* tests */ = {
isa = PBXGroup;
children = (
- 2767FC5119266A36000F61D3 /* testdest.c */,
+ 727EF041192E3544001EF690 /* testadmin.c */,
+ 727EF042192E3544001EF690 /* testarray.c */,
+ 727EF043192E3544001EF690 /* testcache.c */,
+ 727EF044192E3544001EF690 /* testconflicts.c */,
273BF6C61333B5370022CAAB /* testcups.c */,
+ 2767FC5119266A36000F61D3 /* testdest.c */,
+ 727EF045192E3544001EF690 /* testfile.c */,
278C58E2136B647200836530 /* testhttp.c */,
+ 727EF046192E3544001EF690 /* testi18n.c */,
+ 727EF047192E3544001EF690 /* testipp.c */,
+ 727EF048192E3544001EF690 /* testlang.c */,
+ 727EF04D192E3602001EF690 /* testlpd.c */,
270CCDBB135E3D3E00007BE2 /* testmime.c */,
+ 727EF049192E3544001EF690 /* testoptions.c */,
+ 727EF04A192E3544001EF690 /* testppd.c */,
+ 727EF04B192E3544001EF690 /* testpwg.c */,
+ 727EF04C192E3544001EF690 /* testsnmp.c */,
+ 727EF04E192E3602001EF690 /* testspeed.c */,
+ 727EF04F192E3602001EF690 /* testsub.c */,
);
name = tests;
sourceTree = "<group>";
sourceTree = "<group>";
wrapsLines = 1;
};
+ 727EF02E192E3461001EF690 /* cgi-bin */ = {
+ isa = PBXGroup;
+ children = (
+ 727EF02F192E3498001EF690 /* admin.c */,
+ 727EF030192E3498001EF690 /* cgi-private.h */,
+ 727EF031192E3498001EF690 /* cgi.h */,
+ 727EF032192E3498001EF690 /* classes.c */,
+ 727EF033192E3498001EF690 /* help-index.c */,
+ 727EF034192E3498001EF690 /* help-index.h */,
+ 727EF035192E3498001EF690 /* help.c */,
+ 727EF036192E3498001EF690 /* html.c */,
+ 727EF037192E3498001EF690 /* ipp-var.c */,
+ 727EF038192E3498001EF690 /* jobs.c */,
+ 727EF039192E3498001EF690 /* makedocset.c */,
+ 727EF03A192E3498001EF690 /* printers.c */,
+ 727EF03B192E3498001EF690 /* search.c */,
+ 727EF03C192E3498001EF690 /* template.c */,
+ 727EF03D192E3498001EF690 /* testcgi.c */,
+ 727EF03E192E3498001EF690 /* testhi.c */,
+ 727EF03F192E3498001EF690 /* testtemplate.c */,
+ 727EF040192E3498001EF690 /* var.c */,
+ );
+ name = "cgi-bin";
+ sourceTree = "<group>";
+ };
72BF96351333042100B1EAD7 = {
isa = PBXGroup;
children = (
72220FB013330B3400FCA411 /* libcupsmime */,
274FF5F41333310400317ECB /* libcupsppdc */,
724378F71333E3CE009631B9 /* backends */,
+ 727EF02E192E3461001EF690 /* cgi-bin */,
274FF67313333B0A00317ECB /* commands */,
72220F5D13330A5A00FCA411 /* cupsd */,
274FF5D513332C2C00317ECB /* daemon */,