//
// "$Id$"
//
-// PPD file merge utility for the CUPS PPD Compiler.
+// PPD file merge utility for the CUPS PPD Compiler.
//
-// Copyright 2007-2011 by Apple Inc.
-// Copyright 2002-2007 by Easy Software Products.
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 2002-2007 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/".
-//
-// Contents:
-//
-// main() - Main entry for the PPD merge utility.
-// ppd_locale() - Return the locale associated with a PPD file.
-// usage() - Show usage and exit.
+// 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/".
//
//
ppd_status_t status; // PPD open status
int curline, // Current line
linenum; // Line number
-
-
+
+
status = ppdLastError(&linenum);
-
+
_cupsLangPrintf(stderr,
_("%s: Unable to open PPD file: %s on line %d."),
"ppdmerge", ppdErrorString(status), linenum);
cupsFileRewind(infile);
-
+
line[0] = '\0';
curline = 0;
-
+
while (cupsFileGets(infile, line, sizeof(line)))
{
curline ++;
cupsFileClose(infile);
return (1);
}
-
+
// Figure out the locale...
if ((locale = ppd_locale(ppd)) == NULL)
{
languages = _ppdGetLanguages(ppd);
if (outname && !strcmp(inname, outname))
- {
+ {
// Rename input filename so that we don't overwrite it...
char bckname[1024]; // Backup filename
-
-
+
+
snprintf(bckname, sizeof(bckname), "%s.bck", inname);
-
+
if (rename(inname, bckname))
{
_cupsLangPrintf(stderr,
argv[i]);
ppdClose(ppd);
}
-
+
// Close and move on...
cupsFileClose(infile);
}
static const char * // O - Locale string
ppd_locale(ppd_file_t *ppd) // I - PPD file
{
- int i, // Looping var
- vlen; // Length of LanguageVersion string
+ int i; // Looping var
+ size_t vlen; // Length of LanguageVersion string
static char locale[255]; // Locale string
static struct // LanguageVersion translation table
{
{
vlen = strlen(languages[i].version);
- if (!strncasecmp(ppd->lang_version, languages[i].version, vlen))
+ if (!_cups_strncasecmp(ppd->lang_version, languages[i].version, vlen))
{
if (ppd->lang_version[vlen] == '-' ||
ppd->lang_version[vlen] == '_')