X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=ppdc%2Fppdc-source.cxx;h=8838a298e84351a120c15b66c9b0ffb5a0cb66e4;hb=61515785f7de12d8b2a29090020e684988f89977;hp=ac64a1a30ecbc956e9adea321656465b26046add;hpb=bdd6c45b5e42206a5add7bf770196531dd8ad811;p=thirdparty%2Fcups.git diff --git a/ppdc/ppdc-source.cxx b/ppdc/ppdc-source.cxx index ac64a1a30..8838a298e 100644 --- a/ppdc/ppdc-source.cxx +++ b/ppdc/ppdc-source.cxx @@ -1,9 +1,9 @@ // -// "$Id$" +// "$Id: ppdc-source.cxx 4167 2013-02-04 19:27:13Z msweet $" // // Source class for the CUPS PPD Compiler. // -// Copyright 2007-2008 by Apple Inc. +// Copyright 2007-2013 by Apple Inc. // Copyright 2002-2007 by Easy Software Products. // // These coded instructions, statements, and computer programs are the @@ -19,6 +19,8 @@ // ppdcSource::add_include() - Add an include directory. // ppdcSource::find_driver() - Find a driver. // ppdcSource::find_include() - Find an include file. +// ppdcSource::find_po() - Find a message catalog for the given +// locale. // ppdcSource::find_size() - Find a media size. // ppdcSource::find_variable() - Find a variable. // ppdcSource::get_attr() - Get an attribute. @@ -29,18 +31,19 @@ // ppdcSource::get_color_profile() - Get a color profile definition. // ppdcSource::get_color_space() - Get an old-style colorspace value. // ppdcSource::get_constraint() - Get a constraint. -// ppdcSource::get_custom_size() - Get a custom media size definition -// from a file. +// ppdcSource::get_custom_size() - Get a custom media size definition from +// a file. +// ppdcSource::get_duplex() - Get a duplex option. // ppdcSource::get_filter() - Get a filter. // ppdcSource::get_float() - Get a single floating-point number. // ppdcSource::get_font() - Get a font definition. // ppdcSource::get_generic() - Get a generic old-style option. // ppdcSource::get_group() - Get an option group. // ppdcSource::get_installable() - Get an installable option. -// ppdcSource::get_integer() - Get an integer value from a string. // ppdcSource::get_integer() - Get an integer value from a file. // ppdcSource::get_measurement() - Get a measurement value. // ppdcSource::get_option() - Get an option definition. +// ppdcSource::get_po() - Get a message catalog. // ppdcSource::get_resolution() - Get an old-style resolution option. // ppdcSource::get_simple_profile() - Get a simple color profile definition. // ppdcSource::get_size() - Get a media size definition from a file. @@ -57,17 +60,17 @@ // Include necessary headers... // -#include "ppdc.h" -#include +#include "ppdc-private.h" #include #include #include #include #include "data/epson.h" -#include "data/escp.h" #include "data/hp.h" #include "data/label.h" -#include "data/pcl.h" +#ifndef WIN32 +# include +#endif // !WIN32 // @@ -91,8 +94,12 @@ const char *ppdcSource::driver_types[] = // 'ppdcSource::ppdcSource()' - Load a driver source file. // -ppdcSource::ppdcSource(const char *f) // I - File to read +ppdcSource::ppdcSource(const char *f, // I - File to read + cups_file_t *ffp)// I - File pointer to use + : ppdcShared() { + PPDC_NEW; + filename = new ppdcString(f); base_fonts = new ppdcArray(); drivers = new ppdcArray(); @@ -103,8 +110,35 @@ ppdcSource::ppdcSource(const char *f) // I - File to read cond_current = cond_stack; cond_stack[0] = PPDC_COND_NORMAL; + // Add standard #define variables... +#define MAKE_STRING(x) #x + + vars->add(new ppdcVariable("CUPS_VERSION", MAKE_STRING(CUPS_VERSION))); + vars->add(new ppdcVariable("CUPS_VERSION_MAJOR", MAKE_STRING(CUPS_VERSION_MAJOR))); + vars->add(new ppdcVariable("CUPS_VERSION_MINOR", MAKE_STRING(CUPS_VERSION_MINOR))); + vars->add(new ppdcVariable("CUPS_VERSION_PATCH", MAKE_STRING(CUPS_VERSION_PATCH))); + +#ifdef WIN32 + vars->add(new ppdcVariable("PLATFORM_NAME", "Windows")); + vars->add(new ppdcVariable("PLATFORM_ARCH", "X86")); + +#else + struct utsname name; // uname information + + if (!uname(&name)) + { + vars->add(new ppdcVariable("PLATFORM_NAME", name.sysname)); + vars->add(new ppdcVariable("PLATFORM_ARCH", name.machine)); + } + else + { + vars->add(new ppdcVariable("PLATFORM_NAME", "unknown")); + vars->add(new ppdcVariable("PLATFORM_ARCH", "unknown")); + } +#endif // WIN32 + if (f) - read_file(f); + read_file(f, ffp); } @@ -114,12 +148,14 @@ ppdcSource::ppdcSource(const char *f) // I - File to read ppdcSource::~ppdcSource() { - delete filename; - delete base_fonts; - delete drivers; - delete po_files; - delete sizes; - delete vars; + PPDC_DELETE; + + filename->release(); + base_fonts->release(); + drivers->release(); + po_files->release(); + sizes->release(); + vars->release(); } @@ -151,7 +187,7 @@ ppdcSource::find_driver(const char *f) // I - Driver file name for (d = (ppdcDriver *)drivers->first(); d; d = (ppdcDriver *)drivers->next()) - if (!strcasecmp(f, d->pc_file_name->value)) + if (!_cups_strcasecmp(f, d->pc_file_name->value)) return (d); return (NULL); @@ -187,7 +223,8 @@ ppdcSource::find_include( if (*ptr != '>') { - fprintf(stderr, "ppdc: Invalid #include/#po filename \"%s\"!\n", n); + _cupsLangPrintf(stderr, + _("ppdc: Invalid #include/#po filename \"%s\"."), n); return (0); } @@ -238,7 +275,7 @@ ppdcSource::find_include( // -// 'ppdcSource::find_po()' - Find a message catalog for the given locale... +// 'ppdcSource::find_po()' - Find a message catalog for the given locale. // ppdcCatalog * // O - Message catalog or NULL @@ -250,7 +287,7 @@ ppdcSource::find_po(const char *l) // I - Locale name for (cat = (ppdcCatalog *)po_files->first(); cat; cat = (ppdcCatalog *)po_files->next()) - if (!strcasecmp(l, cat->locale->value)) + if (!_cups_strcasecmp(l, cat->locale->value)) return (cat); return (NULL); @@ -268,7 +305,7 @@ ppdcSource::find_size(const char *s) // I - Size name for (m = (ppdcMediaSize *)sizes->first(); m; m = (ppdcMediaSize *)sizes->next()) - if (!strcasecmp(s, m->name->value)) + if (!_cups_strcasecmp(s, m->name->value)) return (m); return (NULL); @@ -286,7 +323,7 @@ ppdcSource::find_variable(const char *n)// I - Variable name for (v = (ppdcVariable *)vars->first(); v; v = (ppdcVariable *)vars->next()) - if (!strcasecmp(n, v->name->value)) + if (!_cups_strcasecmp(n, v->name->value)) return (v); return (NULL); @@ -312,16 +349,17 @@ ppdcSource::get_attr(ppdcFile *fp, // I - File to read // Attribute name selector value if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected name after %sAttribute on line %d of %s!\n", - loc ? "Loc" : "", fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name after %s on line %d of %s."), + loc ? "LocAttribute" : "Attribute", fp->line, fp->filename); return (0); } if (!get_token(fp, selector, sizeof(selector))) { - fprintf(stderr, - "ppdc: Expected selector after %sAttribute on line %d of %s!\n", - loc ? "Loc" : "", fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected selector after %s on line %d of %s."), + loc ? "LocAttribute" : "Attribute", fp->line, fp->filename); return (0); } @@ -330,14 +368,12 @@ ppdcSource::get_attr(ppdcFile *fp, // I - File to read if (!get_token(fp, value, sizeof(value))) { - fprintf(stderr, - "ppdc: Expected value after %sAttribute on line %d of %s!\n", - loc ? "Loc" : "", fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected value after %s on line %d of %s."), + loc ? "LocAttribute" : "Attribute", fp->line, fp->filename); return (0); } -// printf("name=\"%s\", selector=\"%s\", value=\"%s\"\n", name, selector, value); - return (new ppdcAttr(name, selector, text, value, loc)); } @@ -354,23 +390,25 @@ ppdcSource::get_boolean(ppdcFile *fp) // I - File to read if (!get_token(fp, buffer, sizeof(buffer))) { - fprintf(stderr, "ppdc: Expected boolean value on line %d of %s.\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected boolean value on line %d of %s."), + fp->line, fp->filename); return (-1); } - if (!strcasecmp(buffer, "on") || - !strcasecmp(buffer, "yes") || - !strcasecmp(buffer, "true")) + if (!_cups_strcasecmp(buffer, "on") || + !_cups_strcasecmp(buffer, "yes") || + !_cups_strcasecmp(buffer, "true")) return (1); - else if (!strcasecmp(buffer, "off") || - !strcasecmp(buffer, "no") || - !strcasecmp(buffer, "false")) + else if (!_cups_strcasecmp(buffer, "off") || + !_cups_strcasecmp(buffer, "no") || + !_cups_strcasecmp(buffer, "false")) return (0); else { - fprintf(stderr, "ppdc: Bad boolean value (%s) on line %d of %s.\n", - buffer, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Bad boolean value (%s) on line %d of %s."), + buffer, fp->line, fp->filename); return (-1); } } @@ -393,8 +431,9 @@ ppdcSource::get_choice(ppdcFile *fp) // I - File to read // Choice name/text code if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected choice name/text on line %d of %s.\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected choice name/text on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -405,8 +444,8 @@ ppdcSource::get_choice(ppdcFile *fp) // I - File to read if (!get_token(fp, code, sizeof(code))) { - fprintf(stderr, "ppdc: Expected choice code on line %d of %s.\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, _("ppdc: Expected choice code on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -436,10 +475,9 @@ ppdcSource::get_color_model(ppdcFile *fp) // ColorModel name/text colorspace colororder compression if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, - "ppdc: Expected name/text combination for ColorModel on line " - "%d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name/text combination for ColorModel on " + "line %d of %s."), fp->line, fp->filename); return (NULL); } @@ -450,9 +488,9 @@ ppdcSource::get_color_model(ppdcFile *fp) if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, - "ppdc: Expected colorspace for ColorModel on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected colorspace for ColorModel on line %d of " + "%s."), fp->line, fp->filename); return (NULL); } @@ -461,9 +499,9 @@ ppdcSource::get_color_model(ppdcFile *fp) if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, - "ppdc: Expected color order for ColorModel on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected color order for ColorModel on line %d of " + "%s."), fp->line, fp->filename); return (NULL); } @@ -472,9 +510,9 @@ ppdcSource::get_color_model(ppdcFile *fp) if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, - "ppdc: Expected compression for ColorModel on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected compression for ColorModel on line %d of " + "%s."), fp->line, fp->filename); return (NULL); } @@ -497,12 +535,12 @@ int // O - Color order value ppdcSource::get_color_order( const char *co) // I - Color order string { - if (!strcasecmp(co, "chunked") || - !strcasecmp(co, "chunky")) + if (!_cups_strcasecmp(co, "chunked") || + !_cups_strcasecmp(co, "chunky")) return (CUPS_ORDER_CHUNKED); - else if (!strcasecmp(co, "banded")) + else if (!_cups_strcasecmp(co, "banded")) return (CUPS_ORDER_BANDED); - else if (!strcasecmp(co, "planar")) + else if (!_cups_strcasecmp(co, "planar")) return (CUPS_ORDER_PLANAR); else return (-1); @@ -530,8 +568,10 @@ ppdcSource::get_color_profile( // ColorProfile resolution/mediatype gamma density m00 m01 m02 ... m22 if (!get_token(fp, resolution, sizeof(resolution))) { - fprintf(stderr, "ppdc: Expected resolution/mediatype following ColorProfile on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected resolution/mediatype following " + "ColorProfile on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -557,71 +597,71 @@ int // O - Colorspace value ppdcSource::get_color_space( const char *cs) // I - Colorspace string { - if (!strcasecmp(cs, "w")) + if (!_cups_strcasecmp(cs, "w")) return (CUPS_CSPACE_W); - else if (!strcasecmp(cs, "rgb")) + else if (!_cups_strcasecmp(cs, "rgb")) return (CUPS_CSPACE_RGB); - else if (!strcasecmp(cs, "rgba")) + else if (!_cups_strcasecmp(cs, "rgba")) return (CUPS_CSPACE_RGBA); - else if (!strcasecmp(cs, "k")) + else if (!_cups_strcasecmp(cs, "k")) return (CUPS_CSPACE_K); - else if (!strcasecmp(cs, "cmy")) + else if (!_cups_strcasecmp(cs, "cmy")) return (CUPS_CSPACE_CMY); - else if (!strcasecmp(cs, "ymc")) + else if (!_cups_strcasecmp(cs, "ymc")) return (CUPS_CSPACE_YMC); - else if (!strcasecmp(cs, "cmyk")) + else if (!_cups_strcasecmp(cs, "cmyk")) return (CUPS_CSPACE_CMYK); - else if (!strcasecmp(cs, "ymck")) + else if (!_cups_strcasecmp(cs, "ymck")) return (CUPS_CSPACE_YMCK); - else if (!strcasecmp(cs, "kcmy")) + else if (!_cups_strcasecmp(cs, "kcmy")) return (CUPS_CSPACE_KCMY); - else if (!strcasecmp(cs, "kcmycm")) + else if (!_cups_strcasecmp(cs, "kcmycm")) return (CUPS_CSPACE_KCMYcm); - else if (!strcasecmp(cs, "gmck")) + else if (!_cups_strcasecmp(cs, "gmck")) return (CUPS_CSPACE_GMCK); - else if (!strcasecmp(cs, "gmcs")) + else if (!_cups_strcasecmp(cs, "gmcs")) return (CUPS_CSPACE_GMCS); - else if (!strcasecmp(cs, "white")) + else if (!_cups_strcasecmp(cs, "white")) return (CUPS_CSPACE_WHITE); - else if (!strcasecmp(cs, "gold")) + else if (!_cups_strcasecmp(cs, "gold")) return (CUPS_CSPACE_GOLD); - else if (!strcasecmp(cs, "silver")) + else if (!_cups_strcasecmp(cs, "silver")) return (CUPS_CSPACE_SILVER); - else if (!strcasecmp(cs, "CIEXYZ")) + else if (!_cups_strcasecmp(cs, "CIEXYZ")) return (CUPS_CSPACE_CIEXYZ); - else if (!strcasecmp(cs, "CIELab")) + else if (!_cups_strcasecmp(cs, "CIELab")) return (CUPS_CSPACE_CIELab); - else if (!strcasecmp(cs, "RGBW")) + else if (!_cups_strcasecmp(cs, "RGBW")) return (CUPS_CSPACE_RGBW); - else if (!strcasecmp(cs, "ICC1")) + else if (!_cups_strcasecmp(cs, "ICC1")) return (CUPS_CSPACE_ICC1); - else if (!strcasecmp(cs, "ICC2")) + else if (!_cups_strcasecmp(cs, "ICC2")) return (CUPS_CSPACE_ICC2); - else if (!strcasecmp(cs, "ICC3")) + else if (!_cups_strcasecmp(cs, "ICC3")) return (CUPS_CSPACE_ICC3); - else if (!strcasecmp(cs, "ICC4")) + else if (!_cups_strcasecmp(cs, "ICC4")) return (CUPS_CSPACE_ICC4); - else if (!strcasecmp(cs, "ICC5")) + else if (!_cups_strcasecmp(cs, "ICC5")) return (CUPS_CSPACE_ICC5); - else if (!strcasecmp(cs, "ICC6")) + else if (!_cups_strcasecmp(cs, "ICC6")) return (CUPS_CSPACE_ICC6); - else if (!strcasecmp(cs, "ICC7")) + else if (!_cups_strcasecmp(cs, "ICC7")) return (CUPS_CSPACE_ICC7); - else if (!strcasecmp(cs, "ICC8")) + else if (!_cups_strcasecmp(cs, "ICC8")) return (CUPS_CSPACE_ICC8); - else if (!strcasecmp(cs, "ICC9")) + else if (!_cups_strcasecmp(cs, "ICC9")) return (CUPS_CSPACE_ICC9); - else if (!strcasecmp(cs, "ICCA")) + else if (!_cups_strcasecmp(cs, "ICCA")) return (CUPS_CSPACE_ICCA); - else if (!strcasecmp(cs, "ICCB")) + else if (!_cups_strcasecmp(cs, "ICCB")) return (CUPS_CSPACE_ICCB); - else if (!strcasecmp(cs, "ICCC")) + else if (!_cups_strcasecmp(cs, "ICCC")) return (CUPS_CSPACE_ICCC); - else if (!strcasecmp(cs, "ICCD")) + else if (!_cups_strcasecmp(cs, "ICCD")) return (CUPS_CSPACE_ICCD); - else if (!strcasecmp(cs, "ICCE")) + else if (!_cups_strcasecmp(cs, "ICCE")) return (CUPS_CSPACE_ICCE); - else if (!strcasecmp(cs, "ICCF")) + else if (!_cups_strcasecmp(cs, "ICCF")) return (CUPS_CSPACE_ICCF); else return (-1); @@ -651,8 +691,9 @@ ppdcSource::get_constraint(ppdcFile *fp)// I - File to read // UIConstraints "*Option1 Choice1 *Option2 Choice2" if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, "ppdc: Expected constraints string for UIConstraints on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected constraints string for UIConstraints on " + "line %d of %s."), fp->line, fp->filename); return (NULL); } @@ -660,8 +701,9 @@ ppdcSource::get_constraint(ppdcFile *fp)// I - File to read if (*ptr != '*') { - fprintf(stderr, "ppdc: Option constraint must *name on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Option constraint must *name on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -682,8 +724,9 @@ ppdcSource::get_constraint(ppdcFile *fp)// I - File to read if (*ptr != '*') { - fprintf(stderr, "ppdc: Expected two option names on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected two option names on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -779,16 +822,17 @@ ppdcSource::get_duplex(ppdcFile *fp, // I - File to read from // Duplex {boolean|none|normal|flip} if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, "ppdc: Expected duplex type after Duplex on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected duplex type after Duplex on line %d of " + "%s."), fp->line, fp->filename); return; } if (cond_state) return; - if (!strcasecmp(temp, "none") || !strcasecmp(temp, "false") || - !strcasecmp(temp, "no") || !strcasecmp(temp, "off")) + if (!_cups_strcasecmp(temp, "none") || !_cups_strcasecmp(temp, "false") || + !_cups_strcasecmp(temp, "no") || !_cups_strcasecmp(temp, "off")) { g = d->find_group("General"); if ((o = g->find_option("Duplex")) != NULL) @@ -803,9 +847,10 @@ ppdcSource::get_duplex(ppdcFile *fp, // I - File to read from break; } } - else if (!strcasecmp(temp, "normal") || !strcasecmp(temp, "true") || - !strcasecmp(temp, "yes") || !strcasecmp(temp, "on") || - !strcasecmp(temp, "flip")) + else if (!_cups_strcasecmp(temp, "normal") || !_cups_strcasecmp(temp, "true") || + !_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "on") || + !_cups_strcasecmp(temp, "flip") || !_cups_strcasecmp(temp, "rotated") || + !_cups_strcasecmp(temp, "manualtumble")) { g = d->find_group("General"); o = g->find_option("Duplex"); @@ -813,7 +858,7 @@ ppdcSource::get_duplex(ppdcFile *fp, // I - File to read from if (!o) { o = new ppdcOption(PPDC_PICKONE, "Duplex", "2-Sided Printing", - !strcasecmp(temp, "flip") ? PPDC_SECTION_PAGE : + !_cups_strcasecmp(temp, "flip") ? PPDC_SECTION_PAGE : PPDC_SECTION_ANY, 10.0f); o->add_choice(new ppdcChoice("None", "Off (1-Sided)", "<>setpagedevice")); @@ -830,17 +875,36 @@ ppdcSource::get_duplex(ppdcFile *fp, // I - File to read from attr = (ppdcAttr *)d->attrs->next()) if (!strcmp(attr->name->value, "cupsFlipDuplex")) { - if (strcasecmp(temp, "flip")) + if (_cups_strcasecmp(temp, "flip")) d->attrs->remove(attr); break; } - if (!strcasecmp(temp, "flip") && !attr) + if (!_cups_strcasecmp(temp, "flip") && !attr) d->add_attr(new ppdcAttr("cupsFlipDuplex", NULL, NULL, "true")); + + for (attr = (ppdcAttr *)d->attrs->first(); + attr; + attr = (ppdcAttr *)d->attrs->next()) + if (!strcmp(attr->name->value, "cupsBackSide")) + { + d->attrs->remove(attr); + break; + } + + if (!_cups_strcasecmp(temp, "flip")) + d->add_attr(new ppdcAttr("cupsBackSide", NULL, NULL, "Flipped")); + else if (!_cups_strcasecmp(temp, "rotated")) + d->add_attr(new ppdcAttr("cupsBackSide", NULL, NULL, "Rotated")); + else if (!_cups_strcasecmp(temp, "manualtumble")) + d->add_attr(new ppdcAttr("cupsBackSide", NULL, NULL, "ManualTumble")); + else + d->add_attr(new ppdcAttr("cupsBackSide", NULL, NULL, "Normal")); } else - fprintf(stderr, "ppdc: Unknown duplex type \"%s\" on line %d of %s!\n", - temp, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Unknown duplex type \"%s\" on line %d of %s."), + temp, fp->line, fp->filename); } @@ -864,8 +928,9 @@ ppdcSource::get_filter(ppdcFile *fp) // I - File to read if (!get_token(fp, type, sizeof(type))) { - fprintf(stderr, "ppdc: Expected a filter definition on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected a filter definition on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -878,7 +943,7 @@ ppdcSource::get_filter(ppdcFile *fp) // I - File to read while (isspace(*ptr)) ptr ++; - strcpy(program, ptr); + strlcpy(program, ptr, sizeof(program)); } else { @@ -886,30 +951,34 @@ ppdcSource::get_filter(ppdcFile *fp) // I - File to read if (!get_token(fp, program, sizeof(program))) { - fprintf(stderr, "ppdc: Expected a program name on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected a program name on line %d of %s."), + fp->line, fp->filename); return (NULL); } } if (!type[0]) { - fprintf(stderr, "ppdc: Invalid empty MIME type for filter on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Invalid empty MIME type for filter on line %d of " + "%s."), fp->line, fp->filename); return (NULL); } if (cost < 0 || cost > 200) { - fprintf(stderr, "ppdc: Invalid cost for filter on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Invalid cost for filter on line %d of %s."), + fp->line, fp->filename); return (NULL); } if (!program[0]) { - fprintf(stderr, "ppdc: Invalid empty program name for filter on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Invalid empty program name for filter on line %d " + "of %s."), fp->line, fp->filename); return (NULL); } @@ -932,8 +1001,8 @@ ppdcSource::get_float(ppdcFile *fp) // I - File to read // Get the number from the file and range-check... if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, "ppdc: Expected real number on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, _("ppdc: Expected real number on line %d of %s."), + fp->line, fp->filename); return (-1.0f); } @@ -941,8 +1010,9 @@ ppdcSource::get_float(ppdcFile *fp) // I - File to read if (*ptr) { - fprintf(stderr, "ppdc: Unknown trailing characters in real number \"%s\" on line %d of %s!\n", - temp, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Unknown trailing characters in real number \"%s\" " + "on line %d of %s."), temp, fp->line, fp->filename); return (-1.0f); } else @@ -984,8 +1054,9 @@ ppdcSource::get_font(ppdcFile *fp) // I - File to read // "Status" is the keyword ROM or Disk. if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected name after Font on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name after Font on line %d of %s."), + fp->line, fp->filename); return (0); } @@ -1002,40 +1073,45 @@ ppdcSource::get_font(ppdcFile *fp) // I - File to read // Load a full font definition... if (!get_token(fp, encoding, sizeof(encoding))) { - fprintf(stderr, "ppdc: Expected encoding after Font on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected encoding after Font on line %d of " + "%s."), fp->line, fp->filename); return (0); } if (!get_token(fp, version, sizeof(version))) { - fprintf(stderr, "ppdc: Expected version after Font on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected version after Font on line %d of " + "%s."), fp->line, fp->filename); return (0); } if (!get_token(fp, charset, sizeof(charset))) { - fprintf(stderr, "ppdc: Expected charset after Font on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected charset after Font on line %d of " + "%s."), fp->line, fp->filename); return (0); } if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, "ppdc: Expected status after Font on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected status after Font on line %d of %s."), + fp->line, fp->filename); return (0); } - if (!strcasecmp(temp, "ROM")) + if (!_cups_strcasecmp(temp, "ROM")) status = PPDC_FONT_ROM; - else if (!strcasecmp(temp, "Disk")) + else if (!_cups_strcasecmp(temp, "Disk")) status = PPDC_FONT_DISK; else { - fprintf(stderr, "ppdc: Bad status keyword %s on line %d of %s!\n", - temp, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Bad status keyword %s on line %d of %s."), + temp, fp->line, fp->filename); return (0); } } @@ -1076,8 +1152,9 @@ ppdcSource::get_generic(ppdcFile *fp, // I - File to read if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected name/text after %s on line %d of %s!\n", - keyword, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name/text after %s on line %d of %s."), + keyword, fp->line, fp->filename); return (NULL); } @@ -1124,8 +1201,9 @@ ppdcSource::get_group(ppdcFile *fp, // I - File to read // Group name/text if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected group name/text on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected group name/text on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -1163,8 +1241,9 @@ ppdcSource::get_installable(ppdcFile *fp) // Installable name/text if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected name/text after Installable on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name/text after Installable on line %d " + "of %s."), fp->line, fp->filename); return (NULL); } @@ -1239,7 +1318,7 @@ ppdcSource::get_integer(const char *v) // I - Value string while (*v && *v != ')') { // Skip leading whitespace... - while (*v && isspace(*v & 255)); + while (*v && isspace(*v & 255)) v ++; if (!*v || *v == ')') @@ -1259,7 +1338,8 @@ ppdcSource::get_integer(const char *v) // I - Value string // NAME logicop value for (newv = (char *)v + 1; *newv && (isalnum(*newv & 255) || *newv == '_'); - newv ++); + newv ++) + /* do nothing */; ch = *newv; *newv = '\0'; @@ -1282,17 +1362,17 @@ ppdcSource::get_integer(const char *v) // I - Value string while (isspace(*newv & 255)) newv ++; - if (strncmp(newv, "==", 2)) + if (!strncmp(newv, "==", 2)) { compop = PPDC_EQ; newv += 2; } - else if (strncmp(newv, "!=", 2)) + else if (!strncmp(newv, "!=", 2)) { compop = PPDC_NE; newv += 2; } - else if (strncmp(newv, "<=", 2)) + else if (!strncmp(newv, "<=", 2)) { compop = PPDC_LE; newv += 2; @@ -1302,7 +1382,7 @@ ppdcSource::get_integer(const char *v) // I - Value string compop = PPDC_LT; newv ++; } - else if (strncmp(newv, ">=", 2)) + else if (!strncmp(newv, ">=", 2)) { compop = PPDC_GE; newv += 2; @@ -1323,7 +1403,7 @@ ppdcSource::get_integer(const char *v) // I - Value string if (*newv == ')' || !*newv) return (-1); - if (isdigit(*v & 255) || *v == '-' || *v == '+') + if (isdigit(*newv & 255) || *newv == '-' || *newv == '+') { // Get the second number... temp2 = strtol(newv, &newv, 0); @@ -1419,8 +1499,8 @@ ppdcSource::get_integer(ppdcFile *fp) // I - File to read if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, "ppdc: Expected integer on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, _("ppdc: Expected integer on line %d of %s."), + fp->line, fp->filename); return (-1); } else @@ -1449,17 +1529,17 @@ ppdcSource::get_measurement(ppdcFile *fp) val = (float)strtod(buffer, &ptr); // Check for a trailing unit specifier... - if (!strcasecmp(ptr, "mm")) + if (!_cups_strcasecmp(ptr, "mm")) val *= 72.0f / 25.4f; - else if (!strcasecmp(ptr, "cm")) + else if (!_cups_strcasecmp(ptr, "cm")) val *= 72.0f / 2.54f; - else if (!strcasecmp(ptr, "m")) + else if (!_cups_strcasecmp(ptr, "m")) val *= 72.0f / 0.0254f; - else if (!strcasecmp(ptr, "in")) + else if (!_cups_strcasecmp(ptr, "in")) val *= 72.0f; - else if (!strcasecmp(ptr, "ft")) + else if (!_cups_strcasecmp(ptr, "ft")) val *= 72.0f * 12.0f; - else if (strcasecmp(ptr, "pt") && *ptr) + else if (_cups_strcasecmp(ptr, "pt") && *ptr) return (-1.0f); return (val); @@ -1482,6 +1562,7 @@ ppdcSource::get_option(ppdcFile *fp, // I - File to read ppdcOptSection section; // Option section float order; // Option order ppdcOption *o; // Option + ppdcGroup *mg; // Matching group, if any // Read the Option parameters: @@ -1489,8 +1570,9 @@ ppdcSource::get_option(ppdcFile *fp, // I - File to read // Option name/text type section order if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected option name/text on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected option name/text on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -1501,65 +1583,73 @@ ppdcSource::get_option(ppdcFile *fp, // I - File to read if (!get_token(fp, type, sizeof(type))) { - fprintf(stderr, "ppdc: Expected option type on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, _("ppdc: Expected option type on line %d of %s."), + fp->line, fp->filename); return (NULL); } - if (!strcasecmp(type, "boolean")) + if (!_cups_strcasecmp(type, "boolean")) ot = PPDC_BOOLEAN; - else if (!strcasecmp(type, "pickone")) + else if (!_cups_strcasecmp(type, "pickone")) ot = PPDC_PICKONE; - else if (!strcasecmp(type, "pickmany")) + else if (!_cups_strcasecmp(type, "pickmany")) ot = PPDC_PICKMANY; else { - fprintf(stderr, "ppdc: Invalid option type \"%s\" on line %d of %s!\n", - type, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Invalid option type \"%s\" on line %d of %s."), + type, fp->line, fp->filename); return (NULL); } if (!get_token(fp, type, sizeof(type))) { - fprintf(stderr, "ppdc: Expected option section on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected option section on line %d of %s."), + fp->line, fp->filename); return (NULL); } - if (!strcasecmp(type, "AnySetup")) + if (!_cups_strcasecmp(type, "AnySetup")) section = PPDC_SECTION_ANY; - else if (!strcasecmp(type, "DocumentSetup")) + else if (!_cups_strcasecmp(type, "DocumentSetup")) section = PPDC_SECTION_DOCUMENT; - else if (!strcasecmp(type, "ExitServer")) + else if (!_cups_strcasecmp(type, "ExitServer")) section = PPDC_SECTION_EXIT; - else if (!strcasecmp(type, "JCLSetup")) + else if (!_cups_strcasecmp(type, "JCLSetup")) section = PPDC_SECTION_JCL; - else if (!strcasecmp(type, "PageSetup")) + else if (!_cups_strcasecmp(type, "PageSetup")) section = PPDC_SECTION_PAGE; - else if (!strcasecmp(type, "Prolog")) + else if (!_cups_strcasecmp(type, "Prolog")) section = PPDC_SECTION_PROLOG; else { - fprintf(stderr, "ppdc: Invalid option section \"%s\" on line %d of %s!\n", - type, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Invalid option section \"%s\" on line %d of " + "%s."), type, fp->line, fp->filename); return (NULL); } order = get_float(fp); // See if the option already exists... - if ((o = d->find_option(name)) == NULL) + if ((o = d->find_option_group(name, &mg)) == NULL) { // Nope, add a new one... o = new ppdcOption(ot, name, text, section, order); } else if (o->type != ot) { -// printf("o=%p, o->type=%d, o->name=%s, ot=%d, name=%s\n", -// o, o->type, o->name->value, ot, name); - fprintf(stderr, - "ppdc: Option redefined with a different type on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Option %s redefined with a different type on line " + "%d of %s."), name, fp->line, fp->filename); + return (NULL); + } + else if (g != mg) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on line " + "%d of %s."), name, fp->line, fp->filename); return (NULL); } @@ -1587,23 +1677,26 @@ ppdcSource::get_po(ppdcFile *fp) // I - File to read // #po locale "filename.po" if (!get_token(fp, locale, sizeof(locale))) { - fprintf(stderr, "ppdc: Expected locale after #po on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected locale after #po on line %d of %s."), + fp->line, fp->filename); return (NULL); } if (!get_token(fp, poname, sizeof(poname))) { - fprintf(stderr, "ppdc: Expected filename after #po %s on line %d of %s!\n", - locale, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected filename after #po %s on line %d of " + "%s."), locale, fp->line, fp->filename); return (NULL); } // See if the locale is already loaded... if (find_po(locale)) { - fprintf(stderr, "ppdc: Duplicate #po for locale %s on line %d of %s!\n", - locale, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Duplicate #po for locale %s on line %d of %s."), + locale, fp->line, fp->filename); return (NULL); } @@ -1613,16 +1706,19 @@ ppdcSource::get_po(ppdcFile *fp) // I - File to read if ((baseptr = strrchr(basedir, '/')) != NULL) *baseptr = '\0'; else - strcpy(basedir, "."); + strlcpy(basedir, ".", sizeof(basedir)); // Find the po file... - if (find_include(poname, basedir, pofilename, sizeof(pofilename))) + pofilename[0] = '\0'; + + if (!poname[0] || + find_include(poname, basedir, pofilename, sizeof(pofilename))) { // Found it, so load it... cat = new ppdcCatalog(locale, pofilename); // Reset the filename to the name supplied by the user... - delete cat->filename; + cat->filename->release(); cat->filename = new ppdcString(poname); // Return the catalog... @@ -1630,8 +1726,9 @@ ppdcSource::get_po(ppdcFile *fp) // I - File to read } else { - fprintf(stderr, "ppdc: Unable to find #po file %s on line %d of %s!\n", - poname, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Unable to find #po file %s on line %d of %s."), + poname, fp->line, fp->filename); return (NULL); } } @@ -1664,8 +1761,9 @@ ppdcSource::get_resolution(ppdcFile *fp)// I - File to read // Resolution colorspace bits row-count row-feed row-step name/text if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, "ppdc: Expected override field after Resolution on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected override field after Resolution on line " + "%d of %s."), fp->line, fp->filename); return (NULL); } @@ -1680,8 +1778,9 @@ ppdcSource::get_resolution(ppdcFile *fp)// I - File to read if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected name/text after Resolution on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name/text after Resolution on line %d of " + "%s."), fp->line, fp->filename); return (NULL); } @@ -1693,8 +1792,9 @@ ppdcSource::get_resolution(ppdcFile *fp)// I - File to read switch (sscanf(name, "%dx%d", &xdpi, &ydpi)) { case 0 : - fprintf(stderr, "ppdc: Bad resolution name \"%s\" on line %d of %s!\n", - name, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Bad resolution name \"%s\" on line %d of " + "%s."), name, fp->line, fp->filename); break; case 1 : ydpi = xdpi; @@ -1759,8 +1859,10 @@ ppdcSource::get_simple_profile(ppdcFile *fp) // red-density gamma red-adjust green-adjust blue-adjust if (!get_token(fp, resolution, sizeof(resolution))) { - fprintf(stderr, "ppdc: Expected resolution/mediatype following SimpleColorProfile on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected resolution/mediatype following " + "SimpleColorProfile on line %d of %s."), + fp->line, fp->filename); return (NULL); } @@ -1927,8 +2029,9 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read else { // $ch = $ch - fprintf(stderr, "ppdc: Bad variable substitution ($%c) on line %d of %s.\n", - ch, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Bad variable substitution ($%c) on line %d " + "of %s."), ch, fp->line, fp->filename); if (bufptr < bufend) *bufptr++ = '$'; @@ -1941,15 +2044,18 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read var = find_variable(name); if (var) { - strncpy(bufptr, var->value->value, bufend - bufptr); - bufptr += strlen(var->value->value); + strlcpy(bufptr, var->value->value, bufend - bufptr + 1); + bufptr += strlen(bufptr); } else { - fprintf(stderr, "ppdc: Undefined variable (%s) on line %d of %s.\n", - name, fp->line, fp->filename); + if (!(cond_state & PPDC_COND_SKIP)) + _cupsLangPrintf(stderr, + _("ppdc: Undefined variable (%s) on line %d of " + "%s."), name, fp->line, fp->filename); + snprintf(bufptr, bufend - bufptr + 1, "$%s", name); - bufptr += strlen(name) + 1; + bufptr += strlen(bufptr); } } } @@ -2054,8 +2160,9 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read if (quote) { - fprintf(stderr, "ppdc: Unterminated string starting with %c on line %d of %s!\n", - quote, startline, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Unterminated string starting with %c on line %d " + "of %s."), quote, startline, fp->filename); return (NULL); } @@ -2167,6 +2274,8 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to } else if (*format == 'h' || *format == 'l' || *format == 'L') size = *format++; + else + size = '\0'; if (!*format) break; @@ -2183,7 +2292,7 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to if ((format - bufformat + 1) > (int)sizeof(tformat)) break; - strncpy(tformat, bufformat, format - bufformat); + memcpy(tformat, bufformat, format - bufformat); tformat[format - bufformat] = '\0'; bytes += cupsFilePrintf(fp, tformat, va_arg(ap, double)); @@ -2200,17 +2309,25 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to if ((format - bufformat + 1) > (int)sizeof(tformat)) break; - strncpy(tformat, bufformat, format - bufformat); + memcpy(tformat, bufformat, format - bufformat); tformat[format - bufformat] = '\0'; - bytes += cupsFilePrintf(fp, tformat, va_arg(ap, int)); +# ifdef HAVE_LONG_LONG + if (size == 'L') + bytes += cupsFilePrintf(fp, tformat, va_arg(ap, long long)); + else +# endif /* HAVE_LONG_LONG */ + if (size == 'l') + bytes += cupsFilePrintf(fp, tformat, va_arg(ap, long)); + else + bytes += cupsFilePrintf(fp, tformat, va_arg(ap, int)); break; - + case 'p' : // Pointer value if ((format - bufformat + 1) > (int)sizeof(tformat)) break; - strncpy(tformat, bufformat, format - bufformat); + memcpy(tformat, bufformat, format - bufformat); tformat[format - bufformat] = '\0'; bytes += cupsFilePrintf(fp, tformat, va_arg(ap, void *)); @@ -2284,14 +2401,15 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to // void -ppdcSource::read_file(const char *f) // I - File to read +ppdcSource::read_file(const char *f, // I - File to read + cups_file_t *ffp) // I - File pointer to use { - ppdcFile *fp = new ppdcFile(f); + ppdcFile *fp = new ppdcFile(f, ffp); scan_file(fp); delete fp; if (cond_current != cond_stack) - fprintf(stderr, "ppdc: Missing #endif at end of \"%s\"!\n", f); + _cupsLangPrintf(stderr, _("ppdc: Missing #endif at end of \"%s\"."), f); } @@ -2306,6 +2424,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read { ppdcDriver *d; // Current driver ppdcGroup *g, // Current group + *mg, // Matching group *general, // General options group *install; // Installable options group ppdcOption *o; // Current option @@ -2317,7 +2436,10 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read // Initialize things as needed... if (inc && td) + { d = td; + d->retain(); + } else d = new ppdcDriver(td); @@ -2355,27 +2477,28 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read isdefault = 0; } - if (!strcasecmp(temp, "}")) + if (!_cups_strcasecmp(temp, "}")) { // Close this one out... break; } - else if (!strcasecmp(temp, "{")) + else if (!_cups_strcasecmp(temp, "{")) { // Open a new child... scan_file(fp, d); } - else if (!strcasecmp(temp, "#if")) + else if (!_cups_strcasecmp(temp, "#if")) { if ((cond_current - cond_stack) >= 100) { - fprintf(stderr, "ppdc: Too many nested #if's on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Too many nested #if's on line %d of %s."), + fp->line, fp->filename); break; } cond_current ++; - if (get_integer(fp)) + if (get_integer(fp) > 0) *cond_current = PPDC_COND_SATISFIED; else { @@ -2383,12 +2506,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read cond_state |= PPDC_COND_SKIP; } } - else if (!strcasecmp(temp, "#elif")) + else if (!_cups_strcasecmp(temp, "#elif")) { if (cond_current == cond_stack) { - fprintf(stderr, "ppdc: Missing #if on line %d of %s!\n", fp->line, - fp->filename); + _cupsLangPrintf(stderr, _("ppdc: Missing #if on line %d of %s."), + fp->line, fp->filename); break; } @@ -2397,7 +2520,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read get_integer(fp); *cond_current |= PPDC_COND_SKIP; } - else if (get_integer(fp)) + else if (get_integer(fp) > 0) { *cond_current |= PPDC_COND_SATISFIED; *cond_current &= ~PPDC_COND_SKIP; @@ -2418,12 +2541,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read else cond_temp --; } - else if (!strcasecmp(temp, "#else")) + else if (!_cups_strcasecmp(temp, "#else")) { if (cond_current == cond_stack) { - fprintf(stderr, "ppdc: Missing #if on line %d of %s!\n", fp->line, - fp->filename); + _cupsLangPrintf(stderr, _("ppdc: Missing #if on line %d of %s."), + fp->line, fp->filename); break; } @@ -2448,12 +2571,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read else cond_temp --; } - else if (!strcasecmp(temp, "#endif")) + else if (!_cups_strcasecmp(temp, "#endif")) { if (cond_current == cond_stack) { - fprintf(stderr, "ppdc: Missing #if on line %d of %s!\n", fp->line, - fp->filename); + _cupsLangPrintf(stderr, _("ppdc: Missing #if on line %d of %s."), + fp->line, fp->filename); break; } @@ -2472,12 +2595,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read else cond_temp --; } - else if (!strcasecmp(temp, "#define")) + else if (!_cups_strcasecmp(temp, "#define")) { // Get the variable... get_variable(fp); } - else if (!strcasecmp(temp, "#include")) + else if (!_cups_strcasecmp(temp, "#include")) { // #include filename char basedir[1024], // Base directory @@ -2492,8 +2615,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read // Get the include name... if (!get_token(fp, inctemp, sizeof(inctemp))) { - fprintf(stderr, "ppdc: Expected include filename on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected include filename on line %d of " + "%s."), fp->line, fp->filename); break; } @@ -2506,7 +2630,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if ((baseptr = strrchr(basedir, '/')) != NULL) *baseptr = '\0'; else - strcpy(basedir, "."); + strlcpy(basedir, ".", sizeof(basedir)); // Find the include file... if (find_include(inctemp, basedir, incname, sizeof(incname))) @@ -2517,18 +2641,19 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read delete incfile; if (cond_current != old_current) - fprintf(stderr, "ppdc: Missing #endif at end of \"%s\"!\n", incname); + _cupsLangPrintf(stderr, _("ppdc: Missing #endif at end of \"%s\"."), + incname); } else { // Can't find it! - fprintf(stderr, - "ppdc: Unable to find include file \"%s\" on line %d of %s!\n", - inctemp, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Unable to find include file \"%s\" on line %d " + "of %s."), inctemp, fp->line, fp->filename); break; } } - else if (!strcasecmp(temp, "#media")) + else if (!_cups_strcasecmp(temp, "#media")) { ppdcMediaSize *m; // Media size @@ -2543,7 +2668,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read sizes->add(m); } } - else if (!strcasecmp(temp, "#po")) + else if (!_cups_strcasecmp(temp, "#po")) { ppdcCatalog *cat; // Message catalog @@ -2558,14 +2683,14 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read po_files->add(cat); } } - else if (!strcasecmp(temp, "Attribute") || - !strcasecmp(temp, "LocAttribute")) + else if (!_cups_strcasecmp(temp, "Attribute") || + !_cups_strcasecmp(temp, "LocAttribute")) { ppdcAttr *a; // Attribute // Get an attribute... - a = get_attr(fp, !strcasecmp(temp, "LocAttribute")); + a = get_attr(fp, !_cups_strcasecmp(temp, "LocAttribute")); if (a) { if (cond_state) @@ -2574,7 +2699,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->add_attr(a); } } - else if (!strcasecmp(temp, "Choice")) + else if (!_cups_strcasecmp(temp, "Choice")) { // Get a choice... c = get_choice(fp); @@ -2590,8 +2715,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read // Add it to the current option... if (!o) { - fprintf(stderr, "ppdc: Choice found on line %d of %s with no Option!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Choice found on line %d of %s with no " + "Option."), fp->line, fp->filename); break; } @@ -2600,7 +2726,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (isdefault) o->set_defchoice(c); } - else if (!strcasecmp(temp, "ColorDevice")) + else if (!_cups_strcasecmp(temp, "ColorDevice")) { // ColorDevice boolean if (cond_state) @@ -2608,7 +2734,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read else d->color_device = get_boolean(fp); } - else if (!strcasecmp(temp, "ColorModel")) + else if (!_cups_strcasecmp(temp, "ColorModel")) { // Get the color model c = get_color_model(fp); @@ -2637,7 +2763,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = NULL; } - else if (!strcasecmp(temp, "ColorProfile")) + else if (!_cups_strcasecmp(temp, "ColorProfile")) { ppdcProfile *p; // Color profile @@ -2653,7 +2779,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->profiles->add(p); } } - else if (!strcasecmp(temp, "Copyright")) + else if (!_cups_strcasecmp(temp, "Copyright")) { // Copyright string char copytemp[8192], // Copyright string @@ -2664,9 +2790,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read // Get the copyright string... if (!get_token(fp, copytemp, sizeof(temp))) { - fprintf(stderr, - "ppdc: Expected string after Copyright on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected string after Copyright on line %d " + "of %s."), fp->line, fp->filename); break; } @@ -2682,7 +2808,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->copyright->add(new ppdcString(copyptr)); } } - else if (!strcasecmp(temp, "CustomMedia")) + else if (!_cups_strcasecmp(temp, "CustomMedia")) { ppdcMediaSize *m; // Media size @@ -2702,7 +2828,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (isdefault) d->set_default_size(m); } - else if (!strcasecmp(temp, "Cutter")) + else if (!_cups_strcasecmp(temp, "Cutter")) { // Cutter boolean int have_cutter; // Have a paper cutter? @@ -2729,7 +2855,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = NULL; } - else if (!strcasecmp(temp, "Darkness")) + else if (!_cups_strcasecmp(temp, "Darkness")) { // Get the darkness choice... c = get_generic(fp, "Darkness", NULL, "cupsCompression"); @@ -2743,13 +2869,22 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the cupsDarkness option... - if ((o = d->find_option("cupsDarkness")) == NULL) + if ((o = d->find_option_group("cupsDarkness", &mg)) == NULL) { // Create the cupsDarkness option... o = new ppdcOption(PPDC_PICKONE, "cupsDarkness", "Darkness", PPDC_SECTION_ANY, 10.0f); g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s."), "cupsDarkness", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -2758,7 +2893,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = NULL; } - else if (!strcasecmp(temp, "DriverType")) + else if (!_cups_strcasecmp(temp, "DriverType")) { int i; // Looping var @@ -2766,8 +2901,10 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read // DriverType keyword if (!get_token(fp, temp, sizeof(temp))) { - fprintf(stderr, "ppdc: Expected driver type keyword following DriverType on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected driver type keyword following " + "DriverType on line %d of %s."), + fp->line, fp->filename); continue; } @@ -2775,20 +2912,21 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read continue; for (i = 0; i < (int)(sizeof(driver_types) / sizeof(driver_types[0])); i ++) - if (!strcasecmp(temp, driver_types[i])) + if (!_cups_strcasecmp(temp, driver_types[i])) break; if (i < (int)(sizeof(driver_types) / sizeof(driver_types[0]))) d->type = (ppdcDrvType)i; - else if (!strcasecmp(temp, "dymo")) + else if (!_cups_strcasecmp(temp, "dymo")) d->type = PPDC_DRIVER_LABEL; else - fprintf(stderr, "ppdc: Unknown driver type %s on line %d of %s!\n", - temp, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Unknown driver type %s on line %d of %s."), + temp, fp->line, fp->filename); } - else if (!strcasecmp(temp, "Duplex")) + else if (!_cups_strcasecmp(temp, "Duplex")) get_duplex(fp, d); - else if (!strcasecmp(temp, "Filter")) + else if (!_cups_strcasecmp(temp, "Filter")) { ppdcFilter *f; // Filter @@ -2803,7 +2941,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->filters->add(f); } } - else if (!strcasecmp(temp, "Finishing")) + else if (!_cups_strcasecmp(temp, "Finishing")) { // Get the finishing choice... c = get_generic(fp, "Finishing", "OutputType", NULL); @@ -2817,13 +2955,22 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the cupsFinishing option... - if ((o = d->find_option("cupsFinishing")) == NULL) + if ((o = d->find_option_group("cupsFinishing", &mg)) == NULL) { // Create the cupsFinishing option... o = new ppdcOption(PPDC_PICKONE, "cupsFinishing", "Finishing", PPDC_SECTION_ANY, 10.0f); g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s."), "cupsFinishing", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -2832,8 +2979,8 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = NULL; } - else if (!strcasecmp(temp, "Font") || - !strcasecmp(temp, "#font")) + else if (!_cups_strcasecmp(temp, "Font") || + !_cups_strcasecmp(temp, "#font")) { ppdcFont *f; // Font @@ -2846,7 +2993,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read f->release(); else { - if (!strcasecmp(temp, "#font")) + if (!_cups_strcasecmp(temp, "#font")) base_fonts->add(f); else d->add_font(f); @@ -2856,7 +3003,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } } } - else if (!strcasecmp(temp, "Group")) + else if (!_cups_strcasecmp(temp, "Group")) { // Get a group... ppdcGroup *tempg = get_group(fp, d); @@ -2877,7 +3024,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read g = tempg; } } - else if (!strcasecmp(temp, "HWMargins")) + else if (!_cups_strcasecmp(temp, "HWMargins")) { // HWMargins left bottom right top d->left_margin = get_measurement(fp); @@ -2885,7 +3032,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->right_margin = get_measurement(fp); d->top_margin = get_measurement(fp); } - else if (!strcasecmp(temp, "InputSlot")) + else if (!_cups_strcasecmp(temp, "InputSlot")) { // Get the input slot choice... c = get_generic(fp, "InputSlot", NULL, "MediaPosition"); @@ -2899,7 +3046,8 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the InputSlot option... - if ((o = d->find_option("InputSlot")) == NULL) + + if ((o = d->find_option_group("InputSlot", &mg)) == NULL) { // Create the InputSlot option... o = new ppdcOption(PPDC_PICKONE, "InputSlot", "Media Source", @@ -2907,6 +3055,15 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s."), "InputSlot", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -2915,7 +3072,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = NULL; } - else if (!strcasecmp(temp, "Installable")) + else if (!_cups_strcasecmp(temp, "Installable")) { // Get the installable option... o = get_installable(fp); @@ -2931,7 +3088,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = NULL; } } - else if (!strcasecmp(temp, "ManualCopies")) + else if (!_cups_strcasecmp(temp, "ManualCopies")) { // ManualCopies boolean if (cond_state) @@ -2939,7 +3096,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read else d->manual_copies = get_boolean(fp); } - else if (!strcasecmp(temp, "Manufacturer")) + else if (!_cups_strcasecmp(temp, "Manufacturer")) { // Manufacturer name char name[256]; // Model name string @@ -2947,15 +3104,16 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected name after Manufacturer on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name after Manufacturer on line %d " + "of %s."), fp->line, fp->filename); break; } if (!cond_state) d->set_manufacturer(name); } - else if (!strcasecmp(temp, "MaxSize")) + else if (!_cups_strcasecmp(temp, "MaxSize")) { // MaxSize width length if (cond_state) @@ -2969,7 +3127,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->max_length = get_measurement(fp); } } - else if (!strcasecmp(temp, "MediaSize")) + else if (!_cups_strcasecmp(temp, "MediaSize")) { // MediaSize keyword char name[41]; // Media size name @@ -2979,9 +3137,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (get_token(fp, name, sizeof(name)) == NULL) { - fprintf(stderr, - "ppdc: Expected name after MediaSize on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name after MediaSize on line %d of " + "%s."), fp->line, fp->filename); break; } @@ -2992,8 +3150,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (!m) { - fprintf(stderr, "ppdc: Unknown media size \"%s\" on line %d of %s!\n", - name, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Unknown media size \"%s\" on line %d of " + "%s."), name, fp->line, fp->filename); break; } @@ -3007,7 +3166,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (isdefault) d->set_default_size(dm); } - else if (!strcasecmp(temp, "MediaType")) + else if (!_cups_strcasecmp(temp, "MediaType")) { // Get the media type choice... c = get_generic(fp, "MediaType", "MediaType", "cupsMediaType"); @@ -3021,7 +3180,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the MediaType option... - if ((o = d->find_option("MediaType")) == NULL) + if ((o = d->find_option_group("MediaType", &mg)) == NULL) { // Create the MediaType option... o = new ppdcOption(PPDC_PICKONE, "MediaType", "Media Type", @@ -3029,6 +3188,15 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s."), "MediaType", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -3037,7 +3205,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = NULL; } - else if (!strcasecmp(temp, "MinSize")) + else if (!_cups_strcasecmp(temp, "MinSize")) { // MinSize width length if (cond_state) @@ -3051,7 +3219,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->min_length = get_measurement(fp); } } - else if (!strcasecmp(temp, "ModelName")) + else if (!_cups_strcasecmp(temp, "ModelName")) { // ModelName name char name[256]; // Model name string @@ -3059,15 +3227,16 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, "ppdc: Expected name after ModelName on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name after ModelName on line %d of " + "%s."), fp->line, fp->filename); break; } if (!cond_state) d->set_model_name(name); } - else if (!strcasecmp(temp, "ModelNumber")) + else if (!_cups_strcasecmp(temp, "ModelNumber")) { // ModelNumber number if (cond_state) @@ -3075,7 +3244,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read else d->model_number = get_integer(fp); } - else if (!strcasecmp(temp, "Option")) + else if (!_cups_strcasecmp(temp, "Option")) { // Get an option... ppdcOption *tempo = get_option(fp, d, g); @@ -3096,7 +3265,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = tempo; } } - else if (!strcasecmp(temp, "FileName")) + else if (!_cups_strcasecmp(temp, "FileName")) { // FileName name char name[256]; // Filename string @@ -3104,16 +3273,16 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, - "ppdc: Expected name after FileName on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name after FileName on line %d of " + "%s."), fp->line, fp->filename); break; } if (!cond_state) d->set_file_name(name); } - else if (!strcasecmp(temp, "PCFileName")) + else if (!_cups_strcasecmp(temp, "PCFileName")) { // PCFileName name char name[256]; // PC filename string @@ -3121,16 +3290,16 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, - "ppdc: Expected name after PCFileName on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected name after PCFileName on line %d of " + "%s."), fp->line, fp->filename); break; } if (!cond_state) d->set_pc_file_name(name); } - else if (!strcasecmp(temp, "Resolution")) + else if (!_cups_strcasecmp(temp, "Resolution")) { // Get the resolution choice... c = get_resolution(fp); @@ -3144,7 +3313,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the Resolution option... - if ((o = d->find_option("Resolution")) == NULL) + if ((o = d->find_option_group("Resolution", &mg)) == NULL) { // Create the Resolution option... o = new ppdcOption(PPDC_PICKONE, "Resolution", NULL, PPDC_SECTION_ANY, @@ -3152,6 +3321,15 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s."), "Resolution", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -3160,7 +3338,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read o = NULL; } - else if (!strcasecmp(temp, "SimpleColorProfile")) + else if (!_cups_strcasecmp(temp, "SimpleColorProfile")) { ppdcProfile *p; // Color profile @@ -3176,7 +3354,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->profiles->add(p); } } - else if (!strcasecmp(temp, "Throughput")) + else if (!_cups_strcasecmp(temp, "Throughput")) { // Throughput number if (cond_state) @@ -3184,7 +3362,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read else d->throughput = get_integer(fp); } - else if (!strcasecmp(temp, "UIConstraints")) + else if (!_cups_strcasecmp(temp, "UIConstraints")) { ppdcConstraint *con; // Constraint @@ -3199,7 +3377,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read d->constraints->add(con); } } - else if (!strcasecmp(temp, "VariablePaperSize")) + else if (!_cups_strcasecmp(temp, "VariablePaperSize")) { // VariablePaperSize boolean if (cond_state) @@ -3207,7 +3385,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read else d->variable_paper_size = get_boolean(fp); } - else if (!strcasecmp(temp, "Version")) + else if (!_cups_strcasecmp(temp, "Version")) { // Version string char name[256]; // Model name string @@ -3215,9 +3393,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read if (!get_token(fp, name, sizeof(name))) { - fprintf(stderr, - "ppdc: Expected string after Version on line %d of %s!\n", - fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Expected string after Version on line %d of " + "%s."), fp->line, fp->filename); break; } @@ -3226,8 +3404,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } else { - fprintf(stderr, "ppdc: Unknown token \"%s\" seen on line %d of %s!\n", - temp, fp->line, fp->filename); + _cupsLangPrintf(stderr, + _("ppdc: Unknown token \"%s\" seen on line %d of %s."), + temp, fp->line, fp->filename); break; } } @@ -3247,6 +3426,8 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read drivers->add(d); } } + else if (inc && td) + td->release(); } @@ -3341,7 +3522,8 @@ ppdcSource::write_file(const char *f) // I - File to write for (d = (ppdcDriver *)drivers->first(); d; d = (ppdcDriver *)drivers->next()) { // Start the driver... - cupsFilePrintf(fp, "\n// %s %s\n", d->manufacturer->value, d->model_name->value); + cupsFilePrintf(fp, "\n// %s %s\n", d->manufacturer->value, + d->model_name->value); cupsFilePuts(fp, "{\n"); // Write the copyright stings... @@ -3351,15 +3533,15 @@ ppdcSource::write_file(const char *f) // I - File to write quotef(fp, " Copyright \"%s\"\n", st->value); // Write other strings and values... - if (d->manufacturer->value) + if (d->manufacturer && d->manufacturer->value) quotef(fp, " Manufacturer \"%s\"\n", d->manufacturer->value); if (d->model_name->value) quotef(fp, " ModelName \"%s\"\n", d->model_name->value); - if (d->file_name->value) + if (d->file_name && d->file_name->value) quotef(fp, " FileName \"%s\"\n", d->file_name->value); - if (d->pc_file_name->value) + if (d->pc_file_name && d->pc_file_name->value) quotef(fp, " PCFileName \"%s\"\n", d->pc_file_name->value); - if (d->version->value) + if (d->version && d->version->value) quotef(fp, " Version \"%s\"\n", d->version->value); cupsFilePrintf(fp, " DriverType %s\n", driver_types[d->type]); @@ -3368,64 +3550,6 @@ ppdcSource::write_file(const char *f) // I - File to write { switch (d->type) { - case PPDC_DRIVER_ESCP : - cupsFilePuts(fp, " ModelNumber ("); - - if (d->model_number & ESCP_DOTMATRIX) - cupsFilePuts(fp, " $ESCP_DOTMATRIX"); - if (d->model_number & ESCP_MICROWEAVE) - cupsFilePuts(fp, " $ESCP_MICROWEAVE"); - if (d->model_number & ESCP_STAGGER) - cupsFilePuts(fp, " $ESCP_STAGGER"); - if (d->model_number & ESCP_ESCK) - cupsFilePuts(fp, " $ESCP_ESCK"); - if (d->model_number & ESCP_EXT_UNITS) - cupsFilePuts(fp, " $ESCP_EXT_UNITS"); - if (d->model_number & ESCP_EXT_MARGINS) - cupsFilePuts(fp, " $ESCP_EXT_MARGINS"); - if (d->model_number & ESCP_USB) - cupsFilePuts(fp, " $ESCP_USB"); - if (d->model_number & ESCP_PAGE_SIZE) - cupsFilePuts(fp, " $ESCP_PAGE_SIZE"); - if (d->model_number & ESCP_RASTER_ESCI) - cupsFilePuts(fp, " $ESCP_RASTER_ESCI"); - if (d->model_number & ESCP_REMOTE) - cupsFilePuts(fp, " $ESCP_REMOTE"); - - cupsFilePuts(fp, ")\n"); - break; - - case PPDC_DRIVER_PCL : - cupsFilePuts(fp, " ModelNumber ("); - - if (d->model_number & PCL_PAPER_SIZE) - cupsFilePuts(fp, " $PCL_PAPER_SIZE"); - if (d->model_number & PCL_INKJET) - cupsFilePuts(fp, " $PCL_INKJET"); - if (d->model_number & PCL_RASTER_END_COLOR) - cupsFilePuts(fp, " $PCL_RASTER_END_COLOR"); - if (d->model_number & PCL_RASTER_CID) - cupsFilePuts(fp, " $PCL_RASTER_CID"); - if (d->model_number & PCL_RASTER_CRD) - cupsFilePuts(fp, " $PCL_RASTER_CRD"); - if (d->model_number & PCL_RASTER_SIMPLE) - cupsFilePuts(fp, " $PCL_RASTER_SIMPLE"); - if (d->model_number & PCL_RASTER_RGB24) - cupsFilePuts(fp, " $PCL_RASTER_RGB24"); - if (d->model_number & PCL_PJL) - cupsFilePuts(fp, " $PCL_PJL"); - if (d->model_number & PCL_PJL_PAPERWIDTH) - cupsFilePuts(fp, " $PCL_PJL_PAPERWIDTH"); - if (d->model_number & PCL_PJL_HPGL2) - cupsFilePuts(fp, " $PCL_PJL_HPGL2"); - if (d->model_number & PCL_PJL_PCL3GUI) - cupsFilePuts(fp, " $PCL_PJL_PCL3GUI"); - if (d->model_number & PCL_PJL_RESOLUTION) - cupsFilePuts(fp, " $PCL_PJL_RESOLUTION"); - - cupsFilePuts(fp, ")\n"); - break; - case PPDC_DRIVER_LABEL : cupsFilePuts(fp, " ModelNumber "); @@ -3723,5 +3847,5 @@ ppdcSource::write_file(const char *f) // I - File to write // -// End of "$Id$". +// End of "$Id: ppdc-source.cxx 4167 2013-02-04 19:27:13Z msweet $". //