//
// PPD file compiler main entry for the CUPS PPD Compiler.
//
-// Copyright 2007 by Apple Inc.
+// Copyright 2007-2008 by Apple Inc.
// Copyright 2002-2007 by Easy Software Products.
//
// These coded instructions, statements, and computer programs are the
// Include necessary headers...
//
-#include "ppdc.h"
+#include "ppdc-private.h"
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
ppdcArray *locales; // List of locales
+ _cupsSetLocale(argv);
+
// Scan the command-line...
catalog = NULL;
comp = 0;
usage();
if (verbose > 1)
- printf("ppdc: Adding include directory \"%s\"...\n", argv[i]);
+ _cupsLangPrintf(stdout,
+ _("ppdc: Adding include directory \"%s\"...\n"),
+ argv[i]);
ppdcSource::add_include(argv[i]);
break;
usage();
if (verbose > 1)
- printf("ppdc: Loading messages from \"%s\"...\n", argv[i]);
+ _cupsLangPrintf(stdout,
+ _("ppdc: Loading messages from \"%s\"...\n"),
+ argv[i]);
if (!catalog)
catalog = new ppdcCatalog("en");
if (catalog->load_messages(argv[i]))
{
- fprintf(stderr,
- "ppdc: Unable to load localization file \"%s\" - %s\n",
- argv[i], strerror(errno));
+ _cupsLangPrintf(stderr,
+ _("ppdc: Unable to load localization file "
+ "\"%s\" - %s\n"), argv[i], strerror(errno));
return (1);
}
break;
usage();
if (verbose > 1)
- printf("ppdc: Writing PPD files to directory \"%s\"...\n",
- argv[i]);
+ _cupsLangPrintf(stdout,
+ _("ppdc: Writing PPD files to directory "
+ "\"%s\"...\n"), argv[i]);
outdir = argv[i];
break;
else
{
if (verbose > 1)
- printf("ppdc: Loading messages for locale \"%s\"...\n",
- argv[i]);
+ _cupsLangPrintf(stdout,
+ _("ppdc: Loading messages for locale "
+ "\"%s\"...\n"), argv[i]);
if (catalog)
- delete catalog;
+ catalog->release();
catalog = new ppdcCatalog(argv[i]);
if (catalog->messages->count == 0)
{
- fprintf(stderr,
- "ppdc: Unable to find localization for \"%s\" - %s\n",
- argv[i], strerror(errno));
+ _cupsLangPrintf(stderr,
+ _("ppdc: Unable to find localization for "
+ "\"%s\" - %s\n"), argv[i], strerror(errno));
return (1);
}
}
{
// Open and load the driver info file...
if (verbose > 1)
- printf("ppdc: Loading driver information file \"%s\"...\n", argv[i]);
+ _cupsLangPrintf(stdout,
+ _("ppdc: Loading driver information file \"%s\"...\n"),
+ argv[i]);
src->read_file(argv[i]);
}
{
if (errno != EEXIST)
{
- fprintf(stderr, "ppdc: Unable to create output directory %s: %s\n",
+ _cupsLangPrintf(stderr,
+ _("ppdc: Unable to create output directory %s: %s\n"),
outdir, strerror(errno));
return (1);
}
if (pipe(fds))
{
- fprintf(stderr, "ppdc: Unable to create output pipes: %s\n",
- strerror(errno));
+ _cupsLangPrintf(stderr,
+ _("ppdc: Unable to create output pipes: %s\n"),
+ strerror(errno));
return (1);
}
if ((pid = fork()) == 0)
{
// Child process comes here...
- close(0);
- dup(fds[0]);
+ dup2(fds[0], 0);
close(fds[0]);
close(fds[1]);
execlp("cupstestppd", "cupstestppd", "-", (char *)0);
- fprintf(stderr, "ppdc: Unable to execute cupstestppd: %s\n",
- strerror(errno));
+ _cupsLangPrintf(stderr,
+ _("ppdc: Unable to execute cupstestppd: %s\n"),
+ strerror(errno));
return (errno);
}
else if (pid < 0)
{
- fprintf(stderr, "ppdc: Unable to execute cupstestppd: %s\n",
- strerror(errno));
+ _cupsLangPrintf(stderr,
+ _("ppdc: Unable to execute cupstestppd: %s\n"),
+ strerror(errno));
return (errno);
}
fp = cupsFileOpen(filename, comp ? "w9" : "w");
if (!fp)
{
- fprintf(stderr, "ppdc: Unable to create PPD file \"%s\" - %s.\n",
- filename, strerror(errno));
+ _cupsLangPrintf(stderr,
+ _("ppdc: Unable to create PPD file \"%s\" - %s.\n"),
+ filename, strerror(errno));
return (1);
}
if (verbose)
- printf("ppdc: Writing %s...\n", filename);
+ _cupsLangPrintf(stdout, _("ppdc: Writing %s...\n"), filename);
}
/*
* Write the PPD file...
*/
- if (d->write_ppd_file(fp, catalog, locales, src, le))
+ ppdcArray *templocales = locales;
+
+ if (!templocales)
+ {
+ templocales = new ppdcArray();
+ for (ppdcCatalog *tempcatalog = (ppdcCatalog *)src->po_files->first();
+ tempcatalog;
+ tempcatalog = (ppdcCatalog *)src->po_files->next())
+ {
+ tempcatalog->locale->retain();
+ templocales->add(tempcatalog->locale);
+ }
+ }
+
+ if (d->write_ppd_file(fp, catalog, templocales, src, le))
{
cupsFileClose(fp);
return (1);
}
+ if (templocales != locales)
+ templocales->release();
+
cupsFileClose(fp);
}
}
usage();
// Delete the printer driver information...
- delete src;
+ src->release();
// Message catalog...
if (catalog)
- delete catalog;
+ catalog->release();
// Return with no errors.
return (0);
static void
usage(void)
{
- puts("Usage: ppdc [options] filename.drv [ ... filenameN.drv ]");
- puts("Options:");
- puts(" -D name=value Set named variable to value.");
- puts(" -I include-dir Add include directory to search path.");
- puts(" -c catalog.po Load the specified message catalog.");
- puts(" -d output-dir Specify the output directory.");
- puts(" -l lang[,lang,...] Specify the output language(s) (locale).");
- puts(" -m Use the ModelName value as the filename.");
- puts(" -t Test PPDs instead of generating them.");
- puts(" -v Be verbose (more v's for more verbosity).");
- puts(" -z Compress PPD files using GNU zip.");
- puts(" --cr End lines with CR (Mac OS 9).");
- puts(" --crlf End lines with CR + LF (Windows).");
- puts(" --lf End lines with LF (UNIX/Linux/Mac OS X).");
+ _cupsLangPuts(stdout,
+ _("Usage: ppdc [options] filename.drv [ ... filenameN.drv ]\n"
+ "Options:\n"
+ " -D name=value Set named variable to value.\n"
+ " -I include-dir Add include directory to search "
+ "path.\n"
+ " -c catalog.po Load the specified message catalog.\n"
+ " -d output-dir Specify the output directory.\n"
+ " -l lang[,lang,...] Specify the output language(s) "
+ "(locale).\n"
+ " -m Use the ModelName value as the "
+ "filename.\n"
+ " -t Test PPDs instead of generating "
+ "them.\n"
+ " -v Be verbose (more v's for more "
+ "verbosity).\n"
+ " -z Compress PPD files using GNU zip.\n"
+ " --cr End lines with CR (Mac OS 9).\n"
+ " --crlf End lines with CR + LF (Windows).\n"
+ " --lf End lines with LF (UNIX/Linux/Mac "
+ "OS X).\n"));
exit(1);
}