summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am40
-rw-r--r--src/Makefile.in596
-rw-r--r--src/def.h52
-rwxr-xr-xsrc/err.c176
-rw-r--r--src/err.h58
-rwxr-xr-xsrc/filter.c949
-rw-r--r--src/linux_cmn.c320
-rw-r--r--src/linux_cmn.h73
-rw-r--r--src/mem.c76
-rw-r--r--src/mem.h57
-rw-r--r--src/optBase.h192
11 files changed, 2589 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..2b1ee21
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,40 @@
+## Makefile.am -- an automake template for a Makefile.in file
+## EPSON ESC/P-R Printer Driver for Linux
+## Copyright (C) 2000-2008 AVASYS CORPORATION.
+## Copyright (C) Seiko Epson Corporation 2000-2008.
+## 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
+
+cupsfilterdir = $(CUPS_FILTER_DIR)
+cupsfilter_PROGRAMS = \
+ epson-escpage
+
+epson_escpage_CFLAGS = \
+ -I$(top_srcdir)/escpr-lib \
+ -I$(top_srcdir)/escpr-lib/inc \
+ -I$(top_srcdir)/lib \
+ -DEPS_FILTER \
+ -DGCOMSW_CMD_ESCPAGE
+
+epson_escpage_SOURCES = \
+ filter.c \
+ optBase.h \
+ err.c err.h \
+ mem.c mem.h \
+ linux_cmn.h linux_cmn.c \
+ def.h
+
+epson_escpage_LDADD = \
+ $(top_builddir)/lib/.libs/libescpage.a
+
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..6c015ba
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,596 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+cupsfilter_PROGRAMS = epson-escpage$(EXEEXT)
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(cupsfilterdir)"
+PROGRAMS = $(cupsfilter_PROGRAMS)
+am_epson_escpage_OBJECTS = epson_escpage-filter.$(OBJEXT) \
+ epson_escpage-err.$(OBJEXT) epson_escpage-mem.$(OBJEXT) \
+ epson_escpage-linux_cmn.$(OBJEXT)
+epson_escpage_OBJECTS = $(am_epson_escpage_OBJECTS)
+epson_escpage_DEPENDENCIES = $(top_builddir)/lib/.libs/libescpage.a
+epson_escpage_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(epson_escpage_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(epson_escpage_SOURCES)
+DIST_SOURCES = $(epson_escpage_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CUPS_FILTER_DIR = @CUPS_FILTER_DIR@
+CUPS_PPD_DIR = @CUPS_PPD_DIR@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBARCH = @LIBARCH@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LSB_VER = @LSB_VER@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_RELEASE = @PACKAGE_RELEASE@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VENDOR_NAME = @VENDOR_NAME@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+have_cups_config = @have_cups_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+cupsfilterdir = $(CUPS_FILTER_DIR)
+epson_escpage_CFLAGS = \
+ -I$(top_srcdir)/escpr-lib \
+ -I$(top_srcdir)/escpr-lib/inc \
+ -I$(top_srcdir)/lib \
+ -DEPS_FILTER \
+ -DGCOMSW_CMD_ESCPAGE
+
+epson_escpage_SOURCES = \
+ filter.c \
+ optBase.h \
+ err.c err.h \
+ mem.c mem.h \
+ linux_cmn.h linux_cmn.c \
+ def.h
+
+epson_escpage_LDADD = \
+ $(top_builddir)/lib/.libs/libescpage.a
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-cupsfilterPROGRAMS: $(cupsfilter_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(cupsfilterdir)" || $(MKDIR_P) "$(DESTDIR)$(cupsfilterdir)"
+ @list='$(cupsfilter_PROGRAMS)'; test -n "$(cupsfilterdir)" || list=; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p || test -f $$p1; \
+ then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(cupsfilterdir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(cupsfilterdir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-cupsfilterPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(cupsfilter_PROGRAMS)'; test -n "$(cupsfilterdir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(cupsfilterdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(cupsfilterdir)" && rm -f $$files
+
+clean-cupsfilterPROGRAMS:
+ @list='$(cupsfilter_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+epson-escpage$(EXEEXT): $(epson_escpage_OBJECTS) $(epson_escpage_DEPENDENCIES)
+ @rm -f epson-escpage$(EXEEXT)
+ $(epson_escpage_LINK) $(epson_escpage_OBJECTS) $(epson_escpage_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epson_escpage-err.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epson_escpage-filter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epson_escpage-linux_cmn.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epson_escpage-mem.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+epson_escpage-filter.o: filter.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -MT epson_escpage-filter.o -MD -MP -MF $(DEPDIR)/epson_escpage-filter.Tpo -c -o epson_escpage-filter.o `test -f 'filter.c' || echo '$(srcdir)/'`filter.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/epson_escpage-filter.Tpo $(DEPDIR)/epson_escpage-filter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filter.c' object='epson_escpage-filter.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -c -o epson_escpage-filter.o `test -f 'filter.c' || echo '$(srcdir)/'`filter.c
+
+epson_escpage-filter.obj: filter.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -MT epson_escpage-filter.obj -MD -MP -MF $(DEPDIR)/epson_escpage-filter.Tpo -c -o epson_escpage-filter.obj `if test -f 'filter.c'; then $(CYGPATH_W) 'filter.c'; else $(CYGPATH_W) '$(srcdir)/filter.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/epson_escpage-filter.Tpo $(DEPDIR)/epson_escpage-filter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filter.c' object='epson_escpage-filter.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -c -o epson_escpage-filter.obj `if test -f 'filter.c'; then $(CYGPATH_W) 'filter.c'; else $(CYGPATH_W) '$(srcdir)/filter.c'; fi`
+
+epson_escpage-err.o: err.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -MT epson_escpage-err.o -MD -MP -MF $(DEPDIR)/epson_escpage-err.Tpo -c -o epson_escpage-err.o `test -f 'err.c' || echo '$(srcdir)/'`err.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/epson_escpage-err.Tpo $(DEPDIR)/epson_escpage-err.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='err.c' object='epson_escpage-err.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -c -o epson_escpage-err.o `test -f 'err.c' || echo '$(srcdir)/'`err.c
+
+epson_escpage-err.obj: err.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -MT epson_escpage-err.obj -MD -MP -MF $(DEPDIR)/epson_escpage-err.Tpo -c -o epson_escpage-err.obj `if test -f 'err.c'; then $(CYGPATH_W) 'err.c'; else $(CYGPATH_W) '$(srcdir)/err.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/epson_escpage-err.Tpo $(DEPDIR)/epson_escpage-err.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='err.c' object='epson_escpage-err.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -c -o epson_escpage-err.obj `if test -f 'err.c'; then $(CYGPATH_W) 'err.c'; else $(CYGPATH_W) '$(srcdir)/err.c'; fi`
+
+epson_escpage-mem.o: mem.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -MT epson_escpage-mem.o -MD -MP -MF $(DEPDIR)/epson_escpage-mem.Tpo -c -o epson_escpage-mem.o `test -f 'mem.c' || echo '$(srcdir)/'`mem.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/epson_escpage-mem.Tpo $(DEPDIR)/epson_escpage-mem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mem.c' object='epson_escpage-mem.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -c -o epson_escpage-mem.o `test -f 'mem.c' || echo '$(srcdir)/'`mem.c
+
+epson_escpage-mem.obj: mem.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -MT epson_escpage-mem.obj -MD -MP -MF $(DEPDIR)/epson_escpage-mem.Tpo -c -o epson_escpage-mem.obj `if test -f 'mem.c'; then $(CYGPATH_W) 'mem.c'; else $(CYGPATH_W) '$(srcdir)/mem.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/epson_escpage-mem.Tpo $(DEPDIR)/epson_escpage-mem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mem.c' object='epson_escpage-mem.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -c -o epson_escpage-mem.obj `if test -f 'mem.c'; then $(CYGPATH_W) 'mem.c'; else $(CYGPATH_W) '$(srcdir)/mem.c'; fi`
+
+epson_escpage-linux_cmn.o: linux_cmn.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -MT epson_escpage-linux_cmn.o -MD -MP -MF $(DEPDIR)/epson_escpage-linux_cmn.Tpo -c -o epson_escpage-linux_cmn.o `test -f 'linux_cmn.c' || echo '$(srcdir)/'`linux_cmn.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/epson_escpage-linux_cmn.Tpo $(DEPDIR)/epson_escpage-linux_cmn.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='linux_cmn.c' object='epson_escpage-linux_cmn.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -c -o epson_escpage-linux_cmn.o `test -f 'linux_cmn.c' || echo '$(srcdir)/'`linux_cmn.c
+
+epson_escpage-linux_cmn.obj: linux_cmn.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -MT epson_escpage-linux_cmn.obj -MD -MP -MF $(DEPDIR)/epson_escpage-linux_cmn.Tpo -c -o epson_escpage-linux_cmn.obj `if test -f 'linux_cmn.c'; then $(CYGPATH_W) 'linux_cmn.c'; else $(CYGPATH_W) '$(srcdir)/linux_cmn.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/epson_escpage-linux_cmn.Tpo $(DEPDIR)/epson_escpage-linux_cmn.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='linux_cmn.c' object='epson_escpage-linux_cmn.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(epson_escpage_CFLAGS) $(CFLAGS) -c -o epson_escpage-linux_cmn.obj `if test -f 'linux_cmn.c'; then $(CYGPATH_W) 'linux_cmn.c'; else $(CYGPATH_W) '$(srcdir)/linux_cmn.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(cupsfilterdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-cupsfilterPROGRAMS clean-generic clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-cupsfilterPROGRAMS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-cupsfilterPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+ clean-cupsfilterPROGRAMS clean-generic clean-libtool ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am \
+ install-cupsfilterPROGRAMS install-data install-data-am \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-cupsfilterPROGRAMS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/def.h b/src/def.h
new file mode 100644
index 0000000..e14689b
--- /dev/null
+++ b/src/def.h
@@ -0,0 +1,52 @@
+/*
+ * EPSON ESC/P-R Printer Driver for Linux
+ * Copyright (C) 2002-2005 AVASYS CORPORATION.
+ * Copyright (C) Seiko Epson Corporation 2002-2005.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
+ *
+ * As a special exception, AVASYS CORPORATION gives permission to
+ * link the code of this program with libraries which are covered by
+ * the AVASYS Public License and distribute their linked
+ * combinations. You must obey the GNU General Public License in all
+ * respects for all of the code used other than the libraries which
+ * are covered by AVASYS Public License.
+ */
+#ifndef DEF_H
+#define DEF_H
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+
+typedef int bool_t;
+
+/* defines */
+#ifdef __cplusplus
+#define BEGIN_C extern "C" {
+#define END_C }
+#else
+#define BEGIN_C
+#define END_C
+#endif /* __cplusplus */
+
+
+enum exbit_set {
+ EXBIT_COLOR_SEPARATE = 0x00000001
+};
+
+#endif /* DEF_H */
diff --git a/src/err.c b/src/err.c
new file mode 100755
index 0000000..8b72c0c
--- /dev/null
+++ b/src/err.c
@@ -0,0 +1,176 @@
+/*
+ * EPSON ESC/P-R Printer Driver for Linux
+ * Copyright (C) 2002-2005 AVASYS CORPORATION.
+ * Copyright (C) Seiko Epson Corporation 2002-2005.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
+ *
+ * As a special exception, AVASYS CORPORATION gives permission to
+ * link the code of this program with libraries which are covered by
+ * the AVASYS Public License and distribute their linked
+ * combinations. You must obey the GNU General Public License in all
+ * respects for all of the code used other than the libraries which
+ * are covered by AVASYS Public License.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "err.h"
+#include "time.h"
+
+#define HAVE_DEBUG 0
+
+/* global */
+static char err_pname[256] = "";
+static FILE *debug_f = NULL;
+static FILE *debug_f2 = NULL;
+
+/* static functions */
+static void err_doit (enum msgtype, int, const char *, va_list);
+
+void debug_msg(const char *fmt, ...){
+#if (HAVE_DEBUG)
+ va_list ap;
+
+ if(!debug_f){
+ debug_f = fopen(DEBUG_PATH, "wb");
+ if(debug_f == NULL){
+ return;
+ }
+ fchmod (fileno (debug_f), 0777);
+ }
+
+ va_start (ap, fmt);
+ vfprintf (debug_f, fmt, ap);
+ fflush(debug_f);
+ va_end (ap);
+#endif
+ return;
+}
+
+void debugt_msg(char * fmt, ...)
+{
+#if (HAVE_DEBUG_T)
+ if(fmt == NULL || strlen(fmt) == 0){
+ return;
+ }
+
+ va_list ap;
+ if(!debug_f2){
+ debug_f2 = fopen(EPS_DEBUG_PATH2, "wb");
+ if(debug_f2 == NULL){
+ return;
+ }
+ fchmod (fileno (debug_f2), 0644);
+ }
+
+ time_t ltime; /* calendar time */
+ struct tm *Tm;
+ struct timespec start;
+ char szBuf[256];
+ char *p = szBuf;
+ int err = 0;
+
+ ltime=time(NULL); /* get current cal time */
+ Tm = localtime(&ltime);
+ err = clock_gettime(CLOCK_REALTIME, &start);
+ if(err == 0){
+ sprintf(szBuf, "[%02d-%02d-%02d %02d:%02d:%02d::%02d] %s", Tm->tm_year % 10, Tm->tm_mon + 1, Tm->tm_mday, Tm->tm_hour, Tm->tm_min, Tm->tm_sec, (int)start.tv_nsec/1000000, fmt);
+ }else{
+ sprintf(szBuf, "[%02d-%02d-%02d %02d:%02d:%02d] %s", Tm->tm_year % 10, Tm->tm_mon + 1, Tm->tm_mday, Tm->tm_hour, Tm->tm_min, Tm->tm_sec, fmt);
+ }
+
+ va_start (ap, szBuf);
+ vfprintf (debug_f2, szBuf, ap);
+ fflush(debug_f2);
+ va_end (ap);
+#endif
+ return 0;
+}
+
+void
+err_init (const char *name)
+{
+ if (name && strlen (name) < 256)
+ strcpy (err_pname, name);
+ return;
+}
+
+void
+err_msg (enum msgtype type, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ err_doit (type, 0, fmt, ap);
+
+ va_end (ap);
+ return;
+}
+
+void
+err_fatal (const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ err_doit (MSGTYPE_ERROR, 0, fmt, ap);
+
+ va_end (ap);
+ exit (1);
+}
+
+void
+err_system (const char *fmt,...)
+{
+ int e;
+ va_list ap;
+
+ e = errno;
+ va_start (ap, fmt);
+ err_doit (MSGTYPE_ERROR, e, fmt, ap);
+
+ va_end (ap);
+ exit (1);
+}
+
+static void
+err_doit (enum msgtype type, int e, const char *fmt, va_list ap)
+{
+ if (err_pname[0] != '\0')
+ fprintf (stderr, "%s : ", err_pname);
+
+ if (type == MSGTYPE_ERROR)
+ fprintf (stderr, "**** ERROR **** : ");
+ else if (type == MSGTYPE_WARNING)
+ fprintf (stderr, "**** WARNING **** : ");
+ else if (type == MSGTYPE_INFO)
+ fprintf (stderr, "**** INFO **** : ");
+
+ vfprintf (stderr, fmt, ap);
+
+ if (e)
+ fprintf (stderr, " : %s", strerror (e));
+
+ fprintf (stderr, "\n");
+ fflush (stderr);
+ return;
+}
diff --git a/src/err.h b/src/err.h
new file mode 100644
index 0000000..b1cfc30
--- /dev/null
+++ b/src/err.h
@@ -0,0 +1,58 @@
+/*
+ * EPSON ESC/P-R Printer Driver for Linux
+ * Copyright (C) 2002-2005 AVASYS CORPORATION.
+ * Copyright (C) Seiko Epson Corporation 2002-2005.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
+ *
+ * As a special exception, AVASYS CORPORATION gives permission to
+ * link the code of this program with libraries which are covered by
+ * the AVASYS Public License and distribute their linked
+ * combinations. You must obey the GNU General Public License in all
+ * respects for all of the code used other than the libraries which
+ * are covered by AVASYS Public License.
+ */
+#ifndef ERR_H
+#define ERR_H
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdarg.h>
+
+#define DEBUG_PATH "/tmp/eps_debug.txt"
+#define EPS_DEBUG_PATH2 "/tmp/esp_time.txt"
+
+enum msgtype {
+ MSGTYPE_ERROR = 0,
+ MSGTYPE_WARNING,
+ MSGTYPE_INFO,
+ MSGTYPE_MESSAGE
+};
+
+
+
+void err_init (const char *);
+void err_msg (enum msgtype, const char *, ...);
+void err_fatal (const char *, ...);
+void err_system (const char *, ...);
+
+void debug_msg(const char *, ...);
+void debugt_msg(char * fmt, ...);
+
+
+
+#endif /* ERR_H */
diff --git a/src/filter.c b/src/filter.c
new file mode 100755
index 0000000..639e72e
--- /dev/null
+++ b/src/filter.c
@@ -0,0 +1,949 @@
+/*
+ * EPSON ESC/P-R Printer Driver for Linux
+ * Copyright (C) 2002-2005 AVASYS CORPORATION.
+ * Copyright (C) Seiko Epson Corporation 2002-2005.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
+ *
+ * As a special exception, AVASYS CORPORATION gives permission to
+ * link the code of this program with libraries which are covered by
+ * the AVASYS Public License and distribute their linked
+ * combinations. You must obey the GNU General Public License in all
+ * respects for all of the code used other than the libraries which
+ * are covered by AVASYS Public License.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define HAVE_PPM (0)
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <cups/cups.h>
+#include <cups/raster.h>
+
+#include "err.h"
+#include "mem.h"
+#include "optBase.h"
+#include "epson-escpr-def.h"
+#include "epson-escpr-media.h"
+#include "epson-escpr-pvt.h"
+#include "epson-escpr-api.h"
+#include "epson-escpr-services.h"
+#include "epson-escpr-mem.h"
+#include "epson-escpage.h"
+#include "linux_cmn.h"
+
+#define PATH_MAX 256
+#define NAME_MAX 41
+
+#define EPS_PARAM_MP_TRAY 0x00
+#define EPS_PARAM_CASSETTE1 0x01
+#define EPS_PARAM_CASSETTE2 0x02
+#define EPS_PARAM_CASSETTE3 0x03
+#define EPS_PARAM_CASSETTE4 0x04
+#define EPS_PARAM_MANUALFEED 0x0A
+#define EPS_PARAM_AUTO_TRAY 0xFF
+
+#define WIDTH_BYTES(bits) (((bits) + 31) / 32 * 4)
+
+#define PIPSLITE_FILTER_VERSION "* epson-escpr is a part of " PACKAGE_STRING
+
+#define PIPSLITE_FILTER_USAGE "Usage: $ epson-escpr model width_pixel height_pixel Ink PageSize Quality"
+
+
+#ifndef EPS_END_PAGE
+#define EPS_END_PAGE 0 /* There is no next page */
+#endif
+
+#ifndef EPS_NEXT_PAGE
+#define EPS_NEXT_PAGE 1 /* There is a next page */
+#endif
+
+#define PIPSLITE_WRAPPER_VERSION "* epson-escpr-wrapepr is a part of " PACKAGE_STRING
+#define CUPS_FILTER_PATH "/opt/epson-abcdef/"
+#define CUPS_FILTER_NAME "epson-escpage"
+
+typedef struct rtp_filter_option {
+ char model[NAME_MAX];
+ char model_low[NAME_MAX];
+ char ink[NAME_MAX];
+ char media[NAME_MAX];
+ char quality[NAME_MAX];
+ char duplex[NAME_MAX];
+} filter_option_t;
+
+int cancel_flg = 0;
+
+/* static functions */
+static int getMediaTypeID(char *);
+static int getMediaSizeID(char *);
+const int band_line = 1;
+
+extern EPS_INT32 libStatus; /* Library (epsInitDriver) status */
+extern EPS_PRINT_JOB printJob;
+extern EPS_UINT32 sendDataBufSize;
+extern EPS_UINT8* sendDataBuf; /* buffer of SendCommand(save) input */
+extern EPS_UINT32 tmpLineBufSize;
+extern EPS_UINT8* tmpLineBuf;
+
+extern EPS_CMN_FUNC epsCmnFnc;
+
+extern EPS_INT32 back_type;
+extern EPS_INT32 lWidth;
+extern EPS_INT32 lHeight;
+extern EPS_INT32 areaWidth;
+extern EPS_INT32 areaHeight;
+
+#ifndef ESCPR_HEADER_LENGTH
+#define ESCPR_HEADER_LENGTH 10 /* ESC + CLASS + ParamLen + CmdName */
+#endif
+
+#ifndef ESCPR_SEND_DATA_LENGTH
+#define ESCPR_SEND_DATA_LENGTH 7
+#endif
+
+
+EPS_ERR_CODE epsInitLib(){
+ EPS_CMN_FUNC cmnFuncPtrs;
+ memset(&cmnFuncPtrs, 0, sizeof(EPS_CMN_FUNC));
+
+ cmnFuncPtrs.version = EPS_CMNFUNC_VER_CUR;
+ cmnFuncPtrs.findCallback = NULL;
+ cmnFuncPtrs.memAlloc = &epsmpMemAlloc;
+ cmnFuncPtrs.memFree = &epsmpMemFree;
+ cmnFuncPtrs.sleep = &epsmpSleep;
+ cmnFuncPtrs.getTime = &epsmpGetTime;
+ cmnFuncPtrs.getLocalTime = &epsmpGetLocalTime;
+ cmnFuncPtrs.lockSync = &epsmpLockSync;
+ cmnFuncPtrs.unlockSync = &epsmpUnlockSync;
+ cmnFuncPtrs.stateCallback = NULL; /* current version unused */
+
+ memcpy((void*)(&epsCmnFnc), (void*)&cmnFuncPtrs, sizeof(EPS_CMN_FUNC));
+}
+
+EPS_ERR_CODE epsInitJob(){
+
+ memset(&printJob, 0, sizeof(EPS_PRINT_JOB));
+ printJob.printer = (EPS_PRINTER_INN*) malloc(sizeof(EPS_PRINTER_INN));
+ memset(printJob.printer, 0, sizeof(EPS_PRINTER_INN));
+
+ printJob.jobStatus = EPS_STATUS_NOT_INITIALIZED;
+ printJob.pageStatus = EPS_STATUS_NOT_INITIALIZED;
+ printJob.findStatus = EPS_STATUS_NOT_INITIALIZED;
+ printJob.bComm = TRUE;
+ printJob.platform = 0x04; /* '0x04 = linux' is default */
+
+ libStatus = EPS_STATUS_NOT_INITIALIZED;
+ sendDataBufSize = 0;
+ sendDataBuf = NULL;
+ tmpLineBufSize = 0;
+ tmpLineBuf = NULL;
+
+/*** Initialize continue buffer */
+ printJob.contData.sendData = NULL;
+ printJob.contData.sendDataSize = 0;
+
+ /* DEL printJob.additional = EPS_ADDDATA_NONE;
+ printJob.qrcode.bits = NULL;
+ printJob.qrcode.cellNum = 0;
+ printJob.qrcode.dpc = 0; */
+ obsClear();
+
+/*** Set "Endian-ness" for the current cpu */
+ memInspectEndian();
+
+/*** Set Communication Mode */
+ //printJob.commMode = commMode;
+
+/*** Change ESC/P-R Lib Status */
+ libStatus = EPS_STATUS_INITIALIZED;
+ EPS_PRINTER_INN* printer = printJob.printer;
+ printer->pmData.state = EPS_PM_STATE_NOT_FILTERED;
+ printer->language = EPS_LANG_ESCPAGE;
+ return EPS_ERR_NONE;
+}
+
+
+EPS_ERR_CODE epsInitVariable(){
+ sendDataBufSize = (EPS_INT32)(ESCPR_HEADER_LENGTH +
+ ESCPR_SEND_DATA_LENGTH +
+ (printJob.printableAreaWidth * printJob.bpp));
+ sendDataBuf = (EPS_UINT8*)EPS_ALLOC(sendDataBufSize);
+ if(sendDataBuf == NULL){
+ sendDataBufSize = 0;
+ EPS_RETURN( EPS_ERR_MEMORY_ALLOCATION );
+ }
+
+ memset(sendDataBuf, 0xFF, (EPS_UINT32)sendDataBufSize);
+ /*** Allocate buffer for RLE complession */
+ tmpLineBufSize = (EPS_INT32)(printJob.printableAreaWidth * printJob.bpp) + 256; /* 256 is temp buffer */
+ tmpLineBuf = (EPS_UINT8*)EPS_ALLOC(tmpLineBufSize);
+ if(tmpLineBuf == NULL){
+ tmpLineBufSize = 0;
+ EPS_RETURN( EPS_ERR_MEMORY_ALLOCATION );
+ }
+ memset(tmpLineBuf, 0xFF, (EPS_UINT32)tmpLineBufSize);
+ return EPS_ERR_NONE;
+}
+
+
+EPS_ERR_CODE epsFilterEndPage(EPS_BOOL bNextPage){
+ EPS_ERR_CODE retStatus= EPS_ERR_NONE;
+
+#ifdef GCOMSW_CMD_ESCPAGE_S
+ retStatus = pageEndPage();
+#else
+ retStatus = EPS_ERR_LANGUAGE_NOT_SUPPORTED;
+#endif
+
+ return retStatus;
+
+}
+
+void eps_toupper(char *str){
+ int i = 0;
+ int len;
+ if(str == NULL || strlen(str) == 0){
+ return;
+ }
+ len = strlen(str);
+ for(i = 0; i < len; i++){
+ str[i] = toupper(str[i]);
+ }
+ return;
+}
+
+/* Get value for PPD */
+static char *get_default_choice (ppd_file_t *ppd_p, const char *key)
+{
+ ppd_option_t *option;
+ ppd_choice_t *choice;
+
+ option = ppdFindOption (ppd_p, key);
+
+ if( option == NULL && strcmp(key, "FaceUp") == 0 ) {
+ debug_msg("__ Face Down __\n");
+ return "False";
+ }
+
+ if (!option)
+ {
+ debug_msg("option null\n");
+ return NULL;
+ }
+
+ choice = ppdFindChoice (option, option->defchoice);
+ if (!choice)
+ {
+ debug_msg("choice null\n");
+ return NULL;
+ }
+ debug_msg("choice ok = [%s]\n", choice->choice);
+ return choice->choice;
+}
+
+
+int epsGetInputOption(char** in_argv,int in_argc, char *opt, char *dest)
+{
+ int i = 0;
+ char *str = NULL;
+ char *str_tmp = NULL;
+ char dest_t[256];
+ if(opt == NULL || strlen(opt) == 0 || dest == NULL ){
+ return -1;
+ }
+ for(i = 0; i < in_argc; i++){
+ if(strcmp(opt, "RiTech") == 0)
+ {
+ str_tmp = strstr(in_argv[i], "noRiTech");
+ if(str_tmp != NULL)
+ {
+ strcpy(dest, "False");
+ return 0;
+ }
+ else{
+ str_tmp = strstr(in_argv[i], "RiTech");
+ if(str_tmp != NULL)
+ {
+ strcpy(dest, "True");
+ return 0;
+ }
+ }
+ }
+ if(strcmp(opt, "TonerSave") == 0)
+ {
+ str_tmp = strstr(in_argv[i], "noTonerSaving");
+ if(str_tmp != NULL)
+ {
+ strcpy(dest, "False");
+ return 0;
+ } else{
+ str_tmp = strstr(in_argv[i], "TonerSaving");
+ if(str_tmp != NULL)
+ {
+ strcpy(dest, "True");
+ return 0;
+ }
+ }
+ }
+ if(strcmp(opt, "Duplex") == 0)
+ {
+ str_tmp = strstr(in_argv[i], "Duplex=DuplexNoTumble");
+ if(str_tmp != NULL)
+ {
+ strcpy(dest, "DuplexNoTumble");
+ return 0;
+ } else if(str_tmp = strstr(in_argv[i], "Duplex=DuplexTumble")){
+ if(str_tmp != NULL)
+ {
+ strcpy(dest, "DuplexTumble");
+ return 0;
+ }
+ } else {
+ strcpy(dest, "None");
+ return 0;
+ }
+ }
+ if(strcmp(opt, "Orientation") == 0)
+ {
+ str_tmp = strstr(in_argv[i], "Orientation=Portrait");
+ if(str_tmp != NULL)
+ {
+ strcpy(dest, "Portrait");
+ return 0;
+ } else if(str_tmp = strstr(in_argv[i], "Orientation=Landscape")){
+ if(str_tmp != NULL)
+ {
+ strcpy(dest, "Landscape");
+ return 0;
+ }
+ }
+ }
+ str = strstr(in_argv[i], opt);
+ if(str != NULL && (str[strlen(opt)] == '=') && strncmp(str, opt, strlen(opt)) == 0){
+ strcpy(dest_t, str + strlen(opt) + 1);
+ int j = 0;
+ while((dest_t[j] != ' ') && (j < 20))
+ {
+ dest[j] = dest_t[j];
+ j++;
+ }
+ dest[j] = '\0';
+
+ return 0;
+ }
+ }
+
+ debug_msg("return -1 \n");
+ return -1;
+}
+/*tuanvd start add*/
+
+static char *getOptionForJob(ppd_file_t *ppd_p, const char** argv, const int argc, char *key)
+{
+ char *opt_tmp = NULL;
+ int error;
+ //char opt_t[64];
+ char *opt_t;
+ char opt_tem[256];
+
+ error = epsGetInputOption (argv, argc, key, opt_t);
+ if(error == 0){
+ opt_tmp = opt_t;
+ }
+
+ if(opt_tmp == NULL){
+ opt_tmp = get_default_choice (ppd_p, key);
+ }
+ if(strcmp(key, "Duplex") == 0)
+ {
+ debug_msg("Duplex = %s \n", opt_tmp);
+ }
+ free(opt_t);
+ return opt_tmp;
+}
+
+static int setupOptionforJob(const char** argv, const int argc, EPS_JOB_ATTRIB *jobAttr, const char *printer)
+{
+ char *ppd_path; /* Path of PPD */
+ ppd_file_t *ppd_p; /* Struct of PPD */
+ char *opt = NULL; /* Temporary buffer (PPD option) */
+ int i; /* loop */
+ char *err = NULL;
+
+ jobAttr->colorPlane = EPS_CP_FULLCOLOR;
+ jobAttr->printDirection = EPS_PD_BIDIREC;
+ jobAttr->brightness = 0;
+ jobAttr->mediaSizeIdx = -1;
+ jobAttr->mediaTypeIdx = -1;
+ jobAttr->paperSource = 10000;
+ jobAttr->duplex = -1;
+ jobAttr->tonerSave = -1;
+ jobAttr->RiTech = -1;
+ jobAttr->colLate = -1;
+ jobAttr->contrast = 0;
+ jobAttr->orienTation = -1;
+ jobAttr->manualFeed = -1;
+ jobAttr->printQuality = 10000;
+
+ /* Get option from PPD. */
+ ppd_path = (char *) cupsGetPPD (printer);
+ ppd_p = ppdOpenFile (ppd_path);
+ if(NULL == ppd_p){
+ return 0;
+ }
+ /* get Color option */
+ opt = getOptionForJob(ppd_p, argv, argc, "Color");
+ if(opt != NULL){
+ debug_msg("opt check = %s \n", opt);
+ if(strcmp(opt, "MONO") == 0){
+ jobAttr->colorMode = EPS_CM_MONOCHROME;
+ }else{
+ jobAttr->colorMode = EPS_CM_COLOR;
+ }
+ } else{
+ jobAttr->colorMode = EPS_CM_MONOCHROME;
+ }
+ debug_msg("debug 1\n");
+ /* get PageSize */
+ opt = getOptionForJob(ppd_p, argv, argc, "PageSize");
+ debug_msg("opt = %s\n", opt);
+ if(opt != NULL){
+ debug_msg("opt check = %s \n", opt);
+ jobAttr->mediaSizeIdx = getMediaSizeID(opt);
+ debug_msg("jobAttr->mediaSizeIdx = %d\n", jobAttr->mediaSizeIdx);
+ } else return 0;
+ debug_msg("debug 2\n");
+ /* get MediaType */
+ opt = getOptionForJob(ppd_p, argv, argc, "MediaType");
+ if(opt != NULL){
+ jobAttr->mediaTypeIdx = getMediaTypeID(opt);
+ } else return 0;
+ debug_msg("debug 3\n");
+ /* get InputSlot */
+
+ opt = getOptionForJob(ppd_p, argv, argc, "InputSlot");
+ if(opt != NULL){
+ eps_toupper(opt);
+ debug_msg("get option InputSlot \n");
+
+
+ if(strcmp(opt, "Auto") == 0){
+ jobAttr->paperSource = IPS_MPTID_AUTO;
+ }else if(strcmp(opt, "TRAY1") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY1;
+ }else if(strcmp(opt, "TRAY2") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY2;
+ }else if(strcmp(opt, "TRAY3") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY3;
+ }else if(strcmp(opt, "TRAY4") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY4;
+ }else if(strcmp(opt, "TRAY5") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY5;
+ }else if(strcmp(opt, "TRAY6") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY6;
+ }else if(strcmp(opt, "TRAY7") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY7;
+ }else if(strcmp(opt, "TRAY8") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY8;
+ }else if(strcmp(opt, "TRAY9") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY9;
+ }else if(strcmp(opt, "TRAY10") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY10;
+ }else if(strcmp(opt, "TRAY11") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY11;
+ }else if(strcmp(opt, "TRAY12") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY12;
+ }else if(strcmp(opt, "TRAY13") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY13;
+ }else if(strcmp(opt, "TRAY14") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY14;
+ }else if(strcmp(opt, "TRAY15") == 0){
+ jobAttr->paperSource = IPS_MPTID_TRAY15;
+ } else jobAttr->paperSource = IPS_MPTID_AUTO;
+
+
+ } else{
+ jobAttr->paperSource = IPS_MPTID_AUTO;
+ }
+
+
+ /* get Duplex */
+ opt = getOptionForJob(ppd_p, argv, argc, "Duplex");
+ if(opt != NULL){
+ if(strcmp(opt, "DuplexTumble") == 0){
+ jobAttr->duplex = EPS_DUPLEX_SHORT;
+ }else if(strcmp(opt, "DuplexNoTumble") == 0){
+ jobAttr->duplex = EPS_DUPLEX_LONG;
+ }else{
+ jobAttr->duplex = EPS_DUPLEX_NONE;
+ }
+ debug_msg("jobAttr->duplex = %d\n", jobAttr->duplex);
+ } else return 0;
+ debug_msg("debug 4\n");
+ /* get Tonersave */
+ opt = getOptionForJob(ppd_p, argv, argc, "Tonersave");
+ if(opt != NULL){
+ eps_toupper(opt);
+ if(strcmp(opt, "TRUE") == 0){
+ jobAttr->tonerSave = 1; //ON
+ }
+ if(strcmp(opt, "FALSE") == 0){
+ jobAttr->tonerSave = 0; //OFF
+ }
+ } else return 0;
+
+ /* get option RiTech */
+ opt = getOptionForJob(ppd_p, argv, argc, "RiTech");
+ if(opt != NULL){
+ eps_toupper(opt);
+ if(strcmp(opt, "TRUE") == 0){
+ jobAttr->RiTech = 1; //ON
+ }
+ if(strcmp(opt, "FALSE") == 0){
+ jobAttr->RiTech = 0; //OFF
+ }
+ } else return 0;
+
+ /*get option Quality*/
+ opt = getOptionForJob(ppd_p, argv, argc, "Quality");
+ debug_msg("Quality: = %s\n", opt);
+ if(opt != NULL){
+ if(strcmp(opt, "300x300dpi") == 0){
+ debug_msg("__ Nam 0 __\n");
+ jobAttr->printQuality = EPS_MQID_DRAFT;
+ jobAttr->inputResolution = EPS_IR_300X300;
+ jobAttr->topMargin = 300/6;
+ }
+ if(strcmp(opt, "600x600dpi") == 0){
+ debug_msg("__ Nam 1 __\n");
+ jobAttr->printQuality = EPS_MQID_NORMAL;
+ jobAttr->inputResolution = EPS_IR_600X600;
+ jobAttr->topMargin = 600/6;
+ }
+ if (strcmp(opt, "1200x1200dpi") == 0) {
+ debug_msg("__ Nam 2 __\n");
+ jobAttr->printQuality = EPS_MQID_HIGH;
+ jobAttr->inputResolution = EPS_IR_1200X1200;
+ jobAttr->topMargin = 1200/6;
+ }
+ } else return 0;
+
+ /*get option Collate*/
+ opt = getOptionForJob(ppd_p, argv, argc, "Collate");
+ if(opt != NULL){
+ eps_toupper(opt);
+ if((strcmp(opt, "TRUE") == 0) || (strcmp(opt, "ON") == 0)){
+ jobAttr->colLate = 1; //ON
+ } else jobAttr->colLate = 0; //OFF
+ } else return 0;
+
+ /*get option Orientation*/
+ debug_msg("debug orientation \n");
+ opt = getOptionForJob(ppd_p, argv, argc, "Orientation");
+ if(opt != NULL){
+ eps_toupper(opt);
+ if(strcmp(opt, "LANDSCAPE") == 0){
+ jobAttr->orienTation = 1; //Landscape
+ } else jobAttr->orienTation = 0; //Portrai
+ } else return 0;
+
+ /*get option ManualFeed*/
+ debug_msg("debug manual feed \n");
+ opt = getOptionForJob(ppd_p, argv, argc, "ManualFeed");
+ if(opt != NULL){
+ eps_toupper(opt);
+ if( strcmp(opt, "MANUAL") == 0 ){
+ debug_msg("check manual feed \n");
+ jobAttr->manualFeed = 1; //Manual
+ } else {
+ jobAttr->manualFeed = 0; //Automatic
+ }
+ } else return 0;
+
+ opt = getOptionForJob(ppd_p, argv, argc, "FaceUp");
+ if(opt != NULL){
+ //eps_toupper(opt);
+ if(strcmp(opt, "True") == 0){
+ jobAttr->FacingPage = 1;
+ } else{
+ jobAttr->FacingPage = 0;
+ }
+ debug_msg("jobAttr->FacingPage = %d\n", jobAttr->FacingPage);
+ }
+
+
+ /*get option copies*/
+ opt = getOptionForJob(ppd_p, argv, argc, "nCopies");
+ if(opt != NULL){
+ jobAttr->copies = atoi(opt);
+ debug_msg("jobAttr->copies = %d", jobAttr->copies);
+ if(jobAttr->copies < 1 || jobAttr->copies > 999){
+ jobAttr->copies = 1;
+ }
+ } else return 0;
+
+ jobAttr->printLayout = EPS_MLID_BORDERS;
+ jobAttr->feedDirection = EPS_FEEDDIR_PORTRAIT; /* paper feed direction hardcode */
+ ppdClose (ppd_p);
+ return 1;
+}
+/*tuanvd end add*/
+
+
+int main (int argc, char *argv[])
+{
+ int fd; /* file descriptor */
+ FILE *pfp;
+ int i; /* loop */
+ int resul = 0;
+ cups_raster_t *ras; /* raster stream for printing */
+ cups_page_header_t header; /* page device dictionary header */
+ EPS_JOB_ATTRIB fopt;
+
+ debug_msg("%s:%d \t<<%s>>: \t\tStart()\n", __FILE__, __LINE__, __FUNCTION__);
+
+/* attach point */
+#ifdef USE_DEBUGGER
+ int flag = 1;
+ while (flag) sleep (3);
+#endif /* USE_DEBUGGER */
+
+ for (i = 0; i < argc; i++)
+ debug_msg("%s:%d \t<<%s>>: \t\t argv[%d] = [%s]\n", __FILE__, __LINE__, __FUNCTION__, i, argv[i]);
+
+ debug_msg("%s:%d \t<<%s>>: \t\tStart get cups option\n", __FILE__, __LINE__, __FUNCTION__);
+ /*get_option_for_arg(argv, argc, &fopt);
+ get_cups_option(argv[0], &fopt); */
+ resul = setupOptionforJob(argv, argc, &fopt, argv[0]);
+ if(resul == 0){
+ debug_msg("not setup option for job \n");
+ }
+
+ /* Print start */
+ ras = cupsRasterOpen (fd, CUPS_RASTER_READ);
+ if (ras == NULL)
+ {
+ fprintf (stderr, "Can't open CUPS raster file.");
+ debug_msg("%s:%d \t<<%s>>: \t\tCan't open CUPS raster file\n", __FILE__, __LINE__, __FUNCTION__);
+ return 1;
+ }
+ if(ras){
+ do_printJob(pfp, ras, fopt);
+ }
+ debug_msg("Check start call function close rsater file \n");
+ if(ras){
+ cupsRasterClose (ras);
+ }
+ debug_msg("Check end call function close rsater file");
+ return 0;
+}
+
+static int getMediaTypeID(char *rsc_name)
+{
+ debug_msg("%s:%d \t<<%s>>: \t\tTrace in()\n", __FILE__, __LINE__, __FUNCTION__);
+ int j;
+ for(j = 0; mediaTypeData[j].value != END_ARRAY; j++){
+ if(strncmp(mediaTypeData[j].rsc_name,rsc_name, strlen(mediaTypeData[j].rsc_name)) == 0){
+ debug_msg("%s:%d \t<<%s>>: \t\tmediaTypeData[%d].rsc_name = %s, value = %d\n", __FILE__, __LINE__, __FUNCTION__, j, mediaTypeData[j].rsc_name, mediaTypeData[j].value);
+ debug_msg("%s:%d \t<<%s>>: \t\tTrace out OK [%d]\n", __FILE__, __LINE__, __FUNCTION__, mediaTypeData[j].value);
+ return mediaTypeData[j].value;
+ }}
+ debug_msg("%s:%d \t<<%s>>: \t\tTrace out Fail()\n", __FILE__, __LINE__, __FUNCTION__);
+ return 0;
+}
+
+static int getMediaSizeID(char *media_name)
+{
+ debug_msg("check media size \n");
+ debug_msg("%s:%d \t<<%s>>: \t\tTrace in()\n", __FILE__, __LINE__, __FUNCTION__);
+ int j;
+
+ for(j = 0; mediaSizeData[j].value != END_ARRAY; j++){
+ if(strncmp(mediaSizeData[j].rsc_name,media_name, strlen(mediaSizeData[j].rsc_name)) == 0){
+ eps_toupper(media_name);
+ debug_msg("media_name = %s \n", media_name);
+ if(strcmp(media_name, "USER")==0){
+ debug_msg("%s:%d \t<<%s>>: \t\tTrace out USER mode\n", __FILE__, __LINE__, __FUNCTION__);
+ return 0;
+ }
+ debug_msg("%s:%d \t<<%s>>: \t\tTrace out OK [%d]()\n", __FILE__, __LINE__, __FUNCTION__, mediaSizeData[j].value);
+ return mediaSizeData[j].value;
+ }
+ }
+ return 0;
+}
+
+int do_printJob(FILE* pfp,cups_raster_t *ras, EPS_JOB_ATTRIB jobAttr)
+{
+ debug_msg("%s:%d \t<<%s>>: \tTrace in \n", __FILE__, __LINE__, __FUNCTION__);
+ cups_page_header_t header;
+ int width_pixel, height_pixel;
+ char cBuff[256];
+ int bytes_per_line;
+ int byte_par_pixel;
+
+ double print_area_x, print_area_y;
+ char *image_raw;
+ int leftMargin, topMargin;
+
+ int read_size = 0;
+
+ int err = 0;
+ int i, j;
+ EPS_INT32 heightPixels = 0;
+
+ int page_count = 0;
+#if (HAVE_PPM)
+ char ppmfilename[30];
+ FILE *fp;
+
+#endif
+
+ if (jobAttr.colorMode == EPS_CM_COLOR) {
+ byte_par_pixel = 3;
+ }else{
+ byte_par_pixel = 1;
+ }
+
+ while (cupsRasterReadHeader (ras, &header) > 0 && !cancel_flg)
+ {
+ debug_msg("%s:%d \t<<%s>>: \tStart Cupsraster read header \n", __FILE__, __LINE__, __FUNCTION__);
+ int image_bytes;
+ char *image_raw;
+ int write_size = 0;
+ char tmpbuf[256];
+ heightPixels = 0;
+ if (page_count == 0)
+ {
+ width_pixel = header.cupsWidth;
+ height_pixel = header.cupsHeight;
+ epsInitLib();
+ epsInitJob();
+ err = SetupJobAttrib(&jobAttr);
+ if (err)
+ {
+ err_fatal ("Error occurred in \"SetupJobAttrib\"."); /* exit */
+ }
+ printJob.paperWidth = width_pixel;
+ printJob.paperHeight = height_pixel;
+
+ epsInitVariable();
+ switch(printJob.attr.inputResolution)
+ {
+ case EPS_IR_300X300:
+ printJob.topMargin = 50;
+ printJob.leftMargin = 50;
+ break;
+ case EPS_IR_600X600:
+ printJob.topMargin = 100;
+ printJob.leftMargin = 100;
+ break;
+ default:
+ printJob.topMargin = 200;
+ printJob.leftMargin = 200;
+ break;
+ }
+
+ leftMargin = printJob.leftMargin;
+ topMargin = printJob.topMargin;
+
+ printJob.printableAreaHeight = (EPS_UINT32)height_pixel;// - (printJob.topMargin + printJob.leftMargin);
+ printJob.printableAreaWidth = (EPS_UINT32)width_pixel;// - (printJob.topMargin + printJob.leftMargin);
+ err = pageAllocBuffer();
+ if(err)
+ {
+ debug_msg("%s:%d \t<<%s>>: \t\t Error occurred in \"pageAllocBuffer\".", __FILE__, __LINE__, __FUNCTION__); /* exit */
+ err_fatal ("Error occurred in \"pageAllocBuffer\"."); /* exit */
+ }else
+ {
+ debug_msg("%s:%d \t<<%s>>: \t\t pageAllocBuffer() success\n", __FILE__, __LINE__, __FUNCTION__);
+ }
+
+ EPS_PRINTER_INN curPrinter;
+ memset(&curPrinter, 0, sizeof(curPrinter));
+ if(jobAttr.colorMode == EPS_CM_COLOR){
+ curPrinter.language = EPS_LANG_ESCPAGE_COLOR;
+ }else{
+ curPrinter.language = EPS_LANG_ESCPAGE;
+ }
+
+ printJob.printer = &curPrinter;
+ err = pageStartJob();
+ if (err)
+ {
+ err_fatal ("Error occurred in \"pageStartJob\"."); /* exit */
+ }else
+ {
+ debug_msg("%s:%d \t<<%s>>: \t\t pageStartJob() success", __FILE__, __LINE__, __FUNCTION__);
+ }
+ }
+ err = pageStartPage();
+ if (err)
+ {
+ debug_msg("%s:%d \t<<%s>>: \t\t Error occurred in \"pageStartPage\": %d\n", __FILE__, __LINE__, __FUNCTION__, err);
+ err_fatal ("Error occurred in \"pageStartPage\"."); /* exit */
+ }else
+ {
+ debug_msg("%s:%d \t<<%s>>: \t\t pageStartPage() success", __FILE__, __LINE__, __FUNCTION__);
+ }
+ printJob.verticalOffset = 0;
+ print_area_x = printJob.printableAreaWidth;
+ print_area_y = printJob.printableAreaHeight;
+
+ bytes_per_line = (width_pixel * byte_par_pixel);
+
+ int band_out_len = printJob.printableAreaWidth*byte_par_pixel;
+ //band_out_len += band_out_len % 2;
+ band_out_len = ((band_out_len +7)/8)*8;
+ char *bandPrint = mem_new0(char, band_out_len*band_line);
+
+ image_raw = mem_new0 (char, bytes_per_line);
+
+ char *grayBuff;
+ if(byte_par_pixel == 1)
+ {
+ grayBuff = mem_new0 (char, band_out_len*band_line*3);
+ }
+
+ char *pPrint;
+
+ long int total_bytes = 0;
+ read_size = 0;
+ image_bytes = WIDTH_BYTES(header.cupsBytesPerLine)*8;
+ #if (HAVE_PPM)
+
+ sprintf(ppmfilename, "/tmp/al-m2010-page%d.ppm", page_count);
+ fp = fopen(ppmfilename, "w");
+ if(jobAttr.colorMode == EPS_CM_COLOR){
+ fprintf(fp, "P3\n");
+ }else{
+ fprintf(fp, "P2\n");
+ }
+ fprintf(fp, "%u\n",(int)printJob.printableAreaWidth);
+ fprintf(fp, "%u\n",(int)header.cupsHeight);
+ fprintf(fp, "255\n");
+ fclose(fp);
+
+ #endif
+ page_count++;
+ debug_msg("%s:%d \t<<%s>>: \t\timage_bytes = %d\n", __FILE__, __LINE__, __FUNCTION__, image_bytes);
+ image_raw = (char *)calloc (sizeof (char), image_bytes);
+ int i = 0;
+ int y_count = 0;
+ debug_msg("duplex = %d, page_count = %d\n", jobAttr.duplex, page_count);
+
+ for (i = 0; i < header.cupsHeight && !cancel_flg; i ++)
+ {
+ debug_msg("%s:%d \t<<%s>>: \tStart print line [%d]\n", __FILE__, __LINE__, __FUNCTION__, i);
+ int numread = cupsRasterReadPixels (ras, (unsigned char*)image_raw, header.cupsBytesPerLine);
+ if (!numread)
+ {
+ fprintf (stderr, "cupsRasterReadPixels");
+ debug_msg("%s:%d \t<<%s>>: \t\tcupsRasterReadPixels error\n", __FILE__, __LINE__, __FUNCTION__);
+ return 1;
+ }
+ debug_msg("%s:%d \t<<%s>>: \t numread = %d\n", __FILE__, __LINE__, __FUNCTION__, numread);
+ memcpy (bandPrint + (heightPixels%band_line) * band_out_len, image_raw, band_out_len );
+ heightPixels ++;
+ //y_count++;
+ debug_msg("header.cupsBytesPerLine = %d\n", header.cupsBytesPerLine);
+ if (i < printJob.paperHeight)
+ {
+ if(byte_par_pixel == 1)
+ {
+ pPrint = grayBuff;
+ int j = 0;
+ for(j = 0; j < band_out_len*band_line; j++)
+ {
+ grayBuff[j*3] = bandPrint[j];
+ grayBuff[j*3+1] = bandPrint[j];
+ grayBuff[j*3+2] = bandPrint[j];
+ }
+ debug_msg("byte_par_pixel = %d\n", byte_par_pixel);
+ err = PrintBand (grayBuff, band_out_len*band_line*3, &heightPixels);
+ #if (HAVE_PPM)
+ int k = 0;
+ fp = fopen(ppmfilename, "a+");
+ for(k=0; k<(int)header.cupsBytesPerLine; k++)
+ {
+ fprintf(fp, "%u ", (unsigned char)bandPrint[k]);
+ }
+ fprintf(fp, "\n");
+ fclose(fp);
+ #endif
+ }else
+ {
+ debug_msg("byte_par_pixel = %d\n", byte_par_pixel);
+ err = PrintBand (bandPrint, band_out_len, &heightPixels);
+ #if (HAVE_PPM)
+ int k = 0;
+ fp = fopen(ppmfilename, "a+");
+ for(k=0; k<(int)header.cupsBytesPerLine; k++)
+ {
+ fprintf(fp, "%u ", (unsigned char)bandPrint[k]);
+ }
+ fprintf(fp, "\n");
+ fclose(fp);
+ #endif
+ }
+ heightPixels = 0;
+ //err = PrintBand (image_raw, band_out_len, &heightPixels);
+ if (err)
+ {
+ if(err == EPS_OUT_OF_BOUNDS)
+ {
+ debug_msg("EPS_OUT_OF_BOUNDS\n");
+ //break;
+ }
+ debug_msg("PrintBand error: %d\n", err);
+ err_fatal ("Error occurred in \"OUT_FUNC\"."); /* exit */
+ }else
+ {
+ debug_msg("PrintBand success\n");
+ }
+ debug_msg("%s:%d \t<<%s>>: \tCompleted print line [%d]\n", __FILE__, __LINE__, __FUNCTION__, i);
+ }
+ }
+ debug_msg("pageEndPage(%d) call\n", page_count);
+ err = pageEndPage();
+ if (err)
+ {
+ debug_msg("pageEndPage() error: %d\n", err);
+ err_fatal ("Error occurred in \"PEND_FUNC\"."); /* exit */
+ }else
+ {
+ debug_msg("pageEndPage() success\n");
+ }
+ free (image_raw);
+ free(bandPrint);
+ bandPrint = NULL;
+ }
+
+ err = pageEndJob();
+ if(err){
+ err_fatal ("Error occurred in \"pageEndJob\"."); /* exit */
+ }else{
+ debug_msg("pageEndJob() success\n");
+ }
+ return 0;
+}
diff --git a/src/linux_cmn.c b/src/linux_cmn.c
new file mode 100644
index 0000000..c47b8c1
--- /dev/null
+++ b/src/linux_cmn.c
@@ -0,0 +1,320 @@
+/*__________________________________ linux-cmn.c ___________________________________*/
+
+/* 1 2 3 4 5 6 7 8 */
+/*34567890123456789012345678901234567890123456789012345678901234567890123456789012345678*/
+/*******************************************|********************************************/
+/*
+ * Copyright (c) 2007 Seiko Epson Corporation All rights reserved.
+ *
+ * Copyright protection claimed includes all forms and matters of
+ * copyrightable material and information now allowed by statutory or judicial
+ * law or hereinafter granted, including without limitation, material generated
+ * from the software programs which are displayed on the screen such as icons,
+ * screen display looks, etc.
+ *
+ */
+/*******************************************|********************************************/
+/* */
+/* Linux platform depend External Definitions */
+/* */
+/* Function Calls */
+/* -------------------------- */
+/* void* epsmpMemAlloc (size ); */
+/* void epsmpMemFree (memblock ); */
+/* EPS_INT32 epsmpSleep (time ); */
+/* EPS_UINT32 epsmpGetTime (void ); */
+/* EPS_INT32 epsmpLockSync (void ); */
+/* EPS_INT32 epsmpUnlockSync (void ); */
+/* */
+/*******************************************|********************************************/
+
+#if defined (unix) || (__unix)
+/*------------------------------------ Includes -------------------------------------*/
+/*******************************************|********************************************/
+#include "epson-escpr-def.h"
+#include "epson-escpr-err.h"
+#include "linux_cmn.h"
+#include <sys/times.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/time.h> /* struct timeval, select() */
+/* ICANON, ECHO, TCSANOW, struct termios */
+#include <termios.h> /* tcgetattr(), tcsetattr() */
+#include <stdlib.h> /* atexit(), exit() */
+#include <unistd.h> /* read() */
+#include <stdio.h> /* printf() */
+#include <pthread.h>
+
+/*------------------------------ Local Grobal Variables -----------------------------*/
+/*******************************************|********************************************/
+static struct termios g_old_kbd_mode;
+static pthread_mutex_t g_mutex;
+
+/*---------------------------------- Local Functions ---------------------------------*/
+/*******************************************|********************************************/
+static void cooked(void);
+static void raw(void);
+
+/*-------------------------------- Function Declarations ----------------------------*/
+/*******************************************|********************************************/
+
+/*******************************************|********************************************/
+/* Function name: epsmpMemAlloc() */
+/* */
+/* Arguments */
+/* --------- */
+/* Name: Type: Description: */
+/* s size_t I: Number of bytes to allocate, in bytes. */
+/* */
+/* Return value: */
+/* pointer to new buffer */
+/* */
+/* Description: */
+/* Dynamically allocates a memory buffer. */
+/* */
+/*******************************************|********************************************/
+void* epsmpMemAlloc(
+
+ size_t s
+
+){
+ return malloc(s);
+}
+
+
+/*******************************************|********************************************/
+/* Function name: epsmpMemFree() */
+/* */
+/* Arguments */
+/* --------- */
+/* Name: Type: Description: */
+/* p void* I: Block of memory to free. */
+/* */
+/* Return value: */
+/* N/A */
+/* */
+/* Description: */
+/* Frees an allocated block of memory allocated in the xxxMemAlloc () function. */
+/* */
+/*******************************************|********************************************/
+void epsmpMemFree(
+
+ void* p
+
+){
+ free(p);
+}
+
+
+/*******************************************|********************************************/
+/* Function name: epsmpSleep() */
+/* */
+/* Arguments */
+/* --------- */
+/* Name: Type: Description: */
+/* t void* I: Interval (specified in microseconds) */
+/* */
+/* Return value: */
+/* 0 - Success */
+/* -1 - Failure */
+/* */
+/* Description: */
+/* Pauses execution in the current thread for a specified number of microseconds. */
+/* */
+/*******************************************|********************************************/
+EPS_INT32 epsmpSleep(
+
+ EPS_UINT32 t
+
+){
+ usleep( t);
+ return 0;
+}
+
+
+/*******************************************|********************************************/
+/* Function name: epsmpGetTime() */
+/* */
+/* Arguments */
+/* --------- */
+/* Name: Type: Description: */
+/* N/A */
+/* */
+/* Return value: */
+/* System time */
+/* */
+/* Description: */
+/* The time of the system is acquired. */
+/* */
+/*******************************************|********************************************/
+EPS_UINT32 epsmpGetTime(void)
+{
+ struct tms tm;
+ return (times(&tm)*10);
+}
+
+
+/*******************************************|********************************************/
+/* Function name: epsmpGetLocalTime() */
+/* */
+/* Arguments */
+/* --------- */
+/* Name: Type: Description: */
+/* epsTime EPS_LOCAL_TIME* O: time structure. */
+/* */
+/* Return value: */
+/* 0 */
+/* */
+/* Description: */
+/* get the system localtime. */
+/* */
+/*******************************************|********************************************/
+EPS_UINT32 epsmpGetLocalTime(EPS_LOCAL_TIME *epsTime)
+{
+ time_t now;
+ struct tm *t;
+
+ now = time(NULL);
+ t = localtime(&now);
+
+ epsTime->year = 1900;
+ epsTime->mon = 1;
+ epsTime->day = 1;
+ epsTime->hour = 1;
+ epsTime->min = 1;
+ epsTime->sec = 1;
+
+ return 0;
+}
+
+
+/*******************************************|********************************************/
+/* Function name: epsmpLockSync() */
+/* */
+/* Arguments */
+/* --------- */
+/* Name: Type: Description: */
+/* N/A */
+/* */
+/* Return value: */
+/* 0 - Success */
+/* -1 - Failure */
+/* */
+/* Description: */
+/* Lock the synchronization object. */
+/* */
+/*******************************************|********************************************/
+EPS_INT32 epsmpLockSync(void)
+{
+ return pthread_mutex_lock(&g_mutex);
+}
+
+
+/*******************************************|********************************************/
+/* Function name: epsmpUnlockSync() */
+/* */
+/* Arguments */
+/* --------- */
+/* Name: Type: Description: */
+/* N/A */
+/* */
+/* Return value: */
+/* 0 - Success */
+/* -1 - Failure */
+/* */
+/* Description: */
+/* UnLock the synchronization object. */
+/* */
+/*******************************************|********************************************/
+EPS_INT32 epsmpUnlockSync(void)
+{
+ return pthread_mutex_unlock(&g_mutex);
+}
+
+
+
+static void cooked(void)
+{
+ tcsetattr(0, TCSANOW, &g_old_kbd_mode);
+}
+
+static void raw(void)
+{
+ static char init;
+ struct termios new_kbd_mode;
+
+ if(init)
+ return;
+ tcgetattr(0, &g_old_kbd_mode);
+ memcpy(&new_kbd_mode, &g_old_kbd_mode, sizeof(struct termios));
+ new_kbd_mode.c_lflag &= ~(ICANON | ECHO);
+ new_kbd_mode.c_cc[VTIME] = 0;
+ new_kbd_mode.c_cc[VMIN] = 1;
+ tcsetattr(0, TCSANOW, &new_kbd_mode);
+ atexit(cooked);
+
+ init = 1;
+}
+
+EPS_INT32 _kbhit(void)
+{
+ struct timeval timeout;
+ fd_set read_handles;
+ int status;
+
+ raw();
+ FD_ZERO(&read_handles);
+ FD_SET(0, &read_handles);
+ timeout.tv_sec = timeout.tv_usec = 0;
+ status = select(0 + 1, &read_handles, NULL, NULL, &timeout);
+ tcsetattr(0, TCSANOW, &g_old_kbd_mode);
+ if(status < 0)
+ {
+ printf("select() failed in kbhit()\n");
+ exit(1);
+ }
+ return status;
+}
+
+EPS_INT32 _getch(void)
+{
+ unsigned char temp;
+
+ raw();
+ if(read(0, &temp, 1) != 1){
+ tcsetattr(0, TCSANOW, &g_old_kbd_mode);
+ return 0;
+ }
+ tcsetattr(0, TCSANOW, &g_old_kbd_mode);
+ return temp;
+}
+
+
+void _endthread(void)
+{
+ pthread_exit(NULL);
+}
+
+
+void InitMutex(void)
+{
+ pthread_mutex_init(&g_mutex, NULL); /*default (fast) mutex*/
+}
+
+void TermMutex(void)
+{
+ pthread_mutex_destroy(&g_mutex);
+}
+
+
+#endif
+
+/*__________________________________ linux-cmn.c ___________________________________*/
+
+/*34567890123456789012345678901234567890123456789012345678901234567890123456789012345678*/
+/* 1 2 3 4 5 6 7 8 */
+/*******************************************|********************************************/
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+/***** End of File *** End of File *** End of File *** End of File *** End of File ******/
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
diff --git a/src/linux_cmn.h b/src/linux_cmn.h
new file mode 100644
index 0000000..1040936
--- /dev/null
+++ b/src/linux_cmn.h
@@ -0,0 +1,73 @@
+/*__________________________________ linux-cmn.h ___________________________________*/
+
+/* 1 2 3 4 5 6 7 8 */
+/*34567890123456789012345678901234567890123456789012345678901234567890123456789012345678*/
+/*******************************************|********************************************/
+/*
+ * Copyright (c) 2007 Seiko Epson Corporation All rights reserved.
+ *
+ * Copyright protection claimed includes all forms and matters of
+ * copyrightable material and information now allowed by statutory or judicial
+ * law or hereinafter granted, including without limitation, material generated
+ * from the software programs which are displayed on the screen such as icons,
+ * screen display looks, etc.
+ *
+ */
+/*******************************************|********************************************/
+/* */
+/* Linux platform depend External Definitions */
+/* */
+/* Function Calls */
+/* -------------------------- */
+/* void* epsmpMemAlloc (size ); */
+/* void epsmpMemFree (memblock ); */
+/* EPS_INT32 epsmpSleep (time ); */
+/* EPS_UINT32 epsmpGetTime (void ); */
+/* EPS_INT32 epsmpLockSync (void ); */
+/* EPS_INT32 epsmpUnlockSync (void ); */
+/* */
+/*******************************************|********************************************/
+#ifndef __LINUX_CMN__
+#define __LINUX_CMN__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*------------------------------------ Includes -------------------------------------*/
+/*******************************************|********************************************/
+#include "epson-typedefs.h"
+#include "epson-escpr-def.h"
+
+/*--------------------------- Public Function Declarations ---------------------------*/
+/*******************************************|********************************************/
+
+void* epsmpMemAlloc (size_t );
+void epsmpMemFree (void* );
+EPS_INT32 epsmpSleep (EPS_UINT32 );
+EPS_UINT32 epsmpGetTime (void );
+EPS_UINT32 epsmpGetLocalTime(EPS_LOCAL_TIME * );
+EPS_INT32 epsmpLockSync (void );
+EPS_INT32 epsmpUnlockSync (void );
+
+
+EPS_INT32 _kbhit (void );
+EPS_INT32 _getch (void );
+void _endthread (void );
+void InitMutex (void );
+void TermMutex (void );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* def __LINUX_CMN__ */
+
+/*__________________________________ linux-cmn.h ___________________________________*/
+
+/*34567890123456789012345678901234567890123456789012345678901234567890123456789012345678*/
+/* 1 2 3 4 5 6 7 8 */
+/*******************************************|********************************************/
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+/***** End of File *** End of File *** End of File *** End of File *** End of File ******/
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
diff --git a/src/mem.c b/src/mem.c
new file mode 100644
index 0000000..c308514
--- /dev/null
+++ b/src/mem.c
@@ -0,0 +1,76 @@
+/*
+ * EPSON ESC/P-R Printer Driver for Linux
+ * Copyright (C) 2002-2005 AVASYS CORPORATION.
+ * Copyright (C) Seiko Epson Corporation 2002-2005.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
+ *
+ * As a special exception, AVASYS CORPORATION gives permission to
+ * link the code of this program with libraries which are covered by
+ * the AVASYS Public License and distribute their linked
+ * combinations. You must obey the GNU General Public License in all
+ * respects for all of the code used other than the libraries which
+ * are covered by AVASYS Public License.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include "mem.h"
+#include "err.h"
+
+
+void *
+mem_malloc (unsigned int size, bool_t crit)
+{
+ void *m;
+
+ m = malloc (size);
+ if (crit && m == NULL)
+ err_system ("mem_malloc");
+
+ return m;
+}
+
+void *
+mem_calloc (unsigned int num, unsigned int size, bool_t crit)
+{
+ void *m;
+
+ m = calloc (num, size);
+ if (crit && m == NULL)
+ err_system ("mem_calloc");
+
+ return m;
+}
+
+void *
+mem_realloc (void *m, u_int size, bool_t crit)
+{
+ m = realloc (m, size);
+ if (crit && m == NULL)
+ err_system ("mem_realloc");
+
+ return m;
+}
+
+void
+mem_free (void *m)
+{
+ if (m) free (m);
+
+ return;
+}
diff --git a/src/mem.h b/src/mem.h
new file mode 100644
index 0000000..613eb9e
--- /dev/null
+++ b/src/mem.h
@@ -0,0 +1,57 @@
+/*
+ * EPSON ESC/P-R Printer Driver for Linux
+ * Copyright (C) 2002-2005 AVASYS CORPORATION.
+ * Copyright (C) Seiko Epson Corporation 2002-2005.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
+ *
+ * As a special exception, AVASYS CORPORATION gives permission to
+ * link the code of this program with libraries which are covered by
+ * the AVASYS Public License and distribute their linked
+ * combinations. You must obey the GNU General Public License in all
+ * respects for all of the code used other than the libraries which
+ * are covered by AVASYS Public License.
+ */
+#ifndef MEM_H
+#define MEM_H
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "def.h"
+
+/* If it is a success, an address is returned, and if it is failure, a message is outputted and it ends. */
+#define mem_new(type, num) \
+((type *) mem_malloc (sizeof (type) * (num), 1))
+#define mem_new0(type, num) \
+((type *) mem_calloc ((num), sizeof (type), 1))
+#define mem_renew(type, pointer, num) \
+((type *) mem_realloc (pointer, sizeof (type) * (num), 1))
+
+/*
+* bool value true Critical
+* false Normal operation
+*/
+BEGIN_C
+
+void * mem_malloc (unsigned int, bool_t);
+void * mem_calloc (unsigned int, unsigned int, bool_t);
+void * mem_realloc (void *, unsigned int, bool_t);
+void mem_free (void *);
+
+END_C
+
+#endif /* MEM_H */
diff --git a/src/optBase.h b/src/optBase.h
new file mode 100644
index 0000000..c80d1a3
--- /dev/null
+++ b/src/optBase.h
@@ -0,0 +1,192 @@
+/*
+ * EPSON ESC/P-R Printer Driver for Linux
+ * Copyright (C) 2002-2005 AVASYS CORPORATION.
+ * Copyright (C) Seiko Epson Corporation 2002-2005.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
+ *
+ * As a special exception, AVASYS CORPORATION gives permission to
+ * link the code of this program with libraries which are covered by
+ * the AVASYS Public License and distribute their linked
+ * combinations. You must obey the GNU General Public License in all
+ * respects for all of the code used other than the libraries which
+ * are covered by AVASYS Public License.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifndef N_
+#define N_(magic_word) (magic_word)
+#endif
+
+#define END_ARRAY -1
+
+#include "epson-escpr-media.h"
+
+typedef struct _OPTION_DATA
+{
+ int value;
+ char *rsc_name;
+ char *x_name;
+ char *x_name_jp;
+} OPTION_DATA;
+
+OPTION_DATA mediaSizeData[] = {
+ {EPS_MSID_A4, "A4", N_("A4 210x297 mm")},
+ {EPS_MSID_LETTER, "LT", N_("Letter 8 1/2x11 in")},
+ {EPS_MSID_LEGAL, "LGL", N_("Legal 8 1/2x14 in")},
+ {EPS_MSID_A5, "A5", N_("A5 148x210 mm")},
+ {EPS_MSID_A6, "A6", N_("A6 105x148 mm")},
+ {EPS_MSID_B5, "B5", N_("B5 182x257 mm")},
+ {EPS_MSID_EXECUTIVE, "EXE", N_("Executive 7 1/4x10 1/2 in")},
+ {EPS_MSID_HLT, "HLT", N_("Half Letter 5 1/2x8 1/2 in")},
+ {EPS_MSID_PANORAMIC, "PANORAM", N_("Panoramic 210x594 mm")},
+ {EPS_MSID_TRIM_4X6, "4X6", N_("4x6 100x152 mm")},
+ {EPS_MSID_4X6, "4X6FULL", N_("Photo Paper 4x6 in No Perforations")},
+ {EPS_MSID_5X8, "INDEX5", N_("Index card 5x8 in") },
+ {EPS_MSID_8X10, "8x10", N_("Index card 8x10 in") },
+ {EPS_MSID_F4, "F4", N_("F4")},
+ {EPS_MSID_ENVY0, "ENVY0", N_("Yougata 0 120 x 235 mm")},
+ {EPS_MSID_ENVY6, "ENVY6", N_("Yougata 6 98 x 190 mm")},
+ {EPS_MSID_ENVK2, "ENVK2", N_("Kakugata 2 240 x 332 mm")},
+ {EPS_MSID_4PC, "4PC", N_("4PC")},
+ {EPS_MSID_10X15, "PP100", N_("Photo Paper 100x150 mm") },
+ {EPS_MSID_200X300, "PP200", N_("Photo Paper 200x300 mm") },
+ {EPS_MSID_L, "L", N_("3.5x5 in 89x127 mm") },
+ {EPS_MSID_POSTCARD, "POSTCARD", N_("Post Card 100x148 mm") },
+ {EPS_MSID_DBLPOSTCARD, "DPC", N_("Double Post Card 200x148 mm") },
+ {EPS_MSID_ENV_10_L, "ENV10_L", N_("Envelope #10(Landscape) 4 1/8x9 1/2 in") },
+ {EPS_MSID_ENV_C6_L, "ENVC6_L", N_("Envelope C6(Landscape) 114x162 mm") },
+ {EPS_MSID_ENV_DL_L, "ENVDL_L", N_("Envelope DL(Landscape) 110x220 mm") },
+ {EPS_MSID_NEWEVN_L, "ENV5X8_L", N_("Envelope(Landscape) 132x220 mm") },
+ {EPS_MSID_CHOKEI_3, "ENVC3", N_("Envelope 120x235 mm") },
+ {EPS_MSID_CHOKEI_4, "ENVC4", N_("Envelope 90x205 mm") },
+ {EPS_MSID_YOKEI_1, "ENVY1", N_("Envelope 120x176 mm") },
+ {EPS_MSID_YOKEI_2, "ENVY2", N_("Envelope 114x162 mm") },
+ {EPS_MSID_YOKEI_3, "ENVY3", N_("Envelope 98x148 mm") },
+ {EPS_MSID_YOKEI_4, "ENVY4", N_("Envelope 105x235 mm") },
+ {EPS_MSID_2L, "2L", N_("5x7 in 127x178 mm") },
+ //{EPS_MSID_ENV_10, "ENV10", N_("Envelope #10 4 1/8x9 1/2 in") },
+ //{EPS_MSID_ENV_C6, "ENVC6", N_("Envelope C6 114x162 mm") },
+ //{EPS_MSID_ENV_DL, "ENVDL", N_("Envelope DL 110x220 mm") },
+ //{EPS_MSID_NEWENV, "ENV5X8", N_("Envelope 132x220 mm") },
+ {EPS_MSID_BUZCARD_89X50, "NC", N_("Business Card 89x50 mm") },
+ //{EPS_MSID_BUZCARD_89X55, "NC55", N_("Business Card 89x50 mm") },
+ {EPS_MSID_CARD_54X86, "CARD", N_("Card 54x86 mm") },
+ {EPS_MSID_BUZCARD_55X91, "NC91", N_("Business Card 55x91 mm") },
+ {EPS_MSID_ALBUM_A5, "PAA5", N_("Cover of Photo Album L 127 x 198 mm") },
+ {EPS_MSID_ALBUM_L, "PAL", N_("Cover of Photo Album A5 210 x 321 mm") },
+ {EPS_MSID_PALBUM_L_L, "PALL", N_("P.Album L (Landscape) 127 x 89 mm") },
+ {EPS_MSID_PALBUM_2L, "PA2L", N_("P.Album 2L 127 x 178 mm") },
+ {EPS_MSID_PALBUM_A5_L, "PAA5L", N_("P.Album A5 (Landscape) 210 x 148 mm") },
+ {EPS_MSID_PALBUM_A4, "PAA4", N_("P.Album A4 210 x 297 mm") },
+ //{EPS_MSID_4X7, "4X7", N_("16x9 wide size (102 x 181 mm)")},
+ {EPS_MSID_A3NOBI, "A3+", N_("A3+ 329x483 mm") },
+ {EPS_MSID_A3, "A3", N_("A3 297x420 mm") },
+ {EPS_MSID_B4, "B4", N_("B4 257x364 mm") },
+ {EPS_MSID_USB, "USB", N_("US B(11x17 in)")},
+ {EPS_MSID_11X14, "11X14", N_("11x14 in")},
+ {EPS_MSID_B3, "B3", N_("B3 364 x 514 mm")},
+ {EPS_MSID_A2, "A2", N_("A2 420 x 594 mm")},
+ {EPS_MSID_USC, "USC", N_("US C 17 x 22 in")},
+ {EPS_MSID_10X12, "10X12", N_("10x12 in / 254x305 mm")},
+ {EPS_MSID_12X12, "12X12", N_("30 x 30 cm (12 x 12 in)")},
+ {EPS_MSID_GLG, "GLG", N_("8 x 13 in)")},
+ {EPS_MSID_GLT, "GLT", N_("8.5 x 10.5 in")},
+ {EPS_MSID_USER, "USER", N_("User Defined")},
+ {EPS_MSID_MON, "MON", ""},
+ {EPS_MSID_C10, "C10", ""},
+ {EPS_MSID_DL, "DL", ""},
+ {EPS_MSID_C5, "C5",""},
+ {EPS_MSID_C6, "C6",""},
+ {EPS_MSID_IB5, "IB5",""},
+ {EPS_MSID_UNKNOWN, "UNKNOWN", N_("Unknown Paper Size")},
+ {END_ARRAY, "", "" }
+};
+
+
+OPTION_DATA mediaTypeData[] = {
+
+ { EPS_MTID_PLAIN, "PLAIN", N_("plain papers") },
+ { EPS_MTID_360INKJET, "FINE", N_("360dpi Ink Jet Paper") },
+ { EPS_MTID_IRON, "IRON", N_("Iron-On Cool Peel Transfer Paper") },
+ { EPS_MTID_PHOTOINKJET, "SFINE", N_("Photo Quality Ink Jet Paper") },
+ { EPS_MTID_PHOTOADSHEET, "PADSHEET", N_("Photo Quality Self Adhesive Sheets")},
+ { EPS_MTID_MATTE, "PMMATT", N_("EPSON Matte") },
+ { EPS_MTID_PHOTO, "GPPAPER", N_("Photo Paper") }, /* chenged Wed Jan 28 2009 */
+ { EPS_MTID_PHOTOFILM, "GFILM", N_("Photo Quality Glossy Film") },
+ { EPS_MTID_MINIPHOTO, "MINIPHOTO",N_("Epson Photo Stickers") },
+ { EPS_MTID_OHP, "OHP", N_("Ink Jet Transparencies") },
+ { EPS_MTID_BACKLIGHT, "BLFILM", N_("Ink Jet Back Light Film") },
+ { EPS_MTID_PGPHOTO, "PMPHOTO", N_("EPSON Premium Glossy") },
+ { EPS_MTID_PSPHOTO, "PSGLOS", N_("Epson Premium Semigloss") },
+ { EPS_MTID_PLPHOTO, "MCLP", N_("Premium Luster Photo Paper") },
+ { EPS_MTID_MCGLOSSY, "PHOTOW", N_("Glossy Paper - Photo Weight") },
+ { EPS_MTID_ARCHMATTE, "ARCMATT", N_("Archival Matte Paper") },
+ { EPS_MTID_WATERCOLOR, "WATERCOLOR", N_("Watercolor Paper - Radiant White")},
+ { EPS_MTID_PROGLOSS, "PROGLS", N_("Professional Glossy Paper")},
+ { EPS_MTID_MATTEBOARD, "MBOARD", N_("Matte Board Paper")},
+ { EPS_MTID_PHOTOGLOSS, "PHOTOGLS", N_("Photo Quality Glossy Paper")},
+ { EPS_MTID_SEMIPROOF, "SEMIPROOF",N_("Dupont/EPSONSemigloss Proofing Paper-A")},
+ { EPS_MTID_SEMITHICK, "SEMITHICK", ""}, //lam dai hiep add
+ { EPS_MTID_PREPRINTED, "PREPRINTED", ""}, //lam dai hiep add
+ { EPS_MTID_SUPERFINE2, "SFINE2", N_("Photo Quality Ink Jet Paper Plus")},
+ { EPS_MTID_DSMATTE, "DBSMATT", N_("Double-Sided Matte Paper")},
+ { EPS_MTID_CLPHOTO, "CLPP", N_("ColorLife Photo Paper")},
+ { EPS_MTID_ECOPHOTO, "EPHOTO", N_("Economy Photo Paper")},
+ { EPS_MTID_VELVETFINEART, "VELVET_FINE", N_("Velvet Fine Art Paper")},
+ { EPS_MTID_PROOFSEMI, "PROOF_S", N_("Proofing Paper Semimatte")},
+ { EPS_MTID_HAGAKIRECL, "RCPC", N_("Recycled Paper Postcard")},
+ { EPS_MTID_HAGAKIINKJET, "IJPC", N_("Ink Jet Postcard")},
+ { EPS_MTID_PHOTOINKJET2, "PIJ2", N_("Epson Photo Quality Ink Jet")},
+ { EPS_MTID_DURABRITE, "EPP_P", N_("DURABrite Photo Paper")},
+ { EPS_MTID_MATTEMEISHI, "MMEISHI", N_("Matte Business Card")},
+ { EPS_MTID_HAGAKIATENA, "ADDRESS", N_("Post Card Address Side")},
+ { EPS_MTID_PHOTOALBUM, "P_ALBUM", N_("Photo Album")},
+ { EPS_MTID_PHOTOSTAND, "P_BOARD", N_("Photo Board Paper")},
+ { EPS_MTID_RCB, "RCB", N_("RC-B")},
+ { EPS_MTID_PGPHOTOEG, "PGPHOTOEG",N_("Premium Glossy Photo Paper_2")},
+ { EPS_MTID_ENVELOPE, "ENV", N_("Envelope")},
+ { EPS_MTID_PLATINA, "PLATINA", N_("Epson Ultra Glossy")},
+ { EPS_MTID_ULTRASMOOTH, "USF_ART", N_("UltraSmooth Fine Art Paper")},
+/* add Wed Jan 28 2009 v */
+ { EPS_MTID_SFHAGAKI, "SFHAGAKI", N_("Super Fine Postcard")},
+ { EPS_MTID_PHOTOSTD, "PHOTOSTD", N_("Premium Glossy Photo Paper")},
+ { EPS_MTID_GLOSSYHAGAKI, "GLOSSYHAGAKI", N_("Glossy Postcard")},
+ { EPS_MTID_POSTCARD, "POSTCARD", N_("Postcard")},
+ { EPS_MTID_GLOSSYPHOTO, "GLOSSYPHOTO", N_("Glossy Photo Paper")},
+ { EPS_MTID_GLOSSYCAST, "GLOSSYCAST", N_("Epson Photo")},
+ { EPS_MTID_LETTERHEAD, "LETTERHEAD", ""},
+ { EPS_MTID_RECYCLED, "RECYCLED", ""},
+ { EPS_MTID_COLOR, "COLOR", ""},
+ { EPS_MTID_LABEL, "LABEL", ""},
+ { EPS_MTID_THICK, "THICK", ""},
+ {EPS_MTID_TRANSPARENT, "TRANSPARENT", ""},
+ { EPS_MTID_EXTHICK, "EXTHICK", ""},
+ { EPS_MTID_UNSPECIFIED, "UNSPECIFIED", ""},
+ { EPS_MTID_COATED, "COATED", ""},
+ { EPS_MTID_SPECIAL, "SPECIAL", ""},
+ { EPS_MTID_BUSINESSCOAT, "BUSINESSCOAT", N_("Business Ink Jet Coat Paper")},
+/* add Wed Jan 28 2009 ^ */
+/* del Wed Jan 28 2009 { EPS_MTID_GPHOTO, "GPHOTO", N_("Glossy Photo Paper_2")},*/
+/* del Wed Jan 28 2009 { EPS_MTID_PHOTOEGCP, "PHOTOEGCP",N_("Epson Photo")},*/
+ { EPS_MTID_CDDVD, "CDR", N_("CD/DVD")},
+ { EPS_MTID_CDDVDHIGH, "CDRH", N_("CD/DVD Premium Surface")},
+ { EPS_MTID_CLEANING, "CLEAN", N_("Cleaning Sheet")},
+ { EPS_MTID_UNKNOWN, "UNKNOWN", N_("Unknown Paper Type")},
+ { END_ARRAY, "", "" }
+};
+