diff --git a/automake/AUTHORS b/AUTHORS
similarity index 100%
rename from automake/AUTHORS
rename to AUTHORS
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..cca7fc2
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..d4c7144
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,13 @@
+Jul 22, 2009 - 1.1.1
+ - License changed from GPLv3 to LGPLv3
+ - ARYGON ADRA-USB/ADRB-USB reader support
+ - PN533 support
+ - C99 standard (all custom defined types have been renamed)
+ - Autotoolized for GNU/Linux, *BSD
+ - nfc tools (emulate, relay, list, mftool) are now prefixed by nfc in GNU/Linux and *BSD
+
+Mar 27, 2009 - 1.1.0
+ - Next generation, support for ACR122v2 and PN531 USB devices
+
+Feb 12, 2009 - 1.0.0
+ - Initial release
diff --git a/automake/INSTALL b/INSTALL
similarity index 100%
rename from automake/INSTALL
rename to INSTALL
diff --git a/LICENSE b/LICENSE
index 818433e..cca7fc2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,674 +1,165 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- 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.
-
-
- Copyright (C)
-
- 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 .
-
-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:
-
- Copyright (C)
- 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
-.
-
- 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
-.
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/automake/Makefile.am b/Makefile.am
similarity index 100%
rename from automake/Makefile.am
rename to Makefile.am
diff --git a/automake/NEWS b/NEWS
similarity index 100%
rename from automake/NEWS
rename to NEWS
diff --git a/README b/README
index 6790fbe..01ce245 100644
--- a/README
+++ b/README
@@ -1,24 +1,24 @@
-------------------------------------------------------------------------
-Public platform independent Near Field Communication (NFC) library
-Copyright (C) 2009, Roel Verdult
-
-------------------------------------------------------------------------
-Welcome to the developers community of libnfc.
-
-Since it is hard to keep all information up to date
-we decided to only maintain the online documentation.
-Please visit the official website for more info:
-http://www.libnfc.org
-
-If you have questions, remarks, bug-reports, we encourage you to
-post this in the developers community:
-http://www.libnfc.org/community
-
-------------------------------------------------------------------------
-Proprietary Notes:
-
-FeliCa is s registered trademark of Sony Corporation. MIFARE is a
-trademark of NXP Semiconductors. Jewel Topaz is a trademark of Innovision
-Research & Technology. All other trademarks are the property of their
-respective owners.
-
+------------------------------------------------------------------------
+Public platform independent Near Field Communication (NFC) library
+Copyright (C) 2009, Roel Verdult
+
+------------------------------------------------------------------------
+Welcome to the developers community of libnfc.
+
+Since it is hard to keep all information up to date
+we decided to only maintain the online documentation.
+Please visit the official website for more info:
+http://www.libnfc.org
+
+If you have questions, remarks, bug-reports, we encourage you to
+post this in the developers community:
+http://www.libnfc.org/community
+
+------------------------------------------------------------------------
+Proprietary Notes:
+
+FeliCa is s registered trademark of Sony Corporation. MIFARE is a
+trademark of NXP Semiconductors. Jewel Topaz is a trademark of Innovision
+Research & Technology. All other trademarks are the property of their
+respective owners.
+
diff --git a/automake/autogen.sh b/autogen.sh
similarity index 74%
rename from automake/autogen.sh
rename to autogen.sh
index 11eec5f..fbf0634 100755
--- a/automake/autogen.sh
+++ b/autogen.sh
@@ -6,23 +6,21 @@ rm -f aclocal.m4 ltmain.sh
touch README
LIBTOOLIZE=libtoolize
-SKIP_PCSC="0"
-
case `uname -s` in
Darwin)
LIBTOOLIZE=glibtoolize
ACLOCAL_ARGS="-I /opt/local/share/aclocal/"
- SKIP_PCSC="1"
+ # SKIP_PCSC="1"
;;
FreeBSD)
ACLOCAL_ARGS="-I /usr/local/share/aclocal/"
;;
esac
-echo "Running aclocal..." ; aclocal $ACLOCAL_ARGS -I . || exit 1
+echo "Running aclocal..." ; aclocal $ACLOCAL_ARGS || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
-echo "Running libtoolize..." ; $LIBTOOLIZE --force --automake || exit 1
+echo "Running libtoolize..." ; $LIBTOOLIZE --copy --automake || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
if [ -z "$NOCONFIGURE" ]; then
diff --git a/automake/COPYING b/automake/COPYING
deleted file mode 100644
index 94a9ed0..0000000
--- a/automake/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- 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.
-
-
- Copyright (C)
-
- 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 .
-
-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:
-
- Copyright (C)
- 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
-.
-
- 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
-.
diff --git a/automake/ChangeLog b/automake/ChangeLog
deleted file mode 100644
index e69de29..0000000
diff --git a/automake/configure.ac b/automake/configure.ac
deleted file mode 100644
index 85ed45c..0000000
--- a/automake/configure.ac
+++ /dev/null
@@ -1,42 +0,0 @@
-AC_INIT(libnfc, 1.1.1, info@libnfc.org)
-
-AC_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE
-
-AC_LANG_C
-AC_PROG_CC
-AC_PROG_MAKE_SET
-AC_PROG_LIBTOOL
-AC_PROG_RANLIB
-
-AC_PATH_PROG(PKG_CONFIG, pkg-config)
-
-# Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([stdlib.h])
-
-# libusb
-PKG_CHECK_MODULES(LIBUSB, libusb, [WITH_USB=1], [WITH_USB=0])
-if test "$WITH_USB" == "0" ; then
- AC_MSG_ERROR([libusb is mandatory.])
-fi
-AC_SUBST(LIBUSB_LIBS)
-AC_SUBST(LIBUSB_CFLAGS)
-
-# libpcsclite
-if test "$SKIP_PCSC" == "0" ; then
- PKG_CHECK_MODULES(LIBPCSCLITE, libpcsclite, [WITH_PCSC=1], [WITH_PCSC=0])
- if test "$WITH_PCSC" == "0" ; then
- AC_MSG_ERROR([libpcsclite is mandatory.])
- fi
- AC_SUBST(LIBPCSCLITE_LIBS)
- AC_SUBST(LIBPCSCLITE_CFLAGS)
-fi
-
-AC_CONFIG_FILES([
- Makefile
- src/Makefile
- libnfc.pc
- ])
-
-AC_OUTPUT
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..9642d78
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,100 @@
+AC_INIT(libnfc, 1.1.1, info@libnfc.org)
+
+AC_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE
+
+AC_LANG_C
+AC_PROG_CC
+AC_PROG_MAKE_SET
+AC_PROG_LIBTOOL
+AC_PROG_RANLIB
+
+AC_PATH_PROG(PKG_CONFIG, pkg-config)
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_HEADER_STDBOOL
+AC_CHECK_HEADERS([stdio.h stdlib.h stdint.h stddef.h stdbool.h usb.h])
+
+# Checks for types
+AC_TYPE_SIZE_T
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_INT32_T
+
+# --enable-pcsc-lite support (default: yes)
+AC_ARG_ENABLE([pcsc-lite],AS_HELP_STRING([--enable-pcsc-lite],[pcsc-lite feature flag]),[enable_pcsc_lite=$enableval],[enable_pcsc_lite="yes"])
+
+AC_MSG_CHECKING(for pcsc-lite support)
+AC_MSG_RESULT($enable_pcsc_lite)
+
+if test x"$enable_pcsc_lite" = "xno"
+then
+ WITH_PCSC=0
+fi
+AM_CONDITIONAL(PCSC_LITE_ENABLED, [test x"$enable_pcsc_lite" = xyes])
+
+# --enable-debug support (default:no)
+AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Debug flags]),[enable_debug=$enableval],[enable_debug="no"])
+
+AC_MSG_CHECKING(for debug flag)
+AC_MSG_RESULT($enable_debug)
+
+if test x"$enable_debug" = "xyes"
+then
+ CFLAGS="$CFLAGS -g -Wall -DDEBUG -pedantic"
+fi
+AC_SUBST([DEBUG_CFLAGS])
+
+## libusb
+if test x"$PKG_CONFIG" = "x"; then
+ AC_PATH_PROG(LIBUSB_CONFIG,libusb-config)
+ if test x"$LIBUSB_CONFIG" = "x" ; then
+ WITH_USB=0
+ else
+ LIBUSB_CFLAGS=`$LIBUSB_CONFIG --cflags`
+ LIBUSB_LIBS=`$LIBUSB_CONFIG --libs`
+ WITH_USB=1
+ fi
+else
+ PKG_CHECK_MODULES(LIBUSB, libusb, [WITH_USB=1], [WITH_USB=0])
+fi
+
+if test x"$WITH_USB" = "x0"; then
+ AC_MSG_ERROR([libusb is mandatory.])
+fi
+AC_SUBST(LIBUSB_LIBS)
+AC_SUBST(LIBUSB_CFLAGS)
+
+## libpcsclite
+if test "x$enable_pcsc_lite" = "xyes"
+then
+case "$host" in
+ *darwin*)
+ AC_MSG_WARN(Using darwin PCSC Framework)
+ LIBPCSCLITE_LIBS="-Wl,-framework,PCSC"
+ LIBPCSCLITE_CFLAGS="-I/System/Library/Frameworks/PCSC.framework/Headers"
+ ;;
+ *)
+ PKG_CHECK_MODULES(LIBPCSCLITE, libpcsclite, [WITH_PCSC=1], [WITH_PCSC=0])
+ if test "$WITH_PCSC" = "0" ; then
+ AC_MSG_ERROR([libpcsclite is mandatory.])
+ fi
+ ;;
+esac
+ AC_SUBST(LIBPCSCLITE_LIBS)
+ AC_SUBST(LIBPCSCLITE_CFLAGS)
+fi
+
+# Set C standard to C99
+CFLAGS="$CFLAGS -std=c99"
+
+AC_CONFIG_FILES([
+ Makefile
+ src/Makefile
+ libnfc.pc
+ ])
+
+AC_OUTPUT
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..154b4a8
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,12 @@
+libnfc (1.1.1-0) unstable; urgency=low
+
+ * New upstream version.
+
+ -- Romuald Conty Wed, 29 Apr 2009 16:42:42 +0100
+
+libnfc (1.1.0-0) unstable; urgency=low
+
+ * Initial debian package.
+
+ -- Romuald Conty Wed, 22 Apr 2009 10:42:42 +0100
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..1d52e0b
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,30 @@
+Source: libnfc
+Section: devel
+Priority: optional
+Maintainer: Romuald Conty
+Build-Depends: debhelper (>= 5.0.37.2), cdbs (>= 0.4.43), libusb-dev, libpcsclite-dev
+Standards-Version: 3.7.3
+Homepage: http://www.libnfc.org/
+
+Package: libnfc0
+Architecture: any
+Depends: ${shlibs:Depends}, libusb-0.1-4, libpcsclite1 (>= 1.5), libccid (>= 1.3.10)
+Description: Near Field Communication (NFC) library
+ libnfc is a Free Software NFC library. The supported NFC hardware devices are
+ the ACS ACR122(U) NFC reader and various NFC-dongles. In principle all
+ hardware based on the NXP PN53x NFC Controller chip is supported.
+
+Package: libnfc-dev
+Architecture: any
+Depends: libnfc0, libusb-dev, libpcsclite-dev
+Description: Near Field Communication library (development files)
+ libnfc is a Free Software NFC library. The supported NFC hardware devices are
+ the ACS ACR122(U) NFC reader and various NFC-dongles. In principle all
+ hardware based on the NXP PN53x NFC Controller chip is supported.
+
+Package: nfc-tools
+Architecture: any
+Depends: libnfc0
+Description: Near Field Communication tools
+ NFC tools are provide by libnfc team to be able to use NFC devices
+ "out-of-the-box".
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..ce98d8a
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,28 @@
+This package was debianized by Romuald Conty on
+Wed, 22 Apr 2009 10:42:42 +0100.
+
+It was downloaded from: http://www.libnfc.org/
+
+Copyright (C) 2005-2007 by Harald Welte
+Copyright (C) 2009 by Roel Verdult
+
+License: GNU General Public License version 3
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 3
+ as published by the Free Software Foundation
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+On Debian GNU/Linux systems, the complete text of the GNU General Public
+License, version 3, can be found in `/usr/share/common-licenses/GPL-3'.
+
+The Debian packaging is (C) 2009, Romuald Conty and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
diff --git a/debian/libnfc-dev.install b/debian/libnfc-dev.install
new file mode 100644
index 0000000..35dfe53
--- /dev/null
+++ b/debian/libnfc-dev.install
@@ -0,0 +1,3 @@
+debian/tmp/usr/include/libnfc
+debian/tmp/usr/lib/libnfc.{a,la,so}
+debian/tmp/usr/lib/pkgconfig/libnfc.pc
diff --git a/debian/libnfc0.install b/debian/libnfc0.install
new file mode 100644
index 0000000..5ae0ff4
--- /dev/null
+++ b/debian/libnfc0.install
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libnfc.so.*
diff --git a/debian/nfc-tools.install b/debian/nfc-tools.install
new file mode 100644
index 0000000..7459505
--- /dev/null
+++ b/debian/nfc-tools.install
@@ -0,0 +1 @@
+debian/tmp/usr/bin/nfc-*
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..114ab44
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,4 @@
+#!/usr/bin/make -f
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+
diff --git a/automake/install-sh b/install-sh
similarity index 100%
rename from automake/install-sh
rename to install-sh
diff --git a/automake/libnfc.pc.in b/libnfc.pc.in
similarity index 88%
rename from automake/libnfc.pc.in
rename to libnfc.pc.in
index 1edf5b4..a09e1d5 100644
--- a/automake/libnfc.pc.in
+++ b/libnfc.pc.in
@@ -6,5 +6,5 @@ Name: libnfc
Description: Near Field Communication (NFC) library
Version: @VERSION@
Requires: libusb, libpcsclite
-Libs: -L${libdir} -lmytoolkit
+Libs: -L${libdir} -lnfc
Cflags: -I${includedir}
diff --git a/manualmake/macosx/Makefile b/macosx/Makefile
similarity index 98%
rename from manualmake/macosx/Makefile
rename to macosx/Makefile
index bb38c48..6c01605 100644
--- a/manualmake/macosx/Makefile
+++ b/macosx/Makefile
@@ -13,7 +13,7 @@ LIBNFC_LINK=
# General settings
###############################################
LIBNFC_LDFLAGS=$(LIBPCSC_LIB) $(LIBUSB_LIB)
-LIBNFC_PATH=../../src
+LIBNFC_PATH=..
VPATH=$(LIBNFC_PATH)
###############################################
diff --git a/make_release.sh b/make_release.sh
new file mode 100755
index 0000000..e427628
--- /dev/null
+++ b/make_release.sh
@@ -0,0 +1,84 @@
+#! /bin/sh
+
+# Stop script on first error.
+set -e
+
+# Retrieve libnfc version from configure.ac
+LIBNFC_VERSION=$(grep AC_INIT configure.ac | sed 's/^.*(\(.*\))/\1/g' | awk -F', ' '{ print $2 }')
+
+## Easiest part: GNU/linux, BSD and other POSIX systems.
+LIBNFC_AUTOTOOLS_ARCHIVE=libnfc-$LIBNFC_VERSION.tar.gz
+
+if [ ! -f $LIBNFC_AUTOTOOLS_ARCHIVE ]; then
+ # First, we can test archive using "distcheck"
+ ./autogen.sh && make distcheck && make distclean
+
+ # We are ready to make a good autotools release.
+ ./autogen.sh && make dist
+else
+ echo "Autotooled archive (GNU/Linux, BSD, etc.) is already done: skipped."
+fi
+
+# MacOSX part (will be removed if we can use autotools under MacOSX)
+LIBNFC_MACOSX_DIR=libnfc-$LIBNFC_VERSION-macosx
+LIBNFC_MACOSX_ARCHIVE=$LIBNFC_MACOSX_DIR.tgz
+
+if [ ! -f $LIBNFC_MACOSX_ARCHIVE ]; then
+ if [ -d $LIBNFC_MACOSX_DIR ]; then
+ rm -rf $LIBNFC_MACOSX_DIR
+ fi
+
+ mkdir -p $LIBNFC_MACOSX_DIR
+
+ # Copy sources
+ cp src/*.c $LIBNFC_MACOSX_DIR/
+ cp src/*.h $LIBNFC_MACOSX_DIR/
+
+ # Copy important files
+ cp LICENSE $LIBNFC_MACOSX_DIR/
+ cp README $LIBNFC_MACOSX_DIR/
+
+ # Copy MacOSX specific files
+ cp macosx/* $LIBNFC_MACOSX_DIR/
+ # Fix MacOSX Makefile
+ sed -i 's/LIBNFC_PATH=\.\./LIBNFC_PATH=./' Makefile
+
+ # Build archive
+ tar cvzf $LIBNFC_MACOSX_DIR.tgz $LIBNFC_MACOSX_DIR
+ rm -rf $LIBNFC_MACOSX_DIR
+else
+ echo "MacOSX archive is already done: skipped."
+fi
+
+# Windows part
+LIBNFC_WINDOWS_DIR=libnfc-$LIBNFC_VERSION-windows
+LIBNFC_WINDOWS_ARCHIVE=$LIBNFC_WINDOWS_DIR.zip
+
+if [ ! -f $LIBNFC_WINDOWS_ARCHIVE ]; then
+ if [ -d $LIBNFC_WINDOWS_DIR ]; then
+ rm -rf $LIBNFC_WINDOWS_DIR
+ fi
+
+ mkdir -p $LIBNFC_WINDOWS_DIR
+
+ # Copy sources
+ cp src/*.c $LIBNFC_WINDOWS_DIR/
+ cp src/*.h $LIBNFC_WINDOWS_DIR/
+
+ # Copy important files
+ cp LICENSE $LIBNFC_WINDOWS_DIR/
+ cp README $LIBNFC_WINDOWS_DIR/
+
+ # Copy Visual C++ project files
+ cp -r win32 $LIBNFC_WINDOWS_DIR/vc-project
+
+ # Remove svn stuff
+ find $LIBNFC_WINDOWS_DIR -name ".svn" -type d | xargs rm -rf
+
+ # Build archive
+ zip -r $LIBNFC_WINDOWS_ARCHIVE $LIBNFC_WINDOWS_DIR
+ rm -rf $LIBNFC_WINDOWS_DIR
+else
+ echo "Windows archive is already done: skipped."
+fi
+
diff --git a/manualmake/linux/Makefile b/manualmake/linux/Makefile
deleted file mode 100644
index 6a15572..0000000
--- a/manualmake/linux/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-###############################################
-# Linux settings
-###############################################
-LIBPCSC_HEADERS=`pkg-config --cflags libpcsclite`
-LIBPCSC_LIB=`pkg-config --libs libpcsclite`
-LIBUSB_HEADERS=`pkg-config --cflags libusb`
-LIBUSB_LIB=`pkg-config --libs libusb`
-LIBNFC_TYPE=so
-LIBNFC_CFLAGS=-shared
-LIBNFC_LINK=-Wl,-rpath,.
-
-###############################################
-# General settings
-###############################################
-LIBNFC_LDFLAGS=$(LIBPCSC_LIB) $(LIBUSB_LIB)
-LIBNFC_PATH=../../src
-VPATH=$(LIBNFC_PATH)
-
-###############################################
-# Compiler settings
-###############################################
-CC = gcc
-LD = gcc
-CFLAGS = -fPIC -Wall -O4 $(LIBPCSC_HEADERS) $(LIBUSB_HEADERS)
-LDFLAGS = -fPIC -Wall -O4
-
-OBJS = dev_pn531.o dev_pn533.o dev_acr122.o dev_arygon.o bitutils.o libnfc.o rs232.o
-HEADERS = devices.h bitutils.h defines.h libnfc.h
-LIBNFC = libnfc.$(LIBNFC_TYPE)
-EXES = anticol emulate list mftool relay
-
-all: $(LIBNFC) $(EXES)
-
-libnfc.$(LIBNFC_TYPE): $(OBJS)
- $(LD) $(LDFLAGS) -o $(LIBNFC) $(LIBNFC_CFLAGS) $(LIBNFC_LDFLAGS) $(OBJS)
-
-% : %.c $(LIBNFC)
- $(LD) $(LDFLAGS) -o $@ $< -L. -lnfc $(LIBNFC_LINK)
-
-clean:
- rm -f $(OBJS) $(LIBNFC) $(EXES)
diff --git a/automake/missing b/missing
similarity index 100%
rename from automake/missing
rename to missing
diff --git a/src/Makefile.am b/src/Makefile.am
index 3836b9f..3b0c88e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,16 +1,24 @@
+enable_pcsc_lite = @enable_pcsc_lite@
+
bin_PROGRAMS = nfc-anticol nfc-list nfc-mftool nfc-relay nfc-emulate
# set the include path found by configure
INCLUDES= $(all_includes)
-nfcinclude_HEADERS = libnfc.h bitutils.h defines.h dev_acr122.h dev_pn531.h types.h mifaretag.h devices.h
+nfcinclude_HEADERS = libnfc.h bitutils.h defines.h types.h mifaretag.h devices.h rs232.h dev_arygon.h dev_pn531.h dev_pn533.h
nfcincludedir = $(includedir)/libnfc
lib_LTLIBRARIES = libnfc.la
+libnfc_la_SOURCES = bitutils.c libnfc.c rs232.c dev_arygon.c dev_pn531.c dev_pn533.c
+libnfc_la_CFLAGS = @LIBUSB_CFLAGS@
+libnfc_la_LIBADD = @LIBUSB_LIBS@
-libnfc_la_CFLAGS = @LIBUSB_CFLAGS@ @LIBPCSCLITE_CFLAGS@
-libnfc_la_SOURCES = dev_pn531.c dev_acr122.c bitutils.c libnfc.c
-libnfc_la_LIBADD = @LIBUSB_LIBS@ @LIBPCSCLITE_LIBS@
+if PCSC_LITE_ENABLED
+ nfcinclude_HEADERS += dev_acr122.h
+ libnfc_la_CFLAGS += @LIBPCSCLITE_CFLAGS@ -DHAVE_PCSC_LITE
+ libnfc_la_SOURCES += dev_acr122.c
+ libnfc_la_LIBADD += @LIBPCSCLITE_LIBS@
+endif
nfc_anticol_SOURCES = anticol.c
nfc_anticol_LDADD = libnfc.la
@@ -26,3 +34,8 @@ nfc_relay_LDADD = libnfc.la
nfc_emulate_SOURCES = emulate.c
nfc_emulate_LDADD = libnfc.la
+
+dist_man_MANS = nfc-anticol.1 nfc-emulate.1 nfc-list.1 nfc-mftool.1 nfc-relay.1
+#dist_man_MANS = $(man_MANS)
+#EXTRA_DIST = $(man_MANS)
+
diff --git a/src/anticol.c b/src/anticol.c
index e4e4e34..3b7c3ba 100644
--- a/src/anticol.c
+++ b/src/anticol.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,39 +13,44 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#include
#include
+#include
+#include
+#include
+
#include
+
#include "libnfc.h"
#define SAK_FLAG_ATS_SUPPORTED 0x20
-static byte abtRx[MAX_FRAME_LEN];
-static ui32 uiRxBits;
-static ui32 uiRxLen;
-static byte abtUid[10];
-static ui32 uiUidLen = 4;
+static byte_t abtRx[MAX_FRAME_LEN];
+static uint32_t uiRxBits;
+static uint32_t uiRxLen;
+static byte_t abtUid[10];
+static uint32_t uiUidLen = 4;
static dev_info* pdi;
// ISO14443A Anti-Collision Commands
-byte abtReqa [1] = { 0x26 };
-byte abtSelectAll [2] = { 0x93,0x20 };
-byte abtSelectTag [9] = { 0x93,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
-byte abtRats [4] = { 0xe0,0x50,0xbc,0xa5 };
-byte abtHalt [4] = { 0x50,0x00,0x57,0xcd };
+byte_t abtReqa [1] = { 0x26 };
+byte_t abtSelectAll [2] = { 0x93,0x20 };
+byte_t abtSelectTag [9] = { 0x93,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
+byte_t abtRats [4] = { 0xe0,0x50,0xbc,0xa5 };
+byte_t abtHalt [4] = { 0x50,0x00,0x57,0xcd };
-bool transmit_bits(const byte* pbtTx, const ui32 uiTxBits)
+bool transmit_bits(const byte_t* pbtTx, const uint32_t uiTxBits)
{
// Show transmitted command
printf("R: "); print_hex_bits(pbtTx,uiTxBits);
// Transmit the bit frame command, we don't use the arbitrary parity feature
- if (!nfc_reader_transceive_bits(pdi,pbtTx,uiTxBits,null,abtRx,&uiRxBits,null)) return false;
+ if (!nfc_reader_transceive_bits(pdi,pbtTx,uiTxBits,NULL,abtRx,&uiRxBits,NULL)) return false;
// Show received answer
printf("T: "); print_hex_bits(abtRx,uiRxBits);
@@ -55,7 +60,7 @@ bool transmit_bits(const byte* pbtTx, const ui32 uiTxBits)
}
-bool transmit_bytes(const byte* pbtTx, const ui32 uiTxLen)
+bool transmit_bytes(const byte_t* pbtTx, const uint32_t uiTxLen)
{
// Show transmitted command
printf("R: "); print_hex(pbtTx,uiTxLen);
diff --git a/src/bitutils.c b/src/bitutils.c
index 5fda4b1..03cf72a 100644
--- a/src/bitutils.c
+++ b/src/bitutils.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,15 +13,16 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#include
+
#include "bitutils.h"
-const static byte OddParity[256] = {
+const static byte_t OddParity[256] = {
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
@@ -40,7 +41,7 @@ const static byte OddParity[256] = {
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
};
-const static byte ByteMirror[256] = {
+const static byte_t ByteMirror[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30,
0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98,
0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64,
@@ -63,14 +64,14 @@ const static byte ByteMirror[256] = {
0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
-byte oddparity(const byte bt)
+byte_t oddparity(const byte_t bt)
{
return OddParity[bt];
}
-void oddparity_bytes(const byte* pbtData, const ui32 uiLen, byte* pbtPar)
+void oddparity_bytes(const byte_t* pbtData, const uint32_t uiLen, byte_t* pbtPar)
{
- ui32 uiByteNr;
+ uint32_t uiByteNr;
// Calculate the parity bits for the command
for (uiByteNr=0; uiByteNr>8)+((ui32N&0xFF000000)>>24));
}
-ui64 swap_endian64(const void* pui64)
+uint64_t swap_endian64(const void* pui64)
{
- ui64 ui64N = *((ui64*)pui64);
+ uint64_t ui64N = *((uint64_t *)pui64);
return (((ui64N&0xFF)<<56)+((ui64N&0xFF00)<<40)+((ui64N&0xFF0000)<<24)+((ui64N&0xFF000000)<<8)+((ui64N&0xFF00000000ull)>>8)+((ui64N&0xFF0000000000ull)>>24)+((ui64N&0xFF000000000000ull)>>40)+((ui64N&0xFF00000000000000ull)>>56));
}
-void append_iso14443a_crc(byte* pbtData, ui32 uiLen)
+void append_iso14443a_crc(byte_t* pbtData, uint32_t uiLen)
{
- byte bt;
- ui32 wCrc = 0x6363;
+ byte_t bt;
+ uint32_t wCrc = 0x6363;
do {
bt = *pbtData++;
- bt = (bt^(byte)(wCrc & 0x00FF));
+ bt = (bt^(byte_t)(wCrc & 0x00FF));
bt = (bt^(bt<<4));
- wCrc = (wCrc >> 8)^((ui32)bt << 8)^((ui32)bt<<3)^((ui32)bt>>4);
+ wCrc = (wCrc >> 8)^((uint32_t)bt << 8)^((uint32_t)bt<<3)^((uint32_t)bt>>4);
} while (--uiLen);
- *pbtData++ = (byte) (wCrc & 0xFF);
- *pbtData = (byte) ((wCrc >> 8) & 0xFF);
+ *pbtData++ = (byte_t) (wCrc & 0xFF);
+ *pbtData = (byte_t) ((wCrc >> 8) & 0xFF);
}
-void print_hex(const byte* pbtData, const ui32 uiBytes)
+void print_hex(const byte_t* pbtData, const uint32_t uiBytes)
{
- ui32 uiPos;
+ uint32_t uiPos;
for (uiPos=0; uiPos < uiBytes; uiPos++)
{
@@ -146,10 +147,10 @@ void print_hex(const byte* pbtData, const ui32 uiBytes)
printf("\n");
}
-void print_hex_bits(const byte* pbtData, const ui32 uiBits)
+void print_hex_bits(const byte_t* pbtData, const uint32_t uiBits)
{
- ui32 uiPos;
- ui32 uiBytes = uiBits/8;
+ uint32_t uiPos;
+ uint32_t uiBytes = uiBits/8;
for (uiPos=0; uiPos < uiBytes; uiPos++)
{
@@ -162,10 +163,10 @@ void print_hex_bits(const byte* pbtData, const ui32 uiBits)
printf("\n");
}
-void print_hex_par(const byte* pbtData, const ui32 uiBits, const byte* pbtDataPar)
+void print_hex_par(const byte_t* pbtData, const uint32_t uiBits, const byte_t* pbtDataPar)
{
- ui32 uiPos;
- ui32 uiBytes = uiBits/8;
+ uint32_t uiPos;
+ uint32_t uiBytes = uiBits/8;
for (uiPos=0; uiPos < uiBytes; uiPos++)
{
diff --git a/src/bitutils.h b/src/bitutils.h
index 312c968..97bdb16 100644
--- a/src/bitutils.h
+++ b/src/bitutils.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,32 +13,34 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#ifndef _LIBNFC_BITUTILS_H_
#define _LIBNFC_BITUTILS_H_
-#include "defines.h"
+#include
-byte oddparity(const byte bt);
-void oddparity_bytes(const byte* pbtData, const ui32 uiLen, byte* pbtPar);
+#include "types.h"
-byte mirror(byte bt);
-ui32 mirror32(ui32 ui32Bits);
-ui64 mirror64(ui64 ui64Bits);
-void mirror_bytes(byte *pbts, ui32 uiLen);
+byte_t oddparity(const byte_t bt);
+void oddparity_byte_ts(const byte_t* pbtData, const uint32_t uiLen, byte_t* pbtPar);
-ui32 swap_endian32(const void* pui32);
-ui64 swap_endian64(const void* pui64);
+byte_t mirror(byte_t bt);
+uint32_t mirror32(uint32_t ui32Bits);
+uint64_t mirror64(uint64_t ui64Bits);
+void mirror_byte_ts(byte_t *pbts, uint32_t uiLen);
-void append_iso14443a_crc(byte* pbtData, ui32 uiLen);
+uint32_t swap_endian32(const void* pui32);
+uint64_t swap_endian64(const void* pui64);
-void print_hex(const byte* pbtData, const ui32 uiLen);
-void print_hex_bits(const byte* pbtData, const ui32 uiBits);
-void print_hex_par(const byte* pbtData, const ui32 uiBits, const byte* pbtDataPar);
+void append_iso14443a_crc(byte_t* pbtData, uint32_t uiLen);
+
+void print_hex(const byte_t* pbtData, const uint32_t uiLen);
+void print_hex_bits(const byte_t* pbtData, const uint32_t uiBits);
+void print_hex_par(const byte_t* pbtData, const uint32_t uiBits, const byte_t* pbtDataPar);
#endif // _LIBNFC_BITUTILS_H_
diff --git a/src/defines.h b/src/defines.h
index 0cd80dc..a604a7b 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,37 +13,25 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#ifndef _LIBNFC_DEFINES_H_
#define _LIBNFC_DEFINES_H_
-// #define _LIBNFC_VERBOSE_
-
-typedef unsigned char byte;
-typedef unsigned char ui8;
-typedef unsigned short ui16;
-typedef unsigned int ui32;
-typedef unsigned long long ui64;
-typedef unsigned long ulong;
-typedef char i8;
-typedef short i16;
-typedef int i32;
-
-#define null 0
+// #define DEBUG /* DEBUG flag can also be enabled using ./configure --enable-debug */
typedef void* dev_spec; // Device connection specification
-#define INVALID_DEVICE_INFO null
+#define INVALID_DEVICE_INFO 0
#define MAX_FRAME_LEN 264
#define DEVICE_NAME_LENGTH 256
#define MAX_DEVICES 16
// Useful macros
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+//#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+//#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define INNER_XOR8(n) {n ^= (n >> 4); n ^= (n >> 2); n ^= (n >> 1); n &= 0x01; }
#define INNER_XOR32(n) {n ^= (n >> 16); n ^= (n >> 8); INNER_XOR8(n); }
#define INNER_XOR64(n) {n ^= (n >> 32); INNER_XOR32(n); }
diff --git a/src/dev_acr122.c b/src/dev_acr122.c
index 635322a..fa297a0 100644
--- a/src/dev_acr122.c
+++ b/src/dev_acr122.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,18 +13,26 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
-#include "defines.h"
-
-#include
-#include
-#include
-#include
#include "dev_acr122.h"
+
+#include
+#include
+#include
+#include
+
+#ifndef __APPLE__
+#include
+#else
+#include
+#include
+#endif
+
+#include "defines.h"
#include "bitutils.h"
// WINDOWS: #define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE SCARD_CTL_CODE(3500)
@@ -48,23 +56,23 @@ typedef struct {
SCARD_IO_REQUEST ioCard;
} dev_spec_acr122;
-static byte abtTxBuf[ACR122_WRAP_LEN+ACR122_COMMAND_LEN] = { 0xFF, 0x00, 0x00, 0x00 };
-static byte abtRxCmd[5] = { 0xFF,0xC0,0x00,0x00 };
-static byte uiRxCmdLen = sizeof(abtRxCmd);
-static byte abtRxBuf[ACR122_RESPONSE_LEN];
-static ulong ulRxBufLen;
-static byte abtGetFw[5] = { 0xFF,0x00,0x48,0x00,0x00 };
-static byte abtLed[9] = { 0xFF,0x00,0x40,0x05,0x04,0x00,0x00,0x00,0x00 };
+static byte_t abtTxBuf[ACR122_WRAP_LEN+ACR122_COMMAND_LEN] = { 0xFF, 0x00, 0x00, 0x00 };
+static byte_t abtRxCmd[5] = { 0xFF,0xC0,0x00,0x00 };
+static byte_t uiRxCmdLen = sizeof(abtRxCmd);
+static byte_t abtRxBuf[ACR122_RESPONSE_LEN];
+static size_t ulRxBufLen;
+static byte_t abtGetFw[5] = { 0xFF,0x00,0x48,0x00,0x00 };
+static byte_t abtLed[9] = { 0xFF,0x00,0x40,0x05,0x04,0x00,0x00,0x00,0x00 };
-dev_info* dev_acr122_connect(const ui32 uiIndex)
+dev_info* dev_acr122_connect(const uint32_t uiIndex)
{
char* pacReaders[MAX_DEVICES];
char acList[256+64*MAX_DEVICES];
- ulong ulListLen = sizeof(acList);
- ui32 uiPos;
- ui32 uiReaderCount;
- ui32 uiReader;
- ui32 uiDevIndex;
+ size_t ulListLen = sizeof(acList);
+ uint32_t uiPos;
+ uint32_t uiReaderCount;
+ uint32_t uiReader;
+ uint32_t uiDevIndex;
dev_info* pdi;
dev_spec_acr122* pdsa;
dev_spec_acr122 dsa;
@@ -74,12 +82,12 @@ dev_info* dev_acr122_connect(const ui32 uiIndex)
memset(acList,0x00,ulListLen);
// Test if context succeeded
- if (SCardEstablishContext(SCARD_SCOPE_USER,null,null,&(dsa.hCtx)) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO;
+ if (SCardEstablishContext(SCARD_SCOPE_USER,NULL,NULL,&(dsa.hCtx)) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO;
// Retrieve the string array of all available pcsc readers
- if (SCardListReaders(dsa.hCtx,null,acList,(void*)&ulListLen) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO;
+ if (SCardListReaders(dsa.hCtx,NULL,acList,(void*)&ulListLen) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO;
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Found the following PCSC device(s)\n");
printf("- %s\n",acList);
#endif
@@ -104,7 +112,7 @@ dev_info* dev_acr122_connect(const ui32 uiIndex)
uiReaderCount++;
// Debug info
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("- %s\n",acList+uiPos+1);
#endif
}
@@ -131,7 +139,7 @@ dev_info* dev_acr122_connect(const ui32 uiIndex)
// Retrieve the current firmware version
pcFirmware = dev_acr122_firmware((dev_info*)&dsa);
- if (strstr(pcFirmware,FIRMWARE_TEXT) != null)
+ if (strstr(pcFirmware,FIRMWARE_TEXT) != NULL)
{
// We found a occurence, test if it has the right index
if (uiDevIndex != 0)
@@ -171,7 +179,7 @@ void dev_acr122_disconnect(dev_info* pdi)
free(pdi);
}
-bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen)
+bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen)
{
dev_spec_acr122* pdsa = (dev_spec_acr122*)ds;
@@ -184,7 +192,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
// Prepare and transmit the send buffer
memcpy(abtTxBuf+5,pbtTx,uiTxLen);
ulRxBufLen = sizeof(abtRxBuf);
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Tx: ");
print_hex(abtTxBuf,uiTxLen+5);
#endif
@@ -193,7 +201,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
{
if (SCardControl(pdsa->hCard,IOCTL_CCID_ESCAPE_SCARD_CTL_CODE,abtTxBuf,uiTxLen+5,abtRxBuf,ulRxBufLen,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false;
} else {
- if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtTxBuf,uiTxLen+5,null,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false;
+ if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtTxBuf,uiTxLen+5,NULL,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false;
}
if (pdsa->ioCard.dwProtocol == SCARD_PROTOCOL_T0)
@@ -207,16 +215,16 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
// Retrieve the response bytes
abtRxCmd[4] = abtRxBuf[1];
ulRxBufLen = sizeof(abtRxBuf);
- if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtRxCmd,uiRxCmdLen,null,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false;
+ if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtRxCmd,uiRxCmdLen,NULL,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false;
}
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Rx: ");
print_hex(abtRxBuf,ulRxBufLen);
#endif
// When the answer should be ignored, just return a succesful result
- if (pbtRx == null || puiRxLen == null) return true;
+ if (pbtRx == NULL || puiRxLen == NULL) return true;
// Make sure we have an emulated answer that fits the return buffer
if (ulRxBufLen < 4 || (ulRxBufLen-4) > *puiRxLen) return false;
@@ -230,20 +238,20 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
char* dev_acr122_firmware(const dev_spec ds)
{
- ui32 uiResult;
+ uint32_t uiResult;
dev_spec_acr122* pdsa = (dev_spec_acr122*)ds;
static char abtFw[11];
- ulong ulFwLen = sizeof(abtFw);
+ size_t ulFwLen = sizeof(abtFw);
memset(abtFw,0x00,ulFwLen);
if (pdsa->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED)
{
uiResult = SCardControl(pdsa->hCard,IOCTL_CCID_ESCAPE_SCARD_CTL_CODE,abtGetFw,sizeof(abtGetFw),abtFw,ulFwLen,(void*)&ulFwLen);
} else {
- uiResult = SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtGetFw,sizeof(abtGetFw),null,(byte*)abtFw,(void*)&ulFwLen);
+ uiResult = SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtGetFw,sizeof(abtGetFw),NULL,(byte_t*)abtFw,(void*)&ulFwLen);
}
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
if (uiResult != SCARD_S_SUCCESS)
{
printf("No ACR122 firmware received, Error: %08x\n",uiResult);
@@ -256,13 +264,13 @@ char* dev_acr122_firmware(const dev_spec ds)
bool dev_acr122_led_red(const dev_spec ds, bool bOn)
{
dev_spec_acr122* pdsa = (dev_spec_acr122*)ds;
- byte abtBuf[2];
- ulong ulBufLen = sizeof(abtBuf);
+ byte_t abtBuf[2];
+ size_t ulBufLen = sizeof(abtBuf);
if (pdsa->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED)
{
return (SCardControl(pdsa->hCard,IOCTL_CCID_ESCAPE_SCARD_CTL_CODE,abtLed,sizeof(abtLed),abtBuf,ulBufLen,(void*)&ulBufLen) == SCARD_S_SUCCESS);
} else {
- return (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtLed,sizeof(abtLed),null,(byte*)abtBuf,(void*)&ulBufLen) == SCARD_S_SUCCESS);
+ return (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtLed,sizeof(abtLed),NULL,(byte_t*)abtBuf,(void*)&ulBufLen) == SCARD_S_SUCCESS);
}
}
diff --git a/src/dev_acr122.h b/src/dev_acr122.h
index 95c763d..3f9c9dc 100644
--- a/src/dev_acr122.h
+++ b/src/dev_acr122.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,23 +13,26 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#ifndef _LIBNFC_DEV_ACR122_H_
#define _LIBNFC_DEV_ACR122_H_
+#include
+#include
+
#include "defines.h"
#include "types.h"
// Functions used by developer to handle connection to this device
-dev_info* dev_acr122_connect(const ui32 uiIndex);
+dev_info* dev_acr122_connect(const uint32_t uiIndex);
void dev_acr122_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
-bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
+bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen);
// Various additional features this device supports
char* dev_acr122_firmware(const dev_spec ds);
diff --git a/src/dev_arygon.c b/src/dev_arygon.c
index 0663766..997ac41 100644
--- a/src/dev_arygon.c
+++ b/src/dev_arygon.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,8 +13,8 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
@@ -24,26 +24,26 @@ along with this program. If not, see .
#ifdef _WIN32
#define SERIAL_STRING "COM"
-#endif
-#ifdef linux
- #define SERIAL_STRING "/dev/ttyusb"
-#endif
-#ifdef __APPLE__
- #define SERIAL_STRING "/dev/tty.SLAB_USBtoUART"
+#else
+ #ifdef __APPLE__
+ #define SERIAL_STRING "/dev/tty.SLAB_USBtoUART"
+ #else
+ #define SERIAL_STRING "/dev/ttyUSB"
+ #endif
#endif
#define BUFFER_LENGTH 256
#define USB_TIMEOUT 30000
-static byte abtTxBuf[BUFFER_LENGTH] = { 0x32, 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
+static byte_t abtTxBuf[BUFFER_LENGTH] = { 0x32, 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
-dev_info* dev_arygon_connect(const ui32 uiIndex)
+dev_info* dev_arygon_connect(const uint32_t uiIndex)
{
- ui32 uiDevNr;
+ uint32_t uiDevNr;
serial_port sp;
char acConnect[BUFFER_LENGTH];
dev_info* pdi = INVALID_DEVICE_INFO;
-#ifdef _LIBNFC_VERBOSE_
+#ifdef DEBUG
printf("Trying to find ARYGON device on serial port: %s#\n",SERIAL_STRING);
#endif
@@ -58,7 +58,7 @@ dev_info* dev_arygon_connect(const ui32 uiIndex)
sp = rs232_open(acConnect);
#endif
if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT)) break;
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
if (sp == INVALID_SERIAL_PORT) printf("invalid serial port: %s\n",acConnect);
if (sp == CLAIMED_SERIAL_PORT) printf("serial port already claimed: %s\n",acConnect);
#endif
@@ -66,7 +66,7 @@ dev_info* dev_arygon_connect(const ui32 uiIndex)
// Test if we have found a device
if (uiDevNr == MAX_DEVICES) return INVALID_DEVICE_INFO;
-#ifdef _LIBNFC_VERBOSE_
+#ifdef DEBUG
printf("Succesfully connected to: %s\n",acConnect);
#endif
@@ -88,11 +88,11 @@ void dev_arygon_disconnect(dev_info* pdi)
free(pdi);
}
-bool dev_arygon_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen)
+bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen)
{
- byte abtRxBuf[BUFFER_LENGTH];
- ui32 uiRxBufLen = BUFFER_LENGTH;
- ui32 uiPos;
+ byte_t abtRxBuf[BUFFER_LENGTH];
+ uint32_t uiRxBufLen = BUFFER_LENGTH;
+ uint32_t uiPos;
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
abtTxBuf[4] = uiTxLen;
@@ -111,7 +111,7 @@ bool dev_arygon_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
// End of stream marker
abtTxBuf[uiTxLen+7] = 0;
-#ifdef _LIBNFC_VERBOSE_
+#ifdef DEBUG
printf("Tx: ");
print_hex(abtTxBuf,uiTxLen+8);
#endif
@@ -120,13 +120,13 @@ bool dev_arygon_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
if (!rs232_receive((serial_port)ds,abtRxBuf,&uiRxBufLen)) return false;
-#ifdef _LIBNFC_VERBOSE_
+#ifdef DEBUG
printf("Rx: ");
print_hex(abtRxBuf,uiRxBufLen);
#endif
// When the answer should be ignored, just return a succesful result
- if(pbtRx == null || puiRxLen == null) return true;
+ if(pbtRx == NULL || puiRxLen == NULL) return true;
// Only succeed when the result is at least 00 00 ff 00 ff 00 00 00 FF xx Fx Dx xx .. .. .. xx 00 (x = variable)
if(uiRxBufLen < 15) return false;
diff --git a/src/dev_arygon.h b/src/dev_arygon.h
index a1dfd2d..885b7dc 100644
--- a/src/dev_arygon.h
+++ b/src/dev_arygon.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,8 +13,8 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
@@ -25,11 +25,11 @@ along with this program. If not, see .
#include "types.h"
// Functions used by developer to handle connection to this device
-dev_info* dev_arygon_connect(const ui32 uiIndex);
+dev_info* dev_arygon_connect(const uint32_t uiIndex);
void dev_arygon_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
-bool dev_arygon_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
+bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen);
#endif // _LIBNFC_DEV_ARYGON_H_
diff --git a/src/dev_pn531.c b/src/dev_pn531.c
index 5d09b9d..82e7620 100644
--- a/src/dev_pn531.c
+++ b/src/dev_pn531.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,18 +13,22 @@ 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 .
-
-Thanks to d18c7db and Okko for example code
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
-#include "defines.h"
+/*
+Thanks to d18c7db and Okko for example code
+*/
+
+#include
+#include
#include
-#include
#include
+
+#include "defines.h"
#include "dev_pn531.h"
#include "bitutils.h"
@@ -34,15 +38,15 @@ static char buffer[BUFFER_LENGTH] = { 0x00, 0x00, 0xff }; // Every packet must s
typedef struct {
usb_dev_handle* pudh;
- ui32 uiEndPointIn;
- ui32 uiEndPointOut;
+ uint32_t uiEndPointIn;
+ uint32_t uiEndPointOut;
} dev_spec_pn531;
// Find transfer endpoints for bulk transfers
static void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
{
- ui32 uiIndex;
- ui32 uiEndPoint;
+ uint32_t uiIndex;
+ uint32_t uiEndPoint;
struct usb_interface_descriptor* puid = dev->config->interface->altsetting;
// 3 Endpoints maximum: Interrupt In, Bulk In, Bulk Out
@@ -57,7 +61,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
// Test if we dealing with a bulk IN endpoint
if((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_IN)
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Bulk endpoint in : 0x%02X\n", uiEndPoint);
#endif
pdsp->uiEndPointIn = uiEndPoint;
@@ -66,7 +70,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
// Test if we dealing with a bulk OUT endpoint
if((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_OUT)
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Bulk endpoint in : 0x%02X\n", uiEndPoint);
#endif
pdsp->uiEndPointOut = uiEndPoint;
@@ -74,7 +78,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
}
}
-dev_info* dev_pn531_connect(const ui32 uiIndex)
+dev_info* dev_pn531_connect(const uint32_t uiIndex)
{
int idvendor = 0x04CC;
int idproduct = 0x0531;
@@ -85,11 +89,11 @@ dev_info* dev_pn531_connect(const ui32 uiIndex)
dev_info* pdi = INVALID_DEVICE_INFO;
dev_spec_pn531* pdsp;
dev_spec_pn531 dsp;
- ui32 uiDevIndex;
+ uint32_t uiDevIndex;
dsp.uiEndPointIn = 0;
dsp.uiEndPointOut = 0;
- dsp.pudh = null;
+ dsp.pudh = NULL;
usb_init();
if (usb_find_busses() < 0) return INVALID_DEVICE_INFO;
@@ -115,7 +119,7 @@ dev_info* dev_pn531_connect(const ui32 uiIndex)
uiDevIndex--;
continue;
}
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Found PN531 device\n");
#endif
@@ -125,7 +129,7 @@ dev_info* dev_pn531_connect(const ui32 uiIndex)
get_end_points(dev,&dsp);
if(usb_set_configuration(dsp.pudh,1) < 0)
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Setting config failed\n");
#endif
usb_close(dsp.pudh);
@@ -134,7 +138,7 @@ dev_info* dev_pn531_connect(const ui32 uiIndex)
if(usb_claim_interface(dsp.pudh,0) < 0)
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Can't claim interface\n");
#endif
usb_close(dsp.pudh);
@@ -167,39 +171,39 @@ void dev_pn531_disconnect(dev_info* pdi)
free(pdi);
}
-bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen)
+bool dev_pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen)
{
- ui32 uiPos = 0;
+ uint32_t uiPos = 0;
int ret = 0;
char buf[BUFFER_LENGTH];
dev_spec_pn531* pdsp = (dev_spec_pn531*)ds;
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
- buffer[3] = uiTxLen;
- // Packet length checksum
- buffer[4] = BUFFER_LENGTH - buffer[3];
+ buffer[3] = uiTxLen;
+ // Packet length checksum
+ buffer[4] = BUFFER_LENGTH - buffer[3];
// Copy the PN53X command into the packet buffer
memmove(buffer+5,pbtTx,uiTxLen);
// Calculate data payload checksum
- buffer[uiTxLen+5] = 0;
+ buffer[uiTxLen+5] = 0;
for(uiPos=0; uiPos < uiTxLen; uiPos++)
{
buffer[uiTxLen+5] -= buffer[uiPos+5];
}
// End of stream marker
- buffer[uiTxLen+6] = 0;
+ buffer[uiTxLen+6] = 0;
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Tx: ");
- print_hex((byte*)buffer,uiTxLen+7);
+ print_hex((byte_t*)buffer,uiTxLen+7);
#endif
ret = usb_bulk_write(pdsp->pudh, pdsp->uiEndPointOut, buffer, uiTxLen+7, USB_TIMEOUT);
if( ret < 0 )
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("usb_bulk_write failed with error %d\n", ret);
#endif
return false;
@@ -208,15 +212,15 @@ bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
ret = usb_bulk_read(pdsp->pudh, pdsp->uiEndPointIn, buf, BUFFER_LENGTH, USB_TIMEOUT);
if( ret < 0 )
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf( "usb_bulk_read failed with error %d\n", ret);
#endif
return false;
}
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Rx: ");
- print_hex((byte*)buf,ret);
+ print_hex((byte_t*)buf,ret);
#endif
if( ret == 6 )
@@ -224,20 +228,20 @@ bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
ret = usb_bulk_read(pdsp->pudh, pdsp->uiEndPointIn, buf, BUFFER_LENGTH, USB_TIMEOUT);
if( ret < 0 )
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("usb_bulk_read failed with error %d\n", ret);
#endif
return false;
}
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Rx: ");
- print_hex((byte*)buf,ret);
+ print_hex((byte_t*)buf,ret);
#endif
}
// When the answer should be ignored, just return a succesful result
- if(pbtRx == null || puiRxLen == null) return true;
+ if(pbtRx == NULL || puiRxLen == NULL) return true;
// Only succeed when the result is at least 00 00 FF xx Fx Dx xx .. .. .. xx 00 (x = variable)
if(ret < 9) return false;
diff --git a/src/dev_pn531.h b/src/dev_pn531.h
index 65419c4..51279e8 100644
--- a/src/dev_pn531.h
+++ b/src/dev_pn531.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,23 +13,26 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#ifndef _LIBNFC_DEV_PN531_H_
#define _LIBNFC_DEV_PN531_H_
+#include
+#include
+
#include "defines.h"
#include "types.h"
// Functions used by developer to handle connection to this device
-dev_info* dev_pn531_connect(const ui32 uiIndex);
+dev_info* dev_pn531_connect(const uint32_t uiIndex);
void dev_pn531_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
-bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
+bool dev_pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen);
#endif // _LIBNFC_DEV_PN531_H_
diff --git a/src/dev_pn533.c b/src/dev_pn533.c
index 9493994..d73897a 100644
--- a/src/dev_pn533.c
+++ b/src/dev_pn533.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,11 +13,13 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
+*/
+
+/*
Thanks to d18c7db and Okko for example code
-
*/
#include "defines.h"
@@ -34,15 +36,15 @@ static char buffer[BUFFER_LENGTH] = { 0x00, 0x00, 0xff }; // Every packet must s
typedef struct {
usb_dev_handle* pudh;
- ui32 uiEndPointIn;
- ui32 uiEndPointOut;
+ uint32_t uiEndPointIn;
+ uint32_t uiEndPointOut;
} dev_spec_pn533;
// Find transfer endpoints for bulk transfers
static void get_end_points(struct usb_device *dev, dev_spec_pn533* pdsp)
{
- ui32 uiIndex;
- ui32 uiEndPoint;
+ uint32_t uiIndex;
+ uint32_t uiEndPoint;
struct usb_interface_descriptor* puid = dev->config->interface->altsetting;
// 3 Endpoints maximum: Interrupt In, Bulk In, Bulk Out
@@ -57,7 +59,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn533* pdsp)
// Test if we dealing with a bulk IN endpoint
if((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_IN)
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Bulk endpoint in : 0x%02X\n", uiEndPoint);
#endif
pdsp->uiEndPointIn = uiEndPoint;
@@ -66,7 +68,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn533* pdsp)
// Test if we dealing with a bulk OUT endpoint
if((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_OUT)
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Bulk endpoint in : 0x%02X\n", uiEndPoint);
#endif
pdsp->uiEndPointOut = uiEndPoint;
@@ -74,7 +76,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn533* pdsp)
}
}
-dev_info* dev_pn533_connect(const ui32 uiIndex)
+dev_info* dev_pn533_connect(const uint32_t uiIndex)
{
int idvendor = 0x04e6;
int idproduct = 0x5591;
@@ -83,11 +85,11 @@ dev_info* dev_pn533_connect(const ui32 uiIndex)
dev_info* pdi = INVALID_DEVICE_INFO;
dev_spec_pn533* pdsp;
dev_spec_pn533 dsp;
- ui32 uiDevIndex;
+ uint32_t uiDevIndex;
dsp.uiEndPointIn = 0;
dsp.uiEndPointOut = 0;
- dsp.pudh = null;
+ dsp.pudh = NULL;
usb_init();
if (usb_find_busses() < 0) return INVALID_DEVICE_INFO;
@@ -112,7 +114,7 @@ dev_info* dev_pn533_connect(const ui32 uiIndex)
uiDevIndex--;
continue;
}
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Found PN533 device\n");
#endif
@@ -122,7 +124,7 @@ dev_info* dev_pn533_connect(const ui32 uiIndex)
get_end_points(dev,&dsp);
if(usb_set_configuration(dsp.pudh,1) < 0)
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Setting config failed\n");
#endif
usb_close(dsp.pudh);
@@ -131,7 +133,7 @@ dev_info* dev_pn533_connect(const ui32 uiIndex)
if(usb_claim_interface(dsp.pudh,0) < 0)
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Can't claim interface\n");
#endif
usb_close(dsp.pudh);
@@ -164,9 +166,9 @@ void dev_pn533_disconnect(dev_info* pdi)
free(pdi);
}
-bool dev_pn533_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen)
+bool dev_pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen)
{
- ui32 uiPos = 0;
+ uint32_t uiPos = 0;
int ret = 0;
char buf[BUFFER_LENGTH];
dev_spec_pn533* pdsp = (dev_spec_pn533*)ds;
@@ -188,15 +190,15 @@ bool dev_pn533_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
// End of stream marker
buffer[uiTxLen+6] = 0;
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Tx: ");
- print_hex((byte*)buffer,uiTxLen+7);
+ print_hex((byte_t*)buffer,uiTxLen+7);
#endif
ret = usb_bulk_write(pdsp->pudh, pdsp->uiEndPointOut, buffer, uiTxLen+7, USB_TIMEOUT);
if( ret < 0 )
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("usb_bulk_write failed with error %d\n", ret);
#endif
return false;
@@ -205,15 +207,15 @@ bool dev_pn533_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
ret = usb_bulk_read(pdsp->pudh, pdsp->uiEndPointIn, buf, BUFFER_LENGTH, USB_TIMEOUT);
if( ret < 0 )
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf( "usb_bulk_read failed with error %d\n", ret);
#endif
return false;
}
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Rx: ");
- print_hex((byte*)buf,ret);
+ print_hex((byte_t*)buf,ret);
#endif
if( ret == 6 )
@@ -221,20 +223,20 @@ bool dev_pn533_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
ret = usb_bulk_read(pdsp->pudh, pdsp->uiEndPointIn, buf, BUFFER_LENGTH, USB_TIMEOUT);
if( ret < 0 )
{
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("usb_bulk_read failed with error %d\n", ret);
#endif
return false;
}
- #ifdef _LIBNFC_VERBOSE_
+ #ifdef DEBUG
printf("Rx: ");
- print_hex((byte*)buf,ret);
+ print_hex((byte_t*)buf,ret);
#endif
}
// When the answer should be ignored, just return a succesful result
- if(pbtRx == null || puiRxLen == null) return true;
+ if(pbtRx == NULL || puiRxLen == NULL) return true;
// Only succeed when the result is at least 00 00 FF xx Fx Dx xx .. .. .. xx 00 (x = variable)
if(ret < 9) return false;
diff --git a/src/dev_pn533.h b/src/dev_pn533.h
index 387c549..8bf0587 100644
--- a/src/dev_pn533.h
+++ b/src/dev_pn533.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,8 +13,8 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
@@ -25,11 +25,11 @@ along with this program. If not, see .
#include "types.h"
// Functions used by developer to handle connection to this device
-dev_info* dev_pn533_connect(const ui32 uiIndex);
+dev_info* dev_pn533_connect(const uint32_t uiIndex);
void dev_pn533_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
-bool dev_pn533_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
+bool dev_pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen);
#endif // _LIBNFC_DEV_PN533_H_
diff --git a/src/devices.h b/src/devices.h
index 15f8333..330cebc 100644
--- a/src/devices.h
+++ b/src/devices.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,8 +13,8 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
@@ -23,14 +23,18 @@ along with this program. If not, see .
#include "defines.h"
#include "types.h"
-#include "dev_acr122.h"
+#ifdef HAVE_PCSC_LITE
+ #include "dev_acr122.h"
+#endif
#include "dev_pn531.h"
#include "dev_pn533.h"
#include "dev_arygon.h"
const static struct dev_callbacks dev_callbacks_list[] = {
// Driver Name Connect Transceive Disconect
+#ifdef HAVE_PCSC_LITE
{ "ACR122", dev_acr122_connect, dev_acr122_transceive, dev_acr122_disconnect },
+#endif
{ "PN531USB", dev_pn531_connect, dev_pn531_transceive, dev_pn531_disconnect },
{ "PN533USB", dev_pn533_connect, dev_pn533_transceive, dev_pn533_disconnect },
{ "ARYGON", dev_arygon_connect, dev_arygon_transceive, dev_arygon_disconnect }
diff --git a/src/emulate.c b/src/emulate.c
index 5153ba9..d501fae 100644
--- a/src/emulate.c
+++ b/src/emulate.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,29 +13,32 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#include
#include
+#include
+#include
#include
+
#include "libnfc.h"
-static byte abtRecv[MAX_FRAME_LEN];
-static ui32 uiRecvBits;
+static byte_t abtRecv[MAX_FRAME_LEN];
+static uint32_t uiRecvBits;
static dev_info* pdi;
// ISO14443A Anti-Collision response
-byte abtAtqa [2] = { 0x04,0x00 };
-byte abtUidBcc [5] = { 0xDE,0xAD,0xBE,0xAF,0x62 };
-byte abtSak [9] = { 0x08,0xb6,0xdd };
+byte_t abtAtqa [2] = { 0x04,0x00 };
+byte_t abtUidBcc [5] = { 0xDE,0xAD,0xBE,0xAF,0x62 };
+byte_t abtSak [9] = { 0x08,0xb6,0xdd };
int main(int argc, const char* argv[])
{
- byte* pbtTx = null;
- ui32 uiTxBits;
+ byte_t* pbtTx = NULL;
+ uint32_t uiTxBits;
// Try to open the NFC reader
pdi = nfc_connect();
@@ -66,7 +69,7 @@ int main(int argc, const char* argv[])
while(true)
{
// Test if we received a frame
- if (nfc_target_receive_bits(pdi,abtRecv,&uiRecvBits,null))
+ if (nfc_target_receive_bits(pdi,abtRecv,&uiRecvBits,NULL))
{
// Prepare the command to send back for the anti-collision request
switch(uiRecvBits)
@@ -100,7 +103,7 @@ int main(int argc, const char* argv[])
if(uiTxBits)
{
// Send and print the command to the screen
- nfc_target_send_bits(pdi,pbtTx,uiTxBits,null);
+ nfc_target_send_bits(pdi,pbtTx,uiTxBits,NULL);
printf("T: ");
print_hex_bits(pbtTx,uiTxBits);
}
diff --git a/src/libnfc.c b/src/libnfc.c
index 8d87140..8aa1b40 100644
--- a/src/libnfc.c
+++ b/src/libnfc.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,16 +13,21 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#include "libnfc.h"
-#include "bitutils.h"
+
#include
+#include
#include
+#include "devices.h"
+
+#include "bitutils.h"
+
// Registers and symbols masks used to covers parts within a register
#define REG_CIU_TX_MODE 0x6302
#define SYMBOL_TX_CRC_ENABLE 0x80
@@ -53,44 +58,44 @@ along with this program. If not, see .
#define PARAM_NO_AMBLE 0x40
// PN53X configuration
-byte pncmd_get_firmware_version [ 2] = { 0xD4,0x02 };
-byte pncmd_get_general_status [ 2] = { 0xD4,0x04 };
-byte pncmd_get_register [ 4] = { 0xD4,0x06 };
-byte pncmd_set_register [ 5] = { 0xD4,0x08 };
-byte pncmd_set_parameters [ 3] = { 0xD4,0x12 };
+byte_t pncmd_get_firmware_version [ 2] = { 0xD4,0x02 };
+byte_t pncmd_get_general_status [ 2] = { 0xD4,0x04 };
+byte_t pncmd_get_register [ 4] = { 0xD4,0x06 };
+byte_t pncmd_set_register [ 5] = { 0xD4,0x08 };
+byte_t pncmd_set_parameters [ 3] = { 0xD4,0x12 };
// RF field configuration
-byte pncmd_rf_configure_field [ 4] = { 0xD4,0x32,0x01 };
-byte pncmd_rf_configure_timing [ 4] = { 0xD4,0x32,0x02 };
-byte pncmd_rf_configure_retry_data [ 4] = { 0xD4,0x32,0x04 };
-byte pncmd_rf_configure_retry_select [ 6] = { 0xD4,0x32,0x05 };
+byte_t pncmd_rf_configure_field [ 4] = { 0xD4,0x32,0x01 };
+byte_t pncmd_rf_configure_timing [ 4] = { 0xD4,0x32,0x02 };
+byte_t pncmd_rf_configure_retry_data [ 4] = { 0xD4,0x32,0x04 };
+byte_t pncmd_rf_configure_retry_select [ 6] = { 0xD4,0x32,0x05 };
// Reader
-byte pncmd_reader_list_passive [264] = { 0xD4,0x4A };
-byte pncmd_reader_select [ 3] = { 0xD4,0x54 };
-byte pncmd_reader_deselect [ 3] = { 0xD4,0x44,0x00 };
-byte pncmd_reader_release [ 3] = { 0xD4,0x52,0x00 };
-byte pncmd_reader_set_baud_rate [ 5] = { 0xD4,0x4E };
-byte pncmd_reader_exchange_data [265] = { 0xD4,0x40 };
-byte pncmd_reader_auto_poll [ 5] = { 0xD4,0x60 };
+byte_t pncmd_reader_list_passive [264] = { 0xD4,0x4A };
+byte_t pncmd_reader_select [ 3] = { 0xD4,0x54 };
+byte_t pncmd_reader_deselect [ 3] = { 0xD4,0x44,0x00 };
+byte_t pncmd_reader_release [ 3] = { 0xD4,0x52,0x00 };
+byte_t pncmd_reader_set_baud_rate [ 5] = { 0xD4,0x4E };
+byte_t pncmd_reader_exchange_data [265] = { 0xD4,0x40 };
+byte_t pncmd_reader_auto_poll [ 5] = { 0xD4,0x60 };
// Target
-byte pncmd_target_get_data [ 2] = { 0xD4,0x86 };
-byte pncmd_target_init [ 39] = { 0xD4,0x8C };
-byte pncmd_target_virtual_card [ 4] = { 0xD4,0x14 };
-byte pncmd_target_receive [ 2] = { 0xD4,0x88 };
-byte pncmd_target_send [264] = { 0xD4,0x90 };
-byte pncmd_target_get_status [ 2] = { 0xD4,0x8A };
+byte_t pncmd_target_get_data [ 2] = { 0xD4,0x86 };
+byte_t pncmd_target_init [ 39] = { 0xD4,0x8C };
+byte_t pncmd_target_virtual_card [ 4] = { 0xD4,0x14 };
+byte_t pncmd_target_receive [ 2] = { 0xD4,0x88 };
+byte_t pncmd_target_send [264] = { 0xD4,0x90 };
+byte_t pncmd_target_get_status [ 2] = { 0xD4,0x8A };
// Exchange raw data frames
-byte pncmd_exchange_raw_data [266] = { 0xD4,0x42 };
+byte_t pncmd_exchange_raw_data [266] = { 0xD4,0x42 };
// Global buffers used for communication with the PN53X chip
#define MAX_FRAME_LEN 264
-static byte abtRx[MAX_FRAME_LEN];
-static ui32 uiRxLen;
+static byte_t abtRx[MAX_FRAME_LEN];
+static uint32_t uiRxLen;
-bool pn53x_transceive(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen)
+bool pn53x_transceive(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxLen)
{
// Reset the receiving buffer
uiRxLen = MAX_FRAME_LEN;
@@ -105,31 +110,31 @@ bool pn53x_transceive(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen
return true;
}
-byte pn53x_get_reg(const dev_info* pdi, ui16 ui16Reg)
+byte_t pn53x_get_reg(const dev_info* pdi, uint16_t ui16Reg)
{
- ui8 ui8Value;
- ui32 uiValueLen = 1;
+ uint8_t ui8Value;
+ uint32_t uiValueLen = 1;
pncmd_get_register[2] = ui16Reg >> 8;
pncmd_get_register[3] = ui16Reg & 0xff;
pdi->pdc->transceive(pdi->ds,pncmd_get_register,4,&ui8Value,&uiValueLen);
return ui8Value;
}
-bool pn53x_set_reg(const dev_info* pdi, ui16 ui16Reg, ui8 ui8SybmolMask, ui8 ui8Value)
+bool pn53x_set_reg(const dev_info* pdi, uint16_t ui16Reg, uint8_t ui8SybmolMask, uint8_t ui8Value)
{
pncmd_set_register[2] = ui16Reg >> 8;
pncmd_set_register[3] = ui16Reg & 0xff;
pncmd_set_register[4] = ui8Value | (pn53x_get_reg(pdi,ui16Reg) & (~ui8SybmolMask));
- return pdi->pdc->transceive(pdi->ds,pncmd_set_register,5,null,null);
+ return pdi->pdc->transceive(pdi->ds,pncmd_set_register,5,NULL,NULL);
}
-bool pn53x_set_parameters(const dev_info* pdi, ui8 ui8Value)
+bool pn53x_set_parameters(const dev_info* pdi, uint8_t ui8Value)
{
pncmd_set_parameters[2] = ui8Value;
- return pdi->pdc->transceive(pdi->ds,pncmd_set_parameters,3,null,null);
+ return pdi->pdc->transceive(pdi->ds,pncmd_set_parameters,3,NULL,NULL);
}
-bool pn53x_set_tx_bits(const dev_info* pdi, ui8 ui8Bits)
+bool pn53x_set_tx_bits(const dev_info* pdi, uint8_t ui8Bits)
{
// Test if we need to update the transmission bits register setting
if (pdi->ui8TxBits != ui8Bits)
@@ -143,13 +148,13 @@ bool pn53x_set_tx_bits(const dev_info* pdi, ui8 ui8Bits)
return true;
}
-bool pn53x_wrap_frame(const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar, byte* pbtFrame, ui32* puiFrameBits)
+bool pn53x_wrap_frame(const byte_t* pbtTx, const uint32_t uiTxBits, const byte_t* pbtTxPar, byte_t* pbtFrame, uint32_t* puiFrameBits)
{
- byte btFrame;
- byte btData;
- ui32 uiBitPos;
- ui32 uiDataPos = 0;
- ui32 uiBitsLeft = uiTxBits;
+ byte_t btFrame;
+ byte_t btData;
+ uint32_t uiBitPos;
+ uint32_t uiDataPos = 0;
+ uint32_t uiBitsLeft = uiTxBits;
// Make sure we should frame at least something
if (uiBitsLeft == 0) return false;
@@ -199,14 +204,14 @@ bool pn53x_wrap_frame(const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxP
}
}
-bool pn53x_unwrap_frame(const byte* pbtFrame, const ui32 uiFrameBits, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar)
+bool pn53x_unwrap_frame(const byte_t* pbtFrame, const uint32_t uiFrameBits, byte_t* pbtRx, uint32_t* puiRxBits, byte_t* pbtRxPar)
{
- byte btFrame;
- byte btData;
- ui8 uiBitPos;
- ui32 uiDataPos = 0;
- byte* pbtFramePos = (byte*) pbtFrame;
- ui32 uiBitsLeft = uiFrameBits;
+ byte_t btFrame;
+ byte_t btData;
+ uint8_t uiBitPos;
+ uint32_t uiDataPos = 0;
+ byte_t* pbtFramePos = (byte_t*) pbtFrame;
+ uint32_t uiBitsLeft = uiFrameBits;
// Make sure we should frame at least something
if (uiBitsLeft == 0) return false;
@@ -233,7 +238,7 @@ bool pn53x_unwrap_frame(const byte* pbtFrame, const ui32 uiFrameBits, byte* pbtR
btFrame = mirror(pbtFramePos[uiDataPos+1]);
btData |= (btFrame >> (8-uiBitPos));
pbtRx[uiDataPos] = mirror(btData);
- if(pbtRxPar != null) pbtRxPar[uiDataPos] = ((btFrame >> (7-uiBitPos)) & 0x01);
+ if(pbtRxPar != NULL) pbtRxPar[uiDataPos] = ((btFrame >> (7-uiBitPos)) & 0x01);
// Increase the data (without parity bit) position
uiDataPos++;
// Test if we are done
@@ -248,9 +253,9 @@ bool pn53x_unwrap_frame(const byte* pbtFrame, const ui32 uiFrameBits, byte* pbtR
dev_info* nfc_connect()
{
dev_info* pdi;
- ui32 uiDev;
- byte abtFw[4];
- ui32 uiFwLen = sizeof(abtFw);
+ uint32_t uiDev;
+ byte_t abtFw[4];
+ uint32_t uiFwLen = sizeof(abtFw);
// Search through the device list for an available device
for (uiDev=0; uiDevpdc = &(dev_callbacks_list[uiDev]);
- pdi->pdc->transceive(pdi->ds,pncmd_get_register,4,null,null);
+ pdi->pdc->transceive(pdi->ds,pncmd_get_register,4,NULL,NULL);
// Try to retrieve PN53x chip revision
if (!pdi->pdc->transceive(pdi->ds,pncmd_get_firmware_version,2,abtFw,&uiFwLen))
@@ -307,7 +312,7 @@ void nfc_disconnect(dev_info* pdi)
bool nfc_configure(dev_info* pdi, const dev_config_option dco, const bool bEnable)
{
- byte btValue;
+ byte_t btValue;
// Make sure we are dealing with a active device
if (!pdi->bActive) return false;
@@ -332,7 +337,7 @@ bool nfc_configure(dev_info* pdi, const dev_config_option dco, const bool bEnabl
case DCO_ACTIVATE_FIELD:
pncmd_rf_configure_field[3] = (bEnable) ? 1 : 0;
- if (!pdi->pdc->transceive(pdi->ds,pncmd_rf_configure_field,4,null,null)) return false;
+ if (!pdi->pdc->transceive(pdi->ds,pncmd_rf_configure_field,4,NULL,NULL)) return false;
break;
case DCO_ACTIVATE_CRYPTO1:
@@ -345,7 +350,7 @@ bool nfc_configure(dev_info* pdi, const dev_config_option dco, const bool bEnabl
pncmd_rf_configure_retry_select[3] = (bEnable) ? 0xff : 0x00; // MxRtyATR, default: active = 0xff, passive = 0x02
pncmd_rf_configure_retry_select[4] = (bEnable) ? 0xff : 0x00; // MxRtyPSL, default: 0x01
pncmd_rf_configure_retry_select[5] = (bEnable) ? 0xff : 0x00; // MxRtyPassiveActivation, default: 0xff
- if(!pdi->pdc->transceive(pdi->ds,pncmd_rf_configure_retry_select,6,null,null)) return false;
+ if(!pdi->pdc->transceive(pdi->ds,pncmd_rf_configure_retry_select,6,NULL,NULL)) return false;
break;
case DCO_ACCEPT_INVALID_FRAMES:
@@ -379,7 +384,7 @@ bool nfc_reader_init(const dev_info* pdi)
return true;
}
-bool nfc_reader_select(const dev_info* pdi, const init_modulation im, const byte* pbtInitData, const ui32 uiInitDataLen, tag_info* pti)
+bool nfc_reader_select(const dev_info* pdi, const init_modulation im, const byte_t* pbtInitData, const uint32_t uiInitDataLen, tag_info* pti)
{
// Make sure we are dealing with a active device
if (!pdi->bActive) return false;
@@ -477,14 +482,14 @@ bool nfc_reader_select(const dev_info* pdi, const init_modulation im, const byte
bool nfc_reader_deselect(const dev_info* pdi)
{
- return (pdi->pdc->transceive(pdi->ds,pncmd_reader_deselect,3,null,null));
+ return (pdi->pdc->transceive(pdi->ds,pncmd_reader_deselect,3,NULL,NULL));
}
-bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar)
+bool nfc_reader_transceive_bits(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxBits, const byte_t* pbtTxPar, byte_t* pbtRx, uint32_t* puiRxBits, byte_t* pbtRxPar)
{
- ui32 uiFrameBits = 0;
- ui32 uiFrameBytes = 0;
- ui8 ui8Bits = 0;
+ uint32_t uiFrameBits = 0;
+ uint32_t uiFrameBytes = 0;
+ uint8_t ui8Bits = 0;
// Check if we should prepare the parity bits ourself
if (!pdi->bPar)
@@ -534,7 +539,7 @@ bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const ui
return true;
}
-bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen)
+bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen)
{
// We can not just send bytes without parity if while the PN53X expects we handled them
if (!pdi->bPar) return false;
@@ -559,9 +564,9 @@ bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte* pbtTx, const u
return true;
}
-bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const ui8 ui8Block, mifare_param* pmp)
+bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const uint8_t ui8Block, mifare_param* pmp)
{
- ui32 uiParamLen;
+ uint32_t uiParamLen;
// Make sure we are dealing with a active device
if (!pdi->bActive) return false;
@@ -603,7 +608,7 @@ bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const ui8 u
}
// When available, copy the parameter bytes
- if (uiParamLen) memcpy(pncmd_reader_exchange_data+5,(byte*)pmp,uiParamLen);
+ if (uiParamLen) memcpy(pncmd_reader_exchange_data+5,(byte_t*)pmp,uiParamLen);
// Fire the mifare command
if (!pn53x_transceive(pdi,pncmd_reader_exchange_data,5+uiParamLen)) return false;
@@ -615,9 +620,9 @@ bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const ui8 u
return true;
}
-bool nfc_target_init(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits)
+bool nfc_target_init(const dev_info* pdi, byte_t* pbtRx, uint32_t* puiRxBits)
{
- ui8 ui8Bits;
+ uint8_t ui8Bits;
// Save the current configuration settings
bool bCrc = pdi->bCrc;
@@ -665,10 +670,10 @@ bool nfc_target_init(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits)
return true;
}
-bool nfc_target_receive_bits(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar)
+bool nfc_target_receive_bits(const dev_info* pdi, byte_t* pbtRx, uint32_t* puiRxBits, byte_t* pbtRxPar)
{
- ui32 uiFrameBits;
- ui8 ui8Bits;
+ uint32_t uiFrameBits;
+ uint8_t ui8Bits;
// Try to gather a received frame from the reader
if (!pn53x_transceive(pdi,pncmd_target_receive,2)) return false;
@@ -695,7 +700,7 @@ bool nfc_target_receive_bits(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits,
return true;
}
-bool nfc_target_receive_bytes(const dev_info* pdi, byte* pbtRx, ui32* puiRxLen)
+bool nfc_target_receive_bytes(const dev_info* pdi, byte_t* pbtRx, uint32_t* puiRxLen)
{
// Try to gather a received frame from the reader
if (!pn53x_transceive(pdi,pncmd_target_receive,2)) return false;
@@ -710,11 +715,11 @@ bool nfc_target_receive_bytes(const dev_info* pdi, byte* pbtRx, ui32* puiRxLen)
return true;
}
-bool nfc_target_send_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar)
+bool nfc_target_send_bits(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxBits, const byte_t* pbtTxPar)
{
- ui32 uiFrameBits = 0;
- ui32 uiFrameBytes = 0;
- ui8 ui8Bits = 0;
+ uint32_t uiFrameBits = 0;
+ uint32_t uiFrameBytes = 0;
+ uint8_t ui8Bits = 0;
// Check if we should prepare the parity bits ourself
if (!pdi->bPar)
@@ -745,7 +750,7 @@ bool nfc_target_send_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiT
}
-bool nfc_target_send_bytes(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen)
+bool nfc_target_send_bytes(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxLen)
{
// We can not just send bytes without parity if while the PN53X expects we handled them
if (!pdi->bPar) return false;
diff --git a/src/libnfc.h b/src/libnfc.h
index f122137..b5d9822 100644
--- a/src/libnfc.h
+++ b/src/libnfc.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,35 +13,37 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#ifndef _LIBNFC_H_
#define _LIBNFC_H_
+#include
+#include
+
#include "defines.h"
#include "types.h"
#include "bitutils.h"
-#include "devices.h"
-dev_info* nfc_connect();
+dev_info* nfc_connect(void);
void nfc_disconnect(dev_info* pdi);
bool nfc_configure(dev_info* pdi, const dev_config_option dco, const bool bEnable);
bool nfc_reader_init(const dev_info* pdi);
-bool nfc_reader_select(const dev_info* pdi, const init_modulation im, const byte* pbtInitData, const ui32 uiInitDataLen, tag_info* pti);
+bool nfc_reader_select(const dev_info* pdi, const init_modulation im, const byte_t* pbtInitData, const uint32_t uiInitDataLen, tag_info* pti);
bool nfc_reader_deselect(const dev_info* pdi);
-bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar);
-bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
-bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const ui8 ui8Block, mifare_param* pmp);
+bool nfc_reader_transceive_bits(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxBits, const byte_t* pbtTxPar, byte_t* pbtRx, uint32_t* puiRxBits, byte_t* pbtRxPar);
+bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen);
+bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const uint8_t ui8Block, mifare_param* pmp);
-bool nfc_target_init(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits);
-bool nfc_target_receive_bits(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar);
-bool nfc_target_receive_bytes(const dev_info* pdi, byte* pbtRx, ui32* puiRxLen);
-bool nfc_target_send_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar);
-bool nfc_target_send_bytes(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen);
+bool nfc_target_init(const dev_info* pdi, byte_t* pbtRx, uint32_t* puiRxBits);
+bool nfc_target_receive_bits(const dev_info* pdi, byte_t* pbtRx, uint32_t* puiRxBits, byte_t* pbtRxPar);
+bool nfc_target_receive_bytes(const dev_info* pdi, byte_t* pbtRx, uint32_t* puiRxLen);
+bool nfc_target_send_bits(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxBits, const byte_t* pbtTxPar);
+bool nfc_target_send_bytes(const dev_info* pdi, const byte_t* pbtTx, const uint32_t uiTxLen);
#endif // _LIBNFC_H_
diff --git a/src/list.c b/src/list.c
index be02e9b..649939b 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1,96 +1,99 @@
-/*
-
-Public platform independent Near Field Communication (NFC) library
-Copyright (C) 2009, Roel Verdult
-
-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 .
-
-*/
-
-#include
-#include
-#include
-#include "libnfc.h"
-
-static dev_info* pdi;
-static byte abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 };
-
-int main(int argc, const char* argv[])
-{
- tag_info ti;
-
- // Try to open the NFC reader
- pdi = nfc_connect();
-
- if (pdi == INVALID_DEVICE_INFO)
- {
- printf("Error connecting NFC reader\n");
- return 1;
- }
- nfc_reader_init(pdi);
-
+/*
+
+Public platform independent Near Field Communication (NFC) library
+Copyright (C) 2009, Roel Verdult
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser 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 Lesser General Public License
+along with this program. If not, see
+
+*/
+
+#include
+#include
+#include
+
+#include
+
+#include "libnfc.h"
+
+static dev_info* pdi;
+static byte_t abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 };
+
+int main(int argc, const char* argv[])
+{
+ tag_info ti;
+
+ // Try to open the NFC reader
+ pdi = nfc_connect();
+
+ if (pdi == INVALID_DEVICE_INFO)
+ {
+ printf("Error connecting NFC reader\n");
+ return 1;
+ }
+ nfc_reader_init(pdi);
+
// Drop the field for a while
nfc_configure(pdi,DCO_ACTIVATE_FIELD,false);
-
- // Let the reader only try once to find a tag
- nfc_configure(pdi,DCO_INFINITE_SELECT,false);
-
- // Configure the CRC and Parity settings
- nfc_configure(pdi,DCO_HANDLE_CRC,true);
- nfc_configure(pdi,DCO_HANDLE_PARITY,true);
-
- // Enable field so more power consuming cards can power themselves up
- nfc_configure(pdi,DCO_ACTIVATE_FIELD,true);
-
- printf("\nConnected to NFC reader: %s\n\n",pdi->acName);
-
- // Poll for a ISO14443A (MIFARE) tag
- if (nfc_reader_select(pdi,IM_ISO14443A_106,null,null,&ti))
- {
- printf("The following (NFC) ISO14443A tag was found:\n\n");
- printf(" ATQA (SENS_RES): "); print_hex(ti.tia.abtAtqa,2);
- printf(" UID (NFCID%c): ",(ti.tia.abtUid[0]==0x08?'3':'1')); print_hex(ti.tia.abtUid,ti.tia.uiUidLen);
- printf(" SAK (SEL_RES): "); print_hex(&ti.tia.btSak,1);
- if (ti.tia.uiAtsLen)
- {
- printf(" ATS (ATR): ");
- print_hex(ti.tia.abtAts,ti.tia.uiAtsLen);
- }
- }
-
- // Poll for a Felica tag
- if (nfc_reader_select(pdi,IM_FELICA_212,abtFelica,5,&ti) || nfc_reader_select(pdi,IM_FELICA_424,abtFelica,5,&ti))
- {
- printf("The following (NFC) Felica tag was found:\n\n");
- printf("%18s","ID (NFCID2): "); print_hex(ti.tif.abtId,8);
- printf("%18s","Parameter (PAD): "); print_hex(ti.tif.abtPad,8);
- }
-
- // Poll for a ISO14443B tag
- if (nfc_reader_select(pdi,IM_ISO14443B_106,null,null,&ti))
- {
- // No test results yet
- printf("iso14443b\n");
- }
-
- // Poll for a Jewel tag
- if (nfc_reader_select(pdi,IM_JEWEL_106,null,null,&ti))
- {
- // No test results yet
- printf("jewel\n");
- }
-
- nfc_disconnect(pdi);
- return 1;
-}
+
+ // Let the reader only try once to find a tag
+ nfc_configure(pdi,DCO_INFINITE_SELECT,false);
+
+ // Configure the CRC and Parity settings
+ nfc_configure(pdi,DCO_HANDLE_CRC,true);
+ nfc_configure(pdi,DCO_HANDLE_PARITY,true);
+
+ // Enable field so more power consuming cards can power themselves up
+ nfc_configure(pdi,DCO_ACTIVATE_FIELD,true);
+
+ printf("\nConnected to NFC reader: %s\n\n",pdi->acName);
+
+ // Poll for a ISO14443A (MIFARE) tag
+ if (nfc_reader_select(pdi,IM_ISO14443A_106,NULL,0,&ti))
+ {
+ printf("The following (NFC) ISO14443A tag was found:\n\n");
+ printf(" ATQA (SENS_RES): "); print_hex(ti.tia.abtAtqa,2);
+ printf(" UID (NFCID%c): ",(ti.tia.abtUid[0]==0x08?'3':'1')); print_hex(ti.tia.abtUid,ti.tia.uiUidLen);
+ printf(" SAK (SEL_RES): "); print_hex(&ti.tia.btSak,1);
+ if (ti.tia.uiAtsLen)
+ {
+ printf(" ATS (ATR): ");
+ print_hex(ti.tia.abtAts,ti.tia.uiAtsLen);
+ }
+ }
+
+ // Poll for a Felica tag
+ if (nfc_reader_select(pdi,IM_FELICA_212,abtFelica,5,&ti) || nfc_reader_select(pdi,IM_FELICA_424,abtFelica,5,&ti))
+ {
+ printf("The following (NFC) Felica tag was found:\n\n");
+ printf("%18s","ID (NFCID2): "); print_hex(ti.tif.abtId,8);
+ printf("%18s","Parameter (PAD): "); print_hex(ti.tif.abtPad,8);
+ }
+
+ // Poll for a ISO14443B tag
+ if (nfc_reader_select(pdi,IM_ISO14443B_106,NULL,0,&ti))
+ {
+ // No test results yet
+ printf("iso14443b\n");
+ }
+
+ // Poll for a Jewel tag
+ if (nfc_reader_select(pdi,IM_JEWEL_106,NULL,0,&ti))
+ {
+ // No test results yet
+ printf("jewel\n");
+ }
+
+ nfc_disconnect(pdi);
+ return 1;
+}
diff --git a/src/mftool.c b/src/mftool.c
index fb390d2..fbeb4ce 100644
--- a/src/mftool.c
+++ b/src/mftool.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,13 +13,17 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#include
#include
+#include
+#include
+#include
+
#include
#include
@@ -32,21 +36,21 @@ static mifare_param mp;
static mifare_tag mtKeys;
static mifare_tag mtDump;
static bool bUseKeyA;
-static ui32 uiBlocks;
+static uint32_t uiBlocks;
-bool is_first_block(ui32 uiBlock)
+bool is_first_block(uint32_t uiBlock)
{
// Test if we are in the small or big sectors
if (uiBlock < 128) return ((uiBlock)%4 == 0); else return ((uiBlock)%16 == 0);
}
-bool is_trailer_block(ui32 uiBlock)
+bool is_trailer_block(uint32_t uiBlock)
{
// Test if we are in the small or big sectors
if (uiBlock < 128) return ((uiBlock+1)%4 == 0); else return ((uiBlock+1)%16 == 0);
}
-ui32 get_trailer_block(ui32 uiFirstBlock)
+uint32_t get_trailer_block(uint32_t uiFirstBlock)
{
// Test if we are in the small or big sectors
if (uiFirstBlock<128) return uiFirstBlock+3; else return uiFirstBlock+15;
@@ -54,7 +58,7 @@ ui32 get_trailer_block(ui32 uiFirstBlock)
bool read_card()
{
- i32 iBlock;
+ int32_t iBlock;
mifare_cmd mc;
bool bFailure = false;
@@ -71,7 +75,7 @@ bool read_card()
{
printf("x");
// When a failure occured we need to redo the anti-collision
- if (!nfc_reader_select(pdi,IM_ISO14443A_106,null,null,&ti))
+ if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,0,&ti))
{
printf("!\nError: tag was removed\n");
return 1;
@@ -136,8 +140,8 @@ bool read_card()
bool write_card()
{
- ui32 uiBlock;
- ui32 uiTrailerBlock;
+ uint32_t uiBlock;
+ uint32_t uiTrailerBlock;
bool bFailure = false;
mifare_cmd mc;
@@ -154,7 +158,7 @@ bool write_card()
{
printf("x");
// When a failure occured we need to redo the anti-collision
- if (!nfc_reader_select(pdi,IM_ISO14443A_106,null,null,&ti))
+ if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,0,&ti))
{
printf("!\nError: tag was removed\n");
return false;
@@ -227,7 +231,7 @@ int main(int argc, const char* argv[])
{
bool b4K;
bool bReadAction;
- byte* pbtUID;
+ byte_t* pbtUID;
FILE* pfKeys;
FILE* pfDump;
@@ -250,7 +254,7 @@ int main(int argc, const char* argv[])
bUseKeyA = (tolower(*(argv[2])) == 'a');
pfKeys = fopen(argv[3],"rb");
- if (pfKeys == null)
+ if (pfKeys == NULL)
{
printf("Could not open file: %s\n",argv[3]);
return 1;
@@ -269,7 +273,7 @@ int main(int argc, const char* argv[])
} else {
pfDump = fopen(argv[4],"rb");
- if (pfDump == null)
+ if (pfDump == NULL)
{
printf("Could not open dump file: %s\n",argv[4]);
return 1;
@@ -309,7 +313,7 @@ int main(int argc, const char* argv[])
printf("Connected to NFC reader: %s\n",pdi->acName);
// Try to find a MIFARE Classic tag
- if (!nfc_reader_select(pdi,IM_ISO14443A_106,null,null,&ti))
+ if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,0,&ti))
{
printf("Error: no tag was found\n");
nfc_disconnect(pdi);
@@ -348,7 +352,7 @@ int main(int argc, const char* argv[])
printf("Writing data to file: %s\n",argv[4]);
fflush(stdout);
pfDump = fopen(argv[4],"wb");
- if (pfKeys == null)
+ if (pfKeys == NULL)
{
printf("Could not open file: %s\n",argv[4]);
return 1;
diff --git a/src/mifaretag.h b/src/mifaretag.h
index b07e43d..dcea842 100644
--- a/src/mifaretag.h
+++ b/src/mifaretag.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,8 +13,8 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
@@ -24,21 +24,21 @@ along with this program. If not, see .
#include "defines.h"
typedef struct {
- byte abtUID[4];
- byte btBCC;
- byte btUnknown;
- byte abtATQA[2];
- byte abtUnknown[8];
+ byte_t abtUID[4];
+ byte_t btBCC;
+ byte_t btUnknown;
+ byte_t abtATQA[2];
+ byte_t abtUnknown[8];
} mifare_block_manufacturer;
typedef struct {
- byte abtData[16];
+ byte_t abtData[16];
} mifare_block_data;
typedef struct {
- byte abtKeyA[6];
- byte abtAccessBits[4];
- byte abtKeyB[6];
+ byte_t abtKeyA[6];
+ byte_t abtAccessBits[4];
+ byte_t abtKeyB[6];
} mifare_block_trailer;
typedef union {
diff --git a/src/nfc-anticol.1 b/src/nfc-anticol.1
new file mode 100644
index 0000000..83f47be
--- /dev/null
+++ b/src/nfc-anticol.1
@@ -0,0 +1,30 @@
+.TH NFC-ANTICOL 1 "June 26, 2009"
+.SH NAME
+nfc-anticol \- Demonstration NFC anti-collison command line tool based on libnfc
+.SH SYNOPSIS
+.B nfc-anticol
+.SH DESCRIPTION
+.B nfc-anticol
+is an anti-collision demonstration tool for ISO/IEC 14443-A tags, performed
+by custom constructed frames. The first frame must be a short frame which
+is only 7 bits long. Commercial SDK's often don't support a feature to send
+frames that are not a multiple of 8 bits (1 byte) long.
+This makes it impossible to do the anti-collision yourself.
+The developer has to rely on closed proprietary software and should hope it does not contain vulnerabilities during the anti-collision phase.
+Performing the anti-collision using custom frames could protect against a malicious tag that, for example, violates the standard by sending frames with unsupported lengths.
+
+.SH BUGS
+Please report any bugs on the
+.B libnfc
+forum at
+.BR http://www.libnfc.org/community/ "."
+.SH LICENCE
+.B libnfc
+and
+.B nfc-tools
+are covered by the GNU Lesser General Public License (LGPL), version 3.
+.SH AUTHORS
+Roel Verdult
+.PP
+This manual page was written by Romuald Conty .
+It is licensed under the terms of the GNU GPL (version 2 or later).
diff --git a/src/nfc-emulate.1 b/src/nfc-emulate.1
new file mode 100644
index 0000000..543b81e
--- /dev/null
+++ b/src/nfc-emulate.1
@@ -0,0 +1,31 @@
+.TH NFC-EMULATE 1 "June 26, 2009"
+.SH NAME
+nfc-emulate \- NFC target emulation command line tool based on libnfc
+.SH SYNOPSIS
+.B nfc-emulate
+.SH DESCRIPTION
+.B nfc-emulate
+is an tag emulatation tool. Tag emulation is one of the main added features in NFC.
+To avoid abuse of existing systems, manufacturers of the NFC controller intentionally did not
+support emulation of custom UID numbers.
+The emulate tool demonstrates that this can still be done using transmission of raw-frames.
+Fast communication is necessary to in time to respond during the anti-collision protocol.
+Using the USB interface gives some timing issues but an embedded microprocessor could
+be fast enough to emulate a tag with any UID. This makes it a serious thread
+for security systems that rely only on the uniqueness of the UID.
+
+.SH BUGS
+Please report any bugs on the
+.B libnfc
+forum at
+.BR http://www.libnfc.org/community/ "."
+.SH LICENCE
+.B libnfc
+and
+.B nfc-tools
+are covered by the GNU Lesser General Public License (LGPL), version 3.
+.SH AUTHORS
+Roel Verdult
+.PP
+This manual page was written by Romuald Conty .
+It is licensed under the terms of the GNU GPL (version 2 or later).
diff --git a/src/nfc-list.1 b/src/nfc-list.1
new file mode 100644
index 0000000..673def9
--- /dev/null
+++ b/src/nfc-list.1
@@ -0,0 +1,27 @@
+.TH NFC-LIST 1 "June 26, 2009"
+.SH NAME
+nfc-list \- List NFC targets command line tool based on libnfc
+.SH SYNOPSIS
+.B nfc-list
+.SH DESCRIPTION
+.B nfc-list
+utility attempts to select available tags in the field. The NFC
+controller is used to perform the selection procedure. This is different for each modulation type.
+It tries to find a ISO/IEC 14443 type A, type B, Felica or Jewel Topaz tags.
+This tool demonstrates that it is possible to setup a simple NFC system using less than 10 lines of code.
+
+.SH BUGS
+Please report any bugs on the
+.B libnfc
+forum at
+.BR http://www.libnfc.org/community/ "."
+.SH LICENCE
+.B libnfc
+and
+.B nfc-tools
+are covered by the GNU Lesser General Public License (LGPL), version 3.
+.SH AUTHORS
+Roel Verdult
+.PP
+This manual page was written by Romuald Conty .
+It is licensed under the terms of the GNU GPL (version 2 or later).
diff --git a/src/nfc-mftool.1 b/src/nfc-mftool.1
new file mode 100644
index 0000000..c3c17e3
--- /dev/null
+++ b/src/nfc-mftool.1
@@ -0,0 +1,57 @@
+.TH NFC-MFTOOL 1 "June 26, 2009"
+.SH NAME
+nfc-mftool \- Mifare Classic command line tool based on libnfc
+.SH SYNOPSIS
+.B nfc-mftool
+.RI \fR\fBr\fR|\fBw\fR
+.RI \fR\fBa\fR|\fBb\fR
+.IR KEYS
+.IR DUMP
+
+.SH DESCRIPTION
+.B nfc-mftool
+is an Mifare Classic tool that allow to read or write
+.IR DUMP
+file using Mifare keys provide in
+.IR KEYS
+file.
+
+The Mifare Classic tag is one of the most widely used RFID tags.
+The firmware in the NFC controller supports authenticating, reading and writing to/from Mifare Classic tags.
+This tool demonstrate the speed of this library and its easy-of-use.
+It possible to read and write the complete content of a Mifare Classic 4KB tag within 1 second.
+It uses a binary Mifare Dump File to store the keys and date for all sectors.
+
+.SH OPTIONS
+.BR r " | " w
+Perform read from (
+.B r
+) or write to (
+.B w
+)card.
+.TP
+.BR a " | " b
+Use A or B Mifare keys.
+.TP
+.IR KEYS
+Mifare dump that contain Mifare keys.
+.TP
+.IR DUMP
+Used to write card to file ( r ) or file to card ( w )
+
+
+.SH BUGS
+Please report any bugs on the
+.B libnfc
+forum at
+.BR http://www.libnfc.org/community/ "."
+.SH LICENCE
+.B libnfc
+and
+.B nfc-tools
+are covered by the GNU Lesser General Public License (LGPL), version 3.
+.SH AUTHORS
+Roel Verdult
+.PP
+This manual page was written by Romuald Conty .
+It is licensed under the terms of the GNU GPL (version 2 or later).
diff --git a/src/nfc-relay.1 b/src/nfc-relay.1
new file mode 100644
index 0000000..559f79b
--- /dev/null
+++ b/src/nfc-relay.1
@@ -0,0 +1,28 @@
+.TH NFC-RELAY 1 "June 26, 2009"
+.SH NAME
+nfc-relay \- Relay attack command line tool based on libnfc
+.SH SYNOPSIS
+.B nfc-relay
+.SH DESCRIPTION
+.B nfc-relay
+is an utility that demonstrates an relay attack. For this it requires two
+NFC devices. One will emulate an ISO/IEC 14443 type A tag, while the 2nd
+device will act as a reader. The genuine tag can be placed on the 2nd reader and
+the tag emulator can be placed close to the original reader. All communication
+is now relayed and shown in the screen on real-time.
+
+.SH BUGS
+Please report any bugs on the
+.B libnfc
+forum at
+.BR http://www.libnfc.org/community/ "."
+.SH LICENCE
+.B libnfc
+and
+.B nfc-tools
+are covered by the GNU Lesser General Public License (LGPL), version 3.
+.SH AUTHORS
+Roel Verdult
+.PP
+This manual page was written by Romuald Conty .
+It is licensed under the terms of the GNU GPL (version 2 or later).
diff --git a/src/relay.c b/src/relay.c
index 65c1566..aca9b8c 100644
--- a/src/relay.c
+++ b/src/relay.c
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,22 +13,24 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#include
#include
+#include
#include
+
#include "libnfc.h"
-static byte abtReaderRx[MAX_FRAME_LEN];
-static byte abtReaderRxPar[MAX_FRAME_LEN];
-static ui32 uiReaderRxBits;
-static byte abtTagRx[MAX_FRAME_LEN];
-static byte abtTagRxPar[MAX_FRAME_LEN];
-static ui32 uiTagRxBits;
+static byte_t abtReaderRx[MAX_FRAME_LEN];
+static byte_t abtReaderRxPar[MAX_FRAME_LEN];
+static uint32_t uiReaderRxBits;
+static byte_t abtTagRx[MAX_FRAME_LEN];
+static byte_t abtTagRxPar[MAX_FRAME_LEN];
+static uint32_t uiTagRxBits;
static dev_info* pdiReader;
static dev_info* pdiTag;
diff --git a/src/rs232.c b/src/rs232.c
index bbe9a0e..a8be31f 100644
--- a/src/rs232.c
+++ b/src/rs232.c
@@ -4,27 +4,30 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser 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 .
-
- Based on rs232-code written by Teunis van Beelen
- available: http://www.teuniz.net/RS-232/index.html
-
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
+
+*/
+
+/*
+Based on rs232-code written by Teunis van Beelen
+available: http://www.teuniz.net/RS-232/index.html
*/
#include "rs232.h"
-#ifndef _WIN32 /* Linux */
+// Test if we are dealing with unix operating systems
+#ifndef _WIN32
typedef struct termios term_info;
typedef struct {
@@ -93,15 +96,15 @@ void rs232_close(const serial_port sp)
bool rs232_cts(const serial_port sp)
{
- ulong ulStatus;
- if (ioctl(((serial_port_unix*)sp)->fd,TIOCMGET,&ulStatus) < 0) return false;
- return (ulStatus & TIOCM_CTS);
+ char status;
+ if (ioctl(((serial_port_unix*)sp)->fd,TIOCMGET,&status) < 0) return false;
+ return (status & TIOCM_CTS);
}
-bool rs232_receive(const serial_port sp, byte* pbtRx, ui32* puiRxLen)
+bool rs232_receive(const serial_port sp, byte_t* pbtRx, uint32_t* puiRxLen)
{
int iResult;
- ui32 uiCount = 0;
+ uint32_t uiCount = 0;
fd_set rfds;
while (true)
@@ -129,176 +132,92 @@ bool rs232_receive(const serial_port sp, byte* pbtRx, ui32* puiRxLen)
}
}
-bool rs232_send(const serial_port sp, const byte* pbtTx, const ui32 uiTxLen)
+bool rs232_send(const serial_port sp, const byte_t* pbtTx, const uint32_t uiTxLen)
{
int iResult;
iResult = write(((serial_port_unix*)sp)->fd,pbtTx,uiTxLen);
return (iResult >= 0);
}
-#else /* windows */
+#else
+// The windows serial port implementation
+typedef struct {
+ HANDLE hPort; // Serial port handle
+ DCB dcb; // Device control settings
+ COMMTIMEOUTS ct; // Serial port time-out configuration
+} serial_port_windows;
-HANDLE Cport[16];
-
-
-char comports[16][10]={"\\\\.\\COM1", "\\\\.\\COM2", "\\\\.\\COM3", "\\\\.\\COM4",
- "\\\\.\\COM5", "\\\\.\\COM6", "\\\\.\\COM7", "\\\\.\\COM8",
- "\\\\.\\COM9", "\\\\.\\COM10", "\\\\.\\COM11", "\\\\.\\COM12",
- "\\\\.\\COM13", "\\\\.\\COM14", "\\\\.\\COM15", "\\\\.\\COM16"};
-
-char baudr[64];
-
-
-int OpenComport(int comport_number, int baudrate)
+serial_port rs232_open(const char* pcPortName)
{
- if((comport_number>15)||(comport_number<0))
+ char acPortName[255];
+ serial_port_windows* sp = malloc(sizeof(serial_port_windows));
+
+ // Copy the input "com?" to "\\.\COM?" format
+ sprintf(acPortName,"\\\\.\\%s",pcPortName);
+ _strupr(acPortName);
+
+ // Try to open the serial port
+ sp->hPort = CreateFileA(acPortName,GENERIC_READ|GENERIC_WRITE,NULL,NULL,OPEN_EXISTING,NULL,NULL);
+ if (sp->hPort == INVALID_HANDLE_VALUE)
{
- printf("illegal comport number\n");
- return(1);
+ rs232_close(sp);
+ return INVALID_SERIAL_PORT;
}
- switch(baudrate)
+ // Prepare the device control
+ memset(&sp->dcb, 0, sizeof(DCB));
+ sp->dcb.DCBlength = sizeof(DCB);
+ if(!BuildCommDCBA("baud=9600 data=8 parity=N stop=1",&sp->dcb))
{
- sscanf(baudr,"baud=%d data=8 parity=N stop=1",baudrate);
-/*
- case 110 : strcpy(baudr, "baud=110 data=8 parity=N stop=1");
- break;
- case 300 : strcpy(baudr, "baud=300 data=8 parity=N stop=1");
- break;
- case 600 : strcpy(baudr, "baud=600 data=8 parity=N stop=1");
- break;
- case 1200 : strcpy(baudr, "baud=1200 data=8 parity=N stop=1");
- break;
- case 2400 : strcpy(baudr, "baud=2400 data=8 parity=N stop=1");
- break;
- case 4800 : strcpy(baudr, "baud=4800 data=8 parity=N stop=1");
- break;
- case 9600 : strcpy(baudr, "baud=9600 data=8 parity=N stop=1");
- break;
- case 19200 : strcpy(baudr, "baud=19200 data=8 parity=N stop=1");
- break;
- case 38400 : strcpy(baudr, "baud=38400 data=8 parity=N stop=1");
- break;
- case 57600 : strcpy(baudr, "baud=57600 data=8 parity=N stop=1");
- break;
- case 115200 : strcpy(baudr, "baud=115200 data=8 parity=N stop=1");
- break;
- case 128000 : strcpy(baudr, "baud=128000 data=8 parity=N stop=1");
- break;
- case 256000 : strcpy(baudr, "baud=256000 data=8 parity=N stop=1");
- break;
- default : printf("invalid baudrate\n");
- return(1);
- break;
-*/
+ rs232_close(sp);
+ return INVALID_SERIAL_PORT;
}
- Cport[comport_number] = CreateFileA(comports[comport_number],
- GENERIC_READ|GENERIC_WRITE,
- 0, /* no share */
- NULL, /* no security */
- OPEN_EXISTING,
- 0, /* no threads */
- NULL); /* no templates */
-
- if(Cport[comport_number]==INVALID_HANDLE_VALUE)
+ // Update the active serial port
+ if(!SetCommState(sp->hPort,&sp->dcb))
{
- printf("unable to open comport\n");
- return(1);
+ rs232_close(sp);
+ return INVALID_SERIAL_PORT;
}
- DCB port_settings;
- memset(&port_settings, 0, sizeof(port_settings)); /* clear the new struct */
- port_settings.DCBlength = sizeof(port_settings);
-
- if(!BuildCommDCBA(baudr, &port_settings))
- {
- printf("unable to set comport dcb settings\n");
- CloseHandle(Cport[comport_number]);
- return(1);
- }
-
- if(!SetCommState(Cport[comport_number], &port_settings))
- {
- printf("unable to set comport cfg settings\n");
- CloseHandle(Cport[comport_number]);
- return(1);
- }
-
- COMMTIMEOUTS Cptimeouts;
-
- Cptimeouts.ReadIntervalTimeout = MAXDWORD;
- Cptimeouts.ReadTotalTimeoutMultiplier = 0;
- Cptimeouts.ReadTotalTimeoutConstant = 0;
- Cptimeouts.WriteTotalTimeoutMultiplier = 0;
- Cptimeouts.WriteTotalTimeoutConstant = 0;
-
- if(!SetCommTimeouts(Cport[comport_number], &Cptimeouts))
- {
- printf("unable to set comport time-out settings\n");
- CloseHandle(Cport[comport_number]);
- return(1);
- }
-
- return(0);
-}
-
-
-int PollComport(int comport_number, unsigned char *buf, int size)
-{
- int n;
-
- if(size>4096) size = 4096;
-
-/* added the void pointer cast, otherwise gcc will complain about */
-/* "warning: dereferencing type-punned pointer will break strict aliasing rules" */
-
- ReadFile(Cport[comport_number], buf, size, (LPDWORD)((void *)&n), NULL);
-
- return(n);
-}
-
-
-int SendByte(int comport_number, unsigned char byte)
-{
- int n;
-
- WriteFile(Cport[comport_number], &byte, 1, (LPDWORD)((void *)&n), NULL);
-
- if(n<0) return(1);
-
- return(0);
-}
-
-
-int SendBuf(int comport_number, unsigned char *buf, int size)
-{
- int n;
-
- if(WriteFile(Cport[comport_number], buf, size, (LPDWORD)((void *)&n), NULL))
- {
- return(n);
- }
-
- return(-1);
-}
-
-bool rs232_cts(const serial_port sp);
-{
- int status;
+ sp->ct.ReadIntervalTimeout = 30;
+ sp->ct.ReadTotalTimeoutMultiplier = 0;
+ sp->ct.ReadTotalTimeoutConstant = 0;
+ sp->ct.WriteTotalTimeoutMultiplier = 0;
+ sp->ct.WriteTotalTimeoutConstant = 0;
- GetCommModemStatus(Cport[comport_number], (LPDWORD)((void *)&status));
-
- if(status&MS_CTS_ON) return(1);
- else return(0);
+ if(!SetCommTimeouts(sp->hPort,&sp->ct))
+ {
+ rs232_close(sp);
+ return INVALID_SERIAL_PORT;
+ }
+
+ return sp;
}
-
-void CloseComport(int comport_number)
+void rs232_close(const serial_port sp)
{
- CloseHandle(Cport[comport_number]);
+ CloseHandle(((serial_port_windows*)sp)->hPort);
+ free(sp);
}
+bool rs232_cts(const serial_port sp)
+{
+ DWORD dwStatus;
+ if (GetCommModemStatus(((serial_port_windows*)sp)->hPort,&dwStatus) == NULL) return false;
+ return (dwStatus & MS_CTS_ON);
+}
+
+bool rs232_receive(const serial_port sp, byte_t* pbtRx, uint32_t* puiRxLen)
+{
+ return (ReadFile(((serial_port_windows*)sp)->hPort,pbtRx,*puiRxLen,(LPDWORD)puiRxLen,NULL) != NULL);
+}
+
+bool rs232_send(const serial_port sp, const byte_t* pbtTx, const uint32_t uiTxLen)
+{
+ DWORD dwTxLen;
+ return (WriteFile(((serial_port_windows*)sp)->hPort,pbtTx,uiTxLen,&dwTxLen,NULL) != NULL);
+}
#endif
diff --git a/src/rs232.h b/src/rs232.h
index 3a5b95d..e1c6518 100644
--- a/src/rs232.h
+++ b/src/rs232.h
@@ -4,18 +4,18 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser 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 .
-
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
+
*/
#ifndef _LIBNFC_RS232_H_
@@ -36,6 +36,7 @@ along with this program. If not, see .
#include
#include
#include
+ #include
#else
#include
#endif
@@ -48,8 +49,8 @@ typedef void* serial_port;
serial_port rs232_open(const char* pcPortName);
void rs232_close(const serial_port sp);
bool rs232_cts(const serial_port sp);
-bool rs232_receive(const serial_port sp, byte* pbtRx, ui32* puiRxLen);
-bool rs232_send(const serial_port sp, const byte* pbtTx, const ui32 uiTxLen);
+bool rs232_receive(const serial_port sp, byte_t* pbtRx, uint32_t* puiRxLen);
+bool rs232_send(const serial_port sp, const byte_t* pbtTx, const uint32_t uiTxLen);
#endif // _LIBNFC_RS232_H_
diff --git a/src/types.h b/src/types.h
index ab3c02d..0babe2a 100644
--- a/src/types.h
+++ b/src/types.h
@@ -4,7 +4,7 @@ Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
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
+it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -13,23 +13,23 @@ 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 .
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see
*/
#ifndef _LIBNFC_TYPES_H_
#define _LIBNFC_TYPES_H_
+#include
+#include
+
#include "defines.h"
-// Compiler directive, set struct alignment to 1 byte for compatibility
-#pragma pack(1)
+typedef uint8_t byte_t;
-typedef enum {
- false = 0x00,
- true = 0x01
-} bool;
+// Compiler directive, set struct alignment to 1 byte_t for compatibility
+#pragma pack(1)
typedef enum {
CT_PN531 = 0x10,
@@ -47,13 +47,13 @@ typedef struct {
bool bActive; // This represents if the PN53X device was initialized succesful
bool bCrc; // Is the crc automaticly added, checked and removed from the frames
bool bPar; // Does the PN53x chip handles parity bits, all parities are handled as data
- ui8 ui8TxBits; // The last tx bits setting, we need to reset this if it does not apply anymore
+ uint8_t ui8TxBits; // The last tx bits setting, we need to reset this if it does not apply anymore
} dev_info;
struct dev_callbacks {
const char* acDriver; // Driver description
- dev_info* (*connect)(const ui32 uiIndex);
- bool (*transceive)(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
+ dev_info* (*connect)(const uint32_t uiIndex);
+ bool (*transceive)(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen);
void (*disconnect)(dev_info* pdi);
};
@@ -79,37 +79,37 @@ typedef enum {
}init_modulation;
typedef struct {
- byte abtAtqa[2];
- byte btSak;
- ui32 uiUidLen;
- byte abtUid[10];
- ui32 uiAtsLen;
- byte abtAts[36];
+ byte_t abtAtqa[2];
+ byte_t btSak;
+ uint32_t uiUidLen;
+ byte_t abtUid[10];
+ uint32_t uiAtsLen;
+ byte_t abtAts[36];
}tag_info_iso14443a;
typedef struct {
- ui32 uiLen;
- byte btResCode;
- byte abtId[8];
- byte abtPad[8];
- byte abtSysCode[2];
+ uint32_t uiLen;
+ byte_t btResCode;
+ byte_t abtId[8];
+ byte_t abtPad[8];
+ byte_t abtSysCode[2];
}tag_info_felica;
typedef struct {
- byte abtAtqb[12];
- byte abtId[4];
- byte btParam1;
- byte btParam2;
- byte btParam3;
- byte btParam4;
- byte btCid;
- ui32 uiInfLen;
- byte abtInf[64];
+ byte_t abtAtqb[12];
+ byte_t abtId[4];
+ byte_t btParam1;
+ byte_t btParam2;
+ byte_t btParam3;
+ byte_t btParam4;
+ byte_t btCid;
+ uint32_t uiInfLen;
+ byte_t abtInf[64];
}tag_info_iso14443b;
typedef struct {
- byte btSensRes[2];
- byte btId[4];
+ byte_t btSensRes[2];
+ byte_t btId[4];
}tag_info_jewel;
typedef union {
@@ -135,16 +135,16 @@ typedef enum {
// MIFARE Classic command params
typedef struct {
- byte abtKey[6];
- byte abtUid[4];
+ byte_t abtKey[6];
+ byte_t abtUid[4];
}mifare_param_auth;
typedef struct {
- byte abtData[16];
+ byte_t abtData[16];
}mifare_param_data;
typedef struct {
- byte abtValue[4];
+ byte_t abtValue[4];
}mifare_param_value;
typedef union {
diff --git a/manualmake/win32/WINSCARD.LIB b/win32/WINSCARD.LIB
similarity index 100%
rename from manualmake/win32/WINSCARD.LIB
rename to win32/WINSCARD.LIB
diff --git a/manualmake/win32/anticol.vcproj b/win32/anticol.vcproj
similarity index 100%
rename from manualmake/win32/anticol.vcproj
rename to win32/anticol.vcproj
diff --git a/manualmake/win32/emulate.vcproj b/win32/emulate.vcproj
similarity index 100%
rename from manualmake/win32/emulate.vcproj
rename to win32/emulate.vcproj
diff --git a/manualmake/win32/libnfc.def b/win32/libnfc.def
similarity index 100%
rename from manualmake/win32/libnfc.def
rename to win32/libnfc.def
diff --git a/manualmake/win32/libnfc.sln b/win32/libnfc.sln
similarity index 100%
rename from manualmake/win32/libnfc.sln
rename to win32/libnfc.sln
diff --git a/manualmake/win32/libnfc.vcproj b/win32/libnfc.vcproj
similarity index 100%
rename from manualmake/win32/libnfc.vcproj
rename to win32/libnfc.vcproj
diff --git a/manualmake/win32/libusb/libusb.lib b/win32/libusb/libusb.lib
similarity index 100%
rename from manualmake/win32/libusb/libusb.lib
rename to win32/libusb/libusb.lib
diff --git a/manualmake/win32/libusb/libusb0.dll b/win32/libusb/libusb0.dll
similarity index 100%
rename from manualmake/win32/libusb/libusb0.dll
rename to win32/libusb/libusb0.dll
diff --git a/manualmake/win32/libusb/libusb0_x64.dll b/win32/libusb/libusb0_x64.dll
similarity index 100%
rename from manualmake/win32/libusb/libusb0_x64.dll
rename to win32/libusb/libusb0_x64.dll
diff --git a/manualmake/win32/libusb/usb.h b/win32/libusb/usb.h
similarity index 100%
rename from manualmake/win32/libusb/usb.h
rename to win32/libusb/usb.h
diff --git a/manualmake/win32/list.vcproj b/win32/list.vcproj
similarity index 100%
rename from manualmake/win32/list.vcproj
rename to win32/list.vcproj
diff --git a/manualmake/win32/mftool.vcproj b/win32/mftool.vcproj
similarity index 100%
rename from manualmake/win32/mftool.vcproj
rename to win32/mftool.vcproj
diff --git a/manualmake/win32/relay.vcproj b/win32/relay.vcproj
similarity index 100%
rename from manualmake/win32/relay.vcproj
rename to win32/relay.vcproj