/*
- * "$Id: attr.c,v 1.3 2003/01/31 20:09:20 mike Exp $"
+ * "$Id: attr.c,v 1.4 2003/02/28 21:06:08 mike Exp $"
*
* PPD model-specific attribute routines for the Common UNIX Printing System
* (CUPS).
* 'ppdFindAttr()' - Find the first matching attribute...
*/
-const char * /* O - Value or NULL if not found */
+ppd_attr_t * /* O - Attribute or NULL if not found */
ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */
const char *name, /* I - Attribute name */
const char *spec) /* I - Specifier string or NULL */
ppd->cur_attr = match - ppd->attrs;
- if ((*match)->value)
- return ((*match)->value);
- else
- return ("");
+ return (*match);
}
* 'ppdFindNextAttr()' - Find the next matching attribute...
*/
-const char * /* O - Value or NULL if not found */
+ppd_attr_t * /* O - Attribute or NULL if not found */
ppdFindNextAttr(ppd_file_t *ppd, /* I - PPD file data */
const char *name, /* I - Attribute name */
const char *spec) /* I - Specifier string or NULL */
* Return the next attribute's value...
*/
- if ((*match)->value)
- return ((*match)->value);
- else
- return ("");
+ return (*match);
}
/*
- * End of "$Id: attr.c,v 1.3 2003/01/31 20:09:20 mike Exp $".
+ * End of "$Id: attr.c,v 1.4 2003/02/28 21:06:08 mike Exp $".
*/
/*
- * "$Id: emit.c,v 1.30 2003/02/18 22:23:38 mike Exp $"
+ * "$Id: emit.c,v 1.31 2003/02/28 21:06:08 mike Exp $"
*
* PPD code emission routines for the Common UNIX Printing System (CUPS).
*
*input_slot, /* InputSlot choice, if any */
*page; /* PageSize/PageRegion */
ppd_size_t *size; /* Current media size */
- const char *rpr; /* RequiresPageRegion value */
+ ppd_attr_t *rpr; /* RequiresPageRegion value */
/*
ppdMarkOption(ppd, "PageRegion", size->name);
- if ((rpr && !strcmp(rpr, "False")) || (!rpr && !ppd->num_filters))
+ if ((rpr && rpr->value && !strcmp(rpr->value, "False")) ||
+ (!rpr && !ppd->num_filters))
{
/*
* Either the PPD file specifies no PageRegion code or the PPD file
/*
- * End of "$Id: emit.c,v 1.30 2003/02/18 22:23:38 mike Exp $".
+ * End of "$Id: emit.c,v 1.31 2003/02/28 21:06:08 mike Exp $".
*/
/*
- * "$Id: ppd.c,v 1.100 2003/02/28 10:28:25 mike Exp $"
+ * "$Id: ppd.c,v 1.101 2003/02/28 21:06:08 mike Exp $"
*
* PPD file routines for the Common UNIX Printing System (CUPS).
*
*/
static ppd_attr_t *ppd_add_attr(ppd_file_t *ppd, const char *name,
- const char *spec, const char *value);
+ const char *spec, const char *text,
+ const char *value);
static ppd_choice_t *ppd_add_choice(ppd_option_t *option, const char *name);
static ppd_size_t *ppd_add_size(ppd_file_t *ppd, const char *name);
#ifndef __APPLE__
* Add each Product keyword as an attribute...
*/
- ppd_add_attr(ppd, keyword, "", string);
+ ppd_add_attr(ppd, keyword, "", "", string);
/*
* Save the last one in the product element...
* Option not found; add this as an attribute...
*/
- ppd_add_attr(ppd, keyword, "", string);
+ ppd_add_attr(ppd, keyword, "", "", string);
string = NULL; /* Don't free this string below */
}
* Default doesn't match this option; add as an attribute...
*/
- ppd_add_attr(ppd, keyword, "", string);
+ ppd_add_attr(ppd, keyword, "", "", string);
string = NULL; /* Don't free this string below */
}
else if (strcmp(keyword, "OpenSubGroup") != 0 &&
strcmp(keyword, "CloseSubGroup") != 0)
{
- char spec[PPD_MAX_NAME + PPD_MAX_TEXT];
-
- if (text[0])
- {
- snprintf(spec, sizeof(spec), "%s/%s", name, text);
- ppd_add_attr(ppd, keyword, spec, string);
- }
- else
- ppd_add_attr(ppd, keyword, name, string);
+ ppd_add_attr(ppd, keyword, name, text, string);
string = NULL; /* Don't free this string below */
}
ppd_add_attr(ppd_file_t *ppd, /* I - PPD file data */
const char *name, /* I - Attribute name */
const char *spec, /* I - Specifier string, if any */
+ const char *text, /* I - Text string, if any */
const char *value) /* I - Value of attribute */
{
ppd_attr_t **ptr, /* New array */
strlcpy(temp->name, name, sizeof(temp->name));
strlcpy(temp->spec, spec, sizeof(temp->spec));
+ strlcpy(temp->text, text, sizeof(temp->text));
temp->value = (char *)value;
/*
/*
- * End of "$Id: ppd.c,v 1.100 2003/02/28 10:28:25 mike Exp $".
+ * End of "$Id: ppd.c,v 1.101 2003/02/28 21:06:08 mike Exp $".
*/
/*
- * "$Id: ppd.h,v 1.32 2003/02/18 22:43:07 mike Exp $"
+ * "$Id: ppd.h,v 1.33 2003/02/28 21:06:08 mike Exp $"
*
* PostScript Printer Description definitions for the Common UNIX Printing
* System (CUPS).
{
char name[PPD_MAX_NAME],
/* Name of attribute (cupsXYZ) */
- spec[PPD_MAX_NAME + PPD_MAX_TEXT],
+ spec[PPD_MAX_NAME],
/* Specifier string, if any */
+ text[PPD_MAX_TEXT],
+ /* Human-readable text, if any */
*value; /* Value string */
} ppd_attr_t;
/**** New in CUPS 1.1.19 ****/
extern const char *ppdErrorString(ppd_status_t status);
-extern const char *ppdFindAttr(ppd_file_t *ppd, const char *name,
+extern ppd_attr_t *ppdFindAttr(ppd_file_t *ppd, const char *name,
const char *spec);
-extern const char *ppdFindNextAttr(ppd_file_t *ppd, const char *name,
+extern ppd_attr_t *ppdFindNextAttr(ppd_file_t *ppd, const char *name,
const char *spec);
extern ppd_status_t ppdLastError(int *line);
#endif /* !_CUPS_PPD_H_ */
/*
- * End of "$Id: ppd.h,v 1.32 2003/02/18 22:43:07 mike Exp $".
+ * End of "$Id: ppd.h,v 1.33 2003/02/28 21:06:08 mike Exp $".
*/
/*
- * "$Id: cupstestppd.c,v 1.19 2003/02/26 01:19:07 mike Exp $"
+ * "$Id: cupstestppd.c,v 1.20 2003/02/28 21:06:09 mike Exp $"
*
* PPD test program for the Common UNIX Printing System (CUPS).
*
ppd_status_t error; /* Status of ppdOpen*() */
int line; /* Line number for error */
ppd_file_t *ppd; /* PPD file record */
+ ppd_attr_t *attr; /* PPD attribute */
ppd_size_t *size; /* Size record */
ppd_group_t *group; /* UI group */
ppd_option_t *option; /* Standard UI option */
if (verbose > 0)
puts("\n DETAILED CONFORMANCE TEST RESULTS");
- if ((ptr = ppdFindAttr(ppd, "FormatVersion", NULL)) != NULL)
- ppdversion = (int)(10 * atof(ptr) + 0.5);
+ if ((attr = ppdFindAttr(ppd, "FormatVersion", NULL)) != NULL &&
+ attr->value)
+ ppdversion = (int)(10 * atof(attr->value) + 0.5);
if (ppdFindAttr(ppd, "DefaultImageableArea", NULL) != NULL)
{
errors ++;
}
- if ((ptr = ppdFindAttr(ppd, "PSVersion", NULL)) != NULL)
+ if ((attr = ppdFindAttr(ppd, "PSVersion", NULL)) != NULL &&
+ attr->value != NULL)
{
char junkstr[255]; /* Temp string */
int junkint; /* Temp integer */
- if (sscanf(ptr, "(%[^)])%d", junkstr, &junkint) != 2)
+ if (sscanf(attr->value, "(%[^)])%d", junkstr, &junkint) != 2)
{
if (verbose >= 0)
{
{
if (ppdversion < 43)
{
- printf(" WARN Obsolete PPD version %s!\n",
- ppdFindAttr(ppd, "FormatVersion", NULL));
+ printf(" WARN Obsolete PPD version %.1f!\n",
+ 0.1f * ppdversion);
puts(" REF: Page 42, section 5.2.");
}
/*
- * End of "$Id: cupstestppd.c,v 1.19 2003/02/26 01:19:07 mike Exp $".
+ * End of "$Id: cupstestppd.c,v 1.20 2003/02/28 21:06:09 mike Exp $".
*/