summaryrefslogtreecommitdiff
path: root/src/printdef
diff options
context:
space:
mode:
Diffstat (limited to 'src/printdef')
-rw-r--r--src/printdef/.cvsignore8
-rw-r--r--src/printdef/Makefile.am50
-rw-r--r--src/printdef/printdef.h103
-rw-r--r--src/printdef/printdefl.l93
-rw-r--r--src/printdef/printdefy.y213
5 files changed, 467 insertions, 0 deletions
diff --git a/src/printdef/.cvsignore b/src/printdef/.cvsignore
new file mode 100644
index 0000000..8e12f00
--- /dev/null
+++ b/src/printdef/.cvsignore
@@ -0,0 +1,8 @@
+.deps
+.libs
+Makefile
+Makefile.in
+printdefl.c
+printdef
+printdefy.c
+printdefy.h
diff --git a/src/printdef/Makefile.am b/src/printdef/Makefile.am
new file mode 100644
index 0000000..bb9faa3
--- /dev/null
+++ b/src/printdef/Makefile.am
@@ -0,0 +1,50 @@
+## $Id: Makefile.am,v 1.8 2001/11/10 14:42:43 rlk Exp $
+## Copyright (C) 2000 Roger Leigh
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+## Process this file with automake to produce Makefile.in.
+
+AUTOMAKE_OPTIONS = 1.4 gnu
+
+@SET_MAKE@
+
+MAINT_CHARSET = latin1
+
+
+## Variables
+
+AM_CFLAGS = $(GNUCFLAGS)
+INCLUDES = @INCLUDES@
+
+LFLAGS = -i
+YFLAGS = -d
+
+
+## Programs
+
+noinst_PROGRAMS = printdef
+printdef_SOURCES = printdefl.l printdefy.y printdef.h
+
+printdefl.o: printdefy.o
+printdef.o: printdefy.o
+
+
+## Clean
+
+DISTCLEANFILES = printdefl.c printdefy.c printdefy.h
+MAINTAINERCLEANFILES = Makefile.in
+
+EXTRA_DIST = printdefy.h
diff --git a/src/printdef/printdef.h b/src/printdef/printdef.h
new file mode 100644
index 0000000..31bb44a
--- /dev/null
+++ b/src/printdef/printdef.h
@@ -0,0 +1,103 @@
+/*
+ * "$Id: printdef.h,v 1.5 2001/03/31 20:56:53 rlk Exp $"
+ *
+ * I18N header file for the gimp-print plugin.
+ *
+ * Copyright 1997-2000 Michael Sweet (mike@easysw.com),
+ * Robert Krawitz (rlk@alum.mit.edu) and Michael Natterer (mitch@gimp.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#define OUTPUT_GRAY 0 /* Grayscale output */
+#define OUTPUT_COLOR 1 /* Color output */
+#define OUTPUT_GRAY_COLOR 2 /* Grayscale output using color */
+
+#define ORIENT_AUTO -1 /* Best orientation */
+#define ORIENT_PORTRAIT 0 /* Portrait orientation */
+#define ORIENT_LANDSCAPE 1 /* Landscape orientation */
+#define ORIENT_UPSIDEDOWN 2 /* Reverse portrait orientation */
+#define ORIENT_SEASCAPE 3 /* Reverse landscape orientation */
+
+#define IMAGE_LINE_ART 0
+#define IMAGE_SOLID_TONE 1
+#define IMAGE_CONTINUOUS 2
+#define IMAGE_MONOCHROME 3
+#define NIMAGE_TYPES 4
+
+#define COLOR_MODEL_RGB 0
+#define COLOR_MODEL_CMY 1
+
+typedef struct /* Plug-in variables */
+{
+ char output_to[256], /* Name of file or command to print to */
+ driver[64], /* Name of printer "driver" */
+ ppd_file[256], /* PPD file */
+ resolution[64], /* Resolution */
+ media_size[64], /* Media size */
+ media_type[64], /* Media type */
+ media_source[64], /* Media source */
+ ink_type[64], /* Ink or cartridge */
+ dither_algorithm[64]; /* Dithering algorithm */
+ int output_type; /* Color or grayscale output */
+ float brightness; /* Output brightness */
+ float scaling; /* Scaling, percent of printable area */
+ int orientation, /* Orientation - 0 = port., 1 = land.,
+ -1 = auto */
+ left, /* Offset from lower-lefthand corner, points */
+ top; /* ... */
+ float gamma; /* Gamma */
+ float contrast, /* Output Contrast */
+ cyan, /* Output red level */
+ magenta, /* Output green level */
+ yellow; /* Output blue level */
+ float saturation; /* Output saturation */
+ float density; /* Maximum output density */
+ int image_type; /* Image type (line art etc.) */
+ int unit; /* Units for preview area 0=Inch 1=Metric */
+ float app_gamma; /* Application gamma */
+ int page_width; /* Width of page in points */
+ int page_height; /* Height of page in points */
+ int input_color_model; /* Color model for this device */
+ int output_color_model; /* Color model for this device */
+ void *lut; /* Look-up table */
+ void *driver_data; /* Private data of the driver */
+ unsigned char *cmap; /* Color map */
+ void (*outfunc)(void *data, const char *buffer, size_t bytes);
+ void *outdata;
+ void (*errfunc)(void *data, const char *buffer, size_t bytes);
+ void *errdata;
+} stp_vars_t;
+
+typedef struct stp_printer
+{
+ const char *long_name, /* Long name for UI */
+ *driver; /* Short name for printrc file */
+ int model; /* Model number */
+ const char *printfuncs;
+ stp_vars_t printvars;
+} stp_printer_t;
+
+typedef union yylv {
+ int ival;
+ double dval;
+ char *sval;
+} YYSTYPE;
+
+extern YYSTYPE yylval;
+extern stp_printer_t thePrinter;
+
+#include "printdefy.h"
+
diff --git a/src/printdef/printdefl.l b/src/printdef/printdefl.l
new file mode 100644
index 0000000..7c56c88
--- /dev/null
+++ b/src/printdef/printdefl.l
@@ -0,0 +1,93 @@
+/*
+ * "$Id: printdefl.l,v 1.2 2001/06/03 20:53:24 rlk Exp $"
+ *
+ * Parse printer definition pseudo-XML
+ *
+ * Copyright 2000 Robert Krawitz (rlk@alum.mit.edu)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+%{
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "printdef.h"
+
+#define YY_NO_UNPUT
+
+int mylineno = 1;
+
+#if 0
+#define DBG(x) fprintf(stderr, "'%s'%s\n", yytext, #x);
+#else
+#define DBG(x)
+#endif
+
+static char *
+c_strdup(const char *s)
+{
+ char *ret = malloc(strlen(s) + 1);
+ if (!ret)
+ {
+ fprintf(stderr, "Malloc failed.\n");
+ exit(1);
+ }
+ strcpy(ret, s);
+ return ret;
+}
+
+%}
+
+%option noyywrap
+
+digit [0-9]
+integer [-+]?{digit}+
+float [-+]?{digit}+(\.{digit}+)?([eE][-+]?{digit}+)?
+class [a-zA-Z][a-zA-Z0-9_]+
+string [\"][^\"]+[\"]
+ws [ \t]+
+
+%%
+
+\< DBG(tBEGIN) return tBEGIN;
+\> DBG(tEND) return tEND;
+= DBG(ASSIGN) return ASSIGN;
+printer DBG(PRINTER) return PRINTER;
+\/printer DBG(ENDPRINTER) return ENDPRINTER;
+name DBG(NAME) return NAME;
+driver DBG(DRIVER) return DRIVER;
+color DBG(COLOR) return COLOR;
+nocolor DBG(NOCOLOR) return NOCOLOR;
+model DBG(MODEL) return MODEL;
+language DBG(LANGUAGE) return LANGUAGE;
+brightness DBG(BRIGHTNESS) return BRIGHTNESS;
+gamma DBG(GAMMA) return GAMMA;
+contrast DBG(CONTRAST) return CONTRAST;
+cyan DBG(CYAN) return CYAN;
+magenta DBG(MAGENTA) return MAGENTA;
+yellow DBG(YELLOW) return YELLOW;
+saturation DBG(SATURATION) return SATURATION;
+density DBG(DENSITY) return DENSITY;
+value DBG(VALUE) return VALUE;
+
+{integer} yylval.ival = atoi(yytext); DBG(tINT) return tINT;
+{float} yylval.dval = strtod(yytext, NULL); DBG(tDOUBLE) return tDOUBLE;
+{string} yylval.sval = c_strdup(yytext); DBG(tSTRING) return tSTRING;
+{class} yylval.sval = c_strdup(yytext); DBG(tCLASS) return tCLASS;
+{ws} DBG(whitespace1) /* Skip blanks/tabs */
+#[^\n]* DBG(comment1) /* Skip comments */
+\n DBG(newline) mylineno++;
diff --git a/src/printdef/printdefy.y b/src/printdef/printdefy.y
new file mode 100644
index 0000000..98439c2
--- /dev/null
+++ b/src/printdef/printdefy.y
@@ -0,0 +1,213 @@
+/*
+ * "$Id: printdefy.y,v 1.7 2001/08/25 16:25:28 rlk Exp $"
+ *
+ * Parse printer definition pseudo-XML
+ *
+ * Copyright 2000 Robert Krawitz (rlk@alum.mit.edu)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+%{
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "printdef.h"
+
+extern int mylineno;
+stp_printer_t thePrinter;
+char *quotestrip(const char *i);
+char *endstrip(const char *i);
+
+extern int yylex(void);
+void initialize_the_printer(const char *name, const char *driver);
+void output_the_printer(void);
+int yyerror(const char *s);
+
+const char *printfuncs[] =
+{
+ "canon",
+ "escp2",
+ "pcl",
+ "ps",
+ "lexmark"
+};
+
+const size_t nprintfuncs = sizeof(printfuncs) / sizeof(const char *);
+
+void
+initialize_the_printer(const char *name, const char *driver)
+{
+ strncpy(thePrinter.printvars.output_to, name, 63);
+ strncpy(thePrinter.printvars.driver, driver, 63);
+ thePrinter.printvars.top = -1;
+ thePrinter.model = -1;
+ thePrinter.printvars.brightness = 1.0;
+ thePrinter.printvars.gamma = 1.0;
+ thePrinter.printvars.contrast = 1.0;
+ thePrinter.printvars.cyan = 1.0;
+ thePrinter.printvars.magenta = 1.0;
+ thePrinter.printvars.yellow = 1.0;
+ thePrinter.printvars.saturation = 1.0;
+ thePrinter.printvars.density = 1.0;
+}
+
+void
+output_the_printer(void)
+{
+ printf(" {\n");
+ printf(" %s,\n", thePrinter.printvars.output_to);
+ printf(" %s,\n", thePrinter.printvars.driver);
+ printf(" %d,\n", thePrinter.model);
+ printf(" &stp_%s_printfuncs,\n", printfuncs[thePrinter.printvars.top]);
+ printf(" {\n");
+ printf(" \"\",\n"); /* output_to */
+ printf(" %s,\n", thePrinter.printvars.driver); /* driver */
+ printf(" \"\",\n"); /* ppd_file */
+ printf(" \"\",\n"); /* resolution */
+ printf(" \"\",\n"); /* media_size */
+ printf(" \"\",\n"); /* media_type */
+ printf(" \"\",\n"); /* media_source */
+ printf(" \"\",\n"); /* ink_type */
+ printf(" \"\",\n"); /* dither_algorithm */
+ printf(" %d,\n", thePrinter.printvars.output_type);
+ printf(" %.3f,\n", thePrinter.printvars.brightness);
+ printf(" 1.0,\n"); /* scaling */
+ printf(" -1,\n"); /* orientation */
+ printf(" 0,\n"); /* top */
+ printf(" 0,\n"); /* left */
+ printf(" %.3f,\n", thePrinter.printvars.gamma);
+ printf(" %.3f,\n", thePrinter.printvars.contrast);
+ printf(" %.3f,\n", thePrinter.printvars.cyan);
+ printf(" %.3f,\n", thePrinter.printvars.magenta);
+ printf(" %.3f,\n", thePrinter.printvars.yellow);
+ printf(" %.3f,\n", thePrinter.printvars.saturation);
+ printf(" %.3f,\n", thePrinter.printvars.density);
+ printf(" }\n");
+ printf(" },\n");
+}
+
+extern int mylineno;
+extern char* yytext;
+
+static int yyerror( const char *s )
+{
+ fprintf(stderr,"stdin:%d: %s before '%s'\n",mylineno,s,yytext);
+ return 0;
+}
+
+%}
+
+%token <ival> tINT
+%token <dval> tDOUBLE
+%token <sval> tSTRING tCLASS
+%token tBEGIN tEND ASSIGN PRINTER NAME DRIVER COLOR NOCOLOR MODEL
+%token LANGUAGE BRIGHTNESS GAMMA CONTRAST
+%token CYAN MAGENTA YELLOW SATURATION DENSITY ENDPRINTER VALUE
+
+%start Printers
+
+%%
+
+printerstart: tBEGIN PRINTER NAME ASSIGN tSTRING DRIVER ASSIGN tSTRING tEND
+ { initialize_the_printer($5, $8); }
+;
+printerstartalt: tBEGIN PRINTER DRIVER ASSIGN tSTRING NAME ASSIGN tSTRING tEND
+ { initialize_the_printer($8, $5); }
+;
+printerend: tBEGIN ENDPRINTER tEND
+ { output_the_printer(); }
+;
+color: tBEGIN COLOR tEND
+ { thePrinter.printvars.output_type = OUTPUT_COLOR; }
+;
+nocolor: tBEGIN NOCOLOR tEND
+ { thePrinter.printvars.output_type = OUTPUT_GRAY; }
+;
+model: tBEGIN MODEL VALUE ASSIGN tINT tEND
+ { thePrinter.model = $5; }
+;
+language: tBEGIN LANGUAGE VALUE ASSIGN tCLASS tEND
+ {
+ int i;
+ for (i = 0; i < nprintfuncs; i++)
+ {
+ if (!strcmp($5, printfuncs[i]))
+ {
+ thePrinter.printvars.top = i;
+ break;
+ }
+ }
+ }
+;
+brightness: tBEGIN BRIGHTNESS VALUE ASSIGN tDOUBLE tEND
+ { thePrinter.printvars.brightness = $5; }
+;
+gamma: tBEGIN GAMMA VALUE ASSIGN tDOUBLE tEND
+ { thePrinter.printvars.gamma = $5; }
+;
+contrast: tBEGIN CONTRAST VALUE ASSIGN tDOUBLE tEND
+ { thePrinter.printvars.contrast = $5; }
+;
+cyan: tBEGIN CYAN VALUE ASSIGN tDOUBLE tEND
+ { thePrinter.printvars.cyan = $5; }
+;
+magenta: tBEGIN MAGENTA VALUE ASSIGN tDOUBLE tEND
+ { thePrinter.printvars.magenta = $5; }
+;
+yellow: tBEGIN YELLOW VALUE ASSIGN tDOUBLE tEND
+ { thePrinter.printvars.yellow = $5; }
+;
+saturation: tBEGIN SATURATION VALUE ASSIGN tDOUBLE tEND
+ { thePrinter.printvars.saturation = $5; }
+;
+density: tBEGIN DENSITY VALUE ASSIGN tDOUBLE tEND
+ { thePrinter.printvars.density = $5; }
+;
+
+Empty:
+
+pstart: printerstart | printerstartalt
+;
+
+parg: color | nocolor | model | language | brightness | gamma | contrast
+ | cyan | magenta | yellow | saturation | density
+
+pargs: pargs parg | parg
+
+Printer: pstart pargs printerend | pstart printerend
+
+Printers: Printers Printer | Empty
+
+%%
+
+int
+main(int argc, char **argv)
+{
+ int retval;
+ int i;
+ printf("/* This file is automatically generated. See printers.xml.\n");
+ printf(" DO NOT EDIT! */\n\n");
+ for (i = 0; i < nprintfuncs; i++)
+ printf("const extern stp_printfuncs_t stp_%s_printfuncs;\n",
+ printfuncs[i]);
+ printf("\nstatic const stp_internal_printer_t printers[] =\n");
+ printf("{\n");
+ retval = yyparse();
+ printf("};\n");
+ printf("static const int printer_count = sizeof(printers) / sizeof(stp_internal_printer_t);\n");
+ return retval;
+}