Index: ppdc/ppdc-driver.cxx =================================================================== --- ppdc/ppdc-driver.cxx (revision 8602) +++ ppdc/ppdc-driver.cxx (working copy) @@ -190,7 +190,7 @@ for (a = (ppdcAttr *)attrs->first(); a; a = (ppdcAttr *)attrs->next()) if (!strcmp(a->name->value, k) && ((!s && (!a->selector->value || !a->selector->value[0])) || - (!s && !a->selector->value && !strcmp(a->selector->value, s)))) + (s && a->selector->value && !strcmp(a->selector->value, s)))) return (a); return (NULL); @@ -378,7 +378,8 @@ ppdcLineEnding le) // I - Line endings to use { bool delete_cat; // Delete the catalog when we are done? - char query[42]; // Query attribute + char query[42], // Query attribute + custom[42]; // Custom attribute ppdcString *s; // Copyright string ppdcGroup *g; // Current group ppdcOption *o; // Current option @@ -412,10 +413,11 @@ // Write the standard header stuff... cupsFilePrintf(fp, "*PPD-Adobe: \"4.3\"%s", lf); - cupsFilePrintf(fp, "*%% PPD file for %s with CUPS.%s", model_name->value, lf); + cupsFilePrintf(fp, "*%%%%%%%% PPD file for %s with CUPS.%s", + model_name->value, lf); cupsFilePrintf(fp, - "*%% Created by the CUPS PPD Compiler " CUPS_SVERSION ".%s", - lf); + "*%%%%%%%% Created by the CUPS PPD Compiler " CUPS_SVERSION + ".%s", lf); for (s = (ppdcString *)copyright->first(); s; s = (ppdcString *)copyright->next()) @@ -559,6 +561,14 @@ !strcmp(a->name->value, "?PaperDimension"))) continue; + if (!strncmp(a->name->value, "Custom", 6) && + find_option(a->name->value + 6)) + continue; + + if (!strncmp(a->name->value, "ParamCustom", 11) && + find_option(a->name->value + 11)) + continue; + if (!a->selector->value || !a->selector->value[0]) cupsFilePrintf(fp, "*%s", a->name->value); else if (!a->text->value || !a->text->value[0]) @@ -579,7 +589,7 @@ { cupsFilePrintf(fp, ": \"%s\"%s", a->value->value, lf); - if (strchr(a->value->value, '\n')) + if (strchr(a->value->value, '\n') || strchr(a->value->value, '\r')) cupsFilePrintf(fp, "*End%s", lf); } else @@ -931,9 +941,6 @@ cupsFilePrintf(fp, "*ParamCustomPageSize Orientation: 5 int 0 0%s", lf); } - if (type != PPDC_DRIVER_PS && !find_attr("RequiresPageRegion", NULL)) - cupsFilePrintf(fp, "*RequiresPageRegion All: True%s", lf); - // All other options... for (g = (ppdcGroup *)groups->first(); g; g = (ppdcGroup *)groups->next()) { @@ -1034,7 +1041,7 @@ if ((a = find_attr(query, NULL)) != NULL) { - cupsFilePrintf(fp, "*%s: \"%s\"\n", query, a->value->value); + cupsFilePrintf(fp, "*%s: \"%s\"%s", query, a->value->value, lf); if (strchr(a->value->value, '\n') || strchr(a->value->value, '\r')) @@ -1042,6 +1049,32 @@ } cupsFilePrintf(fp, "*CloseUI: *%s%s", o->name->value, lf); + + snprintf(custom, sizeof(custom), "Custom%s", o->name->value); + if ((a = find_attr(custom, "True")) != NULL) + { + // Output custom option information... + cupsFilePrintf(fp, "*%s True: \"%s\"%s", custom, a->value->value, lf); + if (strchr(a->value->value, '\n') || strchr(a->value->value, '\r')) + cupsFilePrintf(fp, "*End%s", lf); + + snprintf(custom, sizeof(custom), "ParamCustom%s", o->name->value); + for (a = (ppdcAttr *)attrs->first(); a; a = (ppdcAttr *)attrs->next()) + { + if (strcmp(a->name->value, custom)) + continue; + + if (!a->selector->value || !a->selector->value[0]) + cupsFilePrintf(fp, "*%s", a->name->value); + else if (!a->text->value || !a->text->value[0]) + cupsFilePrintf(fp, "*%s %s", a->name->value, a->selector->value); + else + cupsFilePrintf(fp, "*%s %s/%s", a->name->value, a->selector->value, + a->text->value); + + cupsFilePrintf(fp, ": %s%s", a->value->value, lf); + } + } } if (strcasecmp(g->name->value, "General")) Index: ppdc/ppdc-import.cxx =================================================================== --- ppdc/ppdc-import.cxx (revision 8602) +++ ppdc/ppdc-import.cxx (working copy) @@ -38,6 +38,7 @@ cups_file_t *fp; // File char line[256], // Comment line *ptr; // Pointer into line + int cost; // Cost for filter ppd_file_t *ppd; // PPD file data ppd_group_t *group; // PPD group ppd_option_t *option; // PPD option @@ -47,6 +48,7 @@ ppd_const_t *constraint2; // Temp PPD UI constraint ppd_size_t *size; // PPD page size ppdcDriver *driver; // Driver + ppdcFilter *filter; // Current filter ppdcFont *font; // Font ppdcGroup *cgroup; // UI group ppdcOption *coption; // UI option @@ -89,7 +91,7 @@ while (cupsFileGets(fp, line, sizeof(line))) if (strncmp(line, "*%", 2)) break; - else + else if (strncmp(line, "*%%%% ", 6)) { for (ptr = line + 2; isspace(*ptr); ptr ++); @@ -111,16 +113,50 @@ else ptr = ppd->modelname; - driver->manufacturer = new ppdcString(ppd->manufacturer); - driver->model_name = new ppdcString(ptr); - driver->pc_file_name = new ppdcString(ppd->pcfilename); + if (ppd->nickname) + driver->add_attr(new ppdcAttr("NickName", NULL, NULL, ppd->nickname)); + + if (ppd->shortnickname) + driver->add_attr(new ppdcAttr("ShortNickName", NULL, NULL, + ppd->shortnickname)); + + driver->manufacturer = new ppdcString(ppd->manufacturer); + driver->model_name = new ppdcString(ptr); + driver->pc_file_name = new ppdcString(ppd->pcfilename); attr = ppdFindAttr(ppd, "FileVersion", NULL); - driver->version = new ppdcString(attr ? attr->value : NULL); - driver->model_number = ppd->model_number; - driver->manual_copies = ppd->manual_copies; - driver->color_device = ppd->color_device; - driver->throughput = ppd->throughput; + driver->version = new ppdcString(attr ? attr->value : NULL); + driver->model_number = ppd->model_number; + driver->manual_copies = ppd->manual_copies; + driver->color_device = ppd->color_device; + driver->throughput = ppd->throughput; + driver->variable_paper_size = ppd->variable_sizes; + driver->max_width = ppd->custom_max[0]; + driver->max_length = ppd->custom_max[1]; + driver->min_width = ppd->custom_min[0]; + driver->min_length = ppd->custom_min[1]; + driver->left_margin = ppd->custom_margins[0]; + driver->bottom_margin = ppd->custom_margins[1]; + driver->right_margin = ppd->custom_margins[2]; + driver->top_margin = ppd->custom_margins[3]; + for (i = 0; i < ppd->num_filters; i ++) + { + strlcpy(line, ppd->filters[i], sizeof(line)); + + for (ptr = line; *ptr; ptr ++) + if (isspace(*ptr & 255)) + break; + *ptr++ = '\0'; + + cost = strtol(ptr, &ptr, 10); + + while (isspace(*ptr & 255)) + ptr ++; + + filter = new ppdcFilter(line, ptr, cost); + driver->add_filter(filter); + } + attr = ppdFindAttr(ppd, "DefaultFont", NULL); driver->default_font = new ppdcString(attr ? attr->value : NULL); @@ -166,7 +202,7 @@ { if (!strcmp(option->keyword, "PageSize") || !strcmp(option->keyword, "PageRegion")) continue; - + coption = new ppdcOption((ppdcOptType)option->ui, option->keyword, option->text, (ppdcOptSection)option->section, option->order); @@ -174,6 +210,9 @@ for (k = option->num_choices, choice = option->choices; k > 0; k --, choice ++) { + if (!strcmp(choice->choice, "Custom")) + continue; + cchoice = new ppdcChoice(choice->choice, choice->text, choice->code); coption->add_choice(cchoice); @@ -188,25 +227,21 @@ i > 0; i --, constraint ++) { - for (j = i - 1, constraint2 = constraint; + // Look for mirrored constraints... + for (j = i - 1, constraint2 = constraint + 1; j > 0; j --, constraint2 ++) - if (constraint != constraint2 && - !strcmp(constraint->option1, constraint2->option2) && - (constraint->choice1 == constraint2->choice2 || - (constraint->choice1 && constraint2->choice2 && - !strcmp(constraint->choice1, constraint2->choice2))) && + if (!strcmp(constraint->option1, constraint2->option2) && + !strcmp(constraint->choice1, constraint2->choice2) && !strcmp(constraint->option2, constraint2->option1) && - (constraint->choice2 == constraint2->choice1 || - (constraint->choice2 && constraint2->choice1 && - !strcmp(constraint->choice2, constraint2->choice1)))) + !strcmp(constraint->choice2, constraint2->choice1)) break; if (j) continue; - cconstraint = new ppdcConstraint(constraint->option1, constraint->choice1, - constraint->option2, constraint->choice2); + cconstraint = new ppdcConstraint(constraint->option2, constraint->choice2, + constraint->option1, constraint->choice1); driver->add_constraint(cconstraint); } @@ -240,6 +275,10 @@ driver->add_font(font); } + else if (!strcmp(attr->name, "CustomPageSize")) + { + driver->set_custom_size_code(attr->value); + } else if ((strncmp(attr->name, "Default", 7) || !strcmp(attr->name, "DefaultColorSpace")) && strcmp(attr->name, "ColorDevice") && @@ -248,15 +287,35 @@ strcmp(attr->name, "MaxMediaHeight") && strcmp(attr->name, "MaxMediaWidth") && strcmp(attr->name, "NickName") && + strcmp(attr->name, "ParamCustomPageSize") && strcmp(attr->name, "ShortNickName") && strcmp(attr->name, "Throughput") && strcmp(attr->name, "PCFileName") && strcmp(attr->name, "FileVersion") && strcmp(attr->name, "FormatVersion") && + strcmp(attr->name, "HWMargins") && strcmp(attr->name, "VariablePaperSize") && strcmp(attr->name, "LanguageEncoding") && - strcmp(attr->name, "LanguageVersion")) + strcmp(attr->name, "LanguageVersion") && + strcmp(attr->name, "cupsFilter") && + strcmp(attr->name, "cupsFlipDuplex") && + strcmp(attr->name, "cupsLanguages") && + strcmp(attr->name, "cupsManualCopies") && + strcmp(attr->name, "cupsModelNumber") && + strcmp(attr->name, "cupsVersion")) { + if ((ptr = strchr(attr->name, '.')) != NULL && + ((ptr - attr->name) == 2 || (ptr - attr->name) == 5)) + { + // Might be a localization attribute; test further... + if (isalpha(attr->name[0] & 255) && + isalpha(attr->name[1] & 255) && + (attr->name[2] == '.' || + (attr->name[2] == '_' && isalpha(attr->name[3] & 255) && + isalpha(attr->name[4] & 255)))) + continue; + } + // Attribute... driver->add_attr(new ppdcAttr(attr->name, attr->spec, attr->text, attr->value)); Index: ppdc/sample.drv =================================================================== --- ppdc/sample.drv (revision 8602) +++ ppdc/sample.drv (working copy) @@ -3,7 +3,7 @@ // // Driver info file for CUPS-supplied PPDs. // -// Copyright 2007-2008 by Apple Inc. +// Copyright 2007-2009 by Apple Inc. // Copyright 1993-2006 by Easy Software Products. // // These coded instructions, statements, and computer programs are the @@ -521,11 +521,10 @@ MinSize 36 36 MaxSize 630 7128 - UIConstraints "*inPrintMode Standard *inCutInterval " - UIConstraints "*inPrintMode Standard *inTearInterval " - UIConstraints "*inPrintMode Tear *inCutInterval " - UIConstraints "*inTearInterval *inPrintMode Cut" - UIConstraints "*inTearInterval *inPrintMode Standard" + UIConstraints "*inPrintMode Standard *inCutInterval" + UIConstraints "*inPrintMode Tear *inCutInterval" + UIConstraints "*inPrintMode Standard *inTearInterval" + UIConstraints "*inPrintMode Cut *inTearInterval" *MediaSize w288h432 Property changes on: ppdc/sample.drv ___________________________________________________________________ Added: svn:keywords + Id Index: ppdc/Makefile =================================================================== --- ppdc/Makefile (revision 8602) +++ ppdc/Makefile (working copy) @@ -58,6 +58,7 @@ libcupsppdc.a UNITTARGETS = \ ppdc-static \ + ppdi-static \ testcatalog EXECTARGETS = \ ppdc \ @@ -101,8 +102,8 @@ $(RM) $(OBJS) core $(RM) *.bak *.bck core.* $(RM) $(TARGETS) $(UNITTARGETS) - $(RM) -r ppd - $(RM) sample.c test.drv + $(RM) -r ppd ppd2 + $(RM) sample-import.drv sample.c test.drv $(RM) libcupsppdc.so libcupsppdc.sl libcupsppdc.dylib @@ -282,6 +283,24 @@ $(CXX) $(LDFLAGS) -o $@ ppdi.o -L. -lcupsppdc $(LIBS) +ppdi-static: ppdc-static ppdi.o libcupsppdc.a ../cups/libcups.a + echo Linking $@... + $(CXX) $(ARCHFLAGS) $(LDFLAGS) -o ppdi-static ppdi.o libcupsppdc.a \ + ../cups/libcups.a $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) \ + $(COMMONLIBS) $(LIBZ) + echo Testing PPD importer... + $(RM) -r ppd ppd2 sample-import.drv + ./ppdc-static -I ../data sample.drv + ./ppdi-static -I ../data -o sample-import.drv ppd/* + ./ppdc-static -I ../data -d ppd2 sample-import.drv + if diff -qr ppd ppd2; then \ + echo PPD import OK; \ + else \ + echo PPD import FAILED; \ + exit 1; \ + fi + + # # ppdmerge, merge PPD files. # Property changes on: ppdc ___________________________________________________________________ Modified: svn:ignore - genstrings libcupsppdc.a libcupsppdc.dylib libcupsppdc.1.dylib libcupsppdc.sl libcupsppdc.sl.1 libcupsppdc.so libcupsppdc.so.1 libcupsppdc_s.a ppd ppdc ppdc-static ppdhtml ppdi ppdmerge ppdpo sample.c testcatalog + genstrings libcupsppdc.a libcupsppdc.dylib libcupsppdc.1.dylib libcupsppdc.sl libcupsppdc.sl.1 libcupsppdc.so libcupsppdc.so.1 libcupsppdc_s.a ppd ppd2 ppdc ppdc-static ppdhtml ppdi ppdi-static ppdmerge ppdpo sample.c sample-import.drv testcatalog