/*
- * "$Id: ppd.c,v 1.51.2.56 2003/07/20 12:51:41 mike Exp $"
+ * "$Id: ppd.c,v 1.51.2.57 2003/08/01 15:00:28 mike Exp $"
*
* PPD file routines for the Common UNIX Printing System (CUPS).
*
* ppdOpen() - Read a PPD file into memory.
* ppdOpenFd() - Read a PPD file into memory.
* ppdOpenFile() - Read a PPD file into memory.
+ * ppdSetConformance() - Set the conformance level for PPD files.
* ppd_add_attr() - Add an attribute to the PPD data.
* ppd_add_choice() - Add a choice to an option.
* ppd_add_size() - Add a page size.
static ppd_status_t ppd_status = PPD_OK;
/* Status of last ppdOpen*() */
static int ppd_line = 0; /* Current line number */
+static ppd_conform_t ppd_conform = PPD_CONFORM_RELAXED;
+ /* Level of conformance required */
/*
"Illegal control character",
"Illegal main keyword string",
"Illegal option keyword string",
- "Illegal translation string"
+ "Illegal translation string",
+ "Illegal whitespace character"
};
- if (status < PPD_OK || status > PPD_ILLEGAL_TRANSLATION)
+ if (status < PPD_OK || status > PPD_ILLEGAL_WHITESPACE)
return ("Unknown");
else
return (messages[status]);
}
+/*
+ * 'ppdSetConformance()' - Set the conformance level for PPD files.
+ */
+
+void
+ppdSetConformance(ppd_conform_t c) /* I - Conformance level */
+{
+ ppd_conform = c;
+}
+
+
/*
* 'ppd_add_attr()' - Add an attribute to the PPD data.
*/
*lineptr++ = '\n';
}
- else if (ch < ' ' && ch != '\t' && ch != 0x1a)
+ else if (ch < ' ' && ch != '\t' && ppd_conform == PPD_CONFORM_STRICT)
{
/*
* Other control characters...
ch = '\n';
}
- else if (ch < ' ' && ch != '\t' && ch != 0x1a)
+ else if (ch < ' ' && ch != '\t' && ppd_conform == PPD_CONFORM_STRICT)
{
/*
* Other control characters...
break;
}
- else if (ch < ' ' && ch != '\t' && ch != 0x1a)
+ else if (ch < ' ' && ch != '\t' && ppd_conform == PPD_CONFORM_STRICT)
{
/*
* Other control characters...
*string = NULL;
if (!line[0] || /* Blank line */
- strcmp(line, "*") == 0 || /* (Bad) comment line */
strncmp(line, "*%", 2) == 0 || /* Comment line */
strcmp(line, "*End") == 0) /* End of multi-line string */
{
continue;
}
+ if (strcmp(line, "*") == 0) /* (Bad) comment line */
+ {
+ if (ppd_conform == PPD_CONFORM_RELAXED)
+ {
+ startline = ppd_line + 1;
+ continue;
+ }
+ else
+ {
+ ppd_line = startline;
+ ppd_status = PPD_ILLEGAL_MAIN_KEYWORD;
+
+ return (0);
+ }
+ }
+
if (line[0] != '*') /* All lines start with an asterisk */
{
+ if (ppd_conform == PPD_CONFORM_STRICT)
+ {
+ ppd_status = PPD_MISSING_ASTERISK;
+ return (0);
+ }
+
/*
* Allow lines consisting of just whitespace...
*/
}
*optptr = '\0';
+
+ if (!option[0] && ppd_conform == PPD_CONFORM_STRICT)
+ {
+ ppd_status = PPD_ILLEGAL_WHITESPACE;
+ return (0);
+ }
+
mask |= PPD_OPTION;
/* DEBUG_printf(("option = \"%s\", lineptr = \"%s\"\n", option, lineptr));*/
/* DEBUG_printf(("text = \"%s\", lineptr = \"%s\"\n", text, lineptr));*/
}
+ if (isspace(*lineptr) && ppd_conform == PPD_CONFORM_STRICT)
+ {
+ ppd_status = PPD_ILLEGAL_WHITESPACE;
+ return (0);
+ }
+
+ while (isspace(*lineptr))
+ lineptr ++;
+
if (*lineptr == ':')
{
/*
* Get string after triming leading and trailing whitespace...
*/
- while (*lineptr == ':' || isspace(*lineptr))
+ lineptr ++;
+ while (isspace(*lineptr))
lineptr ++;
strptr = lineptr + strlen(lineptr) - 1;
/*
- * End of "$Id: ppd.c,v 1.51.2.56 2003/07/20 12:51:41 mike Exp $".
+ * End of "$Id: ppd.c,v 1.51.2.57 2003/08/01 15:00:28 mike Exp $".
*/
/*
- * "$Id: ppd.h,v 1.24.2.17 2003/04/10 03:01:49 mike Exp $"
+ * "$Id: ppd.h,v 1.24.2.18 2003/08/01 15:00:29 mike Exp $"
*
* PostScript Printer Description definitions for the Common UNIX Printing
* System (CUPS).
PPD_ILLEGAL_CHARACTER, /* Illegal control character */
PPD_ILLEGAL_MAIN_KEYWORD, /* Illegal main keyword string */
PPD_ILLEGAL_OPTION_KEYWORD, /* Illegal option keyword string */
- PPD_ILLEGAL_TRANSLATION /* Illegal translation string */
+ PPD_ILLEGAL_TRANSLATION, /* Illegal translation string */
+ PPD_ILLEGAL_WHITESPACE /* Illegal whitespace character */
} ppd_status_t;
+typedef enum /**** Conformance Levels ****/
+{
+ PPD_CONFORM_RELAXED, /* Relax whitespace and control char */
+ PPD_CONFORM_STRICT /* Require strict conformance */
+} ppd_conform_t;
+
typedef struct /**** PPD Attribute Structure ****/
{
char name[PPD_MAX_NAME],
const char *param, int num_values,
const float *values);
+/**** New in CUPS 1.1.20 ****/
+extern void ppdSetConformance(ppd_conform_t c);
+
/**** New in CUPS 1.2 ****/
extern int ppdSave(ppd_file_t *ppd, FILE *fp);
extern int ppdSaveFd(ppd_file_t *ppd, int fd);
#endif /* !_CUPS_PPD_H_ */
/*
- * End of "$Id: ppd.h,v 1.24.2.17 2003/04/10 03:01:49 mike Exp $".
+ * End of "$Id: ppd.h,v 1.24.2.18 2003/08/01 15:00:29 mike Exp $".
*/
/*
- * "$Id: cupstestppd.c,v 1.1.2.24 2003/07/20 02:34:29 mike Exp $"
+ * "$Id: cupstestppd.c,v 1.1.2.25 2003/08/01 15:00:30 mike Exp $"
*
* PPD test program for the Common UNIX Printing System (CUPS).
*
"JCL", "PAGE", "PROLOG" };
- setbuf(stdout, NULL);
-
/*
* Display PPD files for each file listed on the command-line...
*/
+ ppdSetConformance(PPD_CONFORM_STRICT);
+
verbose = 0;
ppd = NULL;
files = 0;
for (opt = argv[i] + 1; *opt; opt ++)
switch (*opt)
{
- case 'q' :
+ case 'q' : /* Quiet mode */
if (verbose > 0)
{
fputs("cupstestppd: The -q option is incompatible with the -v option.\n",
verbose --;
break;
- case 'v' :
+ case 'r' : /* Relaxed mode */
+ ppdSetConformance(PPD_CONFORM_RELAXED);
+ break;
+
+ case 'v' : /* Verbose mode */
if (verbose < 0)
{
fputs("cupstestppd: The -v option is incompatible with the -q option.\n",
void
usage(void)
{
- puts("Usage: cupstestppd [-q] [-v[v]] filename1.ppd[.gz] [... filenameN.ppd[.gz]]");
- puts(" program | cupstestppd [-q] [-v[v]] -");
+ puts("Usage: cupstestppd [-q] [-r] [-v[v]] filename1.ppd[.gz] [... filenameN.ppd[.gz]]");
+ puts(" program | cupstestppd [-q] [-r] [-v[v]] -");
exit(ERROR_USAGE);
}
/*
- * End of "$Id: cupstestppd.c,v 1.1.2.24 2003/07/20 02:34:29 mike Exp $".
+ * End of "$Id: cupstestppd.c,v 1.1.2.25 2003/08/01 15:00:30 mike Exp $".
*/