From f7bc558f279002d6e64c7e77f56a546527b390e4 Mon Sep 17 00:00:00 2001 From: Steve Hawley Date: Sun, 10 May 2015 22:09:14 -0400 Subject: [PATCH] Initial version from local. --- LICENSE.txt | 965 ++++++++++++++++++++++++++ makefile | 85 +++ ppd/EpsonTMT20Simple.ppd | 199 ++++++ rpmbuild_support.sh | 118 ++++ src/bufferedscanlines.c | 140 ++++ src/bufferedscanlines.h | 79 +++ src/rastertoepsonsimple.c | 543 +++++++++++++++ src/rpm-spec/.rpmmacros | 1 + src/rpm-spec/starcupsdrv-version.spec | 264 +++++++ src/setup.sh | 130 ++++ 10 files changed, 2524 insertions(+) create mode 100644 LICENSE.txt create mode 100644 makefile create mode 100644 ppd/EpsonTMT20Simple.ppd create mode 100644 rpmbuild_support.sh create mode 100644 src/bufferedscanlines.c create mode 100644 src/bufferedscanlines.h create mode 100644 src/rastertoepsonsimple.c create mode 100755 src/rpm-spec/.rpmmacros create mode 100644 src/rpm-spec/starcupsdrv-version.spec create mode 100644 src/setup.sh diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..658ea1e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,965 @@ + CUPS License Agreement + + Copyright 2007-2013 by Apple Inc. + 1 Infinite Loop + Cupertino, CA 95014 USA + + WWW: http://www.cups.org/ + + +INTRODUCTION + +CUPS(tm) is provided under the GNU General Public License ("GPL") +and GNU Library General Public License ("LGPL"), Version 2, with an +exception for Apple operating systems. A copy of the exception and +licenses follow this introduction. + +The GNU LGPL applies to the CUPS and CUPS Imaging libraries +located in the "cups" and "filter" subdirectories of the CUPS +source distribution and the files in the "test" subdirectory. The +GNU GPL applies to the remainder of the CUPS distribution. + +For those not familiar with the GNU GPL, the license basically +allows you to: + + - Use the CUPS software at no charge. + - Distribute verbatim copies of the software in source or + binary form. + - Sell verbatim copies of the software for a media fee, or + sell support for the software. + +What this license *does not* allow you to do is make changes or +add features to CUPS and then sell a binary distribution without +source code. You must provide source for any changes or additions +to the software, and all code must be provided under the GPL or +LGPL as appropriate. The only exceptions to this are the portions +of the CUPS software covered by the Apple operating system +license exceptions outlined later in this license agreement. + +The GNU LGPL relaxes the "link-to" restriction, allowing you to +develop applications that use the CUPS and CUPS Imaging libraries +under other licenses and/or conditions as appropriate for your +application, driver, or filter. + + +LICENSE EXCEPTIONS + +In addition, as the copyright holder of CUPS, Apple Inc. grants +the following special exception: + + 1. Apple Operating System Development License Exception; + + a. Software that is developed by any person or entity + for an Apple Operating System ("Apple OS-Developed + Software"), including but not limited to Apple and + third party printer drivers, filters, and backends + for an Apple Operating System, that is linked to the + CUPS imaging library or based on any sample filters + or backends provided with CUPS shall not be + considered to be a derivative work or collective work + based on the CUPS program and is exempt from the + mandatory source code release clauses of the GNU GPL. + You may therefore distribute linked combinations of + the CUPS imaging library with Apple OS-Developed + Software without releasing the source code of the + Apple OS-Developed Software. You may also use sample + filters and backends provided with CUPS to develop + Apple OS-Developed Software without releasing the + source code of the Apple OS-Developed Software. + + b. An Apple Operating System means any operating system + software developed and/or marketed by Apple Inc., + including but not limited to all existing releases and + versions of Apple's Darwin, OS X, and OS X Server + products and all follow-on releases and future + versions thereof. + + c. This exception is only available for Apple + OS-Developed Software and does not apply to software + that is distributed for use on other operating + systems. + + d. All CUPS software that falls under this license + exception have the following text at the top of each + source file: + + This file is subject to the Apple OS-Developed + Software exception. + +No developer is required to provide this exception in a derived +work. + + +KERBEROS SUPPORT CODE + +The Kerberos support code ("KSC") is copyright 2006 by Jelmer +Vernooij and is provided 'as-is', without any express or implied +warranty. In no event will the author or Apple Inc. be held +liable for any damages arising from the use of the KSC. + +Sources files containing KSC have the following text at the top +of each source file: + + This file contains Kerberos support code, copyright 2006 by + Jelmer Vernooij. + +The KSC copyright and license apply only to Kerberos-related +feature code in CUPS. Such code is typically conditionally +compiled based on the present of the HAVE_GSSAPI preprocessor +definition. + +Permission is granted to anyone to use the KSC for any purpose, +including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + + 1. The origin of the KSC must not be misrepresented; you + must not claim that you wrote the original software. If + you use the KSC in a product, an acknowledgment in the + product documentation would be appreciated but is not + required. + + 2. Altered source versions must be plainly marked as such, + and must not be misrepresented as being the original + software. + + 3. This notice may not be removed or altered from any source + distribution. + + +TRADEMARKS + +CUPS and the CUPS logo (the "CUPS Marks") are trademarks of Apple +Inc. Apple grants you a non-exclusive and non-transferable right +to use the CUPS Marks in any direct port or binary distribution +incorporating CUPS software and in any promotional material +therefor. You agree that your products will meet the highest +levels of quality and integrity for similar goods, not be unlawful, +and be developed, manufactured, and distributed in compliance with +this license. You will not interfere with Apple's rights in the +CUPS Marks, and all use of the CUPS Marks shall inure to the +benefit of Apple. This license does not apply to use of the CUPS +Marks in a derivative products, which requires prior written +permission from Apple Inc. + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + [This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/makefile b/makefile new file mode 100644 index 0000000..0b83002 --- /dev/null +++ b/makefile @@ -0,0 +1,85 @@ +VPATH = src:ppd:bin + +ppds = EpsonTMT20Simple.ppd.gz + +DEFS= +LIBS=-lcupsimage -lcups + +ifdef RPMBUILD +DEFS=-DRPMBUILD +LIBS=-ldl +endif + +define dependencies +@if [ ! -e /usr/include/cups ]; then echo "CUPS headers not available - exiting"; exit 1; fi +endef + +define init +@if [ ! -e bin ]; then echo "mkdir bin"; mkdir bin; fi +endef + +define sweep +@if [ -e bin ]; then echo "rm -f bin/*"; rm -f bin/*; rmdir bin; fi +@if [ -e install ]; then echo "rm -f install/*"; rm -f install/*; rmdir install; fi +endef + +install/setup: rastertoepsonsimple $(ppds) setup + # packaging + @if [ -e install ]; then rm -f install/*; rmdir install; fi + mkdir install + cp bin/rastertoepsonsimple install + cp bin/*.ppd.gz install + cp bin/setup install + +.PHONY: install +install: + @if [ ! -e install ]; then echo "Please run make package first."; exit 1; fi + # installing + cd install; exec ./setup + +.PHONY: remove +remove: + #removing from default location (other locations require manual removal) + @if [ -e /usr/lib/cups/filter/rastertoepsonsimple ]; then echo "Removing rastertoepsonsimple"; rm -f /usr/lib/cups/filter/rastertoepsonsimple; fi + @if [ -d /usr/share/cups/model/star ]; then echo "Removing dir .../cups/model/star"; rm -rf /usr/share/cups/model/star; fi + +.PHONY: rpmbuild +rpmbuild: + @if [ ! -e install ]; then echo "Please run make package first."; exit 1; fi + # installing + RPMBUILD="true"; export RPMBUILD; cd install; exec ./setup + +.PHONY: help +help: + # Help for starcupsdrv make file usage + # + # command purpose + # ------------------------------------ + # make compile all sources and create the install directory + # make install execute the setup shell script from the install directory [require root user permissions] + # make remove removes installed files from your system (assumes default install lication) [requires root user permissions] + # make clean deletes all compiles files and their folders + +rastertoepsonsimple: rastertoepsonsimple.c bufferedscanlines.o + $(dependencies) + $(init) + # compiling rastertoepsonsimple filter + gcc -Wl,-rpath,/usr/lib -Wall -fPIC -O2 $(DEFS) -o bin/rastertoepsonsimple bufferedscanlines.o src/rastertoepsonsimple.c $(LIBS) + + +$(ppds): %.ppd.gz: %.ppd + # gzip ppd file + gzip -c $< >> bin/$@ + +setup: setup.sh + $(dependencies) + $(init) + # create setup shell script + cp src/setup.sh bin/setup + chmod +x bin/setup + +.PHONY: clean +clean: + # cleaning + $(sweep) + diff --git a/ppd/EpsonTMT20Simple.ppd b/ppd/EpsonTMT20Simple.ppd new file mode 100644 index 0000000..40070a7 --- /dev/null +++ b/ppd/EpsonTMT20Simple.ppd @@ -0,0 +1,199 @@ +*PPD-Adobe: "4.3" +*FormatVersion: "4.3" +*FileVersion: "2.0" +*LanguageVersion: English +*LanguageEncoding: ISOLatin1 +*PCFileName: "EpsonTMT20Simple.ppd" +*Manufacturer: "Epson" +*Product: "(TM-T20)" +*1284DeviceID: "MFG:Epson;CMD:Epson;MDL:TMT20;CLS:PRINTER;" +*cupsVersion: 1.1 +*cupsManualCopies: True +*cupsModelNumber: 20 +*cupsFilter: "application/vnd.cups-raster 0 rastertoepsonsimple" +*ModelName: "TM-T20" +*ShortNickName: "TM-T20" +*NickName: "Epson TM-T20" +*PSVersion: "(3010.000) 550" +*LanguageLevel: "3" +*ColorDevice: False +*DefaultColorSpace: Gray +*FileSystem: False +*Throughput: "1" +*LandscapeOrientation: Plus90 +*VariablePaperSize: True +*TTRasterizer: Type42 +*cupsSNMPSupplies: False +*cupsIPPReason com.star-paper_out_error/Printer is out of paper: "" + +*OpenUI *PageSize/Media Size: PickOne +*OrderDependency: 10 AnySetup *PageSize +*DefaultPageSize: X80MMY200MM + +*%PageSize Custom/Custom: "<>setpagedevice" + +*% 50.8mm wide page size note +*% 50.8mm = 2.0in * 72 = 144 points +*% use 143 points to cause 5.0 point difference with 52.5mm paper and help CUPS matching algorithm +*% see CUPS src - gdevcups.c - search "find matching page size" +*PageSize X80MMY30MM/80mm * 30mm: "<>setpagedevice" +*PageSize X80MMY40MM/80mm * 40mm: "<>setpagedevice" +*PageSize X80MMY50MM/80mm * 50mm: "<>setpagedevice" +*PageSize X80MMY60MM/80mm * 60mm: "<>setpagedevice" +*PageSize X80MMY70MM/80mm * 70mm: "<>setpagedevice" +*PageSize X80MMY80MM/80mm * 80mm: "<>setpagedevice" +*PageSize X80MMY90MM/80mm * 90mm: "<>setpagedevice" +*PageSize X80MMY100MM/80mm * 100mm: "<>setpagedevice" +*PageSize X80MMY110MM/80mm * 110mm: "<>setpagedevice" +*PageSize X80MMY120MM/80mm * 120mm: "<>setpagedevice" +*PageSize X80MMY130MM/80mm * 130mm: "<>setpagedevice" +*PageSize X80MMY140MM/80mm * 140mm: "<>setpagedevice" +*PageSize X80MMY150MM/80mm * 150mm: "<>setpagedevice" +*PageSize X80MMY160MM/80mm * 160mm: "<>setpagedevice" +*PageSize X80MMY170MM/80mm * 170mm: "<>setpagedevice" +*PageSize X80MMY180MM/80mm * 180mm: "<>setpagedevice" +*PageSize X80MMY190MM/80mm * 190mm: "<>setpagedevice" +*PageSize X80MMY200MM/80mm * 200mm: "<>setpagedevice" +*PageSize X80MMY1500MM/80mm * 1500mm: "<>setpagedevice" +*PageSize X80MMY2000MM/80mm * 2000mm: "<>setpagedevice" + +*% Zoom resolution calculation note +*% A4 real width = 209mm = 8.23in +*% Printer real width = 72mm = 576 dots +*% Printer real resolution = 203dpi +*% Rendering resolution = floor(576 dots / (8.23in * (1 - zoom))) +*% 69 = floor(576 / (8.23 * (1 - 0))) +*% 139 = floor(576 / (8.23 * (1 - .5))) + +*PageSize A4/A4 : "<>setpagedevice" +*PageSize Letter/Letter : "<>setpagedevice" +*PageSize Legal/Legal : "<>setpagedevice" +*CloseUI: *PageSize + +*OpenUI *PageRegion: PickOne +*OrderDependency: 10 AnySetup *PageRegion +*DefaultPageRegion: X80MMY200MM + +*%PageRegion Custom/Custom: "<>setpagedevice" + + +*PageRegion X80MMY30MM/80mm * 30mm: "<>setpagedevice" +*PageRegion X80MMY40MM/80mm * 40mm: "<>setpagedevice" +*PageRegion X80MMY50MM/80mm * 50mm: "<>setpagedevice" +*PageRegion X80MMY60MM/80mm * 60mm: "<>setpagedevice" +*PageRegion X80MMY70MM/80mm * 70mm: "<>setpagedevice" +*PageRegion X80MMY80MM/80mm * 80mm: "<>setpagedevice" +*PageRegion X80MMY90MM/80mm * 90mm: "<>setpagedevice" +*PageRegion X80MMY100MM/80mm * 100mm: "<>setpagedevice" +*PageRegion X80MMY110MM/80mm * 110mm: "<>setpagedevice" +*PageRegion X80MMY120MM/80mm * 120mm: "<>setpagedevice" +*PageRegion X80MMY130MM/80mm * 130mm: "<>setpagedevice" +*PageRegion X80MMY140MM/80mm * 140mm: "<>setpagedevice" +*PageRegion X80MMY150MM/80mm * 150mm: "<>setpagedevice" +*PageRegion X80MMY160MM/80mm * 160mm: "<>setpagedevice" +*PageRegion X80MMY170MM/80mm * 170mm: "<>setpagedevice" +*PageRegion X80MMY180MM/80mm * 180mm: "<>setpagedevice" +*PageRegion X80MMY190MM/80mm * 190mm: "<>setpagedevice" +*PageRegion X80MMY200MM/80mm * 200mm: "<>setpagedevice" +*PageRegion X80MMY1500MM/80mm * 1500mm: "<>setpagedevice" +*PageRegion X80MMY2000MM/80mm * 2000mm: "<>setpagedevice" + +*PageRegion A4/A4 : "<>setpagedevice" +*PageRegion Letter/Letter : "<>setpagedevice" +*PageRegion Legal/Legal : "<>setpagedevice" +*CloseUI: *PageRegion + +*DefaultImageableArea: X80MMY200MM + +*%ImageableArea Custom: "0.0 0.0 0.0 0.0" + +*ImageableArea X80MMY30MM: "0.0 0.0 226.0 85.0" +*ImageableArea X80MMY40MM: "0.0 0.0 226.0 113.0" +*ImageableArea X80MMY50MM: "0.0 0.0 226.0 141.0" +*ImageableArea X80MMY60MM: "0.0 0.0 226.0 170.0" +*ImageableArea X80MMY70MM: "0.0 0.0 226.0 198.0" +*ImageableArea X80MMY80MM: "0.0 0.0 226.0 226.0" +*ImageableArea X80MMY90MM: "0.0 0.0 226.0 255.0" +*ImageableArea X80MMY100MM: "0.0 0.0 226.0 283.0" +*ImageableArea X80MMY110MM: "0.0 0.0 226.0 311.0" +*ImageableArea X80MMY120MM: "0.0 0.0 226.0 340.0" +*ImageableArea X80MMY130MM: "0.0 0.0 226.0 368.0" +*ImageableArea X80MMY140MM: "0.0 0.0 226.0 396.0" +*ImageableArea X80MMY150MM: "0.0 0.0 226.0 425.0" +*ImageableArea X80MMY160MM: "0.0 0.0 226.0 453.0" +*ImageableArea X80MMY170MM: "0.0 0.0 226.0 481.0" +*ImageableArea X80MMY180MM: "0.0 0.0 226.0 510.0" +*ImageableArea X80MMY190MM: "0.0 0.0 226.0 538.0" +*ImageableArea X80MMY200MM: "0.0 0.0 226.0 566.0" +*ImageableArea X80MMY1500MM: "0.0 0.0 226.0 4251.0" +*ImageableArea X80MMY2000MM: "0.0 0.0 226.0 5668.0" + +*ImageableArea A4: "0.0 0.0 595.0 842.0" +*ImageableArea Letter: "0.0 0.0 612.0 792.0" +*ImageableArea Legal: "0.0 0.0 612.0 1008.0" + + +*DefaultPaperDimension: X80MMY200MM + +*%PaperDimension Custom: "0 0" + + +*PaperDimension X80MMY30MM: "226 85" +*PaperDimension X80MMY40MM: "226 113" +*PaperDimension X80MMY50MM: "226 141" +*PaperDimension X80MMY60MM: "226 170" +*PaperDimension X80MMY70MM: "226 198" +*PaperDimension X80MMY80MM: "226 226" +*PaperDimension X80MMY90MM: "226 255" +*PaperDimension X80MMY100MM: "226 283" +*PaperDimension X80MMY110MM: "226 311" +*PaperDimension X80MMY120MM: "226 340" +*PaperDimension X80MMY130MM: "226 368" +*PaperDimension X80MMY140MM: "226 396" +*PaperDimension X80MMY150MM: "226 425" +*PaperDimension X80MMY160MM: "226 453" +*PaperDimension X80MMY170MM: "226 481" +*PaperDimension X80MMY180MM: "226 510" +*PaperDimension X80MMY190MM: "226 538" +*PaperDimension X80MMY200MM: "226 566" +*PaperDimension X80MMY1500MM: "226 4251" +*PaperDimension X80MMY2000MM: "226 5668" + +*PaperDimension A4: "595 842" +*PaperDimension Letter: "612 792" +*PaperDimension Legal: "612 1008" + +*MaxMediaWidth: "226" +*MaxMediaHeight: "5670" +*HWMargins: 0 0 0 0 +*CustomPageSize True: "pop pop pop <>setpagedevice" +*ParamCustomPageSize Width: 1 points 72 226 +*ParamCustomPageSize Height: 2 points 72 5670 +*ParamCustomPageSize WidthOffset: 3 points 0 0 +*ParamCustomPageSize HeightOffset: 4 points 0 0 +*ParamCustomPageSize Orientation: 5 int 0 0 + +*OpenGroup: OutputGroup/Output Options +*OpenUI *PageType/3. Page Type: PickOne +*DefaultPageType: 0Variable +*PageType 0Variable/Variable Length: "" +*PageType 1Fixed/Fixed Length: "" +*CloseUI: *PageType +*CloseGroup: OutputGroup + +*OpenGroup: CutGroup/Cut Options +*OpenUI *PageCutType/1. Page Cut Type: PickOne +*DefaultPageCutType: 0NoCutPage +*PageCutType 0NoCutPage/No Cut: "" +*PageCutType 1CutPage/Cut: "" +*CloseUI: *PageCutType + +*OpenUI *DocCutType/2. Document Cut Type: PickOne +*DefaultDocCutType: 1CutDoc +*DocCutType 0NoCutDoc/No Cut: "" +*DocCutType 1CutDoc/Cut: "" +*CloseUI: *DocCutType +*CloseGroup: CutGroup + + +*% End diff --git a/rpmbuild_support.sh b/rpmbuild_support.sh new file mode 100644 index 0000000..a7076c1 --- /dev/null +++ b/rpmbuild_support.sh @@ -0,0 +1,118 @@ +#!/bin/sh + +#-------------------------------------------------------------- +# This shell script was made for rpmbuild. +# +# Before using this script you have to finish +# to make cups driver without RPMBUILD. +# +# This scirpt is avalable on Red Hat Enterprise Linux 5 +# and uses "rpmbuild ver.4.4.3". +# +# Since 2006/02/25 10:00:00 by K.Nagai +# Last Mod. 2015/01/15 15:00:00 by Y.Hara +#-------------------------------------------------------------- + +PROJNAME=starcupsdrv-3.5.0 +PROJDIRNAME=epsonsimplecupsdrv +RPMROOT=~/RPM +RPMBUILD=$RPMROOT/BUILD +RPMRPMS=$RPMROOT/RPMS +RPMSOURCES=$RPMROOT/SOURCES +RPMSPECS=$RPMROOT/SPECS +RPMSRPMS=$RPMROOT/SRPMS +DESTDIR=$RPMSOURCES/$PROJNAME + +#-------------------------------- +# -- Make .rpmmacros file +#-------------------------------- +if [ -e ~/.rpmmacros ] +then : + echo "This pc already has .rpmmaros file." + echo "If you cannot make rpm file, please comfirm that" + echo "is the existing .rpmmacros correct ?" +else + cp ./src/rpm-spec/.rpmmacros ~ +fi + +#-------------------------------- +# -- Make RPM Directory +#-------------------------------- +# -- RPM root +if [ -d $RPMROOT ] +then : # do nothing +else + mkdir $RPMROOT +fi + +# -- BUILD +if [ -d $RPMBUILD ] +then : # do nothing +else + mkdir $RPMBUILD +fi + +# -- RPMS +if [ -d $RPMRPMS ] +then : # do nothing +else + mkdir $RPMRPMS +fi + +# -- SOURCES +if [ -d $RPMSOURCES ] +then : # do nothing +else + mkdir $RPMSOURCES +fi + +# -- SPECS +if [ -d $RPMSPECS ] +then : # do nothing +else + mkdir $RPMSPECS +fi + +# -- SRPMS +if [ -d $RPMSRPMS ] +then : # do nothing +else + mkdir $RPMSRPMS +fi + +#-------------------------------- +# -- Make [source].tar.gz +#-------------------------------- +if [ -d $DESTDIR ] +then : # do nothing +else + mkdir $DESTDIR +fi + +# -- copy make files +cp ./makefile $DESTDIR +cp ./LICENSE.txt $DESTDIR +cp ./rpmbuild_support.sh $DESTDIR + +# -- copy src files +if [ -d $DESTDIR/src ] +then : # do nothing +else + mkdir $DESTDIR/src +fi +cp ./src/*.c $DESTDIR/src +cp ./src/*.sh $DESTDIR/src + +# -- copy ppd files +if [ -d $DESTDIR/ppd ] +then : # do nothing +else + mkdir $DESTDIR/ppd +fi +cp ./ppd/*.ppd $DESTDIR/ppd + +RETURNPATH=$PWD +cd $RPMSOURCES +tar cvzf ./$PROJNAME.tar.gz $PROJNAME/ +cd $RETURNPATH +rpmbuild -bb ./src/rpm-spec/starcupsdrv-version.spec diff --git a/src/bufferedscanlines.c b/src/bufferedscanlines.c new file mode 100644 index 0000000..855eaa2 --- /dev/null +++ b/src/bufferedscanlines.c @@ -0,0 +1,140 @@ +/* + * 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. + */ + +/* + * These are a set of routines that provide the ability to buffer up + * scanlines for writing in bulk. + * + * Original version, Steve Hawley, 5/10/2015 + */ + +#include +#include +#include "bufferedscanlines.h" + +/* + * private routine to clear a buffer and reset the currentRow + */ +static void bufferscan_reset(t_bufferscan *bs) +{ + if (!bs) return; + int totalBytes; + + if (!bs) return; + totalBytes = bs->bytesPerRow * bs->currentRow; + bs->currentRow = 0; + memset(bs->rawData, 0, totalBytes); +} + +/* + * Allocate and reset a new bufferscan object. + * Returns NULL on failure. + */ +t_bufferscan *bufferscan_new(int bytesperrow, int rows, FILE *fp) +{ + t_bufferscan *bs = (t_bufferscan *)malloc(sizeof(t_bufferscan)); + if (!bs) return 0; + + bs->bytesPerRow = bytesperrow; + bs->totalRows = rows; + bs->fp = fp; + bs->rawData = (unsigned char *)malloc(bytesperrow * rows); + if (!bs->rawData) + { + free(bs); + return 0; + } + bufferscan_reset(bs); + return bs; +} + +/* + * Dispose an existing bufferscan and its memory. + * This will not close the associated FILE. + */ +void bufferscan_dispose(t_bufferscan *bs) +{ + if (!bs) return; + free(bs->rawData); + free(bs); +} + +/* + * Adds a line to the buffer at currentRow. When currentRow is + * advanced to totalRows, then flush out the current data. + */ +void bufferscan_addline(t_bufferscan *bs, unsigned char *data) +{ + unsigned char *dest = 0; + if (!bs || !data) return; + dest = bs->rawData + (bs->bytesPerRow * bs->currentRow); + memcpy(dest, data, bs->bytesPerRow); + bs->currentRow++; + if (bs->currentRow == bs->totalRows) + bufferscan_flush(bs); +} + +/* + * Flushes out any existing data in a bufferscan to the printer + * and resets the bufferscan. This can be called at any time, but it + * will be called automatically by adding lines. + */ +void bufferscan_flush(t_bufferscan *bs) +{ + int totalBytes; + int i; + + if (!bs) return; + if (bs->currentRow == 0) return; + totalBytes = bs->bytesPerRow * bs->currentRow; + + /* + * Image data is represented by a small header block and then a chunk o + * of raw bitmap data. + * The format is: + * <29>8L0p0<1><1>1 + * values in angle brackets are integer values. In this form, + * datalen is a 4 byte integer that represents the length of all + * data that follows immediately after, including the format and + * width/height descriptors. + * datalen is 10 + (bytes wide * rows high). + * The 10 comes from all the information after before + */ + + fputc(29, bs->fp); fputc('8', bs->fp); fputc('L', bs->fp); + writeLong(totalBytes + 10, bs->fp); + fputc('0', bs->fp); fputc('p', bs->fp); + fputc('0', bs->fp); fputc(1, bs->fp); fputc(1, bs->fp); fputc('1', bs->fp); + writeShort(bs->bytesPerRow * 8, bs->fp); + writeShort(bs->currentRow, bs->fp); + + fwrite(bs->rawData, 1, totalBytes, bs->fp); + fputc(29, bs->fp); fputc('(', bs->fp); fputc('L', bs->fp); + fputc(2, bs->fp); fputc(0, bs->fp); fputc('0', bs->fp); fputc('2', bs->fp); + bufferscan_reset(bs); +} + +/* write nbytes of an int in little endian form */ +void writeInt(int n, int nbytes, FILE *fp) +{ + int i; + for (i=0; i < nbytes; i++) { + fputc(n & 0xff, fp); + n = n >> 8; + } +} + + diff --git a/src/bufferedscanlines.h b/src/bufferedscanlines.h new file mode 100644 index 0000000..f92f03c --- /dev/null +++ b/src/bufferedscanlines.h @@ -0,0 +1,79 @@ +#ifndef _H_BufferedScanlines +#define _H_BufferedScanlines +#pragma once + + +/* + * 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. + * + * Original version, Steve Hawley, 5/10/2015 + */ + +#include + +/* + * basic definition for a buffer of scanlines. + * This is more or less a typical 1-bit byte-padded bitmap + * with state information for the current row that needs to + * be buffered and the output FILE. + * + * In theory, the bitmap, the state, and the output should + * be different entities to prevent interdependence, but + * honestly, this code is so dead-simple, any additional + * abstraction takes away from the readability. + */ +typedef struct t_bufferscan { + int bytesPerRow; + int totalRows; + int currentRow; + FILE *fp; + unsigned char *rawData; +} t_bufferscan; + +/* + * This is the primary API for buffering up scanlines. + * There is a constructor/destructor set, a routine for adding a line, + * a routine to flush the current buffer out, and a routine for writing + * little endian integers as binary data. + */ + +/* constructs a new t_bufferscan with the given bytesperrow, the total number of rows, + * and the output FILE. Returns NULL on failure. Internally, this will allocate memory + * for the buffer. + */ +extern t_bufferscan *bufferscan_new(int bytesperrow, int rows, FILE *fp); +/* destructure the t_bufferscan and its contents. Does NOT close the output FILE */ +extern void bufferscan_dispose(t_bufferscan *bs); + +/* adds a line to the current buffer. If this action fills the buffer, the code + * will automatically flush the buffer. + */ +extern void bufferscan_addline(t_bufferscan *bs, unsigned char *data); +/* writes the buffered scanlines out as an image consumable by an EPSON TM-T20 printer. + */ +extern void bufferscan_flush(t_bufferscan *bs); + +/* + * Writes nByes of the integer in little endian format to the FILE + */ +extern void writeInt(int n, int nbytes, FILE *fp); + +/* + * Macros for short and long + */ +#define writeShort(n, fp) writeInt(n, 2, fp) +#define writeLong(n, fp) writeInt(n, 4, fp) + +#endif diff --git a/src/rastertoepsonsimple.c b/src/rastertoepsonsimple.c new file mode 100644 index 0000000..66f56b6 --- /dev/null +++ b/src/rastertoepsonsimple.c @@ -0,0 +1,543 @@ +/* + * This code is based on the Star Micronics Driver. The copyright notice + * is preserved below, however, the code at this point bears very little relationship + * to the original work. What is preserved is the option retrieval code, the CUPS api + * retrieval code, and the structure of the main loop. Otherwise, most of the options + * have been removed and the remaining options and the core implementation of raster + * transfer are totally different. + * GPL still applies. + * + * Stephen Hawley, 5/10/2015 + */ + +/* + * Copyright (C) 2004-2015 Star Micronics Co., Ltd. + * + * 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 "bufferedscanlines.h" +#include +#include +#include +#ifdef MACOSX +#include +#include +#endif +#include +#include +#include + +#ifdef RPMBUILD + +#include + + +typedef cups_raster_t * (*cupsRasterOpen_fndef)(int fd, cups_mode_t mode); +typedef unsigned (*cupsRasterReadHeader2_fndef)(cups_raster_t *r, cups_page_header2_t *h); +typedef unsigned (*cupsRasterReadPixels_fndef)(cups_raster_t *r, unsigned char *p, unsigned len); +typedef void (*cupsRasterClose_fndef)(cups_raster_t *r); + +static cupsRasterOpen_fndef cupsRasterOpen_fn; +static cupsRasterReadHeader2_fndef cupsRasterReadHeader2_fn; +static cupsRasterReadPixels_fndef cupsRasterReadPixels_fn; +static cupsRasterClose_fndef cupsRasterClose_fn; + +#define CUPSRASTEROPEN (*cupsRasterOpen_fn) +#define CUPSRASTERREADHEADER2 (*cupsRasterReadHeader2_fn) +#define CUPSRASTERREADPIXELS (*cupsRasterReadPixels_fn) +#define CUPSRASTERCLOSE (*cupsRasterClose_fn) + +typedef void (*ppdClose_fndef)(ppd_file_t *ppd); +typedef ppd_choice_t * (*ppdFindChoice_fndef)(ppd_option_t *o, const char *option); +typedef ppd_choice_t * (*ppdFindMarkedChoice_fndef)(ppd_file_t *ppd, const char *keyword); +typedef ppd_option_t * (*ppdFindOption_fndef)(ppd_file_t *ppd, const char *keyword); +typedef void (*ppdMarkDefaults_fndef)(ppd_file_t *ppd); +typedef ppd_file_t * (*ppdOpenFile_fndef)(const char *filename); + +typedef void (*cupsFreeOptions_fndef)(int num_options, cups_option_t *options); +typedef int (*cupsParseOptions_fndef)(const char *arg, int num_options, cups_option_t **options); +typedef int (*cupsMarkOptions_fndef)(ppd_file_t *ppd, int num_options, cups_option_t *options); + +static ppdClose_fndef ppdClose_fn; +static ppdFindChoice_fndef ppdFindChoice_fn; +static ppdFindMarkedChoice_fndef ppdFindMarkedChoice_fn; +static ppdFindOption_fndef ppdFindOption_fn; +static ppdMarkDefaults_fndef ppdMarkDefaults_fn; +static ppdOpenFile_fndef ppdOpenFile_fn; + +static cupsFreeOptions_fndef cupsFreeOptions_fn; +static cupsParseOptions_fndef cupsParseOptions_fn; +static cupsMarkOptions_fndef cupsMarkOptions_fn; + +#define PPDCLOSE (*ppdClose_fn) +#define PPDFINDCHOICE (*ppdFindChoice_fn) +#define PPDFINDMARKEDCHOICE (*ppdFindMarkedChoice_fn) +#define PPDFINDOPTION (*ppdFindOption_fn) +#define PPDMARKDEFAULTS (*ppdMarkDefaults_fn) +#define PPDOPENFILE (*ppdOpenFile_fn) + +#define CUPSFREEOPTIONS (*cupsFreeOptions_fn) +#define CUPSPARSEOPTIONS (*cupsParseOptions_fn) +#define CUPSMARKOPTIONS (*cupsMarkOptions_fn) + +#else + +#define CUPSRASTEROPEN cupsRasterOpen +#define CUPSRASTERREADHEADER2 cupsRasterReadHeader2 +#define CUPSRASTERREADPIXELS cupsRasterReadPixels +#define CUPSRASTERCLOSE cupsRasterClose + +#define PPDCLOSE ppdClose +#define PPDFINDCHOICE ppdFindChoice +#define PPDFINDMARKEDCHOICE ppdFindMarkedChoice +#define PPDFINDOPTION ppdFindOption +#define PPDMARKDEFAULTS ppdMarkDefaults +#define PPDOPENFILE ppdOpenFile + +#define CUPSFREEOPTIONS cupsFreeOptions +#define CUPSPARSEOPTIONS cupsParseOptions +#define CUPSMARKOPTIONS cupsMarkOptions + +#endif + +#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) ) + +#define FALSE 0 +#define TRUE (!FALSE) + + +struct settings_ +{ + float pageWidth; + float pageHeight; + + int pageCutType; + int docCutType; + + int bytesPerScanLine; + int bytesPerScanLineStd; + +}; + +struct command +{ + int length; + char* command; +}; + +static const struct command printerInitializeCommand = +{2,(char[2]){0x1b,'@'}}; + +static const struct command pageCutCommand = +{4, (char[4]){29,'V','A',20}}; + + +inline void debugPrintSettings(struct settings_ * settings) +{ + fprintf(stderr, "DEBUG: pageCutType = %d\n" , settings->pageCutType); + fprintf(stderr, "DEBUG: docCutType = %d\n" , settings->docCutType); + fprintf(stderr, "DEBUG: bytesPerScanLine = %d\n", settings->bytesPerScanLine); +} + +inline void outputCommand(struct command output) +{ + int i = 0; + + for (; i < output.length; i++) + { + putchar(output.command[i]); + } +} + +inline int getOptionChoiceIndex(const char * choiceName, ppd_file_t * ppd) +{ + ppd_choice_t * choice; + ppd_option_t * option; + + choice = PPDFINDMARKEDCHOICE(ppd, choiceName); + if (choice == NULL) + { + if ((option = PPDFINDOPTION(ppd, choiceName)) == NULL) return -1; + if ((choice = PPDFINDCHOICE(option,option->defchoice)) == NULL) return -1; + } + + return atoi(choice->choice); +} + +inline void getPageWidthPageHeight(ppd_file_t * ppd, struct settings_ * settings) +{ + ppd_choice_t * choice; + ppd_option_t * option; + + char width[20]; + int widthIdx; + + char height[20]; + int heightIdx; + + char * pageSize; + int idx; + + int state; + + choice = PPDFINDMARKEDCHOICE(ppd, "PageSize"); + if (choice == NULL) + { + option = PPDFINDOPTION(ppd, "PageSize"); + choice = PPDFINDCHOICE(option,option->defchoice); + } + + widthIdx = 0; + memset(width, 0x00, sizeof(width)); + + heightIdx = 0; + memset(height, 0x00, sizeof(height)); + + pageSize = choice->choice; + idx = 0; + + state = 0; // 0 = init, 1 = width, 2 = height, 3 = complete, 4 = fail + + while (pageSize[idx] != 0x00) + { + if (state == 0) + { + if (pageSize[idx] == 'X') + { + state = 1; + + idx++; + continue; + } + } + else if (state == 1) + { + if ((pageSize[idx] >= '0') && (pageSize[idx] <= '9')) + { + width[widthIdx++] = pageSize[idx]; + + idx++; + continue; + } + else if (pageSize[idx] == 'D') + { + width[widthIdx++] = '.'; + + idx++; + continue; + } + else if (pageSize[idx] == 'M') + { + idx++; + continue; + } + else if (pageSize[idx] == 'Y') + { + state = 2; + + idx++; + continue; + } + } + else if (state == 2) + { + if ((pageSize[idx] >= '0') && (pageSize[idx] <= '9')) + { + height[heightIdx++] = pageSize[idx]; + + idx++; + continue; + } + else if (pageSize[idx] == 'D') + { + height[heightIdx++] = '.'; + + idx++; + continue; + } + else if (pageSize[idx] == 'M') + { + state = 3; + break; + } + } + + state = 4; + break; + } + + if (state == 3) + { + settings->pageWidth = atof(width); + settings->pageHeight = atof(height); + } + else + { + settings->pageWidth = 0; + settings->pageHeight = 0; + } +} + +inline void initializeSettings(char * commandLineOptionSettings, struct settings_ * settings) +{ + ppd_file_t * ppd = NULL; + cups_option_t * options = NULL; + int numOptions; + + ppd = PPDOPENFILE(getenv("PPD")); + + PPDMARKDEFAULTS(ppd); + + numOptions = CUPSPARSEOPTIONS(commandLineOptionSettings, 0, &options); + if ((numOptions != 0) && (options != NULL)) + { + CUPSMARKOPTIONS(ppd, numOptions, options); + + CUPSFREEOPTIONS(numOptions, options); + } + + memset(settings, 0x00, sizeof(struct settings_)); + + settings->pageCutType = getOptionChoiceIndex("PageCutType" , ppd); + settings->docCutType = getOptionChoiceIndex("DocCutType" , ppd); + settings->bytesPerScanLine = 80; + settings->bytesPerScanLineStd = 80; + + getPageWidthPageHeight(ppd, settings); + + PPDCLOSE(ppd); + + debugPrintSettings(settings); +} + +void jobSetup(struct settings_ settings) +{ + outputCommand(printerInitializeCommand); +} + +void pageSetup(struct settings_ settings, cups_page_header_t header) +{ +} + +void endPage(struct settings_ settings) +{ + if (settings.pageCutType) + { + outputCommand(pageCutCommand); + } +} + +void endJob(struct settings_ settings) +{ + if (settings.docCutType) + { + outputCommand(pageCutCommand); + } +} + +#define GET_LIB_FN_OR_EXIT_FAILURE(fn_ptr,lib,fn_name) \ +{ \ + fn_ptr = dlsym(lib, fn_name); \ + if ((dlerror()) != NULL) \ + { \ + fputs("ERROR: required fn not exported from dynamically loaded libary\n", stderr); \ + if (libCupsImage != 0) dlclose(libCupsImage); \ + if (libCups != 0) dlclose(libCups); \ + return EXIT_FAILURE; \ + } \ +} + +#ifdef RPMBUILD +#define CLEANUP \ +{ \ + if (rasterData != NULL) free(rasterData); \ + CUPSRASTERCLOSE(ras); \ + if (fd != 0) \ + { \ + close(fd); \ + } \ + dlclose(libCupsImage); \ + dlclose(libCups); \ +} +#else +#define CLEANUP \ +{ \ + if (rasterData != NULL) free(rasterData); \ + CUPSRASTERCLOSE(ras); \ + if (fd != 0) \ + { \ + close(fd); \ + } \ +} +#endif + + +int main(int argc, char *argv[]) +{ + int fd = 0; /* File descriptor providing CUPS raster data */ + cups_raster_t * ras = NULL; /* Raster stream for printing */ + cups_page_header2_t header; /* CUPS Page header */ + int page = 0; /* Current page */ + + int y = 0; /* Vertical position in page 0 <= y <= header.cupsHeight */ + + unsigned char * rasterData = NULL; /* Pointer to raster data buffer */ + struct settings_ settings; /* Configuration settings */ + + int bytesPerScanline = 0; + +#ifdef RPMBUILD + void * libCupsImage = NULL; /* Pointer to libCupsImage library */ + void * libCups = NULL; /* Pointer to libCups library */ + + + libCups = dlopen ("libcups.so", RTLD_NOW | RTLD_GLOBAL); + if (! libCups) + { + fputs("ERROR: libcups.so load failure\n", stderr); + return EXIT_FAILURE; + } + + libCupsImage = dlopen ("libcupsimage.so", RTLD_NOW | RTLD_GLOBAL); + if (! libCupsImage) + { + fputs("ERROR: libcupsimage.so load failure\n", stderr); + dlclose(libCups); + return EXIT_FAILURE; + } + + GET_LIB_FN_OR_EXIT_FAILURE(ppdClose_fn, libCups, "ppdClose" ); + GET_LIB_FN_OR_EXIT_FAILURE(ppdFindChoice_fn, libCups, "ppdFindChoice" ); + GET_LIB_FN_OR_EXIT_FAILURE(ppdFindMarkedChoice_fn, libCups, "ppdFindMarkedChoice" ); + GET_LIB_FN_OR_EXIT_FAILURE(ppdFindOption_fn, libCups, "ppdFindOption" ); + GET_LIB_FN_OR_EXIT_FAILURE(ppdMarkDefaults_fn, libCups, "ppdMarkDefaults" ); + GET_LIB_FN_OR_EXIT_FAILURE(ppdOpenFile_fn, libCups, "ppdOpenFile" ); + GET_LIB_FN_OR_EXIT_FAILURE(cupsFreeOptions_fn, libCups, "cupsFreeOptions" ); + GET_LIB_FN_OR_EXIT_FAILURE(cupsParseOptions_fn, libCups, "cupsParseOptions" ); + GET_LIB_FN_OR_EXIT_FAILURE(cupsMarkOptions_fn, libCups, "cupsMarkOptions" ); + GET_LIB_FN_OR_EXIT_FAILURE(cupsRasterOpen_fn, libCupsImage, "cupsRasterOpen" ); + GET_LIB_FN_OR_EXIT_FAILURE(cupsRasterReadHeade2r_fn, libCupsImage, "cupsRasterReadHeader2" ); + GET_LIB_FN_OR_EXIT_FAILURE(cupsRasterReadPixels_fn, libCupsImage, "cupsRasterReadPixels" ); + GET_LIB_FN_OR_EXIT_FAILURE(cupsRasterClose_fn, libCupsImage, "cupsRasterClose" ); +#endif + + if (argc < 6 || argc > 7) + { + fputs("ERROR: rastertoepsonsimple job-id user title copies options [file]\n", stderr); + + #ifdef RPMBUILD + dlclose(libCupsImage); + dlclose(libCups); + #endif + + return EXIT_FAILURE; + } + + if (argc == 7) + { + if ((fd = open(argv[6], O_RDONLY)) == -1) + { + perror("ERROR: Unable to open raster file - "); + sleep(1); + + #ifdef RPMBUILD + dlclose(libCupsImage); + dlclose(libCups); + #endif + + return EXIT_FAILURE; + } + } + else + { + fd = 0; + } + + initializeSettings(argv[5], &settings); + + jobSetup(settings); + ras = CUPSRASTEROPEN(fd, CUPS_RASTER_READ); + + page = 0; + + while (CUPSRASTERREADHEADER2(ras, &header)) + + { + t_bufferscan *bs = NULL; + if ((header.cupsHeight == 0) || (header.cupsBytesPerLine == 0)) + { + break; + } + + if (rasterData == NULL) + { + rasterData = malloc(header.cupsBytesPerLine); + if (rasterData == NULL) + { + CLEANUP; + return EXIT_FAILURE; + + } + } + + page++; + fprintf(stderr, "PAGE: %d %d\n", page, header.NumCopies); + + bytesPerScanline = settings.bytesPerScanLine < header.cupsBytesPerLine ? + settings.bytesPerScanLine : header.cupsBytesPerLine; + + bs = bufferscan_new(bytesPerScanline, 256, stdout); + if (!bs) + { + CLEANUP; + return EXIT_FAILURE; + } + + for (y = 0; y < header.cupsHeight; y ++) + { + memset(rasterData, 0, bytesPerScanline); + + if (CUPSRASTERREADPIXELS(ras, rasterData, header.cupsBytesPerLine) < 1) + { + break; + } + + bufferscan_addline(bs, rasterData); + } + + bufferscan_flush(bs); + bufferscan_dispose(bs); + bs = NULL; + + endPage(settings); + } + + endJob(settings); + + CLEANUP; + + if (page == 0) + { + fputs("ERROR: No pages found!\n", stderr); + } + else + { + fputs("INFO: Ready to print.\n", stderr); + } + + return (page == 0)?EXIT_FAILURE:EXIT_SUCCESS; +} + diff --git a/src/rpm-spec/.rpmmacros b/src/rpm-spec/.rpmmacros new file mode 100755 index 0000000..d84d9a3 --- /dev/null +++ b/src/rpm-spec/.rpmmacros @@ -0,0 +1 @@ +%_topdir /root/RPM diff --git a/src/rpm-spec/starcupsdrv-version.spec b/src/rpm-spec/starcupsdrv-version.spec new file mode 100644 index 0000000..bc7251a --- /dev/null +++ b/src/rpm-spec/starcupsdrv-version.spec @@ -0,0 +1,264 @@ +%define name starcupsdrv +%define version 3.5.0 +%define release 1 + +Name: %{name} +Summary: Star Micronics SP, TSP, HSP, TUP and FVP model CUPS printer drivers. +Version: %{version} +Release: %{release} +License: GPL +Group: Hardware/Printing +Source: http://www.star-m.jp/service/s_print/bin/%{name}-3.5.0.tar.gz +URL: http://www.star-m.jp/service/s_print/starcupsdrv_linux86_yyyymmdd.htm +Vendor: Star Micronics Co., Ltd. +Packager: Yusuke Hara +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot + +%description +The StarCUPSDrv package contains CUPS based printer drivers +for the following models: + +SP500 +SP700 +TSP100 +TSP100GT +TSP650 +TSP650II +TSP700II +TSP800II +TSP828L +TSP1000 +TUP500 +TUP900 +HSP7000 +FVP10 + +These drivers allow for printing from all applications that use the +standard printing path (CUPS). + +After installing this package, go to http://localhost:631 (aka http://127.0.0.1:631) +or use your favorite CUPS print manager to add a new queue for your printer. + +%prep +%setup + +%build +make RPMBUILD=true + +%install +rm -rf $RPM_BUILD_ROOT +make DESTDIR=$RPM_BUILD_ROOT rpmbuild + +%clean +rm -rf $RPM_BUILD_ROOT + +%pre +LDCONFIGREQ=0 +if [ ! -e /usr/lib/libcups.so ] +then + for libcups in $(ls /usr/lib/libcups.so*) + do + if [ -x $libcups ] + then + LDCONFIGREQ=1 + ln -s $libcups /usr/lib/libcups.so + break + fi + done +fi +if [ ! -x /usr/lib/libcups.so ] +then + echo "required library libcups.so not available" + exit 1 +fi +if [ ! -e /usr/lib/libcupsimage.so ] +then + for libcupsimage in $(ls /usr/lib/libcupsimage.so*) + do + if [ -x $libcupsimage ] + then + LDCONFIGREQ=1 + ln -s $libcupsimage /usr/lib/libcupsimage.so + break + fi + done +fi +if [ ! -x /usr/lib/libcupsimage.so ] +then + echo "required library libcupsimage.so not available" + exit 1 +fi +if [ "$LDCONFIGREQ" = "1" ] +then + ldconfig +fi +exit 0 + +%post +if [ -x /etc/software/init.d/cups ] +then + /etc/software/init.d/cups stop + /etc/software/init.d/cups start +elif [ -x /etc/rc.d/init.d/cups ] +then + /etc/rc.d/init.d/cups stop + /etc/rc.d/init.d/cups start +elif [ -x /etc/init.d/cups ] +then + /etc/init.d/cups stop + /etc/init.d/cups start +elif [ -x /sbin/init.d/cups ] +then + /sbin/init.d/cups stop + /sbin/init.d/cups start +elif [ -x /etc/software/init.d/cupsys ] +then + /etc/software/init.d/cupsys stop + /etc/software/init.d/cupsys start +elif [ -x /etc/rc.d/init.d/cupsys ] +then + /etc/rc.d/init.d/cupsys stop + /etc/rc.d/init.d/cupsys start +elif [ -x /etc/init.d/cupsys ] +then + /etc/init.d/cupsys stop + /etc/init.d/cupsys start +elif [ -x /sbin/init.d/cupsys ] +then + /sbin/init.d/cupsys stop + /sbin/init.d/cupsys start +else + killall -HUP cupsd +fi +exit 0 + +%preun +for ppd in $(ls '/etc/cups/ppd') +do + if grep "SP500\|SP700\|TSP100\|TSP100GT\|TSP650\|TSP700II\|TSP800II\TSP828L\|TSP1000\|TUP500\|TUP900\|FVP10" "/etc/cups/ppd/$ppd"; then exit 127; fi +done +exit 0 + +%files +%attr(755, root, root) /usr/lib/cups/filter/rastertostar +%attr(755, root, root) /usr/lib/cups/filter/rastertostarlm +%attr(755, root, root) %dir /usr/share/cups/model/star/ +%attr(644, root, root) /usr/share/cups/model/star/sp512.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/sp542.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/sp712.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/sp742.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/sp717.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/sp747.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp113.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp143.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp113gt.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp143gt.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp651.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp654.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp700II.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp800II.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp828l.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tsp1000.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tup542.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tup592.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tup942.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/tup992.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/hsp7000r.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/hsp7000s.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/hsp7000v.ppd.gz +%attr(644, root, root) /usr/share/cups/model/star/fvp10.ppd.gz + +%changelog +* Thu Jan 15 2015 Yusuke Hara +- Version 3.5.0 +- Support Bluetooth Printer for Mac + +* Mon Feb 3 2014 Yusuke Hara +- Version 3.4.2 +- Fixed bug that cannot print by using cupsfilter command. + +* Tue Jan 28 2014 Yusuke Hara +- Version 3.4.1 +- Fixed bug that it may cayse extremely slow printing or + data lost when using CUPS drivers + V3.4.0 or older with Mac OS X 10.9 (Mavericks). + +* Fri Dec 14 2012 Yusuke Hara +- Version 3.4.0 release +- Added TSP650II +- Modified File Permission (Mac OS X) + +* Fri Feb 25 2011 Yusuke Hara +- Version 3.2.1 release +- Added "cupsSNMPSupplies is False" in PPD file. +- Modified NSB Invalid command sending in only USB interface of Mac OS X. + +* Tue Aug 31 2010 Yusuke Hara +- Version 3.2.0 release +- Added dataTreatmentRecoverFromError Function of TSP700II, TSP600 and SP700 + +* Thu Apr 20 2010 Yusuke Hara +- Version 3.1.1 release +- Added FVP10 + +* Fri Feb 19 2010 Yusuke hara +- Version 3.0.2 release +- Added Tips.(TSP100IIU BackFeed script and Vertical Compression script) + +* Thu Jun 30 2009 Yusuke Hara +- Version 3.1.0 release +- Added TSP800II + +* Thu Oct 15 2008 Kazumasa Hosozawa +- Version 3.0.0 release +- Added TUP500 + +* Fri Mar 23 2008 Kazumasa Hosozawa +- Version 2.10.0 release +- Added HSP7000 + +* Wed Dec 12 2007 Kazumasa Hosozawa +- Version 2.9.0 release +- Added TSP100GT + +* Wed Dec 3 2007 Kazumasa Hosozawa +- Version 2.8.2 release +- Bug fix. Dot-Printer's Print Speed.(SP700, SP500) + +* Wed Sep 9 2007 Kazumasa Hosozawa +- Version 2.8.1 release +- Modified File Permission (Mac OS X) + +* Fri Jun 26 2007 Kazumasa Hosozawa +- Version 2.8.0 release +- Added TSP650 + +* Thu Feb 8 2007 Toshiharu Takada +- Version 2.7.0 release +- Added TSP700II + +* Fri Dec 1 2006 Toshiharu Takada +- Version 2.6.0 release +- Added SP700 + +* Fri Feb 24 2006 Kenichi Nagai +- Version 2.4.0 release +- Added TSP828L + +* Fri Aug 19 2005 Dwayne Harris +- Version 2.3.0 release +- Added TSP100 + +* Mon Feb 14 2005 Albert Kennis +- Version 2.2.0 release +- Fixed bug - cash drawer setting not working + +* Tue Oct 19 2004 Albert Kennis +- Version 2.1.0 release +- Added TSP1000 +- Added USB device ID support to PPD files +- Fixed bug in support of custom page sizes + +* Fri Jul 16 2004 Albert Kennis +- Version 2.0.0 initial release + diff --git a/src/setup.sh b/src/setup.sh new file mode 100644 index 0000000..6e220db --- /dev/null +++ b/src/setup.sh @@ -0,0 +1,130 @@ +#!/bin/sh + +echo "EpsonTMT20Simple" +echo "cups driver installer" +echo "---------------------------------------" + +ROOT_UID=0 + +if [ -z $RPMBUILD ] && [ "$UID" -ne "$ROOT_UID" ] +then + echo "This script requires root user access." + echo "Re-run as root user." + exit 1 +fi + +if [ ! -z $DESTDIR ] +then + echo "DESTDIR set to $DESTDIR" + echo "" +fi + +SERVERROOT=$(grep '^ServerRoot' /etc/cups/cupsd.conf | awk '{print $2}') + +if [ -z $FILTERDIR ] || [ -z $PPDDIR ] +then + echo "Searching for ServerRoot, ServerBin, and DataDir tags in /etc/cups/cupsd.conf" + echo "" + + if [ -z $FILTERDIR ] + then + SERVERBIN=$(grep '^ServerBin' /etc/cups/cupsd.conf | awk '{print $2}') + + if [ -z $SERVERBIN ] + then + echo "ServerBin tag not present in cupsd.conf - using default" + FILTERDIR=usr/lib/cups/filter + elif [ ${SERVERBIN:0:1} = "/" ] + then + echo "ServerBin tag is present as an absolute path" + FILTERDIR=$SERVERBIN/filter + else + echo "ServerBin tag is present as a relative path - appending to ServerRoot" + FILTERDIR=$SERVERROOT/$SERVERBIN/filter + fi + fi + + echo "" + + if [ -z $PPDDIR ] + then + DATADIR=$(grep '^DataDir' /etc/cups/cupsd.conf | awk '{print $2}') + + if [ -z $DATADIR ] + then + echo "DataDir tag not present in cupsd.conf - using default" + PPDDIR=/usr/share/cups/model/epson + elif [ ${DATADIR:0:1} = "/" ] + then + echo "DataDir tag is present as an absolute path" + PPDDIR=$DATADIR/model/epson + else + echo "DataDir tag is present as a relative path - appending to ServerRoot" + PPDDIR=$SERVERROOT/$DATADIR/model/epson + fi + fi + + echo "" + + echo "ServerRoot = $SERVERROOT" + echo "ServerBin = $SERVERBIN" + echo "DataDir = $DATADIR" + echo "" +fi + +echo "Copying rastertoepsonsimple filter to $DESTDIR/$FILTERDIR" +mkdir -p $DESTDIR/$FILTERDIR +chmod +x rastertoepsonsimple +cp rastertoepsonsimple $DESTDIR/$FILTERDIR +echo "" + +echo "Copying model ppd files to $DESTDIR/$PPDDIR" +mkdir -p $DESTDIR/$PPDDIR +cp *.gz $DESTDIR/$PPDDIR +echo "" + +if [ -z $RPMBUILD ] +then + echo "Restarting CUPS" + if [ -x /etc/software/init.d/cups ] + then + /etc/software/init.d/cups stop + /etc/software/init.d/cups start + elif [ -x /etc/rc.d/init.d/cups ] + then + /etc/rc.d/init.d/cups stop + /etc/rc.d/init.d/cups start + elif [ -x /etc/init.d/cups ] + then + /etc/init.d/cups stop + /etc/init.d/cups start + elif [ -x /sbin/init.d/cups ] + then + /sbin/init.d/cups stop + /sbin/init.d/cups start + elif [ -x /etc/software/init.d/cupsys ] + then + /etc/software/init.d/cupsys stop + /etc/software/init.d/cupsys start + elif [ -x /etc/rc.d/init.d/cupsys ] + then + /etc/rc.d/init.d/cupsys stop + /etc/rc.d/init.d/cupsys start + elif [ -x /etc/init.d/cupsys ] + then + /etc/init.d/cupsys stop + /etc/init.d/cupsys start + elif [ -x /sbin/init.d/cupsys ] + then + /sbin/init.d/cupsys stop + /sbin/init.d/cupsys start + else + echo "Could not restart CUPS" + fi + echo "" +fi + +echo "Install Complete" +echo "Add printer queue using OS tool, http://localhost:631, or http://127.0.0.1:631" +echo "" +