Update zint

This commit is contained in:
Rodrigo Torres 2017-09-04 00:44:16 -03:00
parent 5c3c032ea3
commit ba828a984f
82 changed files with 78771 additions and 9 deletions

11
3rdparty/3rdparty.pro vendored
View File

@ -1,6 +1,5 @@
ZINT_PATH = $$PWD/zint-2.4.4/
ZINT_VERSION = 2.4.4
INCLUDEPATH += $${ZINT_PATH}/backend $${ZINT_PATH}/backend_qt4
DEPENDPATH += $${ZINT_PATH}/backend $${ZINT_PATH}/backend_qt4
include($${ZINT_PATH}/backend_qt4/Zint.pro)
ZINT_PATH = $$PWD/zint-2.6.1/
ZINT_VERSION = 2.6.1
INCLUDEPATH += $${ZINT_PATH}/backend $${ZINT_PATH}/backend_qt
DEPENDPATH += $${ZINT_PATH}/backend $${ZINT_PATH}/backend_qt
include($${ZINT_PATH}/backend_qt/backend_qt.pro)

674
3rdparty/zint-2.6.1/COPYING vendored Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
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
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 3 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, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU 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 Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

357
3rdparty/zint-2.6.1/backend/2of5.c vendored Normal file
View File

@ -0,0 +1,357 @@
/* 2of5.c - Handles Code 2 of 5 barcodes */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#ifdef _MSC_VER
#include <malloc.h>
#define inline _inline
#endif
static const char *C25MatrixTable[10] = {
"113311", "311131", "131131", "331111", "113131", "313111",
"133111", "111331", "311311", "131311"
};
static const char *C25IndustTable[10] = {
"1111313111", "3111111131", "1131111131", "3131111111", "1111311131",
"3111311111", "1131311111", "1111113131", "3111113111", "1131113111"
};
static const char *C25InterTable[10] = {
"11331", "31113", "13113", "33111", "11313", "31311", "13311", "11133",
"31131", "13131"
};
static inline char check_digit(unsigned int count) {
return itoc((10 - (count % 10)) % 10);
}
/* Code 2 of 5 Standard (Code 2 of 5 Matrix) */
int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
char dest[512]; /* 6 + 80 * 6 + 6 + 1 ~ 512*/
if (length > 80) {
strcpy(symbol->errtxt, "301: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "302: Invalid characters in data");
return error_number;
}
/* start character */
strcpy(dest, "411111");
for (i = 0; i < length; i++) {
lookup(NEON, C25MatrixTable, source[i], dest);
}
/* Stop character */
strcat(dest, "41111");
expand(symbol, dest);
ustrcpy(symbol->text, source);
return error_number;
}
/* Code 2 of 5 Industrial */
int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
char dest[512]; /* 6 + 40 * 10 + 6 + 1 */
if (length > 45) {
strcpy(symbol->errtxt, "303: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "304: Invalid character in data");
return error_number;
}
/* start character */
strcpy(dest, "313111");
for (i = 0; i < length; i++) {
lookup(NEON, C25IndustTable, source[i], dest);
}
/* Stop character */
strcat(dest, "31113");
expand(symbol, dest);
ustrcpy(symbol->text, source);
return error_number;
}
/* Code 2 of 5 IATA */
int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
char dest[512]; /* 4 + 45 * 10 + 3 + 1 */
if (length > 45) {
strcpy(symbol->errtxt, "305: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "306: Invalid characters in data");
return error_number;
}
/* start */
strcpy(dest, "1111");
for (i = 0; i < length; i++) {
lookup(NEON, C25IndustTable, source[i], dest);
}
/* stop */
strcat(dest, "311");
expand(symbol, dest);
ustrcpy(symbol->text, source);
return error_number;
}
/* Code 2 of 5 Data Logic */
int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
char dest[512]; /* 4 + 80 * 6 + 3 + 1 */
if (length > 80) {
strcpy(symbol->errtxt, "307: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "308: Invalid characters in data");
return error_number;
}
/* start character */
strcpy(dest, "1111");
for (i = 0; i < length; i++) {
lookup(NEON, C25MatrixTable, source[i], dest);
}
/* Stop character */
strcat(dest, "311");
expand(symbol, dest);
ustrcpy(symbol->text, source);
return error_number;
}
/* Code 2 of 5 Interleaved */
int interleaved_two_of_five(struct zint_symbol *symbol, const unsigned char source[], size_t length) {
int i, j, k, error_number;
char bars[7], spaces[7], mixed[14], dest[1000];
#ifndef _MSC_VER
unsigned char temp[length + 2];
#else
unsigned char* temp = (unsigned char *) _alloca((length + 2) * sizeof (unsigned char));
#endif
if (length > 89) {
strcpy(symbol->errtxt, "309: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "310: Invalid characters in data");
return error_number;
}
ustrcpy(temp, (unsigned char *) "");
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
if an odd number of characters has been entered then add a leading zero */
if (length & 1) {
ustrcpy(temp, (unsigned char *) "0");
length++;
}
strcat((char*) temp, (char*) source);
/* start character */
strcpy(dest, "1111");
for (i = 0; i < length; i += 2) {
/* look up the bars and the spaces and put them in two strings */
strcpy(bars, "");
lookup(NEON, C25InterTable, temp[i], bars);
strcpy(spaces, "");
lookup(NEON, C25InterTable, temp[i + 1], spaces);
/* then merge (interlace) the strings together */
k = 0;
for (j = 0; j <= 4; j++) {
mixed[k] = bars[j];
k++;
mixed[k] = spaces[j];
k++;
}
mixed[k] = '\0';
strcat(dest, mixed);
}
/* Stop character */
strcat(dest, "311");
expand(symbol, dest);
ustrcpy(symbol->text, temp);
return error_number;
}
/* Interleaved 2-of-5 (ITF) */
int itf14(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number, zeroes;
unsigned int count;
char localstr[16];
count = 0;
if (length > 13) {
strcpy(symbol->errtxt, "311: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "312: Invalid character in data");
return error_number;
}
/* Add leading zeros as required */
zeroes = 13 - length;
for (i = 0; i < zeroes; i++) {
localstr[i] = '0';
}
strcpy(localstr + zeroes, (char *) source);
/* Calculate the check digit - the same method used for EAN-13 */
for (i = 12; i >= 0; i--) {
count += ctoi(localstr[i]);
if (!(i & 1)) {
count += 2 * ctoi(localstr[i]);
}
}
localstr[13] = check_digit(count);
localstr[14] = '\0';
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char*) localstr);
return error_number;
}
/* Deutshe Post Leitcode */
int dpleit(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
unsigned int count;
char localstr[16];
int zeroes;
count = 0;
if (length > 13) {
strcpy(symbol->errtxt, "313: Input wrong length");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "314: Invalid characters in data");
return error_number;
}
zeroes = 13 - length;
for (i = 0; i < zeroes; i++)
localstr[i] = '0';
strcpy(localstr + zeroes, (char *) source);
for (i = 12; i >= 0; i--) {
count += 4 * ctoi(localstr[i]);
if (i & 1) {
count += 5 * ctoi(localstr[i]);
}
}
localstr[13] = check_digit(count);
localstr[14] = '\0';
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char*) localstr);
return error_number;
}
/* Deutsche Post Identcode */
int dpident(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number, zeroes;
unsigned int count;
char localstr[16];
count = 0;
if (length > 11) {
strcpy(symbol->errtxt, "315: Input wrong length");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "316: Invalid characters in data");
return error_number;
}
zeroes = 11 - length;
for (i = 0; i < zeroes; i++)
localstr[i] = '0';
strcpy(localstr + zeroes, (char *) source);
for (i = 10; i >= 0; i--) {
count += 4 * ctoi(localstr[i]);
if (i & 1) {
count += 5 * ctoi(localstr[i]);
}
}
localstr[11] = check_digit(count);
localstr[12] = '\0';
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char*) localstr);
return error_number;
}

View File

@ -0,0 +1,31 @@
# (c) 2008 by BogDan Vatra < bogdan@licentia.eu >
project(zint)
find_package(PNG)
set(zint_COMMON_SRCS common.c library.c render.c large.c reedsol.c gs1.c eci.c)
set(zint_ONEDIM_SRCS code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c)
set(zint_POSTAL_SRCS postal.c auspost.c imail.c)
set(zint_TWODIM_SRCS code16k.c codablock.c dmatrix.c pdf417.c qr.c maxicode.c composite.c aztec.c code49.c code1.c gridmtx.c hanxin.c dotcode.c)
set(zint_OUTPUT_SRCS render.c ps.c svg.c emf.c bmp.c pcx.c gif.c png.c tif.c raster.c)
set(zint_SRCS ${zint_OUTPUT_SRCS} ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS})
if(PNG_FOUND)
include_directories( ${PNG_INCLUDES} )
else(PNG_FOUND)
add_definitions (-DNO_PNG)
endif(PNG_FOUND)
add_library(zint SHARED ${zint_SRCS})
set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
VERSION ${ZINT_VERSION})
if(PNG_FOUND)
target_link_libraries(zint ${PNG_LIBRARIES} )
endif(PNG_FOUND)
target_link_libraries(zint -lm)
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(FILES zint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)

133
3rdparty/zint-2.6.1/backend/DEVELOPER vendored Normal file
View File

@ -0,0 +1,133 @@
Contents
--------
Here is a guide to which bit of source code does what.
2of5.c:
Matrix 2 of 5
Industrial 2 of 5
IATA 2 of 5
Data Logic
Interleaved 2 of 5
ITF-14
Deutche Post Leitcode
Deutche Post Identcode
auspost.c:
Australia Post Standard Customer Barcode
Australia Post Customer Barcode 2
Australia Post Customer Barcode 3
Australia Post Reply Paid Barcode
Australia Post Routing Barcode
Australia Post Redirect Barcode
aztec.c:
Aztec Code
Compact Aztec Code
Aztec Runes
blockf.c:
Codablock-F
code128.c:
Code 128
Code 128 Subset B
NVE-18
GS1-128 (UCC/EAN-128)
EAN-14
code16k.c:
Code 16k
code.c:
Code 11
Code 39
Pharmazentral Nummer (PZN)
Extended Code 39 (Code 39+)
Code 93
LOGMARS
Channel Code
code1.c:
Code One
code49.c:
Code 49
composite.c:
CC-A Composite Symbology
CC-B Composite Symbology
CC-C Composite Symbology
dotcode.c:
Dot Code
dm200.c:
Data Matrix ECC 200
gridmtx.c:
Grid Matrix
hanxin.c:
Han Xin Code
imail.c:
USPS OneCode (Intelligent Mail)
maxicode.c:
UPS Maxicode
medical.c:
Pharma Code
Two Track Pharma Code
Codabar
Code 32
pdf417.c:
PDF417
Truncated PDF417
MicroPDF417
plessey.c:
UK Plessey Code (bidirectional)
MSI Plessey
postal.c:
PostNet
PLANET
Facing Identification Mark (FIM)
Royal Mail 4-State Country Code (RM4SCC)
KIX Code
DAFT Code
Flattermarken
Korean Postal Code
Japanese Postal Code
qr.c:
QR Code
Micro QR Code
UPNQR
rss.c:
GS1 DataBar (DataBar-14) (RSS-14)
GS1 DataBar Stacked (RSS-14 Stacked)
GS1 DataBar Stacked Omnidirectional (DataBar-14 Stacked Omnidirectional)
(RSS-14 Stacked Omnidirectional)
GS1 DataBar Limited (RSS Limited)
GS1 DataBar Expanded (RSS Expanded)
GS1 DataBar Expanded Stacked (RSS Expanded Stacked)
telepen.c:
Telepen ASCII
Telepen Numeric
upcean.c:
UPC-A
UPC-E
EAN-2 add-on
EAN-5 add-on
EAN-8
EAN-13
SBN (verification)
ISBN (verification)
ISBN-13 (verification)

13
3rdparty/zint-2.6.1/backend/LICENSE vendored Normal file
View File

@ -0,0 +1,13 @@
ZINT was originally developed by Robin Stuart and licensed under the terms of the GPL (Gnu
Public License). In 2013 Robin Stuart and all developers that contributed to the code agreed
to change the license to a less restrictive one (see ZINT mailing list of May 2013 for
related mails) under the following conditions:
- the names of original copyright holder Robin Stuart and contributors are not removed,
neither from sources nor from the manual
- the documentation is done in British English (as Robin said: "Oh, and please don't
replace the word "colour" with "color" in the documentation - that really annoys me!")
Change to BSD-license is done for backend and therefore for ZINT shared library only, for
the frontends and Qt4-backend the GPL is still valid. Since BSD-license is GPL-compatible
this gives the possibility to include ZINT library in own products or link against it from
own software.

254
3rdparty/zint-2.6.1/backend/auspost.c vendored Normal file
View File

@ -0,0 +1,254 @@
/* auspost.c - Handles Australia Post 4-State Barcode */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#define GDSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #"
static const char *AusNTable[10] = {
"00", "01", "02", "10", "11", "12", "20", "21", "22", "30"
};
static const char *AusCTable[64] = {
"222", "300", "301", "302", "310", "311", "312", "320", "321", "322",
"000", "001", "002", "010", "011", "012", "020", "021", "022", "100", "101", "102", "110",
"111", "112", "120", "121", "122", "200", "201", "202", "210", "211", "212", "220", "221",
"023", "030", "031", "032", "033", "103", "113", "123", "130", "131", "132", "133", "203",
"213", "223", "230", "231", "232", "233", "303", "313", "323", "330", "331", "332", "333",
"003", "013"
};
static const char *AusBarTable[64] = {
"000", "001", "002", "003", "010", "011", "012", "013", "020", "021",
"022", "023", "030", "031", "032", "033", "100", "101", "102", "103", "110", "111", "112",
"113", "120", "121", "122", "123", "130", "131", "132", "133", "200", "201", "202", "203",
"210", "211", "212", "213", "220", "221", "222", "223", "230", "231", "232", "233", "300",
"301", "302", "303", "310", "311", "312", "313", "320", "321", "322", "323", "330", "331",
"332", "333"
};
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include "reedsol.h"
#ifdef _MSC_VER
#define inline _inline
#endif
static inline char convert_pattern(char data, int shift) {
return (data - '0') << shift;
}
/* Adds Reed-Solomon error correction to auspost */
void rs_error(char data_pattern[]) {
size_t reader, triple_writer = 0;
char triple[31], inv_triple[31];
unsigned char result[5];
for (reader = 2; reader < strlen(data_pattern); reader += 3, triple_writer++) {
triple[triple_writer] = convert_pattern(data_pattern[reader], 4)
+ convert_pattern(data_pattern[reader + 1], 2)
+ convert_pattern(data_pattern[reader + 2], 0);
}
for (reader = 0; reader < triple_writer; reader++) {
inv_triple[reader] = triple[(triple_writer - 1) - reader];
}
rs_init_gf(0x43);
rs_init_code(4, 1);
rs_encode(triple_writer, (unsigned char*) inv_triple, result);
for (reader = 4; reader > 0; reader--) {
strcat(data_pattern, AusBarTable[(int) result[reader - 1]]);
}
rs_free();
}
/* Handles Australia Posts's 4 State Codes */
int australia_post(struct zint_symbol *symbol, unsigned char source[], int length) {
/* Customer Standard Barcode, Barcode 2 or Barcode 3 system determined automatically
(i.e. the FCC doesn't need to be specified by the user) dependent
on the length of the input string */
/* The contents of data_pattern conform to the following standard:
0 = Tracker, Ascender and Descender
1 = Tracker and Ascender
2 = Tracker and Descender
3 = Tracker only */
int error_number, zeroes;
int writer;
unsigned int loopey, reader;
size_t h;
char data_pattern[200];
char fcc[3] = {0, 0, 0}, dpid[10];
char localstr[30];
error_number = 0;
strcpy(localstr, "");
/* Do all of the length checking first to avoid stack smashing */
if (symbol->symbology == BARCODE_AUSPOST) {
/* Format control code (FCC) */
switch (length) {
case 8:
strcpy(fcc, "11");
break;
case 13:
strcpy(fcc, "59");
break;
case 16:
strcpy(fcc, "59");
error_number = is_sane(NEON, source, length);
break;
case 18:
strcpy(fcc, "62");
break;
case 23:
strcpy(fcc, "62");
error_number = is_sane(NEON, source, length);
break;
default:
strcpy(symbol->errtxt, "401: Auspost input is wrong length");
return ZINT_ERROR_TOO_LONG;
}
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "402: Invalid characters in data");
return error_number;
}
} else {
if (length > 8) {
strcpy(symbol->errtxt, "403: Auspost input is too long");
return ZINT_ERROR_TOO_LONG;
}
switch (symbol->symbology) {
case BARCODE_AUSREPLY: strcpy(fcc, "45");
break;
case BARCODE_AUSROUTE: strcpy(fcc, "87");
break;
case BARCODE_AUSREDIRECT: strcpy(fcc, "92");
break;
}
/* Add leading zeros as required */
zeroes = 8 - length;
memset(localstr, '0', zeroes);
localstr[8] = '\0';
}
strcat(localstr, (char*) source);
h = strlen(localstr);
error_number = is_sane(GDSET, (unsigned char *) localstr, h);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "404: Invalid characters in data");
return error_number;
}
/* Verifiy that the first 8 characters are numbers */
memcpy(dpid, localstr, 8);
dpid[8] = '\0';
error_number = is_sane(NEON, (unsigned char *) dpid, strlen(dpid));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "405: Invalid characters in DPID");
return error_number;
}
/* Start character */
strcpy(data_pattern, "13");
/* Encode the FCC */
for (reader = 0; reader < 2; reader++) {
lookup(NEON, AusNTable, fcc[reader], data_pattern);
}
/* printf("AUSPOST FCC: %s ", fcc); */
/* Delivery Point Identifier (DPID) */
for (reader = 0; reader < 8; reader++) {
lookup(NEON, AusNTable, dpid[reader], data_pattern);
}
/* Customer Information */
if (h > 8) {
if ((h == 13) || (h == 18)) {
for (reader = 8; reader < h; reader++) {
lookup(GDSET, AusCTable, localstr[reader], data_pattern);
}
} else if ((h == 16) || (h == 23)) {
for (reader = 8; reader < h; reader++) {
lookup(NEON, AusNTable, localstr[reader], data_pattern);
}
}
}
/* Filler bar */
h = strlen(data_pattern);
switch (h) {
case 22:
case 37:
case 52:
strcat(data_pattern, "3");
break;
default:
break;
}
/* Reed Solomon error correction */
rs_error(data_pattern);
/* Stop character */
strcat(data_pattern, "13");
/* Turn the symbol into a bar pattern ready for plotting */
writer = 0;
h = strlen(data_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((data_pattern[loopey] == '1') || (data_pattern[loopey] == '0')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((data_pattern[loopey] == '2') || (data_pattern[loopey] == '0')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
symbol->row_height[0] = 3;
symbol->row_height[1] = 2;
symbol->row_height[2] = 3;
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}

1681
3rdparty/zint-2.6.1/backend/aztec.c vendored Normal file

File diff suppressed because it is too large Load Diff

145
3rdparty/zint-2.6.1/backend/aztec.h vendored Normal file
View File

@ -0,0 +1,145 @@
/* aztec.c - Handles Aztec Mesa 2D Symbols */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#define UPPER 1
#define LOWER 2
#define MIXED 4
#define PUNC 8
#define DIGIT 16
#define BINARY 32
static const unsigned short int CompactAztecMap[] = {
/* 27 x 27 data grid */
609, 608, 411, 413, 415, 417, 419, 421, 423, 425, 427, 429, 431, 433, 435, 437, 439, 441, 443, 445, 447, 449, 451, 453, 455, 457, 459,
607, 606, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458,
605, 604, 409, 408, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 460, 461,
603, 602, 407, 406, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 462, 463,
601, 600, 405, 404, 241, 240, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 284, 285, 464, 465,
599, 598, 403, 402, 239, 238, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 286, 287, 466, 467,
597, 596, 401, 400, 237, 236, 105, 104, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 140, 141, 288, 289, 468, 469,
595, 594, 399, 398, 235, 234, 103, 102, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 142, 143, 290, 291, 470, 471,
593, 592, 397, 396, 233, 232, 101, 100, 1, 1, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 0, 1, 28, 29, 144, 145, 292, 293, 472, 473,
591, 590, 395, 394, 231, 230, 99, 98, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 30, 31, 146, 147, 294, 295, 474, 475,
589, 588, 393, 392, 229, 228, 97, 96, 2027, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2007, 32, 33, 148, 149, 296, 297, 476, 477,
587, 586, 391, 390, 227, 226, 95, 94, 2026, 1, 0, 1, 1, 1, 1, 1, 0, 1, 2008, 34, 35, 150, 151, 298, 299, 478, 479,
585, 584, 389, 388, 225, 224, 93, 92, 2025, 1, 0, 1, 0, 0, 0, 1, 0, 1, 2009, 36, 37, 152, 153, 300, 301, 480, 481,
583, 582, 387, 386, 223, 222, 91, 90, 2024, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2010, 38, 39, 154, 155, 302, 303, 482, 483,
581, 580, 385, 384, 221, 220, 89, 88, 2023, 1, 0, 1, 0, 0, 0, 1, 0, 1, 2011, 40, 41, 156, 157, 304, 305, 484, 485,
579, 578, 383, 382, 219, 218, 87, 86, 2022, 1, 0, 1, 1, 1, 1, 1, 0, 1, 2012, 42, 43, 158, 159, 306, 307, 486, 487,
577, 576, 381, 380, 217, 216, 85, 84, 2021, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2013, 44, 45, 160, 161, 308, 309, 488, 489,
575, 574, 379, 378, 215, 214, 83, 82, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 47, 162, 163, 310, 311, 490, 491,
573, 572, 377, 376, 213, 212, 81, 80, 0, 0, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 0, 0, 48, 49, 164, 165, 312, 313, 492, 493,
571, 570, 375, 374, 211, 210, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 50, 51, 166, 167, 314, 315, 494, 495,
569, 568, 373, 372, 209, 208, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 52, 53, 168, 169, 316, 317, 496, 497,
567, 566, 371, 370, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 170, 171, 318, 319, 498, 499,
565, 564, 369, 368, 207, 205, 203, 201, 199, 197, 195, 193, 191, 189, 187, 185, 183, 181, 179, 177, 175, 172, 173, 320, 321, 500, 501,
563, 562, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 322, 323, 502, 503,
561, 560, 367, 365, 363, 361, 359, 357, 355, 353, 351, 349, 347, 345, 343, 341, 339, 337, 335, 333, 331, 329, 327, 324, 325, 504, 505,
558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 506, 507,
559, 557, 555, 553, 551, 549, 547, 545, 543, 541, 539, 537, 535, 533, 531, 529, 527, 525, 523, 521, 519, 517, 515, 513, 511, 508, 509
};
static const char AztecSymbolChar[128] = {
/* From Table 2 */
0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 15, 16, 17, 18, 19, 1, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 0, 18, 0, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 21, 22,
23, 24, 25, 26, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 27, 21, 28, 22, 23, 24, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 29, 25, 30, 26, 27
};
static const char AztecModes[129] = "BMMMMMMMMMMMMXBBBBBBBBBBBBBMMMMMXPPPPPPPPPPPXPXPDDDDDDDDDDPPPPPPMUUUUUUUUUUUUUUUUUUUUUUUUUUPMPMMMLLLLLLLLLLLLLLLLLLLLLLLLLLPMPMM";
static const unsigned short int AztecSizes[32] = {
/* Codewords per symbol */
21, 48, 60, 88, 120, 156, 196, 240, 230, 272, 316, 364, 416, 470, 528, 588, 652, 720, 790,
864, 940, 1020, 920, 992, 1066, 1144, 1224, 1306, 1392, 1480, 1570, 1664
};
static const int AztecCompactSizes[4] = {
17, 40, 51, 76
};
static const unsigned short int Aztec10DataSizes[32] = {
/* Data bits per symbol maximum with 10% error correction */
96, 246, 408, 616, 840, 1104, 1392, 1704, 2040, 2420, 2820, 3250, 3720, 4200, 4730,
5270, 5840, 6450, 7080, 7750, 8430, 9150, 9900, 10680, 11484, 12324, 13188, 14076,
15000, 15948, 16920, 17940
};
static const unsigned short int Aztec23DataSizes[32] = {
/* Data bits per symbol maximum with 23% error correction */
84, 204, 352, 520, 720, 944, 1184, 1456, 1750, 2070, 2410, 2780, 3180, 3590, 4040,
4500, 5000, 5520, 6060, 6630, 7210, 7830, 8472, 9132, 9816, 10536, 11280, 12036,
12828, 13644, 14472, 15348
};
static const unsigned short int Aztec36DataSizes[32] = {
/* Data bits per symbol maximum with 36% error correction */
66, 168, 288, 432, 592, 776, 984, 1208, 1450, 1720, 2000, 2300, 2640, 2980, 3350,
3740, 4150, 4580, 5030, 5500, 5990, 6500, 7032, 7584, 8160, 8760, 9372, 9996, 10656,
11340, 12024, 12744
};
static const unsigned short int Aztec50DataSizes[32] = {
/* Data bits per symbol maximum with 50% error correction */
48, 126, 216, 328, 456, 600, 760, 936, 1120, 1330, 1550, 1790, 2050, 2320, 2610,
2910, 3230, 3570, 3920, 4290, 4670, 5070, 5484, 5916, 6360, 6828, 7308, 7800, 8316,
8844, 9384, 9948
};
static const unsigned short int AztecCompact10DataSizes [4] = {
78, 198, 336, 520
};
static const unsigned short int AztecCompact23DataSizes [4] = {
66, 168, 288, 440
};
static const unsigned short int AztecCompact36DataSizes [4] = {
48, 138, 232, 360
};
static const unsigned short int AztecCompact50DataSizes [4] = {
36, 102, 176, 280
};
static const char AztecOffset[32] = {
66, 64, 62, 60, 57, 55, 53, 51, 49, 47, 45, 42, 40, 38, 36, 34, 32, 30, 28, 25, 23, 21,
19, 17, 15, 13, 10, 8, 6, 4, 2, 0
};
static const char AztecCompactOffset[4] = {
6, 4, 2, 0
};

147
3rdparty/zint-2.6.1/backend/bmp.c vendored Normal file
View File

@ -0,0 +1,147 @@
/* bmp.c - Handles output to Windows Bitmap file */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "bmp.h" /* Bitmap header structure */
#include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#endif
#define SSET "0123456789ABCDEF"
int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
int i, row, column;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
int row_size;
unsigned int data_size;
unsigned char *bitmap_file_start, *bmp_posn;
char *bitmap;
FILE *bmp_file;
bitmap_file_header_t file_header;
bitmap_info_header_t info_header;
if (symbol->bitmap != NULL)
free(symbol->bitmap);
row_size = 4 * floor((24.0 * symbol->bitmap_width + 31) / 32);
bitmap = (char *) malloc(row_size * symbol->bitmap_height);
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
/* Pixel Plotting */
i = 0;
for (row = 0; row < symbol->bitmap_height; row++) {
for (column = 0; column < symbol->bitmap_width; column++) {
i = (3 * column) + (row * row_size);
switch (*(pixelbuf + (symbol->bitmap_width * (symbol->bitmap_height - row - 1)) + column)) {
case '1':
bitmap[i] = fgblu;
bitmap[i + 1] = fggrn;
bitmap[i + 2] = fgred;
break;
default:
bitmap[i] = bgblu;
bitmap[i + 1] = bggrn;
bitmap[i + 2] = bgred;
break;
}
}
}
data_size = symbol->bitmap_height * row_size;
symbol->bitmap_byte_length = data_size;
file_header.header_field = 0x4d42; // "BM"
file_header.file_size = sizeof (bitmap_file_header_t) + sizeof (bitmap_info_header_t) + data_size;
file_header.reserved = 0;
file_header.data_offset = sizeof (bitmap_file_header_t) + sizeof (bitmap_info_header_t);
info_header.header_size = sizeof (bitmap_info_header_t);
info_header.width = symbol->bitmap_width;
info_header.height = symbol->bitmap_height;
info_header.colour_planes = 1;
info_header.bits_per_pixel = 24;
info_header.compression_method = 0; // BI_RGB
info_header.image_size = 0;
info_header.horiz_res = 0;
info_header.vert_res = 0;
info_header.colours = 0;
info_header.important_colours = 0;
bitmap_file_start = (unsigned char*) malloc(file_header.file_size);
memset(bitmap_file_start, 0xff, file_header.file_size);
bmp_posn = bitmap_file_start;
memcpy(bitmap_file_start, &file_header, sizeof (bitmap_file_header_t));
bmp_posn += sizeof (bitmap_file_header_t);
memcpy(bmp_posn, &info_header, sizeof (bitmap_info_header_t));
bmp_posn += sizeof (bitmap_info_header_t);
memcpy(bmp_posn, bitmap, data_size);
/* Open output file in binary mode */
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "600: Can't open output file");
free(bitmap_file_start);
free(bitmap);
return ZINT_ERROR_FILE_ACCESS;
}
#endif
bmp_file = stdout;
} else {
if (!(bmp_file = fopen(symbol->outfile, "wb"))) {
free(bitmap_file_start);
free(bitmap);
strcpy(symbol->errtxt, "601: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
}
fwrite(bitmap_file_start, file_header.file_size, 1, bmp_file);
fclose(bmp_file);
free(bitmap_file_start);
free(bitmap);
return 0;
}

76
3rdparty/zint-2.6.1/backend/bmp.h vendored Normal file
View File

@ -0,0 +1,76 @@
/* bmp.h - header structure for Windows bitmap files
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef BMP_H
#define BMP_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
#pragma pack (1)
typedef struct bitmap_file_header {
uint16_t header_field;
uint32_t file_size;
uint32_t reserved;
uint32_t data_offset;
} bitmap_file_header_t;
typedef struct bitmap_info_header {
uint32_t header_size;
int32_t width;
int32_t height;
uint16_t colour_planes;
uint16_t bits_per_pixel;
uint32_t compression_method;
uint32_t image_size;
int32_t horiz_res;
int32_t vert_res;
uint32_t colours;
uint32_t important_colours;
} bitmap_info_header_t;
#pragma pack ()
#ifdef __cplusplus
}
#endif
#endif /* BMP_H */

1008
3rdparty/zint-2.6.1/backend/codablock.c vendored Normal file

File diff suppressed because it is too large Load Diff

591
3rdparty/zint-2.6.1/backend/code.c vendored Normal file
View File

@ -0,0 +1,591 @@
/* code.c - Handles Code 11, 39, 39+ and 93 */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* In version 0.5 this file was 1,553 lines long! */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#define SODIUM "0123456789-"
#define SILVER "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd"
static const char *C11Table[11] = {
"111121", "211121", "121121", "221111", "112121", "212111", "122111",
"111221", "211211", "211111", "112111"
};
/* Code 39 tables checked against ISO/IEC 16388:2007 */
/* Incorporates Table A1 */
static const char *C39Table[43] = {
/* Code 39 character assignments (Table 1) */
"1112212111", "2112111121", "1122111121", "2122111111", "1112211121",
"2112211111", "1122211111", "1112112121", "2112112111", "1122112111", "2111121121",
"1121121121", "2121121111", "1111221121", "2111221111", "1121221111", "1111122121",
"2111122111", "1121122111", "1111222111", "2111111221", "1121111221", "2121111211",
"1111211221", "2111211211", "1121211211", "1111112221", "2111112211", "1121112211",
"1111212211", "2211111121", "1221111121", "2221111111", "1211211121", "2211211111",
"1221211111", "1211112121", "2211112111", "1221112111", "1212121111", "1212111211",
"1211121211", "1112121211"
};
static const char *EC39Ctrl[128] = {
/* Encoding the full ASCII character set in Code 39 (Table A2) */
"%U", "$A", "$B", "$C", "$D", "$E", "$F", "$G", "$H", "$I", "$J", "$K",
"$L", "$M", "$N", "$O", "$P", "$Q", "$R", "$S", "$T", "$U", "$V", "$W", "$X", "$Y", "$Z",
"%A", "%B", "%C", "%D", "%E", " ", "/A", "/B", "/C", "/D", "/E", "/F", "/G", "/H", "/I", "/J",
"/K", "/L", "-", ".", "/O", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "/Z", "%F",
"%G", "%H", "%I", "%J", "%V", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "%K", "%L", "%M", "%N", "%O",
"%W", "+A", "+B", "+C", "+D", "+E", "+F", "+G", "+H", "+I", "+J", "+K", "+L", "+M", "+N", "+O",
"+P", "+Q", "+R", "+S", "+T", "+U", "+V", "+W", "+X", "+Y", "+Z", "%P", "%Q", "%R", "%S", "%T"
};
static const char *C93Ctrl[128] = {
"bU", "aA", "aB", "aC", "aD", "aE", "aF", "aG", "aH", "aI", "aJ", "aK",
"aL", "aM", "aN", "aO", "aP", "aQ", "aR", "aS", "aT", "aU", "aV", "aW", "aX", "aY", "aZ",
"bA", "bB", "bC", "bD", "bE", " ", "cA", "cB", "cC", "$", "%", "cF", "cG", "cH", "cI", "cJ",
"+", "cL", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "cZ", "bF",
"bG", "bH", "bI", "bJ", "bV", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bK", "bL", "bM", "bN", "bO",
"bW", "dA", "dB", "dC", "dD", "dE", "dF", "dG", "dH", "dI", "dJ", "dK", "dL", "dM", "dN", "dO",
"dP", "dQ", "dR", "dS", "dT", "dU", "dV", "dW", "dX", "dY", "dZ", "bP", "bQ", "bR", "bS", "bT"
};
static const char *C93Table[47] = {
"131112", "111213", "111312", "111411", "121113", "121212", "121311",
"111114", "131211", "141111", "211113", "211212", "211311", "221112", "221211", "231111",
"112113", "112212", "112311", "122112", "132111", "111123", "111222", "111321", "121122",
"131121", "212112", "212211", "211122", "211221", "221121", "222111", "112122", "112221",
"122121", "123111", "121131", "311112", "311211", "321111", "112131", "113121", "211131",
"121221", "312111", "311121", "122211"
};
/* Global Variables for Channel Code */
int S[11], B[11];
long value;
long target_value;
char pattern[30];
/* Function Prototypes */
void NextS(int Chan, int i, int MaxS, int MaxB);
void NextB(int Chan, int i, int MaxB, int MaxS);
/* *********************** CODE 11 ******************** */
int code_11(struct zint_symbol *symbol, unsigned char source[], int length) { /* Code 11 */
unsigned int i;
int h, c_digit, c_weight, c_count, k_digit, k_weight, k_count;
int weight[128], error_number;
char dest[1024]; /* 6 + 121 * 6 + 2 * 6 + 5 + 1 ~ 1024*/
char checkstr[3];
if (length > 121) {
strcpy(symbol->errtxt, "320: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SODIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "321: Invalid characters in data");
return error_number;
}
c_weight = 1;
c_count = 0;
k_weight = 1;
k_count = 0;
/* start character */
strcpy(dest, "112211");
/* Draw main body of barcode */
for (i = 0; i < (unsigned int) length; i++) {
lookup(SODIUM, C11Table, source[i], dest);
if (source[i] == '-')
weight[i] = 10;
else
weight[i] = ctoi(source[i]);
}
/* Calculate C checksum */
for (h = length - 1; h >= 0; h--) {
c_count += (c_weight * weight[h]);
c_weight++;
if (c_weight > 10) {
c_weight = 1;
}
}
c_digit = c_count % 11;
weight[length] = c_digit;
/* Calculate K checksum */
for (h = length; h >= 0; h--) {
k_count += (k_weight * weight[h]);
k_weight++;
if (k_weight > 9) {
k_weight = 1;
}
}
k_digit = k_count % 11;
checkstr[0] = itoc(c_digit);
checkstr[1] = itoc(k_digit);
if (checkstr[0] == 'A') {
checkstr[0] = '-';
}
if (checkstr[1] == 'A') {
checkstr[1] = '-';
}
checkstr[2] = '\0';
lookup(SODIUM, C11Table, checkstr[0], dest);
lookup(SODIUM, C11Table, checkstr[1], dest);
/* Stop character */
strcat(dest, "11221");
expand(symbol, dest);
ustrcpy(symbol->text, source);
strcat((char*) symbol->text, checkstr);
return error_number;
}
/* Code 39 */
int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
unsigned int i;
unsigned int counter;
char check_digit;
int error_number;
char dest[775];
char localstr[2] = {0};
counter = 0;
if ((symbol->option_2 < 0) || (symbol->option_2 > 1)) {
symbol->option_2 = 0;
}
if ((symbol->symbology == BARCODE_LOGMARS) && (length > 59)) {
strcpy(symbol->errtxt, "322: Input too long");
return ZINT_ERROR_TOO_LONG;
} else if (length > 74) {
strcpy(symbol->errtxt, "323: Input too long");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(SILVER, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "324: Invalid characters in data");
return error_number;
}
/* Start character */
strcpy(dest, "1211212111");
for (i = 0; i < (unsigned int) length; i++) {
lookup(SILVER, C39Table, source[i], dest);
counter += posn(SILVER, source[i]);
}
if ((symbol->symbology == BARCODE_LOGMARS) || (symbol->option_2 == 1)) {
counter = counter % 43;
if (counter < 10) {
check_digit = itoc(counter);
} else {
if (counter < 36) {
check_digit = (counter - 10) + 'A';
} else {
switch (counter) {
case 36: check_digit = '-';
break;
case 37: check_digit = '.';
break;
case 38: check_digit = ' ';
break;
case 39: check_digit = '$';
break;
case 40: check_digit = '/';
break;
case 41: check_digit = '+';
break;
case 42: check_digit = 37;
break;
default: check_digit = ' ';
break; /* Keep compiler happy */
}
}
}
lookup(SILVER, C39Table, check_digit, dest);
/* Display a space check digit as _, otherwise it looks like an error */
if (check_digit == ' ') {
check_digit = '_';
}
localstr[0] = check_digit;
localstr[1] = '\0';
}
/* Stop character */
strcat(dest, "121121211");
if ((symbol->symbology == BARCODE_LOGMARS) || (symbol->symbology == BARCODE_HIBC_39)) {
/* LOGMARS uses wider 'wide' bars than normal Code 39 */
counter = (unsigned int) strlen(dest);
for (i = 0; i < counter; i++) {
if (dest[i] == '2') {
dest[i] = '3';
}
}
}
expand(symbol, dest);
if (symbol->symbology == BARCODE_CODE39) {
strcpy((char*) symbol->text, "*");
strcat((char*) symbol->text, (char*) source);
strcat((char*) symbol->text, localstr);
strcat((char*) symbol->text, "*");
} else {
strcpy((char*) symbol->text, (char*) source);
strcat((char*) symbol->text, localstr);
}
return error_number;
}
/* Pharmazentral Nummer (PZN) */
int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number, zeroes;
unsigned int count, check_digit;
char localstr[11];
count = 0;
if (length > 7) {
strcpy(symbol->errtxt, "325: Input wrong length");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "326: Invalid characters in data");
return error_number;
}
localstr[0] = '-';
zeroes = 7 - length + 1;
for (i = 1; i < zeroes; i++)
localstr[i] = '0';
strcpy(localstr + zeroes, (char *) source);
for (i = 1; i < 8; i++) {
count += i * ctoi(localstr[i]);
}
check_digit = count % 11;
if (check_digit == 11) {
check_digit = 0;
}
localstr[8] = itoc(check_digit);
localstr[9] = '\0';
if (localstr[8] == 'A') {
strcpy(symbol->errtxt, "327: Invalid PZN Data");
return ZINT_ERROR_INVALID_DATA;
}
error_number = c39(symbol, (unsigned char *) localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char *) "PZN");
strcat((char*) symbol->text, localstr);
return error_number;
}
/* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
unsigned char buffer[150] = {0};
unsigned int i;
int error_number;
if (length > 74) {
strcpy(symbol->errtxt, "328: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Creates a buffer string and places control characters into it */
for (i = 0; i < (unsigned int) length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "329: Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
strcat((char*) buffer, EC39Ctrl[source[i]]);
}
/* Then sends the buffer to the C39 function */
error_number = c39(symbol, buffer, ustrlen(buffer));
for (i = 0; i < (unsigned int) length; i++)
symbol->text[i] = source[i] ? source[i] : ' ';
symbol->text[length] = '\0';
return error_number;
}
/* Code 93 is an advancement on Code 39 and the definition is a lot tighter */
int c93(struct zint_symbol *symbol, unsigned char source[], int length) {
/* SILVER includes the extra characters a, b, c and d to represent Code 93 specific
shift characters 1, 2, 3 and 4 respectively. These characters are never used by
c39() and ec39() */
int i;
int h, weight, c, k, values[128], error_number;
char buffer[220];
char dest[670];
char set_copy[] = SILVER;
error_number = 0;
strcpy(buffer, "");
if (length > 107) {
strcpy(symbol->errtxt, "330: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Message Content */
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "331: Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
strcat(buffer, C93Ctrl[source[i]]);
symbol->text[i] = source[i] ? source[i] : ' ';
}
/* Now we can check the true length of the barcode */
h = (int) strlen(buffer);
if (h > 107) {
strcpy(symbol->errtxt, "332: Input too long");
return ZINT_ERROR_TOO_LONG;
}
for (i = 0; i < h; i++) {
values[i] = posn(SILVER, buffer[i]);
}
/* Putting the data into dest[] is not done until after check digits are calculated */
/* Check digit C */
c = 0;
weight = 1;
for (i = h - 1; i >= 0; i--) {
c += values[i] * weight;
weight++;
if (weight == 21)
weight = 1;
}
c = c % 47;
values[h] = c;
buffer[h] = set_copy[c];
/* Check digit K */
k = 0;
weight = 1;
for (i = h; i >= 0; i--) {
k += values[i] * weight;
weight++;
if (weight == 16)
weight = 1;
}
k = k % 47;
buffer[++h] = set_copy[k];
buffer[++h] = '\0';
/* Start character */
strcpy(dest, "111141");
for (i = 0; i < h; i++) {
lookup(SILVER, C93Table, buffer[i], dest);
}
/* Stop character */
strcat(dest, "1111411");
expand(symbol, dest);
symbol->text[length] = set_copy[c];
symbol->text[length + 1] = set_copy[k];
symbol->text[length + 2] = '\0';
return error_number;
}
/* NextS() and NextB() are from ANSI/AIM BC12-1998 and are Copyright (c) AIM 1997 */
/* Their are used here on the understanding that they form part of the specification
for Channel Code and therefore their use is permitted under the following terms
set out in that document:
"It is the intent and understanding of AIM [t]hat the symbology presented in this
specification is entirely in the public domain and free of all use restrictions,
licenses and fees. AIM USA, its memer companies, or individual officers
assume no liability for the use of this document." */
void CheckCharacter() {
int i;
char part[3];
if (value == target_value) {
/* Target reached - save the generated pattern */
strcpy(pattern, "11110");
for (i = 0; i < 11; i++) {
part[0] = itoc(S[i]);
part[1] = itoc(B[i]);
part[2] = '\0';
strcat(pattern, part);
}
}
}
void NextB(int Chan, int i, int MaxB, int MaxS) {
int b;
b = (S[i] + B[i - 1] + S[i - 1] + B[i - 2] > 4) ? 1 : 2;
if (i < Chan + 2) {
for (; b <= MaxB; b++) {
B[i] = b;
NextS(Chan, i + 1, MaxS, MaxB + 1 - b);
}
} else if (b <= MaxB) {
B[i] = MaxB;
CheckCharacter();
value++;
}
}
void NextS(int Chan, int i, int MaxS, int MaxB) {
int s;
for (s = (i < Chan + 2) ? 1 : MaxS; s <= MaxS; s++) {
S[i] = s;
NextB(Chan, i, MaxB, MaxS + 1 - s);
}
}
/* Channel Code - According to ANSI/AIM BC12-1998 */
int channel_code(struct zint_symbol *symbol, unsigned char source[], int length) {
int channels, i;
int error_number = 0, range = 0, zeroes;
char hrt[9];
target_value = 0;
if (length > 7) {
strcpy(symbol->errtxt, "333: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "334: Invalid characters in data");
return error_number;
}
if ((symbol->option_2 < 3) || (symbol->option_2 > 8)) {
channels = 0;
} else {
channels = symbol->option_2;
}
if (channels == 0) {
channels = length + 1;
}
if (channels == 2) {
channels = 3;
}
for (i = 0; i < length; i++) {
target_value *= 10;
target_value += ctoi((char) source[i]);
}
switch (channels) {
case 3: if (target_value > 26) {
range = 1;
}
break;
case 4: if (target_value > 292) {
range = 1;
}
break;
case 5: if (target_value > 3493) {
range = 1;
}
break;
case 6: if (target_value > 44072) {
range = 1;
}
break;
case 7: if (target_value > 576688) {
range = 1;
}
break;
case 8: if (target_value > 7742862) {
range = 1;
}
break;
}
if (range) {
strcpy(symbol->errtxt, "335: Value out of range");
return ZINT_ERROR_INVALID_DATA;
}
for (i = 0; i < 11; i++) {
B[i] = 0;
S[i] = 0;
}
B[0] = S[1] = B[1] = S[2] = B[2] = 1;
value = 0;
NextS(channels, 3, channels, channels);
zeroes = channels - 1 - length;
memset(hrt, '0', zeroes);
strcpy(hrt + zeroes, (char *) source);
ustrcpy(symbol->text, (unsigned char *) hrt);
expand(symbol, pattern);
return error_number;
}

1765
3rdparty/zint-2.6.1/backend/code1.c vendored Normal file

File diff suppressed because it is too large Load Diff

102
3rdparty/zint-2.6.1/backend/code1.h vendored Normal file
View File

@ -0,0 +1,102 @@
/* code1.h - Lookup info for USS Code One */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
static const char c40_shift[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};
static const char c40_value[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
15, 16, 17, 18, 19, 20, 21, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
};
static const char text_shift[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3
};
static const char text_value[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
15, 16, 17, 18, 19, 20, 21, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
22, 23, 24, 25, 26, 0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 27, 28, 29, 30, 31
};
static const unsigned short int c1_height[] = {
16, 22, 28, 40, 52, 70, 104, 148
};
static const unsigned short int c1_width[] = {
18, 22, 32, 42, 54, 76, 98, 134
};
static const unsigned short int c1_data_length[] = {
10, 19, 44, 91, 182, 370, 732, 1480
};
static const unsigned short int c1_ecc_length[] = {
10, 16, 26, 44, 70, 140, 280, 560
};
static const unsigned short int c1_blocks[] = {
1, 1, 1, 1, 1, 2, 4, 8
};
static const unsigned short int c1_data_blocks[] = {
10, 19, 44, 91, 182, 185, 183, 185
};
static const unsigned short int c1_ecc_blocks[] = {
10, 16, 26, 44, 70, 70, 70, 70
};
static const unsigned short int c1_grid_width[] = {
4, 5, 7, 9, 12, 17, 22, 30
};
static const unsigned short int c1_grid_height[] = {
5, 7, 10, 15, 21, 30, 46, 68
};
#define C1_ASCII 1
#define C1_C40 2
#define C1_DECIMAL 3
#define C1_TEXT 4
#define C1_EDI 5
#define C1_BYTE 6

1088
3rdparty/zint-2.6.1/backend/code128.c vendored Normal file

File diff suppressed because it is too large Load Diff

733
3rdparty/zint-2.6.1/backend/code16k.c vendored Normal file
View File

@ -0,0 +1,733 @@
/* code16k.c - Handles Code 16k stacked symbology */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* Updated to comply with BS EN 12323:2005 */
/* Code 16k can hold up to 77 characters or 154 numbers */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#define TRUE 1
#define FALSE 0
#define SHIFTA 90
#define LATCHA 91
#define SHIFTB 92
#define LATCHB 93
#define SHIFTC 94
#define LATCHC 95
#define AORB 96
#define ABORC 97
#define CANDB 98
#define CANDBB 99
extern int parunmodd(const unsigned char llyth);
static int list[2][170];
static const char *C16KTable[107] = {
/* EN 12323 Table 1 - "Code 16K" character encodations */
"212222", "222122", "222221", "121223", "121322", "131222", "122213",
"122312", "132212", "221213", "221312", "231212", "112232", "122132", "122231", "113222",
"123122", "123221", "223211", "221132", "221231", "213212", "223112", "312131", "311222",
"321122", "321221", "312212", "322112", "322211", "212123", "212321", "232121", "111323",
"131123", "131321", "112313", "132113", "132311", "211313", "231113", "231311", "112133",
"112331", "132131", "113123", "113321", "133121", "313121", "211331", "231131", "213113",
"213311", "213131", "311123", "311321", "331121", "312113", "312311", "332111", "314111",
"221411", "431111", "111224", "111422", "121124", "121421", "141122", "141221", "112214",
"112412", "122114", "122411", "142112", "142211", "241211", "221114", "413111", "241112",
"134111", "111242", "121142", "121241", "114212", "124112", "124211", "411212", "421112",
"421211", "212141", "214121", "412121", "111143", "111341", "131141", "114113", "114311",
"411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232",
"211133"
};
static const char *C16KStartStop[8] = {
/* EN 12323 Table 3 and Table 4 - Start patterns and stop patterns */
"3211", "2221", "2122", "1411", "1132", "1231", "1114", "3112"
};
/* EN 12323 Table 5 - Start and stop values defining row numbers */
static const int C16KStartValues[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7
};
static const int C16KStopValues[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3
};
static void grwp16(unsigned int *indexliste) {
int i, j;
/* bring together same type blocks */
if (*(indexliste) > 1) {
i = 1;
while(i < (int)*(indexliste)) {
if (list[1][i - 1] == list[1][i]) {
/* bring together */
list[0][i - 1] = list[0][i - 1] + list[0][i];
j = i + 1;
/* decreace the list */
while(j < (int)*(indexliste)) {
list[0][j - 1] = list[0][j];
list[1][j - 1] = list[1][j];
j++;
}
*(indexliste) = *(indexliste) - 1;
i--;
}
i++;
}
}
}
/* Implements rules from ISO 15417 Annex E */
static void dxsmooth16(unsigned int *indexliste) {
int i, current, last, next, length;
for(i = 0; i < (int)*(indexliste); i++) {
current = list[1][i];
length = list[0][i];
if (i != 0) {
last = list[1][i - 1];
} else {
last = FALSE;
}
if (i != *(indexliste) - 1) {
next = list[1][i + 1];
} else {
next = FALSE;
}
if (i == 0) {
/* first block */
if ((*(indexliste) == 1) && ((length == 2) && (current == ABORC))) {
/* Rule 1a */
list[1][i] = LATCHC;
}
if (current == ABORC) {
if (length >= 4) {
/* Rule 1b */
list[1][i] = LATCHC;
} else {
list[1][i] = AORB;
current = AORB;
}
}
if (current == SHIFTA) {
/* Rule 1c */
list[1][i] = LATCHA;
}
if ((current == AORB) && (next == SHIFTA)) {
/* Rule 1c */
list[1][i] = LATCHA;
current = LATCHA;
}
if (current == AORB) {
/* Rule 1d */
list[1][i] = LATCHB;
}
} else {
if ((current == ABORC) && (length >= 4)) {
/* Rule 3 */
list[1][i] = LATCHC;
current = LATCHC;
}
if (current == ABORC) {
list[1][i] = AORB;
current = AORB;
}
if ((current == AORB) && (last == LATCHA)) {
list[1][i] = LATCHA;
current = LATCHA;
}
if ((current == AORB) && (last == LATCHB)) {
list[1][i] = LATCHB;
current = LATCHB;
}
if ((current == AORB) && (next == SHIFTA)) {
list[1][i] = LATCHA;
current = LATCHA;
}
if ((current == AORB) && (next == SHIFTB)) {
list[1][i] = LATCHB;
current = LATCHB;
}
if (current == AORB) {
list[1][i] = LATCHB;
current = LATCHB;
}
if ((current == SHIFTA) && (length > 1)) {
/* Rule 4 */
list[1][i] = LATCHA;
current = LATCHA;
}
if ((current == SHIFTB) && (length > 1)) {
/* Rule 5 */
list[1][i] = LATCHB;
current = LATCHB;
}
if ((current == SHIFTA) && (last == LATCHA)) {
list[1][i] = LATCHA;
current = LATCHA;
}
if ((current == SHIFTB) && (last == LATCHB)) {
list[1][i] = LATCHB;
current = LATCHB;
}
if ((current == SHIFTA) && (last == LATCHC)) {
list[1][i] = LATCHA;
current = LATCHA;
}
if ((current == SHIFTB) && (last == LATCHC)) {
list[1][i] = LATCHB;
current = LATCHB;
}
} /* Rule 2 is implimented elsewhere, Rule 6 is implied */
}
grwp16(indexliste);
}
static void c16k_set_a(const unsigned char source, unsigned int values[], unsigned int *bar_chars) {
if (source > 127) {
if (source < 160) {
values[(*bar_chars)] = source + 64 - 128;
} else {
values[(*bar_chars)] = source - 32 - 128;
}
} else {
if (source < 32) {
values[(*bar_chars)] = source + 64;
} else {
values[(*bar_chars)] = source - 32;
}
}
(*bar_chars)++;
}
static void c16k_set_b(const unsigned char source, unsigned int values[], unsigned int *bar_chars) {
if (source > 127) {
values[(*bar_chars)] = source - 32 - 128;
} else {
values[(*bar_chars)] = source - 32;
}
(*bar_chars)++;
}
static void c16k_set_c(const unsigned char source_a, unsigned char source_b, unsigned int values[], unsigned int *bar_chars) {
int weight;
weight = (10 * ctoi(source_a)) + ctoi(source_b);
values[(*bar_chars)] = weight;
(*bar_chars)++;
}
int code16k(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
char width_pattern[100];
int current_row, rows_needed, flip_flop, looper, first_check, second_check;
int indexchaine, f_state;
char set[160] = {' '}, fset[160] = {' '}, mode, last_set, current_set;
unsigned int pads_needed, indexliste, i, j, k, m, read, mx_reader, writer;
unsigned int values[160] = {0};
unsigned int bar_characters;
float glyph_count;
int errornum, first_sum, second_sum;
size_t input_length;
int gs1, c_count;
errornum = 0;
strcpy(width_pattern, "");
input_length = length;
if (symbol->input_mode == GS1_MODE) {
gs1 = 1;
} else {
gs1 = 0;
}
if (input_length > 157) {
strcpy(symbol->errtxt, "420: Input too long");
return ZINT_ERROR_TOO_LONG;
}
bar_characters = 0;
/* Detect extended ASCII characters */
for (i = 0; i < (unsigned int) input_length; i++) {
if (source[i] >= 128) {
fset[i] = 'f';
}
}
fset[i] = '\0';
/* Decide when to latch to extended mode */
for (i = 0; i < (unsigned int) input_length; i++) {
j = 0;
if (fset[i] == 'f') {
do {
j++;
} while (fset[i + j] == 'f');
if ((j >= 5) || ((j >= 3) && ((i + j) == (input_length - 1)))) {
for (k = 0; k <= j; k++) {
fset[i + k] = 'F';
}
}
}
}
/* Decide if it is worth reverting to 646 encodation for a few characters */
if (input_length > 1) {
for (i = 1; i < (unsigned int) input_length; i++) {
if ((fset[i - 1] == 'F') && (fset[i] == ' ')) {
/* Detected a change from 8859-1 to 646 - count how long for */
for (j = 0; (fset[i + j] == ' ') && ((i + j) < (unsigned int) input_length); j++);
if ((j < 5) || ((j < 3) && ((i + j) == (input_length - 1)))) {
/* Change to shifting back rather than latching back */
for (k = 0; k < j; k++) {
fset[i + k] = 'n';
}
}
}
}
}
/* Detect mode A, B and C characters */
indexliste = 0;
indexchaine = 0;
mode = parunmodd(source[indexchaine]);
if ((gs1) && (source[indexchaine] == '[')) {
mode = ABORC;
} /* FNC1 */
for (i = 0; i < 160; i++) {
list[0][i] = 0;
}
do {
list[1][indexliste] = mode;
while ((list[1][indexliste] == mode) && (indexchaine < input_length)) {
list[0][indexliste]++;
indexchaine++;
mode = parunmodd(source[indexchaine]);
if ((gs1) && (source[indexchaine] == '[')) {
mode = ABORC;
} /* FNC1 */
}
indexliste++;
} while (indexchaine < input_length);
dxsmooth16(&indexliste);
/* Put set data into set[] */
read = 0;
for (i = 0; i < indexliste; i++) {
for (j = 0; j < list[0][i]; j++) {
switch (list[1][i]) {
case SHIFTA: set[read] = 'a';
break;
case LATCHA: set[read] = 'A';
break;
case SHIFTB: set[read] = 'b';
break;
case LATCHB: set[read] = 'B';
break;
case LATCHC: set[read] = 'C';
break;
}
read++;
}
}
/* Adjust for strings which start with shift characters - make them latch instead */
if (set[0] == 'a') {
i = 0;
do {
set[i] = 'A';
i++;
} while (set[i] == 'a');
}
if (set[0] == 'b') {
i = 0;
do {
set[i] = 'B';
i++;
} while (set[i] == 'b');
}
/* Watch out for odd-length Mode C blocks */
c_count = 0;
for (i = 0; i < read; i++) {
if (set[i] == 'C') {
if (source[i] == '[') {
if (c_count & 1) {
if ((i - c_count) != 0) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
}
}
c_count = 0;
} else {
c_count++;
}
} else {
if (c_count & 1) {
if ((i - c_count) != 0) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
}
}
c_count = 0;
}
}
if (c_count & 1) {
if ((i - c_count) != 0) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
}
}
for (i = 1; i < read - 1; i++) {
if ((set[i] == 'C') && ((set[i - 1] == 'B') && (set[i + 1] == 'B'))) {
set[i] = 'B';
}
}
/* Make sure the data will fit in the symbol */
last_set = ' ';
glyph_count = 0.0;
for (i = 0; i < input_length; i++) {
if ((set[i] == 'a') || (set[i] == 'b')) {
glyph_count = glyph_count + 1.0;
}
if ((fset[i] == 'f') || (fset[i] == 'n')) {
glyph_count = glyph_count + 1.0;
}
if (((set[i] == 'A') || (set[i] == 'B')) || (set[i] == 'C')) {
if (set[i] != last_set) {
last_set = set[i];
glyph_count = glyph_count + 1.0;
}
}
if (i == 0) {
if ((set[i] == 'B') && (set[1] == 'C')) {
glyph_count = glyph_count - 1.0;
}
if ((set[i] == 'B') && (set[1] == 'B')) {
if (set[2] == 'C') {
glyph_count = glyph_count - 1.0;
}
}
if (fset[i] == 'F') {
glyph_count = glyph_count + 2.0;
}
} else {
if ((fset[i] == 'F') && (fset[i - 1] != 'F')) {
glyph_count = glyph_count + 2.0;
}
if ((fset[i] != 'F') && (fset[i - 1] == 'F')) {
glyph_count = glyph_count + 2.0;
}
}
if ((set[i] == 'C') && (!((gs1) && (source[i] == '[')))) {
glyph_count = glyph_count + 0.5;
} else {
glyph_count = glyph_count + 1.0;
}
}
if ((gs1) && (set[0] != 'A')) {
/* FNC1 can be integrated with mode character */
glyph_count--;
}
if (glyph_count > 77.0) {
strcpy(symbol->errtxt, "421: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Calculate how tall the symbol will be */
glyph_count = glyph_count + 2.0;
i = (int)glyph_count;
rows_needed = (i / 5);
if (i % 5 > 0) {
rows_needed++;
}
if (rows_needed == 1) {
rows_needed = 2;
}
/* start with the mode character - Table 2 */
m = 0;
switch (set[0]) {
case 'A': m = 0;
break;
case 'B': m = 1;
break;
case 'C': m = 2;
break;
}
if (symbol->output_options & READER_INIT) {
if (m == 2) {
m = 5;
}
if (gs1) {
strcpy(symbol->errtxt, "422: Cannot use both GS1 mode and Reader Initialisation");
return ZINT_ERROR_INVALID_OPTION;
} else {
if ((set[0] == 'B') && (set[1] == 'C')) {
m = 6;
}
}
values[bar_characters] = (7 * (rows_needed - 2)) + m; /* see 4.3.4.2 */
values[bar_characters + 1] = 96; /* FNC3 */
bar_characters += 2;
} else {
if (gs1) {
/* Integrate FNC1 */
switch (set[0]) {
case 'B': m = 3;
break;
case 'C': m = 4;
break;
}
} else {
if ((set[0] == 'B') && (set[1] == 'C')) {
m = 5;
}
if (((set[0] == 'B') && (set[1] == 'B')) && (set[2] == 'C')) {
m = 6;
}
}
values[bar_characters] = (7 * (rows_needed - 2)) + m; /* see 4.3.4.2 */
bar_characters++;
}
current_set = set[0];
f_state = 0;
/* f_state remembers if we are in Extended ASCII mode (value 1) or
in ISO/IEC 646 mode (value 0) */
if (fset[0] == 'F') {
switch (current_set) {
case 'A':
values[bar_characters] = 101;
values[bar_characters + 1] = 101;
break;
case 'B':
values[bar_characters] = 100;
values[bar_characters + 1] = 100;
break;
}
bar_characters += 2;
f_state = 1;
}
read = 0;
/* Encode the data */
do {
if ((read != 0) && (set[read] != set[read - 1])) {
/* Latch different code set */
switch (set[read]) {
case 'A':
values[bar_characters] = 101;
bar_characters++;
current_set = 'A';
break;
case 'B':
values[bar_characters] = 100;
bar_characters++;
current_set = 'B';
break;
case 'C':
if (!((read == 1) && (set[0] == 'B'))) {
/* Not Mode C/Shift B */
if (!((read == 2) && ((set[0] == 'B') && (set[1] == 'B')))) {
/* Not Mode C/Double Shift B */
values[bar_characters] = 99;
bar_characters++;
}
}
current_set = 'C';
break;
}
}
if (read != 0) {
if ((fset[read] == 'F') && (f_state == 0)) {
/* Latch beginning of extended mode */
switch (current_set) {
case 'A':
values[bar_characters] = 101;
values[bar_characters + 1] = 101;
break;
case 'B':
values[bar_characters] = 100;
values[bar_characters + 1] = 100;
break;
}
bar_characters += 2;
f_state = 1;
}
if ((fset[read] == ' ') && (f_state == 1)) {
/* Latch end of extended mode */
switch (current_set) {
case 'A':
values[bar_characters] = 101;
values[bar_characters + 1] = 101;
break;
case 'B':
values[bar_characters] = 100;
values[bar_characters + 1] = 100;
break;
}
bar_characters += 2;
f_state = 0;
}
}
if ((fset[i] == 'f') || (fset[i] == 'n')) {
/* Shift extended mode */
switch (current_set) {
case 'A':
values[bar_characters] = 101; /* FNC 4 */
break;
case 'B':
values[bar_characters] = 100; /* FNC 4 */
break;
}
bar_characters++;
}
if ((set[i] == 'a') || (set[i] == 'b')) {
/* Insert shift character */
values[bar_characters] = 98;
bar_characters++;
}
if (!((gs1) && (source[read] == '['))) {
switch (set[read]) { /* Encode data characters */
case 'A':
case 'a':
c16k_set_a(source[read], values, &bar_characters);
read++;
break;
case 'B':
case 'b':
c16k_set_b(source[read], values, &bar_characters);
read++;
break;
case 'C': c16k_set_c(source[read], source[read + 1], values, &bar_characters);
read += 2;
break;
}
} else {
values[bar_characters] = 102;
bar_characters++;
read++;
}
} while (read < ustrlen(source));
pads_needed = 5 - ((bar_characters + 2) % 5);
if (pads_needed == 5) {
pads_needed = 0;
}
if ((bar_characters + pads_needed) < 8) {
pads_needed += 8 - (bar_characters + pads_needed);
}
for (i = 0; i < pads_needed; i++) {
values[bar_characters] = 106;
bar_characters++;
}
/* Calculate check digits */
first_sum = 0;
second_sum = 0;
for (i = 0; i < bar_characters; i++) {
first_sum += (i + 2) * values[i];
second_sum += (i + 1) * values[i];
}
first_check = first_sum % 107;
second_sum += first_check * (bar_characters + 1);
second_check = second_sum % 107;
values[bar_characters] = first_check;
values[bar_characters + 1] = second_check;
bar_characters += 2;
for (current_row = 0; current_row < rows_needed; current_row++) {
strcpy(width_pattern, "");
strcat(width_pattern, C16KStartStop[C16KStartValues[current_row]]);
strcat(width_pattern, "1");
for (i = 0; i < 5; i++) {
strcat(width_pattern, C16KTable[values[(current_row * 5) + i]]);
}
strcat(width_pattern, C16KStartStop[C16KStopValues[current_row]]);
/* Write the information into the symbol */
writer = 0;
flip_flop = 1;
for (mx_reader = 0; mx_reader < strlen(width_pattern); mx_reader++) {
for (looper = 0; looper < ctoi(width_pattern[mx_reader]); looper++) {
if (flip_flop == 1) {
set_module(symbol, current_row, writer);
writer++;
} else {
writer++;
}
}
if (flip_flop == 0) {
flip_flop = 1;
} else {
flip_flop = 0;
}
}
symbol->row_height[current_row] = 10;
}
symbol->rows = rows_needed;
symbol->width = 70;
return errornum;
}

345
3rdparty/zint-2.6.1/backend/code49.c vendored Normal file
View File

@ -0,0 +1,345 @@
/* code49.c - Handles Code 49 */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include "code49.h"
#define INSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%!&*"
/* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */
int code_49(struct zint_symbol *symbol, unsigned char source[], const int length) {
int i, j, rows, M, x_count, y_count, z_count, posn_val, local_value;
char intermediate[170] = "";
int codewords[170], codeword_count;
int c_grid[8][8]; /* Refers to table 3 */
int w_grid[8][4]; /* Refets to table 2 */
int pad_count = 0;
char pattern[80];
int gs1;
size_t h;
if (length > 81) {
strcpy(symbol->errtxt, "430: Input too long");
return ZINT_ERROR_TOO_LONG;
}
if (symbol->input_mode == GS1_MODE) {
gs1 = 1;
strcpy(intermediate, "*"); /* FNC1 */
} else {
gs1 = 0;
}
for (i = 0; i < length; i++) {
if (source[i] > 127) {
strcpy(symbol->errtxt, "431: Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
if (gs1 && (source[i] == '['))
strcat(intermediate, "*"); /* FNC1 */
else
strcat(intermediate, c49_table7[source[i]]);
}
codeword_count = 0;
i = 0;
h = strlen(intermediate);
do {
if ((intermediate[i] >= '0') && (intermediate[i] <= '9')) {
/* Numeric data */
for (j = 0; (intermediate[i + j] >= '0') && (intermediate[i + j] <= '9'); j++);
if (j >= 5) {
/* Use Numeric Encodation Method */
int block_count, c;
int block_remain;
int block_value;
codewords[codeword_count] = 48; /* Numeric Shift */
codeword_count++;
block_count = j / 5;
block_remain = j % 5;
for (c = 0; c < block_count; c++) {
if ((c == block_count - 1) && (block_remain == 2)) {
/* Rule (d) */
block_value = 100000;
block_value += ctoi(intermediate[i]) * 1000;
block_value += ctoi(intermediate[i + 1]) * 100;
block_value += ctoi(intermediate[i + 2]) * 10;
block_value += ctoi(intermediate[i + 3]);
codewords[codeword_count] = block_value / (48 * 48);
block_value = block_value - (48 * 48) * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 4;
block_value = ctoi(intermediate[i]) * 100;
block_value += ctoi(intermediate[i + 1]) * 10;
block_value += ctoi(intermediate[i + 2]);
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 3;
} else {
block_value = ctoi(intermediate[i]) * 10000;
block_value += ctoi(intermediate[i + 1]) * 1000;
block_value += ctoi(intermediate[i + 2]) * 100;
block_value += ctoi(intermediate[i + 3]) * 10;
block_value += ctoi(intermediate[i + 4]);
codewords[codeword_count] = block_value / (48 * 48);
block_value = block_value - (48 * 48) * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 5;
}
}
switch (block_remain) {
case 1:
/* Rule (a) */
codewords[codeword_count] = posn(INSET, intermediate[i]);
codeword_count++;
i++;
break;
case 3:
/* Rule (b) */
block_value = ctoi(intermediate[i]) * 100;
block_value += ctoi(intermediate[i + 1]) * 10;
block_value += ctoi(intermediate[i + 2]);
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 3;
break;
case 4:
/* Rule (c) */
block_value = 100000;
block_value += ctoi(intermediate[i]) * 1000;
block_value += ctoi(intermediate[i + 1]) * 100;
block_value += ctoi(intermediate[i + 2]) * 10;
block_value += ctoi(intermediate[i + 3]);
codewords[codeword_count] = block_value / (48 * 48);
block_value = block_value - (48 * 48) * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value / 48;
block_value = block_value - 48 * codewords[codeword_count];
codeword_count++;
codewords[codeword_count] = block_value;
codeword_count++;
i += 4;
break;
}
if (i < h) {
/* There is more to add */
codewords[codeword_count] = 48; /* Numeric Shift */
codeword_count++;
}
} else {
codewords[codeword_count] = posn(INSET, intermediate[i]);
codeword_count++;
i++;
}
} else {
codewords[codeword_count] = posn(INSET, intermediate[i]);
codeword_count++;
i++;
}
} while (i < h);
switch (codewords[0]) {
/* Set starting mode value */
case 48: M = 2;
break;
case 43: M = 4;
break;
case 44: M = 5;
break;
default: M = 0;
break;
}
if (M != 0) {
codeword_count--;
for (i = 0; i < codeword_count; i++) {
codewords[i] = codewords[i + 1];
}
}
if (codeword_count > 49) {
strcpy(symbol->errtxt, "432: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Place codewords in code character array (c grid) */
rows = 0;
do {
for (i = 0; i < 7; i++) {
if (((rows * 7) + i) < codeword_count) {
c_grid[rows][i] = codewords[(rows * 7) + i];
} else {
c_grid[rows][i] = 48; /* Pad */
pad_count++;
}
}
rows++;
} while ((rows * 7) < codeword_count);
if ((((rows <= 6) && (pad_count < 5))) || (rows > 6) || (rows == 1)) {
/* Add a row */
for (i = 0; i < 7; i++) {
c_grid[rows][i] = 48; /* Pad */
}
rows++;
}
/* Add row count and mode character */
c_grid[rows - 1][6] = (7 * (rows - 2)) + M;
/* Add row check character */
for (i = 0; i < rows - 1; i++) {
int row_sum = 0;
for (j = 0; j < 7; j++) {
row_sum += c_grid[i][j];
}
c_grid[i][7] = row_sum % 49;
}
/* Calculate Symbol Check Characters */
posn_val = 0;
x_count = c_grid[rows - 1][6] * 20;
y_count = c_grid[rows - 1][6] * 16;
z_count = c_grid[rows - 1][6] * 38;
for (i = 0; i < rows - 1; i++) {
for (j = 0; j < 4; j++) {
local_value = (c_grid[i][2 * j] * 49) + c_grid[i][(2 * j) + 1];
x_count += c49_x_weight[posn_val] * local_value;
y_count += c49_y_weight[posn_val] * local_value;
z_count += c49_z_weight[posn_val] * local_value;
posn_val++;
}
}
if (rows > 6) {
/* Add Z Symbol Check */
c_grid[rows - 1][0] = (z_count % 2401) / 49;
c_grid[rows - 1][1] = (z_count % 2401) % 49;
}
local_value = (c_grid[rows - 1][0] * 49) + c_grid[rows - 1][1];
x_count += c49_x_weight[posn_val] * local_value;
y_count += c49_y_weight[posn_val] * local_value;
posn_val++;
/* Add Y Symbol Check */
c_grid[rows - 1][2] = (y_count % 2401) / 49;
c_grid[rows - 1][3] = (y_count % 2401) % 49;
local_value = (c_grid[rows - 1][2] * 49) + c_grid[rows - 1][3];
x_count += c49_x_weight[posn_val] * local_value;
/* Add X Symbol Check */
c_grid[rows - 1][4] = (x_count % 2401) / 49;
c_grid[rows - 1][5] = (x_count % 2401) % 49;
/* Add last row check character */
j = 0;
for (i = 0; i < 7; i++) {
j += c_grid[rows - 1][i];
}
c_grid[rows - 1][7] = j % 49;
/* Transfer data to symbol character array (w grid) */
for (i = 0; i < rows; i++) {
for (j = 0; j < 4; j++) {
w_grid[i][j] = (c_grid[i][2 * j] * 49) + c_grid[i][(2 * j) + 1];
}
}
for (i = 0; i < rows; i++) {
strcpy(pattern, "10"); /* Start character */
for (j = 0; j < 4; j++) {
if (i != (rows - 1)) {
if (c49_table4[i][j] == 'E') {
/* Even Parity */
bin_append(c49_even_bitpattern[w_grid[i][j]], 16, pattern);
} else {
/* Odd Parity */
bin_append(c49_odd_bitpattern[w_grid[i][j]], 16, pattern);
}
} else {
/* Last row uses all even parity */
bin_append(c49_even_bitpattern[w_grid[i][j]], 16, pattern);
}
}
strcat(pattern, "1111"); /* Stop character */
/* Expand into symbol */
symbol->row_height[i] = 10;
for (j = 0; j < strlen(pattern); j++) {
if (pattern[j] == '1') {
set_module(symbol, i, j);
}
}
}
symbol->rows = rows;
symbol->width = strlen(pattern);
symbol->whitespace_width = 10;
if (!(symbol->output_options & BARCODE_BIND)) {
symbol->output_options += BARCODE_BIND;
}
symbol->border_width = 2;
return 0;
}

558
3rdparty/zint-2.6.1/backend/code49.h vendored Normal file
View File

@ -0,0 +1,558 @@
/* code49.h - Code 49 Tables */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* This data set taken from ANSI/AIM-BC6-2000, 4th April 2000 */
static const char *c49_table7[128] = {
/* Table 7: Code 49 ASCII Chart */
"! ", "!A", "!B", "!C", "!D", "!E", "!F", "!G", "!H", "!I", "!J", "!K", "!L",
"!M", "!N", "!O", "!P", "!Q", "!R", "!S", "!T", "!U", "!V", "!W", "!X", "!Y",
"!Z", "!1", "!2", "!3", "!4", "!5", " ", "!6", "!7", "!8", "$", "%", "!9", "!0",
"!-", "!.", "!$", "+", "!/", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "!+", "&1", "&2", "&3", "&4", "&5", "&6", "A", "B", "C", "D", "E",
"F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U",
"V", "W", "X", "Y", "Z", "&7", "&8", "&9", "&0", "&-", "&.", "&A", "&B", "&C",
"&D", "&E", "&F", "&G", "&H", "&I", "&J", "&K", "&L", "&M", "&N", "&O", "&P",
"&Q", "&R", "&S", "&T", "&U", "&V", "&W", "&X", "&Y", "&Z", "&$", "&/", "&+",
"&%", "& "
};
/* Table 5: Check Character Weighting Values */
static const char c49_x_weight[] = {
1, 9, 31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43,
39, 11, 13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10
};
static const char c49_y_weight[] = {
9, 31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43, 39,
11, 13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10, 24
};
static const char c49_z_weight[] = {
31, 26, 2, 12, 17, 23, 37, 18, 22, 6, 27, 44, 15, 43, 39, 11,
13, 5, 41, 33, 36, 8, 4, 32, 3, 19, 40, 25, 29, 10, 24, 30
};
static const char *c49_table4[8] = {
/* Table 4: Row Parity Pattern for Code 49 Symbols */
"OEEO", "EOEO", "OOEE", "EEOO", "OEOE", "EOOE", "OOOO", "EEEE"
};
static const unsigned short int c49_even_bitpattern[] = {
/* Appendix E - Code 49 Encodation Patterns (Even Symbol Character Parity) */
0xBE5C, 0xC16E, 0x86DC, 0xC126, 0x864C, 0x9EDC, 0xC726, 0x9E4C, 0xDF26, 0x82CC,
0x8244, 0x8ECC, 0xC322, 0x8E44, 0xBECC, 0xCF22, 0xBE44, 0xC162, 0x86C4, 0xC762,
0x9EC4, 0xDF62, 0x812E, 0x872E, 0x9F2E, 0x836E, 0x8326, 0x8F6E, 0x8F26, 0xBF6E,
0x8166, 0x8122, 0x8766, 0x8722, 0x9F66, 0x9F22, 0x8362, 0x8F62, 0xBF62, 0xA2E0,
0xE8B8, 0xFA2E, 0xD370, 0xF4DC, 0xD130, 0xF44C, 0xAEE0, 0xEBB8, 0xFAEE, 0xA660,
0xE998, 0xFA66, 0xA220, 0xE888, 0xFA22, 0xD730, 0xF5CC, 0xD310, 0xF4C4, 0xAE20,
0xEB88, 0xFAE2, 0x9170, 0xE45C, 0xD8B8, 0xF62E, 0xC9B8, 0xF26E, 0xB370, 0xC898,
0xF226, 0xB130, 0xEC4C, 0x9770, 0xE5DC, 0x9330, 0xE4CC, 0x9110, 0xE444, 0xD888,
0xF622, 0xCB98, 0xF2E6, 0xB730, 0xC988, 0xF262, 0xB310, 0xECC4, 0x9710, 0xE5C4,
0xDB88, 0xF6E2, 0x88B8, 0xE22E, 0xCC5C, 0xB8B8, 0xEE2E, 0xC4DC, 0x99B8, 0xC44C,
0x9898, 0xE626, 0xDC4C, 0x8BB8, 0xE2EE, 0x8998, 0xE266, 0xBBB8, 0x8888, 0xE222,
0xB998, 0xCC44, 0xB888, 0xEE22, 0xC5CC, 0x9B98, 0xC4C4, 0x9988, 0xE662, 0xDCC4,
0x8B88, 0xE2E2, 0xCDC4, 0xBB88, 0xEEE2, 0x845C, 0xC62E, 0x9C5C, 0xDE2E, 0xC26E,
0x8CDC, 0xC226, 0x8C4C, 0xBCDC, 0xCE26, 0xBC4C, 0x85DC, 0x84CC, 0x9DDC, 0x8444,
0x9CCC, 0xC622, 0x9C44, 0xDE22, 0xC2E6, 0x8DCC, 0xC262, 0x8CC4, 0xBDCC, 0xCE62,
0xBCC4, 0x85C4, 0xC6E2, 0x9DC4, 0xDEE2, 0x822E, 0x8E2E, 0x866E, 0x8626, 0x9E6E,
0x9E26, 0x82EE, 0x8266, 0x8EEE, 0x8222, 0x8E66, 0xBEEE, 0x8E22, 0xBE66, 0x86E6,
0x8662, 0x9EE6, 0x9E62, 0x82E2, 0x8EE2, 0xBEE2, 0xA170, 0xE85C, 0xD1B8, 0xF46E,
0xD098, 0xF426, 0xA770, 0xE9DC, 0xA330, 0xE8CC, 0xA110, 0xE844, 0xD7B8, 0xF5EE,
0xD398, 0xF4E6, 0xD188, 0xF462, 0xAF30, 0xEBCC, 0xA710, 0xE9C4, 0xD788, 0xF5E2,
0x90B8, 0xE42E, 0xD85C, 0xC8DC, 0xB1B8, 0xC84C, 0xB098, 0xEC26, 0x93B8, 0xE4EE,
0x9198, 0xE466, 0x9088, 0xE422, 0xD844, 0xCBDC, 0xB7B8, 0xC9CC, 0xB398, 0xC8C4,
0xB188, 0xEC62, 0x9798, 0xE5E6, 0x9388, 0xE4E2, 0xD9C4, 0xCBC4, 0xB788, 0xEDE2,
0x885C, 0xCC2E, 0xB85C, 0xC46E, 0x98DC, 0xC426, 0x984C, 0xDC26, 0x89DC, 0x88CC,
0xB9DC, 0x8844, 0xB8CC, 0xCC22, 0xB844, 0xC5EE, 0x9BDC, 0xC4E6, 0x99CC, 0xC462,
0x98C4, 0xDC62, 0x8BCC, 0x89C4, 0xBBCC, 0xCCE2, 0xB9C4, 0xC5E2, 0x9BC4, 0xDDE2,
0x842E, 0x9C2E, 0x8C6E, 0x8C26, 0xBC6E, 0x84EE, 0x8466, 0x9CEE, 0x8422, 0x9C66,
0x9C22, 0x8DEE, 0x8CE6, 0xBDEE, 0x8C62, 0xBCE6, 0xBC62, 0x85E6, 0x84E2, 0x9DE6,
0x9CE2, 0x8DE2, 0xBDE2, 0xA0B8, 0xE82E, 0xD0DC, 0xD04C, 0xA3B8, 0xE8EE, 0xA198,
0xE866, 0xA088, 0xE822, 0xD3DC, 0xD1CC, 0xD0C4, 0xAFB8, 0xEBEE, 0xA798, 0xE9E6,
0xA388, 0xE8E2, 0xD7CC, 0xD3C4, 0x905C, 0xD82E, 0xC86E, 0xB0DC, 0xC826, 0xB04C,
0x91DC, 0x90CC, 0x9044, 0xD822, 0xC9EE, 0xB3DC, 0xC8E6, 0xB1CC, 0xC862, 0xB0C4,
0x97DC, 0x93CC, 0x91C4, 0xD8E2, 0xCBE6, 0xB7CC, 0xC9E2, 0xB3C4, 0x882E, 0x986E,
0x9826, 0x88EE, 0x8866, 0xB8EE, 0x8822, 0xB866, 0x99EE, 0x98E6, 0x9862, 0x8BEE,
0x89E6, 0xBBEE, 0x88E2, 0xB9E6, 0xB8E2, 0x9BE6, 0x99E2, 0xA05C, 0xD06E, 0xD026,
0xA1DC, 0xA0CC, 0xA044, 0xD1EE, 0xD0E6, 0xD062, 0xA7DC, 0xA3CC, 0xA1C4, 0xD7EE,
0xD3E6, 0xD1E2, 0x902E, 0xB06E, 0x90EE, 0x9066, 0x9022, 0xB1EE, 0xB0E6, 0xB062,
0x93EE, 0x91E6, 0x90E2, 0xB7EE, 0xB3E6, 0xB1E2, 0xA9C0, 0xEA70, 0xFA9C, 0xD460,
0xF518, 0xFD46, 0xA840, 0xEA10, 0xFA84, 0xED78, 0xFB5E, 0x94E0, 0xE538, 0xF94E,
0xDA70, 0xF69C, 0xCA30, 0xF28C, 0xB460, 0xED18, 0xFB46, 0x9420, 0xE508, 0xF942,
0xDA10, 0xF684, 0x9AF0, 0xE6BC, 0xDD78, 0xF75E, 0x8A70, 0xE29C, 0xCD38, 0xF34E,
0xBA70, 0xEE9C, 0xC518, 0xF146, 0x9A30, 0xE68C, 0xDD18, 0xF746, 0x8A10, 0xE284,
0xCD08, 0xF342, 0xBA10, 0xEE84, 0x8D78, 0xE35E, 0xCEBC, 0xBD78, 0xEF5E, 0x8538,
0xE14E, 0xC69C, 0x9D38, 0xE74E, 0xDE9C, 0xC28C, 0x8D18, 0xE346, 0xCE8C, 0xBD18,
0xEF46, 0x8508, 0xE142, 0xC684, 0x9D08, 0xE742, 0xDE84, 0x86BC, 0xC75E, 0x9EBC,
0xDF5E, 0x829C, 0xC34E, 0x8E9C, 0xCF4E, 0xBE9C, 0xC146, 0x868C, 0xC746, 0x9E8C,
0xDF46, 0x8284, 0xC342, 0x8E84, 0xCF42, 0xBE84, 0x835E, 0x8F5E, 0xBF5E, 0x814E,
0x874E, 0x9F4E, 0x8346, 0x8F46, 0xBF46, 0x8142, 0x8742, 0x9F42, 0xD2F0, 0xF4BC,
0xADE0, 0xEB78, 0xFADE, 0xA4E0, 0xE938, 0xFA4E, 0xD670, 0xF59C, 0xD230, 0xF48C,
0xAC60, 0xEB18, 0xFAC6, 0xA420, 0xE908, 0xFA42, 0xD610, 0xF584, 0xC978, 0xF25E,
0xB2F0, 0xECBC, 0x96F0, 0xE5BC, 0x9270, 0xE49C, 0xD938, 0xF64E, 0xCB38, 0xF2CE,
0xB670, 0xC918, 0xF246, 0xB230, 0xEC8C, 0x9630, 0xE58C, 0x9210, 0xE484, 0xD908,
0xF642, 0xCB08, 0xF2C2, 0xB610, 0xED84, 0xC4BC, 0x9978, 0xE65E, 0xDCBC, 0x8B78,
0xE2DE, 0x8938, 0xE24E, 0xBB78, 0xCC9C, 0xB938, 0xEE4E, 0xC59C, 0x9B38, 0xC48C,
0x9918, 0xE646, 0xDC8C, 0x8B18, 0xE2C6, 0x8908, 0xE242, 0xBB18, 0xCC84, 0xB908,
0xEE42, 0xC584, 0x9B08, 0xE6C2, 0xDD84, 0xC25E, 0x8CBC, 0xCE5E, 0xBCBC, 0x85BC,
0x849C, 0x9DBC, 0xC64E, 0x9C9C, 0xDE4E, 0xC2CE, 0x8D9C, 0xC246, 0x8C8C, 0xBD9C,
0xCE46, 0xBC8C, 0x858C, 0x8484, 0x9D8C, 0xC642, 0x9C84, 0xDE42, 0xC2C2, 0x8D84,
0xCEC2, 0xBD84, 0x865E, 0x9E5E, 0x82DE, 0x824E, 0x8EDE, 0x8E4E, 0xBEDE, 0xBE4E,
0x86CE, 0x8646, 0x9ECE, 0x9E46, 0x82C6, 0x8242, 0x8EC6, 0x8E42, 0xBEC6, 0xBE42,
0x86C2, 0x9EC2, 0xD178, 0xF45E, 0xA6F0, 0xE9BC, 0xA270, 0xE89C, 0xD778, 0xF5DE,
0xD338, 0xF4CE, 0xD118, 0xF446, 0xAE70, 0xEB9C, 0xA630, 0xE98C, 0xA210, 0xE884,
0xD718, 0xF5C6, 0xD308, 0xF4C2, 0xAE10, 0xEB84, 0xC8BC, 0xB178, 0xEC5E, 0x9378,
0xE4DE, 0x9138, 0xE44E, 0xD89C, 0xCBBC, 0xB778, 0xC99C, 0xB338, 0xC88C, 0xB118,
0xEC46, 0x9738, 0xE5CE, 0x9318, 0xE4C6, 0x9108, 0xE442, 0xD884, 0xCB8C, 0xB718,
0xC984, 0xB308, 0xECC2, 0x9708, 0xE5C2, 0xDB84, 0xC45E, 0x98BC, 0xDC5E, 0x89BC,
0x889C, 0xB9BC, 0xCC4E, 0xB89C, 0xC5DE, 0x9BBC, 0xC4CE, 0x999C, 0xC446, 0x988C,
0xDC46, 0x8B9C, 0x898C, 0xBB9C, 0x8884, 0xB98C, 0xCC42, 0xB884, 0xC5C6, 0x9B8C,
0xC4C2, 0x9984, 0xDCC2, 0x8B84, 0xCDC2, 0xBB84, 0x8C5E, 0xBC5E, 0x84DE, 0x844E,
0x9CDE, 0x9C4E, 0x8DDE, 0x8CCE, 0xBDDE, 0x8C46, 0xBCCE, 0xBC46, 0x85CE, 0x84C6,
0x9DCE, 0x8442, 0x9CC6, 0x9C42, 0x8DC6, 0x8CC2, 0xBDC6, 0xBCC2, 0x85C2, 0x9DC2,
0xD0BC, 0xA378, 0xE8DE, 0xA138, 0xE84E, 0xD3BC, 0xD19C, 0xD08C, 0xAF78, 0xEBDE,
0xA738, 0xE9CE, 0xA318, 0xE8C6, 0xA108, 0xE842, 0xD79C, 0xD38C, 0xD184, 0xAF18,
0xEBC6, 0xA708, 0xE9C2, 0xC85E, 0xB0BC, 0x91BC, 0x909C, 0xD84E, 0xC9DE, 0xB3BC,
0xC8CE, 0xB19C, 0xC846, 0xB08C, 0x97BC, 0x939C, 0x918C, 0x9084, 0xD842, 0xCBCE,
0xB79C, 0xC9C6, 0xB38C, 0xC8C2, 0xB184, 0x978C, 0x9384, 0xD9C2, 0x985E, 0x88DE,
0x884E, 0xB8DE, 0xB84E, 0x99DE, 0x98CE, 0x9846, 0x8BDE, 0x89CE, 0xBBDE, 0x88C6,
0xB9CE, 0x8842, 0xB8C6, 0xB842, 0x9BCE, 0x99C6, 0x98C2, 0x8BC6, 0x89C2, 0xBBC6,
0xB9C2, 0xD05E, 0xA1BC, 0xA09C, 0xD1DE, 0xD0CE, 0xD046, 0xA7BC, 0xA39C, 0xA18C,
0xA084, 0xD7DE, 0xD3CE, 0xD1C6, 0xD0C2, 0xAF9C, 0xA78C, 0xA384, 0xB05E, 0x90DE,
0x904E, 0xB1DE, 0xB0CE, 0xB046, 0x93DE, 0x91CE, 0x90C6, 0x9042, 0xB7DE, 0xB3CE,
0xB1C6, 0xB0C2, 0x97CE, 0x93C6, 0x91C2, 0xA0DE, 0xA04E, 0xA3DE, 0xA1CE, 0xA0C6,
0xA042, 0xAFDE, 0xA7CE, 0xA3C6, 0xA1C2, 0xD4F0, 0xF53C, 0xA8E0, 0xEA38, 0xFA8E,
0xD430, 0xF50C, 0xA820, 0xEA08, 0xFA82, 0xDAF8, 0xF6BE, 0xCA78, 0xF29E, 0xB4F0,
0xED3C, 0x9470, 0xE51C, 0xDA38, 0xF68E, 0xCA18, 0xF286, 0xB430, 0xED0C, 0x9410,
0xE504, 0xDA08, 0xF682, 0xCD7C, 0xBAF8, 0xEEBE, 0xC53C, 0x9A78, 0xE69E, 0xDD3C,
0x8A38, 0xE28E, 0xCD1C, 0xBA38, 0xEE8E, 0xC50C, 0x9A18, 0xE686, 0xDD0C, 0x8A08,
0xE282, 0xCD04, 0xBA08, 0xEE82, 0xC6BE, 0x9D7C, 0xDEBE, 0xC29E, 0x8D3C, 0xCE9E,
0xBD3C, 0x851C, 0xC68E, 0x9D1C, 0xDE8E, 0xC286, 0x8D0C, 0xCE86, 0xBD0C, 0x8504,
0xC682, 0x9D04, 0xDE82, 0x8EBE, 0xBEBE, 0x869E, 0x9E9E, 0x828E, 0x8E8E, 0xBE8E,
0x8686, 0x9E86, 0x8282, 0x8E82, 0xBE82, 0xE97C, 0xD6F8, 0xF5BE, 0xD278, 0xF49E,
0xACF0, 0xEB3C, 0xA470, 0xE91C, 0xD638, 0xF58E, 0xD218, 0xF486, 0xAC30, 0xEB0C,
0xA410, 0xE904, 0xD608, 0xF582, 0x92F8, 0xE4BE, 0xD97C, 0xCB7C, 0xB6F8, 0xC93C,
0xB278, 0xEC9E, 0x9678, 0xE59E, 0x9238, 0xE48E, 0xD91C, 0xCB1C, 0xB638, 0xC90C,
0xB218, 0xEC86, 0x9618, 0xE586, 0x9208, 0xE482, 0xD904, 0xCB04, 0xB608, 0xED82,
0x897C, 0xCCBE, 0xB97C, 0xC5BE, 0x9B7C, 0xC49E, 0x993C, 0xDC9E, 0x8B3C, 0x891C,
0xBB3C, 0xCC8E, 0xB91C, 0xC58E, 0x9B1C, 0xC486, 0x990C, 0xDC86, 0x8B0C, 0x8904,
0xBB0C, 0xCC82, 0xB904, 0xC582, 0x9B04, 0xDD82, 0x84BE, 0x9CBE, 0x8DBE, 0x8C9E,
0xBDBE, 0xBC9E, 0x859E, 0x848E, 0x9D9E, 0x9C8E, 0x8D8E, 0x8C86, 0xBD8E, 0xBC86,
0x8586, 0x8482, 0x9D86, 0x9C82, 0x8D82, 0xBD82, 0xA2F8, 0xE8BE, 0xD37C, 0xD13C,
0xAEF8, 0xEBBE, 0xA678, 0xE99E, 0xA238, 0xE88E, 0xD73C, 0xD31C, 0xD10C, 0xAE38,
0xEB8E, 0xA618, 0xE986, 0xA208, 0xE882, 0xD70C, 0xD304, 0x917C, 0xD8BE, 0xC9BE,
0xB37C, 0xC89E, 0xB13C, 0x977C, 0x933C, 0x911C, 0xD88E, 0xCB9E, 0xB73C, 0xC98E,
0xB31C, 0xC886, 0xB10C, 0x971C, 0x930C, 0x9104, 0xD882, 0xCB86, 0xB70C, 0xC982,
0xB304, 0x88BE, 0xB8BE, 0x99BE, 0x989E, 0x8BBE, 0x899E, 0xBBBE, 0x888E, 0xB99E,
0xB88E, 0x9B9E, 0x998E, 0x9886, 0x8B8E, 0x8986, 0xBB8E, 0x8882, 0xB986, 0xB882,
0x9B86, 0x9982, 0xA17C, 0xD1BE, 0xD09E, 0xA77C, 0xA33C, 0xA11C, 0xD7BE, 0xD39E,
0xD18E, 0xD086, 0xAF3C, 0xA71C, 0xA30C, 0xA104, 0xD78E, 0xD386, 0xD182, 0x90BE,
0xB1BE, 0xB09E, 0x93BE, 0x919E, 0x908E, 0xB7BE, 0xB39E, 0xB18E, 0xB086, 0x979E,
0x938E, 0x9186, 0x9082, 0xB78E, 0xB386, 0xB182, 0xA0BE, 0xA3BE, 0xA19E, 0xA08E,
0xAFBE, 0xA79E, 0xA38E, 0xA186, 0xA082, 0xA9F0, 0xEA7C, 0xD478, 0xF51E, 0xA870,
0xEA1C, 0xD418, 0xF506, 0xA810, 0xEA04, 0xED7E, 0x94F8, 0xE53E, 0xDA7C, 0xCA3C,
0xB478, 0xED1E, 0x9438, 0xE50E, 0xDA1C, 0xCA0C, 0xB418, 0xED06, 0x9408, 0xE502,
0xDA04, 0x9AFC, 0xDD7E, 0x8A7C, 0xCD3E, 0xBA7C, 0xC51E, 0x9A3C, 0xDD1E, 0x8A1C,
0xCD0E, 0xBA1C, 0xC506, 0x9A0C, 0xDD06, 0x8A04, 0xCD02, 0xBA04, 0x8D7E, 0xBD7E,
0x853E, 0x9D3E, 0x8D1E, 0xBD1E, 0x850E, 0x9D0E, 0x8D06, 0xBD06, 0x8502, 0x9D02,
0xD2FC, 0xADF8, 0xEB7E, 0xA4F8, 0xE93E, 0xD67C, 0xD23C, 0xAC78, 0xEB1E, 0xA438,
0xE90E, 0xD61C, 0xD20C, 0xAC18, 0xEB06, 0xA408, 0xE902, 0xC97E, 0xB2FC, 0x96FC,
0x927C, 0xD93E, 0xCB3E, 0xB67C, 0xC91E, 0xB23C, 0x963C, 0x921C, 0xD90E, 0xCB0E,
0xB61C, 0xC906, 0xB20C, 0x960C, 0x9204, 0xD902, 0x997E, 0x8B7E, 0x893E, 0xBB7E,
0xB93E, 0xE4A0, 0xF928, 0xD940, 0xF650, 0xFD94, 0xCB40, 0xF2D0, 0xEDA0, 0xFB68,
0x8940, 0xE250, 0xCCA0, 0xF328, 0xB940, 0xEE50, 0xFB94, 0xC5A0, 0xF168, 0x9B40,
0xE6D0, 0xF9B4, 0xDDA0, 0xF768, 0xFDDA, 0x84A0, 0xE128, 0xC650, 0xF194, 0x9CA0,
0xE728, 0xF9CA, 0xDE50, 0xF794, 0xC2D0, 0x8DA0, 0xE368, 0xCED0, 0xF3B4, 0xBDA0,
0xEF68, 0xFBDA, 0x8250, 0xC328, 0x8E50, 0xE394, 0xCF28, 0xF3CA, 0xBE50, 0xEF94,
0xC168, 0x86D0, 0xE1B4, 0xC768, 0xF1DA, 0x9ED0, 0xE7B4, 0xDF68, 0xF7DA, 0x8128,
0xC194, 0x8728, 0xE1CA, 0xC794, 0x9F28, 0xE7CA, 0x8368, 0xC3B4, 0x8F68, 0xE3DA,
0xCFB4, 0xBF68, 0xEFDA, 0xE8A0, 0xFA28, 0xD340, 0xF4D0, 0xFD34, 0xEBA0, 0xFAE8,
0x9140, 0xE450, 0xF914, 0xD8A0, 0xF628, 0xFD8A, 0xC9A0, 0xF268, 0xB340, 0xECD0,
0xFB34, 0x9740, 0xE5D0, 0xF974, 0xDBA0, 0xF6E8, 0xFDBA, 0x88A0, 0xE228, 0xCC50,
0xF314, 0xB8A0, 0xEE28, 0xFB8A, 0xC4D0, 0xF134, 0x99A0, 0xE668, 0xF99A, 0xDCD0,
0xF734, 0x8BA0, 0xE2E8, 0xCDD0, 0xF374, 0xBBA0, 0xEEE8, 0xFBBA, 0x8450, 0xE114,
0xC628, 0xF18A, 0x9C50, 0xE714, 0xDE28, 0xF78A, 0xC268, 0x8CD0, 0xE334, 0xCE68,
0xF39A, 0xBCD0, 0xEF34, 0x85D0, 0xE174, 0xC6E8, 0xF1BA, 0x9DD0, 0xE774, 0xDEE8,
0xF7BA, 0x8228, 0xC314, 0x8E28, 0xE38A, 0xCF14, 0xC134, 0x8668, 0xE19A, 0xC734,
0x9E68, 0xE79A, 0xDF34, 0x82E8, 0xC374, 0x8EE8, 0xE3BA, 0xCF74, 0xBEE8, 0xEFBA,
0x8114, 0xC18A, 0x8714, 0xC78A, 0x8334, 0xC39A, 0x8F34, 0xCF9A, 0x8174, 0xC1BA,
0x8774, 0xC7BA, 0x9F74, 0xDFBA, 0xA140, 0xE850, 0xFA14, 0xD1A0, 0xF468, 0xFD1A,
0xA740, 0xE9D0, 0xFA74, 0xD7A0, 0xF5E8, 0xFD7A, 0x90A0, 0xE428, 0xF90A, 0xD850,
0xF614, 0xC8D0, 0xF234, 0xB1A0, 0xEC68, 0xFB1A, 0x93A0, 0xE4E8, 0xF93A, 0xD9D0,
0xF674, 0xCBD0, 0xF2F4, 0xB7A0, 0xEDE8, 0xFB7A, 0x8850, 0xE214, 0xCC28, 0xF30A,
0xB850, 0xEE14, 0xC468, 0xF11A, 0x98D0, 0xE634, 0xDC68, 0xF71A, 0x89D0, 0xE274,
0xCCE8, 0xF33A, 0xB9D0, 0xEE74, 0xC5E8, 0xF17A, 0x9BD0, 0xE6F4, 0xDDE8, 0xF77A,
0x8428, 0xE10A, 0xC614, 0x9C28, 0xE70A, 0xC234, 0x8C68, 0xE31A, 0xCE34, 0xBC68,
0xEF1A, 0x84E8, 0xE13A, 0xC674, 0x9CE8, 0xE73A, 0xDE74, 0xC2F4, 0x8DE8, 0xE37A,
0xCEF4, 0xBDE8, 0xEF7A, 0x8214, 0xC30A, 0x8E14, 0xC11A, 0x8634, 0xC71A, 0x9E34,
0x8274, 0xC33A, 0x8E74, 0xCF3A, 0xBE74, 0xC17A, 0x86F4, 0xC77A, 0x9EF4, 0xDF7A,
0x810A, 0x870A, 0x831A, 0x8F1A, 0x813A, 0x873A, 0x9F3A, 0x837A, 0x8F7A, 0xBF7A,
0xA0A0, 0xE828, 0xFA0A, 0xD0D0, 0xF434, 0xA3A0, 0xE8E8, 0xFA3A, 0xD3D0, 0xF4F4,
0xAFA0, 0xEBE8, 0xFAFA, 0x9050, 0xE414, 0xD828, 0xF60A, 0xC868, 0xF21A, 0xB0D0,
0xEC34, 0x91D0, 0xE474, 0xD8E8, 0xF63A, 0xC9E8, 0xF27A, 0xB3D0, 0xECF4, 0x97D0,
0xE5F4, 0xDBE8, 0xF6FA, 0x8828, 0xE20A, 0xCC14, 0xC434, 0x9868, 0xE61A, 0xDC34,
0x88E8, 0xE23A, 0xCC74, 0xB8E8, 0xEE3A, 0xC4F4, 0x99E8, 0xE67A, 0xDCF4, 0x8BE8,
0xE2FA, 0xCDF4, 0xBBE8, 0xEEFA, 0x8414, 0xC60A, 0xC21A, 0x8C34, 0xCE1A, 0x8474,
0xC63A, 0x9C74, 0xDE3A, 0xC27A, 0x8CF4, 0xCE7A, 0xBCF4, 0x85F4, 0xC6FA, 0x9DF4,
0xDEFA, 0x820A, 0x861A, 0x823A, 0x8E3A, 0x867A, 0x9E7A, 0x82FA, 0x8EFA, 0xBEFA,
0xA050, 0xE814, 0xD068, 0xF41A, 0xA1D0, 0xE874, 0xD1E8, 0xF47A, 0xA7D0, 0xE9F4,
0xD7E8, 0xF5FA, 0x9028, 0xE40A, 0xC834, 0xB068, 0xEC1A, 0x90E8, 0xE43A, 0xD874,
0xC8F4, 0xB1E8, 0xEC7A, 0x93E8, 0xE4FA, 0xD9F4, 0xCBF4, 0xB7E8, 0xEDFA, 0x8814,
0xC41A, 0x9834, 0x8874, 0xCC3A, 0xB874, 0xC47A, 0x98F4, 0xDC7A, 0x89F4, 0xCCFA,
0xB9F4, 0xC5FA, 0x9BF4, 0xDDFA, 0x840A, 0x8C1A, 0x843A, 0x9C3A, 0x8C7A, 0xBC7A,
0x84FA, 0x9CFA, 0x8DFA, 0xBDFA, 0xEA40, 0xFA90, 0xED60, 0xFB58, 0xE520, 0xF948,
0xDA40, 0xF690, 0xFDA4, 0x9AC0, 0xE6B0, 0xF9AC, 0xDD60, 0xF758, 0xFDD6, 0x8A40,
0xE290, 0xCD20, 0xF348, 0xBA40, 0xEE90, 0xFBA4, 0x8D60, 0xE358, 0xCEB0, 0xF3AC,
0xBD60, 0xEF58, 0xFBD6, 0x8520, 0xE148, 0xC690, 0xF1A4, 0x9D20, 0xE748, 0xF9D2,
0xDE90, 0xF7A4, 0x86B0, 0xE1AC, 0xC758, 0xF1D6, 0x9EB0, 0xE7AC, 0xDF58, 0xF7D6,
0x8290, 0xC348, 0x8E90, 0xE3A4, 0xCF48, 0xF3D2, 0xBE90, 0xEFA4, 0x8358, 0xC3AC,
0x8F58, 0xE3D6, 0xCFAC, 0xBF58, 0xEFD6, 0x8148, 0xC1A4, 0x8748, 0xE1D2, 0xC7A4,
0x9F48, 0xE7D2, 0xDFA4, 0xD2C0, 0xF4B0, 0xFD2C, 0xEB60, 0xFAD8, 0xE920, 0xFA48,
0xD640, 0xF590, 0xFD64, 0xC960, 0xF258, 0xB2C0, 0xECB0, 0xFB2C, 0x96C0, 0xE5B0,
0xF96C, 0x9240, 0xE490, 0xF924, 0xD920, 0xF648, 0xFD92, 0xCB20, 0xF2C8, 0xB640,
0xED90, 0xFB64, 0xC4B0, 0xF12C, 0x9960, 0xE658, 0xF996, 0xDCB0, 0xF72C, 0x8B60,
0xE2D8, 0x8920, 0xE248, 0xBB60, 0xCC90, 0xF324, 0xB920, 0xEE48, 0xFB92, 0xC590,
0xF164, 0x9B20, 0xE6C8, 0xF9B2, 0xDD90, 0xF764, 0xC258, 0x8CB0, 0xE32C, 0xCE58,
0xF396, 0xBCB0, 0xEF2C, 0x85B0, 0xE16C, 0x8490, 0xE124, 0x9DB0, 0xC648, 0xF192,
0x9C90, 0xE724, 0xDE48, 0xF792, 0xC2C8, 0x8D90, 0xE364, 0xCEC8, 0xF3B2, 0xBD90,
0xEF64, 0xC12C, 0x8658, 0xE196, 0xC72C, 0x9E58, 0xE796, 0xDF2C, 0x82D8, 0x8248,
0x8ED8, 0xC324, 0x8E48, 0xE392, 0xBED8, 0xCF24, 0xBE48, 0xEF92, 0xC164, 0x86C8,
0xE1B2, 0xC764, 0x9EC8, 0xE7B2, 0xDF64, 0x832C, 0xC396, 0x8F2C, 0xCF96, 0x816C,
0x8124, 0x876C, 0xC192, 0x8724, 0x9F6C, 0xC792, 0x9F24, 0x8364, 0xC3B2, 0x8F64,
0xCFB2, 0xBF64, 0xD160, 0xF458, 0xFD16, 0xA6C0, 0xE9B0, 0xFA6C, 0xA240, 0xE890,
0xFA24, 0xD760, 0xF5D8, 0xFD76, 0xD320, 0xF4C8, 0xFD32, 0xAE40, 0xEB90, 0xFAE4,
0xC8B0, 0xF22C, 0xB160, 0xEC58, 0xFB16, 0x9360, 0xE4D8, 0xF936, 0x9120, 0xE448,
0xF912, 0xD890, 0xF624, 0xCBB0, 0xF2EC, 0xB760, 0xC990, 0xF264, 0xB320, 0xECC8,
0xFB32, 0x9720, 0xE5C8, 0xF972, 0xDB90, 0xF6E4, 0xC458, 0xF116, 0x98B0, 0xE62C,
0xDC58, 0xF716, 0x89B0, 0xE26C, 0x8890, 0xE224, 0xB9B0, 0xCC48, 0xF312, 0xB890,
0xEE24, 0xC5D8, 0xF176, 0x9BB0, 0xC4C8, 0xF132, 0x9990, 0xE664, 0xDCC8, 0xF732,
0x8B90, 0xE2E4, 0xCDC8, 0xF372, 0xBB90, 0xEEE4, 0xC22C, 0x8C58, 0xE316, 0xCE2C,
0xBC58, 0xEF16, 0x84D8, 0xE136, 0x8448, 0xE112, 0x9CD8, 0xC624, 0x9C48, 0xE712,
0xDE24, 0xC2EC, 0x8DD8, 0xC264, 0x8CC8, 0xE332, 0xBDD8, 0xCE64, 0xBCC8, 0xEF32,
0x85C8, 0xE172, 0xC6E4, 0x9DC8, 0xE772, 0xDEE4, 0xC116, 0x862C, 0xC716, 0x9E2C,
0x826C, 0x8224, 0x8E6C, 0xC312, 0x8E24, 0xBE6C, 0xCF12, 0xC176, 0x86EC, 0xC132,
0x8664, 0x9EEC, 0xC732, 0x9E64, 0xDF32, 0x82E4, 0xC372, 0x8EE4, 0xCF72, 0xBEE4,
0x8316, 0x8F16, 0x8136, 0x8112, 0x8736, 0x8712, 0x9F36, 0x8376, 0x8332, 0x8F76,
0x8F32, 0xBF76, 0x8172, 0x8772, 0x9F72, 0xD0B0, 0xF42C, 0xA360, 0xE8D8, 0xFA36,
0xA120, 0xE848, 0xFA12, 0xD3B0, 0xF4EC, 0xD190, 0xF464, 0xAF60, 0xEBD8, 0xFAF6,
0xA720, 0xE9C8, 0xFA72, 0xD790, 0xF5E4, 0xC858, 0xF216, 0xB0B0, 0xEC2C, 0x91B0,
0xE46C, 0x9090, 0xE424, 0xD848, 0xF612, 0xC9D8, 0xF276, 0xB3B0, 0xC8C8, 0xF232,
0xB190, 0xEC64, 0x97B0, 0xE5EC, 0x9390, 0xE4E4, 0xD9C8, 0xF672, 0xCBC8, 0xF2F2,
0xB790, 0xEDE4, 0xC42C, 0x9858, 0xE616, 0xDC2C, 0x88D8, 0xE236, 0x8848, 0xE212,
0xB8D8, 0xCC24, 0xB848, 0xEE12, 0xC4EC, 0x99D8, 0xC464, 0x98C8, 0xE632, 0xDC64,
0x8BD8, 0xE2F6, 0x89C8, 0xE272, 0xBBD8, 0xCCE4, 0xB9C8, 0xEE72, 0xC5E4, 0x9BC8,
0xE6F2, 0xDDE4, 0xC216, 0x8C2C, 0xCE16, 0x846C, 0x8424, 0x9C6C, 0xC612, 0x9C24,
0xC276, 0x8CEC, 0xC232, 0x8C64, 0xBCEC, 0xCE32, 0xBC64, 0x85EC, 0x84E4, 0x9DEC,
0xC672, 0x9CE4, 0xDE72, 0xC2F2, 0x8DE4, 0xCEF2, 0xBDE4, 0x8616, 0x8236, 0x8212,
0x8E36, 0x8E12, 0x8676, 0x8632, 0x9E76, 0x9E32, 0x82F6, 0x8272, 0x8EF6, 0x8E72,
0xBEF6, 0xBE72, 0x86F2, 0x9EF2, 0xD058, 0xF416, 0xA1B0, 0xE86C, 0xA090, 0xE824,
0xD1D8, 0xF476, 0xD0C8, 0xF432, 0xA7B0, 0xE9EC, 0xA390, 0xE8E4, 0xD7D8, 0xF5F6,
0xD3C8, 0xF4F2, 0xAF90, 0xEBE4, 0xC82C, 0xB058, 0xEC16, 0x90D8, 0xE436, 0x9048,
0xE412, 0xD824, 0xC8EC, 0xB1D8, 0xC864, 0xB0C8, 0xEC32, 0x93D8, 0xE4F6, 0x91C8,
0xE472, 0xD8E4, 0xCBEC, 0xB7D8, 0xC9E4, 0xB3C8, 0xECF2, 0x97C8, 0xE5F2, 0xDBE4,
0xC416, 0x982C, 0x886C, 0x8824, 0xB86C, 0xCC12, 0xC476, 0x98EC, 0xC432, 0x9864,
0xDC32, 0x89EC, 0x88E4, 0xB9EC, 0xCC72, 0xB8E4, 0xC5F6, 0x9BEC, 0xC4F2, 0x99E4,
0xDCF2, 0x8BE4, 0xCDF2, 0xBBE4, 0x8C16, 0x8436, 0x8412, 0x9C36, 0x8C76, 0x8C32,
0xBC76, 0x84F6, 0x8472, 0x9CF6, 0x9C72, 0x8DF6, 0x8CF2, 0xBDF6, 0xBCF2, 0x85F2,
0x9DF2, 0xD02C, 0xA0D8, 0xE836, 0xA048, 0xE812, 0xD0EC, 0xD064, 0xA3D8, 0xE8F6,
0xA1C8, 0xE872, 0xD3EC, 0xD1E4, 0xAFD8, 0xEBF6, 0xA7C8, 0xE9F2, 0xC816, 0x906C,
0x9024, 0xC876, 0xB0EC, 0xC832, 0xB064, 0x91EC, 0x90E4, 0xD872, 0xC9F6, 0xB3EC,
0xC8F2, 0xB1E4, 0x97EC, 0x93E4, 0xD9F2, 0x8836, 0x8812, 0x9876, 0x9832, 0x88F6,
0x8872, 0xB8F6, 0xB872, 0x99F6, 0x98F2, 0x8BF6, 0x89F2, 0xBBF6, 0xB9F2, 0xD4C0,
0xF530, 0xFD4C, 0xEA20, 0xFA88, 0xDAE0, 0xF6B8, 0xFDAE, 0xCA60, 0xF298, 0xB4C0,
0xED30, 0xFB4C, 0x9440, 0xE510, 0xF944, 0xDA20, 0xF688, 0xFDA2, 0xCD70, 0xF35C,
0xBAE0, 0xEEB8, 0xFBAE, 0xC530, 0xF14C, 0x9A60, 0xE698, 0xF9A6, 0xDD30, 0xF74C,
0x8A20, 0xE288, 0xCD10, 0xF344, 0xBA20, 0xEE88, 0xFBA2, 0xC6B8, 0xF1AE, 0x9D70,
0xE75C, 0xDEB8, 0xF7AE, 0xC298, 0x8D30, 0xE34C, 0xCE98, 0xF3A6, 0xBD30, 0xEF4C,
0x8510, 0xE144, 0xC688, 0xF1A2, 0x9D10, 0xE744, 0xDE88, 0xF7A2, 0xC35C, 0x8EB8,
0xE3AE, 0xCF5C, 0xBEB8, 0xEFAE, 0xC14C, 0x8698, 0xE1A6, 0xC74C, 0x9E98, 0xE7A6,
0xDF4C, 0x8288, 0xC344, 0x8E88, 0xE3A2, 0xCF44, 0xBE88, 0xEFA2, 0xC1AE, 0x875C,
0xC7AE, 0x9F5C, 0xDFAE, 0x834C, 0xC3A6, 0x8F4C, 0xCFA6, 0xBF4C, 0x8144, 0xC1A2,
0x8744, 0xC7A2, 0x9F44, 0xDFA2, 0xE970, 0xFA5C, 0xD6E0, 0xF5B8, 0xFD6E, 0xD260,
0xF498, 0xFD26, 0xACC0, 0xEB30, 0xFACC, 0xA440, 0xE910, 0xFA44, 0xD620, 0xF588,
0xFD62, 0x92E0, 0xE4B8, 0xF92E, 0xD970, 0xF65C, 0xCB70, 0xF2DC, 0xB6E0, 0xC930,
0xF24C, 0xB260, 0xEC98, 0xFB26, 0x9660, 0xE598, 0xF966, 0x9220, 0xE488, 0xF922,
0xD910, 0xF644, 0xCB10, 0xF2C4, 0xB620, 0xED88, 0xFB62, 0x8970, 0xE25C, 0xCCB8,
0xF32E, 0xB970, 0xEE5C, 0xC5B8, 0xF16E, 0x9B70, 0xC498, 0xF126, 0x9930, 0xE64C,
0xDC98, 0xF726, 0x8B30, 0xE2CC, 0x8910, 0xE244, 0xBB30, 0xCC88, 0xF322, 0xB910,
0xEE44, 0xC588, 0xF162, 0x9B10, 0xE6C4, 0xDD88, 0xF762, 0x84B8, 0xE12E, 0xC65C,
0x9CB8, 0xE72E, 0xDE5C, 0xC2DC, 0x8DB8, 0xC24C, 0x8C98, 0xE326, 0xBDB8, 0xCE4C,
0xBC98, 0xEF26, 0x8598, 0xE166, 0x8488, 0xE122, 0x9D98, 0xC644, 0x9C88, 0xE722,
0xDE44, 0xC2C4, 0x8D88, 0xE362, 0xCEC4, 0xBD88, 0xEF62, 0x825C, 0xC32E, 0x8E5C,
0xCF2E
};
static const unsigned short int c49_odd_bitpattern[] = {
/* Appendix E - Code 49 Encodation Patterns (Odd Symbol Character Parity) */
0xC940, 0xF250, 0xECA0, 0xFB28, 0xE5A0, 0xF968, 0xDB40, 0xF6D0, 0xFDB4, 0xC4A0,
0xF128, 0x9940, 0xE650, 0xF994, 0xDCA0, 0xF728, 0xFDCA, 0x8B40, 0xE2D0, 0xCDA0,
0xF368, 0xBB40, 0xEED0, 0xFBB4, 0xC250, 0x8CA0, 0xE328, 0xCE50, 0xF394, 0xBCA0,
0xEF28, 0xFBCA, 0x85A0, 0xE168, 0xC6D0, 0xF1B4, 0x9DA0, 0xE768, 0xF9DA, 0xDED0,
0xF7B4, 0xC128, 0x8650, 0xE194, 0xC728, 0xF1CA, 0x9E50, 0xE794, 0xDF28, 0xF7CA,
0x82D0, 0xC368, 0x8ED0, 0xE3B4, 0xCF68, 0xF3DA, 0xBED0, 0xEFB4, 0x8328, 0xC394,
0x8F28, 0xE3CA, 0xCF94, 0x8168, 0xC1B4, 0x8768, 0xE1DA, 0xC7B4, 0x9F68, 0xE7DA,
0xDFB4, 0xD140, 0xF450, 0xFD14, 0xE9A0, 0xFA68, 0xD740, 0xF5D0, 0xFD74, 0xC8A0,
0xF228, 0xB140, 0xEC50, 0xFB14, 0x9340, 0xE4D0, 0xF934, 0xD9A0, 0xF668, 0xFD9A,
0xCBA0, 0xF2E8, 0xB740, 0xEDD0, 0xFB74, 0xC450, 0xF114, 0x98A0, 0xE628, 0xF98A,
0xDC50, 0xF714, 0x89A0, 0xE268, 0xCCD0, 0xF334, 0xB9A0, 0xEE68, 0xFB9A, 0xC5D0,
0xF174, 0x9BA0, 0xE6E8, 0xF9BA, 0xDDD0, 0xF774, 0xC228, 0x8C50, 0xE314, 0xCE28,
0xF38A, 0xBC50, 0xEF14, 0x84D0, 0xE134, 0xC668, 0xF19A, 0x9CD0, 0xE734, 0xDE68,
0xF79A, 0xC2E8, 0x8DD0, 0xE374, 0xCEE8, 0xF3BA, 0xBDD0, 0xEF74, 0xC114, 0x8628,
0xE18A, 0xC714, 0x9E28, 0xE78A, 0x8268, 0xC334, 0x8E68, 0xE39A, 0xCF34, 0xBE68,
0xEF9A, 0xC174, 0x86E8, 0xE1BA, 0xC774, 0x9EE8, 0xE7BA, 0xDF74, 0x8314, 0xC38A,
0x8F14, 0x8134, 0xC19A, 0x8734, 0xC79A, 0x9F34, 0x8374, 0xC3BA, 0x8F74, 0xCFBA,
0xBF74, 0xD0A0, 0xF428, 0xFD0A, 0xA340, 0xE8D0, 0xFA34, 0xD3A0, 0xF4E8, 0xFD3A,
0xAF40, 0xEBD0, 0xFAF4, 0xC850, 0xF214, 0xB0A0, 0xEC28, 0xFB0A, 0x91A0, 0xE468,
0xF91A, 0xD8D0, 0xF634, 0xC9D0, 0xF274, 0xB3A0, 0xECE8, 0xFB3A, 0x97A0, 0xE5E8,
0xF97A, 0xDBD0, 0xF6F4, 0xC428, 0xF10A, 0x9850, 0xE614, 0xDC28, 0xF70A, 0x88D0,
0xE234, 0xCC68, 0xF31A, 0xB8D0, 0xEE34, 0xC4E8, 0xF13A, 0x99D0, 0xE674, 0xDCE8,
0xF73A, 0x8BD0, 0xE2F4, 0xCDE8, 0xF37A, 0xBBD0, 0xEEF4, 0xC214, 0x8C28, 0xE30A,
0xCE14, 0x8468, 0xE11A, 0xC634, 0x9C68, 0xE71A, 0xDE34, 0xC274, 0x8CE8, 0xE33A,
0xCE74, 0xBCE8, 0xEF3A, 0x85E8, 0xE17A, 0xC6F4, 0x9DE8, 0xE77A, 0xDEF4, 0xC10A,
0x8614, 0xC70A, 0x8234, 0xC31A, 0x8E34, 0xCF1A, 0xC13A, 0x8674, 0xC73A, 0x9E74,
0xDF3A, 0x82F4, 0xC37A, 0x8EF4, 0xCF7A, 0xBEF4, 0x830A, 0x811A, 0x871A, 0x833A,
0x8F3A, 0x817A, 0x877A, 0x9F7A, 0xD050, 0xF414, 0xA1A0, 0xE868, 0xFA1A, 0xD1D0,
0xF474, 0xA7A0, 0xE9E8, 0xFA7A, 0xD7D0, 0xF5F4, 0xC828, 0xF20A, 0xB050, 0xEC14,
0x90D0, 0xE434, 0xD868, 0xF61A, 0xC8E8, 0xF23A, 0xB1D0, 0xEC74, 0x93D0, 0xE4F4,
0xD9E8, 0xF67A, 0xCBE8, 0xF2FA, 0xB7D0, 0xEDF4, 0xC414, 0x9828, 0xE60A, 0x8868,
0xE21A, 0xCC34, 0xB868, 0xEE1A, 0xC474, 0x98E8, 0xE63A, 0xDC74, 0x89E8, 0xE27A,
0xCCF4, 0xB9E8, 0xEE7A, 0xC5F4, 0x9BE8, 0xE6FA, 0xDDF4, 0xC20A, 0x8C14, 0x8434,
0xC61A, 0x9C34, 0xC23A, 0x8C74, 0xCE3A, 0xBC74, 0x84F4, 0xC67A, 0x9CF4, 0xDE7A,
0xC2FA, 0x8DF4, 0xCEFA, 0xBDF4, 0x860A, 0x821A, 0x8E1A, 0x863A, 0x9E3A, 0x827A,
0x8E7A, 0xBE7A, 0x86FA, 0x9EFA, 0xD028, 0xF40A, 0xA0D0, 0xE834, 0xD0E8, 0xF43A,
0xA3D0, 0xE8F4, 0xD3E8, 0xF4FA, 0xAFD0, 0xEBF4, 0xC814, 0x9068, 0xE41A, 0xD834,
0xC874, 0xB0E8, 0xEC3A, 0x91E8, 0xE47A, 0xD8F4, 0xC9F4, 0xB3E8, 0xECFA, 0x97E8,
0xE5FA, 0xDBF4, 0xC40A, 0x8834, 0xCC1A, 0xC43A, 0x9874, 0xDC3A, 0x88F4, 0xCC7A,
0xB8F4, 0xC4FA, 0x99F4, 0xDCFA, 0x8BF4, 0xCDFA, 0xBBF4, 0x841A, 0x8C3A, 0x847A,
0x9C7A, 0x8CFA, 0xBCFA, 0x85FA, 0x9DFA, 0xF520, 0xFD48, 0xDAC0, 0xF6B0, 0xFDAC,
0xCA40, 0xF290, 0xED20, 0xFB48, 0xCD60, 0xF358, 0xBAC0, 0xEEB0, 0xFBAC, 0xC520,
0xF148, 0x9A40, 0xE690, 0xF9A4, 0xDD20, 0xF748, 0xFDD2, 0xC6B0, 0xF1AC, 0x9D60,
0xE758, 0xF9D6, 0xDEB0, 0xF7AC, 0xC290, 0x8D20, 0xE348, 0xCE90, 0xF3A4, 0xBD20,
0xEF48, 0xFBD2, 0xC358, 0x8EB0, 0xE3AC, 0xCF58, 0xF3D6, 0xBEB0, 0xEFAC, 0xC148,
0x8690, 0xE1A4, 0xC748, 0xF1D2, 0x9E90, 0xE7A4, 0xDF48, 0xF7D2, 0xC1AC, 0x8758,
0xE1D6, 0xC7AC, 0x9F58, 0xE7D6, 0xDFAC, 0x8348, 0xC3A4, 0x8F48, 0xE3D2, 0xCFA4,
0xBF48, 0xEFD2, 0xE960, 0xFA58, 0xD6C0, 0xF5B0, 0xFD6C, 0xD240, 0xF490, 0xFD24,
0xEB20, 0xFAC8, 0x92C0, 0xE4B0, 0xF92C, 0xD960, 0xF658, 0xFD96, 0xCB60, 0xF2D8,
0xB6C0, 0xC920, 0xF248, 0xB240, 0xEC90, 0xFB24, 0x9640, 0xE590, 0xF964, 0xDB20,
0xF6C8, 0xFDB2, 0x8960, 0xE258, 0xCCB0, 0xF32C, 0xB960, 0xEE58, 0xFB96, 0xC5B0,
0xF16C, 0x9B60, 0xC490, 0xF124, 0x9920, 0xE648, 0xF992, 0xDC90, 0xF724, 0x8B20,
0xE2C8, 0xCD90, 0xF364, 0xBB20, 0xEEC8, 0xFBB2, 0x84B0, 0xE12C, 0xC658, 0xF196,
0x9CB0, 0xE72C, 0xDE58, 0xF796, 0xC2D8, 0x8DB0, 0xC248, 0x8C90, 0xE324, 0xBDB0,
0xCE48, 0xF392, 0xBC90, 0xEF24, 0x8590, 0xE164, 0xC6C8, 0xF1B2, 0x9D90, 0xE764,
0xDEC8, 0xF7B2, 0x8258, 0xC32C, 0x8E58, 0xE396, 0xCF2C, 0xBE58, 0xEF96, 0xC16C,
0x86D8, 0xC124, 0x8648, 0xE192, 0x9ED8, 0xC724, 0x9E48, 0xE792, 0xDF24, 0x82C8,
0xC364, 0x8EC8, 0xE3B2, 0xCF64, 0xBEC8, 0xEFB2, 0x812C, 0xC196, 0x872C, 0xC796,
0x9F2C, 0x836C, 0x8324, 0x8F6C, 0xC392, 0x8F24, 0xBF6C, 0xCF92, 0x8164, 0xC1B2,
0x8764, 0xC7B2, 0x9F64, 0xDFB2, 0xA2C0, 0xE8B0, 0xFA2C, 0xD360, 0xF4D8, 0xFD36,
0xD120, 0xF448, 0xFD12, 0xAEC0, 0xEBB0, 0xFAEC, 0xA640, 0xE990, 0xFA64, 0xD720,
0xF5C8, 0xFD72, 0x9160, 0xE458, 0xF916, 0xD8B0, 0xF62C, 0xC9B0, 0xF26C, 0xB360,
0xC890, 0xF224, 0xB120, 0xEC48, 0xFB12, 0x9760, 0xE5D8, 0xF976, 0x9320, 0xE4C8,
0xF932, 0xD990, 0xF664, 0xCB90, 0xF2E4, 0xB720, 0xEDC8, 0xFB72, 0x88B0, 0xE22C,
0xCC58, 0xF316, 0xB8B0, 0xEE2C, 0xC4D8, 0xF136, 0x99B0, 0xC448, 0xF112, 0x9890,
0xE624, 0xDC48, 0xF712, 0x8BB0, 0xE2EC, 0x8990, 0xE264, 0xBBB0, 0xCCC8, 0xF332,
0xB990, 0xEE64, 0xC5C8, 0xF172, 0x9B90, 0xE6E4, 0xDDC8, 0xF772, 0x8458, 0xE116,
0xC62C, 0x9C58, 0xE716, 0xDE2C, 0xC26C, 0x8CD8, 0xC224, 0x8C48, 0xE312, 0xBCD8,
0xCE24, 0xBC48, 0xEF12, 0x85D8, 0xE176, 0x84C8, 0xE132, 0x9DD8, 0xC664, 0x9CC8,
0xE732, 0xDE64, 0xC2E4, 0x8DC8, 0xE372, 0xCEE4, 0xBDC8, 0xEF72, 0x822C, 0xC316,
0x8E2C, 0xCF16, 0xC136, 0x866C, 0xC112, 0x8624, 0x9E6C, 0xC712, 0x9E24, 0x82EC,
0x8264, 0x8EEC, 0xC332, 0x8E64, 0xBEEC, 0xCF32, 0xBE64, 0xC172, 0x86E4, 0xC772,
0x9EE4, 0xDF72, 0x8116, 0x8716, 0x8336, 0x8312, 0x8F36, 0x8F12, 0x8176, 0x8132,
0x8776, 0x8732, 0x9F76, 0x9F32, 0x8372, 0x8F72, 0xBF72, 0xA160, 0xE858, 0xFA16,
0xD1B0, 0xF46C, 0xD090, 0xF424, 0xA760, 0xE9D8, 0xFA76, 0xA320, 0xE8C8, 0xFA32,
0xD7B0, 0xF5EC, 0xD390, 0xF4E4, 0xAF20, 0xEBC8, 0xFAF2, 0x90B0, 0xE42C, 0xD858,
0xF616, 0xC8D8, 0xF236, 0xB1B0, 0xC848, 0xF212, 0xB090, 0xEC24, 0x93B0, 0xE4EC,
0x9190, 0xE464, 0xD8C8, 0xF632, 0xCBD8, 0xF2F6, 0xB7B0, 0xC9C8, 0xF272, 0xB390,
0xECE4, 0x9790, 0xE5E4, 0xDBC8, 0xF6F2, 0x8858, 0xE216, 0xCC2C, 0xB858, 0xEE16,
0xC46C, 0x98D8, 0xC424, 0x9848, 0xE612, 0xDC24, 0x89D8, 0xE276, 0x88C8, 0xE232,
0xB9D8, 0xCC64, 0xB8C8, 0xEE32, 0xC5EC, 0x9BD8, 0xC4E4, 0x99C8, 0xE672, 0xDCE4,
0x8BC8, 0xE2F2, 0xCDE4, 0xBBC8, 0xEEF2, 0x842C, 0xC616, 0x9C2C, 0xC236, 0x8C6C,
0xC212, 0x8C24, 0xBC6C, 0xCE12, 0x84EC, 0x8464, 0x9CEC, 0xC632, 0x9C64, 0xDE32,
0xC2F6, 0x8DEC, 0xC272, 0x8CE4, 0xBDEC, 0xCE72, 0xBCE4, 0x85E4, 0xC6F2, 0x9DE4,
0xDEF2, 0x8216, 0x8E16, 0x8636, 0x8612, 0x9E36, 0x8276, 0x8232, 0x8E76, 0x8E32,
0xBE76, 0x86F6, 0x8672, 0x9EF6, 0x9E72, 0x82F2, 0x8EF2, 0xBEF2, 0xA0B0, 0xE82C,
0xD0D8, 0xF436, 0xD048, 0xF412, 0xA3B0, 0xE8EC, 0xA190, 0xE864, 0xD3D8, 0xF4F6,
0xD1C8, 0xF472, 0xAFB0, 0xEBEC, 0xA790, 0xE9E4, 0xD7C8, 0xF5F2, 0x9058, 0xE416,
0xD82C, 0xC86C, 0xB0D8, 0xC824, 0xB048, 0xEC12, 0x91D8, 0xE476, 0x90C8, 0xE432,
0xD864, 0xC9EC, 0xB3D8, 0xC8E4, 0xB1C8, 0xEC72, 0x97D8, 0xE5F6, 0x93C8, 0xE4F2,
0xD9E4, 0xCBE4, 0xB7C8, 0xEDF2, 0x882C, 0xCC16, 0xC436, 0x986C, 0xC412, 0x9824,
0x88EC, 0x8864, 0xB8EC, 0xCC32, 0xB864, 0xC4F6, 0x99EC, 0xC472, 0x98E4, 0xDC72,
0x8BEC, 0x89E4, 0xBBEC, 0xCCF2, 0xB9E4, 0xC5F2, 0x9BE4, 0xDDF2, 0x8416, 0x8C36,
0x8C12, 0x8476, 0x8432, 0x9C76, 0x9C32, 0x8CF6, 0x8C72, 0xBCF6, 0xBC72, 0x85F6,
0x84F2, 0x9DF6, 0x9CF2, 0x8DF2, 0xBDF2, 0xA058, 0xE816, 0xD06C, 0xD024, 0xA1D8,
0xE876, 0xA0C8, 0xE832, 0xD1EC, 0xD0E4, 0xA7D8, 0xE9F6, 0xA3C8, 0xE8F2, 0xD7EC,
0xD3E4, 0x902C, 0xC836, 0xB06C, 0xC812, 0x90EC, 0x9064, 0xD832, 0xC8F6, 0xB1EC,
0xC872, 0xB0E4, 0x93EC, 0x91E4, 0xD8F2, 0xCBF6, 0xB7EC, 0xC9F2, 0xB3E4, 0x8816,
0x9836, 0x8876, 0x8832, 0xB876, 0x98F6, 0x9872, 0x89F6, 0x88F2, 0xB9F6, 0xB8F2,
0x9BF6, 0x99F2, 0xEA60, 0xFA98, 0xD440, 0xF510, 0xFD44, 0xED70, 0xFB5C, 0x94C0,
0xE530, 0xF94C, 0xDA60, 0xF698, 0xFDA6, 0xCA20, 0xF288, 0xB440, 0xED10, 0xFB44,
0x9AE0, 0xE6B8, 0xF9AE, 0xDD70, 0xF75C, 0x8A60, 0xE298, 0xCD30, 0xF34C, 0xBA60,
0xEE98, 0xFBA6, 0xC510, 0xF144, 0x9A20, 0xE688, 0xF9A2, 0xDD10, 0xF744, 0x8D70,
0xE35C, 0xCEB8, 0xF3AE, 0xBD70, 0xEF5C, 0x8530, 0xE14C, 0xC698, 0xF1A6, 0x9D30,
0xE74C, 0xDE98, 0xF7A6, 0xC288, 0x8D10, 0xE344, 0xCE88, 0xF3A2, 0xBD10, 0xEF44,
0x86B8, 0xE1AE, 0xC75C, 0x9EB8, 0xE7AE, 0xDF5C, 0x8298, 0xC34C, 0x8E98, 0xE3A6,
0xCF4C, 0xBE98, 0xEFA6, 0xC144, 0x8688, 0xE1A2, 0xC744, 0x9E88, 0xE7A2, 0xDF44,
0x835C, 0xC3AE, 0x8F5C, 0xCFAE, 0xBF5C, 0x814C, 0xC1A6, 0x874C, 0xC7A6, 0x9F4C,
0xDFA6, 0x8344, 0xC3A2, 0x8F44, 0xCFA2, 0xBF44, 0xD2E0, 0xF4B8, 0xFD2E, 0xADC0,
0xEB70, 0xFADC, 0xA4C0, 0xE930, 0xFA4C, 0xD660, 0xF598, 0xFD66, 0xD220, 0xF488,
0xFD22, 0xAC40, 0xEB10, 0xFAC4, 0xC970, 0xF25C, 0xB2E0, 0xECB8, 0xFB2E, 0x96E0,
0xE5B8, 0xF96E, 0x9260, 0xE498, 0xF926, 0xD930, 0xF64C, 0xCB30, 0xF2CC, 0xB660,
0xC910, 0xF244, 0xB220, 0xEC88, 0xFB22, 0x9620, 0xE588, 0xF962, 0xDB10, 0xF6C4,
0xC4B8, 0xF12E, 0x9970, 0xE65C, 0xDCB8, 0xF72E, 0x8B70, 0xE2DC, 0x8930, 0xE24C,
0xBB70, 0xCC98, 0xF326, 0xB930, 0xEE4C, 0xC598, 0xF166, 0x9B30, 0xC488, 0xF122,
0x9910, 0xE644, 0xDC88, 0xF722, 0x8B10, 0xE2C4, 0xCD88, 0xF362, 0xBB10, 0xEEC4,
0xC25C, 0x8CB8, 0xE32E, 0xCE5C, 0xBCB8, 0xEF2E, 0x85B8, 0xE16E, 0x8498, 0xE126,
0x9DB8, 0xC64C, 0x9C98, 0xE726, 0xDE4C, 0xC2CC, 0x8D98, 0xC244, 0x8C88, 0xE322,
0xBD98, 0xCE44, 0xBC88, 0xEF22, 0x8588, 0xE162, 0xC6C4, 0x9D88, 0xE762, 0xDEC4,
0xC12E, 0x865C, 0xC72E, 0x9E5C, 0xDF2E, 0x82DC, 0x824C, 0x8EDC, 0xC326, 0x8E4C,
0xBEDC, 0xCF26, 0xBE4C, 0xC166, 0x86CC, 0xC122, 0x8644, 0x9ECC, 0xC722, 0x9E44,
0xDF22, 0x82C4, 0xC362, 0x8EC4, 0xCF62, 0xBEC4, 0x832E, 0x8F2E, 0x816E, 0x8126,
0x876E, 0x8726, 0x9F6E, 0x9F26, 0x8366, 0x8322, 0x8F66, 0x8F22, 0xBF66, 0x8162,
0x8762, 0x9F62, 0xD170, 0xF45C, 0xA6E0, 0xE9B8, 0xFA6E, 0xA260, 0xE898, 0xFA26,
0xD770, 0xF5DC, 0xD330, 0xF4CC, 0xD110, 0xF444, 0xAE60, 0xEB98, 0xFAE6, 0xA620,
0xE988, 0xFA62, 0xD710, 0xF5C4, 0xC8B8, 0xF22E, 0xB170, 0xEC5C, 0x9370, 0xE4DC,
0x9130, 0xE44C, 0xD898, 0xF626, 0xCBB8, 0xF2EE, 0xB770, 0xC998, 0xF266, 0xB330,
0xC888, 0xF222, 0xB110, 0xEC44, 0x9730, 0xE5CC, 0x9310, 0xE4C4, 0xD988, 0xF662,
0xCB88, 0xF2E2, 0xB710, 0xEDC4, 0xC45C, 0x98B8, 0xE62E, 0xDC5C, 0x89B8, 0xE26E,
0x8898, 0xE226, 0xB9B8, 0xCC4C, 0xB898, 0xEE26, 0xC5DC, 0x9BB8, 0xC4CC, 0x9998,
0xC444, 0x9888, 0xE622, 0xDC44, 0x8B98, 0xE2E6, 0x8988, 0xE262, 0xBB98, 0xCCC4,
0xB988, 0xEE62, 0xC5C4, 0x9B88, 0xE6E2, 0xDDC4, 0xC22E, 0x8C5C, 0xCE2E, 0xBC5C,
0x84DC, 0x844C, 0x9CDC, 0xC626, 0x9C4C, 0xDE26, 0xC2EE, 0x8DDC, 0xC266, 0x8CCC,
0xC222, 0xBDDC, 0x8C44, 0xBCCC, 0xCE22, 0xBC44, 0x85CC, 0x84C4, 0x9DCC, 0xC662,
0x9CC4, 0xDE62, 0xC2E2, 0x8DC4, 0xCEE2, 0xBDC4, 0x862E, 0x9E2E, 0x826E, 0x8226,
0x8E6E, 0x8E26, 0xBE6E, 0x86EE, 0x8666, 0x9EEE, 0x8622, 0x9E66, 0x9E22, 0x82E6,
0x8262, 0x8EE6, 0x8E62, 0xBEE6, 0xBE62, 0x86E2, 0x9EE2, 0xD0B8, 0xF42E, 0xA370,
0xE8DC, 0xA130, 0xE84C, 0xD3B8, 0xF4EE, 0xD198, 0xF466, 0xD088, 0xF422, 0xAF70,
0xEBDC, 0xA730, 0xE9CC, 0xA310, 0xE8C4, 0xD798, 0xF5E6, 0xD388, 0xF4E2, 0xAF10,
0xEBC4, 0xC85C, 0xB0B8, 0xEC2E, 0x91B8, 0xE46E, 0x9098, 0xE426, 0xD84C, 0xC9DC,
0xB3B8, 0xC8CC, 0xB198, 0xC844, 0xB088, 0xEC22, 0x97B8, 0xE5EE, 0x9398, 0xE4E6,
0x9188, 0xE462, 0xD8C4, 0xCBCC, 0xB798, 0xC9C4, 0xB388, 0xECE2, 0x9788, 0xE5E2,
0xDBC4, 0xC42E, 0x985C, 0xDC2E, 0x88DC, 0x884C, 0xB8DC, 0xCC26, 0xB84C, 0xC4EE,
0x99DC, 0xC466, 0x98CC, 0xC422, 0x9844, 0xDC22, 0x8BDC, 0x89CC, 0xBBDC, 0x88C4,
0xB9CC, 0xCC62, 0xB8C4, 0xC5E6, 0x9BCC, 0xC4E2, 0x99C4, 0xDCE2, 0x8BC4, 0xCDE2,
0xBBC4, 0x8C2E, 0x846E, 0x8426, 0x9C6E, 0x9C26, 0x8CEE, 0x8C66, 0xBCEE, 0x8C22,
0xBC66, 0x85EE, 0x84E6, 0x9DEE, 0x8462, 0x9CE6, 0x9C62, 0x8DE6, 0x8CE2, 0xBDE6,
0xBCE2, 0x85E2, 0x9DE2, 0xD05C, 0xA1B8, 0xE86E, 0xA098, 0xE826, 0xD1DC, 0xD0CC,
0xD044, 0xA7B8, 0xE9EE, 0xA398, 0xE8E6, 0xA188, 0xE862, 0xD7DC, 0xD3CC, 0xD1C4,
0xAF98, 0xEBE6, 0xA788, 0xE9E2, 0xC82E, 0xB05C, 0x90DC, 0x904C, 0xD826, 0xC8EE,
0xB1DC, 0xC866, 0xB0CC, 0xC822, 0xB044, 0x93DC, 0x91CC, 0x90C4, 0xD862, 0xCBEE,
0xB7DC, 0xC9E6, 0xB3CC, 0xC8E2, 0xB1C4, 0x97CC, 0x93C4, 0xD9E2, 0x982E, 0x886E,
0x8826, 0xB86E, 0x98EE, 0x9866, 0x9822, 0x89EE, 0x88E6, 0xB9EE, 0x8862, 0xB8E6,
0xB862, 0x9BEE, 0x99E6, 0x98E2, 0x8BE6, 0x89E2, 0xBBE6, 0xB9E2, 0xD02E, 0xA0DC,
0xA04C, 0xD0EE, 0xD066, 0xD022, 0xA3DC, 0xA1CC, 0xA0C4, 0xD3EE, 0xD1E6, 0xD0E2,
0xAFDC, 0xA7CC, 0xA3C4, 0x906E, 0x9026, 0xB0EE, 0xB066, 0x91EE, 0x90E6, 0x9062,
0xB3EE, 0xB1E6, 0xB0E2, 0x97EE, 0x93E6, 0x91E2, 0xD4E0, 0xF538, 0xFD4E, 0xA8C0,
0xEA30, 0xFA8C, 0xD420, 0xF508, 0xFD42, 0xDAF0, 0xF6BC, 0xCA70, 0xF29C, 0xB4E0,
0xED38, 0xFB4E, 0x9460, 0xE518, 0xF946, 0xDA30, 0xF68C, 0xCA10, 0xF284, 0xB420,
0xED08, 0xFB42, 0xCD78, 0xF35E, 0xBAF0, 0xEEBC, 0xC538, 0xF14E, 0x9A70, 0xE69C,
0xDD38, 0xF74E, 0x8A30, 0xE28C, 0xCD18, 0xF346, 0xBA30, 0xEE8C, 0xC508, 0xF142,
0x9A10, 0xE684, 0xDD08, 0xF742, 0xC6BC, 0x9D78, 0xE75E, 0xDEBC, 0xC29C, 0x8D38,
0xE34E, 0xCE9C, 0xBD38, 0xEF4E, 0x8518, 0xE146, 0xC68C, 0x9D18, 0xE746, 0xDE8C,
0xC284, 0x8D08, 0xE342, 0xCE84, 0xBD08, 0xEF42, 0xC35E, 0x8EBC, 0xCF5E, 0xBEBC,
0xC14E, 0x869C, 0xC74E, 0x9E9C, 0xDF4E, 0x828C, 0xC346, 0x8E8C, 0xCF46, 0xBE8C,
0xC142, 0x8684, 0xC742, 0x9E84, 0xDF42, 0x875E, 0x9F5E, 0x834E, 0x8F4E, 0xBF4E,
0x8146, 0x8746, 0x9F46, 0x8342, 0x8F42, 0xBF42, 0xE978, 0xFA5E, 0xD6F0, 0xF5BC,
0xD270, 0xF49C, 0xACE0, 0xEB38, 0xFACE, 0xA460, 0xE918, 0xFA46, 0xD630, 0xF58C,
0xD210, 0xF484, 0xAC20, 0xEB08, 0xFAC2, 0x92F0, 0xE4BC, 0xD978, 0xF65E, 0xCB78,
0xF2DE, 0xB6F0, 0xC938, 0xF24E, 0xB270, 0xEC9C, 0x9670, 0xE59C, 0x9230, 0xE48C,
0xD918, 0xF646, 0xCB18, 0xF2C6, 0xB630, 0xC908, 0xF242, 0xB210, 0xEC84, 0x9610,
0xE584, 0xDB08, 0xF6C2, 0x8978, 0xE25E, 0xCCBC, 0xB978, 0xEE5E, 0xC5BC, 0x9B78,
0xC49C, 0x9938, 0xE64E, 0xDC9C, 0x8B38, 0xE2CE, 0x8918, 0xE246, 0xBB38, 0xCC8C,
0xB918, 0xEE46, 0xC58C, 0x9B18, 0xC484, 0x9908, 0xE642, 0xDC84, 0x8B08, 0xE2C2,
0xCD84, 0xBB08, 0xEEC2, 0x84BC, 0xC65E, 0x9CBC, 0xDE5E, 0xC2DE, 0x8DBC, 0xC24E,
0x8C9C, 0xBDBC, 0xCE4E, 0xBC9C, 0x859C, 0x848C, 0x9D9C, 0xC646, 0x9C8C, 0xDE46,
0xC2C6, 0x8D8C, 0xC242, 0x8C84, 0xBD8C, 0xCE42, 0xBC84, 0x8584, 0xC6C2, 0x9D84,
0xDEC2, 0x825E, 0x8E5E, 0xBE5E, 0x86DE, 0x864E, 0x9EDE, 0x9E4E, 0x82CE, 0x8246,
0x8ECE, 0x8E46, 0xBECE, 0xBE46, 0x86C6, 0x8642, 0x9EC6, 0x9E42, 0x82C2, 0x8EC2,
0xBEC2, 0xA2F0, 0xE8BC, 0xD378, 0xF4DE, 0xD138, 0xF44E, 0xAEF0, 0xEBBC, 0xA670,
0xE99C, 0xA230, 0xE88C, 0xD738, 0xF5CE, 0xD318, 0xF4C6, 0xD108, 0xF442, 0xAE30,
0xEB8C, 0xA610, 0xE984, 0xD708, 0xF5C2, 0x9178, 0xE45E, 0xD8BC, 0xC9BC, 0xB378,
0xC89C, 0xB138, 0xEC4E, 0x9778, 0xE5DE, 0x9338, 0xE4CE, 0x9118, 0xE446, 0xD88C,
0xCB9C, 0xB738, 0xC98C, 0xB318, 0xC884, 0xB108, 0xEC42, 0x9718, 0xE5C6, 0x9308,
0xE4C2, 0xD984, 0xCB84, 0xB708, 0xEDC2, 0x88BC, 0xCC5E, 0xB8BC, 0xC4DE, 0x99BC,
0xC44E, 0x989C, 0xDC4E, 0x8BBC, 0x899C, 0xBBBC, 0x888C, 0xB99C, 0xCC46, 0xB88C,
0xC5CE, 0x9B9C, 0xC4C6, 0x998C, 0xC442, 0x9884, 0xDC42, 0x8B8C, 0x8984, 0xBB8C,
0xCCC2, 0xB984, 0xC5C2, 0x9B84, 0xDDC2, 0x845E, 0x9C5E, 0x8CDE, 0x8C4E, 0xBCDE,
0xBC4E, 0x85DE, 0x84CE, 0x9DDE, 0x8446, 0x9CCE, 0x9C46, 0x8DCE, 0x8CC6, 0xBDCE,
0x8C42, 0xBCC6, 0xBC42, 0x85C6, 0x84C2, 0x9DC6, 0x9CC2, 0x8DC2, 0xBDC2, 0xA178,
0xE85E, 0xD1BC, 0xD09C, 0xA778, 0xE9DE, 0xA338, 0xE8CE, 0xA118, 0xE846, 0xD7BC,
0xD39C, 0xD18C, 0xD084, 0xAF38, 0xEBCE, 0xA718, 0xE9C6, 0xA308, 0xE8C2, 0xD78C,
0xD384, 0x90BC, 0xD85E, 0xC8DE, 0xB1BC, 0xC84E, 0xB09C, 0x93BC, 0x919C, 0x908C,
0xD846, 0xCBDE, 0xB7BC, 0xC9CE, 0xB39C, 0xC8C6, 0xB18C, 0xC842, 0xB084, 0x979C,
0x938C, 0x9184, 0xD8C2, 0xCBC6, 0xB78C, 0xC9C2, 0xB384, 0x885E, 0xB85E, 0x98DE,
0x984E, 0x89DE, 0x88CE, 0xB9DE, 0x8846, 0xB8CE, 0xB846, 0x9BDE, 0x99CE, 0x98C6,
0x9842, 0x8BCE, 0x89C6, 0xBBCE, 0x88C2, 0xB9C6, 0xB8C2, 0x9BC6, 0x99C2, 0xA0BC,
0xD0DE, 0xD04E, 0xA3BC, 0xA19C, 0xA08C, 0xD3DE, 0xD1CE, 0xD0C6, 0xD042, 0xAFBC,
0xA79C, 0xA38C, 0xA184, 0xD7CE, 0xD3C6, 0xD1C2, 0x905E, 0xB0DE, 0xB04E, 0x91DE,
0x90CE, 0x9046, 0xB3DE, 0xB1CE, 0xB0C6, 0xB042, 0x97DE, 0x93CE, 0x91C6, 0x90C2,
0xB7CE, 0xB3C6, 0xB1C2, 0xA05E, 0xA1DE, 0xA0CE, 0xA046, 0xA7DE, 0xA3CE, 0xA1C6,
0xA0C2, 0xA9E0, 0xEA78, 0xFA9E, 0xD470, 0xF51C, 0xA860, 0xEA18, 0xFA86, 0xD410,
0xF504, 0xED7C, 0x94F0, 0xE53C, 0xDA78, 0xF69E, 0xCA38, 0xF28E, 0xB470, 0xED1C,
0x9430, 0xE50C, 0xDA18, 0xF686, 0xCA08, 0xF282, 0xB410, 0xED04, 0x9AF8, 0xE6BE,
0xDD7C, 0x8A78, 0xE29E, 0xCD3C, 0xBA78, 0xEE9E, 0xC51C, 0x9A38, 0xE68E, 0xDD1C,
0x8A18, 0xE286, 0xCD0C, 0xBA18, 0xEE86, 0xC504, 0x9A08, 0xE682, 0xDD04, 0x8D7C,
0xCEBE, 0xBD7C, 0x853C, 0xC69E, 0x9D3C, 0xDE9E, 0xC28E, 0x8D1C, 0xCE8E, 0xBD1C,
0x850C, 0xC686, 0x9D0C, 0xDE86, 0xC282, 0x8D04, 0xCE82, 0xBD04, 0x86BE, 0x9EBE,
0x829E, 0x8E9E, 0xBE9E, 0x868E, 0x9E8E, 0x8286, 0x8E86, 0xBE86, 0x8682, 0x9E82,
0xD2F8, 0xF4BE, 0xADF0, 0xEB7C, 0xA4F0, 0xE93C, 0xD678, 0xF59E, 0xD238, 0xF48E,
0xAC70, 0xEB1C, 0xA430, 0xE90C, 0xD618, 0xF586, 0xD208, 0xF482, 0xAC10, 0xEB04,
0xC97C, 0xB2F8, 0xECBE, 0x96F8, 0xE5BE, 0x9278, 0xE49E, 0xD93C, 0xCB3C, 0xB678,
0xC91C, 0xB238, 0xEC8E, 0x9638, 0xE58E, 0x9218, 0xE486, 0xD90C, 0xCB0C, 0xB618,
0xC904, 0xB208, 0xEC82, 0x9608, 0xE582, 0xDB04, 0xC4BE, 0x997C, 0xDCBE, 0x8B7C,
0x893C, 0xBB7C, 0xCC9E, 0xB93C, 0xC59E, 0x9B3C, 0xC48E, 0x991C, 0xDC8E, 0x8B1C,
0x890C, 0xBB1C, 0xCC86, 0xB90C, 0xC586, 0x9B0C, 0xC482, 0x9904, 0xDC82, 0x8B04,
0xCD82, 0xBB04, 0x8CBE, 0xBCBE, 0x85BE, 0x849E, 0x9DBE, 0x9C9E, 0x8D9E, 0x8C8E,
0xBD9E, 0xBC8E, 0x858E, 0x8486, 0x9D8E, 0x9C86, 0x8D86, 0x8C82, 0xBD86, 0xBC82,
0x8582, 0x9D82, 0xD17C, 0xA6F8, 0xE9BE, 0xA278, 0xE89E, 0xD77C, 0xD33C, 0xD11C,
0xAE78, 0xEB9E, 0xA638, 0xE98E, 0xA218, 0xE886, 0xD71C, 0xD30C, 0xD104, 0xAE18,
0xEB86, 0xA608, 0xE982, 0xC8BE, 0xB17C, 0x937C, 0x913C, 0xD89E, 0xCBBE, 0xB77C,
0xC99E, 0xB33C, 0xC88E, 0xB11C, 0x973C, 0x931C, 0x910C, 0xD886, 0xCB8E, 0xB71C,
0xC986, 0xB30C, 0xC882, 0xB104, 0x970C, 0x9304, 0xD982, 0x98BE, 0x89BE, 0x889E,
0xB9BE, 0xB89E, 0x9BBE, 0x999E, 0x988E, 0x8B9E, 0x898E, 0xBB9E, 0x8886, 0xB98E,
0xB886, 0x9B8E, 0x9986, 0x9882, 0x8B86, 0x8982, 0xBB86, 0xB982, 0xD0BE, 0xA37C,
0xA13C, 0xD3BE, 0xD19E, 0xD08E, 0xAF7C, 0xA73C, 0xA31C, 0xA10C, 0xD79E, 0xD38E,
0xD186, 0xD082, 0xAF1C, 0xA70C, 0xA304, 0xB0BE, 0x91BE, 0x909E, 0xB3BE, 0xB19E,
0xB08E, 0x97BE, 0x939E, 0x918E, 0x9086, 0xB79E, 0xB38E, 0xB186, 0xB082, 0x978E,
0x9386, 0x9182, 0xA1BE, 0xA09E, 0xA7BE, 0xA39E, 0xA18E, 0xA086, 0xAF9E, 0xA78E,
0xA386, 0xA182, 0xD4F8, 0xF53E, 0xA8F0, 0xEA3C, 0xD438, 0xF50E, 0xA830, 0xEA0C,
0xD408, 0xF502, 0xDAFC, 0xCA7C, 0xB4F8, 0xED3E, 0x9478, 0xE51E, 0xDA3C, 0xCA1C,
0xB438, 0xED0E, 0x9418, 0xE506, 0xDA0C, 0xCA04, 0xB408, 0xED02, 0xCD7E, 0xBAFC,
0xC53E, 0x9A7C, 0xDD3E, 0x8A3C, 0xCD1E, 0xBA3C, 0xC50E, 0x9A1C, 0xDD0E, 0x8A0C,
0xCD06, 0xBA0C, 0xC502, 0x9A04, 0xDD02, 0x9D7E, 0x8D3E, 0xBD3E, 0x851E, 0x9D1E,
0x8D0E, 0xBD0E, 0x8506, 0x9D06, 0x8D02, 0xBD02, 0xE97E, 0xD6FC, 0xD27C, 0xACF8,
0xEB3E, 0xA478, 0xE91E, 0xD63C, 0xD21C, 0xAC38, 0xEB0E, 0xA418, 0xE906, 0xD60C,
0xD204, 0x92FC, 0xD97E, 0xCB7E, 0xB6FC, 0xC93E, 0xB27C, 0x967C, 0x923C, 0xD91E,
0xCB1E, 0xB63C, 0xC90E, 0xB21C, 0x961C, 0x920C, 0xD906, 0xCB06, 0xB60C, 0xC902,
0xB204, 0x897E, 0xB97E, 0x9B7E, 0x993E, 0x8B3E, 0x891E, 0xBB3E, 0xB91E, 0x9B1E,
0x990E, 0x8B0E, 0x8906, 0xBB0E, 0xB906, 0x9B06, 0x9902, 0xA2FC, 0xD37E, 0xD13E,
0xAEFC
};

317
3rdparty/zint-2.6.1/backend/common.c vendored Normal file
View File

@ -0,0 +1,317 @@
/* common.c - Contains functions needed for a number of barcodes */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
/* Local replacement for strlen() with unsigned char strings */
size_t ustrlen(const unsigned char data[]) {
return strlen((const char*) data);
}
/* Converts a character 0-9 to its equivalent integer value */
int ctoi(const char source) {
if ((source >= '0') && (source <= '9'))
return (source - '0');
return (source - 'A' + 10);
}
/* Convert an integer value to a string representing its binary equivalent */
void bin_append(const int arg, const int length, char *binary) {
int i;
int start;
size_t posn = strlen(binary);
start = 0x01 << (length - 1);
for (i = 0; i < length; i++) {
binary[posn + i] = '0';
if (arg & (start >> i)) {
binary[posn + i] = '1';
}
}
binary[posn + length] = '\0';
return;
}
/* Converts an integer value to its hexadecimal character */
char itoc(const int source) {
if ((source >= 0) && (source <= 9)) {
return ('0' + source);
} else {
return ('A' + (source - 10));
}
}
/* Converts lower case characters to upper case in a string source[] */
void to_upper(unsigned char source[]) {
size_t i, src_len = ustrlen(source);
for (i = 0; i < src_len; i++) {
if ((source[i] >= 'a') && (source[i] <= 'z')) {
source [i] = (source[i] - 'a') + 'A';
}
}
}
/* Verifies that a string only uses valid characters */
int is_sane(const char test_string[], const unsigned char source[], const size_t length) {
unsigned int j, latch;
size_t i, lt = strlen(test_string);
for (i = 0; i < length; i++) {
latch = FALSE;
for (j = 0; j < lt; j++) {
if (source[i] == test_string[j]) {
latch = TRUE;
break;
}
}
if (!(latch)) {
return ZINT_ERROR_INVALID_DATA;
}
}
return 0;
}
/* Replaces huge switch statements for looking up in tables */
void lookup(const char set_string[], const char *table[], const char data, char dest[]) {
size_t i, n = strlen(set_string);
for (i = 0; i < n; i++) {
if (data == set_string[i]) {
strcat(dest, table[i]);
}
}
}
/* Returns the position of data in set_string */
int posn(const char set_string[], const char data) {
int i, n = (int)strlen(set_string);
for (i = 0; i < n; i++) {
if (data == set_string[i]) {
return i;
}
}
return -1;
}
/* Return true (1) if a module is dark/black, otherwise false (0) */
int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
return (symbol->encoded_data[y_coord][x_coord / 7] >> (x_coord % 7)) & 1;
}
/* Set a module to dark/black */
void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
symbol->encoded_data[y_coord][x_coord / 7] |= 1 << (x_coord % 7);
}
/* Set (or unset) a module to white */
void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
symbol->encoded_data[y_coord][x_coord / 7] &= ~(1 << (x_coord % 7));
}
/* Expands from a width pattern to a bit pattern */
void expand(struct zint_symbol *symbol, const char data[]) {
size_t reader, n = strlen(data);
int writer, i;
char latch;
writer = 0;
latch = '1';
for (reader = 0; reader < n; reader++) {
for (i = 0; i < ctoi(data[reader]); i++) {
if (latch == '1') {
set_module(symbol, symbol->rows, writer);
}
writer++;
}
latch = (latch == '1' ? '0' : '1');
}
if (symbol->symbology != BARCODE_PHARMA) {
if (writer > symbol->width) {
symbol->width = writer;
}
} else {
/* Pharmacode One ends with a space - adjust for this */
if (writer > symbol->width + 2) {
symbol->width = writer - 2;
}
}
symbol->rows = symbol->rows + 1;
}
/* Indicates which symbologies can have row binding */
int is_stackable(const int symbology) {
if (symbology < BARCODE_PDF417) {
return 1;
}
switch (symbology) {
case BARCODE_CODE128B:
case BARCODE_ISBNX:
case BARCODE_EAN14:
case BARCODE_NVE18:
case BARCODE_KOREAPOST:
case BARCODE_PLESSEY:
case BARCODE_TELEPEN_NUM:
case BARCODE_ITF14:
case BARCODE_CODE32:
case BARCODE_CODABLOCKF:
return 1;
}
return 0;
}
/* Indicates which symbols can have addon (EAN-2 and EAN-5) */
int is_extendable(const int symbology) {
if (symbology == BARCODE_EANX) {
return 1;
}
if (symbology == BARCODE_UPCA) {
return 1;
}
if (symbology == BARCODE_UPCE) {
return 1;
}
if (symbology == BARCODE_ISBNX) {
return 1;
}
if (symbology == BARCODE_UPCA_CC) {
return 1;
}
if (symbology == BARCODE_UPCE_CC) {
return 1;
}
if (symbology == BARCODE_EANX_CC) {
return 1;
}
return 0;
}
int istwodigits(const unsigned char source[], const size_t position) {
if ((source[position] >= '0') && (source[position] <= '9')) {
if ((source[position + 1] >= '0') && (source[position + 1] <= '9')) {
return 1;
}
}
return 0;
}
int utf8toutf16(struct zint_symbol *symbol, const unsigned char source[], int vals[], size_t *length) {
size_t bpos;
int jpos, error_number;
int next;
bpos = 0;
jpos = 0;
error_number = 0;
next = 0;
do {
if (source[bpos] <= 0x7f) {
/* 1 byte mode (7-bit ASCII) */
vals[jpos] = source[bpos];
next = bpos + 1;
jpos++;
} else {
if ((source[bpos] >= 0x80) && (source[bpos] <= 0xbf)) {
strcpy(symbol->errtxt, "240: Corrupt Unicode data");
return ZINT_ERROR_INVALID_DATA;
}
if ((source[bpos] >= 0xc0) && (source[bpos] <= 0xc1)) {
strcpy(symbol->errtxt, "241: Overlong encoding not supported");
return ZINT_ERROR_INVALID_DATA;
}
if ((source[bpos] >= 0xc2) && (source[bpos] <= 0xdf)) {
/* 2 byte mode */
vals[jpos] = ((source[bpos] & 0x1f) << 6) + (source[bpos + 1] & 0x3f);
next = bpos + 2;
jpos++;
} else
if ((source[bpos] >= 0xe0) && (source[bpos] <= 0xef)) {
/* 3 byte mode */
vals[jpos] = ((source[bpos] & 0x0f) << 12) + ((source[bpos + 1] & 0x3f) << 6) + (source[bpos + 2] & 0x3f);
next = bpos + 3;
jpos++;
} else
if (source[bpos] >= 0xf0) {
strcpy(symbol->errtxt, "242: Unicode sequences of more than 3 bytes not supported");
return ZINT_ERROR_INVALID_DATA;
}
}
bpos = next;
} while (bpos < *length);
*length = jpos;
return error_number;
}
void set_minimum_height(struct zint_symbol *symbol, const int min_height) {
/* Enforce minimum permissable height of rows */
int fixed_height = 0;
int zero_count = 0;
int i;
for (i = 0; i < symbol->rows; i++) {
fixed_height += symbol->row_height[i];
if (symbol->row_height[i] == 0) {
zero_count++;
}
}
if (zero_count > 0) {
if (((symbol->height - fixed_height) / zero_count) < min_height) {
for (i = 0; i < symbol->rows; i++) {
if (symbol->row_height[i] == 0) {
symbol->row_height[i] = min_height;
}
}
}
}
}

79
3rdparty/zint-2.6.1/backend/common.h vendored Normal file
View File

@ -0,0 +1,79 @@
/* common.h - Header for all common functions in common.c */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* Used in some logic */
#ifndef __COMMON_H
#define __COMMON_H
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
/* The most commonly used set */
#define NEON "0123456789"
#include "zint.h"
#include <stdlib.h>
#define ustrcpy(target,source) strcpy((char*)target,(const char*)source)
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern size_t ustrlen(const unsigned char source[]);
extern int ctoi(const char source);
extern char itoc(const int source);
extern void to_upper(unsigned char source[]);
extern int is_sane(const char test_string[], const unsigned char source[], const size_t length);
extern void lookup(const char set_string[], const char *table[], const char data, char dest[]);
extern void bin_append(const int arg, const int length, char *binary);
extern int posn(const char set_string[], const char data);
extern int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
extern void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
extern int istwodigits(const unsigned char source[], const size_t position);
extern int parunmodd(const unsigned char llyth);
extern void expand(struct zint_symbol *symbol, const char data[]);
extern void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
extern int is_stackable(const int symbology);
extern int is_extendable(const int symbology);
extern int utf8toutf16(struct zint_symbol *symbol, const unsigned char source[], int vals[], size_t *length);
extern void set_minimum_height(struct zint_symbol *symbol, const int min_height);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __COMMON_H */

1872
3rdparty/zint-2.6.1/backend/composite.c vendored Normal file

File diff suppressed because it is too large Load Diff

73
3rdparty/zint-2.6.1/backend/composite.h vendored Normal file
View File

@ -0,0 +1,73 @@
/* composite.c - Tables for UCC.EAN Composite Symbols */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#define NUMERIC 110
#define ALPHA 97
#define ISOIEC 105
#define INVALID_CHAR 100
#define ANY_ENC 120
#define ALPHA_OR_ISO 121
/* CC-A component coefficients from ISO/IEC 24728:2006 Annex F */
static const unsigned short int ccaCoeffs[30] = {
/* k = 4 */
522, 568, 723, 809,
/* k = 5 */
427, 919, 460, 155, 566,
/* k = 6 */
861, 285, 19, 803, 17, 766,
/* k = 7 */
76, 925, 537, 597, 784, 691, 437,
/* k = 8 */
237, 308, 436, 284, 646, 653, 428, 379
};
/* rows, error codewords, k-offset of valid CC-A sizes from ISO/IEC 24723:2006 Table 9 */
static const char ccaVariants[51] = {
5, 6, 7, 8, 9, 10, 12, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7,
4, 4, 5, 5, 6, 6, 7, 4, 5, 6, 7, 7, 4, 5, 6, 7, 8,
0, 0, 4, 4, 9, 9, 15, 0, 4, 9, 15, 15, 0, 4, 9, 15, 22
};
/* following is Left RAP, Centre RAP, Right RAP and Start Cluster from ISO/IEC 24723:2006 tables 10 and 11 */
static const char aRAPTable[68] = {
39, 1, 32, 8, 14, 43, 20, 11, 1, 5, 15, 21, 40, 43, 46, 34, 29,
0, 0, 0, 0, 0, 0, 0, 43, 33, 37, 47, 1, 20, 23, 26, 14, 9,
19, 33, 12, 40, 46, 23, 52, 23, 13, 17, 27, 33, 52, 3, 6, 46, 41,
6, 0, 3, 3, 3, 0, 3, 3, 0, 3, 6, 6, 0, 0, 0, 0, 3
};
/* Row Address Patterns are as defined in pdf417.h */

View File

@ -0,0 +1,31 @@
/* Sed: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/versions.asp */
#if defined (_WIN32) && (defined(_USRDLL) || defined(DLL_EXPORT) || defined(PIC))
#include <windows.h>
#include <shlwapi.h>
#ifdef __cplusplus
extern "C"
{
#endif
__declspec(dllexport) HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi);
#ifdef __cplusplus
}
#endif
HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi)
{
if (!pdvi || (sizeof(*pdvi) != pdvi->info1.cbSize))
return (E_INVALIDARG);
pdvi->info1.dwMajorVersion = 2;
pdvi->info1.dwMinorVersion = 2;
pdvi->info1.dwBuildNumber = 1;
pdvi->info1.dwPlatformID = DLLVER_PLATFORM_WINDOWS;
if (sizeof(DLLVERSIONINFO2) == pdvi->info1.cbSize)
pdvi->ullVersion = MAKEDLLVERULL(2, 2, 1, 0);
return S_OK;
}
#endif /* _WIN32 */

1318
3rdparty/zint-2.6.1/backend/dmatrix.c vendored Normal file

File diff suppressed because it is too large Load Diff

237
3rdparty/zint-2.6.1/backend/dmatrix.h vendored Normal file
View File

@ -0,0 +1,237 @@
/* dmatrix.h - Handles Data Matrix ECC 200 */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/*
Containes Extended Rectangular Data Matrix (DMRE)
See http://www.dmre.info for information
Contact: harald.oehlmann@eurodatacouncil.org
*/
#include "common.h"
#ifndef __IEC16022ECC200_H
#define __IEC16022ECC200_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern int data_matrix_200(struct zint_symbol *symbol, const unsigned char source[], const size_t length);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#define MAXBARCODE 3116
#define DM_NULL 0
#define DM_ASCII 1
#define DM_C40 2
#define DM_TEXT 3
#define DM_X12 4
#define DM_EDIFACT 5
#define DM_BASE256 6
static const char c40_shift[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};
static const char c40_value[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
15, 16, 17, 18, 19, 20, 21, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
};
static const char text_shift[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3
};
static const char text_value[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
15, 16, 17, 18, 19, 20, 21, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
22, 23, 24, 25, 26, 0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 27, 28, 29, 30, 31
};
// Position in option array [symbol option value - 1]
// The position in the option array is by increasing total data codewords with square first
// The last comment value is the total data codewords value.
// The index of this array is the --vers parameter value -1 and is given as forst comment value
static const unsigned short int intsymbol[] = {
0, /* 1: 10x10 , 3*/ 1, /* 2: 12x12 , 5*/ 3, /* 3: 14x14 , 8*/ 5, /* 4: 16x16 , 12*/
7, /* 5: 18x18 , 18*/ 9, /* 6: 20x20 , 22*/ 12, /* 7: 22x22 , 30*/ 14, /* 8: 24x24 , 36*/
16, /* 9: 26x26 , 44*/ 18, /* 10: 32x32 , 62*/ 21, /* 11: 36x36 , 86*/ 24, /* 12: 40x40 ,114*/
26, /* 13: 44x44 ,144*/ 27, /* 14: 48x48 ,174*/ 28, /* 15: 52x52 ,204*/ 29, /* 16: 64x64 ,280*/
30, /* 17: 72x72 ,368*/ 31, /* 18: 80x80 ,456*/ 32, /* 19: 88x88 ,576*/ 33, /* 20: 96x96 ,696*/
34, /* 21:104x104,816*/ 35, /* 22:120x120,1050*/36, /* 23:132x132,1304*/37, /* 24:144x144,1558*/
2, /* 25: 8x18 , 5*/ 4, /* 26: 8x32 , 10*/ 6, /* 27: 12x26 , 16*/ 10, /* 28: 12x36 , 22*/
13, /* 29: 16x36 , 32*/ 17, /* 30: 16x48 , 49*/ 8, /* 31: 8x48 , 18*/ 11, /* 32: 8x64 , 24*/
15, /* 33: 12x64 , 43*/ 19, /* 34: 16x64 , 62*/ 20, /* 37: 24x48 , 80*/ 23, /* 38: 24x64 ,108*/
22, /* 41: 26x48 , 90*/ 25, /* 42: 26x64 ,118*/
0
};
// Number of DM Sizes
#define DMSIZESCOUNT 38
// Number of 144x144 for special interlace
#define INTSYMBOL144 37
// Is the current code a DMRE code ?
// This is the case, if intsymbol index >= 30
static const char isDMRE[] = {
/* 0*/ 0, /* 10x10, 3 */ 0, /* 12x12 , 5 */ 0, /* 8x18 , 5 */ 0, /* 14x14 , 8 */
/* 4*/ 0, /* 8x32 ,10 */ 0, /* 16x16 ,12 */ 0, /* 12x26 ,16 */ 0, /* 18x18 ,18 */
/* 8*/ 1, /* 8x48 ,18 */ 0, /* 20x20 ,22 */ 0, /* 12x36 ,22 */ 1, /* 8x64 ,24 */
/*12*/ 0, /* 22x22 ,30 */ 0, /* 16x36 ,32 */ 0, /* 24x24 ,36 */ 1, /* 12x64 ,43 */
/*16*/ 0, /* 26x26 ,44 */ 0, /* 16x48 ,49 */ 0, /* 32x32 ,62 */ 1, /* 16x64 ,62 */
/*20*/ 1, /* 24x48 ,80 */ 0, /* 36x36 ,86 */ 1, /* 26x48 ,90 */ 1, /* 24x64 ,108*/
/*24*/ 0, /* 40x40 ,114*/ 1, /* 26x64 ,118*/ 0, /* 44x44 ,144*/ 0, /* 48x48,174 */
/*28*/ 0, /* 52x52,204 */ 0, /* 64x64,280 */ 0, /* 72x72,368 */ 0, /* 80x80,456 */
/*32*/ 0, /* 88x88,576 */ 0, /* 96x96,696 */ 0, /*104x104,816*/ 0, /*120x120,1050*/
/*36*/ 0, /*132x132,1304*/0 /*144x144,1558*/
};
// Horizontal matrix size
static const unsigned short int matrixH[] = {
/* 0*/ 10, /* 10x10 , 3 */ 12, /* 12x12 , 5 */ 8, /* 8x18 , 5 */ 14, /* 14x14 , 8 */
/* 4*/ 8, /* 8x32 ,10 */ 16, /* 16x16 ,12 */ 12, /* 12x26 ,16 */ 18, /* 18x18 ,18 */
/* 8*/ 8, /* 8x48 ,18 */ 20, /* 20x20 ,22 */ 12, /* 12x36 ,22 */ 8, /* 8x64 ,24 */
/*12*/ 22, /* 22x22 ,30 */ 16, /* 16x36 ,32 */ 24, /* 24x24 ,36 */ 12, /* 12x64 ,43 */
/*16*/ 26, /* 26x26 ,44 */ 16, /* 16x48 ,49 */ 32, /* 32x32 ,62 */ 16, /* 16x64 ,62 */
/*20*/ 24, /* 24x48 ,80 */ 36, /* 36x36 ,86 */ 26, /* 26x48 ,90 */ 24, /* 24x64 ,108*/
/*24*/ 40, /* 40x40 ,114*/ 26, /* 26x64 ,118*/ 44, /* 44x44 ,144*/ 48, /* 48x48,174 */
/*28*/ 52, /* 52x52,204 */ 64, /* 64x64,280 */ 72, /* 72x72,368 */ 80, /* 80x80,456 */
/*32*/ 88, /* 88x88,576 */ 96, /* 96x96,696 */ 104, /*104x104,816*/ 120, /*120x120,1050*/
/*36*/ 132,/*132x132,1304*/144 /*144x144,1558*/
};
// Vertical matrix sizes
static const unsigned short int matrixW[] = {
/* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 18, /* 8x18 */ 14, /* 14x14 */
/* 4*/ 32, /* 8x32 */ 16, /* 16x16 */ 26, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 48, /* 8x48 */ 20, /* 20x20 */ 36, /* 12x36 */ 64, /* 8x64 */
/*12*/ 22, /* 22x22 */ 36, /* 16x36 */ 24, /* 24x24 */ 64, /* 12x64 */
/*16*/ 26, /* 26x26 */ 48, /* 16x48 */ 32, /* 32x32 */ 64, /* 16x64 */
/*20*/ 48, /* 24x48 */ 36, /* 36x36 */ 48, /* 26x48 */ 64, /* 24x64 */
/*24*/ 40, /* 40x40 */ 64, /* 26x64 */ 44, /* 44x44 */ 48, /* 48x48 */
/*28*/ 52, /* 52x52 */ 64, /* 64x64 */ 72, /* 72x72 */ 80, /* 80x80 */
/*32*/ 88, /* 88x88 */ 96, /* 96x96 */ 104,/*104x104*/ 120,/*120x120*/
/*36*/132, /*132x132*/144 /*144x144*/
};
// Horizontal submodule size (including subfinder)
static const unsigned short int matrixFH[] = {
/* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 8, /* 8x18 */ 14, /* 14x14 */
/* 4*/ 8, /* 8x32 */ 16, /* 16x16 */ 12, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 8, /* 8x48 */ 20, /* 20x20 */ 12, /* 12x36 */ 8, /* 8x64 */
/*12*/ 22, /* 22x22 */ 16, /* 16x36 */ 24, /* 24x24 */ 12, /* 12x64 */
/*16*/ 26, /* 26x26 */ 16, /* 16x48 */ 16, /* 32x32 */ 16, /* 16x64 */
/*20*/ 24, /* 24x48 */ 18, /* 36x36 */ 26, /* 26x48 */ 24, /* 24x64 */
/*24*/ 20, /* 40x40 */ 26, /* 26x64 */ 22, /* 44x44 */ 24, /* 48x48 */
/*28*/ 26, /* 52x52 */ 16, /* 64x64 */ 18, /* 72x72 */ 20, /* 80x80 */
/*32*/ 22, /* 88x88 */ 24, /* 96x96 */ 26, /*104x104*/ 20, /*120x120*/
/*36*/ 22, /*132x132*/ 24 /*144x144*/
};
// Vertical submodule size (including subfinder)
static const unsigned short int matrixFW[] = {
/* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 18, /* 8x18 */ 14, /* 14x14 */
/* 4*/ 16, /* 8x32 */ 16, /* 16x16 */ 26, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 24, /* 8x48 */ 20, /* 20x20 */ 18, /* 12x36 */ 16, /* 8x64 */
/*12*/ 22, /* 22x22 */ 18, /* 16x36 */ 24, /* 24x24 */ 16, /* 12x64 */
/*16*/ 26, /* 26x26 */ 24, /* 16x48 */ 16, /* 32x32 */ 16, /* 16x64 */
/*20*/ 24, /* 24x48 */ 18, /* 36x36 */ 24, /* 26x48 */ 16, /* 24x64 */
/*24*/ 20, /* 40x40 */ 16, /* 26x64 */ 22, /* 44x44 */ 24, /* 48x48 */
/*28*/ 26, /* 52x52 */ 16, /* 64x64 */ 18, /* 72x72 */ 20, /* 80x80 */
/*32*/ 22, /* 88x88 */ 24, /* 96x96 */ 26, /*104x104*/ 20, /*120x120*/
/*36*/ 22, /*132x132*/ 24 /*144x144*/
};
// Total Data Codewords
static const unsigned short int matrixbytes[] = {
/* 0*/ 3, /* 10x10 */ 5, /* 12x12 */ 5, /* 8x18 */ 8, /* 14x14 */
/* 4*/ 10, /* 8x32 */ 12, /* 16x16 */ 16, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 18, /* 8x48 */ 22, /* 20x20 */ 22, /* 12x36 */ 24, /* 8x64 */
/*12*/ 30, /* 22x22 */ 32, /* 16x36 */ 36, /* 24x24 */ 43, /* 12x64 */
/*16*/ 44, /* 26x26 */ 49, /* 16x48 */ 62, /* 32x32 */ 62, /* 16x64 */
/*20*/ 80, /* 24x48 */ 86, /* 36x36 */ 90, /* 26x48 */ 108, /* 24x64 */
/*24*/ 114, /* 40x40 */ 118, /* 26x64 */ 144, /* 44x44 */ 174, /* 48x48 */
/*28*/ 204, /* 52x52 */ 280, /* 64x64 */ 368, /* 72x72 */ 456, /* 80x80 */
/*32*/ 576, /* 88x88 */ 696, /* 96x96 */ 816, /*104x104*/1050, /*120x120*/
/*36*/1304, /*132x132*/1558 /*144x144*/
};
// Data Codewords per RS-Block
static const unsigned short int matrixdatablock[] = {
/* 0*/ 3, /* 10x10 */ 5, /* 12x12 */ 5, /* 8x18 */ 8, /* 14x14 */
/* 4*/ 10, /* 8x32 */ 12, /* 16x16 */ 16, /* 12x26 */ 18, /* 18x18 */
/* 8*/ 18, /* 8x48 */ 22, /* 20x20 */ 22, /* 12x36 */ 24, /* 8x64 */
/*12*/ 30, /* 22x22 */ 32, /* 16x36 */ 36, /* 24x24 */ 43, /* 12x64 */
/*16*/ 44, /* 26x26 */ 49, /* 16x48 */ 62, /* 32x32 */ 62, /* 16x64 */
/*20*/ 80, /* 24x48 */ 86, /* 36x36 */ 90, /* 26x48 */ 108, /* 24x64 */
/*24*/ 114, /* 40x40 */ 118, /* 26x64 */ 144, /* 44x44 */ 174, /* 48x48 */
/*28*/ 102, /* 52x52 */ 140, /* 64x64 */ 92, /* 72x72 */ 114, /* 80x80 */
/*32*/ 144, /* 88x88 */ 174, /* 96x96 */ 136, /*104x104*/ 175, /*120x120*/
/*36*/ 163, /*132x132*/ 156 /* 144x144*/
};
// ECC Codewords per RS-Block
static const unsigned short int matrixrsblock[] = {
/* 0*/ 5, /* 10x10 */ 7, /* 12x12 */ 7, /* 8x18 */ 10, /* 14x14 */
/* 4*/ 11, /* 8x32 */ 12, /* 16x16 */ 14, /* 12x26 */ 14, /* 18x18 */
/* 8*/ 15, /* 8x48 */ 18, /* 20x20 */ 18, /* 12x36 */ 18, /* 8x64 */
/*12*/ 20, /* 22x22 */ 24, /* 16x36 */ 24, /* 24x24 */ 27, /* 12x64 */
/*16*/ 28, /* 26x26 */ 28, /* 16x48 */ 36, /* 32x32 */ 36, /* 16x64 */
/*20*/ 41, /* 24x48 */ 42, /* 36x36 */ 42, /* 26x48 */ 46, /* 24x64 */
/*24*/ 48, /* 40x40 */ 50, /* 26x64 */ 56, /* 44x44 */ 68, /* 48x48 */
/*28*/ 42, /* 52x52 */ 56, /* 64x64 */ 36, /* 72x72 */ 48, /* 80x80 */
/*32*/ 56, /* 88x88 */ 68, /* 96x96 */ 56, /*104x104*/ 68, /*120x120*/
/*36*/ 62, /*132x132*/ 62 /*144x144*/
};
#endif

1463
3rdparty/zint-2.6.1/backend/dotcode.c vendored Normal file

File diff suppressed because it is too large Load Diff

309
3rdparty/zint-2.6.1/backend/eci.c vendored Normal file
View File

@ -0,0 +1,309 @@
/* eci.c - Extended Channel Interpretations
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "eci.h"
#include "zint.h"
#ifdef _MSC_VER
#include <malloc.h>
#endif
/* Convert Unicode to other character encodings */
int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length) {
int glyph;
int bytelen;
int in_posn;
int out_posn;
int ext;
int done;
if (eci == 26) {
/* Unicode mode, do not process - just copy data across */
for (in_posn = 0; in_posn < *length; in_posn++) {
dest[in_posn] = source[in_posn];
}
dest[*length] = '\0';
return 0;
}
in_posn = 0;
out_posn = 0;
do {
/* Single byte (ASCII) character */
bytelen = 1;
glyph = (int) source[in_posn];
if ((source[in_posn] >= 0x80) && (source[in_posn] < 0xc0)) {
/* Something has gone wrong, abort */
return ZINT_ERROR_INVALID_DATA;
}
if ((source[in_posn] >= 0xc0) && (source[in_posn] < 0xe0)) {
/* Two-byte character */
bytelen = 2;
glyph = (source[in_posn] & 0x1f) << 6;
if (*length < (in_posn + 2)) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 1] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
glyph += (source[in_posn + 1] & 0x3f);
}
if ((source[in_posn] >= 0xe0) && (source[in_posn] < 0xf0)) {
/* Three-byte character */
bytelen = 3;
glyph = (source[in_posn] & 0x0f) << 12;
if (*length < (in_posn + 2)) {
return ZINT_ERROR_INVALID_DATA;
}
if (*length < (in_posn + 3)) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 1] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 2] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
glyph += (source[in_posn + 1] & 0x3f) << 6;
glyph += (source[in_posn + 2] & 0x3f);
}
if ((source[in_posn] >= 0xf0) && (source[in_posn] < 0xf7)) {
/* Four-byte character */
bytelen = 4;
glyph = (source[in_posn] & 0x07) << 18;
if (*length < (in_posn + 2)) {
return ZINT_ERROR_INVALID_DATA;
}
if (*length < (in_posn + 3)) {
return ZINT_ERROR_INVALID_DATA;
}
if (*length < (in_posn + 4)) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 1] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 2] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 3] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
glyph += (source[in_posn + 1] & 0x3f) << 12;
glyph += (source[in_posn + 2] & 0x3f) << 6;
glyph += (source[in_posn + 3] & 0x3f);
}
if (source[in_posn] >= 0xf7) {
/* More than 4 bytes not supported */
return ZINT_ERROR_INVALID_DATA;
}
if (glyph < 128) {
dest[out_posn] = glyph;
} else {
done = 0;
for (ext = 0; ext < 128; ext++) {
switch (eci) {
case 3: // Latin-1
if (glyph == iso_8859_1[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 4: // Latin-2
if (glyph == iso_8859_2[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 5: // Latin-3
if (glyph == iso_8859_3[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 6: // Latin-4
if (glyph == iso_8859_4[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 7: // Latin/Cyrillic
if (glyph == iso_8859_5[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 8: // Latin/Arabic
if (glyph == iso_8859_6[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 9: // Latin/Greek
if (glyph == iso_8859_7[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 10: // Latin/Hebrew
if (glyph == iso_8859_8[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 11: // Latin-5
if (glyph == iso_8859_9[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 12: // Latin-6
if (glyph == iso_8859_10[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 13: // Latin/Thai
if (glyph == iso_8859_11[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 15: // Latin-7
if (glyph == iso_8859_13[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 16: // Latin-8
if (glyph == iso_8859_14[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 17: // Latin-9
if (glyph == iso_8859_15[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 18: // Latin-10
if (glyph == iso_8859_16[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 21: // Windows-1250
if (glyph == windows_1250[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 22: // Windows-1251
if (glyph == windows_1251[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 23: // Windows-1252
if (glyph == windows_1252[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
case 24: // Windows-1256
if (glyph == windows_1256[ext]) {
dest[out_posn] = ext + 128;
done = 1;
}
break;
default:
break;
}
}
if (!(done)) {
return ZINT_ERROR_INVALID_DATA;
}
}
in_posn += bytelen;
out_posn++;
} while (in_posn < *length);
dest[out_posn] = '\0';
*length = out_posn;
return 0;
}
/* Find the lowest ECI mode which will encode a given set of Unicode text */
int get_best_eci(unsigned char source[], size_t length) {
int eci = 3;
#ifndef _MSC_VER
unsigned char local_source[length + 1];
#else
unsigned char *local_source = (unsigned char*) _alloca(length + 1);
#endif
do {
if (utf_to_eci(eci, source, local_source, &length) == 0) {
return eci;
}
eci++;
} while (eci < 25);
return 26; // If all of these fail, use Unicode!
}

252
3rdparty/zint-2.6.1/backend/eci.h vendored Normal file
View File

@ -0,0 +1,252 @@
/* eci.c - Extended Channel Interpretations to Unicode tables
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef ECI_H
#define ECI_H
#ifdef __cplusplus
extern "C" {
#endif
static const unsigned short int iso_8859_1[] = {// Latin alphabet No. 1
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff
};
static const unsigned short int iso_8859_2[] = {// Latin alphabet No. 2
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7, 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7, 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9
};
static const unsigned short int iso_8859_3[] = {// Latin alphabet No. 3
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7, 0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b,
0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7, 0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c,
0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7, 0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7, 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9
};
static const unsigned short int iso_8859_4[] = {// Latin alphabet No. 4
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x012b, 0x013b, 0x00a7, 0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af,
0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7, 0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b,
0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e, 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a,
0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7, 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df,
0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f, 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b,
0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9
};
static const unsigned short int iso_8859_5[] = {// Latin/Cyrillic alphabet
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f,
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f
};
static const unsigned short int iso_8859_6[] = {// Latin/Arabic alphabet
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0000, 0x0000, 0x0000, 0x00a4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x060c, 0x00ad, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f,
0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
0x0650, 0x0651, 0x0652, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
};
static const unsigned short int iso_8859_7[] = {// Latin/Greek alphabet
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x2018, 0x2019, 0x00a3, 0x20ac, 0x20af, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x037a, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7, 0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f,
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000
};
static const unsigned short int iso_8859_8[] = {// Latin/Hebrew alphabet
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0000, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2017,
0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7, 0x05e8, 0x05e9, 0x05ea, 0x0000, 0x0000, 0x200e, 0x200f, 0x0000
};
static const unsigned short int iso_8859_9[] = {// Latin alphabet No. 5
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff
};
static const unsigned short int iso_8859_10[] = {// Latin alphabet No. 6
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0104, 0x0112, 0x0122, 0x012a, 0x012b, 0x0136, 0x00a7, 0x013b, 0x0110, 0x0160, 0x0166, 0x017d, 0x00ad, 0x016a, 0x014a,
0x00b0, 0x0105, 0x0113, 0x0123, 0x012b, 0x0129, 0x0137, 0x00b7, 0x013c, 0x0111, 0x0161, 0x0167, 0x017e, 0x2015, 0x016b, 0x014b,
0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e, 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x00cf,
0x00d0, 0x0145, 0x014c, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0168, 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f, 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x00ef,
0x00f0, 0x0146, 0x014d, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0169, 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138
};
static const unsigned short int iso_8859_11[] = {// Latin/Thai alphabet
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e36, 0x0e36, 0x0e37, 0x0e38, 0x0e39, 0x0e3a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0e3f,
0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x0000, 0x0000, 0x0000, 0x0000
};
static const unsigned short int iso_8859_13[] = {// Latin alphabet No. 7
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x201d, 0x00a2, 0x00a3, 0x00a4, 0x201e, 0x00a6, 0x00a7, 0x00d8, 0x00a9, 0x0156, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00c6,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x201c, 0x00b5, 0x00b6, 0x00b7, 0x00f8, 0x00b9, 0x0157, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00e6,
0x0104, 0x012e, 0x0100, 0x0106, 0x00c4, 0x00c5, 0x0118, 0x0112, 0x010c, 0x00c9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012a, 0x013b,
0x0160, 0x0143, 0x0145, 0x00d3, 0x014c, 0x00d5, 0x00d6, 0x00d7, 0x0172, 0x0141, 0x015a, 0x016a, 0x00dc, 0x017b, 0x017d, 0x00df,
0x0105, 0x012f, 0x0101, 0x0107, 0x00e4, 0x00e5, 0x0119, 0x0113, 0x010d, 0x00e9, 0x017a, 0x0117, 0x0123, 0x0137, 0x012b, 0x013c,
0x0161, 0x0144, 0x0146, 0x00f3, 0x014d, 0x00f5, 0x00f6, 0x00f7, 0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019
};
static const unsigned short int iso_8859_14[] = {// Latin alphabet No. 8 (Celtic)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7, 0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178,
0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56, 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff
};
static const unsigned short int iso_8859_15[] = {// Latin alphabet No. 9
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7, 0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7, 0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff
};
static const unsigned short int iso_8859_16[] = {// Latin alphabet No. 10
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x00a0, 0x0104, 0x0105, 0x0141, 0x20ac, 0x201e, 0x0160, 0x00a7, 0x0161, 0x00a9, 0x0218, 0x00ab, 0x0179, 0x00ad, 0x017a, 0x017b,
0x00b0, 0x00b1, 0x010c, 0x0142, 0x017d, 0x201d, 0x00b6, 0x00b7, 0x017e, 0x010d, 0x0219, 0x00bb, 0x0152, 0x0153, 0x0178, 0x017c,
0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0106, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x0107, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x0111, 0x0144, 0x00f2, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x015b, 0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff
};
static const unsigned short int windows_1250[] = {
0x20ac, 0x0000, 0x201a, 0x0000, 0x201e, 0x2026, 0x2020, 0x2021, 0x0000, 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179,
0x0000, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a,
0x00a0, 0x02c7, 0x02db, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b,
0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c,
0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9
};
static const unsigned short int windows_1251[] = {
0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f,
0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f,
0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407,
0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457,
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f
};
static const unsigned short int windows_1252[] = {
0x20ac, 0x0000, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x017d, 0x0000,
0x0000, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x0000, 0x017e, 0x0178,
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff
};
static const unsigned short int windows_1256[] = {
0x20ac, 0x067e, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
0x06af, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x06a9, 0x2122, 0x0691, 0x203a, 0x0153, 0x200c, 0x200d, 0x06ba,
0x00a0, 0x060c, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x06be, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x061b, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x061f,
0x06c1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00d7, 0x0637, 0x0638, 0x0639, 0x063a, 0x0640, 0x0641, 0x0642, 0x0643,
0x00e0, 0x0644, 0x00e2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0649, 0x064a, 0x00ee, 0x00ef,
0x064b, 0x064c, 0x064d, 0x064e, 0x00f4, 0x064f, 0x0650, 0x00f7, 0x0651, 0x00f9, 0x0652, 0x00fb, 0x00fc, 0x200e, 0x200f, 0x06d2
};
#ifdef __cplusplus
}
#endif
#endif /* ECI_H */

1222
3rdparty/zint-2.6.1/backend/emf.c vendored Normal file

File diff suppressed because it is too large Load Diff

216
3rdparty/zint-2.6.1/backend/emf.h vendored Normal file
View File

@ -0,0 +1,216 @@
/* emf.h - header structure for Microsoft EMF
libzint - the open source barcode library
Copyright (C) 2016-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef EMF_H
#define EMF_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
#pragma pack(1)
typedef struct rect_l {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
} rect_l_t;
typedef struct size_l {
uint32_t cx;
uint32_t cy;
} size_l_t;
typedef struct point_l {
int32_t x;
int32_t y;
} point_l_t;
typedef struct color_ref {
uint8_t red;
uint8_t green;
uint8_t blue;
uint8_t reserved;
} color_ref_t;
typedef struct log_brush_ex {
uint32_t brush_style;
color_ref_t color;
uint32_t brush_hatch;
} log_brush_ex_t;
typedef struct log_pen {
uint32_t pen_style;
point_l_t width;
color_ref_t color_ref;
} log_pen_t;
typedef struct log_font {
int32_t height;
int32_t width;
int32_t escapement;
int32_t orientation;
int32_t weight;
uint8_t italic;
uint8_t underline;
uint8_t strike_out;
uint8_t char_set;
uint8_t out_precision;
uint8_t clip_precision;
uint8_t quality;
uint8_t pitch_and_family;
unsigned char facename[64];
} log_font_t;
typedef struct emr_text {
point_l_t reference;
uint32_t chars;
uint32_t off_string;
uint32_t options;
rect_l_t rectangle;
uint32_t off_dx;
} emr_text_t;
typedef struct emf_header {
rect_l_t bounds;
rect_l_t frame;
uint32_t record_signature;
uint32_t version;
uint32_t bytes;
uint32_t records;
uint16_t handles;
uint16_t reserved;
uint32_t n_description;
uint32_t off_description;
uint32_t n_pal_entries;
size_l_t device;
size_l_t millimeters;
} emf_header_t;
typedef struct emr_header {
uint32_t type;
uint32_t size;
emf_header_t emf_header;
} emr_header_t;
typedef struct emr_createbrushindirect {
uint32_t type;
uint32_t size;
uint32_t ih_brush;
log_brush_ex_t log_brush;
} emr_createbrushindirect_t;
typedef struct emr_createpen {
uint32_t type;
uint32_t size;
uint32_t ih_pen;
log_pen_t log_pen;
} emr_createpen_t;
typedef struct emr_selectobject {
uint32_t type;
uint32_t size;
uint32_t ih_object;
} emr_selectobject_t;
typedef struct emr_rectangle {
uint32_t type;
uint32_t size;
rect_l_t box;
} emr_rectangle_t;
typedef struct emr_ellipse {
uint32_t type;
uint32_t size;
rect_l_t box;
} emr_ellipse_t;
typedef struct emr_polygon {
uint32_t type;
uint32_t size;
rect_l_t bounds;
uint32_t count;
point_l_t a_points_a;
point_l_t a_points_b;
point_l_t a_points_c;
point_l_t a_points_d;
point_l_t a_points_e;
point_l_t a_points_f;
} emr_polygon_t;
typedef struct emr_extcreatefontindirectw {
uint32_t type;
uint32_t size;
uint32_t ih_fonts;
log_font_t elw;
} emr_extcreatefontindirectw_t;
typedef struct emr_exttextoutw {
uint32_t type;
uint32_t size;
rect_l_t bounds;
uint32_t i_graphics_mode;
float ex_scale;
float ey_scale;
emr_text_t w_emr_text;
} emr_exttextoutw_t;
typedef struct emr_eof {
uint32_t type;
uint32_t size;
uint32_t n_pal_entries;
uint32_t off_pal_entries;
uint32_t size_last;
} emr_eof_t;
typedef struct box {
emr_rectangle_t top;
emr_rectangle_t bottom;
emr_rectangle_t left;
emr_rectangle_t right;
} box_t;
#pragma pack()
#ifdef __cplusplus
}
#endif
#endif /* EMF_H */

419
3rdparty/zint-2.6.1/backend/font.h vendored Normal file
View File

@ -0,0 +1,419 @@
/* font.h - Font for PNG images */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
static const char ascii_font[] = {
/* Each character is 7 x 14 pixels */
0, 0, 8, 8, 8, 8, 8, 8, 8, 0, 8, 8, 0, 0, /* ! */
0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* " */
0, 0, 20, 20, 20, 62, 20, 20, 62, 20, 20, 20, 0, 0, /* # */
0, 0, 8, 60, 74, 74, 40, 28, 10, 74, 74, 60, 8, 0, /* $ */
0, 0, 50, 74, 76, 56, 8, 16, 28, 50, 82, 76, 0, 0, /* % */
0, 0, 24, 36, 36, 36, 24, 50, 74, 68, 76, 50, 0, 0, /* & */
0, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ' */
0, 2, 4, 8, 8, 16, 16, 16, 16, 16, 8, 8, 4, 2, /* ( */
0, 32, 16, 8, 8, 4, 4, 4, 4, 4, 8, 8, 16, 32, /* ) */
0, 0, 0, 0, 8, 42, 28, 8, 28, 42, 8, 0, 0, 0, /* * */
0, 0, 0, 0, 8, 8, 8, 62, 8, 8, 8, 0, 0, 0, /* + */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 8, 8, 16, /* , */
0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, /* - */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 28, 8, 0, /* . */
0, 2, 2, 4, 4, 8, 8, 8, 16, 16, 32, 32, 64, 64, /* / */
0, 0, 24, 36, 66, 66, 66, 66, 66, 66, 36, 24, 0, 0, /* 0 */
0, 0, 8, 24, 40, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* 1 */
0, 0, 60, 66, 66, 2, 4, 4, 8, 16, 32, 126, 0, 0, /* 2 */
0, 0, 126, 2, 4, 8, 28, 2, 2, 66, 66, 60, 0, 0, /* 3 */
0, 0, 4, 12, 20, 20, 36, 36, 68, 126, 4, 4, 0, 0, /* 4 */
0, 0, 126, 64, 64, 124, 66, 2, 2, 66, 66, 60, 0, 0, /* 5 */
0, 0, 28, 32, 64, 64, 92, 98, 66, 66, 66, 60, 0, 0, /* 6 */
0, 0, 126, 2, 4, 4, 8, 8, 16, 16, 32, 32, 0, 0, /* 7 */
0, 0, 60, 66, 66, 36, 24, 36, 66, 66, 66, 60, 0, 0, /* 8 */
0, 0, 60, 66, 66, 66, 70, 58, 2, 66, 68, 56, 0, 0, /* 9 */
0, 0, 0, 0, 8, 28, 8, 0, 0, 8, 28, 8, 0, 0, /* : */
0, 0, 0, 0, 0, 24, 24, 0, 0, 24, 8, 8, 16, 0, /* ; */
0, 0, 0, 2, 4, 8, 16, 32, 16, 8, 4, 2, 0, 0, /* < */
0, 0, 0, 0, 0, 126, 0, 0, 126, 0, 0, 0, 0, 0, /* = */
0, 0, 0, 32, 16, 8, 4, 2, 4, 8, 16, 32, 0, 0, /* > */
0, 0, 60, 66, 66, 4, 8, 8, 8, 0, 8, 8, 0, 0, /* ? */
0, 0, 28, 34, 78, 82, 82, 82, 82, 78, 32, 30, 0, 0, /* @ */
0, 0, 24, 36, 66, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* A */
0, 0, 120, 68, 66, 68, 120, 68, 66, 66, 68, 120, 0, 0, /* B */
0, 0, 60, 66, 66, 64, 64, 64, 64, 66, 66, 60, 0, 0, /* C */
0, 0, 120, 68, 66, 66, 66, 66, 66, 66, 68, 120, 0, 0, /* D */
0, 0, 126, 64, 64, 64, 120, 64, 64, 64, 64, 126, 0, 0, /* E */
0, 0, 126, 64, 64, 64, 120, 64, 64, 64, 64, 64, 0, 0, /* F */
0, 0, 60, 66, 66, 64, 64, 78, 66, 66, 70, 58, 0, 0, /* G */
0, 0, 66, 66, 66, 66, 126, 66, 66, 66, 66, 66, 0, 0, /* H */
0, 0, 62, 8, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* I */
0, 0, 14, 4, 4, 4, 4, 4, 4, 68, 68, 56, 0, 0, /* J */
0, 0, 66, 68, 72, 80, 96, 80, 72, 68, 66, 66, 0, 0, /* K */
0, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 126, 0, 0, /* L */
0, 0, 66, 102, 102, 90, 90, 66, 66, 66, 66, 66, 0, 0, /* M */
0, 0, 66, 66, 98, 98, 82, 74, 70, 70, 66, 66, 0, 0, /* N */
0, 0, 60, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* O */
0, 0, 124, 66, 66, 66, 66, 124, 64, 64, 64, 64, 0, 0, /* P */
0, 0, 60, 66, 66, 66, 66, 66, 114, 74, 70, 60, 4, 2, /* Q */
0, 0, 124, 66, 66, 66, 66, 124, 72, 68, 66, 66, 0, 0, /* R */
0, 0, 60, 66, 66, 64, 48, 12, 2, 66, 66, 60, 0, 0, /* S */
0, 0, 127, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, /* T */
0, 0, 66, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* U */
0, 0, 66, 66, 66, 66, 36, 36, 36, 24, 24, 24, 0, 0, /* V */
0, 0, 34, 34, 34, 34, 34, 34, 42, 42, 42, 20, 0, 0, /* W */
0, 0, 66, 66, 36, 36, 24, 24, 36, 36, 66, 66, 0, 0, /* X */
0, 0, 34, 34, 34, 20, 20, 8, 8, 8, 8, 8, 0, 0, /* Y */
0, 0, 126, 2, 4, 8, 8, 16, 32, 32, 64, 126, 0, 0, /* Z */
0, 30, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 30, /* [ */
0, 64, 64, 32, 32, 16, 16, 16, 8, 8, 4, 4, 2, 2, /* \ */
0, 60, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 60, /* ] */
0, 24, 36, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ^ */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 126, /* _ */
0, 16, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` */
0, 0, 0, 0, 0, 60, 66, 2, 62, 66, 66, 62, 0, 0, /* a */
0, 0, 64, 64, 64, 92, 98, 66, 66, 66, 98, 92, 0, 0, /* b */
0, 0, 0, 0, 0, 60, 66, 64, 64, 64, 66, 60, 0, 0, /* c */
0, 0, 2, 2, 2, 58, 70, 66, 66, 66, 70, 58, 0, 0, /* d */
0, 0, 0, 0, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* e */
0, 0, 12, 18, 16, 16, 124, 16, 16, 16, 16, 16, 0, 0, /* f */
0, 0, 0, 0, 0, 58, 68, 68, 68, 56, 32, 92, 66, 60, /* g */
0, 0, 64, 64, 64, 92, 98, 66, 66, 66, 66, 66, 0, 0, /* h */
0, 0, 8, 8, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* i */
0, 0, 2, 2, 0, 6, 2, 2, 2, 2, 2, 34, 34, 28, /* j */
0, 0, 64, 64, 64, 68, 72, 80, 112, 72, 68, 66, 0, 0, /* k */
0, 0, 24, 8, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* l */
0, 0, 0, 0, 0, 52, 42, 42, 42, 42, 42, 34, 0, 0, /* m */
0, 0, 0, 0, 0, 92, 98, 66, 66, 66, 66, 66, 0, 0, /* n */
0, 0, 0, 0, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* o */
0, 0, 0, 0, 0, 92, 98, 66, 66, 66, 98, 92, 64, 64, /* p */
0, 0, 0, 0, 0, 58, 70, 66, 66, 66, 70, 58, 2, 2, /* q */
0, 0, 0, 0, 0, 92, 98, 66, 64, 64, 64, 64, 0, 0, /* r */
0, 0, 0, 0, 0, 60, 66, 32, 24, 4, 66, 60, 0, 0, /* s */
0, 0, 16, 16, 16, 124, 16, 16, 16, 16, 18, 12, 0, 0, /* t */
0, 0, 0, 0, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* u */
0, 0, 0, 0, 0, 34, 34, 34, 20, 20, 8, 8, 0, 0, /* v */
0, 0, 0, 0, 0, 34, 34, 42, 42, 42, 42, 20, 0, 0, /* w */
0, 0, 0, 0, 0, 66, 66, 36, 24, 36, 66, 66, 0, 0, /* x */
0, 0, 0, 0, 0, 66, 66, 66, 66, 70, 58, 2, 66, 60, /* y */
0, 0, 0, 0, 0, 126, 4, 8, 16, 16, 32, 126, 0, 0, /* z */
0, 6, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 6, /* { */
0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* | */
0, 48, 8, 8, 8, 8, 8, 4, 8, 8, 8, 8, 8, 48, /* } */
0, 32, 82, 74, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ~ */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  */
0, 0, 8, 8, 0, 8, 8, 8, 8, 8, 8, 8, 0, 0, /* ¡ */
0, 0, 0, 0, 16, 60, 82, 80, 80, 80, 82, 60, 16, 0, /* ¢ */
0, 0, 0, 12, 18, 16, 16, 60, 16, 16, 60, 18, 0, 0, /* £ */
0, 0, 0, 0, 66, 60, 36, 36, 60, 66, 0, 0, 0, 0, /* ¤ */
0, 0, 34, 20, 20, 8, 62, 8, 62, 8, 8, 8, 0, 0, /* ¥ */
0, 0, 8, 8, 8, 8, 0, 0, 8, 8, 8, 8, 0, 0, /* ¦ */
0, 60, 66, 32, 24, 36, 66, 36, 24, 4, 66, 60, 0, 0, /* § */
0, 36, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ¨ */
0, 60, 66, 90, 102, 98, 98, 98, 102, 90, 66, 60, 0, 0, /* © */
0, 28, 34, 30, 34, 38, 26, 0, 62, 0, 0, 0, 0, 0, /* ª */
0, 0, 0, 0, 0, 10, 20, 40, 80, 40, 20, 10, 0, 0, /* « */
0, 0, 0, 0, 0, 0, 0, 0, 62, 2, 2, 2, 0, 0, /* ¬ */
0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, /* ­ */
0, 60, 66, 122, 102, 102, 122, 102, 102, 102, 66, 60, 0, 0, /* ® */
0, 0, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ¯ */
0, 24, 36, 36, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ° */
0, 0, 0, 0, 0, 0, 8, 8, 62, 8, 8, 62, 0, 0, /* ± */
0, 24, 36, 4, 8, 16, 32, 60, 0, 0, 0, 0, 0, 0, /* ² */
0, 24, 36, 4, 24, 4, 36, 24, 0, 0, 0, 0, 0, 0, /* ³ */
0, 4, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ´ */
0, 0, 0, 0, 0, 0, 34, 34, 34, 34, 54, 42, 32, 32, /* µ */
0, 0, 30, 42, 42, 42, 42, 26, 10, 10, 10, 10, 10, 14, /* ¶ */
0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, /* · */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 16, /* ¸ */
0, 8, 24, 8, 8, 8, 8, 28, 0, 0, 0, 0, 0, 0, /* ¹ */
0, 0, 24, 36, 36, 24, 0, 60, 0, 0, 0, 0, 0, 0, /* º */
0, 0, 0, 0, 0, 80, 40, 20, 10, 20, 40, 80, 0, 0, /* » */
0, 0, 32, 98, 36, 36, 40, 18, 22, 42, 78, 66, 0, 0, /* ¼ */
0, 0, 32, 98, 36, 36, 40, 20, 26, 34, 68, 78, 0, 0, /* ½ */
0, 0, 98, 18, 36, 24, 104, 18, 38, 42, 78, 2, 0, 0, /* ¾ */
0, 0, 0, 16, 16, 0, 16, 16, 16, 16, 32, 66, 66, 60, /* ¿ */
16, 8, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* À */
8, 16, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Á */
24, 36, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Â */
50, 76, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Ã */
0, 36, 0, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Ä */
0, 24, 36, 24, 36, 66, 66, 126, 66, 66, 66, 66, 0, 0, /* Å */
0, 0, 30, 40, 72, 72, 126, 72, 72, 72, 72, 78, 0, 0, /* Æ */
0, 0, 60, 66, 66, 64, 64, 64, 64, 66, 66, 60, 8, 16, /* Ç */
16, 8, 0, 126, 64, 64, 64, 124, 64, 64, 64, 126, 0, 0, /* È */
8, 16, 0, 126, 64, 64, 64, 124, 64, 64, 64, 126, 0, 0, /* É */
24, 36, 0, 126, 64, 64, 64, 124, 64, 64, 64, 126, 0, 0, /* Ê */
0, 36, 0, 126, 64, 64, 64, 124, 64, 64, 64, 126, 0, 0, /* Ë */
16, 8, 0, 62, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* Ì */
4, 8, 0, 62, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* Í */
8, 20, 0, 62, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* Î */
0, 20, 0, 62, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0, /* Ï */
0, 0, 60, 34, 33, 33, 121, 33, 33, 33, 34, 60, 0, 0, /* Ð */
50, 76, 0, 98, 98, 82, 82, 74, 74, 74, 70, 70, 0, 0, /* Ñ */
16, 8, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ò */
8, 16, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ó */
24, 36, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ô */
50, 76, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Õ */
0, 36, 0, 60, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ö */
0, 0, 0, 0, 0, 65, 34, 20, 8, 20, 34, 65, 0, 0, /* × */
2, 2, 60, 70, 74, 74, 74, 82, 82, 82, 98, 60, 64, 64, /* Ø */
16, 8, 0, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ù */
8, 16, 0, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ú */
24, 36, 0, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Û */
0, 36, 0, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0, /* Ü */
4, 8, 0, 34, 34, 20, 20, 8, 8, 8, 8, 8, 0, 0, /* Ý */
0, 0, 64, 64, 124, 66, 66, 66, 66, 124, 64, 64, 0, 0, /* Þ */
0, 0, 24, 36, 36, 36, 56, 36, 34, 34, 34, 124, 0, 0, /* ß */
0, 0, 16, 8, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* à */
0, 0, 4, 8, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* á */
0, 0, 24, 36, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* â */
0, 0, 50, 76, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* ã */
0, 0, 0, 36, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* ä */
0, 24, 36, 24, 0, 60, 66, 14, 50, 66, 70, 58, 0, 0, /* å */
0, 0, 0, 0, 0, 62, 73, 25, 47, 72, 73, 62, 0, 0, /* æ */
0, 0, 0, 0, 0, 60, 66, 64, 64, 64, 66, 60, 8, 16, /* ç */
0, 0, 16, 8, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* è */
0, 0, 8, 16, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* é */
0, 0, 24, 36, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* ê */
0, 0, 0, 36, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0, /* ë */
0, 0, 16, 8, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* ì */
0, 0, 4, 8, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* í */
0, 0, 24, 36, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* î */
0, 0, 0, 20, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0, /* ï */
0, 20, 8, 20, 2, 30, 34, 34, 34, 34, 34, 28, 0, 0, /* ð */
0, 0, 50, 76, 0, 92, 98, 66, 66, 66, 66, 66, 0, 0, /* ñ */
0, 0, 16, 8, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* ò */
0, 0, 8, 16, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* ó */
0, 0, 24, 36, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* ô */
0, 0, 50, 76, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* õ */
0, 0, 0, 36, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0, /* ö */
0, 0, 0, 0, 0, 0, 0, 24, 0, 126, 0, 24, 0, 0, /* ÷ */
0, 0, 0, 2, 4, 60, 74, 74, 82, 82, 98, 60, 64, 64, /* ø */
0, 0, 16, 8, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* ù */
0, 0, 8, 16, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* ú */
0, 0, 24, 36, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* û */
0, 0, 0, 36, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0, /* ü */
0, 0, 8, 16, 0, 66, 66, 34, 36, 20, 28, 8, 72, 48, /* ý */
0, 0, 64, 64, 64, 92, 98, 66, 66, 66, 98, 92, 64, 64, /* þ */
0, 0, 0, 36, 0, 66, 66, 34, 36, 20, 28, 8, 72, 48, /* ÿ */
};
static const char small_font[] = {
/* Each character is 5 x 9 pixels */
0, 2, 2, 2, 2, 0, 2, 0, 0, /* ! */
0, 5, 5, 5, 0, 0, 0, 0, 0, /* " */
0, 0, 5, 15, 5, 15, 5, 0, 0, /* # */
0, 0, 7, 26, 7, 18, 7, 0, 0, /* $ */
0, 8, 9, 2, 4, 25, 1, 0, 0, /* % */
0, 0, 4, 10, 4, 10, 5, 0, 0, /* & */
0, 2, 2, 2, 0, 0, 0, 0, 0, /* ' */
0, 2, 4, 4, 4, 4, 2, 0, 0, /* ( */
0, 4, 2, 2, 2, 2, 4, 0, 0, /* ) */
0, 0, 5, 2, 7, 2, 5, 0, 0, /* * */
0, 0, 2, 2, 15, 2, 2, 0, 0, /* + */
0, 0, 0, 0, 16, 3, 2, 4, 0, /* , */
0, 0, 0, 0, 15, 0, 0, 0, 0, /* - */
0, 0, 0, 0, 0, 6, 6, 0, 0, /* . */
0, 0, 1, 2, 4, 8, 0, 0, 0, /* / */
0, 2, 5, 5, 5, 5, 2, 0, 0, /* 0 */
0, 2, 6, 2, 2, 2, 7, 0, 0, /* 1 */
0, 6, 9, 1, 2, 4, 15, 0, 0, /* 2 */
0, 15, 1, 6, 1, 9, 6, 0, 0, /* 3 */
0, 2, 6, 10, 15, 2, 2, 0, 0, /* 4 */
0, 15, 8, 14, 1, 9, 6, 0, 0, /* 5 */
0, 6, 8, 14, 9, 9, 6, 0, 0, /* 6 */
0, 15, 1, 2, 2, 4, 4, 0, 0, /* 7 */
0, 6, 9, 6, 9, 9, 6, 0, 0, /* 8 */
0, 6, 9, 9, 7, 1, 6, 0, 0, /* 9 */
0, 0, 6, 6, 0, 6, 6, 0, 0, /* : */
0, 0, 6, 6, 0, 6, 4, 8, 0, /* ; */
0, 0, 1, 2, 4, 2, 1, 0, 0, /* < */
0, 0, 0, 15, 0, 15, 0, 0, 0, /* = */
0, 0, 4, 2, 1, 2, 4, 0, 0, /* > */
0, 2, 5, 1, 2, 0, 2, 0, 0, /* ? */
0, 6, 9, 11, 11, 8, 6, 0, 0, /* @ */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* A */
0, 14, 9, 14, 9, 9, 14, 0, 0, /* B */
0, 6, 9, 8, 8, 9, 6, 0, 0, /* C */
0, 14, 9, 9, 9, 9, 14, 0, 0, /* D */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* E */
0, 15, 8, 14, 8, 8, 8, 0, 0, /* F */
0, 6, 9, 8, 11, 9, 7, 0, 0, /* G */
0, 9, 9, 15, 9, 9, 9, 0, 0, /* H */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* I */
0, 1, 1, 1, 1, 9, 6, 0, 0, /* J */
0, 9, 10, 12, 12, 10, 9, 0, 0, /* K */
0, 8, 8, 8, 8, 8, 15, 0, 0, /* L */
0, 9, 15, 15, 9, 9, 9, 0, 0, /* M */
0, 9, 13, 13, 11, 11, 9, 0, 0, /* N */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* O */
0, 14, 9, 9, 14, 8, 8, 0, 0, /* P */
0, 6, 9, 9, 9, 13, 6, 1, 0, /* Q */
0, 14, 9, 9, 14, 10, 9, 0, 0, /* R */
0, 6, 9, 4, 2, 9, 6, 0, 0, /* S */
0, 7, 2, 2, 2, 2, 2, 0, 0, /* T */
0, 9, 9, 9, 9, 9, 6, 0, 0, /* U */
0, 9, 9, 9, 9, 6, 6, 0, 0, /* V */
0, 9, 9, 9, 15, 15, 9, 0, 0, /* W */
0, 9, 9, 6, 6, 9, 9, 0, 0, /* X */
0, 5, 5, 5, 2, 2, 2, 0, 0, /* Y */
0, 15, 1, 2, 4, 8, 15, 0, 0, /* Z */
0, 7, 4, 4, 4, 4, 7, 0, 0, /* [ */
0, 0, 8, 4, 2, 1, 0, 0, 0, /* \ */
0, 7, 1, 1, 1, 1, 7, 0, 0, /* ] */
0, 2, 5, 0, 0, 0, 0, 0, 0, /* ^ */
0, 0, 0, 0, 0, 0, 15, 0, 0, /* _ */
0, 4, 2, 0, 0, 0, 0, 0, 0, /* ` */
0, 0, 0, 7, 9, 11, 5, 0, 0, /* a */
0, 8, 8, 14, 9, 9, 14, 0, 0, /* b */
0, 0, 0, 6, 8, 8, 6, 0, 0, /* c */
0, 1, 1, 7, 9, 9, 7, 0, 0, /* d */
0, 0, 0, 6, 11, 12, 6, 0, 0, /* e */
0, 2, 5, 4, 14, 4, 4, 0, 0, /* f */
0, 0, 0, 7, 9, 6, 8, 7, 0, /* g */
0, 8, 8, 14, 9, 9, 9, 0, 0, /* h */
0, 2, 0, 6, 2, 2, 7, 0, 0, /* i */
0, 1, 0, 1, 1, 1, 5, 2, 0, /* j */
0, 8, 8, 10, 12, 10, 9, 0, 0, /* k */
0, 6, 2, 2, 2, 2, 7, 0, 0, /* l */
0, 0, 0, 10, 15, 9, 9, 0, 0, /* m */
0, 0, 0, 14, 9, 9, 9, 0, 0, /* n */
0, 0, 0, 6, 9, 9, 6, 0, 0, /* o */
0, 0, 0, 14, 9, 9, 14, 8, 0, /* p */
0, 0, 0, 7, 9, 9, 7, 1, 0, /* q */
0, 0, 0, 14, 9, 8, 8, 0, 0, /* r */
0, 0, 0, 7, 12, 3, 14, 0, 0, /* s */
0, 4, 4, 14, 4, 4, 3, 0, 0, /* t */
0, 0, 0, 9, 9, 9, 7, 0, 0, /* u */
0, 0, 0, 5, 5, 5, 2, 0, 0, /* v */
0, 0, 0, 9, 9, 15, 15, 0, 0, /* w */
0, 0, 0, 9, 6, 6, 9, 0, 0, /* x */
0, 0, 0, 9, 9, 5, 2, 4, 0, /* y */
0, 0, 0, 15, 2, 4, 15, 0, 0, /* z */
0, 1, 2, 6, 2, 2, 1, 0, 0, /* { */
0, 2, 2, 2, 2, 2, 2, 0, 0, /* | */
0, 4, 2, 3, 2, 2, 4, 0, 0, /* } */
0, 5, 10, 0, 0, 0, 0, 0, 0, /* ~ */
0, 0, 0, 0, 0, 0, 0, 0, 0, /*  */
0, 2, 0, 2, 2, 2, 2, 0, 0, /* ¡ */
0, 0, 2, 7, 10, 10, 7, 2, 0, /* ¢ */
0, 0, 3, 4, 14, 4, 11, 0, 0, /* £ */
0, 0, 8, 7, 5, 7, 8, 0, 0, /* ¤ */
0, 5, 21, 2, 7, 2, 18, 0, 0, /* ¥ */
0, 0, 2, 2, 0, 2, 2, 0, 0, /* ¦ */
0, 3, 4, 6, 5, 3, 1, 6, 0, /* § */
0, 5, 0, 0, 0, 0, 0, 0, 0, /* ¨ */
0, 7, 8, 10, 12, 10, 8, 7, 0, /* © */
0, 6, 26, 22, 16, 16, 16, 0, 0, /* ª */
0, 0, 0, 4, 9, 4, 0, 0, 0, /* « */
0, 0, 0, 16, 15, 17, 0, 0, 0, /* ¬ */
0, 0, 0, 0, 0, 0, 0, 0, 0, /* ­ */
0, 7, 8, 14, 12, 12, 8, 7, 0, /* ® */
0, 15, 16, 16, 16, 16, 16, 0, 0, /* ¯ */
0, 2, 5, 2, 0, 0, 0, 0, 0, /* ° */
0, 2, 2, 15, 2, 2, 15, 0, 0, /* ± */
0, 6, 2, 20, 6, 0, 16, 0, 0, /* ² */
0, 6, 6, 2, 6, 0, 0, 0, 0, /* ³ */
0, 2, 4, 0, 0, 0, 0, 0, 0, /* ´ */
0, 0, 0, 9, 9, 9, 14, 8, 0, /* µ */
0, 7, 13, 13, 5, 5, 5, 0, 0, /* ¶ */
0, 0, 0, 6, 6, 0, 0, 0, 0, /* · */
0, 0, 0, 0, 0, 0, 2, 4, 0, /* ¸ */
0, 2, 6, 2, 7, 0, 0, 0, 0, /* ¹ */
0, 4, 10, 4, 0, 0, 0, 0, 0, /* º */
0, 0, 0, 9, 4, 9, 0, 0, 0, /* » */
0, 8, 8, 8, 25, 3, 7, 1, 0, /* ¼ */
0, 8, 8, 8, 11, 1, 2, 3, 0, /* ½ */
0, 12, 12, 4, 13, 3, 7, 1, 0, /* ¾ */
0, 2, 0, 2, 4, 5, 2, 0, 0, /* ¿ */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* À */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* Á */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* Â */
0, 6, 9, 9, 15, 9, 9, 0, 0, /* Ã */
0, 9, 6, 9, 15, 9, 9, 0, 0, /* Ä */
0, 6, 6, 9, 15, 9, 9, 0, 0, /* Å */
0, 7, 10, 11, 14, 10, 11, 0, 0, /* Æ */
0, 6, 9, 8, 8, 9, 6, 4, 0, /* Ç */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* È */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* É */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* Ê */
0, 15, 8, 14, 8, 8, 15, 0, 0, /* Ë */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* Ì */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* Í */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* Î */
0, 7, 2, 2, 2, 2, 7, 0, 0, /* Ï */
0, 14, 5, 13, 5, 5, 14, 0, 0, /* Ð */
0, 11, 9, 13, 11, 11, 9, 0, 0, /* Ñ */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* Ò */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* Ó */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* Ô */
0, 6, 9, 9, 9, 9, 6, 0, 0, /* Õ */
0, 9, 6, 9, 9, 9, 6, 0, 0, /* Ö */
0, 0, 0, 9, 6, 6, 9, 0, 0, /* × */
0, 7, 11, 11, 13, 13, 14, 0, 0, /* Ø */
0, 9, 9, 9, 9, 9, 6, 0, 0, /* Ù */
0, 9, 9, 9, 9, 9, 6, 0, 0, /* Ú */
0, 9, 9, 9, 9, 9, 6, 0, 0, /* Û */
0, 9, 0, 9, 9, 9, 6, 0, 0, /* Ü */
0, 5, 5, 5, 2, 2, 2, 0, 0, /* Ý */
0, 8, 14, 9, 14, 8, 8, 0, 0, /* Þ */
0, 6, 9, 10, 9, 9, 10, 0, 0, /* ß */
0, 4, 2, 7, 9, 11, 5, 0, 0, /* à */
0, 2, 4, 7, 9, 11, 5, 0, 0, /* á */
0, 2, 5, 7, 9, 11, 5, 0, 0, /* â */
0, 5, 10, 7, 9, 11, 5, 0, 0, /* ã */
0, 5, 0, 7, 9, 11, 5, 0, 0, /* ä */
0, 6, 6, 7, 9, 11, 5, 0, 0, /* å */
0, 0, 0, 7, 11, 10, 7, 0, 0, /* æ */
0, 0, 0, 3, 4, 4, 3, 2, 0, /* ç */
0, 4, 2, 6, 11, 12, 6, 0, 0, /* è */
0, 2, 4, 6, 11, 12, 6, 0, 0, /* é */
0, 4, 10, 6, 11, 12, 6, 0, 0, /* ê */
0, 10, 0, 6, 11, 12, 6, 0, 0, /* ë */
0, 4, 2, 6, 2, 2, 7, 0, 0, /* ì */
0, 2, 4, 6, 2, 2, 7, 0, 0, /* í */
0, 2, 5, 6, 2, 2, 7, 0, 0, /* î */
0, 5, 0, 6, 2, 2, 7, 0, 0, /* ï */
0, 4, 3, 6, 9, 9, 6, 0, 0, /* ð */
0, 5, 10, 14, 9, 9, 9, 0, 0, /* ñ */
0, 4, 2, 6, 9, 9, 6, 0, 0, /* ò */
0, 2, 4, 6, 9, 9, 6, 0, 0, /* ó */
0, 6, 0, 6, 9, 9, 6, 0, 0, /* ô */
0, 5, 10, 6, 9, 9, 6, 0, 0, /* õ */
0, 5, 0, 6, 9, 9, 6, 0, 0, /* ö */
0, 0, 6, 0, 15, 0, 6, 0, 0, /* ÷ */
0, 0, 0, 7, 11, 13, 14, 0, 0, /* ø */
0, 4, 2, 9, 9, 9, 7, 0, 0, /* ù */
0, 2, 4, 9, 9, 9, 7, 0, 0, /* ú */
0, 6, 0, 9, 9, 9, 7, 0, 0, /* û */
0, 5, 0, 9, 9, 9, 7, 0, 0, /* ü */
0, 2, 4, 9, 9, 5, 2, 4, 0, /* ý */
0, 0, 8, 14, 9, 9, 14, 8, 0, /* þ */
0, 5, 0, 9, 9, 5, 2, 4, 0, /* ÿ */
};

23324
3rdparty/zint-2.6.1/backend/gb18030.h vendored Normal file

File diff suppressed because it is too large Load Diff

7478
3rdparty/zint-2.6.1/backend/gb2312.h vendored Normal file

File diff suppressed because it is too large Load Diff

402
3rdparty/zint-2.6.1/backend/gif.c vendored Normal file
View File

@ -0,0 +1,402 @@
/* gif.c - Handles output to gif file */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#include <malloc.h>
#endif
#define SSET "0123456789ABCDEF"
/* Index of transparent color, -1 for no transparent color
* This might be set into a variable if transparency is activated as an option
*/
#define TRANSPARENT_INDEX (-1)
/* Used bit depth, may be changed for bigger pallet in future */
#define DESTINATION_IMAGE_BITS 1
#include <stdlib.h>
typedef struct s_statestruct {
unsigned char * pOut;
unsigned char *pIn;
unsigned int InLen;
unsigned int OutLength;
unsigned int OutPosCur;
unsigned int OutByteCountPos;
unsigned short ClearCode;
unsigned short FreeCode;
char fByteCountByteSet;
unsigned char OutBitsFree;
unsigned short NodeAxon[4096];
unsigned short NodeNext[4096];
unsigned char NodePix[4096];
} statestruct;
static char BufferNextByte(statestruct *pState) {
(pState->OutPosCur)++;
/* Check if this position is a byte count position
* fg_f_bytecountbyte_set indicates, if byte count position bytes should be
* inserted in general.
* If this is true, and the distance to the last byte count position is 256
* (e.g. 255 bytes in between), a byte count byte is inserted, and the value
* of the last one is set to 255.
* */
if (pState->fByteCountByteSet && (pState->OutByteCountPos + 256 == pState->OutPosCur)) {
(pState->pOut)[pState->OutByteCountPos] = 255;
pState->OutByteCountPos = pState->OutPosCur;
(pState->OutPosCur)++;
}
if (pState->OutPosCur >= pState->OutLength)
return 1;
(pState->pOut)[pState->OutPosCur] = 0x00;
return 0;
}
static char AddCodeToBuffer(statestruct *pState, unsigned short CodeIn, unsigned char CodeBits) {
/* Check, if we may fill up the current byte completely */
if (CodeBits >= pState->OutBitsFree) {
(pState->pOut)[pState->OutPosCur] |= (unsigned char)
(CodeIn << (8 - pState->OutBitsFree));
if (BufferNextByte(pState))
return -1;
CodeIn = (unsigned short) (CodeIn >> pState->OutBitsFree);
CodeBits -= pState->OutBitsFree;
pState->OutBitsFree = 8;
/* Write a full byte if there are at least 8 code bits left */
if (CodeBits >= pState->OutBitsFree) {
(pState->pOut)[pState->OutPosCur] = (unsigned char) CodeIn;
if (BufferNextByte(pState))
return -1;
CodeIn = (unsigned short) (CodeIn >> 8);
CodeBits -= 8;
}
}
/* The remaining bits of CodeIn fit in the current byte. */
if (CodeBits > 0) {
(pState->pOut)[pState->OutPosCur] |= (unsigned char)
(CodeIn << (8 - pState->OutBitsFree));
pState->OutBitsFree -= CodeBits;
}
return 0;
}
static void FlushStringTable(statestruct *pState) {
unsigned short Pos;
for (Pos = 0; Pos < pState->ClearCode; Pos++) {
(pState->NodeAxon)[Pos] = 0;
}
}
unsigned short FindPixelOutlet(statestruct *pState, unsigned short HeadNode, unsigned char Byte) {
unsigned short Outlet;
Outlet = (pState->NodeAxon)[HeadNode];
while (Outlet) {
if ((pState->NodePix)[Outlet] == Byte)
return Outlet;
Outlet = (pState->NodeNext)[Outlet];
}
return 0;
}
static char NextCode(statestruct *pState, unsigned char * pPixelValueCur, unsigned char CodeBits) {
unsigned short UpNode;
unsigned short DownNode;
/* start with the root node for last pixel chain */
UpNode = *pPixelValueCur;
if ((pState->InLen) == 0)
return AddCodeToBuffer(pState, UpNode, CodeBits);
*pPixelValueCur = (*(pState->pIn)) - '0';
(pState->pIn)++;
(pState->InLen)--;
/* Follow the string table and the data stream to the end of the longest string that has a code */
while (0 != (DownNode = FindPixelOutlet(pState, UpNode, *pPixelValueCur))) {
UpNode = DownNode;
if ((pState->InLen) == 0)
return AddCodeToBuffer(pState, UpNode, CodeBits);
*pPixelValueCur = (*(pState->pIn)) - '0';
(pState->pIn)++;
(pState->InLen)--;
}
/* Submit 'UpNode' which is the code of the longest string */
if (AddCodeToBuffer(pState, UpNode, CodeBits))
return -1;
/* ... and extend the string by appending 'PixelValueCur' */
/* Create a successor node for 'PixelValueCur' whose code is 'freecode' */
(pState->NodePix)[pState->FreeCode] = *pPixelValueCur;
(pState->NodeAxon)[pState->FreeCode] = (pState->NodeNext)[pState->FreeCode] = 0;
/* ...and link it to the end of the chain emanating from fg_axon[UpNode]. */
DownNode = (pState->NodeAxon)[UpNode];
if (!DownNode) {
(pState->NodeAxon)[UpNode] = pState->FreeCode;
} else {
while ((pState->NodeNext)[DownNode]) {
DownNode = (pState->NodeNext)[DownNode];
}
(pState->NodeNext)[DownNode] = pState->FreeCode;
}
return 1;
}
int gif_lzw(unsigned char *pOut, int OutLength, unsigned char *pIn, int InLen) {
unsigned char PixelValueCur;
unsigned char CodeBits;
unsigned short Pos;
statestruct State;
State.pIn = pIn;
State.InLen = InLen;
State.pOut = pOut;
State.OutLength = OutLength;
// > Get first data byte
if (State.InLen == 0)
return 0;
PixelValueCur = (unsigned char) ((*(State.pIn)) - '0');
(State.pIn)++;
(State.InLen)--;
CodeBits = 3;
State.ClearCode = 4;
State.FreeCode = 6;
State.OutBitsFree = 8;
State.OutPosCur = -1;
State.fByteCountByteSet = 0;
if (BufferNextByte(&State))
return 0;
for (Pos = 0; Pos < State.ClearCode; Pos++)
State.NodePix[Pos] = (unsigned char) Pos;
FlushStringTable(&State);
/* Write what the GIF specification calls the "code size". */
(State.pOut)[State.OutPosCur] = 2;
/* Reserve first bytecount byte */
if (BufferNextByte(&State))
return 0;
State.OutByteCountPos = State.OutPosCur;
if (BufferNextByte(&State))
return 0;
State.fByteCountByteSet = 1;
/* Submit one 'ClearCode' as the first code */
if (AddCodeToBuffer(&State, State.ClearCode, CodeBits))
return 0;
for (;;) {
char Res;
/* generate and save the next code, which may consist of multiple input pixels. */
Res = NextCode(&State, &PixelValueCur, CodeBits);
if (Res < 0)
return 0;
//* Check for end of data stream */
if (!Res) {
/* submit 'eoi' as the last item of the code stream */
if (AddCodeToBuffer(&State, (unsigned short) (State.ClearCode + 1), CodeBits))
return 0;
State.fByteCountByteSet = 0;
if (State.OutBitsFree < 8) {
if (BufferNextByte(&State))
return 0;
}
// > Update last bytecount byte;
if (State.OutByteCountPos < State.OutPosCur) {
(State.pOut)[State.OutByteCountPos] = (unsigned char) (State.OutPosCur - State.OutByteCountPos - 1);
}
State.OutPosCur++;
return State.OutPosCur;
}
/* Check for currently last code */
if (State.FreeCode == (1U << CodeBits))
CodeBits++;
State.FreeCode++;
/* Check for full stringtable */
if (State.FreeCode == 0xfff) {
FlushStringTable(&State);
if (AddCodeToBuffer(&State, State.ClearCode, CodeBits))
return 0;
CodeBits = (unsigned char) (1 + 2);
State.FreeCode = (unsigned short) (State.ClearCode + 2);
}
}
}
int gif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
char outbuf[10];
FILE *gif_file;
unsigned short usTemp;
int byte_out;
#ifdef _MSC_VER
char * lzwoutbuf;
#endif
#ifndef _MSC_VER
char lzwoutbuf[symbol->bitmap_height * symbol->bitmap_width];
#else
lzwoutbuf = (char *) _alloca((symbol->bitmap_height * symbol->bitmap_width) * sizeof (char));
#endif /* _MSC_VER */
/* Open output file in binary mode */
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "610: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
#endif
gif_file = stdout;
} else {
if (!(gif_file = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "611: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
}
/*ImageWidth = 2;
ImageHeight = 2;
rotated_bitmap[0] = 1;
rotated_bitmap[1] = 1;
rotated_bitmap[2] = 0;
rotated_bitmap[3] = 0;
*/
/* GIF signature (6) */
memcpy(outbuf, "GIF87a", 6);
if (TRANSPARENT_INDEX != -1)
outbuf[4] = '9';
fwrite(outbuf, 6, 1, gif_file);
/* Screen Descriptor (7) */
/* Screen Width */
usTemp = (unsigned short) symbol->bitmap_width;
outbuf[0] = (unsigned char) (0xff & usTemp);
outbuf[1] = (unsigned char) ((0xff00 & usTemp) / 0x100);
/* Screen Height */
usTemp = (unsigned short) symbol->bitmap_height;
outbuf[2] = (unsigned char) (0xff & usTemp);
outbuf[3] = (unsigned char) ((0xff00 & usTemp) / 0x100);
/* write ImageBits-1 to the three least significant bits of byte 5 of
* the Screen Descriptor
*/
outbuf[4] = (unsigned char) (0xf0 | (0x7 & (DESTINATION_IMAGE_BITS - 1)));
/* Background color = colortable index 0 */
outbuf[5] = 0x00;
/* Byte 7 must be 0x00 */
outbuf[6] = 0x00;
fwrite(outbuf, 7, 1, gif_file);
/* Global Color Table (6) */
/* RGB 0 color */
outbuf[0] = (unsigned char) (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
outbuf[1] = (unsigned char) (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
outbuf[2] = (unsigned char) (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
/* RGB 1 color */
outbuf[3] = (unsigned char) (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
outbuf[4] = (unsigned char) (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
outbuf[5] = (unsigned char) (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
fwrite(outbuf, 6, 1, gif_file);
/* Graphic control extension (8) */
/* A graphic control extension block is used for overlay gifs.
* This is necessary to define a transparent color.
*/
if (TRANSPARENT_INDEX != -1) {
/* Extension Introducer = '!' */
outbuf[0] = '\x21';
/* Graphic Control Label */
outbuf[1] = '\xf9';
/* Block Size */
outbuf[2] = 4;
/* Packet fields:
* 3 Reserved
* 3 Disposal Method: 0 No Action, 1 No Dispose, 2: Background, 3: Prev.
* 1 User Input Flag: 0: no user input, 1: user input
* 1 Transparent Color Flag: 0: No Transparency, 1: Transparency index
*/
outbuf[3] = 1;
/* Delay Time */
outbuf[4] = 0;
outbuf[5] = 0;
/* Transparent Color Index */
outbuf[6] = (unsigned char) TRANSPARENT_INDEX;
/* Block Terminator */
outbuf[7] = 0;
fwrite(outbuf, 8, 1, gif_file);
}
/* Image Descriptor */
/* Image separator character = ',' */
outbuf[0] = 0x2c;
/* "Image Left" */
outbuf[1] = 0x00;
outbuf[2] = 0x00;
/* "Image Top" */
outbuf[3] = 0x00;
outbuf[4] = 0x00;
/* Image Width (low byte first) */
outbuf[5] = (unsigned char) (0xff & symbol->bitmap_width);
outbuf[6] = (unsigned char) ((0xff00 & symbol->bitmap_width) / 0x100);
/* Image Height */
outbuf[7] = (unsigned char) (0xff & symbol->bitmap_height);
outbuf[8] = (unsigned char) ((0xff00 & symbol->bitmap_height) / 0x100);
/* Byte 10 contains the interlaced flag and
* information on the local color table.
* There is no local color table if its most significant bit is reset.
*/
outbuf[9] = (unsigned char) (0 | (0x7 & (DESTINATION_IMAGE_BITS - 1)));
fwrite(outbuf, 10, 1, gif_file);
/* call lzw encoding */
byte_out = gif_lzw(
(unsigned char *) lzwoutbuf,
symbol->bitmap_height * symbol->bitmap_width,
(unsigned char *) pixelbuf,
symbol->bitmap_height * symbol->bitmap_width);
if (byte_out <= 0) {
fclose(gif_file);
return ZINT_ERROR_MEMORY;
}
fwrite(lzwoutbuf, byte_out, 1, gif_file);
/* GIF terminator */
fputc('\x3b', gif_file);
fclose(gif_file);
return 0;
}

1208
3rdparty/zint-2.6.1/backend/gridmtx.c vendored Normal file

File diff suppressed because it is too large Load Diff

184
3rdparty/zint-2.6.1/backend/gridmtx.h vendored Normal file
View File

@ -0,0 +1,184 @@
/* gridmtx.h - definitions for Grid Matrix
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#define GM_NUMBER 1
#define GM_LOWER 2
#define GM_UPPER 3
#define GM_MIXED 4
#define GM_CONTROL 5
#define GM_BYTE 6
#define GM_CHINESE 7
#define EUROPIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
static const char shift_set[] = {
/* From Table 7 - Encoding of control characters */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* NULL -> SI */
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* DLE -> US */
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':',
';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~'
};
static const unsigned short int gm_recommend_cw[] = {
9, 30, 59, 114, 170, 237, 315, 405, 506, 618, 741, 875, 1021
};
static const unsigned short int gm_max_cw[] = {
11, 40, 79, 146, 218, 305, 405, 521, 650, 794, 953, 1125, 1313
};
static const unsigned short int gm_data_codewords[] = {
0, 15, 13, 11, 9,
45, 40, 35, 30, 25,
89, 79, 69, 59, 49,
146, 130, 114, 98, 81,
218, 194, 170, 146, 121,
305, 271, 237, 203, 169,
405, 360, 315, 270, 225,
521, 463, 405, 347, 289,
650, 578, 506, 434, 361,
794, 706, 618, 530, 441,
953, 847, 741, 635, 529,
1125, 1000, 875, 750, 625,
1313, 1167, 1021, 875, 729
};
static const char gm_n1[] = {
18, 50, 98, 81, 121, 113, 113, 116, 121, 126, 118, 125, 122
};
static const char gm_b1[] = {
1, 1, 1, 2, 2, 2, 2, 3, 2, 7, 5, 10, 6
};
static const char gm_b2[] = {
0, 0, 0, 0, 0, 1, 2, 2, 4, 0, 4, 0, 6
};
/* Values from table A.1 */
static const char gm_ebeb[] = {
/* E1 B3 E2 B4 */
0, 0, 0, 0, // version 1
3, 1, 0, 0,
5, 1, 0, 0,
7, 1, 0, 0,
9, 1, 0, 0,
5, 1, 0, 0, // version 2
10, 1, 0, 0,
15, 1, 0, 0,
20, 1, 0, 0,
25, 1, 0, 0,
9, 1, 0, 0, // version 3
19, 1, 0, 0,
29, 1, 0, 0,
39, 1, 0, 0,
49, 1, 0, 0,
8, 2, 0, 0, // version 4
16, 2, 0, 0,
24, 2, 0, 0,
32, 2, 0, 0,
41, 1, 40, 1,
12, 2, 0, 0, // version 5
24, 2, 0, 0,
36, 2, 0, 0,
48, 2, 0, 0,
61, 1, 60, 1,
11, 3, 0, 0, // version 6
23, 1, 22, 2,
34, 2, 33, 1,
45, 3, 0, 0,
57, 1, 56, 2,
12, 1, 11, 3, // version 7
23, 2, 22, 2,
34, 3, 33, 1,
45, 4, 0, 0,
57, 1, 56, 3,
12, 2, 11, 3, // version 8
23, 5, 0, 0,
35, 3, 34, 2,
47, 1, 46, 4,
58, 4, 57, 1,
12, 6, 0, 0, // version 9
24, 6, 0, 0,
36, 6, 0, 0,
48, 6, 0, 0,
61, 1, 60, 5,
13, 4, 12, 3, // version 10
26, 1, 25, 6,
38, 5, 37, 2,
51, 2, 50, 5,
63, 7, 0, 0,
12, 6, 11, 3, // version 11
24, 4, 23, 5,
36, 2, 35, 7,
47, 9, 0, 0,
59, 7, 58, 2,
13, 5, 12, 5, // version 12
25, 10, 0, 0,
38, 5, 37, 5,
50, 10, 0, 0,
63, 5, 62, 5,
13, 1, 12, 11, //version 13
25, 3, 24, 9,
37, 5, 36, 7,
49, 7, 48, 5,
61, 9, 60, 3
};
static const unsigned short int gm_macro_matrix[] = {
728, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650,
727, 624, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 651,
726, 623, 528, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 553, 652,
725, 622, 527, 440, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 463, 554, 653,
724, 621, 526, 439, 360, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 381, 464, 555, 654,
723, 620, 525, 438, 359, 288, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 307, 382, 465, 556, 655,
722, 619, 524, 437, 358, 287, 224, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 241, 308, 383, 466, 557, 656,
721, 618, 523, 436, 357, 286, 223, 168, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 183, 242, 309, 384, 467, 558, 657,
720, 617, 522, 435, 356, 285, 222, 167, 120, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 133, 184, 243, 310, 385, 468, 559, 658,
719, 616, 521, 434, 355, 284, 221, 166, 119, 80, 49, 50, 51, 52, 53, 54, 55, 56, 91, 134, 185, 244, 311, 386, 469, 560, 659,
718, 615, 520, 433, 354, 283, 220, 165, 118, 79, 48, 25, 26, 27, 28, 29, 30, 57, 92, 135, 186, 245, 312, 387, 470, 561, 660,
717, 614, 519, 432, 353, 282, 219, 164, 117, 78, 47, 24, 9, 10, 11, 12, 31, 58, 93, 136, 187, 246, 313, 388, 471, 562, 661,
716, 613, 518, 431, 352, 281, 218, 163, 116, 77, 46, 23, 8, 1, 2, 13, 32, 59, 94, 137, 188, 247, 314, 389, 472, 563, 662,
715, 612, 517, 430, 351, 280, 217, 162, 115, 76, 45, 22, 7, 0, 3, 14, 33, 60, 95, 138, 189, 248, 315, 390, 473, 564, 663,
714, 611, 516, 429, 350, 279, 216, 161, 114, 75, 44, 21, 6, 5, 4, 15, 34, 61, 96, 139, 190, 249, 316, 391, 474, 565, 664,
713, 610, 515, 428, 349, 278, 215, 160, 113, 74, 43, 20, 19, 18, 17, 16, 35, 62, 97, 140, 191, 250, 317, 392, 475, 566, 665,
712, 609, 514, 427, 348, 277, 214, 159, 112, 73, 42, 41, 40, 39, 38, 37, 36, 63, 98, 141, 192, 251, 318, 393, 476, 567, 666,
711, 608, 513, 426, 347, 276, 213, 158, 111, 72, 71, 70, 69, 68, 67, 66, 65, 64, 99, 142, 193, 252, 319, 394, 477, 568, 667,
710, 607, 512, 425, 346, 275, 212, 157, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 143, 194, 253, 320, 395, 478, 569, 668,
709, 606, 511, 424, 345, 274, 211, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 195, 254, 321, 396, 479, 570, 669,
708, 605, 510, 423, 344, 273, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 255, 322, 397, 480, 571, 670,
707, 604, 509, 422, 343, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 323, 398, 481, 572, 671,
706, 603, 508, 421, 342, 341, 340, 339, 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, 324, 399, 482, 573, 672,
705, 602, 507, 420, 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 483, 574, 673,
704, 601, 506, 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 575, 674,
703, 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, 578, 577, 576, 675,
702, 701, 700, 699, 698, 697, 696, 695, 694, 693, 692, 691, 690, 689, 688, 687, 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, 676,
};

358
3rdparty/zint-2.6.1/backend/gs1.c vendored Normal file
View File

@ -0,0 +1,358 @@
/* gs1.c - Verifies GS1 data */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#include "gs1.h"
/* This code does some checks on the integrity of GS1 data. It is not intended
to be bulletproof, nor does it report very accurately what problem was found
or where, but should prevent some of the more common encoding errors */
void itostr(char ai_string[], int ai_value) {
int thou, hund, ten, unit;
char temp[2];
strcpy(ai_string, "(");
thou = ai_value / 1000;
hund = (ai_value - (1000 * thou)) / 100;
ten = (ai_value - ((1000 * thou) + (100 * hund))) / 10;
unit = ai_value - ((1000 * thou) + (100 * hund) + (10 * ten));
temp[1] = '\0';
if (ai_value >= 1000) {
temp[0] = itoc(thou);
strcat(ai_string, temp);
}
if (ai_value >= 100) {
temp[0] = itoc(hund);
strcat(ai_string, temp);
}
temp[0] = itoc(ten);
strcat(ai_string, temp);
temp[0] = itoc(unit);
strcat(ai_string, temp);
strcat(ai_string, ")");
}
int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const size_t src_len, char reduced[]) {
int i, j, last_ai, ai_latch;
char ai_string[6];
int bracket_level, max_bracket_level, ai_length, max_ai_length, min_ai_length;
int ai_value[100], ai_location[100], ai_count, data_location[100], data_length[100];
int error_latch;
/* Detect extended ASCII characters */
for (i = 0; i < src_len; i++) {
if (source[i] >= 128) {
strcpy(symbol->errtxt, "250: Extended ASCII characters are not supported by GS1");
return ZINT_ERROR_INVALID_DATA;
}
if (source[i] < 32) {
strcpy(symbol->errtxt, "251: Control characters are not supported by GS1 ");
return ZINT_ERROR_INVALID_DATA;
}
}
if (source[0] != '[') {
strcpy(symbol->errtxt, "252: Data does not start with an AI");
return ZINT_ERROR_INVALID_DATA;
}
/* Check the position of the brackets */
bracket_level = 0;
max_bracket_level = 0;
ai_length = 0;
max_ai_length = 0;
min_ai_length = 5;
j = 0;
ai_latch = 0;
for (i = 0; i < src_len; i++) {
ai_length += j;
if (((j == 1) && (source[i] != ']')) && ((source[i] < '0') || (source[i] > '9'))) {
ai_latch = 1;
}
if (source[i] == '[') {
bracket_level++;
j = 1;
}
if (source[i] == ']') {
bracket_level--;
if (ai_length < min_ai_length) {
min_ai_length = ai_length;
}
j = 0;
ai_length = 0;
}
if (bracket_level > max_bracket_level) {
max_bracket_level = bracket_level;
}
if (ai_length > max_ai_length) {
max_ai_length = ai_length;
}
}
min_ai_length--;
if (bracket_level != 0) {
/* Not all brackets are closed */
strcpy(symbol->errtxt, "253: Malformed AI in input data (brackets don\'t match)");
return ZINT_ERROR_INVALID_DATA;
}
if (max_bracket_level > 1) {
/* Nested brackets */
strcpy(symbol->errtxt, "254: Found nested brackets in input data");
return ZINT_ERROR_INVALID_DATA;
}
if (max_ai_length > 4) {
/* AI is too long */
strcpy(symbol->errtxt, "255: Invalid AI in input data (AI too long)");
return ZINT_ERROR_INVALID_DATA;
}
if (min_ai_length <= 1) {
/* AI is too short */
strcpy(symbol->errtxt, "256: Invalid AI in input data (AI too short)");
return ZINT_ERROR_INVALID_DATA;
}
if (ai_latch == 1) {
/* Non-numeric data in AI */
strcpy(symbol->errtxt, "257: Invalid AI in input data (non-numeric characters in AI)");
return ZINT_ERROR_INVALID_DATA;
}
ai_count = 0;
for (i = 1; i < src_len; i++) {
if (source[i - 1] == '[') {
ai_location[ai_count] = i;
j = 0;
do {
ai_string[j] = source[i + j];
j++;
} while (ai_string[j - 1] != ']');
ai_string[j - 1] = '\0';
ai_value[ai_count] = atoi(ai_string);
ai_count++;
}
}
for (i = 0; i < ai_count; i++) {
data_location[i] = ai_location[i] + 3;
if (ai_value[i] >= 100) {
data_location[i]++;
}
if (ai_value[i] >= 1000) {
data_location[i]++;
}
data_length[i] = 0;
do {
data_length[i]++;
} while ((source[data_location[i] + data_length[i] - 1] != '[') && (data_location[i] + data_length[i] <= src_len));
data_length[i]--;
}
for (i = 0; i < ai_count; i++) {
if (data_length[i] == 0) {
/* No data for given AI */
strcpy(symbol->errtxt, "258: Empty data field in input data");
return ZINT_ERROR_INVALID_DATA;
}
}
error_latch = 0;
strcpy(ai_string, "");
for (i = 0; i < ai_count; i++) {
switch (ai_value[i]) {
case 0: if (data_length[i] != 18) {
error_latch = 1;
}
break;
case 1:
case 2:
case 3: if (data_length[i] != 14) {
error_latch = 1;
}
break;
case 4: if (data_length[i] != 16) {
error_latch = 1;
}
break;
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19: if (data_length[i] != 6) {
error_latch = 1;
}
break;
case 20: if (data_length[i] != 2) {
error_latch = 1;
}
break;
case 23:
case 24:
case 25:
case 39:
case 40:
case 41:
case 42:
case 70:
case 80:
case 81: error_latch = 2;
break;
}
if (
((ai_value[i] >= 100) && (ai_value[i] <= 179))
|| ((ai_value[i] >= 1000) && (ai_value[i] <= 1799))
|| ((ai_value[i] >= 200) && (ai_value[i] <= 229))
|| ((ai_value[i] >= 2000) && (ai_value[i] <= 2299))
|| ((ai_value[i] >= 300) && (ai_value[i] <= 309))
|| ((ai_value[i] >= 3000) && (ai_value[i] <= 3099))
|| ((ai_value[i] >= 31) && (ai_value[i] <= 36))
|| ((ai_value[i] >= 310) && (ai_value[i] <= 369))
) {
error_latch = 2;
}
if ((ai_value[i] >= 3100) && (ai_value[i] <= 3699)) {
if (data_length[i] != 6) {
error_latch = 1;
}
}
if (
((ai_value[i] >= 370) && (ai_value[i] <= 379))
|| ((ai_value[i] >= 3700) && (ai_value[i] <= 3799))
) {
error_latch = 2;
}
if ((ai_value[i] >= 410) && (ai_value[i] <= 415)) {
if (data_length[i] != 13) {
error_latch = 1;
}
}
if (
((ai_value[i] >= 4100) && (ai_value[i] <= 4199))
|| ((ai_value[i] >= 700) && (ai_value[i] <= 703))
|| ((ai_value[i] >= 800) && (ai_value[i] <= 810))
|| ((ai_value[i] >= 900) && (ai_value[i] <= 999))
|| ((ai_value[i] >= 9000) && (ai_value[i] <= 9999))
) {
error_latch = 2;
}
if ((error_latch < 4) && (error_latch > 0)) {
/* error has just been detected: capture AI */
itostr(ai_string, ai_value[i]);
error_latch += 4;
}
}
if (error_latch == 5) {
strcpy(symbol->errtxt, "259: Invalid data length for AI ");
strcat(symbol->errtxt, ai_string);
return ZINT_ERROR_INVALID_DATA;
}
if (error_latch == 6) {
strcpy(symbol->errtxt, "260: Invalid AI value");
strcat(symbol->errtxt, ai_string);
return ZINT_ERROR_INVALID_DATA;
}
/* Resolve AI data - put resulting string in 'reduced' */
j = 0;
last_ai = 0;
ai_latch = 1;
for (i = 0; i < src_len; i++) {
if ((source[i] != '[') && (source[i] != ']')) {
reduced[j++] = source[i];
}
if (source[i] == '[') {
/* Start of an AI string */
if (ai_latch == 0) {
reduced[j++] = '[';
}
ai_string[0] = source[i + 1];
ai_string[1] = source[i + 2];
ai_string[2] = '\0';
last_ai = atoi(ai_string);
ai_latch = 0;
/* The following values from "GS-1 General Specification version 8.0 issue 2, May 2008"
figure 5.4.8.2.1 - 1 "Element Strings with Pre-Defined Length Using Application Identifiers" */
if (
((last_ai >= 0) && (last_ai <= 4))
|| ((last_ai >= 11) && (last_ai <= 20))
|| (last_ai == 23) /* legacy support - see 5.3.8.2.2 */
|| ((last_ai >= 31) && (last_ai <= 36))
|| (last_ai == 41)
) {
ai_latch = 1;
}
}
/* The ']' character is simply dropped from the input */
}
reduced[j] = '\0';
/* the character '[' in the reduced string refers to the FNC1 character */
return 0;
}
int ugs1_verify(struct zint_symbol *symbol, const unsigned char source[], const unsigned int src_len, unsigned char reduced[]) {
/* Only to keep the compiler happy */
#ifndef _MSC_VER
char temp[src_len + 5];
#else
char* temp = (char*) _alloca(src_len + 5);
#endif
int error_number;
error_number = gs1_verify(symbol, source, src_len, temp);
if (error_number != 0) {
return error_number;
}
if (strlen(temp) < src_len + 5) {
ustrcpy(reduced, (unsigned char*) temp);
return 0;
}
strcpy(symbol->errtxt, "261: ugs1_verify overflow");
return ZINT_ERROR_INVALID_DATA;
}

46
3rdparty/zint-2.6.1/backend/gs1.h vendored Normal file
View File

@ -0,0 +1,46 @@
/* gs1.h - Verifies GS1 data */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef __GS1_H
#define __GS1_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const size_t src_len, char reduced[]);
extern int ugs1_verify(struct zint_symbol *symbol, const unsigned char source[], const unsigned int src_len, unsigned char reduced[]);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GS1_H */

1576
3rdparty/zint-2.6.1/backend/hanxin.c vendored Normal file

File diff suppressed because it is too large Load Diff

460
3rdparty/zint-2.6.1/backend/hanxin.h vendored Normal file
View File

@ -0,0 +1,460 @@
/* hanxin.h - definitions for Han Xin code
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2016 Zoe Stuart
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* Data from table B1: Data capacity of Han Xin Code */
static const unsigned short int hx_total_codewords[] = {
25, 37, 50, 54, 69, 84, 100, 117, 136, 155, 161, 181, 203, 225, 249,
273, 299, 325, 353, 381, 411, 422, 453, 485, 518, 552, 587, 623, 660,
698, 737, 754, 794, 836, 878, 922, 966, 1011, 1058, 1105, 1126, 1175,
1224, 1275, 1327, 1380, 1434, 1489, 1513, 1569, 1628, 1686, 1745, 1805,
1867, 1929, 1992, 2021, 2086, 2151, 2218, 2286, 2355, 2425, 2496, 2528,
2600, 2673, 2749, 2824, 2900, 2977, 3056, 3135, 3171, 3252, 3334, 3416,
3500, 3585, 3671, 3758, 3798, 3886
};
static const unsigned short int hx_data_codewords_L1[] = {
21, 31, 42, 46, 57, 70, 84, 99, 114, 131, 135, 153, 171, 189, 209, 229,
251, 273, 297, 321, 345, 354, 381, 407, 436, 464, 493, 523, 554, 586, 619,
634, 666, 702, 738, 774, 812, 849, 888, 929, 946, 987, 1028, 1071, 1115,
1160, 1204, 1251, 1271, 1317, 1368, 1416, 1465, 1517, 1569, 1621, 1674,
1697, 1752, 1807, 1864, 1920, 1979, 2037, 2096, 2124, 2184, 2245, 2309,
2372, 2436, 2501, 2568, 2633, 2663, 2732, 2800, 2870, 2940, 3011,
3083, 3156, 3190, 3264
};
static const unsigned short int hx_data_codewords_L2[] = {
17, 25, 34, 38, 49, 58, 70, 81, 96, 109, 113, 127, 143, 157, 175, 191, 209,
227, 247, 267, 287, 296, 317, 339, 362, 386, 411, 437, 462, 488, 515, 528,
556, 586, 614, 646, 676, 707, 740, 773, 788, 823, 856, 893, 929, 966, 1004,
1043, 1059, 1099, 1140, 1180, 1221, 1263, 1307, 1351, 1394, 1415, 1460,
1505, 1552, 1600, 1649, 1697, 1748, 1770, 1820, 1871, 1925, 1976, 2030,
2083, 2140, 2195, 2219, 2276, 2334, 2392, 2450, 2509, 2569, 2630, 2658,
2720
};
static const unsigned short int hx_data_codewords_L3[] = {
13, 19, 26, 30, 37, 46, 54, 63, 74, 83, 87, 97, 109, 121, 135, 147, 161,
175, 191, 205, 221, 228, 245, 261, 280, 298, 317, 337, 358, 376, 397, 408,
428, 452, 474, 498, 522, 545, 572, 597, 608, 635, 660, 689, 717, 746, 774,
805, 817, 847, 880, 910, 943, 975, 1009, 1041, 1076, 1091, 1126, 1161, 1198,
1234, 1271, 1309, 1348, 1366, 1404, 1443, 1485, 1524, 1566, 1607, 1650, 1693,
1713, 1756, 1800, 1844, 1890, 1935, 1983, 2030, 2050, 2098
};
static const unsigned short int hx_data_codewords_L4[] = {
9, 15, 20, 22, 27, 34, 40, 47, 54, 61, 65, 73, 81, 89, 99, 109, 119, 129,
141, 153, 165, 168, 181, 195, 208, 220, 235, 251, 264, 280, 295, 302, 318,
334, 352, 368, 386, 405, 424, 441, 450, 469, 490, 509, 531, 552, 574, 595, 605,
627, 652, 674, 697, 721, 747, 771, 796, 809, 834, 861, 892, 914, 941, 969, 998,
1012, 1040, 1069, 1099, 1130, 1160, 1191, 1222, 1253, 1269, 1300, 1334,
1366, 1400, 1433, 1469, 1504, 1520, 1554
};
/* Value 'k' from Annex A */
static const char hx_module_k[] = {
0, 0, 0, 14, 16, 16, 17, 18, 19, 20,
14, 15, 16, 16, 17, 17, 18, 19, 20, 20,
21, 16, 17, 17, 18, 18, 19, 19, 20, 20,
21, 17, 17, 18, 18, 19, 19, 19, 20, 20,
17, 17, 18, 18, 18, 19, 19, 19, 17, 17,
18, 18, 18, 18, 19, 19, 19, 17, 17, 18,
18, 18, 18, 19, 19, 17, 17, 17, 18, 18,
18, 18, 19, 19, 17, 17, 17, 18, 18, 18,
18, 18, 17, 17
};
/* Value 'r' from Annex A */
static const char hx_module_r[] = {
0, 0, 0, 15, 15, 17, 18, 19, 20, 21,
15, 15, 15, 17, 17, 19, 19, 19, 19, 21,
21, 17, 16, 18, 17, 19, 18, 20, 19, 21,
20, 17, 19, 17, 19, 17, 19, 21, 19, 21,
18, 20, 17, 19, 21, 18, 20, 22, 17, 19,
15, 17, 19, 21, 17, 19, 21, 18, 20, 15,
17, 19, 21, 16, 18, 17, 19, 21, 15, 17,
19, 21, 15, 17, 18, 20, 22, 15, 17, 19,
21, 23, 17, 19
};
/* Value of 'm' from Annex A */
static const char hx_module_m[] = {
0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
6, 6, 6, 6, 6, 6, 6, 7, 7, 7,
7, 7, 7, 7, 7, 8, 8, 8, 8, 8,
8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
9, 9, 10, 10
};
/* Error correction block sizes from Table D1 */
static const unsigned short int hx_table_d1[] = {
/* #blocks, k, 2t, #blocks, k, 2t, #blocks, k, 2t */
1, 21, 4, 0, 0, 0, 0, 0, 0, // version 1
1, 17, 8, 0, 0, 0, 0, 0, 0,
1, 13, 12, 0, 0, 0, 0, 0, 0,
1, 9, 16, 0, 0, 0, 0, 0, 0,
1, 31, 6, 0, 0, 0, 0, 0, 0, // version 2
1, 25, 12, 0, 0, 0, 0, 0, 0,
1, 19, 18, 0, 0, 0, 0, 0, 0,
1, 15, 22, 0, 0, 0, 0, 0, 0,
1, 42, 8, 0, 0, 0, 0, 0, 0, // version 3
1, 34, 16, 0, 0, 0, 0, 0, 0,
1, 26, 24, 0, 0, 0, 0, 0, 0,
1, 20, 30, 0, 0, 0, 0, 0, 0,
1, 46, 8, 0, 0, 0, 0, 0, 0, // version 4
1, 38, 16, 0, 0, 0, 0, 0, 0,
1, 30, 24, 0, 0, 0, 0, 0, 0,
1, 22, 32, 0, 0, 0, 0, 0, 0,
1, 57, 12, 0, 0, 0, 0, 0, 0, // version 5
1, 49, 20, 0, 0, 0, 0, 0, 0,
1, 37, 32, 0, 0, 0, 0, 0, 0,
1, 14, 20, 1, 13, 22, 0, 0, 0,
1, 70, 14, 0, 0, 0, 0, 0, 0, // version 6
1, 58, 26, 0, 0, 0, 0, 0, 0,
1, 24, 20, 1, 22, 18, 0, 0, 0,
1, 16, 24, 1, 18, 26, 0, 0, 0,
1, 84, 16, 0, 0, 0, 0, 0, 0, // version 7
1, 70, 30, 0, 0, 0, 0, 0, 0,
1, 26, 22, 1, 28, 24, 0, 0, 0,
2, 14, 20, 1, 12, 20, 0, 0, 0,
1, 99, 18, 0, 0, 0, 0, 0, 0, // version 8
1, 40, 18, 1, 41, 18, 0, 0, 0,
1, 31, 26, 1, 32, 28, 0, 0, 0,
2, 16, 24, 1, 15, 22, 0, 0, 0,
1, 114, 22, 0, 0, 0, 0, 0, 0, // version 9
2, 48, 20, 0, 0, 0, 0, 0, 0,
2, 24, 20, 1, 26, 22, 0, 0, 0,
2, 18, 28, 1, 18, 26, 0, 0, 0,
1, 131, 24, 0, 0, 0, 0, 0, 0, // version 10
1, 52, 22, 1, 57, 24, 0, 0, 0,
2, 27, 24, 1, 29, 24, 0, 0, 0,
2, 21, 32, 1, 19, 30, 0, 0, 0,
1, 135, 26, 0, 0, 0, 0, 0, 0, // version 11
1, 56, 24, 1, 57, 24, 0, 0, 0,
2, 28, 24, 1, 31, 26, 0, 0, 0,
2, 22, 32, 1, 21, 32, 0, 0, 0,
1, 153, 28, 0, 0, 0, 0, 0, 0, // version 12
1, 62, 26, 1, 65, 28, 0, 0, 0,
2, 32, 28, 1, 33, 28, 0, 0, 0,
3, 17, 26, 1, 22, 30, 0, 0, 0,
1, 86, 16, 1, 85, 16, 0, 0, 0, // version 13
1, 71, 30, 1, 72, 30, 0, 0, 0,
2, 37, 32, 1, 35, 30, 0, 0, 0,
3, 20, 30, 1, 21, 32, 0, 0, 0,
1, 94, 18, 1, 95, 18, 0, 0, 0, // version 14
2, 51, 22, 1, 55, 24, 0, 0, 0,
3, 30, 26, 1, 31, 26, 0, 0, 0,
4, 18, 28, 1, 17, 24, 0, 0, 0,
1, 104, 20, 1, 105, 20, 0, 0, 0, // version 15
2, 57, 24, 1, 61, 26, 0, 0, 0,
3, 33, 28, 1, 36, 30, 0, 0, 0,
4, 20, 30, 1, 19, 30, 0, 0, 0,
1, 115, 22, 1, 114, 22, 0, 0, 0, // version 16
2, 65, 28, 1, 61, 26, 0, 0, 0,
3, 38, 32, 1, 33, 30, 0, 0, 0,
5, 19, 28, 1, 14, 24, 0, 0, 0,
1, 126, 24, 1, 125, 24, 0, 0, 0, // version 17
2, 70, 30, 1, 69, 30, 0, 0, 0,
4, 33, 28, 1, 29, 26, 0, 0, 0,
5, 20, 30, 1, 19, 30, 0, 0, 0,
1, 136, 26, 1, 137, 26, 0, 0, 0, //version 18
3, 56, 24, 1, 59, 26, 0, 0, 0,
5, 35, 30, 0, 0, 0, 0, 0, 0,
6, 18, 28, 1, 21, 28, 0, 0, 0,
1, 148, 28, 1, 149, 28, 0, 0, 0, // version 19
3, 61, 26, 1, 64, 28, 0, 0, 0,
7, 24, 20, 1, 23, 22, 0, 0, 0,
6, 20, 30, 1, 21, 32, 0, 0, 0,
3, 107, 20, 0, 0, 0, 0, 0, 0, // version 20
3, 65, 28, 1, 72, 30, 0, 0, 0,
7, 26, 22, 1, 23, 22, 0, 0, 0,
7, 19, 28, 1, 20, 32, 0, 0, 0,
3, 115, 22, 0, 0, 0, 0, 0, 0, // version 21
4, 56, 24, 1, 63, 28, 0, 0, 0,
7, 28, 24, 1, 25, 22, 0, 0, 0,
8, 18, 28, 1, 21, 22, 0, 0, 0,
2, 116, 22, 1, 122, 24, 0, 0, 0, // version 22
4, 56, 24, 1, 72, 30, 0, 0, 0,
7, 28, 24, 1, 32, 26, 0, 0, 0,
8, 18, 28, 1, 24, 30, 0, 0, 0,
3, 127, 24, 0, 0, 0, 0, 0, 0, // version 23
5, 51, 22, 1, 62, 26, 0, 0, 0,
7, 30, 26, 1, 35, 26, 0, 0, 0,
8, 20, 30, 1, 21, 32, 0, 0, 0,
2, 135, 26, 1, 137, 26, 0, 0, 0, // version 24
5, 56, 24, 1, 59, 26, 0, 0, 0,
7, 33, 28, 1, 30, 28, 0, 0, 0,
11, 16, 24, 1, 19, 26, 0, 0, 0,
3, 105, 20, 1, 121, 22, 0, 0, 0, // version 25
5, 61, 26, 1, 57, 26, 0, 0, 0,
9, 28, 24, 1, 28, 22, 0, 0, 0,
10, 19, 28, 1, 18, 30, 0, 0, 0,
2, 157, 30, 1, 150, 28, 0, 0, 0, // version 26
5, 65, 28, 1, 61, 26, 0, 0, 0,
8, 33, 28, 1, 34, 30, 0, 0, 0,
10, 19, 28, 2, 15, 26, 0, 0, 0,
3, 126, 24, 1, 115, 22, 0, 0, 0, // version 27
7, 51, 22, 1, 54, 22, 0, 0, 0,
8, 35, 30, 1, 37, 30, 0, 0, 0,
15, 15, 22, 1, 10, 22, 0, 0, 0,
4, 105, 20, 1, 103, 20, 0, 0, 0, // version 28
7, 56, 24, 1, 45, 18, 0, 0, 0,
10, 31, 26, 1, 27, 26, 0, 0, 0,
10, 17, 26, 3, 20, 28, 1, 21, 28,
3, 139, 26, 1, 137, 28, 0, 0, 0, // version 29
6, 66, 28, 1, 66, 30, 0, 0, 0,
9, 36, 30, 1, 34, 32, 0, 0, 0,
13, 19, 28, 1, 17, 32, 0, 0, 0,
6, 84, 16, 1, 82, 16, 0, 0, 0, // version 30
6, 70, 30, 1, 68, 30, 0, 0, 0,
7, 35, 30, 3, 33, 28, 1, 32, 28,
13, 20, 30, 1, 20, 28, 0, 0, 0,
5, 105, 20, 1, 94, 18, 0, 0, 0, // version 31
6, 74, 32, 1, 71, 30, 0, 0, 0,
11, 33, 28, 1, 34, 32, 0, 0, 0,
13, 19, 28, 3, 16, 26, 0, 0, 0,
4, 127, 24, 1, 126, 24, 0, 0, 0, // version 32
7, 66, 28, 1, 66, 30, 0, 0, 0,
12, 30, 24, 1, 24, 28, 1, 24, 30,
15, 19, 28, 1, 17, 32, 0, 0, 0,
7, 84, 16, 1, 78, 16, 0, 0, 0, // version 33
7, 70, 30, 1, 66, 28, 0, 0, 0,
12, 33, 28, 1, 32, 30, 0, 0, 0,
14, 21, 32, 1, 24, 28, 0, 0, 0,
5, 117, 22, 1, 117, 24, 0, 0, 0, // version 34
8, 66, 28, 1, 58, 26, 0, 0, 0,
11, 38, 32, 1, 34, 32, 0, 0, 0,
15, 20, 30, 2, 17, 26, 0, 0, 0,
4, 148, 28, 1, 146, 28, 0, 0, 0, // version 35
8, 68, 30, 1, 70, 24, 0, 0, 0,
10, 36, 32, 3, 38, 28, 0, 0, 0,
16, 19, 28, 3, 16, 26, 0, 0, 0,
4, 126, 24, 2, 135, 26, 0, 0, 0, // version 36
8, 70, 28, 2, 43, 26, 0, 0, 0,
13, 32, 28, 2, 41, 30, 0, 0, 0,
17, 19, 28, 3, 15, 26, 0, 0, 0,
5, 136, 26, 1, 132, 24, 0, 0, 0, // version 37
5, 67, 30, 4, 68, 28, 1, 69, 28,
14, 35, 30, 1, 32, 24, 0, 0, 0,
18, 18, 26, 3, 16, 28, 1, 14, 28,
3, 142, 26, 3, 141, 28, 0, 0, 0, // version 38
8, 70, 30, 1, 73, 32, 1, 74, 32,
12, 34, 30, 3, 34, 26, 1, 35, 28,
18, 21, 32, 1, 27, 30, 0, 0, 0,
5, 116, 22, 2, 103, 20, 1, 102, 20, // version 39
9, 74, 32, 1, 74, 30, 0, 0, 0,
14, 34, 28, 2, 32, 32, 1, 32, 30,
19, 21, 32, 1, 25, 26, 0, 0, 0,
7, 116, 22, 1, 117, 22, 0, 0, 0, // version 40
11, 65, 28, 1, 58, 24, 0, 0, 0,
15, 38, 32, 1, 27, 28, 0, 0, 0,
20, 20, 30, 1, 20, 32, 1, 21, 32,
6, 136, 26, 1, 130, 24, 0, 0, 0, // version 41
11, 66, 28, 1, 62, 30, 0, 0, 0,
14, 34, 28, 3, 34, 32, 1, 30, 30,
18, 20, 30, 3, 20, 28, 2, 15, 26,
5, 105, 20, 2, 115, 22, 2, 116, 22, // version 42
10, 75, 32, 1, 73, 32, 0, 0, 0,
16, 38, 32, 1, 27, 28, 0, 0, 0,
22, 19, 28, 2, 16, 30, 1, 19, 30,
6, 147, 28, 1, 146, 28, 0, 0, 0, // version 43
11, 66, 28, 2, 65, 30, 0, 0, 0,
18, 33, 28, 2, 33, 30, 0, 0, 0,
22, 21, 32, 1, 28, 30, 0, 0, 0,
6, 116, 22, 3, 125, 24, 0, 0, 0, // version 44
11, 75, 32, 1, 68, 30, 0, 0, 0,
13, 35, 28, 6, 34, 32, 1, 30, 30,
23, 21, 32, 1, 26, 30, 0, 0, 0,
7, 105, 20, 4, 95, 18, 0, 0, 0, // version 45
12, 67, 28, 1, 63, 30, 1, 62, 32,
21, 31, 26, 2, 33, 32, 0, 0, 0,
23, 21, 32, 2, 24, 30, 0, 0, 0,
10, 116, 22, 0, 0, 0, 0, 0, 0, // version 46
12, 74, 32, 1, 78, 30, 0, 0, 0,
18, 37, 32, 1, 39, 30, 1, 41, 28,
25, 21, 32, 1, 27, 28, 0, 0, 0,
5, 126, 24, 4, 115, 22, 1, 114, 22, // version 47
12, 67, 28, 2, 66, 32, 1, 68, 30,
21, 35, 30, 1, 39, 30, 0, 0, 0,
26, 21, 32, 1, 28, 28, 0, 0, 0,
9, 126, 24, 1, 117, 22, 0, 0, 0, // version 48
13, 75, 32, 1, 68, 30, 0, 0, 0,
20, 35, 30, 3, 35, 28, 0, 0, 0,
27, 21, 32, 1, 28, 30, 0, 0, 0,
9, 126, 24, 1, 137, 26, 0, 0, 0, // version 49
13, 71, 30, 2, 68, 32, 0, 0, 0,
20, 37, 32, 1, 39, 28, 1, 38, 28,
24, 20, 32, 5, 25, 28, 0, 0, 0,
8, 147, 28, 1, 141, 28, 0, 0, 0, // version 50
10, 73, 32, 4, 74, 30, 1, 73, 30,
16, 36, 32, 6, 39, 30, 1, 37, 30,
27, 21, 32, 3, 20, 26, 0, 0, 0,
9, 137, 26, 1, 135, 26, 0, 0, 0, // version 51
12, 70, 30, 4, 75, 32, 0, 0, 0,
24, 35, 30, 1, 40, 28, 0, 0, 0,
23, 20, 32, 8, 24, 30, 0, 0, 0,
14, 95, 18, 1, 86, 18, 0, 0, 0, // version 52
13, 73, 32, 3, 77, 30, 0, 0, 0,
24, 35, 30, 2, 35, 28, 0, 0, 0,
26, 21, 32, 5, 21, 30, 1, 23, 30,
9, 147, 28, 1, 142, 28, 0, 0, 0, // version 53
10, 73, 30, 6, 70, 32, 1, 71, 32,
25, 35, 30, 2, 34, 26, 0, 0, 0,
29, 21, 32, 4, 22, 30, 0, 0, 0,
11, 126, 24, 1, 131, 24, 0, 0, 0, // version 54
16, 74, 32, 1, 79, 30, 0, 0, 0,
25, 38, 32, 1, 25, 30, 0, 0, 0,
33, 21, 32, 1, 28, 28, 0, 0, 0,
14, 105, 20, 1, 99, 18, 0, 0, 0, // version 55
19, 65, 28, 1, 72, 28, 0, 0, 0,
24, 37, 32, 2, 40, 30, 1, 41, 30,
31, 21, 32, 4, 24, 32, 0, 0, 0,
10, 147, 28, 1, 151, 28, 0, 0, 0, // version 56
15, 71, 30, 3, 71, 32, 1, 73, 32,
24, 37, 32, 3, 38, 30, 1, 39, 30,
36, 19, 30, 3, 29, 26, 0, 0, 0,
15, 105, 20, 1, 99, 18, 0, 0, 0, // version 57
19, 70, 30, 1, 64, 28, 0, 0, 0,
27, 38, 32, 2, 25, 26, 0, 0, 0,
38, 20, 30, 2, 18, 28, 0, 0, 0,
14, 105, 20, 1, 113, 22, 1, 114, 22, // version 58
17, 67, 30, 3, 92, 32, 0, 0, 0,
30, 35, 30, 1, 41, 30, 0, 0, 0,
36, 21, 32, 1, 26, 30, 1, 27, 30,
11, 146, 28, 1, 146, 26, 0, 0, 0, // version 59
20, 70, 30, 1, 60, 26, 0, 0, 0,
29, 38, 32, 1, 24, 32, 0, 0, 0,
40, 20, 30, 2, 17, 26, 0, 0, 0,
3, 137, 26, 1, 136, 26, 10, 126, 24, // version 60
22, 65, 28, 1, 75, 30, 0, 0, 0,
30, 37, 32, 1, 51, 30, 0, 0, 0,
42, 20, 30, 1, 21, 30, 0, 0, 0,
12, 126, 24, 2, 118, 22, 1, 116, 22, // version 61
19, 74, 32, 1, 74, 30, 1, 72, 28,
30, 38, 32, 2, 29, 30, 0, 0, 0,
39, 20, 32, 2, 37, 26, 1, 38, 26,
12, 126, 24, 3, 136, 26, 0, 0, 0, // version 62
21, 70, 30, 2, 65, 28, 0, 0, 0,
34, 35, 30, 1, 44, 32, 0, 0, 0,
42, 20, 30, 2, 19, 28, 2, 18, 28,
12, 126, 24, 3, 117, 22, 1, 116, 22, // version 63
25, 61, 26, 2, 62, 28, 0, 0, 0,
34, 35, 30, 1, 40, 32, 1, 41, 32,
45, 20, 30, 1, 20, 32, 1, 21, 32,
15, 105, 20, 2, 115, 22, 2, 116, 22, // version 64
25, 65, 28, 1, 72, 28, 0, 0, 0,
18, 35, 30, 17, 37, 32, 1, 50, 32,
42, 20, 30, 6, 19, 28, 1, 15, 28,
19, 105, 20, 1, 101, 20, 0, 0, 0, // version 65
33, 51, 22, 1, 65, 22, 0, 0, 0,
40, 33, 28, 1, 28, 28, 0, 0, 0,
49, 20, 30, 1, 18, 28, 0, 0, 0,
18, 105, 20, 2, 117, 22, 0, 0, 0, // version 66
26, 65, 28, 1, 80, 30, 0, 0, 0,
35, 35, 30, 3, 35, 28, 1, 36, 28,
52, 18, 28, 2, 38, 30, 0, 0, 0,
26, 84, 16, 0, 0, 0, 0, 0, 0, // version 67
26, 70, 30, 0, 0, 0, 0, 0, 0,
45, 31, 26, 1, 9, 26, 0, 0, 0,
52, 20, 30, 0, 0, 0, 0, 0, 0,
16, 126, 24, 1, 114, 22, 1, 115, 22, // version 68
23, 70, 30, 3, 65, 28, 1, 66, 28,
40, 35, 30, 1, 43, 30, 0, 0, 0,
46, 20, 30, 7, 19, 28, 1, 16, 28,
19, 116, 22, 1, 105, 22, 0, 0, 0, // version 69
20, 70, 30, 7, 66, 28, 1, 63, 28,
40, 35, 30, 1, 42, 32, 1, 43, 32,
54, 20, 30, 1, 19, 30, 0, 0, 0,
17, 126, 24, 2, 115, 22, 0, 0, 0, // version 70
24, 70, 30, 4, 74, 32, 0, 0, 0,
48, 31, 26, 2, 18, 26, 0, 0, 0,
54, 19, 28, 6, 15, 26, 1, 14, 26,
29, 84, 16, 0, 0, 0, 0, 0, 0, // version 71
29, 70, 30, 0, 0, 0, 0, 0, 0,
6, 34, 30, 3, 36, 30, 38, 33, 28,
58, 20, 30, 0, 0, 0, 0, 0, 0,
16, 147, 28, 1, 149, 28, 0, 0, 0, // version 72
31, 66, 28, 1, 37, 26, 0, 0, 0,
48, 33, 28, 1, 23, 26, 0, 0, 0,
53, 20, 30, 6, 19, 28, 1, 17, 28,
20, 115, 22, 2, 134, 24, 0, 0, 0, // verdion 73
29, 66, 28, 2, 56, 26, 2, 57, 26,
45, 36, 30, 2, 15, 28, 0, 0, 0,
59, 20, 30, 2, 21, 32, 0, 0, 0,
17, 147, 28, 1, 134, 26, 0, 0, 0, // version 74
26, 70, 30, 5, 75, 32, 0, 0, 0,
47, 35, 30, 1, 48, 32, 0, 0, 0,
64, 18, 28, 2, 33, 30, 1, 35, 30,
22, 115, 22, 1, 133, 24, 0, 0, 0, // version 75
33, 65, 28, 1, 74, 28, 0, 0, 0,
43, 36, 30, 5, 27, 28, 1, 30, 28,
57, 20, 30, 5, 21, 32, 1, 24, 32,
18, 136, 26, 2, 142, 26, 0, 0, 0, // version 76
33, 66, 28, 2, 49, 26, 0, 0, 0,
48, 35, 30, 2, 38, 28, 0, 0, 0,
64, 20, 30, 1, 20, 32, 0, 0, 0,
19, 126, 24, 2, 135, 26, 1, 136, 26, // version 77
32, 66, 28, 2, 55, 26, 2, 56, 26,
49, 36, 30, 2, 18, 32, 0, 0, 0,
65, 18, 28, 5, 27, 30, 1, 29, 30,
20, 137, 26, 1, 130, 26, 0, 0, 0, // version 78
30, 75, 32, 2, 71, 32, 0, 0, 0,
46, 35, 30, 6, 39, 32, 0, 0, 0,
3, 12, 30, 70, 19, 28, 0, 0, 0,
20, 147, 28, 0, 0, 0, 0, 0, 0, // version 79
35, 70, 30, 0, 0, 0, 0, 0, 0,
49, 35, 30, 5, 35, 28, 0, 0, 0,
70, 20, 30, 0, 0, 0, 0, 0, 0,
21, 136, 26, 1, 155, 28, 0, 0, 0, // version 80
34, 70, 30, 1, 64, 28, 1, 65, 28,
54, 35, 30, 1, 45, 30, 0, 0, 0,
68, 20, 30, 3, 18, 28, 1, 19, 28,
19, 126, 24, 5, 115, 22, 1, 114, 22, // version 81
33, 70, 30, 3, 65, 28, 1, 64, 28,
52, 35, 30, 3, 41, 32, 1, 40, 32,
67, 20, 30, 5, 21, 32, 1, 24, 32,
2, 150, 28, 21, 136, 26, 0, 0, 0, // version 82
32, 70, 30, 6, 65, 28, 0, 0, 0,
52, 38, 32, 2, 27, 32, 0, 0, 0,
73, 20, 30, 2, 22, 32, 0, 0, 0,
21, 126, 24, 4, 136, 26, 0, 0, 0, // version 83
30, 74, 32, 6, 73, 30, 0, 0, 0,
54, 35, 30, 4, 40, 32, 0, 0, 0,
75, 20, 30, 1, 20, 28, 0, 0, 0,
30, 105, 20, 1, 114, 22, 0, 0, 0, // version 84
3, 45, 22, 55, 47, 20, 0, 0, 0,
2, 26, 26, 62, 33, 28, 0, 0, 0,
79, 18, 28, 4, 33, 30, 0, 0, 0
};

605
3rdparty/zint-2.6.1/backend/imail.c vendored Normal file
View File

@ -0,0 +1,605 @@
/* imail.c - Handles Intelligent Mail (aka OneCode) for USPS */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* The function "USPS_MSB_Math_CRC11GenerateFrameCheckSequence"
is Copyright (C) 2006 United States Postal Service */
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "common.h"
#include "large.h"
#define SODIUM "0123456789-"
/* The following lookup tables were generated using the code in Appendix C */
static const unsigned short AppxD_I[1287] = {
/* Appendix D Table 1 - 5 of 13 characters */
0x001F, 0x1F00, 0x002F, 0x1E80, 0x0037, 0x1D80, 0x003B, 0x1B80, 0x003D, 0x1780,
0x003E, 0x0F80, 0x004F, 0x1E40, 0x0057, 0x1D40, 0x005B, 0x1B40, 0x005D, 0x1740,
0x005E, 0x0F40, 0x0067, 0x1CC0, 0x006B, 0x1AC0, 0x006D, 0x16C0, 0x006E, 0x0EC0,
0x0073, 0x19C0, 0x0075, 0x15C0, 0x0076, 0x0DC0, 0x0079, 0x13C0, 0x007A, 0x0BC0,
0x007C, 0x07C0, 0x008F, 0x1E20, 0x0097, 0x1D20, 0x009B, 0x1B20, 0x009D, 0x1720,
0x009E, 0x0F20, 0x00A7, 0x1CA0, 0x00AB, 0x1AA0, 0x00AD, 0x16A0, 0x00AE, 0x0EA0,
0x00B3, 0x19A0, 0x00B5, 0x15A0, 0x00B6, 0x0DA0, 0x00B9, 0x13A0, 0x00BA, 0x0BA0,
0x00BC, 0x07A0, 0x00C7, 0x1C60, 0x00CB, 0x1A60, 0x00CD, 0x1660, 0x00CE, 0x0E60,
0x00D3, 0x1960, 0x00D5, 0x1560, 0x00D6, 0x0D60, 0x00D9, 0x1360, 0x00DA, 0x0B60,
0x00DC, 0x0760, 0x00E3, 0x18E0, 0x00E5, 0x14E0, 0x00E6, 0x0CE0, 0x00E9, 0x12E0,
0x00EA, 0x0AE0, 0x00EC, 0x06E0, 0x00F1, 0x11E0, 0x00F2, 0x09E0, 0x00F4, 0x05E0,
0x00F8, 0x03E0, 0x010F, 0x1E10, 0x0117, 0x1D10, 0x011B, 0x1B10, 0x011D, 0x1710,
0x011E, 0x0F10, 0x0127, 0x1C90, 0x012B, 0x1A90, 0x012D, 0x1690, 0x012E, 0x0E90,
0x0133, 0x1990, 0x0135, 0x1590, 0x0136, 0x0D90, 0x0139, 0x1390, 0x013A, 0x0B90,
0x013C, 0x0790, 0x0147, 0x1C50, 0x014B, 0x1A50, 0x014D, 0x1650, 0x014E, 0x0E50,
0x0153, 0x1950, 0x0155, 0x1550, 0x0156, 0x0D50, 0x0159, 0x1350, 0x015A, 0x0B50,
0x015C, 0x0750, 0x0163, 0x18D0, 0x0165, 0x14D0, 0x0166, 0x0CD0, 0x0169, 0x12D0,
0x016A, 0x0AD0, 0x016C, 0x06D0, 0x0171, 0x11D0, 0x0172, 0x09D0, 0x0174, 0x05D0,
0x0178, 0x03D0, 0x0187, 0x1C30, 0x018B, 0x1A30, 0x018D, 0x1630, 0x018E, 0x0E30,
0x0193, 0x1930, 0x0195, 0x1530, 0x0196, 0x0D30, 0x0199, 0x1330, 0x019A, 0x0B30,
0x019C, 0x0730, 0x01A3, 0x18B0, 0x01A5, 0x14B0, 0x01A6, 0x0CB0, 0x01A9, 0x12B0,
0x01AA, 0x0AB0, 0x01AC, 0x06B0, 0x01B1, 0x11B0, 0x01B2, 0x09B0, 0x01B4, 0x05B0,
0x01B8, 0x03B0, 0x01C3, 0x1870, 0x01C5, 0x1470, 0x01C6, 0x0C70, 0x01C9, 0x1270,
0x01CA, 0x0A70, 0x01CC, 0x0670, 0x01D1, 0x1170, 0x01D2, 0x0970, 0x01D4, 0x0570,
0x01D8, 0x0370, 0x01E1, 0x10F0, 0x01E2, 0x08F0, 0x01E4, 0x04F0, 0x01E8, 0x02F0,
0x020F, 0x1E08, 0x0217, 0x1D08, 0x021B, 0x1B08, 0x021D, 0x1708, 0x021E, 0x0F08,
0x0227, 0x1C88, 0x022B, 0x1A88, 0x022D, 0x1688, 0x022E, 0x0E88, 0x0233, 0x1988,
0x0235, 0x1588, 0x0236, 0x0D88, 0x0239, 0x1388, 0x023A, 0x0B88, 0x023C, 0x0788,
0x0247, 0x1C48, 0x024B, 0x1A48, 0x024D, 0x1648, 0x024E, 0x0E48, 0x0253, 0x1948,
0x0255, 0x1548, 0x0256, 0x0D48, 0x0259, 0x1348, 0x025A, 0x0B48, 0x025C, 0x0748,
0x0263, 0x18C8, 0x0265, 0x14C8, 0x0266, 0x0CC8, 0x0269, 0x12C8, 0x026A, 0x0AC8,
0x026C, 0x06C8, 0x0271, 0x11C8, 0x0272, 0x09C8, 0x0274, 0x05C8, 0x0278, 0x03C8,
0x0287, 0x1C28, 0x028B, 0x1A28, 0x028D, 0x1628, 0x028E, 0x0E28, 0x0293, 0x1928,
0x0295, 0x1528, 0x0296, 0x0D28, 0x0299, 0x1328, 0x029A, 0x0B28, 0x029C, 0x0728,
0x02A3, 0x18A8, 0x02A5, 0x14A8, 0x02A6, 0x0CA8, 0x02A9, 0x12A8, 0x02AA, 0x0AA8,
0x02AC, 0x06A8, 0x02B1, 0x11A8, 0x02B2, 0x09A8, 0x02B4, 0x05A8, 0x02B8, 0x03A8,
0x02C3, 0x1868, 0x02C5, 0x1468, 0x02C6, 0x0C68, 0x02C9, 0x1268, 0x02CA, 0x0A68,
0x02CC, 0x0668, 0x02D1, 0x1168, 0x02D2, 0x0968, 0x02D4, 0x0568, 0x02D8, 0x0368,
0x02E1, 0x10E8, 0x02E2, 0x08E8, 0x02E4, 0x04E8, 0x0307, 0x1C18, 0x030B, 0x1A18,
0x030D, 0x1618, 0x030E, 0x0E18, 0x0313, 0x1918, 0x0315, 0x1518, 0x0316, 0x0D18,
0x0319, 0x1318, 0x031A, 0x0B18, 0x031C, 0x0718, 0x0323, 0x1898, 0x0325, 0x1498,
0x0326, 0x0C98, 0x0329, 0x1298, 0x032A, 0x0A98, 0x032C, 0x0698, 0x0331, 0x1198,
0x0332, 0x0998, 0x0334, 0x0598, 0x0338, 0x0398, 0x0343, 0x1858, 0x0345, 0x1458,
0x0346, 0x0C58, 0x0349, 0x1258, 0x034A, 0x0A58, 0x034C, 0x0658, 0x0351, 0x1158,
0x0352, 0x0958, 0x0354, 0x0558, 0x0361, 0x10D8, 0x0362, 0x08D8, 0x0364, 0x04D8,
0x0383, 0x1838, 0x0385, 0x1438, 0x0386, 0x0C38, 0x0389, 0x1238, 0x038A, 0x0A38,
0x038C, 0x0638, 0x0391, 0x1138, 0x0392, 0x0938, 0x0394, 0x0538, 0x03A1, 0x10B8,
0x03A2, 0x08B8, 0x03A4, 0x04B8, 0x03C1, 0x1078, 0x03C2, 0x0878, 0x03C4, 0x0478,
0x040F, 0x1E04, 0x0417, 0x1D04, 0x041B, 0x1B04, 0x041D, 0x1704, 0x041E, 0x0F04,
0x0427, 0x1C84, 0x042B, 0x1A84, 0x042D, 0x1684, 0x042E, 0x0E84, 0x0433, 0x1984,
0x0435, 0x1584, 0x0436, 0x0D84, 0x0439, 0x1384, 0x043A, 0x0B84, 0x043C, 0x0784,
0x0447, 0x1C44, 0x044B, 0x1A44, 0x044D, 0x1644, 0x044E, 0x0E44, 0x0453, 0x1944,
0x0455, 0x1544, 0x0456, 0x0D44, 0x0459, 0x1344, 0x045A, 0x0B44, 0x045C, 0x0744,
0x0463, 0x18C4, 0x0465, 0x14C4, 0x0466, 0x0CC4, 0x0469, 0x12C4, 0x046A, 0x0AC4,
0x046C, 0x06C4, 0x0471, 0x11C4, 0x0472, 0x09C4, 0x0474, 0x05C4, 0x0487, 0x1C24,
0x048B, 0x1A24, 0x048D, 0x1624, 0x048E, 0x0E24, 0x0493, 0x1924, 0x0495, 0x1524,
0x0496, 0x0D24, 0x0499, 0x1324, 0x049A, 0x0B24, 0x049C, 0x0724, 0x04A3, 0x18A4,
0x04A5, 0x14A4, 0x04A6, 0x0CA4, 0x04A9, 0x12A4, 0x04AA, 0x0AA4, 0x04AC, 0x06A4,
0x04B1, 0x11A4, 0x04B2, 0x09A4, 0x04B4, 0x05A4, 0x04C3, 0x1864, 0x04C5, 0x1464,
0x04C6, 0x0C64, 0x04C9, 0x1264, 0x04CA, 0x0A64, 0x04CC, 0x0664, 0x04D1, 0x1164,
0x04D2, 0x0964, 0x04D4, 0x0564, 0x04E1, 0x10E4, 0x04E2, 0x08E4, 0x0507, 0x1C14,
0x050B, 0x1A14, 0x050D, 0x1614, 0x050E, 0x0E14, 0x0513, 0x1914, 0x0515, 0x1514,
0x0516, 0x0D14, 0x0519, 0x1314, 0x051A, 0x0B14, 0x051C, 0x0714, 0x0523, 0x1894,
0x0525, 0x1494, 0x0526, 0x0C94, 0x0529, 0x1294, 0x052A, 0x0A94, 0x052C, 0x0694,
0x0531, 0x1194, 0x0532, 0x0994, 0x0534, 0x0594, 0x0543, 0x1854, 0x0545, 0x1454,
0x0546, 0x0C54, 0x0549, 0x1254, 0x054A, 0x0A54, 0x054C, 0x0654, 0x0551, 0x1154,
0x0552, 0x0954, 0x0561, 0x10D4, 0x0562, 0x08D4, 0x0583, 0x1834, 0x0585, 0x1434,
0x0586, 0x0C34, 0x0589, 0x1234, 0x058A, 0x0A34, 0x058C, 0x0634, 0x0591, 0x1134,
0x0592, 0x0934, 0x05A1, 0x10B4, 0x05A2, 0x08B4, 0x05C1, 0x1074, 0x05C2, 0x0874,
0x0607, 0x1C0C, 0x060B, 0x1A0C, 0x060D, 0x160C, 0x060E, 0x0E0C, 0x0613, 0x190C,
0x0615, 0x150C, 0x0616, 0x0D0C, 0x0619, 0x130C, 0x061A, 0x0B0C, 0x061C, 0x070C,
0x0623, 0x188C, 0x0625, 0x148C, 0x0626, 0x0C8C, 0x0629, 0x128C, 0x062A, 0x0A8C,
0x062C, 0x068C, 0x0631, 0x118C, 0x0632, 0x098C, 0x0643, 0x184C, 0x0645, 0x144C,
0x0646, 0x0C4C, 0x0649, 0x124C, 0x064A, 0x0A4C, 0x0651, 0x114C, 0x0652, 0x094C,
0x0661, 0x10CC, 0x0662, 0x08CC, 0x0683, 0x182C, 0x0685, 0x142C, 0x0686, 0x0C2C,
0x0689, 0x122C, 0x068A, 0x0A2C, 0x0691, 0x112C, 0x0692, 0x092C, 0x06A1, 0x10AC,
0x06A2, 0x08AC, 0x06C1, 0x106C, 0x06C2, 0x086C, 0x0703, 0x181C, 0x0705, 0x141C,
0x0706, 0x0C1C, 0x0709, 0x121C, 0x070A, 0x0A1C, 0x0711, 0x111C, 0x0712, 0x091C,
0x0721, 0x109C, 0x0722, 0x089C, 0x0741, 0x105C, 0x0742, 0x085C, 0x0781, 0x103C,
0x0782, 0x083C, 0x080F, 0x1E02, 0x0817, 0x1D02, 0x081B, 0x1B02, 0x081D, 0x1702,
0x081E, 0x0F02, 0x0827, 0x1C82, 0x082B, 0x1A82, 0x082D, 0x1682, 0x082E, 0x0E82,
0x0833, 0x1982, 0x0835, 0x1582, 0x0836, 0x0D82, 0x0839, 0x1382, 0x083A, 0x0B82,
0x0847, 0x1C42, 0x084B, 0x1A42, 0x084D, 0x1642, 0x084E, 0x0E42, 0x0853, 0x1942,
0x0855, 0x1542, 0x0856, 0x0D42, 0x0859, 0x1342, 0x085A, 0x0B42, 0x0863, 0x18C2,
0x0865, 0x14C2, 0x0866, 0x0CC2, 0x0869, 0x12C2, 0x086A, 0x0AC2, 0x0871, 0x11C2,
0x0872, 0x09C2, 0x0887, 0x1C22, 0x088B, 0x1A22, 0x088D, 0x1622, 0x088E, 0x0E22,
0x0893, 0x1922, 0x0895, 0x1522, 0x0896, 0x0D22, 0x0899, 0x1322, 0x089A, 0x0B22,
0x08A3, 0x18A2, 0x08A5, 0x14A2, 0x08A6, 0x0CA2, 0x08A9, 0x12A2, 0x08AA, 0x0AA2,
0x08B1, 0x11A2, 0x08B2, 0x09A2, 0x08C3, 0x1862, 0x08C5, 0x1462, 0x08C6, 0x0C62,
0x08C9, 0x1262, 0x08CA, 0x0A62, 0x08D1, 0x1162, 0x08D2, 0x0962, 0x08E1, 0x10E2,
0x0907, 0x1C12, 0x090B, 0x1A12, 0x090D, 0x1612, 0x090E, 0x0E12, 0x0913, 0x1912,
0x0915, 0x1512, 0x0916, 0x0D12, 0x0919, 0x1312, 0x091A, 0x0B12, 0x0923, 0x1892,
0x0925, 0x1492, 0x0926, 0x0C92, 0x0929, 0x1292, 0x092A, 0x0A92, 0x0931, 0x1192,
0x0932, 0x0992, 0x0943, 0x1852, 0x0945, 0x1452, 0x0946, 0x0C52, 0x0949, 0x1252,
0x094A, 0x0A52, 0x0951, 0x1152, 0x0961, 0x10D2, 0x0983, 0x1832, 0x0985, 0x1432,
0x0986, 0x0C32, 0x0989, 0x1232, 0x098A, 0x0A32, 0x0991, 0x1132, 0x09A1, 0x10B2,
0x09C1, 0x1072, 0x0A07, 0x1C0A, 0x0A0B, 0x1A0A, 0x0A0D, 0x160A, 0x0A0E, 0x0E0A,
0x0A13, 0x190A, 0x0A15, 0x150A, 0x0A16, 0x0D0A, 0x0A19, 0x130A, 0x0A1A, 0x0B0A,
0x0A23, 0x188A, 0x0A25, 0x148A, 0x0A26, 0x0C8A, 0x0A29, 0x128A, 0x0A2A, 0x0A8A,
0x0A31, 0x118A, 0x0A43, 0x184A, 0x0A45, 0x144A, 0x0A46, 0x0C4A, 0x0A49, 0x124A,
0x0A51, 0x114A, 0x0A61, 0x10CA, 0x0A83, 0x182A, 0x0A85, 0x142A, 0x0A86, 0x0C2A,
0x0A89, 0x122A, 0x0A91, 0x112A, 0x0AA1, 0x10AA, 0x0AC1, 0x106A, 0x0B03, 0x181A,
0x0B05, 0x141A, 0x0B06, 0x0C1A, 0x0B09, 0x121A, 0x0B11, 0x111A, 0x0B21, 0x109A,
0x0B41, 0x105A, 0x0B81, 0x103A, 0x0C07, 0x1C06, 0x0C0B, 0x1A06, 0x0C0D, 0x1606,
0x0C0E, 0x0E06, 0x0C13, 0x1906, 0x0C15, 0x1506, 0x0C16, 0x0D06, 0x0C19, 0x1306,
0x0C23, 0x1886, 0x0C25, 0x1486, 0x0C26, 0x0C86, 0x0C29, 0x1286, 0x0C31, 0x1186,
0x0C43, 0x1846, 0x0C45, 0x1446, 0x0C49, 0x1246, 0x0C51, 0x1146, 0x0C61, 0x10C6,
0x0C83, 0x1826, 0x0C85, 0x1426, 0x0C89, 0x1226, 0x0C91, 0x1126, 0x0CA1, 0x10A6,
0x0CC1, 0x1066, 0x0D03, 0x1816, 0x0D05, 0x1416, 0x0D09, 0x1216, 0x0D11, 0x1116,
0x0D21, 0x1096, 0x0D41, 0x1056, 0x0D81, 0x1036, 0x0E03, 0x180E, 0x0E05, 0x140E,
0x0E09, 0x120E, 0x0E11, 0x110E, 0x0E21, 0x108E, 0x0E41, 0x104E, 0x0E81, 0x102E,
0x0F01, 0x101E, 0x100F, 0x1E01, 0x1017, 0x1D01, 0x101B, 0x1B01, 0x101D, 0x1701,
0x1027, 0x1C81, 0x102B, 0x1A81, 0x102D, 0x1681, 0x1033, 0x1981, 0x1035, 0x1581,
0x1039, 0x1381, 0x1047, 0x1C41, 0x104B, 0x1A41, 0x104D, 0x1641, 0x1053, 0x1941,
0x1055, 0x1541, 0x1059, 0x1341, 0x1063, 0x18C1, 0x1065, 0x14C1, 0x1069, 0x12C1,
0x1071, 0x11C1, 0x1087, 0x1C21, 0x108B, 0x1A21, 0x108D, 0x1621, 0x1093, 0x1921,
0x1095, 0x1521, 0x1099, 0x1321, 0x10A3, 0x18A1, 0x10A5, 0x14A1, 0x10A9, 0x12A1,
0x10B1, 0x11A1, 0x10C3, 0x1861, 0x10C5, 0x1461, 0x10C9, 0x1261, 0x10D1, 0x1161,
0x1107, 0x1C11, 0x110B, 0x1A11, 0x110D, 0x1611, 0x1113, 0x1911, 0x1115, 0x1511,
0x1119, 0x1311, 0x1123, 0x1891, 0x1125, 0x1491, 0x1129, 0x1291, 0x1131, 0x1191,
0x1143, 0x1851, 0x1145, 0x1451, 0x1149, 0x1251, 0x1183, 0x1831, 0x1185, 0x1431,
0x1189, 0x1231, 0x1207, 0x1C09, 0x120B, 0x1A09, 0x120D, 0x1609, 0x1213, 0x1909,
0x1215, 0x1509, 0x1219, 0x1309, 0x1223, 0x1889, 0x1225, 0x1489, 0x1229, 0x1289,
0x1243, 0x1849, 0x1245, 0x1449, 0x1283, 0x1829, 0x1285, 0x1429, 0x1303, 0x1819,
0x1305, 0x1419, 0x1407, 0x1C05, 0x140B, 0x1A05, 0x140D, 0x1605, 0x1413, 0x1905,
0x1415, 0x1505, 0x1423, 0x1885, 0x1425, 0x1485, 0x1443, 0x1845, 0x1483, 0x1825,
0x1503, 0x1815, 0x1603, 0x180D, 0x1807, 0x1C03, 0x180B, 0x1A03, 0x1813, 0x1903,
0x1823, 0x1883, 0x1843, 0x1445, 0x1249, 0x1151, 0x10E1, 0x0C46, 0x0A4A, 0x0952,
0x08E2, 0x064C, 0x0554, 0x04E4, 0x0358, 0x02E8, 0x01F0
};
static const unsigned short AppxD_II[78] = {
/* Appendix D Table II - 2 of 13 characters */
0x0003, 0x1800, 0x0005, 0x1400, 0x0006, 0x0C00, 0x0009, 0x1200, 0x000A, 0x0A00,
0x000C, 0x0600, 0x0011, 0x1100, 0x0012, 0x0900, 0x0014, 0x0500, 0x0018, 0x0300,
0x0021, 0x1080, 0x0022, 0x0880, 0x0024, 0x0480, 0x0028, 0x0280, 0x0030, 0x0180,
0x0041, 0x1040, 0x0042, 0x0840, 0x0044, 0x0440, 0x0048, 0x0240, 0x0050, 0x0140,
0x0060, 0x00C0, 0x0081, 0x1020, 0x0082, 0x0820, 0x0084, 0x0420, 0x0088, 0x0220,
0x0090, 0x0120, 0x0101, 0x1010, 0x0102, 0x0810, 0x0104, 0x0410, 0x0108, 0x0210,
0x0201, 0x1008, 0x0202, 0x0808, 0x0204, 0x0408, 0x0401, 0x1004, 0x0402, 0x0804,
0x0801, 0x1002, 0x1001, 0x0802, 0x0404, 0x0208, 0x0110, 0x00A0
};
static const unsigned short int AppxD_IV[130] = {
/* Appendix D Table IV - Bar-to-Character Mapping (reverse lookup) */
67, 6, 78, 16, 86, 95, 34, 40, 45, 113, 117, 121, 62, 87, 18, 104, 41, 76, 57, 119, 115, 72, 97,
2, 127, 26, 105, 35, 122, 52, 114, 7, 24, 82, 68, 63, 94, 44, 77, 112, 70, 100, 39, 30, 107,
15, 125, 85, 10, 65, 54, 88, 20, 106, 46, 66, 8, 116, 29, 61, 99, 80, 90, 37, 123, 51, 25, 84,
129, 56, 4, 109, 96, 28, 36, 47, 11, 71, 33, 102, 21, 9, 17, 49, 124, 79, 64, 91, 42, 69, 53,
60, 14, 1, 27, 103, 126, 75, 89, 50, 120, 19, 32, 110, 92, 111, 130, 59, 31, 12, 81, 43, 55,
5, 74, 22, 101, 128, 58, 118, 48, 108, 38, 98, 93, 23, 83, 13, 73, 3
};
/***************************************************************************
** USPS_MSB_Math_CRC11GenerateFrameCheckSequence
**
** Inputs:
** ByteAttayPtr is the address of a 13 byte array holding 102 bytes which
** are right justified - ie: the leftmost 2 bits of the first byte do not
** hold data and must be set to zero.
**
** Outputs:
** return unsigned short - 11 bit Frame Check Sequence (right justified)
***************************************************************************/
extern unsigned short USPS_MSB_Math_CRC11GenerateFrameCheckSequence(unsigned char *ByteArrayPtr) {
unsigned short GeneratorPolynomial = 0x0F35;
unsigned short FrameCheckSequence = 0x07FF;
unsigned short Data;
int ByteIndex, Bit;
/* Do most significant byte skipping the 2 most significant bits */
Data = *ByteArrayPtr << 5;
ByteArrayPtr++;
for (Bit = 2; Bit < 8; Bit++) {
if ((FrameCheckSequence ^ Data) & 0x400)
FrameCheckSequence = (FrameCheckSequence << 1) ^ GeneratorPolynomial;
else
FrameCheckSequence = (FrameCheckSequence << 1);
FrameCheckSequence &= 0x7FF;
Data <<= 1;
}
/* Do rest of the bytes */
for (ByteIndex = 1; ByteIndex < 13; ByteIndex++) {
Data = *ByteArrayPtr << 3;
ByteArrayPtr++;
for (Bit = 0; Bit < 8; Bit++) {
if ((FrameCheckSequence ^ Data) & 0x0400) {
FrameCheckSequence = (FrameCheckSequence << 1) ^ GeneratorPolynomial;
} else {
FrameCheckSequence = (FrameCheckSequence << 1);
}
FrameCheckSequence &= 0x7FF;
Data <<= 1;
}
}
return FrameCheckSequence;
}
int imail(struct zint_symbol *symbol, unsigned char source[], int length) {
char data_pattern[200];
int error_number;
int i, j, read;
char zip[35], tracker[35], zip_adder[11], temp[2];
short int accum[112], x_reg[112], y_reg[112];
unsigned char byte_array[13];
unsigned short usps_crc;
int codeword[10];
unsigned short characters[10];
short int bar_map[130];
error_number = 0;
if (length > 32) {
strcpy(symbol->errtxt, "450: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SODIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "451: Invalid characters in data");
return error_number;
}
strcpy(zip, "");
strcpy(tracker, "");
/* separate the tracking code from the routing code */
read = 0;
j = 0;
for (i = 0; i < length; i++) {
if (source[i] == '-') {
tracker[read] = '\0';
j = 1;
read = 0;
} else {
if (j == 0) {
/* reading tracker */
tracker[read] = source[i];
read++;
} else {
/* reading zip code */
zip[read] = source[i];
read++;
}
}
}
if (j == 0) {
tracker[read] = '\0';
} else {
zip[read] = '\0';
}
if (strlen(tracker) != 20) {
strcpy(symbol->errtxt, "452: Invalid length tracking code");
return ZINT_ERROR_INVALID_DATA;
}
if (strlen(zip) > 11) {
strcpy(symbol->errtxt, "453: Invalid ZIP code");
return ZINT_ERROR_INVALID_DATA;
}
/* *** Step 1 - Conversion of Data Fields into Binary Data *** */
/* Routing code first */
for (i = 0; i < 112; i++) {
accum[i] = 0;
}
for (read = 0; read < strlen(zip); read++) {
for (i = 0; i < 112; i++) {
x_reg[i] = accum[i];
}
for (i = 0; i < 9; i++) {
binary_add(accum, x_reg);
}
for (i = 0; i < 112; i++) {
x_reg[i] = 0;
}
for (i = 0; i < 4; i++) {
if (ctoi(zip[read]) & (0x01 << i)) x_reg[i] = 1;
}
binary_add(accum, x_reg);
}
/* add weight to routing code */
for (i = 0; i < 112; i++) {
x_reg[i] = accum[i];
}
if (strlen(zip) > 9) {
strcpy(zip_adder, "1000100001");
} else {
if (strlen(zip) > 5) {
strcpy(zip_adder, "100001");
} else {
if (strlen(zip) > 0) {
strcpy(zip_adder, "1");
} else {
strcpy(zip_adder, "0");
}
}
}
for (i = 0; i < 112; i++) {
accum[i] = 0;
}
for (read = 0; read < strlen(zip_adder); read++) {
for (i = 0; i < 112; i++) {
y_reg[i] = accum[i];
}
for (i = 0; i < 9; i++) {
binary_add(accum, y_reg);
}
for (i = 0; i < 112; i++) {
y_reg[i] = 0;
}
for (i = 0; i < 4; i++) {
if (ctoi(zip_adder[read]) & (0x01 << i)) y_reg[i] = 1;
}
binary_add(accum, y_reg);
}
binary_add(accum, x_reg);
/* tracking code */
/* multiply by 10 */
for (i = 0; i < 112; i++) {
y_reg[i] = accum[i];
}
for (i = 0; i < 9; i++) {
binary_add(accum, y_reg);
}
for (i = 0; i < 112; i++) {
y_reg[i] = 0;
}
/* add first digit of tracker */
for (i = 0; i < 4; i++) {
if (ctoi(tracker[0]) & (0x01 << i)) y_reg[i] = 1;
}
binary_add(accum, y_reg);
/* multiply by 5 */
for (i = 0; i < 112; i++) {
y_reg[i] = accum[i];
}
for (i = 0; i < 4; i++) {
binary_add(accum, y_reg);
}
for (i = 0; i < 112; i++) {
y_reg[i] = 0;
}
/* add second digit */
for (i = 0; i < 4; i++) {
if (ctoi(tracker[1]) & (0x01 << i)) y_reg[i] = 1;
}
binary_add(accum, y_reg);
/* and then the rest */
for (read = 2; read < strlen(tracker); read++) {
for (i = 0; i < 112; i++) {
y_reg[i] = accum[i];
}
for (i = 0; i < 9; i++) {
binary_add(accum, y_reg);
}
for (i = 0; i < 112; i++) {
y_reg[i] = 0;
}
for (i = 0; i < 4; i++) {
if (ctoi(tracker[read]) & (0x01 << i)) y_reg[i] = 1;
}
binary_add(accum, y_reg);
}
/* *** Step 2 - Generation of 11-bit CRC on Binary Data *** */
accum[103] = 0;
accum[102] = 0;
memset(byte_array, 0, 13);
for (j = 0; j < 13; j++) {
i = 96 - (8 * j);
byte_array[j] = 0;
byte_array[j] += accum[i];
byte_array[j] += 2 * accum[i + 1];
byte_array[j] += 4 * accum[i + 2];
byte_array[j] += 8 * accum[i + 3];
byte_array[j] += 16 * accum[i + 4];
byte_array[j] += 32 * accum[i + 5];
byte_array[j] += 64 * accum[i + 6];
byte_array[j] += 128 * accum[i + 7];
}
usps_crc = USPS_MSB_Math_CRC11GenerateFrameCheckSequence(byte_array);
/* *** Step 3 - Conversion from Binary Data to Codewords *** */
/* start with codeword J which is base 636 */
for (i = 0; i < 112; i++) {
x_reg[i] = 0;
y_reg[i] = 0;
}
x_reg[101] = 1;
x_reg[98] = 1;
x_reg[97] = 1;
x_reg[96] = 1;
x_reg[95] = 1;
x_reg[94] = 1;
for (i = 92; i >= 0; i--) {
y_reg[i] = islarger(accum, x_reg);
if (y_reg[i] == 1) {
binary_subtract(accum, x_reg);
}
shiftdown(x_reg);
}
codeword[9] = (accum[9] * 512) + (accum[8] * 256) + (accum[7] * 128) + (accum[6] * 64) +
(accum[5] * 32) + (accum[4] * 16) + (accum[3] * 8) + (accum[2] * 4) +
(accum[1] * 2) + accum[0];
/* then codewords I to B with base 1365 */
for (j = 8; j > 0; j--) {
for (i = 0; i < 112; i++) {
accum[i] = y_reg[i];
y_reg[i] = 0;
x_reg[i] = 0;
}
x_reg[101] = 1;
x_reg[99] = 1;
x_reg[97] = 1;
x_reg[95] = 1;
x_reg[93] = 1;
x_reg[91] = 1;
for (i = 91; i >= 0; i--) {
y_reg[i] = islarger(accum, x_reg);
if (y_reg[i] == 1) {
binary_subtract(accum, x_reg);
}
shiftdown(x_reg);
}
codeword[j] = (accum[10] * 1024) + (accum[9] * 512) + (accum[8] * 256) +
(accum[7] * 128) + (accum[6] * 64) + (accum[5] * 32) +
(accum[4] * 16) + (accum[3] * 8) + (accum[2] * 4) +
(accum[1] * 2) + accum[0];
}
codeword[0] = (y_reg[10] * 1024) + (y_reg[9] * 512) + (y_reg[8] * 256) +
(y_reg[7] * 128) + (y_reg[6] * 64) + (y_reg[5] * 32) +
(y_reg[4] * 16) + (y_reg[3] * 8) + (y_reg[2] * 4) +
(y_reg[1] * 2) + y_reg[0];
for (i = 0; i < 8; i++) {
if (codeword[i] == 1365) {
codeword[i] = 0;
codeword[i + 1]++;
}
}
/* *** Step 4 - Inserting Additional Information into Codewords *** */
codeword[9] = codeword[9] * 2;
if (usps_crc >= 1024) {
codeword[0] += 659;
}
/* *** Step 5 - Conversion from Codewords to Characters *** */
for (i = 0; i < 10; i++) {
if (codeword[i] < 1287) {
characters[i] = AppxD_I[codeword[i]];
} else {
characters[i] = AppxD_II[codeword[i] - 1287];
}
}
for (i = 0; i < 10; i++) {
if (usps_crc & (1 << i)) {
characters[i] = 0x1FFF - characters[i];
}
}
/* *** Step 6 - Conversion from Characters to the Intelligent Mail Barcode *** */
for (i = 0; i < 10; i++) {
for (j = 0; j < 13; j++) {
if (characters[i] & (1 << j)) {
bar_map[AppxD_IV[(13 * i) + j] - 1] = 1;
} else {
bar_map[AppxD_IV[(13 * i) + j] - 1] = 0;
}
}
}
strcpy(data_pattern, "");
temp[1] = '\0';
for (i = 0; i < 65; i++) {
j = 0;
if (bar_map[i] == 0)
j += 1;
if (bar_map[i + 65] == 0)
j += 2;
temp[0] = itoc(j);
strcat(data_pattern, temp);
}
/* Translate 4-state data pattern to symbol */
read = 0;
for (i = 0; i < strlen(data_pattern); i++) {
if ((data_pattern[i] == '1') || (data_pattern[i] == '0')) {
set_module(symbol, 0, read);
}
set_module(symbol, 1, read);
if ((data_pattern[i] == '2') || (data_pattern[i] == '0')) {
set_module(symbol, 2, read);
}
read += 2;
}
symbol->row_height[0] = 3;
symbol->row_height[1] = 2;
symbol->row_height[2] = 3;
symbol->rows = 3;
symbol->width = read - 1;
return error_number;
}

191
3rdparty/zint-2.6.1/backend/large.c vendored Normal file
View File

@ -0,0 +1,191 @@
/* large.c - Handles binary manipulation of large numbers */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "large.h"
void binary_add(short int accumulator[], short int input_buffer[]) { /* Binary addition */
int i, carry, done;
carry = 0;
for (i = 0; i < 112; i++) {
done = 0;
if (((input_buffer[i] == 0) && (accumulator[i] == 0))
&& ((carry == 0) && (done == 0))) {
accumulator[i] = 0;
carry = 0;
done = 1;
}
if (((input_buffer[i] == 0) && (accumulator[i] == 0))
&& ((carry == 1) && (done == 0))) {
accumulator[i] = 1;
carry = 0;
done = 1;
}
if (((input_buffer[i] == 0) && (accumulator[i] == 1))
&& ((carry == 0) && (done == 0))) {
accumulator[i] = 1;
carry = 0;
done = 1;
}
if (((input_buffer[i] == 0) && (accumulator[i] == 1))
&& ((carry == 1) && (done == 0))) {
accumulator[i] = 0;
carry = 1;
done = 1;
}
if (((input_buffer[i] == 1) && (accumulator[i] == 0))
&& ((carry == 0) && (done == 0))) {
accumulator[i] = 1;
carry = 0;
done = 1;
}
if (((input_buffer[i] == 1) && (accumulator[i] == 0))
&& ((carry == 1) && (done == 0))) {
accumulator[i] = 0;
carry = 1;
done = 1;
}
if (((input_buffer[i] == 1) && (accumulator[i] == 1))
&& ((carry == 0) && (done == 0))) {
accumulator[i] = 0;
carry = 1;
done = 1;
}
if (((input_buffer[i] == 1) && (accumulator[i] == 1))
&& ((carry == 1) && (done == 0))) {
accumulator[i] = 1;
carry = 1;
done = 1;
}
}
}
void binary_subtract(short int accumulator[], short int input_buffer[]) {
/* 2's compliment subtraction */
/* take input_buffer from accumulator and put answer in accumulator */
int i;
short int sub_buffer[112];
for (i = 0; i < 112; i++) {
if (input_buffer[i] == 0) {
sub_buffer[i] = 1;
} else {
sub_buffer[i] = 0;
}
}
binary_add(accumulator, sub_buffer);
sub_buffer[0] = 1;
for (i = 1; i < 112; i++) {
sub_buffer[i] = 0;
}
binary_add(accumulator, sub_buffer);
}
void shiftdown(short int buffer[]) {
int i;
buffer[102] = 0;
buffer[103] = 0;
for (i = 0; i < 102; i++) {
buffer[i] = buffer[i + 1];
}
}
void shiftup(short int buffer[]) {
int i;
for (i = 102; i > 0; i--) {
buffer[i] = buffer[i - 1];
}
buffer[0] = 0;
}
short int islarger(short int accum[], short int reg[]) {
/* Returns 1 if accum[] is larger than reg[], else 0 */
int i, latch, larger;
latch = 0;
i = 103;
larger = 0;
do {
if ((accum[i] == 1) && (reg[i] == 0)) {
latch = 1;
larger = 1;
}
if ((accum[i] == 0) && (reg[i] == 1)) {
latch = 1;
}
i--;
} while ((latch == 0) && (i >= -1));
return larger;
}
void binary_load(short int reg[], char data[], const size_t src_len) {
size_t read;
int i;
short int temp[112] = {0};
for (i = 0; i < 112; i++) {
reg[i] = 0;
}
for (read = 0; read < src_len; read++) {
for (i = 0; i < 112; i++) {
temp[i] = reg[i];
}
for (i = 0; i < 9; i++) {
binary_add(reg, temp);
}
for (i = 0; i < 112; i++) {
temp[i] = 0;
}
for (i = 0; i < 4; i++) {
if (ctoi(data[read]) & (0x01 << i)) temp[i] = 1;
}
binary_add(reg, temp);
}
}

50
3rdparty/zint-2.6.1/backend/large.h vendored Normal file
View File

@ -0,0 +1,50 @@
/* large.h - Handles binary manipulation of large numbers */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef __LARGE_H
#define __LARGE_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern void binary_load(short int reg[], char data[], const size_t src_len);
extern void binary_add(short int accumulator[], short int input_buffer[]);
extern void binary_subtract(short int accumulator[], short int input_buffer[]);
extern void shiftdown(short int buffer[]);
extern void shiftup(short int buffer[]);
extern short int islarger(short int accum[], short int reg[]);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LARGE_H */

1312
3rdparty/zint-2.6.1/backend/library.c vendored Normal file

File diff suppressed because it is too large Load Diff

42
3rdparty/zint-2.6.1/backend/libzint.rc vendored Normal file
View File

@ -0,0 +1,42 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winver.h>
#ifdef GCC_WINDRES
VS_VERSION_INFO VERSIONINFO
#else
VS_VERSION_INFO VERSIONINFO
#endif
FILEVERSION 2,6,0,0
PRODUCTVERSION 2,6,0,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
//language ID = U.S. English, char set = Windows, Multilingual
BEGIN
VALUE "FileDescription", "libzint barcode library\0"
VALUE "FileVersion", "2.6.0.0\0"
VALUE "InternalName", "zint.dll\0"
VALUE "LegalCopyright", "Copyright © 2017 Robin Stuart & BogDan Vatra\0"
VALUE "OriginalFilename", "zint.dll\0"
VALUE "ProductName", "libzint\0"
VALUE "ProductVersion", "2.6.0.0\0"
VALUE "License", "BSD License version 3\0"
VALUE "WWW", "http://www.sourceforge.net/projects/zint"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1250
END
END

733
3rdparty/zint-2.6.1/backend/maxicode.c vendored Normal file
View File

@ -0,0 +1,733 @@
/* maxicode.c - Handles Maxicode */
/*
libzint - the open source barcode library
Copyright (C) 2010-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* Includes corrections thanks to Monica Swanson @ Source Technologies */
#include "common.h"
#include "maxicode.h"
#include "reedsol.h"
#include <string.h>
#include <stdlib.h>
int maxi_codeword[144];
/* Handles error correction of primary message */
void maxi_do_primary_check() {
unsigned char data[15];
unsigned char results[15];
int j;
int datalen = 10;
int ecclen = 10;
rs_init_gf(0x43);
rs_init_code(ecclen, 1);
for (j = 0; j < datalen; j += 1)
data[j] = maxi_codeword[j];
rs_encode(datalen, data, results);
for (j = 0; j < ecclen; j += 1)
maxi_codeword[ datalen + j] = results[ecclen - 1 - j];
rs_free();
}
/* Handles error correction of odd characters in secondary */
void maxi_do_secondary_chk_odd(int ecclen) {
unsigned char data[100];
unsigned char results[30];
int j;
int datalen = 68;
rs_init_gf(0x43);
rs_init_code(ecclen, 1);
if (ecclen == 20)
datalen = 84;
for (j = 0; j < datalen; j += 1)
if (j & 1) // odd
data[(j - 1) / 2] = maxi_codeword[j + 20];
rs_encode(datalen / 2, data, results);
for (j = 0; j < (ecclen); j += 1)
maxi_codeword[ datalen + (2 * j) + 1 + 20 ] = results[ecclen - 1 - j];
rs_free();
}
/* Handles error correction of even characters in secondary */
void maxi_do_secondary_chk_even(int ecclen) {
unsigned char data[100];
unsigned char results[30];
int j;
int datalen = 68;
if (ecclen == 20)
datalen = 84;
rs_init_gf(0x43);
rs_init_code(ecclen, 1);
for (j = 0; j < datalen + 1; j += 1)
if (!(j & 1)) // even
data[j / 2] = maxi_codeword[j + 20];
rs_encode(datalen / 2, data, results);
for (j = 0; j < (ecclen); j += 1)
maxi_codeword[ datalen + (2 * j) + 20] = results[ecclen - 1 - j];
rs_free();
}
/* Moves everything up so that a shift or latch can be inserted */
void maxi_bump(int set[], int character[], int bump_posn) {
int i;
for (i = 143; i > bump_posn; i--) {
set[i] = set[i - 1];
character[i] = character[i - 1];
}
}
/* Format text according to Appendix A */
int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
/* This code doesn't make use of [Lock in C], [Lock in D]
and [Lock in E] and so is not always the most efficient at
compressing data, but should suffice for most applications */
int set[144], character[144], i, j, done, count, current_set;
if (length > 138) {
return ZINT_ERROR_TOO_LONG;
}
for (i = 0; i < 144; i++) {
set[i] = -1;
character[i] = 0;
}
for (i = 0; i < length; i++) {
/* Look up characters in table from Appendix A - this gives
value and code set for most characters */
set[i] = maxiCodeSet[source[i]];
character[i] = maxiSymbolChar[source[i]];
}
/* If a character can be represented in more than one code set,
pick which version to use */
if (set[0] == 0) {
if (character[0] == 13) {
character[0] = 0;
}
set[0] = 1;
}
for (i = 1; i < length; i++) {
if (set[i] == 0) {
done = 0;
/* Special character */
if (character[i] == 13) {
/* Carriage Return */
if (set[i - 1] == 5) {
character[i] = 13;
set[i] = 5;
} else {
if ((i != length - 1) && (set[i + 1] == 5)) {
character[i] = 13;
set[i] = 5;
} else {
character[i] = 0;
set[i] = 1;
}
}
done = 1;
}
if ((character[i] == 28) && (done == 0)) {
/* FS */
if (set[i - 1] == 5) {
character[i] = 32;
set[i] = 5;
} else {
set[i] = set[i - 1];
}
done = 1;
}
if ((character[i] == 29) && (done == 0)) {
/* GS */
if (set[i - 1] == 5) {
character[i] = 33;
set[i] = 5;
} else {
set[i] = set[i - 1];
}
done = 1;
}
if ((character[i] == 30) && (done == 0)) {
/* RS */
if (set[i - 1] == 5) {
character[i] = 34;
set[i] = 5;
} else {
set[i] = set[i - 1];
}
done = 1;
}
if ((character[i] == 32) && (done == 0)) {
/* Space */
if (set[i - 1] == 1) {
character[i] = 32;
set[i] = 1;
}
if (set[i - 1] == 2) {
character[i] = 47;
set[i] = 2;
}
if (set[i - 1] >= 3) {
if (i != length - 1) {
if (set[i + 1] == 1) {
character[i] = 32;
set[i] = 1;
}
if (set[i + 1] == 2) {
character[i] = 47;
set[i] = 2;
}
if (set[i + 1] >= 3) {
character[i] = 59;
set[i] = set[i - 1];
}
} else {
character[i] = 59;
set[i] = set[i - 1];
}
}
done = 1;
}
if ((character[i] == 44) && (done == 0)) {
/* Comma */
if (set[i - 1] == 2) {
character[i] = 48;
set[i] = 2;
} else {
if ((i != length - 1) && (set[i + 1] == 2)) {
character[i] = 48;
set[i] = 2;
} else {
set[i] = 1;
}
}
done = 1;
}
if ((character[i] == 46) && (done == 0)) {
/* Full Stop */
if (set[i - 1] == 2) {
character[i] = 49;
set[i] = 2;
} else {
if ((i != length - 1) && (set[i + 1] == 2)) {
character[i] = 49;
set[i] = 2;
} else {
set[i] = 1;
}
}
done = 1;
}
if ((character[i] == 47) && (done == 0)) {
/* Slash */
if (set[i - 1] == 2) {
character[i] = 50;
set[i] = 2;
} else {
if ((i != length - 1) && (set[i + 1] == 2)) {
character[i] = 50;
set[i] = 2;
} else {
set[i] = 1;
}
}
done = 1;
}
if ((character[i] == 58) && (done == 0)) {
/* Colon */
if (set[i - 1] == 2) {
character[i] = 51;
set[i] = 2;
} else {
if ((i != length - 1) && (set[i + 1] == 2)) {
character[i] = 51;
set[i] = 2;
} else {
set[i] = 1;
}
}
done = 1;
}
}
}
for (i = length; i < 144; i++) {
/* Add the padding */
if (set[length - 1] == 2) {
set[i] = 2;
} else {
set[i] = 1;
}
character[i] = 33;
}
/* Find candidates for number compression */
if ((mode == 2) || (mode == 3)) {
j = 0;
} else {
j = 9;
}
/* Number compression not allowed in primary message */
count = 0;
for (i = j; i < 143; i++) {
if ((set[i] == 1) && ((character[i] >= 48) && (character[i] <= 57))) {
/* Character is a number */
count++;
} else {
count = 0;
}
if (count == 9) {
/* Nine digits in a row can be compressed */
set[i] = 6;
set[i - 1] = 6;
set[i - 2] = 6;
set[i - 3] = 6;
set[i - 4] = 6;
set[i - 5] = 6;
set[i - 6] = 6;
set[i - 7] = 6;
set[i - 8] = 6;
count = 0;
}
}
/* Add shift and latch characters */
current_set = 1;
i = 0;
do {
if ((set[i] != current_set) && (set[i] != 6)) {
switch (set[i]) {
case 1:
if (set[i + 1] == 1) {
if (set[i + 2] == 1) {
if (set[i + 3] == 1) {
/* Latch A */
maxi_bump(set, character, i);
character[i] = 63;
current_set = 1;
length++;
} else {
/* 3 Shift A */
maxi_bump(set, character, i);
character[i] = 57;
length++;
i += 2;
}
} else {
/* 2 Shift A */
maxi_bump(set, character, i);
character[i] = 56;
length++;
i++;
}
} else {
/* Shift A */
maxi_bump(set, character, i);
character[i] = 59;
length++;
}
break;
case 2:
if (set[i + 1] == 2) {
/* Latch B */
maxi_bump(set, character, i);
character[i] = 63;
current_set = 2;
length++;
} else {
/* Shift B */
maxi_bump(set, character, i);
character[i] = 59;
length++;
}
break;
case 3:
/* Shift C */
maxi_bump(set, character, i);
character[i] = 60;
length++;
break;
case 4:
/* Shift D */
maxi_bump(set, character, i);
character[i] = 61;
length++;
break;
case 5:
/* Shift E */
maxi_bump(set, character, i);
character[i] = 62;
length++;
break;
}
i++;
}
i++;
} while (i < 144);
/* Number compression has not been forgotten! - It's handled below */
i = 0;
do {
if (set[i] == 6) {
/* Number compression */
char substring[11];
int value;
for (j = 0; j < 9; j++) {
substring[j] = character[i + j];
}
substring[9] = '\0';
value = atoi(substring);
character[i] = 31; /* NS */
character[i + 1] = (value & 0x3f000000) >> 24;
character[i + 2] = (value & 0xfc0000) >> 18;
character[i + 3] = (value & 0x3f000) >> 12;
character[i + 4] = (value & 0xfc0) >> 6;
character[i + 5] = (value & 0x3f);
i += 6;
for (j = i; j < 140; j++) {
set[j] = set[j + 3];
character[j] = character[j + 3];
}
length -= 3;
} else {
i++;
}
} while (i <= 143);
/* Insert ECI at the beginning of message if needed */
/* Encode ECI assignment numbers according to table 3 */
if (eci != 3) {
maxi_bump(set, character, 0);
character[0] = 27; // ECI
if (eci <= 31) {
maxi_bump(set, character, 1);
character[1] = eci;
length += 2;
}
if ((eci >= 32) && (eci <= 1023)) {
maxi_bump(set, character, 1);
maxi_bump(set, character, 1);
character[1] = 0x20 + ((eci >> 6) & 0x0F);
character[2] = eci & 0x3F;
length += 3;
}
if ((eci >= 1024) && (eci <= 32767)) {
maxi_bump(set, character, 1);
maxi_bump(set, character, 1);
maxi_bump(set, character, 1);
character[1] = 0x30 + ((eci >> 12) & 0x03);
character[2] = (eci >> 6) & 0x3F;
character[3] = eci & 0x3F;
length += 4;
}
if (eci >= 32768) {
maxi_bump(set, character, 1);
maxi_bump(set, character, 1);
maxi_bump(set, character, 1);
maxi_bump(set, character, 1);
character[1] = 0x38 + ((eci >> 18) & 0x02);
character[2] = (eci >> 12) & 0x3F;
character[3] = (eci >> 6) & 0x3F;
character[4] = eci & 0x3F;
length += 5;
}
}
if (((mode == 2) || (mode == 3)) && (length > 84)) {
return ZINT_ERROR_TOO_LONG;
}
if (((mode == 4) || (mode == 6)) && (length > 93)) {
return ZINT_ERROR_TOO_LONG;
}
if ((mode == 5) && (length > 77)) {
return ZINT_ERROR_TOO_LONG;
}
/* Copy the encoded text into the codeword array */
if ((mode == 2) || (mode == 3)) {
for (i = 0; i < 84; i++) { /* secondary only */
maxi_codeword[i + 20] = character[i];
}
}
if ((mode == 4) || (mode == 6)) {
for (i = 0; i < 9; i++) { /* primary */
maxi_codeword[i + 1] = character[i];
}
for (i = 0; i < 84; i++) { /* secondary */
maxi_codeword[i + 20] = character[i + 9];
}
}
if (mode == 5) {
for (i = 0; i < 9; i++) { /* primary */
maxi_codeword[i + 1] = character[i];
}
for (i = 0; i < 68; i++) { /* secondary */
maxi_codeword[i + 20] = character[i + 9];
}
}
return 0;
}
/* Format structured primary for Mode 2 */
void maxi_do_primary_2(char postcode[], int country, int service) {
size_t postcode_length;
int postcode_num, i;
for (i = 0; i < 10; i++) {
if ((postcode[i] < '0') || (postcode[i] > '9')) {
postcode[i] = '\0';
}
}
postcode_length = strlen(postcode);
postcode_num = atoi(postcode);
maxi_codeword[0] = ((postcode_num & 0x03) << 4) | 2;
maxi_codeword[1] = ((postcode_num & 0xfc) >> 2);
maxi_codeword[2] = ((postcode_num & 0x3f00) >> 8);
maxi_codeword[3] = ((postcode_num & 0xfc000) >> 14);
maxi_codeword[4] = ((postcode_num & 0x3f00000) >> 20);
maxi_codeword[5] = ((postcode_num & 0x3c000000) >> 26) | ((postcode_length & 0x3) << 4);
maxi_codeword[6] = ((postcode_length & 0x3c) >> 2) | ((country & 0x3) << 4);
maxi_codeword[7] = (country & 0xfc) >> 2;
maxi_codeword[8] = ((country & 0x300) >> 8) | ((service & 0xf) << 2);
maxi_codeword[9] = ((service & 0x3f0) >> 4);
}
/* Format structured primary for Mode 3 */
void maxi_do_primary_3(char postcode[], int country, int service) {
int i, h;
h = strlen(postcode);
to_upper((unsigned char*) postcode);
for (i = 0; i < h; i++) {
if ((postcode[i] >= 'A') && (postcode[i] <= 'Z')) {
/* (Capital) letters shifted to Code Set A values */
postcode[i] -= 64;
}
if (((postcode[i] == 27) || (postcode[i] == 31)) || ((postcode[i] == 33) || (postcode[i] >= 59))) {
/* Not a valid postcode character */
postcode[i] = ' ';
}
/* Input characters lower than 27 (NUL - SUB) in postcode are
interpreted as capital letters in Code Set A (e.g. LF becomes 'J') */
}
maxi_codeword[0] = ((postcode[5] & 0x03) << 4) | 3;
maxi_codeword[1] = ((postcode[4] & 0x03) << 4) | ((postcode[5] & 0x3c) >> 2);
maxi_codeword[2] = ((postcode[3] & 0x03) << 4) | ((postcode[4] & 0x3c) >> 2);
maxi_codeword[3] = ((postcode[2] & 0x03) << 4) | ((postcode[3] & 0x3c) >> 2);
maxi_codeword[4] = ((postcode[1] & 0x03) << 4) | ((postcode[2] & 0x3c) >> 2);
maxi_codeword[5] = ((postcode[0] & 0x03) << 4) | ((postcode[1] & 0x3c) >> 2);
maxi_codeword[6] = ((postcode[0] & 0x3c) >> 2) | ((country & 0x3) << 4);
maxi_codeword[7] = (country & 0xfc) >> 2;
maxi_codeword[8] = ((country & 0x300) >> 8) | ((service & 0xf) << 2);
maxi_codeword[9] = ((service & 0x3f0) >> 4);
}
int maxicode(struct zint_symbol *symbol, unsigned char local_source[], int length) {
int i, j, block, bit, mode, countrycode = 0, service = 0, lp = 0;
int bit_pattern[7], internal_error = 0, eclen;
char postcode[12], countrystr[4], servicestr[4];
mode = symbol->option_1;
strcpy(postcode, "");
strcpy(countrystr, "");
strcpy(servicestr, "");
memset(maxi_codeword, 0, sizeof (maxi_codeword));
if (mode == -1) { /* If mode is unspecified */
lp = strlen(symbol->primary);
if (lp == 0) {
mode = 4;
} else {
mode = 2;
for (i = 0; i < 10 && i < lp; i++) {
if ((symbol->primary[i] < 48) || (symbol->primary[i] > 57)) {
mode = 3;
break;
}
}
}
}
if ((mode < 2) || (mode > 6)) { /* Only codes 2 to 6 supported */
strcpy(symbol->errtxt, "550: Invalid Maxicode Mode");
return ZINT_ERROR_INVALID_OPTION;
}
if ((mode == 2) || (mode == 3)) { /* Modes 2 and 3 need data in symbol->primary */
if (lp == 0) { /* Mode set manually means lp doesn't get set */
lp = strlen(symbol->primary);
}
if (lp != 15) {
strcpy(symbol->errtxt, "551: Invalid Primary String");
return ZINT_ERROR_INVALID_DATA;
}
for (i = 9; i < 15; i++) { /* check that country code and service are numeric */
if ((symbol->primary[i] < '0') || (symbol->primary[i] > '9')) {
strcpy(symbol->errtxt, "552: Invalid Primary String");
return ZINT_ERROR_INVALID_DATA;
}
}
memcpy(postcode, symbol->primary, 9);
postcode[9] = '\0';
if (mode == 2) {
for (i = 0; i < 10; i++) {
if (postcode[i] == ' ') {
postcode[i] = '\0';
}
}
} else if (mode == 3) {
postcode[6] = '\0';
}
countrystr[0] = symbol->primary[9];
countrystr[1] = symbol->primary[10];
countrystr[2] = symbol->primary[11];
countrystr[3] = '\0';
servicestr[0] = symbol->primary[12];
servicestr[1] = symbol->primary[13];
servicestr[2] = symbol->primary[14];
servicestr[3] = '\0';
countrycode = atoi(countrystr);
service = atoi(servicestr);
if (mode == 2) {
maxi_do_primary_2(postcode, countrycode, service);
}
if (mode == 3) {
maxi_do_primary_3(postcode, countrycode, service);
}
} else {
maxi_codeword[0] = mode;
}
i = maxi_text_process(mode, local_source, length, symbol->eci);
if (i == ZINT_ERROR_TOO_LONG) {
strcpy(symbol->errtxt, "553: Input data too long");
return i;
}
/* All the data is sorted - now do error correction */
maxi_do_primary_check(); /* always EEC */
if (mode == 5)
eclen = 56; // 68 data codewords , 56 error corrections
else
eclen = 40; // 84 data codewords, 40 error corrections
maxi_do_secondary_chk_even(eclen / 2); // do error correction of even
maxi_do_secondary_chk_odd(eclen / 2); // do error correction of odd
/* Copy data into symbol grid */
for (i = 0; i < 33; i++) {
for (j = 0; j < 30; j++) {
block = (MaxiGrid[(i * 30) + j] + 5) / 6;
bit = (MaxiGrid[(i * 30) + j] + 5) % 6;
if (block != 0) {
bit_pattern[0] = (maxi_codeword[block - 1] & 0x20) >> 5;
bit_pattern[1] = (maxi_codeword[block - 1] & 0x10) >> 4;
bit_pattern[2] = (maxi_codeword[block - 1] & 0x8) >> 3;
bit_pattern[3] = (maxi_codeword[block - 1] & 0x4) >> 2;
bit_pattern[4] = (maxi_codeword[block - 1] & 0x2) >> 1;
bit_pattern[5] = (maxi_codeword[block - 1] & 0x1);
if (bit_pattern[bit] != 0) {
set_module(symbol, i, j);
}
}
}
}
/* Add orientation markings */
set_module(symbol, 0, 28); // Top right filler
set_module(symbol, 0, 29);
set_module(symbol, 9, 10); // Top left marker
set_module(symbol, 9, 11);
set_module(symbol, 10, 11);
set_module(symbol, 15, 7); // Left hand marker
set_module(symbol, 16, 8);
set_module(symbol, 16, 20); // Right hand marker
set_module(symbol, 17, 20);
set_module(symbol, 22, 10); // Bottom left marker
set_module(symbol, 23, 10);
set_module(symbol, 22, 17); // Bottom right marker
set_module(symbol, 23, 17);
symbol->width = 30;
symbol->rows = 33;
return internal_error;
}

104
3rdparty/zint-2.6.1/backend/maxicode.h vendored Normal file
View File

@ -0,0 +1,104 @@
/* maxicode.h - Handles Maxicode */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
static const unsigned short int MaxiGrid[] = {
/* ISO/IEC 16023 Figure 5 - MaxiCode Module Sequence */ /* 30 x 33 data grid */
122, 121, 128, 127, 134, 133, 140, 139, 146, 145, 152, 151, 158, 157, 164, 163, 170, 169, 176, 175, 182, 181, 188, 187, 194, 193, 200, 199, 0, 0,
124, 123, 130, 129, 136, 135, 142, 141, 148, 147, 154, 153, 160, 159, 166, 165, 172, 171, 178, 177, 184, 183, 190, 189, 196, 195, 202, 201, 817, 0,
126, 125, 132, 131, 138, 137, 144, 143, 150, 149, 156, 155, 162, 161, 168, 167, 174, 173, 180, 179, 186, 185, 192, 191, 198, 197, 204, 203, 819, 818,
284, 283, 278, 277, 272, 271, 266, 265, 260, 259, 254, 253, 248, 247, 242, 241, 236, 235, 230, 229, 224, 223, 218, 217, 212, 211, 206, 205, 820, 0,
286, 285, 280, 279, 274, 273, 268, 267, 262, 261, 256, 255, 250, 249, 244, 243, 238, 237, 232, 231, 226, 225, 220, 219, 214, 213, 208, 207, 822, 821,
288, 287, 282, 281, 276, 275, 270, 269, 264, 263, 258, 257, 252, 251, 246, 245, 240, 239, 234, 233, 228, 227, 222, 221, 216, 215, 210, 209, 823, 0,
290, 289, 296, 295, 302, 301, 308, 307, 314, 313, 320, 319, 326, 325, 332, 331, 338, 337, 344, 343, 350, 349, 356, 355, 362, 361, 368, 367, 825, 824,
292, 291, 298, 297, 304, 303, 310, 309, 316, 315, 322, 321, 328, 327, 334, 333, 340, 339, 346, 345, 352, 351, 358, 357, 364, 363, 370, 369, 826, 0,
294, 293, 300, 299, 306, 305, 312, 311, 318, 317, 324, 323, 330, 329, 336, 335, 342, 341, 348, 347, 354, 353, 360, 359, 366, 365, 372, 371, 828, 827,
410, 409, 404, 403, 398, 397, 392, 391, 80, 79, 0, 0, 14, 13, 38, 37, 3, 0, 45, 44, 110, 109, 386, 385, 380, 379, 374, 373, 829, 0,
412, 411, 406, 405, 400, 399, 394, 393, 82, 81, 41, 0, 16, 15, 40, 39, 4, 0, 0, 46, 112, 111, 388, 387, 382, 381, 376, 375, 831, 830,
414, 413, 408, 407, 402, 401, 396, 395, 84, 83, 42, 0, 0, 0, 0, 0, 6, 5, 48, 47, 114, 113, 390, 389, 384, 383, 378, 377, 832, 0,
416, 415, 422, 421, 428, 427, 104, 103, 56, 55, 17, 0, 0, 0, 0, 0, 0, 0, 21, 20, 86, 85, 434, 433, 440, 439, 446, 445, 834, 833,
418, 417, 424, 423, 430, 429, 106, 105, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 23, 22, 88, 87, 436, 435, 442, 441, 448, 447, 835, 0,
420, 419, 426, 425, 432, 431, 108, 107, 60, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 90, 89, 438, 437, 444, 443, 450, 449, 837, 836,
482, 481, 476, 475, 470, 469, 49, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 54, 53, 464, 463, 458, 457, 452, 451, 838, 0,
484, 483, 478, 477, 472, 471, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 466, 465, 460, 459, 454, 453, 840, 839,
486, 485, 480, 479, 474, 473, 52, 51, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 43, 468, 467, 462, 461, 456, 455, 841, 0,
488, 487, 494, 493, 500, 499, 98, 97, 62, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 92, 91, 506, 505, 512, 511, 518, 517, 843, 842,
490, 489, 496, 495, 502, 501, 100, 99, 64, 63, 0, 0, 0, 0, 0, 0, 0, 0, 29, 28, 94, 93, 508, 507, 514, 513, 520, 519, 844, 0,
492, 491, 498, 497, 504, 503, 102, 101, 66, 65, 18, 0, 0, 0, 0, 0, 0, 0, 19, 30, 96, 95, 510, 509, 516, 515, 522, 521, 846, 845,
560, 559, 554, 553, 548, 547, 542, 541, 74, 73, 33, 0, 0, 0, 0, 0, 0, 11, 68, 67, 116, 115, 536, 535, 530, 529, 524, 523, 847, 0,
562, 561, 556, 555, 550, 549, 544, 543, 76, 75, 0, 0, 8, 7, 36, 35, 12, 0, 70, 69, 118, 117, 538, 537, 532, 531, 526, 525, 849, 848,
564, 563, 558, 557, 552, 551, 546, 545, 78, 77, 0, 34, 10, 9, 26, 25, 0, 0, 72, 71, 120, 119, 540, 539, 534, 533, 528, 527, 850, 0,
566, 565, 572, 571, 578, 577, 584, 583, 590, 589, 596, 595, 602, 601, 608, 607, 614, 613, 620, 619, 626, 625, 632, 631, 638, 637, 644, 643, 852, 851,
568, 567, 574, 573, 580, 579, 586, 585, 592, 591, 598, 597, 604, 603, 610, 609, 616, 615, 622, 621, 628, 627, 634, 633, 640, 639, 646, 645, 853, 0,
570, 569, 576, 575, 582, 581, 588, 587, 594, 593, 600, 599, 606, 605, 612, 611, 618, 617, 624, 623, 630, 629, 636, 635, 642, 641, 648, 647, 855, 854,
728, 727, 722, 721, 716, 715, 710, 709, 704, 703, 698, 697, 692, 691, 686, 685, 680, 679, 674, 673, 668, 667, 662, 661, 656, 655, 650, 649, 856, 0,
730, 729, 724, 723, 718, 717, 712, 711, 706, 705, 700, 699, 694, 693, 688, 687, 682, 681, 676, 675, 670, 669, 664, 663, 658, 657, 652, 651, 858, 857,
732, 731, 726, 725, 720, 719, 714, 713, 708, 707, 702, 701, 696, 695, 690, 689, 684, 683, 678, 677, 672, 671, 666, 665, 660, 659, 654, 653, 859, 0,
734, 733, 740, 739, 746, 745, 752, 751, 758, 757, 764, 763, 770, 769, 776, 775, 782, 781, 788, 787, 794, 793, 800, 799, 806, 805, 812, 811, 861, 860,
736, 735, 742, 741, 748, 747, 754, 753, 760, 759, 766, 765, 772, 771, 778, 777, 784, 783, 790, 789, 796, 795, 802, 801, 808, 807, 814, 813, 862, 0,
738, 737, 744, 743, 750, 749, 756, 755, 762, 761, 768, 767, 774, 773, 780, 779, 786, 785, 792, 791, 798, 797, 804, 803, 810, 809, 816, 815, 864, 863
};
static const char maxiCodeSet[256] = {
/* from Appendix A - ASCII character to Code Set (e.g. 2 = Set B) */
/* set 0 refers to special characters that fit into more than one set (e.g. GS) */
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 0, 2, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2,
2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 4, 5, 5, 5, 5, 5, 5, 4, 5, 3, 4, 3, 5, 5, 4, 4, 3, 3, 3,
4, 3, 5, 4, 4, 3, 3, 4, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
};
static const char maxiSymbolChar[256] = {
/* from Appendix A - ASCII character to symbol value */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 30, 28, 29, 30, 35, 32, 53, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 37,
38, 39, 40, 41, 52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 42, 43, 44, 45, 46, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 32, 54, 34, 35, 36, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 36,
37, 37, 38, 39, 40, 41, 42, 43, 38, 44, 37, 39, 38, 45, 46, 40, 41, 39, 40, 41,
42, 42, 47, 43, 44, 43, 44, 45, 45, 46, 47, 46, 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32,
33, 34, 35, 36, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32, 33, 34, 35, 36
};

306
3rdparty/zint-2.6.1/backend/medical.c vendored Normal file
View File

@ -0,0 +1,306 @@
/* medical.c - Handles 1 track and 2 track pharmacode and Codabar */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common.h"
extern int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length);
/* Codabar table checked against EN 798:1995 */
#define CALCIUM "0123456789-$:/.+ABCD"
static const char *CodaTable[20] = {
"11111221", "11112211", "11121121", "22111111", "11211211", "21111211",
"12111121", "12112111", "12211111", "21121111", "11122111", "11221111", "21112121", "21211121",
"21212111", "11212121", "11221211", "12121121", "11121221", "11122211"
};
int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length) {
/* "Pharmacode can represent only a single integer from 3 to 131070. Unlike other
commonly used one-dimensional barcode schemes, pharmacode does not store the data in a
form corresponding to the human-readable digits; the number is encoded in binary, rather
than decimal. Pharmacode is read from right to left: with n as the bar position starting
at 0 on the right, each narrow bar adds 2n to the value and each wide bar adds 2(2^n).
The minimum barcode is 2 bars and the maximum 16, so the smallest number that could
be encoded is 3 (2 narrow bars) and the biggest is 131070 (16 wide bars)."
- http://en.wikipedia.org/wiki/Pharmacode */
/* This code uses the One Track Pharamacode calculating algorithm as recommended by
the specification at http://www.laetus.com/laetus.php?request=file&id=69 */
unsigned long int tester;
int counter, error_number, h;
char inter[18] = {0}; /* 131070 -> 17 bits */
char dest[64]; /* 17 * 2 + 1 */
if (length > 6) {
strcpy(symbol->errtxt, "350: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "351: Invalid characters in data");
return error_number;
}
tester = atoi((char*) source);
if ((tester < 3) || (tester > 131070)) {
strcpy(symbol->errtxt, "352: Data out of range");
return ZINT_ERROR_INVALID_DATA;
}
do {
if (!(tester & 1)) {
strcat(inter, "W");
tester = (tester - 2) / 2;
} else {
strcat(inter, "N");
tester = (tester - 1) / 2;
}
} while (tester != 0);
h = strlen(inter) - 1;
*dest = '\0';
for (counter = h; counter >= 0; counter--) {
if (inter[counter] == 'W') {
strcat(dest, "32");
} else {
strcat(dest, "12");
}
}
expand(symbol, dest);
return error_number;
}
int pharma_two_calc(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
/* This code uses the Two Track Pharamacode defined in the document at
http://www.laetus.com/laetus.php?request=file&id=69 and using a modified
algorithm from the One Track system. This standard accepts integet values
from 4 to 64570080. */
unsigned long int tester;
int counter, h;
char inter[17];
int error_number;
tester = atoi((char*) source);
if ((tester < 4) || (tester > 64570080)) {
strcpy(symbol->errtxt, "353: Data out of range");
return ZINT_ERROR_INVALID_DATA;
}
error_number = 0;
strcpy(inter, "");
do {
switch (tester % 3) {
case 0:
strcat(inter, "3");
tester = (tester - 3) / 3;
break;
case 1:
strcat(inter, "1");
tester = (tester - 1) / 3;
break;
case 2:
strcat(inter, "2");
tester = (tester - 2) / 3;
break;
}
} while (tester != 0);
h = strlen(inter) - 1;
for (counter = h; counter >= 0; counter--) {
dest[h - counter] = inter[counter];
}
dest[h + 1] = '\0';
return error_number;
}
int pharma_two(struct zint_symbol *symbol, unsigned char source[], int length) {
/* Draws the patterns for two track pharmacode */
char height_pattern[200];
unsigned int loopey, h;
int writer;
int error_number = 0;
strcpy(height_pattern, "");
if (length > 8) {
strcpy(symbol->errtxt, "354: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "355: Invalid characters in data");
return error_number;
}
error_number = pharma_two_calc(symbol, source, height_pattern);
if (error_number != 0) {
return error_number;
}
writer = 0;
h = strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((height_pattern[loopey] == '2') || (height_pattern[loopey] == '3')) {
set_module(symbol, 0, writer);
}
if ((height_pattern[loopey] == '1') || (height_pattern[loopey] == '3')) {
set_module(symbol, 1, writer);
}
writer += 2;
}
symbol->rows = 2;
symbol->width = writer - 1;
return error_number;
}
/* The Codabar system consisting of simple substitution */
int codabar(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
char dest[512];
strcpy(dest, "");
if (length > 60) { /* No stack smashing please */
strcpy(symbol->errtxt, "356: Input too long");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(CALCIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "357: Invalid characters in data");
return error_number;
}
/* Codabar must begin and end with the characters A, B, C or D */
if ((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C')
&& (source[0] != 'D')) {
strcpy(symbol->errtxt, "358: Invalid characters in data");
return ZINT_ERROR_INVALID_DATA;
}
if ((source[length - 1] != 'A') && (source[length - 1] != 'B') &&
(source[length - 1] != 'C') && (source[length - 1] != 'D')) {
strcpy(symbol->errtxt, "359: Invalid characters in data");
return ZINT_ERROR_INVALID_DATA;
}
for (i = 0; i < length; i++) {
lookup(CALCIUM, CodaTable, source[i], dest);
}
expand(symbol, dest);
ustrcpy(symbol->text, source);
return error_number;
}
/* Italian Pharmacode */
int code32(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, zeroes, error_number, checksum, checkpart, checkdigit;
char localstr[10], risultante[7];
long int pharmacode, remainder, devisor;
int codeword[6];
char tabella[34];
/* Validate the input */
if (length > 8) {
strcpy(symbol->errtxt, "360: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "361: Invalid characters in data");
return error_number;
}
/* Add leading zeros as required */
zeroes = 8 - length;
memset(localstr, '0', zeroes);
strcpy(localstr + zeroes, (char*) source);
/* Calculate the check digit */
checksum = 0;
checkpart = 0;
for (i = 0; i < 4; i++) {
checkpart = ctoi(localstr[i * 2]);
checksum += checkpart;
checkpart = 2 * (ctoi(localstr[(i * 2) + 1]));
if (checkpart >= 10) {
checksum += (checkpart - 10) + 1;
} else {
checksum += checkpart;
}
}
/* Add check digit to data string */
checkdigit = checksum % 10;
localstr[8] = itoc(checkdigit);
localstr[9] = '\0';
/* Convert string into an integer value */
pharmacode = atoi(localstr);
/* Convert from decimal to base-32 */
devisor = 33554432;
for (i = 5; i >= 0; i--) {
codeword[i] = pharmacode / devisor;
remainder = pharmacode % devisor;
pharmacode = remainder;
devisor /= 32;
}
/* Look up values in 'Tabella di conversione' */
strcpy(tabella, "0123456789BCDFGHJKLMNPQRSTUVWXYZ");
for (i = 5; i >= 0; i--) {
risultante[5 - i] = tabella[codeword[i]];
}
risultante[6] = '\0';
/* Plot the barcode using Code 39 */
error_number = c39(symbol, (unsigned char*) risultante, strlen(risultante));
if (error_number != 0) {
return error_number;
}
/* Override the normal text output with the Pharmacode number */
strcpy((char*) symbol->text, "A");
strcat((char*) symbol->text, (char*) localstr);
return error_number;
}

234
3rdparty/zint-2.6.1/backend/ms_stdint.h vendored Normal file
View File

@ -0,0 +1,234 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
/* @(#) $Id: ms_stdint.h,v 1.1 2009/09/19 08:16:21 hooper114 Exp $ */
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#if (_MSC_VER < 1300) && defined(__cplusplus)
extern "C++" {
#endif
# include <wchar.h>
#if (_MSC_VER < 1300) && defined(__cplusplus)
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef _W64 int intptr_t;
typedef _W64 unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]

172
3rdparty/zint-2.6.1/backend/pcx.c vendored Normal file
View File

@ -0,0 +1,172 @@
/* pcx.c - Handles output to ZSoft PCX file */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "pcx.h" /* PCX header structure */
#include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#include <malloc.h>
#endif
#define SSET "0123456789ABCDEF"
int pcx_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
int row, column, i, colour;
int run_count;
FILE *pcx_file;
pcx_header_t header;
#ifdef _MSC_VER
unsigned char* rle_row;
#endif
#ifndef _MSC_VER
unsigned char rle_row[symbol->bitmap_width];
#else
rle_row = (unsigned char *) _alloca((symbol->bitmap_width * 6) * sizeof (unsigned char));
#endif /* _MSC_VER */
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
header.manufacturer = 10; // ZSoft
header.version = 5; // Version 3.0
header.encoding = 1; // Run length encoding
header.bits_per_pixel = 8;
header.window_xmin = 0;
header.window_ymin = 0;
header.window_xmax = symbol->bitmap_width - 1;
header.window_ymax = symbol->bitmap_height - 1;
header.horiz_dpi = 300;
header.vert_dpi = 300;
for (i = 0; i < 48; i++) {
header.colourmap[i] = 0x00;
}
header.reserved = 0;
header.number_of_planes = 3;
if (symbol->bitmap_width % 2) {
header.bytes_per_line = symbol->bitmap_width + 1;
} else {
header.bytes_per_line = symbol->bitmap_width;
}
header.palette_info = 1; // Colour
header.horiz_screen_size = 0;
header.vert_screen_size = 0;
for (i = 0; i < 54; i++) {
header.filler[i] = 0x00;
}
/* Open output file in binary mode */
if (symbol->output_options & BARCODE_STDOUT) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "620: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
#endif
pcx_file = stdout;
} else {
if (!(pcx_file = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "621: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
}
fwrite(&header, sizeof (pcx_header_t), 1, pcx_file);
for (row = 0; row < symbol->bitmap_height; row++) {
for (colour = 0; colour < 3; colour++) {
for (column = 0; column < symbol->bitmap_width; column++) {
switch (colour) {
case 0:
if (pixelbuf[(row * symbol->bitmap_width) + column] == '1') {
rle_row[column] = fgred;
} else {
rle_row[column] = bgred;
}
break;
case 1:
if (pixelbuf[(row * symbol->bitmap_width) + column] == '1') {
rle_row[column] = fggrn;
} else {
rle_row[column] = bggrn;
}
break;
case 2:
if (pixelbuf[(row * symbol->bitmap_width) + column] == '1') {
rle_row[column] = fgblu;
} else {
rle_row[column] = bgblu;
}
break;
}
}
run_count = 1;
for (column = 1; column < symbol->bitmap_width; column++) {
if ((rle_row[column - 1] == rle_row[column]) && (run_count < 63)) {
run_count++;
} else {
run_count += 0xc0;
fputc(run_count, pcx_file);
fputc(rle_row[column - 1], pcx_file);
run_count = 1;
}
}
if (run_count > 1) {
run_count += 0xc0;
fputc(run_count, pcx_file);
fputc(rle_row[column - 1], pcx_file);
}
}
}
fclose(pcx_file);
return 0;
}

76
3rdparty/zint-2.6.1/backend/pcx.h vendored Normal file
View File

@ -0,0 +1,76 @@
/* pcx.h - header structure for ZSoft PCX files
libzint - the open source barcode library
Copyright (C) 2016-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef PCX_H
#define PCX_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
#pragma pack (1)
typedef struct pcx_header {
uint8_t manufacturer;
uint8_t version;
uint8_t encoding;
uint8_t bits_per_pixel;
uint16_t window_xmin;
uint16_t window_ymin;
uint16_t window_xmax;
uint16_t window_ymax;
uint16_t horiz_dpi;
uint16_t vert_dpi;
uint8_t colourmap[48];
uint8_t reserved;
uint8_t number_of_planes;
uint16_t bytes_per_line;
uint16_t palette_info;
uint16_t horiz_screen_size;
uint16_t vert_screen_size;
uint8_t filler[54];
} pcx_header_t;
#pragma pack ()
#ifdef __cplusplus
}
#endif
#endif /* PCX_H */

1296
3rdparty/zint-2.6.1/backend/pdf417.c vendored Normal file

File diff suppressed because it is too large Load Diff

514
3rdparty/zint-2.6.1/backend/pdf417.h vendored Normal file
View File

@ -0,0 +1,514 @@
/* pdf417.h - PDF417 tables and coefficients */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Portions Copyright (C) 2004 Grandzebu
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* this file contains the character table, the pre-calculated coefficients and the
codeword patterns taken from lines 416 to 454 of pdf417.frm */
#define TRUE 1
#define FALSE 0
#define TEX 900
#define BYT 901
#define NUM 902
/* PDF417 error correction coefficients from Grand Zebu */
static const unsigned short int coefrs[1022] = {
/* k = 2 */
27, 917,
/* k = 4 */
522, 568, 723, 809,
/* k = 8 */
237, 308, 436, 284, 646, 653, 428, 379,
/* k = 16 */
274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176, 65,
/* k = 32 */
361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, 517,
273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330, 63, 410,
/* k = 64 */
539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733, 877, 381, 612,
723, 476, 462, 172, 430, 609, 858, 822, 543, 376, 511, 400, 672, 762, 283, 184,
440, 35, 519, 31, 460, 594, 225, 535, 517, 352, 605, 158, 651, 201, 488, 502,
648, 733, 717, 83, 404, 97, 280, 771, 840, 629, 4, 381, 843, 623, 264, 543,
/* k = 128 */
521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, 925, 749, 415,
822, 93, 217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908, 490, 704,
516, 258, 457, 907, 594, 723, 674, 292, 272, 96, 684, 432, 686, 606, 860, 569,
193, 219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379, 712, 463, 646, 776,
171, 491, 297, 763, 156, 732, 95, 270, 447, 90, 507, 48, 228, 821, 808, 898,
784, 663, 627, 378, 382, 262, 380, 602, 754, 336, 89, 614, 87, 432, 670, 616,
157, 374, 242, 726, 600, 269, 375, 898, 845, 454, 354, 130, 814, 587, 804, 34,
211, 330, 539, 297, 827, 865, 37, 517, 834, 315, 550, 86, 801, 4, 108, 539,
/* k = 256 */
524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, 786, 138, 720,
858, 194, 311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280, 828, 757,
710, 814, 919, 89, 68, 569, 11, 204, 796, 605, 540, 913, 801, 700, 799, 137,
439, 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257, 284, 549, 209, 884,
315, 70, 329, 793, 490, 274, 877, 162, 749, 812, 684, 461, 334, 376, 849, 521,
307, 291, 803, 712, 19, 358, 399, 908, 103, 511, 51, 8, 517, 225, 289, 470,
637, 731, 66, 255, 917, 269, 463, 830, 730, 433, 848, 585, 136, 538, 906, 90,
2, 290, 743, 199, 655, 903, 329, 49, 802, 580, 355, 588, 188, 462, 10, 134,
628, 320, 479, 130, 739, 71, 263, 318, 374, 601, 192, 605, 142, 673, 687, 234,
722, 384, 177, 752, 607, 640, 455, 193, 689, 707, 805, 641, 48, 60, 732, 621,
895, 544, 261, 852, 655, 309, 697, 755, 756, 60, 231, 773, 434, 421, 726, 528,
503, 118, 49, 795, 32, 144, 500, 238, 836, 394, 280, 566, 319, 9, 647, 550,
73, 914, 342, 126, 32, 681, 331, 792, 620, 60, 609, 441, 180, 791, 893, 754,
605, 383, 228, 749, 760, 213, 54, 297, 134, 54, 834, 299, 922, 191, 910, 532,
609, 829, 189, 20, 167, 29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173,
404, 251, 688, 95, 497, 555, 642, 543, 307, 159, 924, 558, 648, 55, 497, 10,
/* k = 512 */
352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350, 492,
197, 265, 920, 155, 914, 299, 229, 643, 294, 871, 306, 88, 87, 193, 352, 781,
846, 75, 327, 520, 435, 543, 203, 666, 249, 346, 781, 621, 640, 268, 794, 534,
539, 781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37, 858, 916, 552, 41,
542, 289, 122, 272, 383, 800, 485, 98, 752, 472, 761, 107, 784, 860, 658, 741,
290, 204, 681, 407, 855, 85, 99, 62, 482, 180, 20, 297, 451, 593, 913, 142,
808, 684, 287, 536, 561, 76, 653, 899, 729, 567, 744, 390, 513, 192, 516, 258,
240, 518, 794, 395, 768, 848, 51, 610, 384, 168, 190, 826, 328, 596, 786, 303,
570, 381, 415, 641, 156, 237, 151, 429, 531, 207, 676, 710, 89, 168, 304, 402,
40, 708, 575, 162, 864, 229, 65, 861, 841, 512, 164, 477, 221, 92, 358, 785,
288, 357, 850, 836, 827, 736, 707, 94, 8, 494, 114, 521, 2, 499, 851, 543,
152, 729, 771, 95, 248, 361, 578, 323, 856, 797, 289, 51, 684, 466, 533, 820,
669, 45, 902, 452, 167, 342, 244, 173, 35, 463, 651, 51, 699, 591, 452, 578,
37, 124, 298, 332, 552, 43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911,
283, 711, 472, 420, 245, 288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408,
842, 383, 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713, 159, 672, 729,
624, 59, 193, 417, 158, 209, 563, 564, 343, 693, 109, 608, 563, 365, 181, 772,
677, 310, 248, 353, 708, 410, 579, 870, 617, 841, 632, 860, 289, 536, 35, 777,
618, 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751, 331, 247, 184, 45,
787, 680, 18, 66, 407, 369, 54, 492, 228, 613, 830, 922, 437, 519, 644, 905,
789, 420, 305, 441, 207, 300, 892, 827, 141, 537, 381, 662, 513, 56, 252, 341,
242, 797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310, 756, 665, 397, 808,
851, 309, 473, 795, 378, 31, 647, 915, 459, 806, 590, 731, 425, 216, 548, 249,
321, 881, 699, 535, 673, 782, 210, 815, 905, 303, 843, 922, 281, 73, 469, 791,
660, 162, 498, 308, 155, 422, 907, 817, 187, 62, 16, 425, 535, 336, 286, 437,
375, 273, 610, 296, 183, 923, 116, 667, 751, 353, 62, 366, 691, 379, 687, 842,
37, 357, 720, 742, 330, 5, 39, 923, 311, 424, 242, 749, 321, 54, 669, 316,
342, 299, 534, 105, 667, 488, 640, 672, 576, 540, 316, 486, 721, 610, 46, 656,
447, 171, 616, 464, 190, 531, 297, 321, 762, 752, 533, 175, 134, 14, 381, 433,
717, 45, 111, 20, 596, 284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780,
407, 164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768, 223, 849, 647,
63, 310, 863, 251, 366, 304, 282, 738, 675, 410, 389, 244, 31, 121, 303, 263
};
static const unsigned short int pdf_bitpattern[2787] = {
0xEAE0, 0xF578, 0xFABE, 0xEA70, 0xF53C, 0xFA9F, 0xD460, 0xEA38, 0xD430, 0xA820,
0xD418, 0xA810, 0xD6E0, 0xEB78, 0xF5BE, 0xD670, 0xEB3C, 0xF59F, 0xAC60, 0xD638,
0xAC30, 0xAEE0, 0xD778, 0xEBBE, 0xAE70, 0xD73C, 0xEB9F, 0xAE38, 0xD71E, 0xAF78,
0xD7BE, 0xAF3C, 0xD79F, 0xAFBE, 0xFAFD, 0xE970, 0xF4BC, 0xFA5F, 0xD260, 0xE938,
0xF49E, 0xD230, 0xE91C, 0xA420, 0xD218, 0xE90E, 0xA410, 0xD20C, 0xA408, 0xD370,
0xE9BC, 0xF4DF, 0xA660, 0xD338, 0xE99E, 0xA630, 0xD31C, 0xE98F, 0xA618, 0xD30E,
0xA770, 0xD3BC, 0xE9DF, 0xA738, 0xD39E, 0xA71C, 0xD38F, 0xA7BC, 0xD3DF, 0xA79E,
0xA78F, 0xD160, 0xE8B8, 0xF45E, 0xD130, 0xE89C, 0xF44F, 0xA220, 0xD118, 0xE88E,
0xA210, 0xD10C, 0xA208, 0xA204, 0xA360, 0xD1B8, 0xE8DE, 0xA330, 0xD19C, 0xE8CF,
0xA318, 0xD18E, 0xA30C, 0xA306, 0xA3B8, 0xD1DE, 0xA39C, 0xD1CF, 0xA38E, 0xA3DE,
0xD0B0, 0xE85C, 0xF42F, 0xA120, 0xD098, 0xE84E, 0xA110, 0xD08C, 0xE847, 0xA108,
0xD086, 0xA104, 0xD083, 0xA1B0, 0xD0DC, 0xE86F, 0xA198, 0xD0CE, 0xA18C, 0xD0C7,
0xA186, 0xA183, 0xD0EF, 0xA1C7, 0xA0A0, 0xD058, 0xE82E, 0xA090, 0xD04C, 0xE827,
0xA088, 0xD046, 0xA084, 0xD043, 0xA082, 0xA0D8, 0xA0CC, 0xA0C6, 0xA050, 0xE817,
0xD026, 0xD023, 0xA041, 0xE570, 0xF2BC, 0xF95F, 0xCA60, 0xE538, 0xF29E, 0xCA30,
0xE51C, 0xF28F, 0x9420, 0xCA18, 0x9410, 0xCB70, 0xE5BC, 0xF2DF, 0x9660, 0xCB38,
0xE59E, 0x9630, 0xCB1C, 0x9618, 0x960C, 0x9770, 0xCBBC, 0xE5DF, 0x9738, 0xCB9E,
0x971C, 0x970E, 0x97BC, 0xCBDF, 0x979E, 0x97DF, 0xED60, 0xF6B8, 0xFB5E, 0xED30,
0xF69C, 0xFB4F, 0xDA20, 0xED18, 0xF68E, 0xDA10, 0xED0C, 0xF687, 0xDA08, 0xED06,
0xC960, 0xE4B8, 0xF25E, 0xDB60, 0xC930, 0xE49C, 0xF24F, 0xDB30, 0xED9C, 0xF6CF,
0xB620, 0x9210, 0xC90C, 0xE487, 0xB610, 0xDB0C, 0xB608, 0x9360, 0xC9B8, 0xE4DE,
0xB760, 0x9330, 0xC99C, 0xE4CF, 0xB730, 0xDB9C, 0xEDCF, 0xB718, 0x930C, 0xB70C,
0x93B8, 0xC9DE, 0xB7B8, 0x939C, 0xC9CF, 0xB79C, 0xDBCF, 0xB78E, 0x93DE, 0xB7DE,
0x93CF, 0xB7CF, 0xECB0, 0xF65C, 0xFB2F, 0xD920, 0xEC98, 0xF64E, 0xD910, 0xEC8C,
0xF647, 0xD908, 0xEC86, 0xD904, 0xD902, 0xC8B0, 0xE45C, 0xF22F, 0xD9B0, 0xC898,
0xE44E, 0xB320, 0x9110, 0xECCE, 0xE447, 0xB310, 0x9108, 0xC886, 0xB308, 0xD986,
0xC883, 0x9102, 0x91B0, 0xC8DC, 0xE46F, 0xB3B0, 0x9198, 0xC8CE, 0xB398, 0xD9CE,
0xC8C7, 0xB38C, 0x9186, 0x9183, 0x91DC, 0xC8EF, 0xB3DC, 0x91CE, 0xB3CE, 0x91C7,
0xB3C7, 0xB3EF, 0xD8A0, 0xEC58, 0xF62E, 0xD890, 0xEC4C, 0xF627, 0xD888, 0xEC46,
0xD884, 0xEC43, 0xD882, 0xD881, 0x90A0, 0xC858, 0xE42E, 0xB1A0, 0x9090, 0xC84C,
0xE427, 0xB190, 0xD8CC, 0xEC67, 0xB188, 0x9084, 0xC843, 0xB184, 0xD8C3, 0xB182,
0x90D8, 0xC86E, 0xB1D8, 0x90CC, 0xC867, 0xB1CC, 0xD8E7, 0xB1C6, 0x90C3, 0xB1C3,
0xB1EE, 0xB1E7, 0xD850, 0xEC2C, 0xF617, 0xD848, 0xEC26, 0xD844, 0xEC23, 0xD842,
0xD841, 0x9050, 0xC82C, 0xE417, 0xB0D0, 0x9048, 0xC826, 0xB0C8, 0xD866, 0xC823,
0xB0C4, 0x9042, 0xB0C2, 0x9041, 0x906C, 0xB0EC, 0xB0E6, 0xB0E3, 0xEC16, 0xEC13,
0xD821, 0xC816, 0x9024, 0xB064, 0xB062, 0xB061, 0xC560, 0xE2B8, 0xF15E, 0xC530,
0xE29C, 0x8A20, 0xC518, 0xE28E, 0x8A10, 0xC50C, 0x8A08, 0x8A04, 0x8B60, 0xC5B8,
0xE2DE, 0x8B30, 0xC59C, 0xE2CF, 0x8B18, 0xC58E, 0x8B0C, 0x8B06, 0x8BB8, 0xC5DE,
0x8B9C, 0xC5CF, 0x8B8E, 0x8BDE, 0x8BCF, 0xE6B0, 0xF35C, 0xF9AF, 0xCD20, 0xE698,
0xF34E, 0xCD10, 0xE68C, 0xF347, 0xCD08, 0xE686, 0xCD04, 0xE683, 0xC4B0, 0xE25C,
0xF12F, 0xCDB0, 0xC498, 0xE24E, 0x9B20, 0x8910, 0xE6CE, 0xE247, 0x9B10, 0xCD8C,
0xC486, 0x9B08, 0x8904, 0x9B04, 0x89B0, 0xC4DC, 0xE26F, 0x9BB0, 0x8998, 0xE6EF,
0x9B98, 0xCDCE, 0xC4C7, 0x9B8C, 0x8986, 0x9B86, 0x89DC, 0xC4EF, 0x9BDC, 0x89CE,
0x9BCE, 0x89C7, 0x89EF, 0x9BEF, 0xEEA0, 0xF758, 0xFBAE, 0xEE90, 0xF74C, 0xFBA7,
0xEE88, 0xF746, 0xEE84, 0xF743, 0xEE82, 0xCCA0, 0xE658, 0xF32E, 0xDDA0, 0xCC90,
0xF76E, 0xF327, 0xDD90, 0xEECC, 0xF767, 0xDD88, 0xCC84, 0xE643, 0xDD84, 0xEEC3,
0xCC81, 0x88A0, 0xC458, 0xE22E, 0x99A0, 0x8890, 0xC44C, 0xE227, 0xBBA0, 0x9990,
0xCCCC, 0xE667, 0xBB90, 0xDDCC, 0xEEE7, 0xC443, 0xBB88, 0x9984, 0xCCC3, 0xBB84,
0x8881, 0x88D8, 0xC46E, 0x99D8, 0x88CC, 0xC467, 0xBBD8, 0x99CC, 0xCCE7, 0xBBCC,
0xDDE7, 0x88C3, 0x99C3, 0x88EE, 0x99EE, 0x88E7, 0xBBEE, 0x99E7, 0xEE50, 0xF72C,
0xFB97, 0xEE48, 0xF726, 0xEE44, 0xF723, 0xEE42, 0xEE41, 0xCC50, 0xE62C, 0xF317,
0xDCD0, 0xCC48, 0xF737, 0xDCC8, 0xEE66, 0xE623, 0xDCC4, 0xCC42, 0xDCC2, 0xCC41,
0xDCC1, 0x8850, 0xC42C, 0xE217, 0x98D0, 0x8848, 0xC426, 0xB9D0, 0x98C8, 0xCC66,
0xC423, 0xB9C8, 0xDCE6, 0x8842, 0xB9C4, 0x98C2, 0x8841, 0x98C1, 0x886C, 0xC437,
0x98EC, 0x8866, 0xB9EC, 0x98E6, 0x8863, 0xB9E6, 0x98E3, 0x8877, 0xB9F7, 0xEE28,
0xF716, 0xEE24, 0xF713, 0xEE22, 0xEE21, 0xCC28, 0xE616, 0xDC68, 0xCC24, 0xE613,
0xDC64, 0xEE33, 0xDC62, 0xCC21, 0xDC61, 0x8828, 0xC416, 0x9868, 0x8824, 0xC413,
0xB8E8, 0x9864, 0xCC33, 0xB8E4, 0xDC73, 0x8821, 0xB8E2, 0x9861, 0xB8E1, 0x9876,
0xB8F6, 0xB8F3, 0xF70B, 0xEE11, 0xE60B, 0xCC12, 0xCC11, 0x8814, 0x9834, 0xB874,
0x8811, 0x9831, 0xC2B0, 0x8520, 0xC298, 0x8510, 0xC28C, 0xE147, 0x8508, 0xC286,
0x8504, 0xC283, 0x85B0, 0xC2DC, 0xE16F, 0x8598, 0xC2CE, 0x858C, 0xC2C7, 0x8586,
0x8583, 0x85DC, 0xC2EF, 0x85CE, 0x85C7, 0x85EF, 0xC6A0, 0xE358, 0xF1AE, 0xC690,
0xE34C, 0xC688, 0xE346, 0xC684, 0xE343, 0xC682, 0x84A0, 0xC258, 0xE12E, 0x8DA0,
0x8490, 0xE36E, 0xE127, 0x8D90, 0xC6CC, 0xE367, 0x8D88, 0x8484, 0xC243, 0x8D84,
0xC6C3, 0x8481, 0x84D8, 0xC26E, 0x8DD8, 0x84CC, 0xC267, 0x8DCC, 0xC6E7, 0x8DC6,
0x84C3, 0x84EE, 0x8DEE, 0x84E7, 0x8DE7, 0xE750, 0xF3AC, 0xF9D7, 0xE748, 0xF3A6,
0xE744, 0xF3A3, 0xE742, 0xE741, 0xC650, 0xE32C, 0xCED0, 0xC648, 0xE326, 0xCEC8,
0xE766, 0xE323, 0xCEC4, 0xC642, 0xCEC2, 0xC641, 0xCEC1, 0x8450, 0xC22C, 0x8CD0,
0x8448, 0xE337, 0x9DD0, 0x8CC8, 0xC666, 0xC223, 0x9DC8, 0xCEE6, 0x8442, 0x9DC4,
0x8CC2, 0x8441, 0x8CC1, 0x846C, 0xC237, 0x8CEC, 0x8466, 0x9DEC, 0x8CE6, 0x8463,
0x9DE6, 0x8CE3, 0x8477, 0x8CF7, 0x9DF7, 0xF7A8, 0xFBD6, 0xF7A4, 0xFBD3, 0xF7A2,
0xF7A1, 0xE728, 0xF396, 0xEF68, 0xF7B6, 0xF393, 0xEF64, 0xF7B3, 0xEF62, 0xE721,
0xEF61, 0xC628, 0xE316, 0xCE68, 0xC624, 0xE313, 0xDEE8, 0xCE64, 0xE733, 0xDEE4,
0xEF73, 0xC621, 0xDEE2, 0xCE61, 0xDEE1, 0x8428, 0xC216, 0x8C68, 0x8424, 0xC213,
0x9CE8, 0x8C64, 0xC633, 0xBDE8, 0x9CE4, 0xCE73, 0x8421, 0xBDE4, 0xDEF3, 0x8C61,
0xBDE2, 0x8436, 0x8C76, 0x8433, 0x9CF6, 0x8C73, 0xBDF6, 0x9CF3, 0xBDF3, 0xF794,
0xFBCB, 0xF792, 0xF791, 0xE714, 0xF38B, 0xEF34, 0xF79B, 0xEF32, 0xE711, 0xEF31,
0xC614, 0xE30B, 0xCE34, 0xC612, 0xDE74, 0xCE32, 0xC611, 0xDE72, 0xCE31, 0xDE71,
0x8414, 0xC20B, 0x8C34, 0xC61B, 0x9C74, 0x8C32, 0x8411, 0xBCF4, 0x9C72, 0x8C31,
0xBCF2, 0x9C71, 0xBCF1, 0x8C3B, 0xBCFB, 0xF789, 0xEF1A, 0xEF19, 0xCE1A, 0xDE3A,
0xDE39, 0x8C1A, 0x9C3A, 0xBC7A, 0xBC79, 0x82A0, 0x8290, 0xC14C, 0x8288, 0x8284,
0x8282, 0x82D8, 0x82CC, 0x82C6, 0x82C3, 0x82EE, 0x82E7, 0xC350, 0xC348, 0xE1A6,
0xC344, 0xE1A3, 0xC342, 0xC341, 0x8250, 0xC12C, 0x86D0, 0xC36C, 0xC126, 0x86C8,
0xC366, 0x86C4, 0xC363, 0x86C2, 0x8241, 0x86C1, 0x826C, 0xC137, 0x86EC, 0xC377,
0x86E6, 0x8263, 0x86E3, 0x8277, 0x86F7, 0xE3A8, 0xE3A4, 0xE3A2, 0xE3A1, 0xC328,
0xC768, 0xE3B6, 0xE193, 0xC764, 0xE3B3, 0xC762, 0xC321, 0xC761, 0x8228, 0x8668,
0x8224, 0xC113, 0x8EE8, 0x8664, 0x8222, 0x8EE4, 0x8662, 0x8221, 0x8EE2, 0x8661,
0x8236, 0x8676, 0x8233, 0x8EF6, 0x8673, 0x8EF3, 0xF3D4, 0xF3D2, 0xF3D1, 0xE394,
0xE7B4, 0xF3DB, 0xE7B2, 0xE391, 0xE7B1, 0xC314, 0xE18B, 0xC734, 0xE39B, 0xCF74,
0xC732, 0xC311, 0xCF72, 0xC731, 0xCF71, 0x8214, 0xC10B, 0x8634, 0xC31B, 0x8E74,
0x8632, 0x8211, 0x9EF4, 0x8E72, 0x8631, 0x9EF2, 0x8E71, 0x821B, 0x863B, 0x8E7B,
0x9EFB, 0xFBEA, 0xFBE9, 0xF3CA, 0xF7DA, 0xF3C9, 0xF7D9, 0xE38A, 0xE79A, 0xE389,
0xEFBA, 0xE799, 0xEFB9, 0xC30A, 0xC71A, 0xC309, 0xCF3A, 0xC719, 0xDF7A, 0xFAB0,
0xFD5C, 0xF520, 0xFA98, 0xFD4E, 0xF510, 0xFA8C, 0xFD47, 0xF508, 0xFA86, 0xF504,
0xFA83, 0xF502, 0xF5B0, 0xFADC, 0xFD6F, 0xEB20, 0xF598, 0xFACE, 0xEB10, 0xF58C,
0xFAC7, 0xEB08, 0xF586, 0xEB04, 0xF583, 0xEB02, 0xEBB0, 0xF5DC, 0xFAEF, 0xD720,
0xEB98, 0xF5CE, 0xD710, 0xEB8C, 0xF5C7, 0xD708, 0xEB86, 0xD704, 0xEB83, 0xD702,
0xD7B0, 0xEBDC, 0xF5EF, 0xAF20, 0xD798, 0xEBCE, 0xAF10, 0xD78C, 0xEBC7, 0xAF08,
0xD786, 0xAF04, 0xD783, 0xAFB0, 0xD7DC, 0xEBEF, 0xAF98, 0xD7CE, 0xAF8C, 0xD7C7,
0xAF86, 0xAFDC, 0xD7EF, 0xAFCE, 0xAFC7, 0xF4A0, 0xFA58, 0xFD2E, 0xF490, 0xFA4C,
0xFD27, 0xF488, 0xFA46, 0xF484, 0xFA43, 0xF482, 0xF481, 0xE9A0, 0xF4D8, 0xFA6E,
0xE990, 0xF4CC, 0xFA67, 0xE988, 0xF4C6, 0xE984, 0xF4C3, 0xE982, 0xE981, 0xD3A0,
0xE9D8, 0xF4EE, 0xD390, 0xE9CC, 0xF4E7, 0xD388, 0xE9C6, 0xD384, 0xE9C3, 0xD382,
0xD381, 0xA7A0, 0xD3D8, 0xE9EE, 0xA790, 0xD3CC, 0xE9E7, 0xA788, 0xD3C6, 0xA784,
0xD3C3, 0xA782, 0xA7D8, 0xD3EE, 0xA7CC, 0xD3E7, 0xA7C6, 0xA7C3, 0xA7EE, 0xA7E7,
0xF450, 0xFA2C, 0xFD17, 0xF448, 0xFA26, 0xF444, 0xFA23, 0xF442, 0xF441, 0xE8D0,
0xF46C, 0xFA37, 0xE8C8, 0xF466, 0xE8C4, 0xF463, 0xE8C2, 0xE8C1, 0xD1D0, 0xE8EC,
0xF477, 0xD1C8, 0xE8E6, 0xD1C4, 0xE8E3, 0xD1C2, 0xD1C1, 0xA3D0, 0xD1EC, 0xE8F7,
0xA3C8, 0xD1E6, 0xA3C4, 0xD1E3, 0xA3C2, 0xA3C1, 0xA3EC, 0xD1F7, 0xA3E6, 0xA3E3,
0xA3F7, 0xF428, 0xFA16, 0xF424, 0xFA13, 0xF422, 0xF421, 0xE868, 0xF436, 0xE864,
0xF433, 0xE862, 0xE861, 0xD0E8, 0xE876, 0xD0E4, 0xE873, 0xD0E2, 0xD0E1, 0xA1E8,
0xD0F6, 0xA1E4, 0xD0F3, 0xA1E2, 0xA1E1, 0xA1F6, 0xA1F3, 0xF414, 0xFA0B, 0xF412,
0xF411, 0xE834, 0xF41B, 0xE832, 0xE831, 0xD074, 0xE83B, 0xD072, 0xD071, 0xA0F4,
0xD07B, 0xA0F2, 0xA0F1, 0xF40A, 0xF409, 0xE81A, 0xE819, 0xD03A, 0xD039, 0xF2A0,
0xF958, 0xFCAE, 0xF290, 0xF94C, 0xFCA7, 0xF288, 0xF946, 0xF284, 0xF943, 0xF282,
0xF281, 0xE5A0, 0xF2D8, 0xF96E, 0xE590, 0xF2CC, 0xF967, 0xE588, 0xF2C6, 0xE584,
0xF2C3, 0xE582, 0xE581, 0xCBA0, 0xE5D8, 0xF2EE, 0xCB90, 0xE5CC, 0xF2E7, 0xCB88,
0xE5C6, 0xCB84, 0xE5C3, 0xCB82, 0xCB81, 0x97A0, 0xCBD8, 0xE5EE, 0x9790, 0xCBCC,
0xE5E7, 0x9788, 0xCBC6, 0x9784, 0xCBC3, 0x9782, 0x97D8, 0xCBEE, 0x97CC, 0xCBE7,
0x97C6, 0x97C3, 0x97EE, 0x97E7, 0xFB50, 0xFDAC, 0xB5F8, 0xFB48, 0xFDA6, 0xB4FC,
0xFB44, 0xFDA3, 0xB47E, 0xFB42, 0xFB41, 0xF250, 0xF92C, 0xFC97, 0xF6D0, 0xF248,
0xFDB7, 0xF6C8, 0xFB66, 0xF923, 0xF6C4, 0xF242, 0xF6C2, 0xF241, 0xF6C1, 0xE4D0,
0xF26C, 0xF937, 0xEDD0, 0xE4C8, 0xF266, 0xEDC8, 0xF6E6, 0xF263, 0xEDC4, 0xE4C2,
0xEDC2, 0xE4C1, 0xEDC1, 0xC9D0, 0xE4EC, 0xF277, 0xDBD0, 0xC9C8, 0xE4E6, 0xDBC8,
0xEDE6, 0xE4E3, 0xDBC4, 0xC9C2, 0xDBC2, 0xC9C1, 0xDBC1, 0x93D0, 0xC9EC, 0xE4F7,
0xB7D0, 0x93C8, 0xC9E6, 0xB7C8, 0xDBE6, 0xC9E3, 0xB7C4, 0x93C2, 0xB7C2, 0x93C1,
0x93EC, 0xC9F7, 0xB7EC, 0x93E6, 0xB7E6, 0x93E3, 0xB7E3, 0x93F7, 0xFB28, 0xFD96,
0xB2FC, 0xFB24, 0xFD93, 0xB27E, 0xFB22, 0xB23F, 0xFB21, 0xF228, 0xF916, 0xF668,
0xF224, 0xF913, 0xF664, 0xFB33, 0xF662, 0xF221, 0xF661, 0xE468, 0xF236, 0xECE8,
0xE464, 0xF233, 0xECE4, 0xF673, 0xECE2, 0xE461, 0xECE1, 0xC8E8, 0xE476, 0xD9E8,
0xC8E4, 0xE473, 0xD9E4, 0xECF3, 0xD9E2, 0xC8E1, 0xD9E1, 0x91E8, 0xC8F6, 0xB3E8,
0x91E4, 0xC8F3, 0xB3E4, 0xD9F3, 0xB3E2, 0x91E1, 0xB3E1, 0x91F6, 0xB3F6, 0x91F3,
0xB3F3, 0xFB14, 0xFD8B, 0xB17E, 0xFB12, 0xB13F, 0xFB11, 0xF214, 0xF90B, 0xF634,
0xFB1B, 0xF632, 0xF211, 0xF631, 0xE434, 0xF21B, 0xEC74, 0xE432, 0xEC72, 0xE431,
0xEC71, 0xC874, 0xE43B, 0xD8F4, 0xEC7B, 0xD8F2, 0xC871, 0xD8F1, 0x90F4, 0xC87B,
0xB1F4, 0x90F2, 0xB1F2, 0x90F1, 0xB1F1, 0x90FB, 0xB1FB, 0xFB0A, 0xB0BF, 0xFB09,
0xF20A, 0xF61A, 0xF209, 0xF619, 0xE41A, 0xEC3A, 0xE419, 0xEC39, 0xC83A, 0xD87A,
0xC839, 0xD879, 0x907A, 0xB0FA, 0x9079, 0xB0F9, 0xFB05, 0xF205, 0xF60D, 0xE40D,
0xEC1D, 0xC81D, 0xD83D, 0xF150, 0xF8AC, 0xFC57, 0xF148, 0xF8A6, 0xF144, 0xF8A3,
0xF142, 0xF141, 0xE2D0, 0xF16C, 0xF8B7, 0xE2C8, 0xF166, 0xE2C4, 0xF163, 0xE2C2,
0xE2C1, 0xC5D0, 0xE2EC, 0xF177, 0xC5C8, 0xE2E6, 0xC5C4, 0xE2E3, 0xC5C2, 0xC5C1,
0x8BD0, 0xC5EC, 0xE2F7, 0x8BC8, 0xC5E6, 0x8BC4, 0xC5E3, 0x8BC2, 0x8BC1, 0x8BEC,
0xC5F7, 0x8BE6, 0x8BE3, 0x8BF7, 0xF9A8, 0xFCD6, 0x9AFC, 0xF9A4, 0xFCD3, 0x9A7E,
0xF9A2, 0x9A3F, 0xF9A1, 0xF128, 0xF896, 0xF368, 0xF124, 0xF893, 0xF364, 0xF9B3,
0xF362, 0xF121, 0xF361, 0xE268, 0xF136, 0xE6E8, 0xE264, 0xF133, 0xE6E4, 0xF373,
0xE6E2, 0xE261, 0xE6E1, 0xC4E8, 0xE276, 0xCDE8, 0xC4E4, 0xE273, 0xCDE4, 0xE6F3,
0xCDE2, 0xC4E1, 0xCDE1, 0x89E8, 0xC4F6, 0x9BE8, 0x89E4, 0xC4F3, 0x9BE4, 0xCDF3,
0x9BE2, 0x89E1, 0x9BE1, 0x89F6, 0x9BF6, 0x89F3, 0x9BF3, 0xFDD4, 0xBAF8, 0xDD7E,
0xFDD2, 0xBA7C, 0xDD3F, 0xFDD1, 0xBA3E, 0xBA1F, 0xF994, 0xFCCB, 0x997E, 0xFBB4,
0xFDDB, 0xBB7E, 0x993F, 0xFBB2, 0xF991, 0xBB3F, 0xFBB1, 0xF114, 0xF88B, 0xF334,
0xF112, 0xF774, 0xFBBB, 0xF111, 0xF772, 0xF331, 0xF771, 0xE234, 0xF11B, 0xE674,
0xE232, 0xEEF4, 0xE672, 0xE231, 0xEEF2, 0xE671, 0xEEF1, 0xC474, 0xE23B, 0xCCF4,
0xC472, 0xDDF4, 0xCCF2, 0xC471, 0xDDF2, 0xCCF1, 0xDDF1, 0x88F4, 0xC47B, 0x99F4,
0x88F2, 0xBBF4, 0x99F2, 0x88F1, 0xBBF2, 0x99F1, 0xBBF1, 0x88FB, 0x99FB, 0xFDCA,
0xB97C, 0xDCBF, 0xFDC9, 0xB93E, 0xB91F, 0xF98A, 0x98BF, 0xFB9A, 0xF989, 0xB9BF,
0xFB99, 0xF10A, 0xF31A, 0xF109, 0xF73A, 0xF319, 0xF739, 0xE21A, 0xE63A, 0xE219,
0xEE7A, 0xE639, 0xEE79, 0xC43A, 0xCC7A, 0xC439, 0xDCFA, 0xCC79, 0xDCF9, 0x887A,
0x98FA, 0x8879, 0xB9FA, 0x98F9, 0xB9F9, 0xFDC5, 0xB8BE, 0xB89F, 0xF985, 0xFB8D,
0xF105, 0xF30D, 0xF71D, 0xE20D, 0xE61D, 0xEE3D, 0xC41D, 0xCC3D, 0xDC7D, 0x883D,
0x987D, 0xB8FD, 0xB85F, 0xF0A8, 0xF856, 0xF0A4, 0xF853, 0xF0A2, 0xF0A1, 0xE168,
0xF0B6, 0xE164, 0xF0B3, 0xE162, 0xE161, 0xC2E8, 0xE176, 0xC2E4, 0xE173, 0xC2E2,
0xC2E1, 0x85E8, 0xC2F6, 0x85E4, 0xC2F3, 0x85E2, 0x85E1, 0x85F6, 0x85F3, 0xF8D4,
0xFC6B, 0x8D7E, 0xF8D2, 0x8D3F, 0xF8D1, 0xF094, 0xF84B, 0xF1B4, 0xF092, 0xF1B2,
0xF091, 0xF1B1, 0xE134, 0xF09B, 0xE374, 0xE132, 0xE372, 0xE131, 0xE371, 0xC274,
0xE13B, 0xC6F4, 0xC272, 0xC6F2, 0xC271, 0xC6F1, 0x84F4, 0xC27B, 0x8DF4, 0x84F2,
0x8DF2, 0x84F1, 0x8DF1, 0x84FB, 0x8DFB, 0xFCEA, 0x9D7C, 0xCEBF, 0xFCE9, 0x9D3E,
0x9D1F, 0xF8CA, 0x8CBF, 0xF9DA, 0xF8C9, 0x9DBF, 0xF9D9, 0xF08A, 0xF19A, 0xF089,
0xF3BA, 0xF199, 0xF3B9, 0xE11A, 0xE33A, 0xE119, 0xE77A, 0xE339, 0xE779, 0xC23A,
0xC67A, 0xC239, 0xCEFA, 0xC679, 0xCEF9, 0x847A, 0x8CFA, 0x8479, 0x9DFA, 0x8CF9,
0x9DF9, 0xBD78, 0xDEBE, 0xBD3C, 0xDE9F, 0xBD1E, 0xBD0F, 0xFCE5, 0x9CBE, 0xFDED,
0xBDBE, 0x9C9F, 0xBD9F, 0xF8C5, 0xF9CD, 0xFBDD, 0xF085, 0xF18D, 0xF39D, 0xF7BD,
0xE10D, 0xE31D, 0xE73D, 0xEF7D, 0xC21D, 0xC63D, 0xCE7D, 0xDEFD, 0x843D, 0x8C7D,
0x9CFD, 0xBCBC, 0xDE5F, 0xBC9E, 0xBC8F, 0x9C5F, 0xBCDF, 0xBC5E, 0xBC4F, 0xBC2F,
0xF054, 0xF052, 0xF051, 0xE0B4, 0xF05B, 0xE0B2, 0xE0B1, 0xC174, 0xE0BB, 0xC172,
0xC171, 0x82F4, 0xC17B, 0x82F2, 0x82F1, 0x82FB, 0xF86A, 0x86BF, 0xF869, 0xF04A,
0xF0DA, 0xF049, 0xF0D9, 0xE09A, 0xE1BA, 0xE099, 0xE1B9, 0xC13A, 0xC37A, 0xC139,
0xC379, 0x827A, 0x86FA, 0x8279, 0x86F9, 0xFC75, 0x8EBE, 0x8E9F, 0xF865, 0xF8ED,
0xF045, 0xF0CD, 0xF1DD, 0xE08D, 0xE19D, 0xE3BD, 0xC11D, 0xC33D, 0xC77D, 0x823D,
0x867D, 0x8EFD, 0x9EBC, 0xCF5F, 0x9E9E, 0x9E8F, 0x8E5F, 0x9EDF, 0xBEB8, 0xDF5E,
0xBE9C, 0xDF4F, 0xBE8E, 0xBE87, 0x9E5E, 0xBEDE, 0x9E4F, 0xBECF, 0xBE5C, 0xDF2F,
0xBE4E, 0xBE47, 0x9E2F, 0xBE6F, 0xBE2E, 0xBE27, 0xBE17, 0xE05A, 0xE059, 0xC0BA,
0xC0B9, 0x817A, 0x8179, 0xF06D, 0xE04D, 0xE0DD, 0xC09D, 0xC1BD, 0x813D, 0x837D,
0x875F, 0x8F5E, 0x8F4F, 0x9F5C, 0xCFAF, 0x9F4E, 0x9F47, 0x8F2F, 0x9F6F, 0xBF58,
0xDFAE, 0xBF4C, 0xDFA7, 0xBF46, 0xBF43, 0x9F2E, 0xBF6E, 0x9F27, 0xBF67, 0xBF2C,
0xDF97, 0xBF26, 0xBF23, 0x9F17, 0xBF37, 0xBF16, 0xBF13, 0x87AF, 0x8FAE, 0x8FA7,
0x9FAC, 0xCFD7, 0x9FA6, 0x9FA3, 0x8F97, 0x9FB7, 0x9F96, 0x9F93, 0xD5F0, 0xEAFC,
0xA9E0, 0xD4F8, 0xEA7E, 0xA8F0, 0xD47C, 0xEA3F, 0xA878, 0xD43E, 0xA83C, 0xFD68,
0xADF0, 0xD6FC, 0xFD64, 0xACF8, 0xD67E, 0xFD62, 0xAC7C, 0xD63F, 0xFD61, 0xAC3E,
0xFAE8, 0xFD76, 0xAEFC, 0xFAE4, 0xFD73, 0xAE7E, 0xFAE2, 0xAE3F, 0xFAE1, 0xF5E8,
0xFAF6, 0xF5E4, 0xFAF3, 0xF5E2, 0xF5E1, 0xEBE8, 0xF5F6, 0xEBE4, 0xF5F3, 0xEBE2,
0xEBE1, 0xD7E8, 0xEBF6, 0xD7E4, 0xEBF3, 0xD7E2, 0xA5E0, 0xD2F8, 0xE97E, 0xA4F0,
0xD27C, 0xE93F, 0xA478, 0xD23E, 0xA43C, 0xD21F, 0xA41E, 0xFD34, 0xA6F8, 0xD37E,
0xFD32, 0xA67C, 0xD33F, 0xFD31, 0xA63E, 0xA61F, 0xFA74, 0xFD3B, 0xA77E, 0xFA72,
0xA73F, 0xFA71, 0xF4F4, 0xFA7B, 0xF4F2, 0xF4F1, 0xE9F4, 0xF4FB, 0xE9F2, 0xE9F1,
0xD3F4, 0xE9FB, 0xD3F2, 0xD3F1, 0xA2F0, 0xD17C, 0xE8BF, 0xA278, 0xD13E, 0xA23C,
0xD11F, 0xA21E, 0xA20F, 0xFD1A, 0xA37C, 0xD1BF, 0xFD19, 0xA33E, 0xA31F, 0xFA3A,
0xA3BF, 0xFA39, 0xF47A, 0xF479, 0xE8FA, 0xE8F9, 0xD1FA, 0xD1F9, 0xA178, 0xD0BE,
0xA13C, 0xD09F, 0xA11E, 0xA10F, 0xFD0D, 0xA1BE, 0xA19F, 0xFA1D, 0xF43D, 0xE87D,
0xA0BC, 0xD05F, 0xA09E, 0xA08F, 0xA0DF, 0xA05E, 0xA04F, 0x95E0, 0xCAF8, 0xE57E,
0x94F0, 0xCA7C, 0xE53F, 0x9478, 0xCA3E, 0x943C, 0xCA1F, 0x941E, 0xFCB4, 0x96F8,
0xCB7E, 0xFCB2, 0x967C, 0xCB3F, 0xFCB1, 0x963E, 0x961F, 0xF974, 0xFCBB, 0x977E,
0xF972, 0x973F, 0xF971, 0xF2F4, 0xF97B, 0xF2F2, 0xF2F1, 0xE5F4, 0xF2FB, 0xE5F2,
0xE5F1, 0xCBF4, 0xE5FB, 0xCBF2, 0xCBF1, 0xDAF0, 0xED7C, 0xF6BF, 0xB4E0, 0xDA78,
0xED3E, 0xB470, 0xDA3C, 0xED1F, 0xB438, 0xDA1E, 0xB41C, 0xDA0F, 0xB40E, 0x92F0,
0xC97C, 0xE4BF, 0xB6F0, 0x9278, 0xC93E, 0xB678, 0xDB3E, 0xC91F, 0xB63C, 0x921E,
0xB61E, 0x920F, 0xB60F, 0xFC9A, 0x937C, 0xC9BF, 0xFDBA, 0xFC99, 0xB77C, 0x933E,
0xFDB9, 0xB73E, 0x931F, 0xB71F, 0xF93A, 0x93BF, 0xFB7A, 0xF939, 0xB7BF, 0xFB79,
0xF27A, 0xF6FA, 0xF279, 0xF6F9, 0xE4FA, 0xEDFA, 0xE4F9, 0xEDF9, 0xC9FA, 0xC9F9,
0xB2E0, 0xD978, 0xECBE, 0xB270, 0xD93C, 0xEC9F, 0xB238, 0xD91E, 0xB21C, 0xD90F,
0xB20E, 0xB207, 0x9178, 0xC8BE, 0xB378, 0x913C, 0xC89F, 0xB33C, 0xD99F, 0xB31E,
0x910F, 0xB30F, 0xFC8D, 0x91BE, 0xFD9D, 0xB3BE, 0x919F, 0xB39F, 0xF91D, 0xFB3D,
0xF23D, 0xF67D, 0xE47D, 0xECFD, 0xC8FD, 0xB170, 0xD8BC, 0xEC5F, 0xB138, 0xD89E,
0xB11C, 0xD88F, 0xB10E, 0xB107, 0x90BC, 0xC85F, 0xB1BC, 0x909E, 0xB19E, 0x908F,
0xB18F, 0x90DF, 0xB1DF, 0xB0B8, 0xD85E, 0xB09C, 0xD84F, 0xB08E, 0xB087, 0x905E,
0xB0DE, 0x904F, 0xB0CF, 0xB05C, 0xD82F, 0xB04E, 0xB047, 0x902F, 0xB06F, 0xB02E,
0xB027, 0x8AF0, 0xC57C, 0xE2BF, 0x8A78, 0xC53E, 0x8A3C, 0xC51F, 0x8A1E, 0x8A0F,
0xFC5A, 0x8B7C, 0xC5BF, 0xFC59, 0x8B3E, 0x8B1F, 0xF8BA, 0x8BBF, 0xF8B9, 0xF17A,
0xF179, 0xE2FA, 0xE2F9, 0xC5FA, 0xC5F9, 0x9AE0, 0xCD78, 0xE6BE, 0x9A70, 0xCD3C,
0xE69F, 0x9A38, 0xCD1E, 0x9A1C, 0xCD0F, 0x9A0E, 0x9A07, 0x8978, 0xC4BE, 0x9B78,
0x893C, 0xC49F, 0x9B3C, 0xCD9F, 0x9B1E, 0x890F, 0x9B0F, 0xFC4D, 0x89BE, 0xFCDD,
0x9BBE, 0x899F, 0x9B9F, 0xF89D, 0xF9BD, 0xF13D, 0xF37D, 0xE27D, 0xE6FD, 0xC4FD,
0xDD70, 0xEEBC, 0xF75F, 0xBA60, 0xDD38, 0xEE9E, 0xBA30, 0xDD1C, 0xEE8F, 0xBA18,
0xDD0E, 0xBA0C, 0xDD07, 0xBA06, 0x9970, 0xCCBC, 0xE65F, 0xBB70, 0x9938, 0xCC9E,
0xBB38, 0xDD9E, 0xCC8F, 0xBB1C, 0x990E, 0xBB0E, 0x9907, 0xBB07, 0x88BC, 0xC45F,
0x99BC, 0x889E, 0xBBBC, 0x999E, 0x888F, 0xBB9E, 0x998F, 0xBB8F, 0x88DF, 0x99DF,
0xBBDF, 0xB960, 0xDCB8, 0xEE5E, 0xB930, 0xDC9C, 0xEE4F, 0xB918, 0xDC8E, 0xB90C,
0xDC87, 0xB906, 0xB903, 0x98B8, 0xCC5E, 0xB9B8, 0x989C, 0xCC4F, 0xB99C, 0xDCCF,
0xB98E, 0x9887, 0xB987, 0x885E, 0x98DE, 0x884F, 0xB9DE, 0x98CF, 0xB9CF, 0xB8B0,
0xDC5C, 0xEE2F, 0xB898, 0xDC4E, 0xB88C, 0xDC47, 0xB886, 0xB883, 0x985C, 0xCC2F,
0xB8DC, 0x984E, 0xB8CE, 0x9847, 0xB8C7, 0x882F, 0x986F, 0xB8EF, 0xB858, 0xDC2E,
0xB84C, 0xDC27, 0xB846, 0xB843, 0x982E, 0xB86E, 0x9827, 0xB867, 0xB82C, 0xDC17,
0xB826, 0xB823, 0x9817, 0xB837, 0xB816, 0xB813, 0x8578, 0xC2BE, 0x853C, 0xC29F,
0x851E, 0x850F, 0x85BE, 0x859F, 0xF85D, 0xF0BD, 0xE17D, 0xC2FD, 0x8D70, 0xC6BC,
0xE35F, 0x8D38, 0xC69E, 0x8D1C, 0xC68F, 0x8D0E, 0x8D07, 0x84BC, 0xC25F, 0x8DBC,
0x849E, 0x8D9E, 0x848F, 0x8D8F, 0x84DF, 0x8DDF, 0x9D60, 0xCEB8, 0xE75E, 0x9D30,
0xCE9C, 0xE74F, 0x9D18, 0xCE8E, 0x9D0C, 0xCE87, 0x9D06, 0x9D03, 0x8CB8, 0xC65E,
0x9DB8, 0x8C9C, 0xC64F, 0x9D9C, 0x8C8E, 0x9D8E, 0x8C87, 0x9D87, 0x845E, 0x8CDE,
0x844F, 0x9DDE, 0x8CCF, 0x9DCF, 0xDEB0, 0xEF5C, 0xF7AF, 0xBD20, 0xDE98, 0xEF4E,
0xBD10, 0xDE8C, 0xEF47, 0xBD08, 0xDE86, 0xBD04, 0xDE83, 0xBD02, 0x9CB0, 0xCE5C,
0xE72F, 0xBDB0, 0x9C98, 0xCE4E, 0xBD98, 0xDECE, 0xCE47, 0xBD8C, 0x9C86, 0xBD86,
0x9C83, 0xBD83, 0x8C5C, 0xC62F, 0x9CDC, 0x8C4E, 0xBDDC, 0x9CCE, 0x8C47, 0xBDCE,
0x9CC7, 0xBDC7, 0x842F, 0x8C6F, 0x9CEF, 0xBDEF, 0xBCA0, 0xDE58, 0xEF2E, 0xBC90,
0xDE4C, 0xEF27, 0xBC88, 0xDE46, 0xBC84, 0xDE43, 0xBC82, 0xBC81, 0x9C58, 0xCE2E,
0xBCD8, 0x9C4C, 0xCE27, 0xBCCC, 0xDE67, 0xBCC6, 0x9C43, 0xBCC3, 0x8C2E, 0x9C6E,
0x8C27, 0xBCEE, 0x9C67, 0xBCE7, 0xBC50, 0xDE2C, 0xEF17, 0xBC48, 0xDE26, 0xBC44,
0xDE23, 0xBC42, 0xBC41, 0x9C2C, 0xCE17, 0xBC6C, 0x9C26, 0xBC66, 0x9C23, 0xBC63,
0x8C17, 0x9C37, 0xBC77, 0xBC28, 0xDE16, 0xBC24, 0xDE13, 0xBC22, 0xBC21, 0x9C16,
0xBC36, 0x9C13, 0xBC33, 0xBC14, 0xDE0B, 0xBC12, 0xBC11, 0x9C0B, 0xBC1B, 0x82BC,
0xC15F, 0x829E, 0x828F, 0x82DF, 0x86B8, 0xC35E, 0x869C, 0xC34F, 0x868E, 0x8687,
0x825E, 0x86DE, 0x824F, 0x86CF, 0x8EB0, 0xC75C, 0xE3AF, 0x8E98, 0xC74E, 0x8E8C,
0xC747, 0x8E86, 0x8E83, 0x865C, 0xC32F, 0x8EDC, 0x864E, 0x8ECE, 0x8647, 0x8EC7,
0x822F, 0x866F, 0x8EEF, 0x9EA0, 0xCF58, 0xE7AE, 0x9E90, 0xCF4C, 0xE7A7, 0x9E88,
0xCF46, 0x9E84, 0xCF43, 0x9E82, 0x9E81, 0x8E58, 0xC72E, 0x9ED8, 0x8E4C, 0xC727,
0x9ECC, 0xCF67, 0x9EC6, 0x8E43, 0x9EC3, 0x862E, 0x8E6E, 0x8627, 0x9EEE, 0x8E67,
0x9EE7, 0xDF50, 0xEFAC, 0xF7D7, 0xDF48, 0xEFA6, 0xDF44, 0xEFA3, 0xDF42, 0xDF41,
0x9E50, 0xCF2C, 0xE797, 0xBED0, 0x9E48, 0xCF26, 0xBEC8, 0xDF66, 0xCF23, 0xBEC4,
0x9E42, 0xBEC2, 0x9E41, 0xBEC1, 0x8E2C, 0xC717, 0x9E6C, 0x8E26, 0xBEEC, 0x9E66,
0x8E23, 0xBEE6, 0x9E63, 0xBEE3, 0x8617, 0x8E37, 0x9E77, 0xBEF7, 0xDF28, 0xEF96,
0xDF24, 0xEF93, 0xDF22, 0xDF21, 0x9E28, 0xCF16, 0xBE68, 0x9E24, 0xCF13, 0xBE64,
0xDF33, 0xBE62, 0x9E21, 0xBE61, 0x8E16, 0x9E36, 0x8E13, 0xBE76, 0x9E33, 0xBE73,
0xDF14, 0xEF8B, 0xDF12, 0xDF11, 0x9E14, 0xCF0B, 0xBE34, 0x9E12, 0xBE32, 0x9E11,
0xBE31, 0x8E0B, 0x9E1B, 0xBE3B, 0xDF0A, 0xDF09, 0x9E0A, 0xBE1A, 0x9E09, 0xBE19,
0x815E, 0x814F, 0x835C, 0xC1AF, 0x834E, 0x8347, 0x812F, 0x836F, 0x8758, 0xC3AE,
0x874C, 0xC3A7, 0x8746, 0x8743, 0x832E, 0x876E, 0x8327, 0x8767, 0x8F50, 0xC7AC,
0xE3D7, 0x8F48, 0xC7A6, 0x8F44, 0xC7A3, 0x8F42, 0x8F41, 0x872C, 0xC397, 0x8F6C,
0xC7B7, 0x8F66, 0x8723, 0x8F63, 0x8317, 0x8737, 0x8F77, 0xCFA8, 0xE7D6, 0xCFA4,
0xE7D3, 0xCFA2, 0xCFA1, 0x8F28, 0xC796, 0x9F68, 0xCFB6, 0xC793, 0x9F64, 0x8F22,
0x9F62, 0x8F21, 0x9F61, 0x8716, 0x8F36, 0x8713, 0x9F76, 0x8F33, 0x9F73, 0xEFD4,
0xF7EB, 0xEFD2, 0xEFD1, 0xCF94, 0xE7CB, 0xDFB4, 0xCF92, 0xDFB2, 0xCF91, 0xDFB1,
0x8F14, 0xC78B, 0x9F34, 0x8F12, 0xBF74, 0x9F32, 0x8F11, 0xBF72, 0x9F31, 0xBF71,
0x870B, 0x8F1B, 0x9F3B, 0xBF7B, 0xEFCA, 0xEFC9, 0xCF8A, 0xDF9A, 0xCF89, 0xDF99,
0x8F0A, 0x9F1A, 0x8F09, 0xBF3A, 0x9F19, 0xBF39, 0xEFC5, 0xCF85, 0xDF8D, 0x8F05,
0x9F0D, 0xBF1D, 0x81AE, 0x81A7, 0x83AC, 0xC1D7, 0x83A6, 0x83A3, 0x8197, 0x83B7,
0x87A8, 0xC3D6, 0x87A4, 0xC3D3, 0x87A2, 0x87A1, 0x8396, 0x87B6, 0x8393, 0x87B3,
0xC7D4, 0xE3EB, 0xC7D2, 0xC7D1, 0x8794, 0xC3CB, 0x8FB4, 0xC7DB, 0x8FB2, 0x8791,
0x8FB1, 0x838B, 0x879B, 0x8FBB, 0xE7EA, 0xE7E9, 0xC7CA, 0xCFDA, 0xC7C9, 0xCFD9,
0x878A, 0x8F9A, 0x8789, 0x9FBA, 0x8F99, 0x9FB9, 0xE7E5, 0xC7C5, 0xCFCD, 0x8785,
0x8F8D, 0x9F9D, 0x81D6, 0x81D3, 0x83D4, 0xC1EB, 0x83D2, 0x83D1, 0x81CB, 0x83DB,
0xC3EA, 0xC3E9, 0x83CA, 0x87DA, 0x83C9, 0x87D9, 0xE3F5
};
/* MicroPDF417 coefficients from ISO/IEC 24728:2006 Annex F */
static const unsigned short int Microcoeffs[344] = {
/* k = 7 */
76, 925, 537, 597, 784, 691, 437,
/* k = 8 */
237, 308, 436, 284, 646, 653, 428, 379,
/* k = 9 */
567, 527, 622, 257, 289, 362, 501, 441, 205,
/* k = 10 */
377, 457, 64, 244, 826, 841, 818, 691, 266, 612,
/* k = 11 */
462, 45, 565, 708, 825, 213, 15, 68, 327, 602, 904,
/* k = 12 */
597, 864, 757, 201, 646, 684, 347, 127, 388, 7, 69, 851,
/* k = 13 */
764, 713, 342, 384, 606, 583, 322, 592, 678, 204, 184, 394, 692,
/* k = 14 */
669, 677, 154, 187, 241, 286, 274, 354, 478, 915, 691, 833, 105, 215,
/* k = 15 */
460, 829, 476, 109, 904, 664, 230, 5, 80, 74, 550, 575, 147, 868, 642,
/* k = 16 */
274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176, 65,
/* k = 18 */
279, 577, 315, 624, 37, 855, 275, 739, 120, 297, 312, 202, 560, 321, 233, 756,
760, 573,
/* k = 21 */
108, 519, 781, 534, 129, 425, 681, 553, 422, 716, 763, 693, 624, 610, 310, 691,
347, 165, 193, 259, 568,
/* k = 26 */
443, 284, 887, 544, 788, 93, 477, 760, 331, 608, 269, 121, 159, 830, 446, 893,
699, 245, 441, 454, 325, 858, 131, 847, 764, 169,
/* k = 32 */
361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, 517,
273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330, 63, 410,
/* k = 38 */
234, 228, 438, 848, 133, 703, 529, 721, 788, 322, 280, 159, 738, 586, 388, 684,
445, 680, 245, 595, 614, 233, 812, 32, 284, 658, 745, 229, 95, 689, 920, 771,
554, 289, 231, 125, 117, 518,
/* k = 44 */
476, 36, 659, 848, 678, 64, 764, 840, 157, 915, 470, 876, 109, 25, 632, 405,
417, 436, 714, 60, 376, 97, 413, 706, 446, 21, 3, 773, 569, 267, 272, 213,
31, 560, 231, 758, 103, 271, 572, 436, 339, 730, 82, 285,
/* k = 50 */
923, 797, 576, 875, 156, 706, 63, 81, 257, 874, 411, 416, 778, 50, 205, 303,
188, 535, 909, 155, 637, 230, 534, 96, 575, 102, 264, 233, 919, 593, 865, 26,
579, 623, 766, 146, 10, 739, 246, 127, 71, 244, 211, 477, 920, 876, 427, 820,
718, 435
};
/* rows, columns, error codewords, k-offset of valid MicroPDF417 sizes from ISO/IEC 24728:2006 */
static const unsigned short int MicroVariants[170] ={
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
11, 14, 17, 20, 24, 28, 8, 11, 14, 17, 20, 23, 26, 6, 8, 10, 12, 15, 20, 26, 32, 38, 44, 4, 6, 8, 10, 12, 15, 20, 26, 32, 38, 44,
7, 7, 7, 8, 8, 8, 8, 9, 9, 10, 11, 13, 15, 12, 14, 16, 18, 21, 26, 32, 38, 44, 50, 8, 12, 14, 16, 18, 21, 26, 32, 38, 44, 50,
0, 0, 0, 7, 7, 7, 7, 15, 15, 24, 34, 57, 84, 45, 70, 99, 115, 133, 154, 180, 212, 250, 294, 7, 45, 70, 99, 115, 133, 154, 180, 212, 250, 294
};
/* rows, columns, error codewords, k-offset */
/* following is Left RAP, Centre RAP, Right RAP and Start Cluster from ISO/IEC 24728:2006 tables 10, 11 and 12 */
static const char RAPTable[136] ={
1, 8, 36, 19, 9, 25, 1, 1, 8, 36, 19, 9, 27, 1, 7, 15, 25, 37, 1, 1, 21, 15, 1, 47, 1, 7, 15, 25, 37, 1, 1, 21, 15, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 25, 37, 17, 9, 29, 31, 25, 19, 1, 7, 15, 25, 37, 17, 9, 29, 31, 25,
9, 8, 36, 19, 17, 33, 1, 9, 8, 36, 19, 17, 35, 1, 7, 15, 25, 37, 33, 17, 37, 47, 49, 43, 1, 7, 15, 25, 37, 33, 17, 37, 47, 49,
0, 3, 6, 0, 6, 0, 0, 0, 3, 6, 0, 6, 6, 0, 0, 6, 0, 0, 0, 0, 6, 6, 0, 3, 0, 0, 6, 0, 0, 0, 0, 6, 6, 0
};
/* Left and Right Row Address Pattern from Table 2 */
static const unsigned short int rap_side[52] = {
0x322, 0x3A2, 0x3B2, 0x332, 0x372, 0x37A, 0x33A, 0x3BA, 0x39A, 0x3DA,
0x3CA, 0x38A, 0x30A, 0x31A, 0x312, 0x392, 0x3D2, 0x3D6, 0x3D4, 0x394,
0x3B4, 0x3A4, 0x3A6, 0x3AE, 0x3AC, 0x3A8, 0x328, 0x32C, 0x32E, 0x326,
0x336, 0x3B6, 0x396, 0x316, 0x314, 0x334, 0x374, 0x364, 0x366, 0x36E,
0x36C, 0x368, 0x348, 0x358, 0x35C, 0x35E, 0x34E, 0x34C, 0x344, 0x346,
0x342, 0x362
};
/* Centre Row Address Pattern from Table 2 */
static const unsigned short int rap_centre[52] = {
0x2CE, 0x24E, 0x26E, 0x22E, 0x226, 0x236, 0x216, 0x212, 0x21A, 0x23A,
0x232, 0x222, 0x262, 0x272, 0x27A, 0x2FA, 0x2F2, 0x2F6, 0x276, 0x274,
0x264, 0x266, 0x246, 0x242, 0x2C2, 0x2E2, 0x2E6, 0x2E4, 0x2EC, 0x26C,
0x22C, 0x228, 0x268, 0x2E8, 0x2C8, 0x2CC, 0x2C4, 0x2C6, 0x286, 0x28E,
0x28C, 0x29C, 0x298, 0x2B8, 0x2B0, 0x290, 0x2D0, 0x250, 0x258, 0x25C,
0x2DC, 0x2DE
};
void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block);

492
3rdparty/zint-2.6.1/backend/plessey.c vendored Normal file
View File

@ -0,0 +1,492 @@
/* plessey.c - Handles Plessey and MSI Plessey */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#define SSET "0123456789ABCDEF"
static const char *PlessTable[16] = {
"13131313", "31131313", "13311313", "31311313", "13133113", "31133113",
"13313113", "31313113", "13131331", "31131331", "13311331", "31311331", "13133131",
"31133131", "13313131", "31313131"
};
static const char *MSITable[10] = {
"12121212", "12121221", "12122112", "12122121", "12211212", "12211221",
"12212112", "12212121", "21121212", "21121221"
};
/* Not MSI/Plessey but the older Plessey standard */
int plessey(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
unsigned int i, check;
unsigned char *checkptr;
static const char grid[9] = {1, 1, 1, 1, 0, 1, 0, 0, 1};
char dest[1024]; /* 8 + 65 * 8 + 8 * 2 + 9 + 1 ~ 1024 */
int error_number;
if (length > 65) {
strcpy(symbol->errtxt, "370: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "371: Invalid characters in data");
return error_number;
}
checkptr = (unsigned char *) calloc(1, length * 4 + 8);
/* Start character */
strcpy(dest, "31311331");
/* Data area */
for (i = 0; i < length; i++) {
check = posn(SSET, source[i]);
lookup(SSET, PlessTable, source[i], dest);
checkptr[4 * i] = check & 1;
checkptr[4 * i + 1] = (check >> 1) & 1;
checkptr[4 * i + 2] = (check >> 2) & 1;
checkptr[4 * i + 3] = (check >> 3) & 1;
}
/* CRC check digit code adapted from code by Leonid A. Broukhis
used in GNU Barcode */
for (i = 0; i < (4 * length); i++) {
int j;
if (checkptr[i])
for (j = 0; j < 9; j++)
checkptr[i + j] ^= grid[j];
}
for (i = 0; i < 8; i++) {
switch (checkptr[length * 4 + i]) {
case 0: strcat(dest, "13");
break;
case 1: strcat(dest, "31");
break;
}
}
/* Stop character */
strcat(dest, "331311313");
expand(symbol, dest);
ustrcpy(symbol->text, source);
free(checkptr);
return error_number;
}
/* Plain MSI Plessey - does not calculate any check character */
int msi_plessey(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
size_t i;
char dest[512]; /* 2 + 55 * 8 + 3 + 1 ~ 512 */
if (length > 55) {
strcpy(symbol->errtxt, "372: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* start character */
strcpy(dest, "21");
for (i = 0; i < length; i++) {
lookup(NEON, MSITable, source[i], dest);
}
/* Stop character */
strcat(dest, "121");
expand(symbol, dest);
ustrcpy(symbol->text, source);
return 0;
}
/* MSI Plessey with Modulo 10 check digit - algorithm from Barcode Island
* http://www.barcodeisland.com/ */
int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int length) {
unsigned long i, wright, dau, pedwar, pump, n;
char un[200], tri[32];
int error_number, h;
char dest[1000];
error_number = 0;
if (length > 18) {
strcpy(symbol->errtxt, "373: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* start character */
strcpy(dest, "21");
/* draw data section */
for (i = 0; i < length; i++) {
lookup(NEON, MSITable, source[i], dest);
}
/* calculate check digit */
wright = 0;
n = !(length & 1);
for (i = n; i < length; i += 2) {
un[wright++] = source[i];
}
un[wright] = '\0';
dau = strtoul(un, NULL, 10);
dau *= 2;
sprintf(tri, "%ld", dau);
pedwar = 0;
h = strlen(tri);
for (i = 0; i < h; i++) {
pedwar += ctoi(tri[i]);
}
n = length & 1;
for (i = n; i < length; i += 2) {
pedwar += ctoi(source[i]);
}
pump = (10 - pedwar % 10);
if (pump == 10) {
pump = 0;
}
/* draw check digit */
lookup(NEON, MSITable, itoc(pump), dest);
/* Stop character */
strcat(dest, "121");
expand(symbol, dest);
ustrcpy(symbol->text, source);
symbol->text[length] = itoc(pump);
symbol->text[length + 1] = '\0';
return error_number;
}
/* MSI Plessey with two Modulo 10 check digits - algorithm from
* Barcode Island http://www.barcodeisland.com/ */
int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len) {
unsigned long i, n, wright, dau, pedwar, pump, chwech;
char un[16], tri[32];
int error_number, h;
char dest[1000];
error_number = 0;
if (src_len > 18) {
/* No Entry Stack Smashers! limit because of str->number conversion*/
strcpy(symbol->errtxt, "374: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* start character */
strcpy(dest, "21");
/* draw data section */
for (i = 0; i < src_len; i++) {
lookup(NEON, MSITable, source[i], dest);
}
/* calculate first check digit */
wright = 0;
n = !(src_len & 1);
for (i = n; i < src_len; i += 2) {
un[wright++] = source[i];
}
un[wright] = '\0';
dau = strtoul(un, NULL, 10);
dau *= 2;
sprintf(tri, "%ld", dau);
pedwar = 0;
h = strlen(tri);
for (i = 0; i < h; i++) {
pedwar += ctoi(tri[i]);
}
n = src_len & 1;
for (i = n; i < src_len; i += 2) {
pedwar += ctoi(source[i]);
}
pump = 10 - pedwar % 10;
if (pump == 10) {
pump = 0;
}
/* calculate second check digit */
wright = 0;
n = src_len & 1;
for (i = n; i < src_len; i += 2) {
un[wright++] = source[i];
}
un[wright++] = itoc(pump);
un[wright] = '\0';
dau = strtoul(un, NULL, 10);
dau *= 2;
sprintf(tri, "%ld", dau);
pedwar = 0;
h = strlen(tri);
for (i = 0; i < h; i++) {
pedwar += ctoi(tri[i]);
}
i = !(src_len & 1);
for (; i < src_len; i += 2) {
pedwar += ctoi(source[i]);
}
chwech = 10 - pedwar % 10;
if (chwech == 10) {
chwech = 0;
}
/* Draw check digits */
lookup(NEON, MSITable, itoc(pump), dest);
lookup(NEON, MSITable, itoc(chwech), dest);
/* Stop character */
strcat(dest, "121");
expand(symbol, dest);
ustrcpy(symbol->text, source);
symbol->text[src_len] = itoc(pump);
symbol->text[src_len + 1] = itoc(chwech);
symbol->text[src_len + 2] = '\0';
return error_number;
}
/* Calculate a Modulo 11 check digit using the system discussed on Wikipedia -
see http://en.wikipedia.org/wiki/Talk:MSI_Barcode */
int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len) {
/* uses the IBM weight system */
int i, weight, x, check;
int error_number;
char dest[1000];
error_number = 0;
if (src_len > 55) {
strcpy(symbol->errtxt, "375: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* start character */
strcpy(dest, "21");
/* draw data section */
for (i = 0; i < src_len; i++) {
lookup(NEON, MSITable, source[i], dest);
}
/* calculate check digit */
x = 0;
weight = 2;
for (i = src_len - 1; i >= 0; i--) {
x += weight * ctoi(source[i]);
weight++;
if (weight > 7) {
weight = 2;
}
}
check = (11 - (x % 11)) % 11;
if (check == 10) {
lookup(NEON, MSITable, '1', dest);
lookup(NEON, MSITable, '0', dest);
} else {
lookup(NEON, MSITable, itoc(check), dest);
}
/* stop character */
strcat(dest, "121");
expand(symbol, dest);
ustrcpy(symbol->text, source);
if (check == 10) {
strcat((char*) symbol->text, "10");
} else {
symbol->text[src_len] = itoc(check);
symbol->text[src_len + 1] = '\0';
}
return error_number;
}
/* Combining the Barcode Island and Wikipedia code
* Verified against http://www.bokai.com/BarcodeJSP/applet/BarcodeSampleApplet.htm */
int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len) {
/* Weighted using the IBM system */
unsigned long i, weight, x, check, wright, dau, pedwar, pump;
size_t h;
long si;
char un[16], tri[16];
int error_number;
char dest[1000];
unsigned char temp[32];
unsigned int temp_len;
error_number = 0;
if (src_len > 18) {
strcpy(symbol->errtxt, "376: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* start character */
strcpy(dest, "21");
/* draw data section */
for (i = 0; i < src_len; i++) {
lookup(NEON, MSITable, source[i], dest);
}
/* calculate first (mod 11) digit */
x = 0;
weight = 2;
for (si = src_len - 1; si >= 0; si--) {
x += weight * ctoi(source[si]);
weight++;
if (weight > 7) {
weight = 2;
}
}
check = (11 - (x % 11)) % 11;
ustrcpy(temp, source);
temp_len = src_len;
if (check == 10) {
lookup(NEON, MSITable, '1', dest);
lookup(NEON, MSITable, '0', dest);
strcat((char*) temp, "10");
temp_len += 2;
} else {
lookup(NEON, MSITable, itoc(check), dest);
temp[temp_len++] = itoc(check);
temp[temp_len] = '\0';
}
/* calculate second (mod 10) check digit */
wright = 0;
i = !(temp_len & 1);
for (; i < temp_len; i += 2) {
un[wright++] = temp[i];
}
un[wright] = '\0';
dau = strtoul(un, NULL, 10);
dau *= 2;
sprintf(tri, "%ld", dau);
pedwar = 0;
h = strlen(tri);
for (i = 0; i < h; i++) {
pedwar += ctoi(tri[i]);
}
i = temp_len & 1;
for (; i < temp_len; i += 2) {
pedwar += ctoi(temp[i]);
}
pump = 10 - pedwar % 10;
if (pump == 10) {
pump = 0;
}
/* draw check digit */
lookup(NEON, MSITable, itoc(pump), dest);
/* stop character */
strcat(dest, "121");
expand(symbol, dest);
temp[temp_len++] = itoc(pump);
temp[temp_len] = '\0';
ustrcpy(symbol->text, temp);
return error_number;
}
int msi_handle(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number;
error_number = is_sane(NEON, source, length);
if (error_number != 0) {
strcpy(symbol->errtxt, "377: Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
if ((symbol->option_2 < 0) || (symbol->option_2 > 4)) {
symbol->option_2 = 0;
}
switch (symbol->option_2) {
case 0: error_number = msi_plessey(symbol, source, length);
break;
case 1: error_number = msi_plessey_mod10(symbol, source, length);
break;
case 2: error_number = msi_plessey_mod1010(symbol, source, length);
break;
case 3: error_number = msi_plessey_mod11(symbol, source, length);
break;
case 4: error_number = msi_plessey_mod1110(symbol, source, length);
break;
}
return error_number;
}

191
3rdparty/zint-2.6.1/backend/png.c vendored Normal file
View File

@ -0,0 +1,191 @@
/* png.c - Handles output to PNG file */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdio.h>
#ifdef _MSC_VER
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "common.h"
#ifndef NO_PNG
#include <png.h>
#include <zlib.h>
#include <setjmp.h>
#define SSET "0123456789ABCDEF"
struct mainprog_info_type {
long width;
long height;
FILE *outfile;
jmp_buf jmpbuf;
};
static void writepng_error_handler(png_structp png_ptr, png_const_charp msg) {
struct mainprog_info_type *graphic;
fprintf(stderr, "writepng libpng error: %s (F30)\n", msg);
fflush(stderr);
graphic = (struct mainprog_info_type*) png_get_error_ptr(png_ptr);
if (graphic == NULL) {
/* we are completely hosed now */
fprintf(stderr,
"writepng severe error: jmpbuf not recoverable; terminating. (F31)\n");
fflush(stderr);
return;
}
longjmp(graphic->jmpbuf, 1);
}
int png_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
struct mainprog_info_type wpng_info;
struct mainprog_info_type *graphic;
png_structp png_ptr;
png_infop info_ptr;
unsigned char *image_data;
int i, row, column;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
#ifndef _MSC_VER
unsigned char outdata[symbol->bitmap_width * 3];
#else
unsigned char* outdata = (unsigned char*) _alloca(symbol->bitmap_width * 3);
#endif
graphic = &wpng_info;
graphic->width = symbol->bitmap_width;
graphic->height = symbol->bitmap_height;
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
/* Open output file in binary mode */
if (symbol->output_options & BARCODE_STDOUT) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "631: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
#endif
graphic->outfile = stdout;
} else {
if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "632: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
}
/* Set up error handling routine as proc() above */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic, writepng_error_handler, NULL);
if (!png_ptr) {
strcpy(symbol->errtxt, "633: Out of memory");
return ZINT_ERROR_MEMORY;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_write_struct(&png_ptr, NULL);
strcpy(symbol->errtxt, "634: Out of memory");
return ZINT_ERROR_MEMORY;
}
/* catch jumping here */
if (setjmp(graphic->jmpbuf)) {
png_destroy_write_struct(&png_ptr, &info_ptr);
strcpy(symbol->errtxt, "635: libpng error occurred");
return ZINT_ERROR_MEMORY;
}
/* open output file with libpng */
png_init_io(png_ptr, graphic->outfile);
/* set compression */
png_set_compression_level(png_ptr, 9);
/* set Header block */
png_set_IHDR(png_ptr, info_ptr, graphic->width, graphic->height,
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
/* write all chunks up to (but not including) first IDAT */
png_write_info(png_ptr, info_ptr);
/* set up the transformations: for now, just pack low-bit-depth pixels
into bytes (one, two or four pixels per byte) */
png_set_packing(png_ptr);
/* Pixel Plotting */
for (row = 0; row < symbol->bitmap_height; row++) {
for (column = 0; column < symbol->bitmap_width; column++) {
i = column * 3;
switch (*(pixelbuf + (symbol->bitmap_width * row) + column)) {
case '1':
outdata[i] = fgred;
outdata[i + 1] = fggrn;
outdata[i + 2] = fgblu;
break;
default:
outdata[i] = bgred;
outdata[i + 1] = bggrn;
outdata[i + 2] = bgblu;
break;
}
}
/* write row contents to file */
image_data = outdata;
png_write_row(png_ptr, image_data);
}
/* End the file */
png_write_end(png_ptr, NULL);
/* make sure we have disengaged */
if (png_ptr && info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
if (symbol->output_options & BARCODE_STDOUT) {
fflush(wpng_info.outfile);
} else {
fclose(wpng_info.outfile);
}
return 0;
}
#endif /* NO_PNG */

621
3rdparty/zint-2.6.1/backend/postal.c vendored Normal file
View File

@ -0,0 +1,621 @@
/* postal.c - Handles PostNet, PLANET, FIM. RM4SCC and Flattermarken */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Including bug fixes by Bryan Hatton
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#define DAFTSET "DAFT"
#define KRSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define KASUTSET "1234567890-abcdefgh"
#define CHKASUTSET "0123456789-abcdefgh"
#define SHKASUTSET "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ"
/* PostNet number encoding table - In this table L is long as S is short */
static const char *PNTable[10] = {
"LLSSS", "SSSLL", "SSLSL", "SSLLS", "SLSSL", "SLSLS", "SLLSS", "LSSSL",
"LSSLS", "LSLSS"
};
static const char *PLTable[10] = {
"SSLLL", "LLLSS", "LLSLS", "LLSSL", "LSLLS", "LSLSL", "LSSLL", "SLLLS",
"SLLSL", "SLSLL"
};
static const char *RoyalValues[36] = {
"11", "12", "13", "14", "15", "10", "21", "22", "23", "24", "25",
"20", "31", "32", "33", "34", "35", "30", "41", "42", "43", "44", "45", "40", "51", "52",
"53", "54", "55", "50", "01", "02", "03", "04", "05", "00"
};
/* 0 = Full, 1 = Ascender, 2 = Descender, 3 = Tracker */
static const char *RoyalTable[36] = {
"3300", "3210", "3201", "2310", "2301", "2211", "3120", "3030", "3021",
"2130", "2121", "2031", "3102", "3012", "3003", "2112", "2103", "2013", "1320", "1230",
"1221", "0330", "0321", "0231", "1302", "1212", "1203", "0312", "0303", "0213", "1122",
"1032", "1023", "0132", "0123", "0033"
};
static const char *FlatTable[10] = {
"0504", "18", "0117", "0216", "0315", "0414", "0513", "0612", "0711", "0810"
};
static const char *KoreaTable[10] = {
"1313150613", "0713131313", "0417131313", "1506131313",
"0413171313", "17171313", "1315061313", "0413131713", "17131713", "13171713"
};
static const char *JapanTable[19] = {
"114", "132", "312", "123", "141", "321", "213", "231", "411", "144",
"414", "324", "342", "234", "432", "243", "423", "441", "111"
};
/* Handles the PostNet system used for Zip codes in the US */
int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
unsigned int i, sum, check_digit;
int error_number;
error_number = 0;
if (length > 38) {
strcpy(symbol->errtxt, "480: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "481: Invalid characters in data");
return error_number;
}
sum = 0;
/* start character */
strcpy(dest, "L");
for (i = 0; i < length; i++) {
lookup(NEON, PNTable, source[i], dest);
sum += ctoi(source[i]);
}
check_digit = (10 - (sum % 10)) % 10;
strcat(dest, PNTable[check_digit]);
/* stop character */
strcat(dest, "L");
return error_number;
}
/* Puts PostNet barcodes into the pattern matrix */
int post_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 + 1 ~ 256 */
unsigned int loopey, h;
int writer;
int error_number;
error_number = 0;
error_number = postnet(symbol, source, height_pattern, length);
if (error_number != 0) {
return error_number;
}
writer = 0;
h = strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if (height_pattern[loopey] == 'L') {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
writer += 3;
}
symbol->row_height[0] = 6;
symbol->row_height[1] = 6;
symbol->rows = 2;
symbol->width = writer - 1;
return error_number;
}
/* Handles the PLANET system used for item tracking in the US */
int planet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
unsigned int i, sum, check_digit;
int error_number;
error_number = 0;
if (length > 38) {
strcpy(symbol->errtxt, "482: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "483: Invalid characters in data");
return error_number;
}
sum = 0;
/* start character */
strcpy(dest, "L");
for (i = 0; i < length; i++) {
lookup(NEON, PLTable, source[i], dest);
sum += ctoi(source[i]);
}
check_digit = (10 - (sum % 10)) % 10;
strcat(dest, PLTable[check_digit]);
/* stop character */
strcat(dest, "L");
return error_number;
}
/* Puts PLANET barcodes into the pattern matrix */
int planet_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 + 1 ~ 256 */
unsigned int loopey, h;
int writer;
int error_number;
error_number = 0;
error_number = planet(symbol, source, height_pattern, length);
if (error_number != 0) {
return error_number;
}
writer = 0;
h = strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if (height_pattern[loopey] == 'L') {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
writer += 3;
}
symbol->row_height[0] = 6;
symbol->row_height[1] = 6;
symbol->rows = 2;
symbol->width = writer - 1;
return error_number;
}
/* Korean Postal Authority */
int korea_post(struct zint_symbol *symbol, unsigned char source[], int length) {
int total, loop, check, zeroes, error_number;
char localstr[8], dest[80];
error_number = 0;
if (length > 6) {
strcpy(symbol->errtxt, "484: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "485: Invalid characters in data");
return error_number;
}
zeroes = 6 - length;
memset(localstr, '0', zeroes);
strcpy(localstr + zeroes, (char *) source);
total = 0;
for (loop = 0; loop < 6; loop++) {
total += ctoi(localstr[loop]);
}
check = 10 - (total % 10);
if (check == 10) {
check = 0;
}
localstr[6] = itoc(check);
localstr[7] = '\0';
*dest = '\0';
for (loop = 5; loop >= 0; loop--) {
lookup(NEON, KoreaTable, localstr[loop], dest);
}
lookup(NEON, KoreaTable, localstr[6], dest);
expand(symbol, dest);
ustrcpy(symbol->text, (unsigned char*) localstr);
return error_number;
}
/* The simplest barcode symbology ever! Supported by MS Word, so here it is!
glyphs from http://en.wikipedia.org/wiki/Facing_Identification_Mark */
int fim(struct zint_symbol *symbol, unsigned char source[], int length) {
char dest[16] = {0};
if (length > 1) {
strcpy(symbol->errtxt, "486: Input too long");
return ZINT_ERROR_TOO_LONG;
}
switch ((char) source[0]) {
case 'a':
case 'A':
strcpy(dest, "111515111");
break;
case 'b':
case 'B':
strcpy(dest, "13111311131");
break;
case 'c':
case 'C':
strcpy(dest, "11131313111");
break;
case 'd':
case 'D':
strcpy(dest, "1111131311111");
break;
default:
strcpy(symbol->errtxt, "487: Invalid characters in data");
return ZINT_ERROR_INVALID_DATA;
break;
}
expand(symbol, dest);
return 0;
}
/* Handles the 4 State barcodes used in the UK by Royal Mail */
char rm4scc(char source[], unsigned char dest[], int length) {
unsigned int i;
int top, bottom, row, column, check_digit;
char values[3], set_copy[] = KRSET;
top = 0;
bottom = 0;
/* start character */
strcpy((char*) dest, "1");
for (i = 0; i < length; i++) {
lookup(KRSET, RoyalTable, source[i], (char*) dest);
strcpy(values, RoyalValues[posn(KRSET, source[i])]);
top += ctoi(values[0]);
bottom += ctoi(values[1]);
}
/* Calculate the check digit */
row = (top % 6) - 1;
column = (bottom % 6) - 1;
if (row == -1) {
row = 5;
}
if (column == -1) {
column = 5;
}
check_digit = (6 * row) + column;
strcat((char*) dest, RoyalTable[check_digit]);
/* stop character */
strcat((char*) dest, "0");
return set_copy[check_digit];
}
/* Puts RM4SCC into the data matrix */
int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[210];
unsigned int loopey, h;
int writer;
int error_number;
strcpy(height_pattern, "");
error_number = 0;
if (length > 50) {
strcpy(symbol->errtxt, "488: Input too long");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "489: Invalid characters in data");
return error_number;
}
/*check = */rm4scc((char*) source, (unsigned char*) height_pattern, length);
writer = 0;
h = strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
symbol->row_height[0] = 3;
symbol->row_height[1] = 2;
symbol->row_height[2] = 3;
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}
/* Handles Dutch Post TNT KIX symbols
The same as RM4SCC but without check digit
Specification at http://www.tntpost.nl/zakelijk/klantenservice/downloads/kIX_code/download.aspx */
int kix_code(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[75], localstr[20];
unsigned int loopey;
int writer, i, h;
int error_number; /* zeroes; */
strcpy(height_pattern, "");
error_number = 0;
if (length > 18) {
strcpy(symbol->errtxt, "490: Input too long");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "491: Invalid characters in data");
return error_number;
}
strcpy(localstr, (char *) source);
/* Encode data */
for (i = 0; i < length; i++) {
lookup(KRSET, RoyalTable, localstr[i], height_pattern);
}
writer = 0;
h = strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
symbol->row_height[0] = 3;
symbol->row_height[1] = 2;
symbol->row_height[2] = 3;
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}
/* Handles DAFT Code symbols */
int daft_code(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[100];
unsigned int loopey, h;
int writer, i, error_number;
strcpy(height_pattern, "");
error_number = 0;
if (length > 50) {
strcpy(symbol->errtxt, "492: Input too long");
return ZINT_ERROR_TOO_LONG;
}
to_upper((unsigned char*) source);
error_number = is_sane(DAFTSET, (unsigned char*) source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "493: Invalid characters in data");
return error_number;
}
for (i = 0; i < length; i++) {
if (source[i] == 'D') {
strcat(height_pattern, "2");
}
if (source[i] == 'A') {
strcat(height_pattern, "1");
}
if (source[i] == 'F') {
strcat(height_pattern, "0");
}
if (source[i] == 'T') {
strcat(height_pattern, "3");
}
}
writer = 0;
h = strlen(height_pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
symbol->row_height[0] = 3;
symbol->row_height[1] = 2;
symbol->row_height[2] = 3;
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}
/* Flattermarken - Not really a barcode symbology! */
int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length) {
int loop, error_number;
char dest[512]; /* 90 * 4 + 1 ~ */
error_number = 0;
if (length > 90) {
strcpy(symbol->errtxt, "494: Input too long");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "495: Invalid characters in data");
return error_number;
}
*dest = '\0';
for (loop = 0; loop < length; loop++) {
lookup(NEON, FlatTable, source[loop], dest);
}
expand(symbol, dest);
return error_number;
}
/* Japanese Postal Code (Kasutama Barcode) */
int japan_post(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number, h;
char pattern[69];
int writer, loopey, inter_posn, i, sum, check;
char check_char;
char inter[23];
#ifndef _MSC_VER
char local_source[length + 1];
#else
char* local_source = (char*) _alloca(length + 1);
#endif
if (length > 20) {
strcpy(symbol->errtxt, "496: Input too long");
return ZINT_ERROR_TOO_LONG;
}
inter_posn = 0;
error_number = 0;
strcpy(local_source, (char*) source);
for (i = 0; i < length; i++) {
local_source[i] = source[i];
}
to_upper((unsigned char*) local_source);
error_number = is_sane(SHKASUTSET, (unsigned char*) local_source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "497: Invalid characters in data");
return error_number;
}
memset(inter, 'd', 20); /* Pad character CC4 */
inter[20] = '\0';
i = 0;
inter_posn = 0;
do {
if (((local_source[i] >= '0') && (local_source[i] <= '9')) || (local_source[i] == '-')) {
inter[inter_posn] = local_source[i];
inter_posn++;
} else {
if ((local_source[i] >= 'A') && (local_source[i] <= 'J')) {
inter[inter_posn] = 'a';
inter[inter_posn + 1] = local_source[i] - 'A' + '0';
inter_posn += 2;
}
if ((local_source[i] >= 'K') && (local_source[i] <= 'T')) {
inter[inter_posn] = 'b';
inter[inter_posn + 1] = local_source[i] - 'K' + '0';
inter_posn += 2;
}
if ((local_source[i] >= 'U') && (local_source[i] <= 'Z')) {
inter[inter_posn] = 'c';
inter[inter_posn + 1] = local_source[i] - 'U' + '0';
inter_posn += 2;
}
}
i++;
} while ((i < length) && (inter_posn < 20));
inter[20] = '\0';
strcpy(pattern, "13"); /* Start */
sum = 0;
for (i = 0; i < 20; i++) {
strcat(pattern, JapanTable[posn(KASUTSET, inter[i])]);
sum += posn(CHKASUTSET, inter[i]);
}
/* Calculate check digit */
check = 19 - (sum % 19);
if (check == 19) {
check = 0;
}
if (check <= 9) {
check_char = check + '0';
}
if (check == 10) {
check_char = '-';
}
if (check >= 11) {
check_char = (check - 11) + 'a';
}
strcat(pattern, JapanTable[posn(KASUTSET, check_char)]);
strcat(pattern, "31"); /* Stop */
/* Resolve pattern to 4-state symbols */
writer = 0;
h = strlen(pattern);
for (loopey = 0; loopey < h; loopey++) {
if ((pattern[loopey] == '2') || (pattern[loopey] == '1')) {
set_module(symbol, 0, writer);
}
set_module(symbol, 1, writer);
if ((pattern[loopey] == '3') || (pattern[loopey] == '1')) {
set_module(symbol, 2, writer);
}
writer += 2;
}
symbol->row_height[0] = 3;
symbol->row_height[1] = 2;
symbol->row_height[2] = 3;
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
}

974
3rdparty/zint-2.6.1/backend/ps.c vendored Normal file
View File

@ -0,0 +1,974 @@
/* ps.c - Post Script output */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <locale.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "common.h"
#define SSET "0123456789ABCDEF"
int ps_plot(struct zint_symbol *symbol) {
int i, block_width, latch, r, this_row;
float textpos, large_bar_height, preset_height, row_height, row_posn;
FILE *feps;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
float red_ink, green_ink, blue_ink, red_paper, green_paper, blue_paper;
float cyan_ink, magenta_ink, yellow_ink, black_ink;
float cyan_paper, magenta_paper, yellow_paper, black_paper;
int error_number = 0;
int textoffset, xoffset, yoffset, textdone, main_width;
char textpart[10], addon[6];
int large_bar_count, comp_offset;
float addon_text_posn;
float scaler = symbol->scale;
float default_text_posn;
const char *locale = NULL;
#ifndef _MSC_VER
unsigned char local_text[ustrlen(symbol->text) + 1];
#else
unsigned char* local_text = (unsigned char*) malloc(ustrlen(symbol->text) + 1);
#endif
row_height = 0;
textdone = 0;
main_width = symbol->width;
strcpy(addon, "");
comp_offset = 0;
addon_text_posn = 0.0;
if (symbol->show_hrt != 0) {
/* Copy text from symbol */
ustrcpy(local_text, symbol->text);
} else {
/* No text needed */
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CC:
case BARCODE_ISBNX:
case BARCODE_UPCA:
case BARCODE_UPCE:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
/* For these symbols use dummy text to ensure formatting is done
* properly even if no text is required */
for (i = 0; i < ustrlen(symbol->text); i++) {
if (symbol->text[i] == '+') {
local_text[i] = '+';
} else {
local_text[i] = ' ';
}
local_text[ustrlen(symbol->text)] = '\0';
}
break;
default:
/* For everything else, just remove the text */
local_text[0] = '\0';
break;
}
}
if (symbol->output_options & BARCODE_STDOUT) {
feps = stdout;
} else {
feps = fopen(symbol->outfile, "w");
}
if (feps == NULL) {
strcpy(symbol->errtxt, "645: Could not open output file");
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_FILE_ACCESS;
}
/* sort out colour options */
to_upper((unsigned char*) symbol->fgcolour);
to_upper((unsigned char*) symbol->bgcolour);
if (strlen(symbol->fgcolour) != 6) {
strcpy(symbol->errtxt, "646: Malformed foreground colour target");
fclose(feps);
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_INVALID_OPTION;
}
if (strlen(symbol->bgcolour) != 6) {
strcpy(symbol->errtxt, "647: Malformed background colour target");
fclose(feps);
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_INVALID_OPTION;
}
error_number = is_sane(SSET, (unsigned char*) symbol->fgcolour, strlen(symbol->fgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "648: Malformed foreground colour target");
fclose(feps);
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_INVALID_OPTION;
}
error_number = is_sane(SSET, (unsigned char*) symbol->bgcolour, strlen(symbol->bgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "649: Malformed background colour target");
fclose(feps);
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_INVALID_OPTION;
}
locale = setlocale(LC_ALL, "C");
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
red_ink = fgred / 256.0;
green_ink = fggrn / 256.0;
blue_ink = fgblu / 256.0;
red_paper = bgred / 256.0;
green_paper = bggrn / 256.0;
blue_paper = bgblu / 256.0;
/* Convert RGB to CMYK */
if (red_ink > green_ink) {
if (blue_ink > red_ink) {
black_ink = 1 - blue_ink;
} else {
black_ink = 1 - red_ink;
}
} else {
if (blue_ink > red_ink) {
black_ink = 1 - blue_ink;
} else {
black_ink = 1 - green_ink;
}
}
if (black_ink < 1.0) {
cyan_ink = (1 - red_ink - black_ink) / (1 - black_ink);
magenta_ink = (1 - green_ink - black_ink) / (1 - black_ink);
yellow_ink = (1 - blue_ink - black_ink) / (1 - black_ink);
} else {
cyan_ink = 0.0;
magenta_ink = 0.0;
yellow_ink = 0.0;
}
if (red_paper > green_paper) {
if (blue_paper > red_paper) {
black_paper = 1 - blue_paper;
} else {
black_paper = 1 - red_paper;
}
} else {
if (blue_paper > red_paper) {
black_paper = 1 - blue_paper;
} else {
black_paper = 1 - green_paper;
}
}
if (black_paper < 1.0) {
cyan_paper = (1 - red_paper - black_paper) / (1 - black_paper);
magenta_paper = (1 - green_paper - black_paper) / (1 - black_paper);
yellow_paper = (1 - blue_paper - black_paper) / (1 - black_paper);
} else {
cyan_paper = 0.0;
magenta_paper = 0.0;
yellow_paper = 0.0;
}
if (symbol->height == 0) {
symbol->height = 50;
}
large_bar_count = 0;
preset_height = 0.0;
for (i = 0; i < symbol->rows; i++) {
preset_height += symbol->row_height[i];
if (symbol->row_height[i] == 0) {
large_bar_count++;
}
}
large_bar_height = (symbol->height - preset_height) / large_bar_count;
if (large_bar_count == 0) {
symbol->height = preset_height;
}
while (!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
comp_offset++;
}
/* Certain symbols need whitespace otherwise characters get chopped off the sides */
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC))
|| (symbol->symbology == BARCODE_ISBNX)) {
switch (ustrlen(local_text)) {
case 13: /* EAN 13 */
case 16:
case 19:
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
}
main_width = 96 + comp_offset;
break;
default:
main_width = 68 + comp_offset;
}
}
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
main_width = 96 + comp_offset;
}
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
main_width = 51 + comp_offset;
}
}
latch = 0;
r = 0;
/* Isolate add-on text */
if (is_extendable(symbol->symbology)) {
for (i = 0; i < ustrlen(local_text); i++) {
if (latch == 1) {
addon[r] = local_text[i];
r++;
}
if (local_text[i] == '+') {
latch = 1;
}
}
}
addon[r] = '\0';
if (ustrlen(local_text) != 0) {
textoffset = 9;
} else {
textoffset = 0;
}
xoffset = symbol->border_width + symbol->whitespace_width;
yoffset = symbol->border_width;
/* Start writing the header */
fprintf(feps, "%%!PS-Adobe-3.0 EPSF-3.0\n");
fprintf(feps, "%%%%Creator: Zint %d.%d.%d\n", ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE);
if ((ustrlen(local_text) != 0) && (symbol->show_hrt != 0)) {
fprintf(feps, "%%%%Title: %s\n", local_text);
} else {
fprintf(feps, "%%%%Title: Zint Generated Symbol\n");
}
fprintf(feps, "%%%%Pages: 0\n");
if (symbol->symbology != BARCODE_MAXICODE) {
fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", (int) ceil((symbol->width + xoffset + xoffset) * scaler), (int) ceil((symbol->height + textoffset + yoffset + yoffset) * scaler));
} else {
fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", (int) ceil((74.0F + xoffset + xoffset) * scaler), (int) ceil((72.0F + yoffset + yoffset) * scaler));
}
fprintf(feps, "%%%%EndComments\n");
/* Definitions */
fprintf(feps, "/TL { setlinewidth moveto lineto stroke } bind def\n");
fprintf(feps, "/TC { moveto 0 360 arc 360 0 arcn fill } bind def\n");
fprintf(feps, "/TD { newpath 0 360 arc fill } bind def\n");
fprintf(feps, "/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def\n");
fprintf(feps, "/TB { 2 copy } bind def\n");
fprintf(feps, "/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def\n");
fprintf(feps, "/TE { pop pop } bind def\n");
fprintf(feps, "newpath\n");
/* Now the actual representation */
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_paper, magenta_paper, yellow_paper, black_paper);
}
fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", (symbol->height + textoffset + yoffset + yoffset) * scaler, (symbol->width + xoffset + xoffset) * scaler);
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
default_text_posn = 0.5 * scaler;
} else {
default_text_posn = (symbol->border_width + 0.5) * scaler;
}
if (symbol->symbology == BARCODE_MAXICODE) {
/* Maxicode uses hexagons */
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy, mx, my;
textoffset = 0.0;
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, textoffset * scaler, 0.0, (74.0 + xoffset + xoffset) * scaler);
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, (textoffset + 72.0 + symbol->border_width) * scaler, 0.0, (74.0 + xoffset + xoffset) * scaler);
}
if ((symbol->output_options & BARCODE_BOX) != 0) {
/* side bars */
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", (72.0 + (2 * symbol->border_width)) * scaler, textoffset * scaler, 0.0, symbol->border_width * scaler);
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", (72.0 + (2 * symbol->border_width)) * scaler, textoffset * scaler, (74.0 + xoffset + xoffset - symbol->border_width) * scaler, symbol->border_width * scaler);
}
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TC\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 10.85 * scaler, (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 8.97 * scaler, (44.73 + xoffset) * scaler, (35.60 + yoffset) * scaler);
fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TC\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 7.10 * scaler, (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 5.22 * scaler, (40.98 + xoffset) * scaler, (35.60 + yoffset) * scaler);
fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TC\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 3.31 * scaler, (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 1.43 * scaler, (37.19 + xoffset) * scaler, (35.60 + yoffset) * scaler);
for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
/* Dump a hexagon */
my = ((symbol->rows - r - 1)) * 2.135 + 1.43;
ay = my + 1.0 + yoffset;
by = my + 0.5 + yoffset;
cy = my - 0.5 + yoffset;
dy = my - 1.0 + yoffset;
ey = my - 0.5 + yoffset;
fy = my + 0.5 + yoffset;
mx = 2.46 * i + 1.23 + (r & 1 ? 1.23 : 0);
ax = mx + xoffset;
bx = mx + 0.86 + xoffset;
cx = mx + 0.86 + xoffset;
dx = mx + xoffset;
ex = mx - 0.86 + xoffset;
fx = mx - 0.86 + xoffset;
fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TH\n", ax * scaler, ay * scaler, bx * scaler, by * scaler, cx * scaler, cy * scaler, dx * scaler, dy * scaler, ex * scaler, ey * scaler, fx * scaler, fy * scaler);
}
}
}
}
if (symbol->symbology != BARCODE_MAXICODE) {
/* everything else uses rectangles (or squares) */
/* Works from the bottom of the symbol up */
int addon_latch = 0;
for (r = 0; r < symbol->rows; r++) {
this_row = symbol->rows - r - 1; /* invert r otherwise plots upside down */
if (symbol->row_height[this_row] == 0) {
row_height = large_bar_height;
} else {
row_height = symbol->row_height[this_row];
}
row_posn = 0;
for (i = 0; i < r; i++) {
if (symbol->row_height[symbol->rows - i - 1] == 0) {
row_posn += large_bar_height;
} else {
row_posn += symbol->row_height[symbol->rows - i - 1];
}
}
row_posn += (textoffset + yoffset);
if ((symbol->output_options & BARCODE_DOTTY_MODE) != 0) {
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
/* Use dots instead of squares */
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, this_row, i)) {
fprintf(feps, "%.2f %.2f %.2f TD\n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (symbol->dot_size / 2.0) * scaler);
}
}
} else {
/* Normal mode, with rectangles */
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f ", row_height * scaler, row_posn * scaler);
i = 0;
if (module_is_set(symbol, this_row, 0)) {
latch = 1;
} else {
latch = 0;
}
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
if ((addon_latch == 0) && (r == 0) && (i > main_width)) {
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f ", (row_height - 5.0) * scaler, (row_posn - 5.0) * scaler);
addon_text_posn = row_posn + row_height - 8.0;
addon_latch = 1;
}
if (latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset) * scaler, block_width * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < symbol->width);
}
}
}
/* That's done the actual data area, everything else is human-friendly */
xoffset += comp_offset;
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) ||
(symbol->symbology == BARCODE_ISBNX)) {
/* guard bar extensions and text formatting for EAN8 and EAN13 */
switch (ustrlen(local_text)) {
case 8: /* EAN-8 */
case 11:
case 14:
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (32 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (34 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (64 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (66 + xoffset) * scaler, 1 * scaler);
for (i = 0; i < 4; i++) {
textpart[i] = local_text[i];
}
textpart[4] = '\0';
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 17;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 4; i++) {
textpart[i] = local_text[i + 4];
}
textpart[4] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 50;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 86;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 100;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
break;
case 13: /* EAN 13 */
case 16:
case 19:
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (92 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (94 + xoffset) * scaler, 1 * scaler);
textpart[0] = local_text[0];
textpart[1] = '\0';
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = -7;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 1];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 7];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 71;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 114;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 128;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
break;
}
}
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
/* guard bar extensions and text formatting for UPCA */
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
latch = 1;
i = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 11 + comp_offset);
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
latch = 1;
i = 85 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 96 + comp_offset);
textpart[0] = local_text[0];
textpart[1] = '\0';
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 5; i++) {
textpart[i] = local_text[i + 1];
}
textpart[5] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 27;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 5; i++) {
textpart[i] = local_text[i + 6];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 68;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textpart[0] = local_text[11];
textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 100;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 116;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 130;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
/* guard bar extensions and text formatting for UPCE */
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (50 + xoffset) * scaler, 1 * scaler);
textpart[0] = local_text[0];
textpart[1] = '\0';
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 1];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textpart[0] = local_text[7];
textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 55;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 70;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 84;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
}
xoffset -= comp_offset;
switch (symbol->symbology) {
case BARCODE_MAXICODE:
/* Do nothing! (It's already been done) */
break;
default:
if (symbol->output_options & BARCODE_BIND) {
if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
/* row binding */
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
if (symbol->symbology != BARCODE_CODABLOCKF) {
for (r = 1; r < symbol->rows; r++) {
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", 2.0 * scaler, ((r * row_height) + textoffset + yoffset - 1) * scaler, xoffset * scaler, symbol->width * scaler);
}
} else {
for (r = 1; r < symbol->rows; r++) {
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", 2.0 * scaler, ((r * row_height) + textoffset + yoffset - 1) * scaler, (xoffset + 11) * scaler, (symbol->width - 25) * scaler);
}
}
}
}
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
if (symbol->symbology != BARCODE_CODABLOCKF) {
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, textoffset * scaler, 0.0, (symbol->width + xoffset + xoffset) * scaler);
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, (textoffset + symbol->height + symbol->border_width) * scaler, 0.0, (symbol->width + xoffset + xoffset) * scaler);
} else {
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, textoffset * scaler, xoffset * scaler, symbol->width * scaler);
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, (textoffset + symbol->height + symbol->border_width) * scaler, xoffset * scaler, symbol->width * scaler);
}
}
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", (symbol->height + (2 * symbol->border_width)) * scaler, textoffset * scaler, 0.0, symbol->border_width * scaler);
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", (symbol->height + (2 * symbol->border_width)) * scaler, textoffset * scaler, (symbol->width + xoffset + xoffset - symbol->border_width) * scaler, symbol->border_width * scaler);
}
break;
}
/* Put the human readable text at the bottom */
if ((textdone == 0) && (ustrlen(local_text))) {
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = symbol->width / 2.0;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", local_text);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", local_text);
fprintf(feps, "setmatrix\n");
}
fprintf(feps, "\nshowpage\n");
if (symbol->output_options & BARCODE_STDOUT) {
fflush(feps);
} else {
fclose(feps);
}
if (locale)
setlocale(LC_ALL, locale);
#ifdef _MSC_VER
free(local_text);
#endif
return error_number;
}

2983
3rdparty/zint-2.6.1/backend/qr.c vendored Normal file

File diff suppressed because it is too large Load Diff

167
3rdparty/zint-2.6.1/backend/qr.h vendored Normal file
View File

@ -0,0 +1,167 @@
/* qr.h Data for QR Code */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2006 Kentaro Fukuchi <fukuchi@megaui.net>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#define LEVEL_L 1
#define LEVEL_M 2
#define LEVEL_Q 3
#define LEVEL_H 4
#define RHODIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"
/* From ISO/IEC 18004:2006 Table 7 */
static const unsigned short int qr_data_codewords_L[] = {
19, 34, 55, 80, 108, 136, 156, 194, 232, 274, 324, 370, 428, 461, 523, 589, 647,
721, 795, 861, 932, 1006, 1094, 1174, 1276, 1370, 1468, 1531, 1631,
1735, 1843, 1955, 2071, 2191, 2306, 2434, 2566, 2702, 2812, 2956
};
static const unsigned short int qr_data_codewords_M[] = {
16, 28, 44, 64, 86, 108, 124, 154, 182, 216, 254, 290, 334, 365, 415, 453, 507,
563, 627, 669, 714, 782, 860, 914, 1000, 1062, 1128, 1193, 1267,
1373, 1455, 1541, 1631, 1725, 1812, 1914, 1992, 2102, 2216, 2334
};
static const unsigned short int qr_data_codewords_Q[] = {
13, 22, 34, 48, 62, 76, 88, 110, 132, 154, 180, 206, 244, 261, 295, 325, 367,
397, 445, 485, 512, 568, 614, 664, 718, 754, 808, 871, 911,
985, 1033, 1115, 1171, 1231, 1286, 1354, 1426, 1502, 1582, 1666
};
static const unsigned short int qr_data_codewords_H[] = {
9, 16, 26, 36, 46, 60, 66, 86, 100, 122, 140, 158, 180, 197, 223, 253, 283,
313, 341, 385, 406, 442, 464, 514, 538, 596, 628, 661, 701,
745, 793, 845, 901, 961, 986, 1054, 1096, 1142, 1222, 1276
};
static const unsigned short int qr_total_codewords[] = {
26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815,
901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051,
2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
};
static const char qr_blocks_L[] = {
1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12,
12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25
};
static const char qr_blocks_M[] = {
1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20,
21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49
};
static const char qr_blocks_Q[] = {
1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25,
27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68
};
static const char qr_blocks_H[] = {
1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30,
32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81
};
static const unsigned short int qr_sizes[] = {
21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97,
101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177
};
static const char micro_qr_sizes[] = {
11, 13, 15, 17
};
static const char qr_align_loopsize[] = {
0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7
};
static const unsigned short int qr_table_e1[] = {
6, 18, 0, 0, 0, 0, 0,
6, 22, 0, 0, 0, 0, 0,
6, 26, 0, 0, 0, 0, 0,
6, 30, 0, 0, 0, 0, 0,
6, 34, 0, 0, 0, 0, 0,
6, 22, 38, 0, 0, 0, 0,
6, 24, 42, 0, 0, 0, 0,
6, 26, 46, 0, 0, 0, 0,
6, 28, 50, 0, 0, 0, 0,
6, 30, 54, 0, 0, 0, 0,
6, 32, 58, 0, 0, 0, 0,
6, 34, 62, 0, 0, 0, 0,
6, 26, 46, 66, 0, 0, 0,
6, 26, 48, 70, 0, 0, 0,
6, 26, 50, 74, 0, 0, 0,
6, 30, 54, 78, 0, 0, 0,
6, 30, 56, 82, 0, 0, 0,
6, 30, 58, 86, 0, 0, 0,
6, 34, 62, 90, 0, 0, 0,
6, 28, 50, 72, 94, 0, 0,
6, 26, 50, 74, 98, 0, 0,
6, 30, 54, 78, 102, 0, 0,
6, 28, 54, 80, 106, 0, 0,
6, 32, 58, 84, 110, 0, 0,
6, 30, 58, 86, 114, 0, 0,
6, 34, 62, 90, 118, 0, 0,
6, 26, 50, 74, 98, 122, 0,
6, 30, 54, 78, 102, 126, 0,
6, 26, 52, 78, 104, 130, 0,
6, 30, 56, 82, 108, 134, 0,
6, 34, 60, 86, 112, 138, 0,
6, 30, 58, 86, 114, 142, 0,
6, 34, 62, 90, 118, 146, 0,
6, 30, 54, 78, 102, 126, 150,
6, 24, 50, 76, 102, 128, 154,
6, 28, 54, 80, 106, 132, 158,
6, 32, 58, 84, 110, 136, 162,
6, 26, 54, 82, 110, 138, 166,
6, 30, 58, 86, 114, 142, 170
};
static const unsigned int qr_annex_c[] = {
/* Format information bit sequences */
0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, 0x77c4, 0x72f3, 0x7daa, 0x789d,
0x662f, 0x6318, 0x6c41, 0x6976, 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b,
0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed
};
static const unsigned int qr_annex_d[] = {
/* Version information bit sequences */
0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, 0x0f928, 0x10b78,
0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, 0x177ec, 0x18ec4, 0x191e1, 0x1afab,
0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b,
0x2542e, 0x26a64, 0x27541, 0x28c69
};
static const unsigned int qr_annex_c1[] = {
/* Micro QR Code format information */
0x4445, 0x4172, 0x4e2b, 0x4b1c, 0x55ae, 0x5099, 0x5fc0, 0x5af7, 0x6793, 0x62a4, 0x6dfd, 0x68ca, 0x7678, 0x734f,
0x7c16, 0x7921, 0x06de, 0x03e9, 0x0cb0, 0x0987, 0x1735, 0x1202, 0x1d5b, 0x186c, 0x2508, 0x203f, 0x2f66, 0x2a51, 0x34e3,
0x31d4, 0x3e8d, 0x3bba
};

1138
3rdparty/zint-2.6.1/backend/raster.c vendored Normal file

File diff suppressed because it is too large Load Diff

164
3rdparty/zint-2.6.1/backend/reedsol.c vendored Normal file
View File

@ -0,0 +1,164 @@
/**
This is a simple Reed-Solomon encoder
(C) Cliff Hones 2004
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
// It is not written with high efficiency in mind, so is probably
// not suitable for real-time encoding. The aim was to keep it
// simple, general and clear.
//
// <Some notes on the theory and implementation need to be added here>
// Usage:
// First call rs_init_gf(poly) to set up the Galois Field parameters.
// Then call rs_init_code(size, index) to set the encoding size
// Then call rs_encode(datasize, data, out) to encode the data.
//
// These can be called repeatedly as required - but note that
// rs_init_code must be called following any rs_init_gf call.
//
// If the parameters are fixed, some of the statics below can be
// replaced with constants in the obvious way, and additionally
// malloc/free can be avoided by using static arrays of a suitable
// size.
#include <stdio.h> // only needed for debug (main)
#include <stdlib.h> // only needed for malloc/free
#include "reedsol.h"
static int logmod; // 2**symsize - 1
static int rlen;
static int *logt = NULL, *alog = NULL, *rspoly = NULL;
// rs_init_gf(poly) initialises the parameters for the Galois Field.
// The symbol size is determined from the highest bit set in poly
// This implementation will support sizes up to 30 bits (though that
// will result in very large log/antilog tables) - bit sizes of
// 8 or 4 are typical
//
// The poly is the bit pattern representing the GF characteristic
// polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
void rs_init_gf(const int poly) {
int m, b, p, v;
// Find the top bit, and hence the symbol size
for (b = 1, m = 0; b <= poly; b <<= 1)
m++;
b >>= 1;
m--;
// Calculate the log/alog tables
logmod = (1 << m) - 1;
logt = (int *) malloc(sizeof (int) * (logmod + 1));
alog = (int *) malloc(sizeof (int) * logmod);
for (p = 1, v = 0; v < logmod; v++) {
alog[v] = p;
logt[p] = v;
p <<= 1;
if (p & b)
p ^= poly;
}
}
// rs_init_code(nsym, index) initialises the Reed-Solomon encoder
// nsym is the number of symbols to be generated (to be appended
// to the input data). index is usually 1 - it is the index of
// the constant in the first term (i) of the RS generator polynomial:
// (x + 2**i)*(x + 2**(i+1))*... [nsym terms]
// For ECC200, index is 1.
void rs_init_code(const int nsym, int index) {
int i, k;
rspoly = (int *) malloc(sizeof (int) * (nsym + 1));
rlen = nsym;
rspoly[0] = 1;
for (i = 1; i <= nsym; i++) {
rspoly[i] = 1;
for (k = i - 1; k > 0; k--) {
if (rspoly[k])
rspoly[k] = alog[(logt[rspoly[k]] + index) % logmod];
rspoly[k] ^= rspoly[k - 1];
}
rspoly[0] = alog[(logt[rspoly[0]] + index) % logmod];
index++;
}
}
void rs_encode(const size_t len,const unsigned char *data, unsigned char *res) {
int i, k, m;
for (i = 0; i < rlen; i++)
res[i] = 0;
for (i = 0; i < len; i++) {
m = res[rlen - 1] ^ data[i];
for (k = rlen - 1; k > 0; k--) {
if (m && rspoly[k])
res[k] = (unsigned char) (res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod]);
else
res[k] = res[k - 1];
}
if (m && rspoly[0])
res[0] = (unsigned char) (alog[(logt[m] + logt[rspoly[0]]) % logmod]);
else
res[0] = 0;
}
}
/* The same as above but for larger bitlengths - Aztec code compatible */
void rs_encode_long(const int len, const unsigned int *data, unsigned int *res) {
int i, k, m;
for (i = 0; i < rlen; i++)
res[i] = 0;
for (i = 0; i < len; i++) {
m = res[rlen - 1] ^ data[i];
for (k = rlen - 1; k > 0; k--) {
if (m && rspoly[k])
res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod];
else
res[k] = res[k - 1];
}
if (m && rspoly[0])
res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod];
else
res[0] = 0;
}
}
/* Free memory */
void rs_free(void) {
free(logt);
free(alog);
free(rspoly);
rspoly = NULL;
}

50
3rdparty/zint-2.6.1/backend/reedsol.h vendored Normal file
View File

@ -0,0 +1,50 @@
/*
This is a simple Reed-Solomon encoder
(C) Cliff Hones 2004
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef __REEDSOL_H
#define __REEDSOL_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern void rs_init_gf(const int poly);
extern void rs_init_code(const int nsym,int index);
extern void rs_encode(const size_t len,const unsigned char *data, unsigned char *res);
extern void rs_encode_long(const int len,const unsigned int *data, unsigned int *res);
extern void rs_free(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __REEDSOL_H */

778
3rdparty/zint-2.6.1/backend/render.c vendored Normal file
View File

@ -0,0 +1,778 @@
/*
* render.c - Generic Rendered Format
*
* Initiall written by Sam Lown for use in gLabels. Converts encoded
* data into a generic internal structure of lines and characters
* usable in external applications.
*/
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <locale.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#define GL_CONST 2.8346
struct zint_render_line *render_plot_create_line(float x, float y, float width, float length);
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line);
struct zint_render_ring *render_plot_create_ring(float x, float y, float radius, float line_width);
int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ring, struct zint_render_ring **last_ring);
struct zint_render_hexagon *render_plot_create_hexagon(float x, float y);
int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexagon *ring, struct zint_render_hexagon **last_hexagon);
int render_plot_add_string(struct zint_symbol *symbol, unsigned char *text, float x, float y, float fsize, float width, struct zint_render_string **last_string);
int render_plot(struct zint_symbol *symbol, const float width, const float height) {
struct zint_render *render;
struct zint_render_line *line, *last_line = NULL;
struct zint_render_string *last_string = NULL;
struct zint_render_ring *ring, *last_ring = NULL;
struct zint_render_hexagon *hexagon, *last_hexagon = NULL;
int i, r, block_width, latch, this_row;
float textpos, textwidth, large_bar_height, preset_height, row_height, row_posn = 0.0;
// int error_number = 0;
int text_offset, text_height, xoffset, yoffset, textdone, main_symbol_width_x, addon_width_x;
char addon[6], textpart[10];
int large_bar_count, symbol_lead_in, total_symbol_width_x, total_area_width_x;
float addon_text_posn;
float default_text_posn;
float scaler;
const char *locale = NULL;
int hide_text = 0;
float required_aspect;
float symbol_aspect = 1;
float x_dimension;
int upceanflag = 0;
// Allocate memory for the rendered version
render = symbol->rendered = (struct zint_render *) malloc(sizeof (struct zint_render));
if (!symbol->rendered) return ZINT_ERROR_MEMORY;
render->lines = NULL;
render->strings = NULL;
render->rings = NULL;
render->hexagons = NULL;
locale = setlocale(LC_ALL, "C");
row_height = 0;
textdone = 0;
textpos = 0.0;
main_symbol_width_x = symbol->width;
strcpy(addon, "");
symbol_lead_in = 0;
addon_text_posn = 0.0;
addon_width_x = 0;
/*
* Determine if there will be any addon texts and text height
*/
latch = 0;
r = 0;
/* Isolate add-on text */
if (is_extendable(symbol->symbology)) {
for(i = 0; i < (int)ustrlen(symbol->text); i++) {
if (latch == 1) {
addon[r] = symbol->text[i];
r++;
}
if (symbol->text[i] == '+') {
latch = 1;
}
}
}
addon[r] = '\0';
if ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)) {
hide_text = 1;
text_height = text_offset = 0.0;
} else {
text_height = 9.0;
text_offset = 2.0;
}
/*
* Calculate the width of the barcode, especially if there are any extra
* borders or white space to add.
*/
while (!(module_is_set(symbol, symbol->rows - 1, symbol_lead_in))) {
symbol_lead_in++;
}
/* Certain symbols need whitespace otherwise characters get chopped off the sides */
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC))
|| (symbol->symbology == BARCODE_ISBNX)) {
switch (ustrlen(symbol->text)) {
case 13: /* EAN 13 */
case 16:
case 19:
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
}
main_symbol_width_x = 96 + symbol_lead_in;
upceanflag = 13;
break;
case 2:
main_symbol_width_x = 22 + symbol_lead_in;
upceanflag = 2;
break;
case 5:
main_symbol_width_x = 49 + symbol_lead_in;
upceanflag = 5;
break;
default:
main_symbol_width_x = 68 + symbol_lead_in;
upceanflag = 8;
}
switch (ustrlen(symbol->text)) {
case 11:
case 16:
/* EAN-2 add-on */
addon_width_x = 31;
break;
case 14:
case 19:
/* EAN-5 add-on */
addon_width_x = 58;
break;
}
}
else if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
upceanflag = 12;
if (symbol->whitespace_width < 10) {
symbol->whitespace_width = 10;
main_symbol_width_x = 96 + symbol_lead_in;
}
switch (ustrlen(symbol->text)) {
case 15:
/* EAN-2 add-on */
addon_width_x = 31;
break;
case 18:
/* EAN-5 add-on */
addon_width_x = 58;
break;
}
}
else if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
upceanflag = 6;
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
main_symbol_width_x = 51 + symbol_lead_in;
}
switch (ustrlen(symbol->text)) {
case 11:
/* EAN-2 add-on */
addon_width_x = 31;
break;
case 14:
/* EAN-5 add-on */
addon_width_x = 58;
break;
}
}
total_symbol_width_x = 0.0 + main_symbol_width_x + addon_width_x;
total_area_width_x = total_symbol_width_x + (2 * (symbol->border_width + symbol->whitespace_width));
xoffset = symbol->border_width + symbol->whitespace_width;
yoffset = symbol->border_width;
// Determine if height should be overridden
large_bar_count = 0;
preset_height = 0.0;
for (i = 0; i < symbol->rows; i++) {
preset_height += symbol->row_height[i];
if (symbol->row_height[i] == 0) {
large_bar_count++;
}
}
if (large_bar_count == 0) {
required_aspect = width / height;
symbol_aspect = (total_symbol_width_x + (2 * xoffset)) / (preset_height + (2 * yoffset) + text_offset + text_height);
symbol->height = (int) preset_height;
if (required_aspect > symbol_aspect) {
/* the area is too wide */
scaler = height / (preset_height + (2 * yoffset) + text_offset + text_height);
render->width = symbol_aspect * height;
render->height = height;
} else {
/* the area is too high */
scaler = width / (total_symbol_width_x + (2 * xoffset));
render->width = width;
render->height = width / symbol_aspect;
}
} else {
scaler = width / (total_symbol_width_x + (2 * xoffset));
symbol->height = (int) ((height / scaler) - ((2 * yoffset) + text_offset + text_height));
render->width = width;
render->height = height;
}
large_bar_height = (symbol->height - preset_height) / large_bar_count;
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
default_text_posn = (symbol->height + text_offset + symbol->border_width + symbol->border_width) * scaler;
} else {
default_text_posn = (symbol->height + text_offset + symbol->border_width) * scaler;
}
x_dimension = render->width / total_area_width_x;
x_dimension /= GL_CONST;
/* Set minimum size of symbol */
/* Barcode must be at least 2mm high by 2mm across */
if (render->height < ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 2.0) * GL_CONST) {
render->height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 2.0) * GL_CONST;
}
if (render->width < (2.0 * GL_CONST)) {
render->width = (2.0 * GL_CONST);
}
if (symbol->symbology == BARCODE_CODABAR) {
/* The minimum X-dimension of Codabar is 0.191mm. The minimum bar height is 5mm */
if (x_dimension < 0.191) {
render->width = 0.191 * GL_CONST * total_area_width_x;
}
if (render->height < ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 5.0) * GL_CONST) {
render->height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 5.0) * GL_CONST;
}
}
else if (symbol->symbology == BARCODE_CODE49) {
/* The minimum X-dimension of Code 49 is 0.191mm */
if (x_dimension < 0.191) {
render->width = 0.191 * GL_CONST * total_area_width_x;
render->height = render->width / symbol_aspect;
}
}
if (upceanflag != 0) {
/* The X-dimension of UPC/EAN symbols is fixed at 0.330mm */
/* NOTE: This code will need adjustment before it correctly deals with composite symbols */
render->width = 0.330 * GL_CONST * total_area_width_x;
/* The height is also fixed */
switch (upceanflag) {
case 6:
case 12:
case 13:
/* UPC-A, UPC-E and EAN-13 */
/* Height of bars should be 22.85mm */
render->height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 22.85) * GL_CONST;
break;
case 8:
/* EAN-8 */
/* Height of bars should be 18.23mm */
render->height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 18.23) * GL_CONST;
break;
default:
/* EAN-2 and EAN-5 */
/* Height of bars should be 21.10mm */
render->height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 21.10) * GL_CONST;
}
}
if (symbol->symbology == BARCODE_ONECODE) {
/* The size of USPS Intelligent Mail barcode is fixed */
render->width = 0.508 * GL_CONST * total_area_width_x;
render->height = 4.064 * GL_CONST;
}
else if ((symbol->symbology == BARCODE_POSTNET) || (symbol->symbology == BARCODE_PLANET)) {
/* The size of PostNet and PLANET are fized */
render->width = 0.508 * GL_CONST * total_area_width_x;
render->height = 2.921 * GL_CONST;
}
else if (((symbol->symbology == BARCODE_AUSPOST) || (symbol->symbology == BARCODE_AUSREPLY)) ||
((symbol->symbology == BARCODE_AUSROUTE) || (symbol->symbology == BARCODE_AUSREDIRECT))) {
/* Australia Post use the same sizes as USPS */
render->width = 0.508 * GL_CONST * total_area_width_x;
render->height = 4.064 * GL_CONST;
}
else if ((symbol->symbology == BARCODE_RM4SCC) || (symbol->symbology == BARCODE_KIX)) {
/* Royal Mail and KIX Code uses 22 bars per inch */
render->width = 0.577 * GL_CONST * total_area_width_x;
render->height = 5.22 * GL_CONST;
}
if (symbol->symbology == BARCODE_MAXICODE) {
/* Maxicode is a fixed size */
scaler = GL_CONST; /* Converts from millimeters to the scale used by glabels */
render->width = 28.16 * scaler;
render->height = 26.86 * scaler;
/* Central bullseye pattern */
ring = render_plot_create_ring(13.64 * scaler, 13.43 * scaler, 0.85 * scaler, 0.67 * scaler);
render_plot_add_ring(symbol, ring, &last_ring);
ring = render_plot_create_ring(13.64 * scaler, 13.43 * scaler, 2.20 * scaler, 0.67 * scaler);
render_plot_add_ring(symbol, ring, &last_ring);
ring = render_plot_create_ring(13.64 * scaler, 13.43 * scaler, 3.54 * scaler, 0.67 * scaler);
render_plot_add_ring(symbol, ring, &last_ring);
/* Hexagons */
for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
hexagon = render_plot_create_hexagon(((i * 0.88) + (r & 1 ? 1.76 : 1.32)) * scaler, ((r * 0.76) + 0.76) * scaler);
render_plot_add_hexagon(symbol, hexagon, &last_hexagon);
}
}
}
} else {
/* everything else uses rectangles (or squares) */
/* Works from the bottom of the symbol up */
int addon_latch = 0;
for (r = 0; r < symbol->rows; r++) {
this_row = r;
if (symbol->row_height[this_row] == 0) {
row_height = large_bar_height;
} else {
row_height = symbol->row_height[this_row];
}
row_posn = 0;
for (i = 0; i < r; i++) {
if (symbol->row_height[i] == 0) {
row_posn += large_bar_height;
} else {
row_posn += symbol->row_height[i];
}
}
row_posn += yoffset;
i = 0;
if (module_is_set(symbol, this_row, 0)) {
latch = 1;
} else {
latch = 0;
}
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
if ((addon_latch == 0) && (r == (symbol->rows - 1)) && (i > main_symbol_width_x)) {
addon_text_posn = row_posn * scaler;
addon_latch = 1;
}
if (latch == 1) {
/* a bar */
if (addon_latch == 0) {
line = render_plot_create_line((i + xoffset) * scaler, (row_posn) * scaler, block_width * scaler, row_height * scaler);
} else {
line = render_plot_create_line((i + xoffset) * scaler, (row_posn + 10.0) * scaler, block_width * scaler, (row_height - 5.0) * scaler);
}
latch = 0;
render_plot_add_line(symbol, line, &last_line);
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < symbol->width);
}
}
/* That's done the actual data area, everything else is human-friendly */
/* Add the text */
xoffset -= symbol_lead_in;
row_posn = (row_posn + large_bar_height) * scaler;
if (!hide_text) {
if (upceanflag == 8) {
/* guard bar extensions and text formatting for EAN-8 */
i = 0;
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
switch (i) {
case 0:
case 1:
case 10:
case 11:
case 20:
case 21:
line->length += (5.0 * scaler);
break;
}
i++;
}
for (i = 0; i < 4; i++) {
textpart[i] = symbol->text[i];
}
textpart[4] = '\0';
textpos = 17;
textwidth = 4.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
for (i = 0; i < 4; i++) {
textpart[i] = symbol->text[i + 4];
}
textpart[4] = '\0';
textpos = 50;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 86;
textwidth = 2.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
break;
case 5:
textpos = xoffset + 100;
textwidth = 5.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
break;
}
}
if (upceanflag == 13) {
/* guard bar extensions and text formatting for EAN-13 */
i = 0;
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
switch (i) {
case 0:
case 1:
case 14:
case 15:
case 28:
case 29:
line->length += (5.0 * scaler);
break;
}
i++;
}
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5; // 7
textwidth = 8.5;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
textpos = 25;
textwidth = 6.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 7];
}
textpart[6] = '\0';
textpos = 72;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 114;
textwidth = 2.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
break;
case 5:
textpos = xoffset + 128;
textwidth = 5.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
break;
}
}
if (upceanflag == 12) {
/* guard bar extensions and text formatting for UPCA */
i = 0;
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 14:
case 15:
case 26:
case 27:
case 28:
case 29:
line->length += (5.0 * scaler);
break;
}
i++;
}
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5;
textwidth = 6.2;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn + (2.0 * scaler), 8.0 * scaler, textwidth * scaler, &last_string);
for (i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[5] = '\0';
textpos = 27;
textwidth = 5.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
for (i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 6];
}
textpos = 68;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
textpart[0] = symbol->text[11];
textpart[1] = '\0';
textpos = 100;
textwidth = 6.2;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn + (2.0 * scaler), 8.0 * scaler, textwidth * scaler, &last_string);
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 116;
textwidth = 2.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
break;
case 5:
textpos = xoffset + 130;
textwidth = 5.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
break;
}
}
if (upceanflag == 6) {
/* guard bar extensions and text formatting for UPCE */
i = 0;
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
switch (i) {
case 0:
case 1:
case 14:
case 15:
case 16:
line->length += (5.0 * scaler);
break;
}
i++;
}
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5;
textwidth = 6.2;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn + (2.0 * scaler), 8.0 * scaler, textwidth * scaler, &last_string);
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
textpos = 24;
textwidth = 6.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
textpart[0] = symbol->text[7];
textpart[1] = '\0';
textpos = 55;
textwidth = 6.2;
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn + (2.0 * scaler), 8.0 * scaler, textwidth * scaler, &last_string);
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 70;
textwidth = 2.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
break;
case 5:
textpos = xoffset + 84;
textwidth = 5.0 * 8.5;
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
break;
}
}
/* Put normal human readable text at the bottom (and centered) */
if (textdone == 0) {
// caculate start xoffset to center text
render_plot_add_string(symbol, symbol->text, ((symbol->width / 2.0) + xoffset) * scaler, default_text_posn, 9.0 * scaler, 0.0, &last_string);
}
}
switch (symbol->symbology) {
case BARCODE_MAXICODE:
/* Do nothing! */
break;
default:
if ((symbol->output_options & BARCODE_BIND) != 0) {
if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
/* row binding */
for (r = 1; r < symbol->rows; r++) {
line = render_plot_create_line(xoffset * scaler, ((r * row_height) + yoffset - 1) * scaler, symbol->width * scaler, 2.0 * scaler);
render_plot_add_line(symbol, line, &last_line);
}
}
}
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
line = render_plot_create_line(0, 0, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
render_plot_add_line(symbol, line, &last_line);
line = render_plot_create_line(0, (symbol->height + symbol->border_width) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
render_plot_add_line(symbol, line, &last_line);
}
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
line = render_plot_create_line(0, 0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
render_plot_add_line(symbol, line, &last_line);
line = render_plot_create_line((symbol->width + xoffset + xoffset - symbol->border_width) * scaler, 0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
render_plot_add_line(symbol, line, &last_line);
}
break;
}
if (locale)
setlocale(LC_ALL, locale);
return 1;
}
/*
* Create a new line with its memory allocated ready for adding to the
* rendered structure.
*
* This is much quicker than writing out each line manually (in some cases!)
*/
struct zint_render_line *render_plot_create_line(float x, float y, float width, float length) {
struct zint_render_line *line;
line = (struct zint_render_line*) malloc(sizeof (struct zint_render_line));
if (!line) return NULL;
line->next = NULL;
line->x = x;
line->y = y;
line->width = width;
line->length = length;
return line;
}
/*
* Add the line to the current rendering and update the last line's
* next value.
*/
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line) {
if (!line) return ZINT_ERROR_MEMORY;
if (*last_line)
(*last_line)->next = line;
else
symbol->rendered->lines = line; // first line
*last_line = line;
return 1;
}
struct zint_render_ring *render_plot_create_ring(float x, float y, float radius, float line_width) {
struct zint_render_ring *ring;
ring = (struct zint_render_ring *) malloc(sizeof (struct zint_render_ring));
if (!ring) return NULL;
ring->next = NULL;
ring->x = x;
ring->y = y;
ring->radius = radius;
ring->line_width = line_width;
return ring;
}
int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ring, struct zint_render_ring **last_ring) {
if (!ring) return ZINT_ERROR_MEMORY;
if (*last_ring)
(*last_ring)->next = ring;
else
symbol->rendered->rings = ring; // first ring
*last_ring = ring;
return 1;
}
struct zint_render_hexagon *render_plot_create_hexagon(float x, float y) {
struct zint_render_hexagon *hexagon;
hexagon = (struct zint_render_hexagon*) malloc(sizeof (struct zint_render_hexagon));
if (!hexagon) return NULL;
hexagon->next = NULL;
hexagon->x = x;
hexagon->y = y;
return hexagon;
}
int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexagon *hexagon, struct zint_render_hexagon **last_hexagon) {
if (!hexagon) return ZINT_ERROR_MEMORY;
if (*last_hexagon)
(*last_hexagon)->next = hexagon;
else
symbol->rendered->hexagons = hexagon; // first hexagon
*last_hexagon = hexagon;
return 1;
}
/*
* Add a string structure to the symbol.
* Coordinates assumed to be from top-center.
*/
int render_plot_add_string(struct zint_symbol *symbol,
unsigned char *text, float x, float y, float fsize, float width,
struct zint_render_string **last_string) {
struct zint_render_string *string;
string = (struct zint_render_string*) malloc(sizeof (struct zint_render_string));
string->next = NULL;
string->x = x;
string->y = y;
string->width = width;
string->fsize = fsize;
string->length = ustrlen(text);
string->text = (unsigned char*) malloc(sizeof (unsigned char) * (ustrlen(text) + 1));
ustrcpy(string->text, text);
if (*last_string)
(*last_string)->next = string;
else
symbol->rendered->strings = string; // First character
*last_string = string;
return 1;
}

2307
3rdparty/zint-2.6.1/backend/rss.c vendored Normal file

File diff suppressed because it is too large Load Diff

298
3rdparty/zint-2.6.1/backend/rss.h vendored Normal file
View File

@ -0,0 +1,298 @@
/* rss.h - Data tables for Reduced Space Symbology */
/*
libzint - the open source barcode library
Copyright (C) 2007-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#define NUMERIC 110
#define ALPHA 97
#define ISOIEC 105
#define INVALID_CHAR 100
#define ANY_ENC 120
#define ALPHA_OR_ISO 121
/* RSS-14 Tables */
static const unsigned short int g_sum_table[9] = {
0, 161, 961, 2015, 2715, 0, 336, 1036, 1516
};
static const char t_table[9] = {
1, 10, 34, 70, 126, 4, 20, 48, 81
};
static const char modules_odd[9] = {
12, 10, 8, 6, 4, 5, 7, 9, 11
};
static const char modules_even[9] = {
4, 6, 8, 10, 12, 10, 8, 6, 4
};
static const char widest_odd[9] = {
8, 6, 4, 3, 1, 2, 4, 6, 8
};
static const char widest_even[9] = {
1, 3, 5, 6, 8, 7, 5, 3, 1
};
static int widths[8];
static const char finder_pattern[45] = {
3, 8, 2, 1, 1,
3, 5, 5, 1, 1,
3, 3, 7, 1, 1,
3, 1, 9, 1, 1,
2, 7, 4, 1, 1,
2, 5, 6, 1, 1,
2, 3, 8, 1, 1,
1, 5, 7, 1, 1,
1, 3, 9, 1, 1
};
static const char checksum_weight[32] = {
/* Table 5 */
1, 3, 9, 27, 2, 6, 18, 54,
4, 12, 36, 29, 8, 24, 72, 58,
16, 48, 65, 37, 32, 17, 51, 74,
64, 34, 23, 69, 49, 68, 46, 59
};
/* RSS Limited Tables */
static const unsigned short int t_even_ltd[7] = {
28, 728, 6454, 203, 2408, 1, 16632
};
static const char modules_odd_ltd[7] = {
17, 13, 9, 15, 11, 19, 7
};
static const char modules_even_ltd[7] = {
9, 13, 17, 11, 15, 7, 19
};
static const char widest_odd_ltd[7] = {
6, 5, 3, 5, 4, 8, 1
};
static const char widest_even_ltd[7] = {
3, 4, 6, 4, 5, 1, 8
};
static const char checksum_weight_ltd[28] = {
/* Table 7 */
1, 3, 9, 27, 81, 65, 17, 51, 64, 14, 42, 37, 22, 66,
20, 60, 2, 6, 18, 54, 73, 41, 34, 13, 39, 28, 84, 74
};
static const char finder_pattern_ltd[1246] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 2, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1,
1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1,
1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1,
1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 2, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 2, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1,
1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 1,
1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1,
1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 1,
1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
1, 3, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1,
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1,
1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1,
1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1,
1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1,
1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1,
1, 1, 1, 2, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1,
1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1,
1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1,
1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1,
1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1,
1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 3, 1, 1,
1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1,
1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 2, 1, 1, 1,
1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 1,
1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 1,
1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1,
1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1,
1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1,
1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1,
1, 2, 1, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1,
1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1,
1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1,
1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1,
1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1,
1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1,
1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1,
1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 1,
1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1,
1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1,
2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1,
2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1,
2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1,
2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1,
2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1,
2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1,
2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1,
2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1,
2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1
};
/* RSS Expanded Tables */
static const unsigned short int g_sum_exp[5] = {
0, 348, 1388, 2948, 3988
};
static const unsigned short int t_even_exp[5] = {
4, 20, 52, 104, 204
};
static const char modules_odd_exp[5] = {
12, 10, 8, 6, 4
};
static const char modules_even_exp[5] = {
5, 7, 9, 11, 13
};
static const char widest_odd_exp[5] = {
7, 5, 4, 3, 1
};
static const char widest_even_exp[5] = {
2, 4, 5, 6, 8
};
static const unsigned short int checksum_weight_exp[184] = {
/* Table 14 */
1, 3, 9, 27, 81, 32, 96, 77,
20, 60, 180, 118, 143, 7, 21, 63,
189, 145, 13, 39, 117, 140, 209, 205,
193, 157, 49, 147, 19, 57, 171, 91,
62, 186, 136, 197, 169, 85, 44, 132,
185, 133, 188, 142, 4, 12, 36, 108,
113, 128, 173, 97, 80, 29, 87, 50,
150, 28, 84, 41, 123, 158, 52, 156,
46, 138, 203, 187, 139, 206, 196, 166,
76, 17, 51, 153, 37, 111, 122, 155,
43, 129, 176, 106, 107, 110, 119, 146,
16, 48, 144, 10, 30, 90, 59, 177,
109, 116, 137, 200, 178, 112, 125, 164,
70, 210, 208, 202, 184, 130, 179, 115,
134, 191, 151, 31, 93, 68, 204, 190,
148, 22, 66, 198, 172, 94, 71, 2,
6, 18, 54, 162, 64, 192, 154, 40,
120, 149, 25, 75, 14, 42, 126, 167,
79, 26, 78, 23, 69, 207, 199, 175,
103, 98, 83, 38, 114, 131, 182, 124,
161, 61, 183, 127, 170, 88, 53, 159,
55, 165, 73, 8, 24, 72, 5, 15,
45, 135, 194, 160, 58, 174, 100, 89
};
static const char finder_pattern_exp[60] = {
/* Table 15 */
1, 8, 4, 1, 1,
1, 1, 4, 8, 1,
3, 6, 4, 1, 1,
1, 1, 4, 6, 3,
3, 4, 6, 1, 1,
1, 1, 6, 4, 3,
3, 2, 8, 1, 1,
1, 1, 8, 2, 3,
2, 6, 5, 1, 1,
1, 1, 5, 6, 2,
2, 2, 9, 1, 1,
1, 1, 9, 2, 2
};
static const char finder_sequence[198] = {
/* Table 16 */
1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0,
1, 6, 3, 8, 0, 0, 0, 0, 0, 0, 0,
1, 10, 3, 8, 5, 0, 0, 0, 0, 0, 0,
1, 10, 3, 8, 7, 12, 0, 0, 0, 0, 0,
1, 10, 3, 8, 9, 12, 11, 0, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 10, 9, 0, 0,
1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 0,
1, 2, 3, 4, 5, 8, 7, 10, 9, 12, 11
};
static const char weight_rows[210] = {
0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 5, 6, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 9, 10, 3, 4, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 11, 12, 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 18, 3, 4, 13, 14, 15, 16, 21, 22, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 15, 16, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 19, 20, 21, 22, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 11, 12, 17, 18, 15, 16, 21, 22, 19, 20
};

6886
3rdparty/zint-2.6.1/backend/sjis.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
/* stdint_msvc.h - definitions for libzint
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef STDINT_MSVC_H
#define STDINT_MSVC_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef _MSC_VER
typedef BYTE uint8_t;
typedef WORD uint16_t;
typedef DWORD uint32_t;
typedef INT32 int32_t;
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* STDINT_MSVC_H */

679
3rdparty/zint-2.6.1/backend/svg.c vendored Normal file
View File

@ -0,0 +1,679 @@
/* svg.c - Scalable Vector Graphics */
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <locale.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#define SSET "0123456789ABCDEF"
int svg_plot(struct zint_symbol *symbol) {
int i, block_width, latch, r, this_row;
float textpos, large_bar_height, preset_height, row_height, row_posn = 0.0;
FILE *fsvg;
int error_number = 0;
int textoffset, xoffset, yoffset, textdone, main_width;
char textpart[10], addon[6];
int large_bar_count, comp_offset;
float addon_text_posn;
float scaler = symbol->scale;
float default_text_posn;
const char *locale = NULL;
#ifndef _MSC_VER
unsigned char local_text[ustrlen(symbol->text) + 1];
#else
unsigned char* local_text = (unsigned char*) _alloca(ustrlen(symbol->text) + 1);
#endif
row_height = 0;
textdone = 0;
main_width = symbol->width;
strcpy(addon, "");
comp_offset = 0;
addon_text_posn = 0.0;
if (symbol->show_hrt != 0) {
/* Copy text from symbol */
ustrcpy(local_text, symbol->text);
} else {
/* No text needed */
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CC:
case BARCODE_ISBNX:
case BARCODE_UPCA:
case BARCODE_UPCE:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
/* For these symbols use dummy text to ensure formatting is done
* properly even if no text is required */
for (i = 0; i < ustrlen(symbol->text); i++) {
if (symbol->text[i] == '+') {
local_text[i] = '+';
} else {
local_text[i] = ' ';
}
local_text[ustrlen(symbol->text)] = '\0';
}
break;
default:
/* For everything else, just remove the text */
local_text[0] = '\0';
break;
}
}
if (symbol->output_options & BARCODE_STDOUT) {
fsvg = stdout;
} else {
fsvg = fopen(symbol->outfile, "w");
}
if (fsvg == NULL) {
strcpy(symbol->errtxt, "660: Could not open output file");
return ZINT_ERROR_FILE_ACCESS;
}
/* sort out colour options */
to_upper((unsigned char*) symbol->fgcolour);
to_upper((unsigned char*) symbol->bgcolour);
if (strlen(symbol->fgcolour) != 6) {
strcpy(symbol->errtxt, "661: Malformed foreground colour target");
fclose(fsvg);
return ZINT_ERROR_INVALID_OPTION;
}
if (strlen(symbol->bgcolour) != 6) {
strcpy(symbol->errtxt, "662: Malformed background colour target");
fclose(fsvg);
return ZINT_ERROR_INVALID_OPTION;
}
error_number = is_sane(SSET, (unsigned char*) symbol->fgcolour, strlen(symbol->fgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "663: Malformed foreground colour target");
fclose(fsvg);
return ZINT_ERROR_INVALID_OPTION;
}
error_number = is_sane(SSET, (unsigned char*) symbol->bgcolour, strlen(symbol->bgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "664: Malformed background colour target");
fclose(fsvg);
return ZINT_ERROR_INVALID_OPTION;
}
locale = setlocale(LC_ALL, "C");
if (symbol->height == 0) {
symbol->height = 50;
}
large_bar_count = 0;
preset_height = 0.0;
for (i = 0; i < symbol->rows; i++) {
preset_height += symbol->row_height[i];
if (symbol->row_height[i] == 0) {
large_bar_count++;
}
}
large_bar_height = (symbol->height - preset_height) / large_bar_count;
if (large_bar_count == 0) {
symbol->height = preset_height;
}
while (!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
comp_offset++;
}
/* Certain symbols need whitespace otherwise characters get chopped off the sides */
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC))
|| (symbol->symbology == BARCODE_ISBNX)) {
switch (ustrlen(local_text)) {
case 13: /* EAN 13 */
case 16:
case 19:
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
}
main_width = 96 + comp_offset;
break;
default:
main_width = 68 + comp_offset;
}
}
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
main_width = 96 + comp_offset;
}
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
main_width = 51 + comp_offset;
}
}
latch = 0;
r = 0;
/* Isolate add-on text */
if (is_extendable(symbol->symbology)) {
for (i = 0; i < ustrlen(local_text); i++) {
if (latch == 1) {
addon[r] = local_text[i];
r++;
}
if (local_text[i] == '+') {
latch = 1;
}
}
}
addon[r] = '\0';
/* Don't include control characters in output text */
for(i = 0; i < ustrlen(local_text); i++) {
if (local_text[i] < ' ') {
local_text[i] = ' ';
}
}
if (ustrlen(local_text) != 0) {
textoffset = 9;
} else {
textoffset = 0;
}
xoffset = symbol->border_width + symbol->whitespace_width;
yoffset = symbol->border_width;
/* Start writing the header */
fprintf(fsvg, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
fprintf(fsvg, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n");
fprintf(fsvg, " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
if (symbol->symbology != BARCODE_MAXICODE) {
fprintf(fsvg, "<svg width=\"%d\" height=\"%d\" version=\"1.1\"\n", (int) ceil((symbol->width + xoffset + xoffset) * scaler), (int) ceil((symbol->height + textoffset + yoffset + yoffset) * scaler));
} else {
fprintf(fsvg, "<svg width=\"%d\" height=\"%d\" version=\"1.1\"\n", (int) ceil((74.0F + xoffset + xoffset) * scaler), (int) ceil((72.0F + yoffset + yoffset) * scaler));
}
fprintf(fsvg, " xmlns=\"http://www.w3.org/2000/svg\">\n");
if ((ustrlen(local_text) != 0) && (symbol->show_hrt != 0)) {
fprintf(fsvg, " <desc>%s\n", local_text);
} else {
fprintf(fsvg, " <desc>Zint Generated Symbol\n");
}
fprintf(fsvg, " </desc>\n");
fprintf(fsvg, "\n <g id=\"barcode\" fill=\"#%s\">\n", symbol->fgcolour);
if (symbol->symbology != BARCODE_MAXICODE) {
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", (int) ceil((symbol->width + xoffset + xoffset) * scaler), (int) ceil((symbol->height + textoffset + yoffset + yoffset) * scaler), symbol->bgcolour);
} else {
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", (int) ceil((74.0F + xoffset + xoffset) * scaler), (int) ceil((72.0F + yoffset + yoffset) * scaler), symbol->bgcolour);
}
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
default_text_posn = (symbol->height + textoffset + symbol->border_width + symbol->border_width) * scaler;
} else {
default_text_posn = (symbol->height + textoffset + symbol->border_width) * scaler;
}
if (symbol->symbology == BARCODE_MAXICODE) {
/* Maxicode uses hexagons */
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy, mx, my;
textoffset = 0.0;
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, (74.0 + xoffset + xoffset) * scaler, symbol->border_width * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, (72.0 + symbol->border_width) * scaler, (74.0 + xoffset + xoffset) * scaler, symbol->border_width * scaler);
}
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (74.0 + xoffset + xoffset - symbol->border_width) * scaler, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler);
}
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 10.85 * scaler, symbol->fgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 8.97 * scaler, symbol->bgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 7.10 * scaler, symbol->fgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 5.22 * scaler, symbol->bgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 3.31 * scaler, symbol->fgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 1.43 * scaler, symbol->bgcolour);
for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
/* Dump a hexagon */
my = r * 2.135 + 1.43;
ay = my + 1.0 + yoffset;
by = my + 0.5 + yoffset;
cy = my - 0.5 + yoffset;
dy = my - 1.0 + yoffset;
ey = my - 0.5 + yoffset;
fy = my + 0.5 + yoffset;
if (r & 1) {
mx = (2.46 * i) + 1.23 + 1.23;
} else {
mx = (2.46 * i) + 1.23;
}
ax = mx + xoffset;
bx = mx + 0.86 + xoffset;
cx = mx + 0.86 + xoffset;
dx = mx + xoffset;
ex = mx - 0.86 + xoffset;
fx = mx - 0.86 + xoffset;
fprintf(fsvg, " <path d=\"M %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f Z\" />\n", ax * scaler, ay * scaler, bx * scaler, by * scaler, cx * scaler, cy * scaler, dx * scaler, dy * scaler, ex * scaler, ey * scaler, fx * scaler, fy * scaler);
}
}
}
}
if (symbol->symbology != BARCODE_MAXICODE) {
/* everything else uses rectangles (or squares) */
/* Works from the bottom of the symbol up */
int addon_latch = 0;
for (r = 0; r < symbol->rows; r++) {
this_row = r;
if (symbol->row_height[this_row] == 0) {
row_height = large_bar_height;
} else {
row_height = symbol->row_height[this_row];
}
row_posn = 0;
for (i = 0; i < r; i++) {
if (symbol->row_height[i] == 0) {
row_posn += large_bar_height;
} else {
row_posn += symbol->row_height[i];
}
}
row_posn += yoffset;
if (symbol->output_options & BARCODE_DOTTY_MODE) {
/* Use dot mode */
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, this_row, i)) {
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (symbol->dot_size / 2.0) * scaler, symbol->fgcolour);
}
}
} else {
/* Normal mode, with rectangles */
i = 0;
if (module_is_set(symbol, this_row, 0)) {
latch = 1;
} else {
latch = 0;
}
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
if ((addon_latch == 0) && (r == (symbol->rows - 1)) && (i > main_width)) {
addon_text_posn = (row_posn + 8.0) * scaler;
addon_latch = 1;
}
if (latch == 1) {
/* a bar */
if (addon_latch == 0) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset) * scaler, row_posn * scaler, block_width * scaler, row_height * scaler);
} else {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset) * scaler, (row_posn + 10.0) * scaler, block_width * scaler, (row_height - 5.0) * scaler);
}
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < symbol->width);
}
}
}
/* That's done the actual data area, everything else is human-friendly */
xoffset += comp_offset;
row_posn = (row_posn + large_bar_height) * scaler;
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) ||
(symbol->symbology == BARCODE_ISBNX)) {
/* guard bar extensions and text formatting for EAN8 and EAN13 */
switch (ustrlen(local_text)) {
case 8: /* EAN-8 */
case 11:
case 14:
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (32 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (34 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (64 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (66 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
for (i = 0; i < 4; i++) {
textpart[i] = local_text[i];
}
textpart[4] = '\0';
textpos = 17;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 4; i++) {
textpart[i] = local_text[i + 4];
}
textpart[4] = '\0';
textpos = 50;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 86;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 100;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
break;
case 13: /* EAN 13 */
case 16:
case 19:
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (92 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (94 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpart[0] = local_text[0];
textpart[1] = '\0';
textpos = -7;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 1];
}
textpart[6] = '\0';
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 7];
}
textpart[6] = '\0';
textpos = 71;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 114;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 128;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
break;
}
}
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
/* guard bar extensions and text formatting for UPCA */
latch = 1;
i = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 11 + comp_offset);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
latch = 1;
i = 85 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 96 + comp_offset);
textpart[0] = local_text[0];
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 5; i++) {
textpart[i] = local_text[i + 1];
}
textpart[5] = '\0';
textpos = 27;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 5; i++) {
textpart[i] = local_text[i + 6];
}
textpart[6] = '\0';
textpos = 68;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = local_text[11];
textpart[1] = '\0';
textpos = 100;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 116;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 130;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
/* guard bar extensions and text formatting for UPCE */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (50 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpart[0] = local_text[0];
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 1];
}
textpart[6] = '\0';
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = local_text[7];
textpart[1] = '\0';
textpos = 55;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 70;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 84;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
}
xoffset -= comp_offset;
switch (symbol->symbology) {
case BARCODE_MAXICODE:
/* Do nothing! (It's already been done) */
break;
default:
if (symbol->output_options & BARCODE_BIND) {
if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
/* row binding */
if (symbol->symbology != BARCODE_CODABLOCKF) {
for (r = 1; r < symbol->rows; r++) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", xoffset * scaler, ((r * row_height) + yoffset - 1) * scaler, symbol->width * scaler, 2.0 * scaler);
}
} else {
for (r = 1; r < symbol->rows; r++) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (xoffset + 11) * scaler, ((r * row_height) + yoffset - 1) * scaler, (symbol->width - 25) * scaler, 2.0 * scaler);
}
}
}
}
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
if (symbol->symbology != BARCODE_CODABLOCKF) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, (symbol->height + symbol->border_width) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
} else {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", xoffset * scaler, 0.0, symbol->width * scaler, symbol->border_width * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", xoffset * scaler, (symbol->height + symbol->border_width) * scaler, symbol->width * scaler, symbol->border_width * scaler);
}
}
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (symbol->width + xoffset + xoffset - symbol->border_width) * scaler, 0.0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
}
break;
}
/* Put the human readable text at the bottom */
if ((textdone == 0) && ustrlen(local_text)) {
textpos = symbol->width / 2.0;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", local_text);
fprintf(fsvg, " </text>\n");
}
fprintf(fsvg, " </g>\n");
fprintf(fsvg, "</svg>\n");
if (symbol->output_options & BARCODE_STDOUT) {
fflush(fsvg);
} else {
fclose(fsvg);
}
if (locale)
setlocale(LC_ALL, locale);
return error_number;
}

167
3rdparty/zint-2.6.1/backend/telepen.c vendored Normal file
View File

@ -0,0 +1,167 @@
/* telepen.c - Handles Telepen and Telepen numeric */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#define SODIUM "0123456789X"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
static char *TeleTable[] = {
"1111111111111111", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111",
"31333111", "1131113131", "33113131", "1111333111", "3111113131", "1113133111", "1311133111", "111111113131",
"3131113111", "11313331", "333331", "111131113111", "31113331", "1133113111", "1313113111", "1111113331",
"31131331", "113111113111", "3311113111", "1111131331", "311111113111", "1113111331", "1311111331", "11111111113111",
"31313311", "1131311131", "33311131", "1111313311", "3111311131", "11333311", "13133311", "111111311131",
"31331131", "1131113311", "33113311", "1111331131", "3111113311", "1113131131", "1311131131", "111111113311",
"3131111131", "1131131311", "33131311", "111131111131", "3111131311", "1133111131", "1313111131", "111111131311",
"3113111311", "113111111131", "3311111131", "111113111311", "311111111131", "111311111311", "131111111311", "11111111111131",
"3131311111", "11313133", "333133", "111131311111", "31113133", "1133311111", "1313311111", "1111113133",
"313333", "113111311111", "3311311111", "11113333", "311111311111", "11131333", "13111333", "11111111311111",
"31311133", "1131331111", "33331111", " 1111311133", "3111331111", "11331133", "13131133", "111111331111",
"3113131111", "1131111133", "33111133", "111113131111", "3111111133", "111311131111", "131111131111", "111111111133",
"31311313", "113131111111", "3331111111", "1111311313", "311131111111", "11331313", "13131313", "11111131111111",
"3133111111", "1131111313", "33111313", "111133111111", "3111111313", "111313111111", "131113111111", "111111111313",
"313111111111", "1131131113", "33131113", "11113111111111", "3111131113", "113311111111", "131311111111", "111111131113",
"3113111113", "11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113", "131111111113"
};
int telepen(struct zint_symbol *symbol, unsigned char source[], const size_t src_len) {
unsigned int i, count, check_digit;
int error_number;
char dest[512]; /*14 + 30 * 14 + 14 + 14 + 1 ~ 512 */
error_number = 0;
count = 0;
if (src_len > 30) {
strcpy(symbol->errtxt, "390: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Start character */
strcpy(dest, TeleTable['_']);
for (i = 0; i < src_len; i++) {
if (source[i] > 126) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "391: Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
strcat(dest, TeleTable[source[i]]);
count += source[i];
}
check_digit = 127 - (count % 127);
if (check_digit == 127) {
check_digit = 0;
}
strcat(dest, TeleTable[check_digit]);
/* Stop character */
strcat(dest, TeleTable['z']);
expand(symbol, dest);
for (i = 0; i < src_len; i++) {
if (source[i] == '\0') {
symbol->text[i] = ' ';
} else {
symbol->text[i] = source[i];
}
}
symbol->text[src_len] = '\0';
return error_number;
}
int telepen_num(struct zint_symbol *symbol, unsigned char source[], const size_t src_len) {
unsigned int count, check_digit, glyph;
int error_number;
size_t i,temp_length = src_len;
char dest[1024]; /* 14 + 60 * 14 + 14 + 14 + 1 ~ 1024 */
unsigned char temp[64];
count = 0;
if (temp_length > 60) {
strcpy(symbol->errtxt, "392: Input too long");
return ZINT_ERROR_TOO_LONG;
}
ustrcpy(temp, source);
to_upper(temp);
error_number = is_sane(SODIUM, temp, temp_length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "393: Invalid characters in data");
return error_number;
}
/* Add a leading zero if required */
if (temp_length & 1) {
memmove(temp + 1, temp, temp_length);
temp[0] = '0';
temp[++temp_length] = '\0';
}
/* Start character */
strcpy(dest, TeleTable['_']);
for (i = 0; i < temp_length; i += 2) {
if (temp[i] == 'X') {
strcpy(symbol->errtxt, "394: Invalid position of X in Telepen data");
return ZINT_ERROR_INVALID_DATA;
}
if (temp[i + 1] == 'X') {
glyph = ctoi(temp[i]) + 17;
count += glyph;
} else {
glyph = (10 * ctoi(temp[i])) + ctoi(temp[i + 1]);
glyph += 27;
count += glyph;
}
strcat(dest, TeleTable[glyph]);
}
check_digit = 127 - (count % 127);
if (check_digit == 127) {
check_digit = 0;
}
strcat(dest, TeleTable[check_digit]);
/* Stop character */
strcat(dest, TeleTable['z']);
expand(symbol, dest);
ustrcpy(symbol->text, temp);
return error_number;
}

289
3rdparty/zint-2.6.1/backend/tif.c vendored Normal file
View File

@ -0,0 +1,289 @@
/* tif.c - Aldus Tagged Image File Format support */
/*
libzint - the open source barcode library
Copyright (C) 2016-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "common.h"
#include "tif.h"
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#include <malloc.h>
#endif
int tbump_up(int input) {
/* Strings length must be a multiple of 4 bytes */
if ((input % 2) == 1) {
input++;
}
return input;
}
int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
int i;
int rows_per_strip, strip_count;
int free_memory;
int row, column;
FILE *tif_file;
#ifdef _MSC_VER
uint32_t* strip_offset;
uint32_t* strip_bytes;
#endif
tiff_header_t header;
tiff_ifd_t ifd;
uint16_t temp;
uint32_t temp32;
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
rows_per_strip = 8192 / (symbol->bitmap_width * 3);
if (rows_per_strip == 0) {
rows_per_strip = 1;
}
strip_count = symbol->bitmap_height / rows_per_strip;
if ((symbol->bitmap_height % rows_per_strip) != 0) {
strip_count++;
}
#ifndef _MSC_VER
uint32_t strip_offset[strip_count];
uint32_t strip_bytes[strip_count];
#else
strip_offset = (uint32_t*) _alloca(strip_count * sizeof(uint32_t));
strip_bytes = (uint32_t*) _alloca(strip_count * sizeof(uint32_t));
#endif
free_memory = 8;
for(i = 0; i < strip_count; i++) {
strip_offset[i] = free_memory;
if (i != (strip_count - 1)) {
strip_bytes[i] = rows_per_strip * symbol->bitmap_width * 3;
} else {
if ((symbol->bitmap_height % rows_per_strip) != 0) {
strip_bytes[i] = (symbol->bitmap_height % rows_per_strip) * symbol->bitmap_width * 3;
} else {
strip_bytes[i] = rows_per_strip * symbol->bitmap_width * 3;
}
}
free_memory += strip_bytes[i];
if ((free_memory % 2) == 1) {
free_memory++;
}
}
if (free_memory > 0xffff0000) {
#ifdef _MSC_VER
free(strip_offset);
free(strip_bytes);
#endif
strcpy(symbol->errtxt, "670: Output file size too big");
return ZINT_ERROR_MEMORY;
}
/* Open output file in binary mode */
if (symbol->output_options & BARCODE_STDOUT) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "671: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
#endif
tif_file = stdout;
} else {
if (!(tif_file = fopen(symbol->outfile, "wb"))) {
strcpy(symbol->errtxt, "672: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
}
/* Header */
header.byte_order = 0x4949;
header.identity = 42;
header.offset = free_memory;
fwrite(&header, sizeof(tiff_header_t), 1, tif_file);
free_memory += sizeof(tiff_ifd_t);
/* Pixel data */
for (row = 0; row < symbol->bitmap_height; row++) {
for (column = 0; column < symbol->bitmap_width; column++) {
if (pixelbuf[(row * symbol->bitmap_width) + column] == '1') {
putc(fgred, tif_file);
putc(fggrn, tif_file);
putc(fgblu, tif_file);
} else {
putc(bgred, tif_file);
putc(bggrn, tif_file);
putc(bgblu, tif_file);
}
}
if (((row + 1) % rows_per_strip) == 0) {
/* End of a strip */
if ((strip_bytes[0] % 2) == 1) {
/* Add end-of strip pad */
putc(0, tif_file);
}
}
}
/* Image File Directory */
ifd.entries = 14;
ifd.offset = 0;
ifd.new_subset.tag = 0xfe;
ifd.new_subset.type = 4;
ifd.new_subset.count = 1;
ifd.new_subset.offset = 0;
ifd.image_width.tag = 0x0100;
ifd.image_width.type = 3; // SHORT
ifd.image_width.count = 1;
ifd.image_width.offset = symbol->bitmap_width;
ifd.image_length.tag = 0x0101;
ifd.image_length.type = 3; // SHORT
ifd.image_length.count = 1;
ifd.image_length.offset = symbol->bitmap_height;
ifd.bits_per_sample.tag = 0x0102;
ifd.bits_per_sample.type = 3; // SHORT
ifd.bits_per_sample.count = 3;
ifd.bits_per_sample.offset = free_memory;
free_memory += 6;
ifd.compression.tag = 0x0103;
ifd.compression.type = 3;
ifd.compression.count = 1;
ifd.compression.offset = 1; // Uncompressed
ifd.photometric.tag = 0x0106;
ifd.photometric.type = 3; // SHORT
ifd.photometric.count = 1;
ifd.photometric.offset = 2; // RGB Model
ifd.strip_offsets.tag = 0x0111;
ifd.strip_offsets.type = 4; // LONG
ifd.strip_offsets.count = strip_count;
ifd.strip_offsets.offset = free_memory;
free_memory += strip_count * 4;
ifd.samples_per_pixel.tag = 0x0115;
ifd.samples_per_pixel.type = 3;
ifd.samples_per_pixel.count = 1;
ifd.samples_per_pixel.offset = 3;
ifd.rows_per_strip.tag = 0x0116;
ifd.rows_per_strip.type = 4;
ifd.rows_per_strip.count = 1;
ifd.rows_per_strip.offset = rows_per_strip;
ifd.strip_byte_counts.tag = 0x0117;
ifd.strip_byte_counts.type = 4;
ifd.strip_byte_counts.count = strip_count;
ifd.strip_byte_counts.offset = free_memory;
free_memory += strip_count * 4;
ifd.x_resolution.tag = 0x011a;
ifd.x_resolution.type = 5;
ifd.x_resolution.count = 1;
ifd.x_resolution.offset = free_memory;
free_memory += 8;
ifd.y_resolution.tag = 0x011b;
ifd.y_resolution.type = 5;
ifd.y_resolution.count = 1;
ifd.y_resolution.offset = free_memory;
free_memory += 8;
ifd.planar_config.tag = 0x11c;
ifd.planar_config.type = 3;
ifd.planar_config.count = 1;
ifd.planar_config.offset = 1;
ifd.resolution_unit.tag = 0x0128;
ifd.resolution_unit.type = 3;
ifd.resolution_unit.count = 1;
ifd.resolution_unit.offset = 2; // Inches
fwrite(&ifd, sizeof(tiff_ifd_t), 1, tif_file);
/* Bits per sample */
temp = 8;
fwrite(&temp, 2, 1, tif_file); // Red Bytes
fwrite(&temp, 2, 1, tif_file); // Green Bytes
fwrite(&temp, 2, 1, tif_file); // Blue Bytes
/* Strip offsets */
for(i = 0; i < strip_count; i++) {
fwrite(&strip_offset[i], 4, 1, tif_file);
}
/* Strip byte lengths */
for(i = 0; i < strip_count; i++) {
fwrite(&strip_bytes[i], 4, 1, tif_file);
}
/* X Resolution */
temp32 = 72;
fwrite(&temp32, 4, 1, tif_file);
temp32 = 1;
fwrite(&temp32, 4, 1, tif_file);
/* Y Resolution */
temp32 = 72;
fwrite(&temp32, 4, 1, tif_file);
temp32 = 1;
fwrite(&temp32, 4, 1, tif_file);
if (symbol->output_options & BARCODE_STDOUT) {
fflush(tif_file);
} else {
fclose(tif_file);
}
#ifdef _MSC_VER
free(strip_offset);
free(strip_bytes);
#endif
return 0;
}

87
3rdparty/zint-2.6.1/backend/tif.h vendored Normal file
View File

@ -0,0 +1,87 @@
/* tif.h - Aldus Tagged Image File Format */
/*
libzint - the open source barcode library
Copyright (C) 2016-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef TIF_H
#define TIF_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
#pragma pack(1)
typedef struct tiff_header {
uint16_t byte_order;
uint16_t identity;
uint32_t offset;
} tiff_header_t;
typedef struct tiff_tag {
uint16_t tag;
uint16_t type;
uint32_t count;
uint32_t offset;
} tiff_tag_t;
typedef struct tiff_ifd {
uint16_t entries;
tiff_tag_t new_subset;
tiff_tag_t image_width;
tiff_tag_t image_length;
tiff_tag_t bits_per_sample;
tiff_tag_t compression;
tiff_tag_t photometric;
tiff_tag_t strip_offsets;
tiff_tag_t samples_per_pixel;
tiff_tag_t rows_per_strip;
tiff_tag_t strip_byte_counts;
tiff_tag_t x_resolution;
tiff_tag_t y_resolution;
tiff_tag_t planar_config;
tiff_tag_t resolution_unit;
uint32_t offset;
} tiff_ifd_t;
#pragma pack()
#ifdef __cplusplus
}
#endif
#endif /* TIF_H */

936
3rdparty/zint-2.6.1/backend/upcean.c vendored Normal file
View File

@ -0,0 +1,936 @@
/* upcean.c - Handles UPC, EAN and ISBN
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#define SODIUM "0123456789+"
#define EAN2 102
#define EAN5 105
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common.h"
/* UPC and EAN tables checked against EN 797:1996 */
static const char *UPCParity0[10] = {
/* Number set for UPC-E symbol (EN Table 4) */
"BBBAAA", "BBABAA", "BBAABA", "BBAAAB", "BABBAA", "BAABBA", "BAAABB",
"BABABA", "BABAAB", "BAABAB"
};
static const char *UPCParity1[10] = {
/* Not covered by BS EN 797:1995 */
"AAABBB", "AABABB", "AABBAB", "AABBBA", "ABAABB", "ABBAAB", "ABBBAA",
"ABABAB", "ABABBA", "ABBABA"
};
static const char *EAN2Parity[4] = {
/* Number sets for 2-digit add-on (EN Table 6) */
"AA", "AB", "BA", "BB"
};
static const char *EAN5Parity[10] = {
/* Number set for 5-digit add-on (EN Table 7) */
"BBAAA", "BABAA", "BAABA", "BAAAB", "ABBAA", "AABBA", "AAABB", "ABABA",
"ABAAB", "AABAB"
};
static const char *EAN13Parity[10] = {
/* Left hand of the EAN-13 symbol (EN Table 3) */
"AAAAA", "ABABB", "ABBAB", "ABBBA", "BAABB", "BBAAB", "BBBAA", "BABAB",
"BABBA", "BBABA"
};
static const char *EANsetA[10] = {
/* Representation set A and C (EN Table 1) */
"3211", "2221", "2122", "1411", "1132", "1231", "1114", "1312", "1213", "3112"
};
static const char *EANsetB[10] = {
/* Representation set B (EN Table 1) */
"1123", "1222", "2212", "1141", "2311", "1321", "4111", "2131", "3121", "2113"
};
/* Calculate the correct check digit for a UPC barcode */
char upc_check(char source[]) {
unsigned int i, count, check_digit;
count = 0;
for (i = 0; i < strlen(source); i++) {
count += ctoi(source[i]);
if (!(i & 1)) {
count += 2 * (ctoi(source[i]));
}
}
check_digit = 10 - (count % 10);
if (check_digit == 10) {
check_digit = 0;
}
return itoc(check_digit);
}
/* UPC A is usually used for 12 digit numbers, but this function takes a source of any length */
void upca_draw(char source[], char dest[]) {
unsigned int i, half_way;
half_way = strlen(source) / 2;
/* start character */
strcat(dest, "111");
for (i = 0; i <= strlen(source); i++) {
if (i == half_way) {
/* middle character - separates manufacturer no. from product no. */
/* also inverts right hand characters */
strcat(dest, "11111");
}
lookup(NEON, EANsetA, source[i], dest);
}
/* stop character */
strcat(dest, "111");
}
/* Make a UPC A barcode when we haven't been given the check digit */
int upca(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
int length;
char gtin[15];
strcpy(gtin, (char*) source);
length = strlen(gtin);
if (length == 11) {
gtin[length] = upc_check(gtin);
gtin[length + 1] = '\0';
} else {
gtin[length - 1] = '\0';
if (source[length - 1] != upc_check(gtin)) {
strcpy(symbol->errtxt, "270: Invalid check digit");
return ZINT_ERROR_INVALID_DATA;
}
gtin[length - 1] = upc_check(gtin);
}
upca_draw(gtin, dest);
ustrcpy(symbol->text, (unsigned char*) gtin);
return 0;
}
/* UPC E is a zero-compressed version of UPC A */
int upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
unsigned int i, num_system;
char emode, equivalent[12], check_digit, parity[8], temp[8];
char hrt[9];
/* Two number systems can be used - system 0 and system 1 */
if (symbol->symbology != BARCODE_UPCE_CHK) {
/* No check digit in input data */
if (ustrlen(source) == 7) {
switch (source[0]) {
case '0': num_system = 0;
break;
case '1': num_system = 1;
break;
default: num_system = 0;
source[0] = '0';
break;
}
strcpy(temp, (char*) source);
strcpy(hrt, (char*) source);
for (i = 1; i <= 7; i++) {
source[i - 1] = temp[i];
}
} else {
num_system = 0;
hrt[0] = '0';
hrt[1] = '\0';
strcat(hrt, (char*) source);
}
} else {
/* Check digit is included in input data */
if (ustrlen(source) == 8) {
switch (source[0]) {
case '0': num_system = 0;
break;
case '1': num_system = 1;
break;
default: num_system = 0;
source[0] = '0';
break;
}
strcpy(temp, (char*) source);
strcpy(hrt, (char*) source);
for (i = 1; i <= 7; i++) {
source[i - 1] = temp[i];
}
} else {
num_system = 0;
hrt[0] = '0';
hrt[1] = '\0';
strcat(hrt, (char*) source);
}
}
/* Expand the zero-compressed UPCE code to make a UPCA equivalent (EN Table 5) */
emode = source[5];
for (i = 0; i < 11; i++) {
equivalent[i] = '0';
}
if (num_system == 1) {
equivalent[0] = temp[0];
}
equivalent[1] = source[0];
equivalent[2] = source[1];
equivalent[11] = '\0';
switch (emode) {
case '0':
case '1':
case '2':
equivalent[3] = emode;
equivalent[8] = source[2];
equivalent[9] = source[3];
equivalent[10] = source[4];
break;
case '3':
equivalent[3] = source[2];
equivalent[9] = source[3];
equivalent[10] = source[4];
if (((source[2] == '0') || (source[2] == '1')) || (source[2] == '2')) {
/* Note 1 - "X3 shall not be equal to 0, 1 or 2" */
strcpy(symbol->errtxt, "271: Invalid UPC-E data");
return ZINT_ERROR_INVALID_DATA;
}
break;
case '4':
equivalent[3] = source[2];
equivalent[4] = source[3];
equivalent[10] = source[4];
if (source[3] == '0') {
/* Note 2 - "X4 shall not be equal to 0" */
strcpy(symbol->errtxt, "272: Invalid UPC-E data");
return ZINT_ERROR_INVALID_DATA;
}
break;
case '5':
case '6':
case '7':
case '8':
case '9':
equivalent[3] = source[2];
equivalent[4] = source[3];
equivalent[5] = source[4];
equivalent[10] = emode;
if (source[4] == '0') {
/* Note 3 - "X5 shall not be equal to 0" */
strcpy(symbol->errtxt, "273: Invalid UPC-E data");
return ZINT_ERROR_INVALID_DATA;
}
break;
}
/* Get the check digit from the expanded UPCA code */
check_digit = upc_check(equivalent);
/* Use the number system and check digit information to choose a parity scheme */
if (num_system == 1) {
strcpy(parity, UPCParity1[ctoi(check_digit)]);
} else {
strcpy(parity, UPCParity0[ctoi(check_digit)]);
}
/* Take all this information and make the barcode pattern */
/* start character */
strcat(dest, "111");
for (i = 0; i <= ustrlen(source); i++) {
switch (parity[i]) {
case 'A': lookup(NEON, EANsetA, source[i], dest);
break;
case 'B': lookup(NEON, EANsetB, source[i], dest);
break;
}
}
/* stop character */
strcat(dest, "111111");
if (symbol->symbology != BARCODE_UPCE_CHK) {
hrt[7] = check_digit;
hrt[8] = '\0';
} else {
if (hrt[7] != check_digit) {
strcpy(symbol->errtxt, "274: Invalid check digit");
return ZINT_ERROR_INVALID_DATA;
}
}
ustrcpy(symbol->text, (unsigned char*) hrt);
return 0;
}
/* EAN-2 and EAN-5 add-on codes */
void add_on(unsigned char source[], char dest[], int mode) {
char parity[6];
unsigned int i, code_type;
/* If an add-on then append with space */
if (mode != 0) {
strcat(dest, "9");
}
/* Start character */
strcat(dest, "112");
/* Determine EAN2 or EAN5 add-on */
if (ustrlen(source) == 2) {
code_type = EAN2;
} else {
code_type = EAN5;
}
/* Calculate parity for EAN2 */
if (code_type == EAN2) {
int code_value, parity_bit;
code_value = (10 * ctoi(source[0])) + ctoi(source[1]);
parity_bit = code_value % 4;
strcpy(parity, EAN2Parity[parity_bit]);
}
if (code_type == EAN5) {
int values[6], parity_sum, parity_bit;
for (i = 0; i < 6; i++) {
values[i] = ctoi(source[i]);
}
parity_sum = (3 * (values[0] + values[2] + values[4]));
parity_sum += (9 * (values[1] + values[3]));
parity_bit = parity_sum % 10;
strcpy(parity, EAN5Parity[parity_bit]);
}
for (i = 0; i < ustrlen(source); i++) {
switch (parity[i]) {
case 'A': lookup(NEON, EANsetA, source[i], dest);
break;
case 'B': lookup(NEON, EANsetB, source[i], dest);
break;
}
/* Glyph separator */
if (i != (ustrlen(source) - 1)) {
strcat(dest, "11");
}
}
}
/* ************************ EAN-13 ****************** */
/* Calculate the correct check digit for a EAN-13 barcode */
char ean_check(char source[]) {
int i;
unsigned int h, count, check_digit;
count = 0;
h = strlen(source);
for (i = h - 1; i >= 0; i--) {
count += ctoi(source[i]);
if (i & 1) {
count += 2 * ctoi(source[i]);
}
}
check_digit = 10 - (count % 10);
if (check_digit == 10) {
check_digit = 0;
}
return itoc(check_digit);
}
int ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
unsigned int length, i, half_way;
char parity[6];
char gtin[15];
strcpy(parity, "");
strcpy(gtin, (char*) source);
/* Add the appropriate check digit */
length = strlen(gtin);
if (length == 12) {
gtin[length] = ean_check(gtin);
gtin[length + 1] = '\0';
} else {
gtin[length - 1] = '\0';
if (source[length - 1] != ean_check(gtin)) {
strcpy(symbol->errtxt, "275: Invalid check digit");
return ZINT_ERROR_INVALID_DATA;
}
gtin[length - 1] = ean_check(gtin);
}
/* Get parity for first half of the symbol */
lookup(SODIUM, EAN13Parity, gtin[0], parity);
/* Now get on with the cipher */
half_way = 7;
/* start character */
strcat(dest, "111");
length = strlen(gtin);
for (i = 1; i <= length; i++) {
if (i == half_way) {
/* middle character - separates manufacturer no. from product no. */
/* also inverses right hand characters */
strcat(dest, "11111");
}
if (((i > 1) && (i < 7)) && (parity[i - 2] == 'B')) {
lookup(NEON, EANsetB, gtin[i], dest);
} else {
lookup(NEON, EANsetA, gtin[i], dest);
}
}
/* stop character */
strcat(dest, "111");
ustrcpy(symbol->text, (unsigned char*) gtin);
return 0;
}
/* Make an EAN-8 barcode when we haven't been given the check digit */
int ean8(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
/* EAN-8 is basically the same as UPC-A but with fewer digits */
int length;
char gtin[10];
strcpy(gtin, (char*) source);
length = strlen(gtin);
if (length == 7) {
gtin[length] = upc_check(gtin);
gtin[length + 1] = '\0';
} else {
gtin[length - 1] = '\0';
if (source[length - 1] != upc_check(gtin)) {
strcpy(symbol->errtxt, "276: Invalid check digit");
return ZINT_ERROR_INVALID_DATA;
}
gtin[length - 1] = upc_check(gtin);
}
upca_draw(gtin, dest);
ustrcpy(symbol->text, (unsigned char*) gtin);
return 0;
}
/* For ISBN(13) only */
char isbn13_check(unsigned char source[]) {
unsigned int i, weight, sum, check, h;
sum = 0;
weight = 1;
h = ustrlen(source) - 1;
for (i = 0; i < h; i++) {
sum += ctoi(source[i]) * weight;
if (weight == 1) weight = 3;
else weight = 1;
}
check = sum % 10;
check = 10 - check;
if (check == 10) check = 0;
return itoc(check);
}
/* For ISBN(10) and SBN only */
char isbn_check(unsigned char source[]) {
unsigned int i, weight, sum, check, h;
char check_char;
sum = 0;
weight = 1;
h = ustrlen(source) - 1;
for (i = 0; i < h; i++) {
sum += ctoi(source[i]) * weight;
weight++;
}
check = sum % 11;
check_char = itoc(check);
if (check == 10) {
check_char = 'X';
}
return check_char;
}
/* Make an EAN-13 barcode from an SBN or ISBN */
static int isbn(struct zint_symbol *symbol, unsigned char source[], const size_t src_len, char dest[]) {
int i, error_number;
char check_digit;
to_upper(source);
error_number = is_sane("0123456789X", source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "277: Invalid characters in input");
return error_number;
}
/* Input must be 9, 10 or 13 characters */
if (((src_len < 9) || (src_len > 13)) || ((src_len > 10) && (src_len < 13))) {
strcpy(symbol->errtxt, "278: Input wrong length");
return ZINT_ERROR_TOO_LONG;
}
if (src_len == 13) /* Using 13 character ISBN */ {
if (!(((source[0] == '9') && (source[1] == '7')) &&
((source[2] == '8') || (source[2] == '9')))) {
strcpy(symbol->errtxt, "279: Invalid ISBN");
return ZINT_ERROR_INVALID_DATA;
}
check_digit = isbn13_check(source);
if (source[src_len - 1] != check_digit) {
strcpy(symbol->errtxt, "280: Incorrect ISBN check");
return ZINT_ERROR_INVALID_CHECK;
}
source[12] = '\0';
ean13(symbol, source, dest);
}
if (src_len == 10) /* Using 10 digit ISBN */ {
check_digit = isbn_check(source);
if (check_digit != source[src_len - 1]) {
strcpy(symbol->errtxt, "281: Incorrect ISBN check");
return ZINT_ERROR_INVALID_CHECK;
}
for (i = 13; i > 0; i--) {
source[i] = source[i - 3];
}
source[0] = '9';
source[1] = '7';
source[2] = '8';
source[12] = '\0';
ean13(symbol, source, dest);
}
if (src_len == 9) /* Using 9 digit SBN */ {
/* Add leading zero */
for (i = 10; i > 0; i--) {
source[i] = source[i - 1];
}
source[0] = '0';
/* Verify check digit */
check_digit = isbn_check(source);
if (check_digit != source[ustrlen(source) - 1]) {
strcpy(symbol->errtxt, "282: Incorrect SBN check");
return ZINT_ERROR_INVALID_CHECK;
}
/* Convert to EAN-13 number */
for (i = 13; i > 0; i--) {
source[i] = source[i - 3];
}
source[0] = '9';
source[1] = '7';
source[2] = '8';
source[12] = '\0';
ean13(symbol, source, dest);
}
return 0;
}
/* Add leading zeroes to EAN and UPC strings */
void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsigned char local_source[]) {
unsigned char first_part[20], second_part[20], zfirst_part[20], zsecond_part[20];
int with_addon = 0;
int first_len = 0, second_len = 0, zfirst_len = 0, zsecond_len = 0, i, h;
h = ustrlen(source);
for (i = 0; i < h; i++) {
if (source[i] == '+') {
with_addon = 1;
} else {
if (with_addon == 0) {
first_len++;
} else {
second_len++;
}
}
}
ustrcpy(first_part, (unsigned char *) "");
ustrcpy(second_part, (unsigned char *) "");
ustrcpy(zfirst_part, (unsigned char *) "");
ustrcpy(zsecond_part, (unsigned char *) "");
/* Split input into two strings */
for (i = 0; i < first_len; i++) {
first_part[i] = source[i];
first_part[i + 1] = '\0';
}
for (i = 0; i < second_len; i++) {
second_part[i] = source[i + first_len + 1];
second_part[i + 1] = '\0';
}
/* Calculate target lengths */
if (second_len <= 5) {
zsecond_len = 5;
}
if (second_len <= 2) {
zsecond_len = 2;
}
if (second_len == 0) {
zsecond_len = 0;
}
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CC:
if (first_len <= 12) {
zfirst_len = 12;
}
if (first_len <= 7) {
zfirst_len = 7;
}
if (second_len == 0) {
if (first_len <= 5) {
zfirst_len = 5;
}
if (first_len <= 2) {
zfirst_len = 2;
}
}
break;
case BARCODE_EANX_CHK:
if (first_len <= 13) {
zfirst_len = 13;
}
if (first_len <= 8) {
zfirst_len = 8;
}
if (second_len == 0) {
if (first_len <= 5) {
zfirst_len = 5;
}
if (first_len <= 2) {
zfirst_len = 2;
}
}
break;
case BARCODE_UPCA:
case BARCODE_UPCA_CC:
zfirst_len = 11;
break;
case BARCODE_UPCA_CHK:
zfirst_len = 12;
break;
case BARCODE_UPCE:
case BARCODE_UPCE_CC:
if (first_len == 7) {
zfirst_len = 7;
}
if (first_len <= 6) {
zfirst_len = 6;
}
break;
case BARCODE_UPCE_CHK:
if (first_len == 8) {
zfirst_len = 8;
}
if (first_len <= 7) {
zfirst_len = 7;
}
break;
case BARCODE_ISBNX:
if (first_len <= 9) {
zfirst_len = 9;
}
break;
}
/* Add leading zeroes */
for (i = 0; i < (zfirst_len - first_len); i++) {
strcat((char*) zfirst_part, "0");
}
strcat((char*) zfirst_part, (char*) first_part);
for (i = 0; i < (zsecond_len - second_len); i++) {
strcat((char*) zsecond_part, "0");
}
strcat((char*) zsecond_part, (char*) second_part);
/* Copy adjusted data back to local_source */
strcat((char*) local_source, (char*) zfirst_part);
if (zsecond_len != 0) {
strcat((char*) local_source, "+");
strcat((char*) local_source, (char*) zsecond_part);
}
}
/* splits string to parts before and after '+' parts */
int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
unsigned char first_part[20] = {0}, second_part[20] = {0}, dest[1000] = {0};
unsigned char local_source[20] = {0};
unsigned int latch, reader, writer, with_addon;
int error_number, i;
with_addon = FALSE;
latch = FALSE;
writer = 0;
if (src_len > 19) {
strcpy(symbol->errtxt, "283: Input too long");
return ZINT_ERROR_TOO_LONG;
}
if (symbol->symbology != BARCODE_ISBNX) {
/* ISBN has it's own checking routine */
error_number = is_sane("0123456789+", source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "284: Invalid characters in data");
return error_number;
}
} else {
error_number = is_sane("0123456789Xx", source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "285: Invalid characters in input");
return error_number;
}
}
/* Add leading zeroes */
ustrcpy(local_source, (unsigned char *) "");
if (symbol->symbology == BARCODE_ISBNX) {
to_upper(local_source);
}
ean_leading_zeroes(symbol, source, local_source);
for (reader = 0; reader < ustrlen(local_source); reader++) {
if (local_source[reader] == '+') {
with_addon = TRUE;
}
}
reader = 0;
if (with_addon) {
do {
if (local_source[reader] == '+') {
first_part[writer] = '\0';
latch = TRUE;
reader++;
writer = 0;
}
if (latch) {
second_part[writer] = local_source[reader];
reader++;
writer++;
} else {
first_part[writer] = local_source[reader];
reader++;
writer++;
}
} while (reader <= ustrlen(local_source));
} else {
strcpy((char*) first_part, (char*) local_source);
}
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CHK:
switch (ustrlen(first_part)) {
case 2: add_on(first_part, (char*) dest, 0);
ustrcpy(symbol->text, first_part);
break;
case 5: add_on(first_part, (char*) dest, 0);
ustrcpy(symbol->text, first_part);
break;
case 7:
case 8: error_number = ean8(symbol, first_part, (char*) dest);
break;
case 12:
case 13: error_number = ean13(symbol, first_part, (char*) dest);
break;
default: strcpy(symbol->errtxt, "286: Invalid length input");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_EANX_CC:
switch (ustrlen(first_part)) { /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */
case 7: set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 67);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 68);
set_module(symbol, symbol->rows + 2, 1);
set_module(symbol, symbol->rows + 1, 67);
symbol->row_height[symbol->rows] = 2;
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
error_number = ean8(symbol, first_part, (char*) dest);
break;
case 12:set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 95);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 96);
set_module(symbol, symbol->rows + 2, 1);
set_module(symbol, symbol->rows + 2, 95);
symbol->row_height[symbol->rows] = 2;
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
error_number = ean13(symbol, first_part, (char*) dest);
break;
default: strcpy(symbol->errtxt, "287: Invalid length EAN input");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_UPCA:
case BARCODE_UPCA_CHK:
if ((ustrlen(first_part) == 11) || (ustrlen(first_part) == 12)) {
error_number = upca(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "288: Input wrong length (C6I)");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_UPCA_CC:
if (ustrlen(first_part) == 11) {
set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 95);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 96);
set_module(symbol, symbol->rows + 2, 1);
set_module(symbol, symbol->rows + 2, 95);
symbol->row_height[symbol->rows] = 2;
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
error_number = upca(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "289: UPCA input wrong length");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_UPCE:
case BARCODE_UPCE_CHK:
if ((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 8)) {
error_number = upce(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "290: Input wrong length");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_UPCE_CC:
if ((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 7)) {
set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 51);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 52);
set_module(symbol, symbol->rows + 2, 1);
set_module(symbol, symbol->rows + 2, 51);
symbol->row_height[symbol->rows] = 2;
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
error_number = upce(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "291: UPCE input wrong length");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_ISBNX:
error_number = isbn(symbol, first_part, ustrlen(first_part), (char*) dest);
break;
}
if (error_number > 4) {
return error_number;
}
switch (ustrlen(second_part)) {
case 0: break;
case 2:
add_on(second_part, (char*) dest, 1);
strcat((char*) symbol->text, "+");
strcat((char*) symbol->text, (char*) second_part);
break;
case 5:
add_on(second_part, (char*) dest, 1);
strcat((char*) symbol->text, "+");
strcat((char*) symbol->text, (char*) second_part);
break;
default:
strcpy(symbol->errtxt, "292: Invalid length input");
return ZINT_ERROR_TOO_LONG;
}
expand(symbol, (char*) dest);
switch (symbol->symbology) {
case BARCODE_EANX_CC:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
/* shift the symbol to the right one space to allow for separator bars */
for (i = (symbol->width + 1); i >= 1; i--) {
if (module_is_set(symbol, symbol->rows - 1, i - 1)) {
set_module(symbol, symbol->rows - 1, i);
} else {
unset_module(symbol, symbol->rows - 1, i);
}
}
unset_module(symbol, symbol->rows - 1, 0);
symbol->width += 2;
break;
}
return 0;
}

283
3rdparty/zint-2.6.1/backend/zint.h vendored Normal file
View File

@ -0,0 +1,283 @@
/* zint.h - definitions for libzint
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef ZINT_H
#define ZINT_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct zint_render_line {
float x, y, length, width;
struct zint_render_line *next; /* Pointer to next line */
};
struct zint_render_string {
float x, y, fsize;
float width; /* Suggested string width, may be 0 if none recommended */
int length;
unsigned char *text;
struct zint_render_string *next; /* Pointer to next character */
};
struct zint_render_ring {
float x, y, radius, line_width;
struct zint_render_ring *next; /* Pointer to next ring */
};
struct zint_render_hexagon {
float x, y;
struct zint_render_hexagon *next; /* Pointer to next hexagon */
};
struct zint_render {
float width, height;
struct zint_render_line *lines; /* Pointer to first line */
struct zint_render_string *strings; /* Pointer to first string */
struct zint_render_ring *rings; /* Pointer to first ring */
struct zint_render_hexagon *hexagons; /* Pointer to first hexagon */
};
struct zint_symbol {
int symbology;
int height;
int whitespace_width;
int border_width;
int output_options;
char fgcolour[10];
char bgcolour[10];
char outfile[256];
float scale;
int option_1;
int option_2;
int option_3;
int show_hrt;
int input_mode;
int eci;
unsigned char text[128];
int rows;
int width;
char primary[128];
unsigned char encoded_data[200][143];
int row_height[200]; /* Largest symbol is 189 x 189 Han Xin */
char errtxt[100];
char *bitmap;
int bitmap_width;
int bitmap_height;
unsigned int bitmap_byte_length;
float dot_size;
struct zint_render *rendered;
int debug;
};
#define ZINT_VERSION_MAJOR 2
#define ZINT_VERSION_MINOR 6
#define ZINT_VERSION_RELEASE 1
/* Tbarcode 7 codes */
#define BARCODE_CODE11 1
#define BARCODE_C25MATRIX 2
#define BARCODE_C25INTER 3
#define BARCODE_C25IATA 4
#define BARCODE_C25LOGIC 6
#define BARCODE_C25IND 7
#define BARCODE_CODE39 8
#define BARCODE_EXCODE39 9
#define BARCODE_EANX 13
#define BARCODE_EANX_CHK 14
#define BARCODE_EAN128 16
#define BARCODE_CODABAR 18
#define BARCODE_CODE128 20
#define BARCODE_DPLEIT 21
#define BARCODE_DPIDENT 22
#define BARCODE_CODE16K 23
#define BARCODE_CODE49 24
#define BARCODE_CODE93 25
#define BARCODE_FLAT 28
#define BARCODE_RSS14 29
#define BARCODE_RSS_LTD 30
#define BARCODE_RSS_EXP 31
#define BARCODE_TELEPEN 32
#define BARCODE_UPCA 34
#define BARCODE_UPCA_CHK 35
#define BARCODE_UPCE 37
#define BARCODE_UPCE_CHK 38
#define BARCODE_POSTNET 40
#define BARCODE_MSI_PLESSEY 47
#define BARCODE_FIM 49
#define BARCODE_LOGMARS 50
#define BARCODE_PHARMA 51
#define BARCODE_PZN 52
#define BARCODE_PHARMA_TWO 53
#define BARCODE_PDF417 55
#define BARCODE_PDF417TRUNC 56
#define BARCODE_MAXICODE 57
#define BARCODE_QRCODE 58
#define BARCODE_CODE128B 60
#define BARCODE_AUSPOST 63
#define BARCODE_AUSREPLY 66
#define BARCODE_AUSROUTE 67
#define BARCODE_AUSREDIRECT 68
#define BARCODE_ISBNX 69
#define BARCODE_RM4SCC 70
#define BARCODE_DATAMATRIX 71
#define BARCODE_EAN14 72
#define BARCODE_CODABLOCKF 74
#define BARCODE_NVE18 75
#define BARCODE_JAPANPOST 76
#define BARCODE_KOREAPOST 77
#define BARCODE_RSS14STACK 79
#define BARCODE_RSS14STACK_OMNI 80
#define BARCODE_RSS_EXPSTACK 81
#define BARCODE_PLANET 82
#define BARCODE_MICROPDF417 84
#define BARCODE_ONECODE 85
#define BARCODE_PLESSEY 86
/* Tbarcode 8 codes */
#define BARCODE_TELEPEN_NUM 87
#define BARCODE_ITF14 89
#define BARCODE_KIX 90
#define BARCODE_AZTEC 92
#define BARCODE_DAFT 93
#define BARCODE_MICROQR 97
/* Tbarcode 9 codes */
#define BARCODE_HIBC_128 98
#define BARCODE_HIBC_39 99
#define BARCODE_HIBC_DM 102
#define BARCODE_HIBC_QR 104
#define BARCODE_HIBC_PDF 106
#define BARCODE_HIBC_MICPDF 108
#define BARCODE_HIBC_BLOCKF 110
#define BARCODE_HIBC_AZTEC 112
/* Tbarcode 10 codes */
#define BARCODE_DOTCODE 115
#define BARCODE_HANXIN 116
/* Zint specific */
#define BARCODE_AZRUNE 128
#define BARCODE_CODE32 129
#define BARCODE_EANX_CC 130
#define BARCODE_EAN128_CC 131
#define BARCODE_RSS14_CC 132
#define BARCODE_RSS_LTD_CC 133
#define BARCODE_RSS_EXP_CC 134
#define BARCODE_UPCA_CC 135
#define BARCODE_UPCE_CC 136
#define BARCODE_RSS14STACK_CC 137
#define BARCODE_RSS14_OMNI_CC 138
#define BARCODE_RSS_EXPSTACK_CC 139
#define BARCODE_CHANNEL 140
#define BARCODE_CODEONE 141
#define BARCODE_GRIDMATRIX 142
#define BARCODE_UPNQR 143
// Output options
#define BARCODE_NO_ASCII 1
#define BARCODE_BIND 2
#define BARCODE_BOX 4
#define BARCODE_STDOUT 8
#define READER_INIT 16
#define SMALL_TEXT 32
#define BOLD_TEXT 64
#define CMYK_COLOUR 128
#define BARCODE_DOTTY_MODE 256
// Input data types
#define DATA_MODE 0
#define UNICODE_MODE 1
#define GS1_MODE 2
#define KANJI_MODE 3
#define SJIS_MODE 4
// Data Matrix specific options
#define DM_SQUARE 100
#define DM_DMRE 101
// Warning and error conditions
#define ZINT_WARN_INVALID_OPTION 2
#define ZINT_WARN_USES_ECI 3
#define ZINT_ERROR_TOO_LONG 5
#define ZINT_ERROR_INVALID_DATA 6
#define ZINT_ERROR_INVALID_CHECK 7
#define ZINT_ERROR_INVALID_OPTION 8
#define ZINT_ERROR_ENCODING_PROBLEM 9
#define ZINT_ERROR_FILE_ACCESS 10
#define ZINT_ERROR_MEMORY 11
// Raster file types
#define OUT_BUFFER 0
#define OUT_PNG_FILE 100
#define OUT_BMP_FILE 120
#define OUT_GIF_FILE 140
#define OUT_PCX_FILE 160
#define OUT_JPG_FILE 180
#define OUT_TIF_FILE 200
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(_MSC_VER)
#if defined (DLL_EXPORT) || defined(PIC) || defined(_USRDLL)
#define ZINT_EXTERN __declspec(dllexport)
#elif defined(ZINT_DLL)
#define ZINT_EXTERN __declspec(dllimport)
#else
#define ZINT_EXTERN extern
#endif
#else
#define ZINT_EXTERN extern
#endif
ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
ZINT_EXTERN void ZBarcode_Clear(struct zint_symbol *symbol);
ZINT_EXTERN void ZBarcode_Delete(struct zint_symbol *symbol);
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *input, int length);
ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename);
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
ZINT_EXTERN int ZBarcode_Render(struct zint_symbol *symbol, const float width, const float height);
ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle);
ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
ZINT_EXTERN int ZBarcode_Version();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ZINT_H */

View File

@ -0,0 +1,21 @@
# (c) 2008 by BogDan Vatra < bogdan@licentia.eu >
project(QZint)
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend" )
set(QZint_SRCS qzint.cpp)
add_library(QZint SHARED ${QZint_SRCS})
set_target_properties(QZint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
VERSION ${ZINT_VERSION})
add_dependencies(QZint zint)
link_directories( "${CMAKE_BINARY_DIR}/backend" )
target_link_libraries(QZint zint Qt5::Widgets Qt5::Gui )
install(TARGETS QZint ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(FILES qzint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)

View File

@ -0,0 +1,120 @@
DEFINES += NO_PNG
TEMPLATE = lib
contains(CONFIG, static_build){
CONFIG += staticlib
DEFINES += HAVE_STATIC_BUILD
}
!contains(CONFIG, staticlib){
CONFIG += dll
DEFINES += QZINT_LIBRARY
}
include(../../../common.pri)
macx{
CONFIG -= dll
CONFIG += lib_bundle
}
unix{
CONFIG += plugin
}
#VERSION = 2.4.4
INCLUDEPATH += $$PWD/../backend
DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS ZINT_VERSION=\\\"$$VERSION\\\"
contains(CONFIG,release) {
TARGET = QtZint
} else {
TARGET = QtZintd
}
!contains(DEFINES, NO_PNG) {
SOURCES += $$PWD/../backend/png.c
LIBS += -lpng
}
win32-msvc* {
DEFINES += _CRT_SECURE_NO_WARNINGS
#QMAKE_CFLAGS += /TP /wd4018 /wd4244 /wd4305
#QMAKE_CXXFLAGS += /TP /wd4018 /wd4244 /wd4305
}
INCLUDEPATH += zint zint/backend zint/backend_qt
HEADERS += $$PWD/../backend/aztec.h \
$$PWD/../backend/bmp.h \
$$PWD/../backend/code49.h \
$$PWD/../backend/common.h \
$$PWD/../backend/composite.h \
$$PWD/../backend/dmatrix.h \
$$PWD/../backend/eci.h \
$$PWD/../backend/font.h \
$$PWD/../backend/gridmtx.h \
$$PWD/../backend/gs1.h \
$$PWD/../backend/hanxin.h \
$$PWD/../backend/large.h \
$$PWD/../backend/maxicode.h \
$$PWD/../backend/pcx.h \
$$PWD/../backend/pdf417.h \
$$PWD/../backend/reedsol.h \
$$PWD/../backend/rss.h \
$$PWD/../backend/sjis.h \
$$PWD/../backend/stdint_msvc.h \
$$PWD/../backend/zint.h \
$$PWD/qzint.h
SOURCES += $$PWD/../backend/2of5.c \
$$PWD/../backend/auspost.c \
$$PWD/../backend/aztec.c \
$$PWD/../backend/bmp.c \
$$PWD/../backend/codablock.c \
$$PWD/../backend/code.c \
$$PWD/../backend/code1.c \
$$PWD/../backend/code128.c \
$$PWD/../backend/code16k.c \
$$PWD/../backend/code49.c \
$$PWD/../backend/common.c \
$$PWD/../backend/composite.c \
$$PWD/../backend/dllversion.c \
$$PWD/../backend/dmatrix.c \
$$PWD/../backend/dotcode.c \
$$PWD/../backend/eci.c \
$$PWD/../backend/emf.c \
$$PWD/../backend/gif.c \
$$PWD/../backend/gridmtx.c \
$$PWD/../backend/gs1.c \
$$PWD/../backend/hanxin.c \
$$PWD/../backend/imail.c \
$$PWD/../backend/large.c \
$$PWD/../backend/library.c \
$$PWD/../backend/maxicode.c \
$$PWD/../backend/medical.c \
$$PWD/../backend/pcx.c \
$$PWD/../backend/pdf417.c \
$$PWD/../backend/plessey.c \
$$PWD/../backend/png.c \
$$PWD/../backend/postal.c \
$$PWD/../backend/ps.c \
$$PWD/../backend/qr.c \
$$PWD/../backend/raster.c \
$$PWD/../backend/reedsol.c \
$$PWD/../backend/render.c \
$$PWD/../backend/rss.c \
$$PWD/../backend/svg.c \
$$PWD/../backend/telepen.c \
$$PWD/../backend/tif.c \
$$PWD/../backend/upcean.c \
$$PWD/qzint.cpp
DESTDIR = $${DEST_LIBS}
#DLLDESTDIR = $${DESTDIR}
unix {
target.path = $${DESTDIR}
INSTALLS = target
}

View File

@ -0,0 +1,71 @@
win32 {
TEMPLATE = vclib
CONFIG += staticlib debug-and-release
}
TARGET = QtZint2
VERSION = 2.3.0
QMAKE_CFLAGS += /TP /wd4018 /wd4244 /wd4305
QMAKE_CXXFLAGS += /TP /wd4018 /wd4244 /wd4305
INCLUDEPATH += ../backend d:\\opt\\include
DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS ZINT_VERSION=\\\"$$VERSION\\\" include=""
!contains(DEFINES, NO_PNG) {
SOURCES += ../backend/png.c
}
HEADERS += ../backend/aztec.h \
../backend/code1.h \
../backend/code49.h \
../backend/common.h \
../backend/composite.h \
../backend/dmatrix.h \
../backend/font.h \
../backend/gb2312.h \
../backend/gridmtx.h \
../backend/gs1.h \
../backend/large.h \
../backend/maxicode.h \
../backend/maxihex.h \
../backend/ms_stdint.h \
../backend/pdf417.h \
../backend/qr.h \
../backend/reedsol.h \
../backend/rss.h \
../backend/sjis.h \
../backend/zint.h \
qzint.h
SOURCES += ../backend/2of5.c \
../backend/auspost.c \
../backend/aztec.c \
../backend/code.c \
../backend/code1.c \
../backend/code128.c \
../backend/code16k.c \
../backend/code49.c \
../backend/common.c \
../backend/composite.c \
../backend/dmatrix.c \
../backend/gridmtx.c \
../backend/gs1.c \
../backend/imail.c \
../backend/large.c \
../backend/library.c \
../backend/maxicode.c \
../backend/medical.c \
../backend/pdf417.c \
../backend/plessey.c \
../backend/postal.c \
../backend/ps.c \
../backend/qr.c \
../backend/reedsol.c \
../backend/render.c \
../backend/rss.c \
../backend/svg.c \
../backend/telepen.c \
../backend/upcean.c \
qzint.cpp

692
3rdparty/zint-2.6.1/backend_qt/qzint.cpp vendored Normal file
View File

@ -0,0 +1,692 @@
/***************************************************************************
* Copyright (C) 2008 by BogDan Vatra *
* bogdan@licentia.eu *
* Copyright (C) 2010-2017 Robin Stuart *
* *
* 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 3 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, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "qzint.h"
#include <stdio.h>
namespace Zint {
static const qreal maxi_diagonal = 11;
static const qreal maxi_width = 1.73205807568877 * maxi_diagonal / 2;
static const char* fontstyle = "Arial";
static const int fontPixelSizeSmall = 6;
static const int fontPixelSizeLarge = 8;
QZint::QZint() {
m_symbol = BARCODE_CODE128;
m_height = 50;
m_border = NO_BORDER;
m_borderWidth = 0;
m_securityLevel = -1;
m_pdf417CodeWords = 928;
m_fgColor = Qt::black;
m_bgColor = Qt::white;
m_zintSymbol = 0;
m_error = 0;
m_input_mode = UNICODE_MODE;
m_scale = 1.0;
m_option_3 = 0;
m_hidetext = 0;
m_dot_size = 4.0 / 5.0;
target_size_horiz = 0;
target_size_vert = 0;
m_width = 0;
m_whitespace = 0;
}
QZint::~QZint() {
if (m_zintSymbol)
ZBarcode_Delete(m_zintSymbol);
}
void QZint::encode() {
if (m_zintSymbol)
ZBarcode_Delete(m_zintSymbol);
m_lastError.clear();
m_zintSymbol = ZBarcode_Create();
m_zintSymbol->output_options = m_border;
m_zintSymbol->symbology = m_symbol;
m_zintSymbol->height = m_height;
m_zintSymbol->whitespace_width = m_whitespace;
m_zintSymbol->border_width = m_borderWidth;
m_zintSymbol->option_1 = m_securityLevel;
m_zintSymbol->input_mode = m_input_mode;
m_zintSymbol->option_2 = m_width;
m_zintSymbol->dot_size = m_dot_size;
if (m_hidetext) {
m_zintSymbol->show_hrt = 0;
} else {
m_zintSymbol->show_hrt = 1;
}
if (m_symbol == BARCODE_PDF417) {
m_zintSymbol->option_3 = m_pdf417CodeWords;
} else {
m_zintSymbol->option_3 = m_option_3;
}
QByteArray bstr = m_text.toUtf8();
QByteArray pstr = m_primaryMessage.left(99).toLatin1();
strcpy(m_zintSymbol->primary, pstr.data());
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length());
if (error > ZINT_WARN_INVALID_OPTION)
m_lastError = m_zintSymbol->errtxt;
if (m_zintSymbol->symbology == BARCODE_MAXICODE)
m_zintSymbol->height = 33;
switch (m_zintSymbol->output_options) {
case 0: m_border = NO_BORDER;
break;
case 2: m_border = BIND;
break;
case 4: m_border = BOX;
break;
}
m_borderWidth = m_zintSymbol->border_width;
m_whitespace = m_zintSymbol->whitespace_width;
}
int QZint::symbol() {
return m_symbol;
}
void QZint::setSymbol(int symbol) {
m_symbol = symbol;
}
void QZint::setInputMode(int input_mode) {
m_input_mode = input_mode;
}
QString QZint::text() {
return m_text;
}
void QZint::setText(const QString & text) {
m_text = text;
}
void QZint::setTargetSize(int width, int height) {
target_size_horiz = width;
target_size_vert = height;
}
QString QZint::primaryMessage() {
return m_primaryMessage;
}
void QZint::setPrimaryMessage(const QString & primaryMessage) {
m_primaryMessage = primaryMessage;
}
int QZint::height() {
encode();
return (m_zintSymbol->height + (m_border != NO_BORDER) ? m_borderWidth * 2 : 0)*(m_zintSymbol->symbology == BARCODE_MAXICODE ? (maxi_width + 1) : 1);
}
void QZint::setHeight(int height) {
m_height = height;
}
void QZint::setWidth(int width) {
m_width = width;
}
void QZint::setOption3(int option) {
m_option_3 = option;
}
int QZint::width() {
encode();
return (m_zintSymbol->width + (m_border == BOX) ? m_borderWidth * 2 : 0)*(m_zintSymbol->symbology == BARCODE_MAXICODE ? (maxi_width + 1) : 1);
}
float QZint::scale() {
return m_scale;
}
void QZint::setScale(float scale) {
m_scale = scale;
}
void QZint::setDotSize(float dot_size) {
m_dot_size = dot_size;
}
QColor QZint::fgColor() {
return m_fgColor;
}
void QZint::setFgColor(const QColor & fgColor) {
m_fgColor = fgColor;
}
QColor QZint::bgColor() {
return m_bgColor;
}
void QZint::setBgColor(const QColor & bgColor) {
m_bgColor = bgColor;
}
QZint::BorderType QZint::borderType() {
return m_border;
}
void QZint::setBorderType(BorderType border) {
m_border = border;
}
int QZint::borderWidth() {
return m_borderWidth;
}
void QZint::setBorderWidth(int boderWidth) {
if (boderWidth < 0 || boderWidth > 16)
boderWidth = 0;
m_borderWidth = boderWidth;
}
void QZint::setWhitespace(int whitespace) {
m_whitespace = whitespace;
}
int QZint::pdf417CodeWords() {
return m_pdf417CodeWords;
}
void QZint::setPdf417CodeWords(int pdf417CodeWords) {
m_pdf417CodeWords = pdf417CodeWords;
}
int QZint::securityLevel() {
return m_securityLevel;
}
void QZint::setSecurityLevel(int securityLevel) {
m_securityLevel = securityLevel;
}
QString QZint::error_message() {
return m_lastError;
}
int QZint::mode() {
return m_securityLevel;
}
void QZint::setMode(int securityLevel) {
m_securityLevel = securityLevel;
}
void QZint::setHideText(bool hide) {
m_hidetext = hide;
}
bool QZint::save_to_file(QString filename) {
if (m_zintSymbol)
ZBarcode_Delete(m_zintSymbol);
QString fg_colour_hash = m_fgColor.name();
QString bg_colour_hash = m_bgColor.name();
m_lastError.clear();
m_zintSymbol = ZBarcode_Create();
m_zintSymbol->output_options = m_border;
m_zintSymbol->symbology = m_symbol;
m_zintSymbol->height = m_height;
m_zintSymbol->whitespace_width = m_whitespace;
m_zintSymbol->border_width = m_borderWidth;
m_zintSymbol->option_1 = m_securityLevel;
m_zintSymbol->input_mode = m_input_mode;
m_zintSymbol->option_2 = m_width;
m_zintSymbol->dot_size = m_dot_size;
if (m_hidetext) {
m_zintSymbol->show_hrt = 0;
} else {
m_zintSymbol->show_hrt = 1;
}
if (m_symbol == BARCODE_PDF417) {
m_zintSymbol->option_3 = m_pdf417CodeWords;
} else {
m_zintSymbol->option_3 = m_option_3;
}
m_zintSymbol->scale = m_scale;
QByteArray bstr = m_text.toUtf8();
QByteArray pstr = m_primaryMessage.left(99).toLatin1();
QByteArray fstr = filename.left(255).toLatin1();
strcpy(m_zintSymbol->primary, pstr.data());
strcpy(m_zintSymbol->outfile, fstr.data());
QByteArray fgcol = fg_colour_hash.right(6).toLatin1();
QByteArray bgcol = bg_colour_hash.right(6).toLatin1();
strcpy(m_zintSymbol->fgcolour, fgcol.data());
strcpy(m_zintSymbol->bgcolour, bgcol.data());
int error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0);
if (error > ZINT_WARN_INVALID_OPTION) {
m_lastError = m_zintSymbol->errtxt;
}
if (error == 0) {
return true;
} else {
return false;
}
}
int QZint::module_set(int y_coord, int x_coord) {
int x_char, x_sub, result;
x_char = x_coord / 7;
x_sub = x_coord % 7;
result = 0;
if (m_zintSymbol->encoded_data[y_coord][x_char] & (0x01 << x_sub)) {
result = 1;
}
return result;
}
void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode) {
bool textdone;
int comp_offset = 0;
int xoffset = m_whitespace;
int j, main_width = 0, addon_text_height = 0;
int yoffset = 0;
encode();
QString caption = QString::fromUtf8((const char *) m_zintSymbol->text, -1);
QFont fontSmall(fontstyle);
fontSmall.setPixelSize(fontPixelSizeSmall);
QFont fontLarge(fontstyle);
fontLarge.setPixelSize(fontPixelSizeLarge);
if (m_lastError.length()) {
fontLarge.setPointSize(14);
painter.setFont(fontLarge);
painter.drawText(paintRect, Qt::AlignCenter, m_lastError);
return;
}
painter.save();
painter.setClipRect(paintRect, Qt::IntersectClip);
qreal xtr = paintRect.x();
qreal ytr = paintRect.y();
int zrow_height = m_zintSymbol->height;
int zrows = 0;
for (int i = 0; i < m_zintSymbol->rows; i++) {
zrow_height -= m_zintSymbol->row_height[i];
if (!m_zintSymbol->row_height[i])
zrows++;
}
if (zrows) {
zrow_height /= zrows;
for (int i = 0; i < m_zintSymbol->rows; i++)
if (!m_zintSymbol->row_height[i])
m_zintSymbol->row_height[i] = zrow_height;
} else
m_zintSymbol->height -= zrow_height;
qreal gwidth = m_zintSymbol->width;
qreal gheight = m_zintSymbol->height;
if (m_zintSymbol->symbology == BARCODE_MAXICODE) {
gwidth = (33.0 * maxi_width);
gheight = (32.0 * maxi_width);
}
if (m_zintSymbol->output_options & BARCODE_DOTTY_MODE) {
gwidth += 2.0;
gheight += 2.0;
}
qreal xsf = 1;
qreal ysf = 1;
qreal textoffset = 0;
gwidth += ((m_border == BOX) ? m_borderWidth * 2 : 0);
gheight += ((m_border != NO_BORDER) ? m_borderWidth * 2 : 0);
if (QString((const char*) m_zintSymbol->text).isEmpty() == false) {
textoffset = 9;
gheight += textoffset;
} else {
textoffset = 0;
}
gwidth += m_zintSymbol->whitespace_width * 2;
if (paintRect.width() / gwidth < paintRect.height() / gheight) {
ysf = xsf = (qreal) paintRect.width() / gwidth;
ytr += (qreal) (paintRect.height() - gheight * ysf) / 2;
} else {
ysf = xsf = (qreal) paintRect.height() / gheight;
xtr += (qreal) (paintRect.width() - gwidth * xsf) / 2;
}
painter.setBackground(QBrush(m_bgColor));
painter.fillRect(paintRect, QBrush(m_bgColor));
painter.translate(xtr, ytr);
painter.scale(xsf, ysf);
QPen p;
p.setColor(m_fgColor);
p.setWidth(m_borderWidth);
painter.setPen(p);
if (m_zintSymbol->symbology != BARCODE_MAXICODE) {
/* Draw boundary bars or boxes around the symbol */
switch (m_border) {
case BOX:
painter.fillRect(0, m_borderWidth, m_borderWidth, m_zintSymbol->height, QBrush(m_fgColor));
painter.fillRect(m_zintSymbol->width + m_zintSymbol->whitespace_width + m_zintSymbol->whitespace_width + m_borderWidth, m_borderWidth, m_borderWidth, m_zintSymbol->height, QBrush(m_fgColor));
painter.fillRect(0, 0, m_zintSymbol->width + m_zintSymbol->whitespace_width + m_zintSymbol->whitespace_width + m_borderWidth + m_borderWidth, m_borderWidth, QBrush(m_fgColor));
painter.fillRect(0, m_zintSymbol->height + m_borderWidth, m_zintSymbol->width + m_zintSymbol->whitespace_width + m_zintSymbol->whitespace_width + m_borderWidth + m_borderWidth, m_borderWidth, QBrush(m_fgColor));
painter.translate(m_borderWidth + m_zintSymbol->whitespace_width, m_borderWidth);
yoffset = m_borderWidth;
break;
case BIND:
if (m_zintSymbol->symbology != BARCODE_CODABLOCKF) {
painter.fillRect(0, 0, m_zintSymbol->width + m_zintSymbol->whitespace_width + m_zintSymbol->whitespace_width, m_borderWidth, QBrush(m_fgColor));
painter.fillRect(0, m_zintSymbol->height, m_zintSymbol->width + m_zintSymbol->whitespace_width + m_zintSymbol->whitespace_width, m_borderWidth, QBrush(m_fgColor));
} else {
painter.fillRect(m_zintSymbol->whitespace_width, 0, m_zintSymbol->width, m_borderWidth, QBrush(m_fgColor));
painter.fillRect(m_zintSymbol->whitespace_width, m_zintSymbol->height, m_zintSymbol->width, m_borderWidth, QBrush(m_fgColor));
}
painter.translate(m_zintSymbol->whitespace_width, m_borderWidth);
yoffset = m_borderWidth;
break;
default:
painter.translate(m_zintSymbol->whitespace_width, 0);
break;
}
}
while (!(module_set(m_zintSymbol->rows - 1, comp_offset))) {
comp_offset++;
}
xoffset = comp_offset;
/* Set up some values for displaying EAN and UPC symbols correctly */
main_width = m_zintSymbol->width;
if ((((m_zintSymbol->symbology == BARCODE_EANX) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_EANX_CC))
|| (m_zintSymbol->symbology == BARCODE_ISBNX)) {
switch (caption.size()) {
case 13: /* EAN 13 */
case 16:
case 19:
if (m_zintSymbol->whitespace_width == 0) {
m_zintSymbol->whitespace_width = 10;
}
main_width = 96 + comp_offset;
break;
default:
main_width = 68 + comp_offset;
break;
}
}
if (((m_zintSymbol->symbology == BARCODE_UPCA) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) {
if (m_zintSymbol->whitespace_width == 0) {
m_zintSymbol->whitespace_width = 10;
}
main_width = 96 + comp_offset;
}
if (((m_zintSymbol->symbology == BARCODE_UPCE) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
if (m_zintSymbol->whitespace_width == 0) {
m_zintSymbol->whitespace_width = 10;
}
main_width = 51 + comp_offset;
}
p.setWidth(1);
painter.setPen(p);
if (m_zintSymbol->symbology == BARCODE_MAXICODE) {
/* Draw Maxicode with hexagons */
painter.save();
painter.setRenderHint(QPainter::Antialiasing);
for (int r = 0; r < m_zintSymbol->rows; r++) {
for (int c = 0; c < m_zintSymbol->width; c++) {
if (module_set(r, c)) {
qreal col = (qreal) c * (maxi_width + 1)+(r % 2)*((maxi_width + 1) / 2);
qreal row = (qreal) r * (maxi_width + 1)*0.868;
QPainterPath pt;
pt.moveTo(col + maxi_width / 2, row);
pt.lineTo(col + maxi_width, row + maxi_diagonal / 4);
pt.lineTo(col + maxi_width, row + (maxi_diagonal - maxi_diagonal / 4));
pt.lineTo(col + maxi_width / 2, row + maxi_diagonal);
pt.lineTo(col, row + (maxi_diagonal - maxi_diagonal / 4));
pt.lineTo(col, row + maxi_diagonal / 4);
pt.lineTo(col + maxi_width / 2, row);
painter.fillPath(pt, QBrush(m_fgColor));
}
}
}
p.setWidth(maxi_width);
painter.setPen(p);
const qreal w = maxi_width + 1;
painter.drawEllipse(QPointF(14.5 * w, 16.5 * w * 0.868), w, w);
painter.drawEllipse(QPointF(14.5 * w, 16.5 * w * 0.868), w + w * 1.5, w + w * 1.5);
painter.drawEllipse(QPointF(14.5 * w, 16.5 * w * 0.868), w + w * 3, w + w * 3);
painter.restore();
} else if (m_zintSymbol->output_options & BARCODE_DOTTY_MODE) {
/* Draw with dots (circles) */
p.setColor(m_fgColor);
p.setWidth(0);
painter.setPen(p);
painter.setBrush(QBrush(m_fgColor));
painter.setRenderHint(QPainter::Antialiasing);
for (int r = 0; r < m_zintSymbol->rows; r++) {
for (int c = 0; c < m_zintSymbol->width; c++) {
if (module_set(r, c)) {
painter.drawEllipse(QPointF((c + 1.0), (r + 1.0)), m_dot_size / 2.0, m_dot_size / 2.0);
}
}
}
} else {
/* Draw all other symbols with rectangles */
int y = 0;
for (int row = 0; row < m_zintSymbol->rows; row++) {
for (int i = 0; i < m_zintSymbol->width; i++) {
if (module_set(row, i)) {
int ed = module_set(row, i);
int linewidth = 0;
for (int j = i; j < m_zintSymbol->width; j++, linewidth++)
if (ed != module_set(row, j))
break;
QColor color;
color = m_fgColor;
if (!((i > main_width) && (row == m_zintSymbol->rows - 1))) {
painter.fillRect(i, y, linewidth, m_zintSymbol->row_height[row], QBrush(color));
} else {
painter.fillRect(i, y + 8, linewidth, m_zintSymbol->row_height[row] - 3, QBrush(color));
addon_text_height = y;
}
}
}
/* Add row binding */
if (((m_zintSymbol->symbology == BARCODE_CODE16K)
|| (m_zintSymbol->symbology == BARCODE_CODE49)) && (row != 0)) {
painter.fillRect(0, y - 1, m_zintSymbol->width, 2, QBrush(m_fgColor));
}
if ((m_zintSymbol->symbology == BARCODE_CODABLOCKF) && (row != 0)) {
painter.fillRect(11, y - 1, m_zintSymbol->width - 25, 2, QBrush(m_fgColor));
}
y += m_zintSymbol->row_height[row];
}
}
textdone = false;
if (m_hidetext == false) {
painter.setFont(fontSmall);
if (((m_zintSymbol->symbology == BARCODE_EANX) || (m_zintSymbol->symbology == BARCODE_EANX_CC)) ||
(m_zintSymbol->symbology == BARCODE_ISBNX)) {
/* Add bridge and format text for EAN */
switch (caption.size()) {
case 8:
case 11:
case 14:
painter.fillRect(0 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(2 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(32 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(34 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(64 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(66 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.setFont(fontLarge);
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 29, 9, Qt::AlignCenter, caption.mid(0, 4));
painter.drawText(35 + xoffset, m_zintSymbol->height + yoffset, 29, 9, Qt::AlignCenter, caption.mid(4, 4));
if (caption.size() == 11) {
/* EAN-2 */ painter.drawText(76 + xoffset, addon_text_height, 20, 9, Qt::AlignCenter, caption.mid(9, 2));
};
if (caption.size() == 14) {
/* EAN-5 */ painter.drawText(76 + xoffset, addon_text_height, 47, 9, Qt::AlignCenter, caption.mid(9, 5));
};
painter.setFont(fontSmall);
textdone = true;
break;
case 13:
case 16:
case 19:
painter.fillRect(0 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(2 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(46 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(48 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(92 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(94 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.setFont(fontLarge);
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset, 7, 9, Qt::AlignCenter, caption.mid(0, 1));
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 43, 9, Qt::AlignCenter, caption.mid(1, 6));
painter.drawText(49 + xoffset, m_zintSymbol->height + yoffset, 43, 9, Qt::AlignCenter, caption.mid(7, 6));
if (caption.size() == 16) {
/* EAN-2 */ painter.drawText(104 + xoffset, addon_text_height, 20, 9, Qt::AlignCenter, caption.mid(14, 2));
};
if (caption.size() == 19) {
/* EAN-5 */ painter.drawText(104 + xoffset, addon_text_height, 47, 9, Qt::AlignCenter, caption.mid(14, 5));
};
painter.setFont(fontSmall);
textdone = true;
break;
}
if (textdone == false) {
painter.setFont(fontLarge);
painter.drawText(0, m_zintSymbol->height, m_zintSymbol->width, 9, Qt::AlignCenter, caption);
painter.setFont(fontSmall);
textdone = true;
}
}
if ((m_zintSymbol->symbology == BARCODE_UPCA) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) {
/* Add bridge and format text for UPC-A */
int block_width;
bool latch = true;
j = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
if (latch == true) {
/* a bar */
painter.fillRect(j + xoffset - comp_offset, m_zintSymbol->height, block_width, 5, QBrush(m_fgColor));
latch = false;
} else {
/* a space */
latch = true;
}
j += block_width;
} while (j < 11 + comp_offset);
painter.fillRect(46 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(48 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
latch = true;
j = 85 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
if (latch == true) {
/* a bar */
painter.fillRect(j + xoffset - comp_offset, m_zintSymbol->height, block_width, 5, QBrush(m_fgColor));
latch = false;
} else {
/* a space */
latch = true;
}
j += block_width;
} while (j < 96 + comp_offset);
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset + 2, 7, 7, Qt::AlignCenter, caption.mid(0, 1));
painter.drawText(96 + xoffset, m_zintSymbol->height + yoffset + 2, 7, 7, Qt::AlignCenter, caption.mid(11, 1));
painter.setFont(fontLarge);
painter.drawText(11 + xoffset, m_zintSymbol->height + yoffset, 35, 9, Qt::AlignCenter, caption.mid(1, 5));
painter.drawText(49 + xoffset, m_zintSymbol->height + yoffset, 35, 9, Qt::AlignCenter, caption.mid(6, 5));
if (caption.size() == 15) {
/* EAN-2 */ painter.drawText(104 + xoffset, addon_text_height, 20, 9, Qt::AlignCenter, caption.mid(13, 2));
};
if (caption.size() == 18) {
/* EAN-5 */ painter.drawText(104 + xoffset, addon_text_height, 47, 9, Qt::AlignCenter, caption.mid(13, 5));
};
painter.setFont(fontSmall);
textdone = true;
}
if ((m_zintSymbol->symbology == BARCODE_UPCE) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
/* Add bridge and format text for UPC-E */
painter.fillRect(0 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(2 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(46 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(48 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.fillRect(50 + xoffset, m_zintSymbol->height, 1, 5, QBrush(m_fgColor));
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset + 2, 7, 7, Qt::AlignCenter, caption.mid(0, 1));
painter.drawText(51 + xoffset, m_zintSymbol->height + yoffset + 2, 7, 7, Qt::AlignCenter, caption.mid(7, 1));
painter.setFont(fontLarge);
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 43, 9, Qt::AlignCenter, caption.mid(1, 6));
if (caption.size() == 11) {
/* EAN-2 */ painter.drawText(60 + xoffset, addon_text_height, 20, 9, Qt::AlignCenter, caption.mid(9, 2));
};
if (caption.size() == 14) {
/* EAN-2 */ painter.drawText(60 + xoffset, addon_text_height, 47, 9, Qt::AlignCenter, caption.mid(9, 5));
};
painter.setFont(fontSmall);
textdone = true;
}
} /* if (m_hidetext == false) */
if ((m_hidetext == false) && (textdone == false)) {
/* Add text to any other symbol */
painter.drawText(0, m_zintSymbol->height + yoffset, m_zintSymbol->width, 7, Qt::AlignCenter, caption);
}
painter.restore();
}
const QString & QZint::lastError() {
return m_lastError;
}
bool QZint::hasErrors() {
return m_lastError.length();
}
}

128
3rdparty/zint-2.6.1/backend_qt/qzint.h vendored Normal file
View File

@ -0,0 +1,128 @@
/***************************************************************************
* Copyright (C) 2008 by BogDan Vatra *
* bogdan@licentia.eu *
* *
* 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 3 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, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef BARCODERENDER_H
#define BARCODERENDER_H
#include <QColor>
#include <QPainter>
#include "zint.h"
namespace Zint
{
class QZint
{
private:
public:
enum BorderType{NO_BORDER=0, BIND=2, BOX=4};
enum AspectRatioMode{IgnoreAspectRatio=0, KeepAspectRatio=1, CenterBarCode=2};
public:
QZint();
~QZint();
int symbol();
void setSymbol(int symbol);
QString text();
void setText(const QString & text);
QString primaryMessage();
void setPrimaryMessage(const QString & primaryMessage);
void setHeight(int height);
int height();
void setWidth(int width);
int width();
void setOption3(int option);
QColor fgColor();
void setFgColor(const QColor & fgColor);
QColor bgColor();
void setBgColor(const QColor & bgColor);
BorderType borderType();
void setBorderType(BorderType border);
int borderWidth();
void setBorderWidth(int boderWidth);
int pdf417CodeWords();
void setPdf417CodeWords(int pdf417CodeWords);
int securityLevel();
void setSecurityLevel(int securityLevel);
float scale();
void setScale(float scale);
void setDotSize(float dot_size);
int mode();
void setMode(int securityLevel);
void setInputMode(int input_mode);
void setWhitespace(int whitespace);
QString error_message();
void render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode=IgnoreAspectRatio);
const QString & lastError();
bool hasErrors();
bool save_to_file(QString filename);
void setHideText(bool hide);
void setTargetSize(int width, int height);
private:
void encode();
int module_set(int y_coord, int x_coord);
private:
int m_symbol;
QString m_text;
QString m_primaryMessage;
int m_height;
BorderType m_border;
int m_borderWidth;
int m_width;
int m_securityLevel;
int m_pdf417CodeWords;
int m_input_mode;
QColor m_fgColor;
QColor m_bgColor;
QString m_lastError;
int m_error;
int m_whitespace;
zint_symbol * m_zintSymbol;
float m_scale;
int m_option_3;
bool m_hidetext;
float m_dot_size;
int target_size_horiz;
int target_size_vert;
};
}
#endif

9
3rdparty/zint-2.6.1/backend_qt/readme vendored Normal file
View File

@ -0,0 +1,9 @@
Edit zint-1.6.pro and edit the 'DEFINES' section
NO_PNG -> compile zint without png support
NO_QR -> compile zint without QR support
QR_SYSTEM -> if you have QT installed in your system, zint will be compiled with QT support
QR -> compile zint with QR support static (you must have qrencode in the current folder)
Edit compile_n_config and set the paths.
Exec compile_n_config

View File

@ -11,7 +11,7 @@ CONFIG += build_translations
CONFIG += dialogdesigner
}
ZINT_PATH = $$PWD/3rdparty/zint-2.4.4
ZINT_PATH = $$PWD/3rdparty/zint-2.6.1
contains(CONFIG,zint){
DEFINES += HAVE_ZINT
}

View File

@ -76,8 +76,8 @@ win32 {
contains(CONFIG,zint){
message(zint)
INCLUDEPATH += $$ZINT_PATH/backend $$ZINT_PATH/backend_qt4
DEPENDPATH += $$ZINT_PATH/backend $$ZINT_PATH/backend_qt4
INCLUDEPATH += $$ZINT_PATH/backend $$ZINT_PATH/backend_qt
DEPENDPATH += $$ZINT_PATH/backend $$ZINT_PATH/backend_qt
LIBS += -L$${DEST_LIBS}
contains(CONFIG,release) {
LIBS += -lQtZint