diff options
Diffstat (limited to 'src/foomatic/printer_options.c')
-rw-r--r-- | src/foomatic/printer_options.c | 225 |
1 files changed, 136 insertions, 89 deletions
diff --git a/src/foomatic/printer_options.c b/src/foomatic/printer_options.c index d3a3b42..6848354 100644 --- a/src/foomatic/printer_options.c +++ b/src/foomatic/printer_options.c @@ -1,7 +1,7 @@ /* - * "$Id: printer_options.c,v 1.50 2006/05/28 16:59:03 rlk Exp $" + * "$Id: printer_options.c,v 1.50.8.2 2007/05/29 01:47:27 rlk Exp $" * - * Dump the per-printer options for Grant Taylor's *-omatic database + * Dump the per-printer options for the OpenPrinting database * * Copyright 2000 Robert Krawitz (rlk@alum.mit.edu) * @@ -33,10 +33,12 @@ main(int argc, char **argv) { int i, j, k; stp_parameter_level_t max_level = STP_PARAMETER_LEVEL_ADVANCED4; + stp_string_list_t *params_seen; if (argc > 1 && !strcmp(argv[1], "-s")) max_level = STP_PARAMETER_LEVEL_BASIC; stp_init(); + params_seen = stp_string_list_create(); for (i = 0; i < stp_printer_model_count(); i++) { stp_parameter_list_t params; @@ -83,65 +85,96 @@ main(int argc, char **argv) stp_describe_parameter(pv, p->name, &desc); if (desc.is_active) { + char buf[1024]; + sprintf(buf, "STP_%s", desc.name); + if (!stp_string_list_find(params_seen, buf)) + { + stp_string_list_add_string(params_seen, buf, buf); + if ((desc.p_type == STP_PARAMETER_TYPE_DOUBLE || + desc.p_type == STP_PARAMETER_TYPE_DIMENSION || + desc.p_type == STP_PARAMETER_TYPE_INT) && + !desc.is_mandatory) + { + sprintf(buf, "STP_Enable%s", desc.name); + if (!stp_string_list_find(params_seen, buf)) + { + stp_string_list_add_string(params_seen, buf, buf); + /* + * Create a dummy option that enables or disables + * the option as appropriate. The long name ends in + * enable, rather than starts with enable, because + * CUPS has this nasty habit of sorting options + * alphabetically rather than leaving them in the + * order listed. This ensures that the enable + * option is adjacent to the value it controls. + */ + printf("$longnames{'STP_Enable%s'} = '%s Enable';", + desc.name, desc.text); + printf("$param_classes{'STP_Enable%s'} = %d;", + desc.name, desc.p_class); + printf("$param_levels{'STP_Enable%s'} = %d;", + desc.name, desc.p_level); + printf("$longnames{'STP_%s'} = '%s Value';", + desc.name, desc.text); + } + } + else + printf("$longnames{'STP_%s'} = '%s';", + desc.name, desc.text); + printf("$param_classes{'STP_%s'} = %d;", + desc.name, desc.p_class); + printf("$param_levels{'STP_%s'} = %d;", + desc.name, desc.p_level); + } if ((desc.p_type == STP_PARAMETER_TYPE_DOUBLE || desc.p_type == STP_PARAMETER_TYPE_DIMENSION || desc.p_type == STP_PARAMETER_TYPE_INT) && !desc.is_mandatory) { - /* - * Create a dummy option that enables or disables - * the option as appropriate. The long name ends in - * enable, rather than starts with enable, because - * CUPS has this nasty habit of sorting options - * alphabetically rather than leaving them in the - * order listed. This ensures that the enable - * option is adjacent to the value it controls. - */ - printf("$longnames{'STP_Enable%s'} = '%s Enable';\n", - desc.name, desc.text); - printf("$param_classes{'STP_Enable%s'} = %d;\n", - desc.name, desc.p_class); - printf("$param_levels{'STP_Enable%s'} = %d;\n", - desc.name, desc.p_level); - printf("$defaults{'%s'}{'STP_Enable%s'} = 'Disabled';\n", + printf("$defaults{'%s'}{'STP_Enable%s'} = 'Disabled';", driver, desc.name); - printf("$stpdata{'%s'}{'STP_Enable%s'}{'Disabled'} = 'Disabled';\n", + printf("$stpdata{'%s'}{'STP_Enable%s'}{'Disabled'} = 'Disabled';", driver, desc.name); - printf("$stpdata{'%s'}{'STP_Enable%s'}{'Enabled'} = 'Enabled';\n", + printf("$stpdata{'%s'}{'STP_Enable%s'}{'Enabled'} = 'Enabled';", driver, desc.name); - printf("$longnames{'STP_%s'} = '%s Value';\n", - desc.name, desc.text); } - else - printf("$longnames{'STP_%s'} = '%s';\n", - desc.name, desc.text); - printf("$param_classes{'STP_%s'} = %d;\n", - desc.name, desc.p_class); - printf("$param_levels{'STP_%s'} = %d;\n", - desc.name, desc.p_level); if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) { count = stp_string_list_count(desc.bounds.str); if (count > 0) { + printf("{ $stpdata{'%s'}{'STP_%s'} = {};", + driver, desc.name); + printf("my $tmp = $stpdata{'%s'}{'STP_%s'};", + driver, desc.name); + if (strcmp(desc.name, "Resolution") == 0) + { + printf("$stpdata{'%s'}{'x_resolution'} = {};", + driver); + printf("my $x_t = $stpdata{'%s'}{'x_resolution'};", + driver); + printf("$stpdata{'%s'}{'y_resolution'} = {};", + driver); + printf("my $y_t = $stpdata{'%s'}{'y_resolution'};", + driver); + } if (desc.is_mandatory) { - printf("$defaults{'%s'}{'STP_%s'} = '%s';\n", + printf("$defaults{'%s'}{'STP_%s'} = '%s';", driver, desc.name, desc.deflt.str); } else { - printf("$defaults{'%s'}{'STP_%s'} = '%s';\n", + printf("$defaults{'%s'}{'STP_%s'} = '%s';", driver, desc.name, "None"); - printf("$stpdata{'%s'}{'STP_%s'}{'%s'} = '%s';\n", - driver, desc.name, "None", "None"); + printf("$$tmp{'%s'} = '%s';", "None", "None"); } for (j = 0; j < count; j++) { const stp_param_string_t *param = stp_string_list_param(desc.bounds.str, j); - printf("$stpdata{'%s'}{'STP_%s'}{'%s'} = '%s';\n", - driver, desc.name, param->name, param->text); + printf("$$tmp{'%s'} = '%s';", + param->name, param->text); if (strcmp(desc.name, "Resolution") == 0) { int x, y; @@ -150,31 +183,30 @@ main(int argc, char **argv) stp_describe_resolution(pv, &x, &y); if (x > 0 && y > 0) { - printf("$stpdata{'%s'}{'%s'}{'%s'} = '%d';\n", - driver, "x_resolution", param->name, x); - printf("$stpdata{'%s'}{'%s'}{'%s'} = '%d';\n", - driver, "y_resolution", param->name, y); + printf("$$x_t{'%s'} = '%d';",param->name, x); + printf("$$y_t{'%s'} = '%d';",param->name, y); } } } + printf("}\n"); } } else if (desc.p_type == STP_PARAMETER_TYPE_BOOLEAN) { if (desc.is_mandatory) { - printf("$defaults{'%s'}{'STP_%s'} = '%d';\n", + printf("$defaults{'%s'}{'STP_%s'} = '%d';", driver, desc.name, desc.deflt.boolean); } else { - printf("$defaults{'%s'}{'STP_%s'} = '%s';\n", + printf("$defaults{'%s'}{'STP_%s'} = '%s';", driver, desc.name, "None"); - printf("$stpdata{'%s'}{'STP_%s'}{'%s'} = '%s';\n", + printf("$stpdata{'%s'}{'STP_%s'}{'%s'} = '%s';", driver, desc.name, "None", "None"); } - printf("$stpdata{'%s'}{'STP_%s'}{'False'} = 'False';\n", + printf("$stpdata{'%s'}{'STP_%s'}{'False'} = 'False';", driver, desc.name); printf("$stpdata{'%s'}{'STP_%s'}{'True'} = 'True';\n", driver, desc.name); @@ -184,20 +216,25 @@ main(int argc, char **argv) if (desc.bounds.dbl.lower <= desc.deflt.dbl && desc.bounds.dbl.upper >= desc.deflt.dbl) { - printf("$stp_float_values{'%s'}{'MINVAL'}{'STP_%s'} = %.3f;\n", - driver, desc.name, desc.bounds.dbl.lower); - printf("$stp_float_values{'%s'}{'MAXVAL'}{'STP_%s'} = %.3f;\n", - driver, desc.name, desc.bounds.dbl.upper); - printf("$stp_float_values{'%s'}{'DEFVAL'}{'STP_%s'} = %.3f;\n", - driver, desc.name, desc.deflt.dbl); - /* printf("$stp_float_values{'%s'}{'LONG_NAME'}{'STP_%s'} = '%s';\n", - driver, desc.name, gettext(desc.text)); */ - printf("$stp_float_values{'%s'}{'CATEGORY'}{'STP_%s'} = '%s';\n", - driver, desc.name, gettext(desc.category)); - printf("$stp_float_values{'%s'}{'HELP'}{'STP_%s'} = q(%s);\n", - driver, desc.name, (desc.help ? gettext(desc.help) : "''")); - printf("$stp_float_values{'%s'}{'MANDATORY'}{'STP_%s'} = q(%d);\n", - driver, desc.name, desc.is_mandatory); + printf("{ $stp_float_values{'%s'}{'STP_%s'} = {};", + driver, desc.name); + printf("my $tmp = $stp_float_values{'%s'}{'STP_%s'};", + driver, desc.name); + printf("$$tmp{'MINVAL'} = %.3f;", + desc.bounds.dbl.lower); + printf("$$tmp{'MAXVAL'} = %.3f;", + desc.bounds.dbl.upper); + printf("$$tmp{'DEFVAL'} = %.3f;", + desc.deflt.dbl); + /* printf("$$tmp{'LONG_NAME'} = '%s';", + gettext(desc.text)); */ + printf("$$tmp{'CATEGORY'} = '%s';", + gettext(desc.category)); + printf("$$tmp{'HELP'} = q(%s);", + (desc.help ? gettext(desc.help) : "''")); + printf("$$tmp{'MANDATORY'} = q(%d);", + desc.is_mandatory); + printf("}\n"); } } else if (desc.p_type == STP_PARAMETER_TYPE_INT) @@ -205,20 +242,25 @@ main(int argc, char **argv) if (desc.bounds.integer.lower <= desc.deflt.integer && desc.bounds.integer.upper >= desc.deflt.integer) { - printf("$stp_int_values{'%s'}{'MINVAL'}{'STP_%s'} = %d;\n", - driver, desc.name, desc.bounds.integer.lower); - printf("$stp_int_values{'%s'}{'MAXVAL'}{'STP_%s'} = %d;\n", - driver, desc.name, desc.bounds.integer.upper); - printf("$stp_int_values{'%s'}{'DEFVAL'}{'STP_%s'} = %d;\n", - driver, desc.name, desc.deflt.integer); - /* printf("$stp_int_values{'%s'}{'LONG_NAME'}{'STP_%s'} = '%s';\n", - driver, desc.name, gettext(desc.text)); */ - printf("$stp_int_values{'%s'}{'CATEGORY'}{'STP_%s'} = '%s';\n", - driver, desc.name, gettext(desc.category)); - printf("$stp_int_values{'%s'}{'HELP'}{'STP_%s'} = q(%s);\n", - driver, desc.name, (desc.help ? gettext(desc.help) : "''")); - printf("$stp_int_values{'%s'}{'MANDATORY'}{'STP_%s'} = q(%d);\n", - driver, desc.name, desc.is_mandatory); + printf("{ $stp_int_values{'%s'}{'STP_%s'} = {};", + driver, desc.name); + printf("my $tmp = $stp_int_values{'%s'}{'STP_%s'};", + driver, desc.name); + printf("$$tmp{'MINVAL'} = %d;", + desc.bounds.integer.lower); + printf("$$tmp{'MAXVAL'} = %d;", + desc.bounds.integer.upper); + printf("$$tmp{'DEFVAL'} = %d;", + desc.deflt.integer); + /* printf("$$tmp{'LONG_NAME'} = '%s';", + gettext(desc.text)); */ + printf("$$tmp{'CATEGORY'} = '%s';", + gettext(desc.category)); + printf("$$tmp{'HELP'} = q(%s);", + (desc.help ? gettext(desc.help) : "''")); + printf("$$tmp{'MANDATORY'} = q(%d);", + desc.is_mandatory); + printf("}\n"); } } else if (desc.p_type == STP_PARAMETER_TYPE_DIMENSION) @@ -226,20 +268,25 @@ main(int argc, char **argv) if (desc.bounds.dimension.lower <= desc.deflt.dimension && desc.bounds.dimension.upper >= desc.deflt.dimension) { - printf("$stp_dimension_values{'%s'}{'MINVAL'}{'STP_%s'} = %d;\n", - driver, desc.name, desc.bounds.dimension.lower); - printf("$stp_dimension_values{'%s'}{'MAXVAL'}{'STP_%s'} = %d;\n", - driver, desc.name, desc.bounds.dimension.upper); - printf("$stp_dimension_values{'%s'}{'DEFVAL'}{'STP_%s'} = %d;\n", - driver, desc.name, desc.deflt.dimension); - /* printf("$stp_dimension_values{'%s'}{'LONG_NAME'}{'STP_%s'} = '%s';\n", - driver, desc.name, gettext(desc.text)); */ - printf("$stp_dimension_values{'%s'}{'CATEGORY'}{'STP_%s'} = '%s';\n", - driver, desc.name, gettext(desc.category)); - printf("$stp_dimension_values{'%s'}{'HELP'}{'STP_%s'} = q(%s);\n", - driver, desc.name, (desc.help ? gettext(desc.help) : "''")); - printf("$stp_dimension_values{'%s'}{'MANDATORY'}{'STP_%s'} = q(%d);\n", - driver, desc.name, desc.is_mandatory); + printf("{ $stp_dimension_values{'%s'}{'STP_%s'} = {};", + driver, desc.name); + printf("my $tmp = $stp_dimension_values{'%s'}{'STP_%s'};", + driver, desc.name); + printf("$$tmp{'MINVAL'} = %d;", + desc.bounds.dimension.lower); + printf("$$tmp{'MAXVAL'} = %d;", + desc.bounds.dimension.upper); + printf("$$tmp{'DEFVAL'} = %d;", + desc.deflt.dimension); + /* printf("$$tmp{'LONG_NAME'} = '%s';", + gettext(desc.text)); */ + printf("$$tmp{'CATEGORY'} = '%s';", + gettext(desc.category)); + printf("$$tmp{'HELP'} = q(%s);", + (desc.help ? gettext(desc.help) : "''")); + printf("$$tmp{'MANDATORY'} = q(%d);", + desc.is_mandatory); + printf("}\n"); } } tcount += count; @@ -251,17 +298,17 @@ main(int argc, char **argv) { if (printer_is_color) { - printf("$defaults{'%s'}{'%s'} = '%s';\n", + printf("$defaults{'%s'}{'%s'} = '%s';", driver, "Color", "Color"); - printf("$stpdata{'%s'}{'%s'}{'%s'} = '%s';\n", + printf("$stpdata{'%s'}{'%s'}{'%s'} = '%s';", driver, "Color", "Color", "Color"); printf("$stpdata{'%s'}{'%s'}{'%s'} = '%s';\n", driver, "Color", "RawCMYK", "Raw CMYK"); } else - printf("$defaults{'%s'}{'%s'} = '%s';\n", + printf("$defaults{'%s'}{'%s'} = '%s';", driver, "Color", "Grayscale"); - printf("$stpdata{'%s'}{'%s'}{'%s'} = '%s';\n", + printf("$stpdata{'%s'}{'%s'}{'%s'} = '%s';", driver, "Color", "Grayscale", "Gray Scale"); printf("$stpdata{'%s'}{'%s'}{'%s'} = '%s';\n", driver, "Color", "BlackAndWhite", "Black and White"); |