summaryrefslogtreecommitdiff
path: root/ppdc/ppdc-source.cxx
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2008-05-21 01:15:17 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2008-05-21 01:15:17 +0000
commitbdd6c45b5e42206a5add7bf770196531dd8ad811 (patch)
tree0c0c794dd8f5da9ab0bf589b2cb9fd2a7e0778ca /ppdc/ppdc-source.cxx
parent20fbc9034781e607f8063453c8a52ec73fc5c293 (diff)
downloadcups-bdd6c45b5e42206a5add7bf770196531dd8ad811.tar.gz
Merge changes from CUPS 1.4svn-r7607.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@784 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'ppdc/ppdc-source.cxx')
-rw-r--r--ppdc/ppdc-source.cxx638
1 files changed, 562 insertions, 76 deletions
diff --git a/ppdc/ppdc-source.cxx b/ppdc/ppdc-source.cxx
index e397f0abb..ac64a1a30 100644
--- a/ppdc/ppdc-source.cxx
+++ b/ppdc/ppdc-source.cxx
@@ -93,12 +93,15 @@ const char *ppdcSource::driver_types[] =
ppdcSource::ppdcSource(const char *f) // I - File to read
{
- filename = new ppdcString(f);
- base_fonts = new ppdcArray();
- drivers = new ppdcArray();
- po_files = new ppdcArray();
- sizes = new ppdcArray();
- vars = new ppdcArray();
+ filename = new ppdcString(f);
+ base_fonts = new ppdcArray();
+ drivers = new ppdcArray();
+ po_files = new ppdcArray();
+ sizes = new ppdcArray();
+ vars = new ppdcArray();
+ cond_state = PPDC_COND_NORMAL;
+ cond_current = cond_stack;
+ cond_stack[0] = PPDC_COND_NORMAL;
if (f)
read_file(f);
@@ -295,7 +298,8 @@ ppdcSource::find_variable(const char *n)// I - Variable name
//
ppdcAttr * // O - Attribute
-ppdcSource::get_attr(ppdcFile *fp) // I - File to read
+ppdcSource::get_attr(ppdcFile *fp, // I - File to read
+ bool loc) // I - Localize this attribute?
{
char name[1024], // Name string
selector[1024], // Selector string
@@ -308,15 +312,16 @@ 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 Attribute on line %d of %s!\n",
- fp->line, fp->filename);
+ fprintf(stderr, "ppdc: Expected name after %sAttribute on line %d of %s!\n",
+ loc ? "Loc" : "", fp->line, fp->filename);
return (0);
}
if (!get_token(fp, selector, sizeof(selector)))
{
- fprintf(stderr, "ppdc: Expected selector after Attribute on line %d of %s!\n",
- fp->line, fp->filename);
+ fprintf(stderr,
+ "ppdc: Expected selector after %sAttribute on line %d of %s!\n",
+ loc ? "Loc" : "", fp->line, fp->filename);
return (0);
}
@@ -325,14 +330,15 @@ ppdcSource::get_attr(ppdcFile *fp) // I - File to read
if (!get_token(fp, value, sizeof(value)))
{
- fprintf(stderr, "ppdc: Expected value after Attribute on line %d of %s!\n",
- fp->line, fp->filename);
+ fprintf(stderr,
+ "ppdc: Expected value after %sAttribute on line %d of %s!\n",
+ loc ? "Loc" : "", fp->line, fp->filename);
return (0);
}
// printf("name=\"%s\", selector=\"%s\", value=\"%s\"\n", name, selector, value);
- return (new ppdcAttr(name, selector, text, value));
+ return (new ppdcAttr(name, selector, text, value, loc));
}
@@ -778,6 +784,9 @@ ppdcSource::get_duplex(ppdcFile *fp, // I - File to read from
return;
}
+ if (cond_state)
+ return;
+
if (!strcasecmp(temp, "none") || !strcasecmp(temp, "false") ||
!strcasecmp(temp, "no") || !strcasecmp(temp, "off"))
{
@@ -1130,7 +1139,6 @@ ppdcSource::get_group(ppdcFile *fp, // I - File to read
{
// Nope, add a new one...
g = new ppdcGroup(name, text);
- d->add_group(g);
}
return (g);
@@ -1180,19 +1188,31 @@ ppdcSource::get_installable(ppdcFile *fp)
// 'ppdcSource::get_integer()' - Get an integer value from a string.
//
+#define PPDC_XX -1 // Bad
+#define PPDC_EQ 0 // ==
+#define PPDC_NE 1 // !=
+#define PPDC_LT 2 // <
+#define PPDC_LE 3 // <=
+#define PPDC_GT 4 // >
+#define PPDC_GE 5 // >=
+
int // O - Integer value
ppdcSource::get_integer(const char *v) // I - Value string
{
- long val; // Value
- long temp; // Temporary value
- char *newv; // New value string pointer
+ long val; // Value
+ long temp, // Temporary value
+ temp2; // Second temporary value
+ char *newv, // New value string pointer
+ ch; // Temporary character
+ ppdcVariable *var; // #define variable
+ int compop; // Comparison operator
// Parse the value string...
if (!v)
return (-1);
- if (isdigit(*v) || *v == '-' || *v == '+')
+ if (isdigit(*v & 255) || *v == '-' || *v == '+')
{
// Return a simple integer value
val = strtol(v, (char **)&v, 0);
@@ -1203,29 +1223,187 @@ ppdcSource::get_integer(const char *v) // I - Value string
}
else if (*v == '(')
{
- // Return the bitwise OR of each integer in parenthesis...
+ // Evaluate and expression in any of the following formats:
+ //
+ // (number number ... number) Bitwise OR of all numbers
+ // (NAME == value) 1 if equal, 0 otherwise
+ // (NAME != value) 1 if not equal, 0 otherwise
+ // (NAME < value) 1 if less than, 0 otherwise
+ // (NAME <= value) 1 if less than or equal, 0 otherwise
+ // (NAME > value) 1 if greater than, 0 otherwise
+ // (NAME >= value) 1 if greater than or equal, 0 otherwise
+
v ++;
val = 0;
while (*v && *v != ')')
{
- temp = strtol(v, &newv, 0);
+ // Skip leading whitespace...
+ while (*v && isspace(*v & 255));
+ v ++;
+
+ if (!*v || *v == ')')
+ break;
+
+ if (isdigit(*v & 255) || *v == '-' || *v == '+')
+ {
+ // Bitwise OR a number...
+ temp = strtol(v, &newv, 0);
+
+ if (!*newv || newv == v || !(isspace(*newv) || *newv == ')') ||
+ temp == LONG_MIN)
+ return (-1);
+ }
+ else
+ {
+ // NAME logicop value
+ for (newv = (char *)v + 1;
+ *newv && (isalnum(*newv & 255) || *newv == '_');
+ newv ++);
+
+ ch = *newv;
+ *newv = '\0';
+
+ if ((var = find_variable(v)) != NULL)
+ {
+ if (!var->value || !var->value->value || !var->value->value[0])
+ temp = 0;
+ else if (isdigit(var->value->value[0] & 255) ||
+ var->value->value[0] == '-' ||
+ var->value->value[0] == '+')
+ temp = strtol(var->value->value, NULL, 0);
+ else
+ temp = 1;
+ }
+ else
+ temp = 0;
+
+ *newv = ch;
+ while (isspace(*newv & 255))
+ newv ++;
+
+ if (strncmp(newv, "==", 2))
+ {
+ compop = PPDC_EQ;
+ newv += 2;
+ }
+ else if (strncmp(newv, "!=", 2))
+ {
+ compop = PPDC_NE;
+ newv += 2;
+ }
+ else if (strncmp(newv, "<=", 2))
+ {
+ compop = PPDC_LE;
+ newv += 2;
+ }
+ else if (*newv == '<')
+ {
+ compop = PPDC_LT;
+ newv ++;
+ }
+ else if (strncmp(newv, ">=", 2))
+ {
+ compop = PPDC_GE;
+ newv += 2;
+ }
+ else if (*newv == '>')
+ {
+ compop = PPDC_GT;
+ newv ++;
+ }
+ else
+ compop = PPDC_XX;
+
+ if (compop != PPDC_XX)
+ {
+ while (isspace(*newv & 255))
+ newv ++;
+
+ if (*newv == ')' || !*newv)
+ return (-1);
+
+ if (isdigit(*v & 255) || *v == '-' || *v == '+')
+ {
+ // Get the second number...
+ temp2 = strtol(newv, &newv, 0);
+ if (!*newv || newv == v || !(isspace(*newv) || *newv == ')') ||
+ temp == LONG_MIN)
+ return (-1);
+ }
+ else
+ {
+ // Lookup the second name...
+ for (v = newv, newv ++;
+ *newv && (isalnum(*newv & 255) || *newv == '_');
+ newv ++);
- if (!*newv || newv == v || !(isspace(*newv) || *newv == ')') ||
- temp == LONG_MIN)
- return (-1);
+ ch = *newv;
+ *newv = '\0';
+
+ if ((var = find_variable(v)) != NULL)
+ {
+ if (!var->value || !var->value->value || !var->value->value[0])
+ temp2 = 0;
+ else if (isdigit(var->value->value[0] & 255) ||
+ var->value->value[0] == '-' ||
+ var->value->value[0] == '+')
+ temp2 = strtol(var->value->value, NULL, 0);
+ else
+ temp2 = 1;
+ }
+ else
+ temp2 = 0;
+
+ *newv = ch;
+ }
+
+ // Do the comparison...
+ switch (compop)
+ {
+ case PPDC_EQ :
+ temp = temp == temp2;
+ break;
+ case PPDC_NE :
+ temp = temp != temp2;
+ break;
+ case PPDC_LT :
+ temp = temp < temp2;
+ break;
+ case PPDC_LE :
+ temp = temp <= temp2;
+ break;
+ case PPDC_GT :
+ temp = temp > temp2;
+ break;
+ case PPDC_GE :
+ temp = temp >= temp2;
+ break;
+ }
+ }
+ }
val |= temp;
v = newv;
}
- if (*v == ')')
+ if (*v == ')' && !v[1])
return ((int)val);
else
return (-1);
}
+ else if ((var = find_variable(v)) != NULL)
+ {
+ // NAME by itself returns 1 if the #define variable is not blank and
+ // not "0"...
+ return (var->value->value && var->value->value[0] &&
+ strcmp(var->value->value, "0"));
+ }
else
+ {
+ // Anything else is an error...
return (-1);
+ }
}
@@ -1374,13 +1552,13 @@ ppdcSource::get_option(ppdcFile *fp, // I - File to read
{
// Nope, add a new one...
o = new ppdcOption(ot, name, text, section, order);
- g->add_option(o);
}
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 already defined with a different type on line %d of %s!\n",
+ fprintf(stderr,
+ "ppdc: Option redefined with a different type on line %d of %s!\n",
fp->line, fp->filename);
return (NULL);
}
@@ -2111,6 +2289,9 @@ ppdcSource::read_file(const char *f) // I - File to read
ppdcFile *fp = new ppdcFile(f);
scan_file(fp);
delete fp;
+
+ if (cond_current != cond_stack)
+ fprintf(stderr, "ppdc: Missing #endif at end of \"%s\"!\n", f);
}
@@ -2155,6 +2336,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
// Loop until EOF or }
o = 0;
g = general;
+
while (get_token(fp, temp, sizeof(temp)))
{
if (temp[0] == '*')
@@ -2183,6 +2365,113 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
// Open a new child...
scan_file(fp, d);
}
+ else if (!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);
+ break;
+ }
+
+ cond_current ++;
+ if (get_integer(fp))
+ *cond_current = PPDC_COND_SATISFIED;
+ else
+ {
+ *cond_current = PPDC_COND_SKIP;
+ cond_state |= PPDC_COND_SKIP;
+ }
+ }
+ else if (!strcasecmp(temp, "#elif"))
+ {
+ if (cond_current == cond_stack)
+ {
+ fprintf(stderr, "ppdc: Missing #if on line %d of %s!\n", fp->line,
+ fp->filename);
+ break;
+ }
+
+ if (*cond_current & PPDC_COND_SATISFIED)
+ {
+ get_integer(fp);
+ *cond_current |= PPDC_COND_SKIP;
+ }
+ else if (get_integer(fp))
+ {
+ *cond_current |= PPDC_COND_SATISFIED;
+ *cond_current &= ~PPDC_COND_SKIP;
+ }
+ else
+ *cond_current |= PPDC_COND_SKIP;
+
+ // Update the current state
+ int *cond_temp = cond_current; // Temporary stack pointer
+
+ cond_state = PPDC_COND_NORMAL;
+ while (cond_temp > cond_stack)
+ if (*cond_temp & PPDC_COND_SKIP)
+ {
+ cond_state = PPDC_COND_SKIP;
+ break;
+ }
+ else
+ cond_temp --;
+ }
+ else if (!strcasecmp(temp, "#else"))
+ {
+ if (cond_current == cond_stack)
+ {
+ fprintf(stderr, "ppdc: Missing #if on line %d of %s!\n", fp->line,
+ fp->filename);
+ break;
+ }
+
+ if (*cond_current & PPDC_COND_SATISFIED)
+ *cond_current |= PPDC_COND_SKIP;
+ else
+ {
+ *cond_current |= PPDC_COND_SATISFIED;
+ *cond_current &= ~PPDC_COND_SKIP;
+ }
+
+ // Update the current state
+ int *cond_temp = cond_current; // Temporary stack pointer
+
+ cond_state = PPDC_COND_NORMAL;
+ while (cond_temp > cond_stack)
+ if (*cond_temp & PPDC_COND_SKIP)
+ {
+ cond_state = PPDC_COND_SKIP;
+ break;
+ }
+ else
+ cond_temp --;
+ }
+ else if (!strcasecmp(temp, "#endif"))
+ {
+ if (cond_current == cond_stack)
+ {
+ fprintf(stderr, "ppdc: Missing #if on line %d of %s!\n", fp->line,
+ fp->filename);
+ break;
+ }
+
+ cond_current --;
+
+ // Update the current state
+ int *cond_temp = cond_current; // Temporary stack pointer
+
+ cond_state = PPDC_COND_NORMAL;
+ while (cond_temp > cond_stack)
+ if (*cond_temp & PPDC_COND_SKIP)
+ {
+ cond_state = PPDC_COND_SKIP;
+ break;
+ }
+ else
+ cond_temp --;
+ }
else if (!strcasecmp(temp, "#define"))
{
// Get the variable...
@@ -2196,6 +2485,8 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
inctemp[1024], // Initial filename
incname[1024]; // Include filename
ppdcFile *incfile; // Include file
+ int *old_current = cond_current;
+ // Previous current stack
// Get the include name...
@@ -2206,13 +2497,16 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
break;
}
+ if (cond_state)
+ continue;
+
// Figure out the current directory...
strlcpy(basedir, fp->filename, sizeof(basedir));
if ((baseptr = strrchr(basedir, '/')) != NULL)
- *baseptr = '\0';
+ *baseptr = '\0';
else
- strcpy(basedir, ".");
+ strcpy(basedir, ".");
// Find the include file...
if (find_include(inctemp, basedir, incname, sizeof(incname)))
@@ -2221,13 +2515,16 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
incfile = new ppdcFile(incname);
scan_file(incfile, d, true);
delete incfile;
+
+ if (cond_current != old_current)
+ fprintf(stderr, "ppdc: Missing #endif at end of \"%s\"!\n", incname);
}
else
{
- // Can't find it!
+ // Can't find it!
fprintf(stderr,
- "ppdc: Unable to find include file \"%s\" on line %d of %s!\n",
- inctemp, fp->line, fp->filename);
+ "ppdc: Unable to find include file \"%s\" on line %d of %s!\n",
+ inctemp, fp->line, fp->filename);
break;
}
}
@@ -2239,7 +2536,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
// Get a media size...
m = get_size(fp);
if (m)
- sizes->add(m);
+ {
+ if (cond_state)
+ m->release();
+ else
+ sizes->add(m);
+ }
}
else if (!strcasecmp(temp, "#po"))
{
@@ -2249,21 +2551,43 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
// Get a message catalog...
cat = get_po(fp);
if (cat)
- po_files->add(cat);
+ {
+ if (cond_state)
+ cat->release();
+ else
+ po_files->add(cat);
+ }
}
- else if (!strcasecmp(temp, "Attribute"))
+ else if (!strcasecmp(temp, "Attribute") ||
+ !strcasecmp(temp, "LocAttribute"))
{
ppdcAttr *a; // Attribute
// Get an attribute...
- a = get_attr(fp);
+ a = get_attr(fp, !strcasecmp(temp, "LocAttribute"));
if (a)
- d->add_attr(a);
+ {
+ if (cond_state)
+ a->release();
+ else
+ d->add_attr(a);
+ }
}
else if (!strcasecmp(temp, "Choice"))
{
// Get a choice...
+ c = get_choice(fp);
+ if (!c)
+ break;
+
+ if (cond_state)
+ {
+ c->release();
+ continue;
+ }
+
+ // Add it to the current option...
if (!o)
{
fprintf(stderr, "ppdc: Choice found on line %d of %s with no Option!\n",
@@ -2271,11 +2595,6 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
break;
}
- c = get_choice(fp);
- if (!c)
- break;
-
- // Add it to the current option...
o->add_choice(c);
if (isdefault)
@@ -2284,7 +2603,10 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
else if (!strcasecmp(temp, "ColorDevice"))
{
// ColorDevice boolean
- d->color_device = get_boolean(fp);
+ if (cond_state)
+ get_boolean(fp);
+ else
+ d->color_device = get_boolean(fp);
}
else if (!strcasecmp(temp, "ColorModel"))
{
@@ -2293,6 +2615,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
if (!c)
continue;
+ if (cond_state)
+ {
+ c->release();
+ continue;
+ }
+
// Add the choice to the ColorModel option...
if ((o = d->find_option("ColorModel")) == NULL)
{
@@ -2318,7 +2646,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
p = get_color_profile(fp);
if (p)
- d->profiles->add(p);
+ {
+ if (cond_state)
+ p->release();
+ else
+ d->profiles->add(p);
+ }
}
else if (!strcasecmp(temp, "Copyright"))
{
@@ -2337,6 +2670,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
break;
}
+ if (cond_state)
+ continue;
+
// Break it up into individual lines...
for (copyptr = copytemp; copyptr; copyptr = copyend)
{
@@ -2353,6 +2689,13 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
// Get a custom media size...
m = get_custom_size(fp);
+
+ if (cond_state)
+ {
+ m->release();
+ continue;
+ }
+
if (m)
d->sizes->add(m);
@@ -2366,7 +2709,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
have_cutter = get_boolean(fp);
- if (have_cutter <= 0)
+ if (have_cutter <= 0 || cond_state)
continue;
if ((o = d->find_option("CutMedia")) == NULL)
@@ -2393,6 +2736,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
if (!c)
continue;
+ if (cond_state)
+ {
+ c->release();
+ continue;
+ }
+
// Add the choice to the cupsDarkness option...
if ((o = d->find_option("cupsDarkness")) == NULL)
{
@@ -2422,6 +2771,9 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
continue;
}
+ if (cond_state)
+ continue;
+
for (i = 0; i < (int)(sizeof(driver_types) / sizeof(driver_types[0])); i ++)
if (!strcasecmp(temp, driver_types[i]))
break;
@@ -2444,7 +2796,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
// Get the filter value...
f = get_filter(fp);
if (f)
- d->filters->add(f);
+ {
+ if (cond_state)
+ f->release();
+ else
+ d->filters->add(f);
+ }
}
else if (!strcasecmp(temp, "Finishing"))
{
@@ -2453,6 +2810,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
if (!c)
continue;
+ if (cond_state)
+ {
+ c->release();
+ continue;
+ }
+
// Add the choice to the cupsFinishing option...
if ((o = d->find_option("cupsFinishing")) == NULL)
{
@@ -2479,21 +2842,40 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
f = get_font(fp);
if (f)
{
- if (!strcasecmp(temp, "#font"))
- base_fonts->add(f);
- else
- d->add_font(f);
+ if (cond_state)
+ f->release();
+ else
+ {
+ if (!strcasecmp(temp, "#font"))
+ base_fonts->add(f);
+ else
+ d->add_font(f);
- if (isdefault)
- d->set_default_font(f);
+ if (isdefault)
+ d->set_default_font(f);
+ }
}
}
else if (!strcasecmp(temp, "Group"))
{
// Get a group...
- g = get_group(fp, d);
- if (!g)
+ ppdcGroup *tempg = get_group(fp, d);
+
+ if (!tempg)
break;
+
+ if (cond_state)
+ {
+ if (!d->find_group(tempg->name->value))
+ tempg->release();
+ }
+ else
+ {
+ if (!d->find_group(tempg->name->value))
+ d->add_group(tempg);
+
+ g = tempg;
+ }
}
else if (!strcasecmp(temp, "HWMargins"))
{
@@ -2510,6 +2892,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
if (!c)
continue;
+ if (cond_state)
+ {
+ c->release();
+ continue;
+ }
+
// Add the choice to the InputSlot option...
if ((o = d->find_option("InputSlot")) == NULL)
{
@@ -2535,14 +2923,21 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
// Add it as needed...
if (o)
{
- install->add_option(o);
+ if (cond_state)
+ o->release();
+ else
+ install->add_option(o);
+
o = NULL;
}
}
else if (!strcasecmp(temp, "ManualCopies"))
{
// ManualCopies boolean
- d->manual_copies = get_boolean(fp);
+ if (cond_state)
+ get_boolean(fp);
+ else
+ d->manual_copies = get_boolean(fp);
}
else if (!strcasecmp(temp, "Manufacturer"))
{
@@ -2557,13 +2952,22 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
break;
}
- d->set_manufacturer(name);
+ if (!cond_state)
+ d->set_manufacturer(name);
}
else if (!strcasecmp(temp, "MaxSize"))
{
// MaxSize width length
- d->max_width = get_measurement(fp);
- d->max_length = get_measurement(fp);
+ if (cond_state)
+ {
+ get_measurement(fp);
+ get_measurement(fp);
+ }
+ else
+ {
+ d->max_width = get_measurement(fp);
+ d->max_length = get_measurement(fp);
+ }
}
else if (!strcasecmp(temp, "MediaSize"))
{
@@ -2575,11 +2979,15 @@ 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",
+ fprintf(stderr,
+ "ppdc: Expected name after MediaSize on line %d of %s!\n",
fp->line, fp->filename);
break;
}
+ if (cond_state)
+ continue;
+
m = find_size(name);
if (!m)
@@ -2606,6 +3014,12 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
if (!c)
continue;
+ if (cond_state)
+ {
+ c->release();
+ continue;
+ }
+
// Add the choice to the MediaType option...
if ((o = d->find_option("MediaType")) == NULL)
{
@@ -2626,8 +3040,16 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
else if (!strcasecmp(temp, "MinSize"))
{
// MinSize width length
- d->min_width = get_measurement(fp);
- d->min_length = get_measurement(fp);
+ if (cond_state)
+ {
+ get_measurement(fp);
+ get_measurement(fp);
+ }
+ else
+ {
+ d->min_width = get_measurement(fp);
+ d->min_length = get_measurement(fp);
+ }
}
else if (!strcasecmp(temp, "ModelName"))
{
@@ -2642,34 +3064,71 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
break;
}
- d->set_model_name(name);
+ if (!cond_state)
+ d->set_model_name(name);
}
else if (!strcasecmp(temp, "ModelNumber"))
{
// ModelNumber number
- d->model_number = get_integer(fp);
+ if (cond_state)
+ get_integer(fp);
+ else
+ d->model_number = get_integer(fp);
}
else if (!strcasecmp(temp, "Option"))
{
// Get an option...
- o = get_option(fp, d, g);
- if (!o)
+ ppdcOption *tempo = get_option(fp, d, g);
+
+ if (!tempo)
break;
+
+ if (cond_state)
+ {
+ if (!g->find_option(tempo->name->value))
+ tempo->release();
+ }
+ else
+ {
+ if (!g->find_option(tempo->name->value))
+ g->add_option(tempo);
+
+ o = tempo;
+ }
+ }
+ else if (!strcasecmp(temp, "FileName"))
+ {
+ // FileName name
+ char name[256]; // Filename string
+
+
+ if (!get_token(fp, name, sizeof(name)))
+ {
+ fprintf(stderr,
+ "ppdc: Expected name after FileName on line %d of %s!\n",
+ fp->line, fp->filename);
+ break;
+ }
+
+ if (!cond_state)
+ d->set_file_name(name);
}
else if (!strcasecmp(temp, "PCFileName"))
{
// PCFileName name
- char name[256]; // Model name string
+ char name[256]; // PC filename string
if (!get_token(fp, name, sizeof(name)))
{
- fprintf(stderr, "ppdc: Expected name after PCFileName on line %d of %s!\n",
+ fprintf(stderr,
+ "ppdc: Expected name after PCFileName on line %d of %s!\n",
fp->line, fp->filename);
break;
}
- d->set_pc_file_name(name);
+ if (!cond_state)
+ d->set_pc_file_name(name);
}
else if (!strcasecmp(temp, "Resolution"))
{
@@ -2678,11 +3137,18 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
if (!c)
continue;
+ if (cond_state)
+ {
+ c->release();
+ continue;
+ }
+
// Add the choice to the Resolution option...
if ((o = d->find_option("Resolution")) == NULL)
{
// Create the Resolution option...
- o = new ppdcOption(PPDC_PICKONE, "Resolution", NULL, PPDC_SECTION_ANY, 10.0f);
+ o = new ppdcOption(PPDC_PICKONE, "Resolution", NULL, PPDC_SECTION_ANY,
+ 10.0f);
g = general;
g->add_option(o);
}
@@ -2703,12 +3169,20 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
p = get_simple_profile(fp);
if (p)
- d->profiles->add(p);
+ {
+ if (cond_state)
+ p->release();
+ else
+ d->profiles->add(p);
+ }
}
else if (!strcasecmp(temp, "Throughput"))
{
// Throughput number
- d->throughput = get_integer(fp);
+ if (cond_state)
+ get_integer(fp);
+ else
+ d->throughput = get_integer(fp);
}
else if (!strcasecmp(temp, "UIConstraints"))
{
@@ -2718,12 +3192,20 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read
con = get_constraint(fp);
if (con)
- d->constraints->add(con);
+ {
+ if (cond_state)
+ con->release();
+ else
+ d->constraints->add(con);
+ }
}
else if (!strcasecmp(temp, "VariablePaperSize"))
{
// VariablePaperSize boolean
- d->variable_paper_size = get_boolean(fp);
+ if (cond_state)
+ get_boolean(fp);
+ else
+ d->variable_paper_size = get_boolean(fp);
}
else if (!strcasecmp(temp, "Version"))
{
@@ -2733,12 +3215,14 @@ 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",
+ fprintf(stderr,
+ "ppdc: Expected string after Version on line %d of %s!\n",
fp->line, fp->filename);
break;
}
- d->set_version(name);
+ if (!cond_state)
+ d->set_version(name);
}
else
{
@@ -2871,6 +3355,8 @@ ppdcSource::write_file(const char *f) // I - File to write
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)
+ quotef(fp, " FileName \"%s\"\n", d->file_name->value);
if (d->pc_file_name->value)
quotef(fp, " PCFileName \"%s\"\n", d->pc_file_name->value);
if (d->version->value)