aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-09-19 11:28:28 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-09-19 18:30:01 +0300
commit1153970626892573e5966e135e8d81185f4ea53c (patch)
tree773fdf5a8d00ec2ef752c3a8fd5f32c79829cf23
downloadeclat-1153970626892573e5966e135e8d81185f4ea53c.tar.gz
eclat-1153970626892573e5966e135e8d81185f4ea53c.tar.bz2
Initial commit
-rw-r--r--.gitignore26
-rw-r--r--.gitmodules3
-rw-r--r--AUTHORS1
-rw-r--r--COPYING674
-rw-r--r--Makefile.am27
-rw-r--r--NEWS33
-rw-r--r--README1
-rw-r--r--THANKS0
-rw-r--r--bootstrap5
-rw-r--r--configure.ac67
m---------grecs0
-rw-r--r--lib/Makefile.am28
-rw-r--r--lib/base64.c94
-rw-r--r--lib/hmac_sha1.c76
-rw-r--r--lib/libeclat.h29
-rw-r--r--lib/sha1.c418
-rw-r--r--lib/sha1.h98
-rw-r--r--lib/urlencode.c68
-rw-r--r--src/.gitignore2
-rw-r--r--src/Makefile.am44
-rw-r--r--src/accfile.c105
-rw-r--r--src/cmdline.opt226
-rw-r--r--src/config.c110
-rw-r--r--src/diag.c108
-rw-r--r--src/eclat.c162
-rw-r--r--src/eclat.h81
-rw-r--r--src/error.c64
-rw-r--r--src/startinst.c28
-rw-r--r--tests/.gitignore8
-rw-r--r--tests/Makefile.am79
-rw-r--r--tests/atlocal.in6
-rw-r--r--tests/hmac01.at25
-rw-r--r--tests/hmac02.at25
-rw-r--r--tests/hmac03.at26
-rw-r--r--tests/testsuite.at30
-rw-r--r--tests/thmac.c128
-rw-r--r--tests/turlenc.c46
-rw-r--r--tests/urlenc01.at28
38 files changed, 2979 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fd1d991
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,26 @@
+*.a
+*.o
+*.tar.*
+*~
+.deps
+.gdbinit
+.emacs.desktop
+.emacs.desktop.lock
+.emacsrc
+ABOUT-NLS
+ChangeLog
+INSTALL
+Makefile
+Makefile.in
+TAGS
+aclocal.m4
+autom4te.cache
+build-aux
+config.h
+config.h.in
+config.log
+config.status
+configure
+core
+m4
+stamp-h1
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..fea8f96
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "grecs"]
+ path = grecs
+ url = git://git.gnu.org.ua/grecs.git
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..ca6ccd1
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Sergey Poznyakoff <gray@gnu.org.ua>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..6d532d6
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,27 @@
+# This file is part of Eclat
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+ACLOCAL_AMFLAGS = -I grecs/am
+
+SUBDIRS = grecs lib src tests
+
+.PHONY: ChangeLog
+ChangeLog:
+ $(AM_V_GEN)if test -d .git; then \
+ git log --pretty='format:%ct %an <%ae>%n%n%s%n%n%b%n' | \
+ awk -f $(top_srcdir)/grecs/build-aux/git2chg.awk > ChangeLog; \
+ fi
+
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..a38e2aa
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,33 @@
+Eclat NEWS -- history of user-visible changes. 2012-09-19
+Copyright (C) 2012 Sergey Poznyakoff
+See the end of file for copying conditions.
+
+Please send Eclat bug reports to <gray+eclat@gnu.org.ua>
+
+
+No news is good news.
+
+=========================================================================
+Copyright information:
+
+Copyright (C) 2012 Sergey Poznyakoff
+
+ Permission is granted to anyone to make or distribute verbatim copies
+ of this document as received, in any medium, provided that the
+ copyright notice and this permission notice are preserved,
+ thus giving the recipient permission to redistribute in turn.
+
+ Permission is granted to distribute modified versions
+ of this document, or of portions of it,
+ under the above conditions, provided also that they
+ carry prominent notices stating who last changed them.
+
+Local variables:
+mode: outline
+paragraph-separate: "[ ]*$"
+eval: (add-hook 'write-file-hooks 'time-stamp)
+time-stamp-start: "changes. "
+time-stamp-format: "%:y-%02m-%02d"
+time-stamp-end: "\n"
+end:
+
diff --git a/README b/README
new file mode 100644
index 0000000..b7424b3
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+Eclat stands for Ec2 Command Line Administrator Tool. \ No newline at end of file
diff --git a/THANKS b/THANKS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/THANKS
diff --git a/bootstrap b/bootstrap
new file mode 100644
index 0000000..ae677ac
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,5 @@
+#! /bin/sh
+set -e
+git submodule init
+git submodule update
+autoreconf -f -i -s
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..c6384ab
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,67 @@
+# This file is part of Eclat -*- autoconf -*-
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+AC_PREREQ(2.63)
+AC_INIT([eclat], 0.1, [gray+eclat@gnu.org.ua])
+AC_CONFIG_SRCDIR([src/eclat.h])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_HEADER([config.h])
+AM_INIT_AUTOMAKE([1.11 gnits tar-ustar dist-xz std-options silent-rules])
+dnl AC_CONFIG_LIBOBJ_DIR([src])
+
+# Enable silent rules by default:
+AM_SILENT_RULES([yes])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_RANLIB
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([getopt.h])
+
+# Check for libcurl
+AC_ARG_VAR([CURL_CONFIG],[pathname of the curl-config binary])
+AC_ARG_VAR([CURL_CFLAGS],[cc flags to use when compiling with libcurl])
+AC_ARG_VAR([CURL_LIBS],[curl libraries to link with])
+
+if test -z "$CURL_LIBS"; then
+ if test -z "$CURL_CONFIG"; then
+ AC_PATH_PROG(CURL_CONFIG, curl-config, none, $PATH)
+ fi
+ if test "$CURL_CONFIG" = "none"; then
+ AC_MSG_ERROR([cannot find libcurl])
+ fi
+ CURL_CFLAGS=`$CURL_CONFIG --cflags`
+ CURL_LIBS=`$CURL_CONFIG --libs`
+ # FIXME: Check curl version?
+fi
+
+# Grecs subsystem
+
+GRECS_SETUP([grecs],[tests getopt git2chg])
+
+# Initialize the test suite.
+AC_CONFIG_TESTDIR(tests)
+AC_CONFIG_FILES([tests/Makefile tests/atlocal])
+AM_MISSING_PROG([AUTOM4TE], [autom4te])
+
+AC_CONFIG_FILES([Makefile
+ lib/Makefile
+ src/Makefile])
+
+AC_OUTPUT
+
diff --git a/grecs b/grecs
new file mode 160000
+Subproject 0b44dc8fcb5c4a4d4b8c7e74a90d8bda602ed22
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 0000000..522a5bf
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1,28 @@
+# This file is part of Eclat
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+noinst_LIBRARIES=libeclat.a
+
+libeclat_a_SOURCES=\
+ base64.c\
+ hmac_sha1.c\
+ libeclat.h\
+ sha1.c\
+ sha1.h\
+ urlencode.c
+
+AM_LDFLAGS = $(CURL_LIBS)
+INCLUDES = -I$(top_srcdir)/grecs/src/ $(CURL_CFLAGS)
diff --git a/lib/base64.c b/lib/base64.c
new file mode 100644
index 0000000..ee37e49
--- /dev/null
+++ b/lib/base64.c
@@ -0,0 +1,94 @@
+/* This file is part of Eclat
+ Copyright (C) 2012 Sergey Poznyakoff
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+/* The code taken from Mailutils, with minor modifications */
+
+#include "libeclat.h"
+#include "grecs.h"
+
+static char b64tab[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static int b64val[128] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
+ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
+};
+
+void
+eclat_base64_encode(const unsigned char *input, size_t input_len,
+ unsigned char **output, size_t *output_len)
+{
+ size_t olen = 4 * (input_len + 2) / 3 + 1;
+ unsigned char *out = grecs_malloc(olen);
+
+ *output = out;
+ while (input_len >= 3) {
+ *out++ = b64tab[input[0] >> 2];
+ *out++ = b64tab[((input[0] << 4) & 0x30) | (input[1] >> 4)];
+ *out++ = b64tab[((input[1] << 2) & 0x3c) | (input[2] >> 6)];
+ *out++ = b64tab[input[2] & 0x3f];
+ input_len -= 3;
+ input += 3;
+ }
+
+ if (input_len > 0) {
+ unsigned char c = (input[0] << 4) & 0x30;
+ *out++ = b64tab[input[0] >> 2];
+ if (input_len > 1)
+ c |= input[1] >> 4;
+ *out++ = b64tab[c];
+ *out++ = (input_len < 2) ? '=' : b64tab[(input[1] << 2) & 0x3c];
+ *out++ = '=';
+ }
+ *output_len = out - *output;
+ *out = 0;
+}
+
+int
+eclat_base64_decode(const unsigned char *input, size_t input_len,
+ unsigned char **output, size_t *output_len)
+{
+ int olen = input_len;
+ unsigned char *out = grecs_malloc(olen);
+
+ *output = out;
+ do {
+ if (input[0] > 127 || b64val[input[0]] == -1
+ || input[1] > 127 || b64val[input[1]] == -1
+ || input[2] > 127 ||
+ ((input[2] != '=') && (b64val[input[2]] == -1))
+ || input[3] > 127 ||
+ ((input[3] != '=') && (b64val[input[3]] == -1)))
+ return 1;
+ *out++ = (b64val[input[0]] << 2) | (b64val[input[1]] >> 4);
+ if (input[2] != '=') {
+ *out++ = ((b64val[input[1]] << 4) & 0xf0) |
+ (b64val[input[2]] >> 2);
+ if (input[3] != '=')
+ *out++ = ((b64val[input[2]] << 6) & 0xc0) |
+ b64val[input[3]];
+ }
+ input += 4;
+ input_len -= 4;
+ } while (input_len > 0);
+ *output_len = out - *output;
+ return 0;
+}
diff --git a/lib/hmac_sha1.c b/lib/hmac_sha1.c
new file mode 100644
index 0000000..2b4c0c0
--- /dev/null
+++ b/lib/hmac_sha1.c
@@ -0,0 +1,76 @@
+/* This file is part of Eclat
+ Copyright (C) 2012 Sergey Poznyakoff
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "libeclat.h"
+#include "sha1.h"
+#include <string.h>
+
+#define IPAD 0x36
+#define OPAD 0x5c
+
+void
+hmac_sha1(const void *text, size_t textlen,
+ const void *key, size_t keylen,
+ void *digest)
+{
+ size_t i;
+ struct sha1_ctx ctx;
+ char innerhash[20];
+ char keybuf[20];
+ unsigned char ipad[64]; /* inner padding - key ^ ipad[64] */
+ unsigned char opad[64]; /* outer padding - key ^ opad[64] */
+ unsigned char *kp = (unsigned char *)key;
+
+ /* if key is longer than 64 bytes reset it to key=SHA1(key) */
+ if (keylen > 64) {
+ struct sha1_ctx keyhash;
+
+ sha1_init_ctx(&keyhash);
+ sha1_process_bytes(key, keylen, &keyhash);
+ sha1_finish_ctx(&keyhash, keybuf);
+ key = keybuf;
+ keylen = sizeof(keybuf);
+ }
+
+ /* Compute SHA1(K XOR opad, SHA1(K XOR ipad, text)),
+ where
+ K is an key, padded to 64 bytes with zeros,
+ ipad and opad are the respective defines above repeated 64 times
+ text is the text argument (textlen bytes long)
+ */
+ memset(ipad, IPAD, sizeof(ipad));
+ memset(opad, OPAD, sizeof(opad));
+
+ for (i = 0; i < keylen; i++, kp++) {
+ ipad[i] ^= *kp;
+ opad[i] ^= *kp;
+ }
+
+ /* Compute inner hash */
+ sha1_init_ctx(&ctx);
+ sha1_process_block(ipad, sizeof(ipad), &ctx);
+ sha1_process_bytes(text, textlen, &ctx);
+ sha1_finish_ctx(&ctx, innerhash);
+
+ /* Compute outer hash */
+ sha1_init_ctx(&ctx);
+ sha1_process_block(opad, sizeof(opad), &ctx);
+ sha1_process_bytes(innerhash, sizeof(innerhash), &ctx);
+ sha1_finish_ctx(&ctx, digest);
+}
+
+
+
diff --git a/lib/libeclat.h b/lib/libeclat.h
new file mode 100644
index 0000000..0c6006e
--- /dev/null
+++ b/lib/libeclat.h
@@ -0,0 +1,29 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stddef.h>
+
+void hmac_sha1(const void *text, size_t textlen,
+ const void *key, size_t keylen,
+ void *digest);
+void urlencode(const char *input, size_t len,
+ char **poutput, size_t *poutlen);
+
+void eclat_base64_encode(const unsigned char *input, size_t input_len,
+ unsigned char **output, size_t *output_len);
+int eclat_base64_decode(const unsigned char *input, size_t input_len,
+ unsigned char **output, size_t *output_len);
+
diff --git a/lib/sha1.c b/lib/sha1.c
new file mode 100644
index 0000000..a4380cb
--- /dev/null
+++ b/lib/sha1.c
@@ -0,0 +1,418 @@
+/* sha1.c - Functions to compute SHA1 message digest of files or
+ memory blocks according to the NIST specification FIPS-180-1.
+
+ Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software
+ Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Scott G. Miller
+ Credits:
+ Robert Klep <robert@ilse.nl> -- Expansion function fix
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sha1.h>
+
+#include <stddef.h>
+#include <string.h>
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+#endif
+
+#ifdef WORDS_BIGENDIAN
+# define SWAP(n) (n)
+#else
+# define SWAP(n) \
+ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
+#endif
+
+#define BLOCKSIZE 4096
+#if BLOCKSIZE % 64 != 0
+# error "invalid BLOCKSIZE"
+#endif
+
+/* This array contains the bytes used to pad the buffer to the next
+ 64-byte boundary. (RFC 1321, 3.1: Step 1) */
+static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
+
+
+/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
+ initialize it to the start constants of the SHA1 algorithm. This
+ must be called before using hash in the call to sha1_hash. */
+void
+sha1_init_ctx (struct sha1_ctx *ctx)
+{
+ ctx->A = 0x67452301;
+ ctx->B = 0xefcdab89;
+ ctx->C = 0x98badcfe;
+ ctx->D = 0x10325476;
+ ctx->E = 0xc3d2e1f0;
+
+ ctx->total[0] = ctx->total[1] = 0;
+ ctx->buflen = 0;
+}
+
+/* Put result from CTX in first 20 bytes following RESBUF. The result
+ must be in little endian byte order.
+
+ IMPORTANT: On some systems it is required that RESBUF is correctly
+ aligned for a 32-bit value. */
+void *
+sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
+{
+ ((uint32_t *) resbuf)[0] = SWAP (ctx->A);
+ ((uint32_t *) resbuf)[1] = SWAP (ctx->B);
+ ((uint32_t *) resbuf)[2] = SWAP (ctx->C);
+ ((uint32_t *) resbuf)[3] = SWAP (ctx->D);
+ ((uint32_t *) resbuf)[4] = SWAP (ctx->E);
+
+ return resbuf;
+}
+
+/* Process the remaining bytes in the internal buffer and the usual
+ prolog according to the standard and write the result to RESBUF.
+
+ IMPORTANT: On some systems it is required that RESBUF is correctly
+ aligned for a 32-bit value. */
+void *
+sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
+{
+ /* Take yet unprocessed bytes into account. */
+ uint32_t bytes = ctx->buflen;
+ size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
+
+ /* Now count remaining bytes. */
+ ctx->total[0] += bytes;
+ if (ctx->total[0] < bytes)
+ ++ctx->total[1];
+
+ /* Put the 64-bit file length in *bits* at the end of the buffer. */
+ ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
+ ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
+
+ memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
+
+ /* Process last bytes. */
+ sha1_process_block (ctx->buffer, size * 4, ctx);
+
+ return sha1_read_ctx (ctx, resbuf);
+}
+
+/* Compute SHA1 message digest for bytes read from STREAM. The
+ resulting message digest number will be written into the 16 bytes
+ beginning at RESBLOCK. */
+int
+sha1_stream (FILE *stream, void *resblock)
+{
+ struct sha1_ctx ctx;
+ char buffer[BLOCKSIZE + 72];
+ size_t sum;
+
+ /* Initialize the computation context. */
+ sha1_init_ctx (&ctx);
+
+ /* Iterate over full file contents. */
+ while (1)
+ {
+ /* We read the file in blocks of BLOCKSIZE bytes. One call of the
+ computation function processes the whole buffer so that with the
+ next round of the loop another block can be read. */
+ size_t n;
+ sum = 0;
+
+ /* Read block. Take care for partial reads. */
+ while (1)
+ {
+ n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
+
+ sum += n;
+
+ if (sum == BLOCKSIZE)
+ break;
+
+ if (n == 0)
+ {
+ /* Check for the error flag IFF N == 0, so that we don't
+ exit the loop after a partial read due to e.g., EAGAIN
+ or EWOULDBLOCK. */
+ if (ferror (stream))
+ return 1;
+ goto process_partial_block;
+ }
+
+ /* We've read at least one byte, so ignore errors. But always
+ check for EOF, since feof may be true even though N > 0.
+ Otherwise, we could end up calling fread after EOF. */
+ if (feof (stream))
+ goto process_partial_block;
+ }
+
+ /* Process buffer with BLOCKSIZE bytes. Note that
+ BLOCKSIZE % 64 == 0
+ */
+ sha1_process_block (buffer, BLOCKSIZE, &ctx);
+ }
+
+ process_partial_block:;
+
+ /* Process any remaining bytes. */
+ if (sum > 0)
+ sha1_process_bytes (buffer, sum, &ctx);
+
+ /* Construct result in desired memory. */
+ sha1_finish_ctx (&ctx, resblock);
+ return 0;
+}
+
+/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
+ result is always in little endian byte order, so that a byte-wise
+ output yields to the wanted ASCII representation of the message
+ digest. */
+void *
+sha1_buffer (const char *buffer, size_t len, void *resblock)
+{
+ struct sha1_ctx ctx;
+
+ /* Initialize the computation context. */
+ sha1_init_ctx (&ctx);
+
+ /* Process whole buffer but last len % 64 bytes. */
+ sha1_process_bytes (buffer, len, &ctx);
+
+ /* Put result in desired memory area. */
+ return sha1_finish_ctx (&ctx, resblock);
+}
+
+void
+sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
+{
+ /* When we already have some bits in our internal buffer concatenate
+ both inputs first. */
+ if (ctx->buflen != 0)
+ {
+ size_t left_over = ctx->buflen;
+ size_t add = 128 - left_over > len ? len : 128 - left_over;
+
+ memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
+ ctx->buflen += add;
+
+ if (ctx->buflen > 64)
+ {
+ sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
+
+ ctx->buflen &= 63;
+ /* The regions in the following copy operation cannot overlap. */
+ memcpy (ctx->buffer,
+ &((char *) ctx->buffer)[(left_over + add) & ~63],
+ ctx->buflen);
+ }
+
+ buffer = (const char *) buffer + add;
+ len -= add;
+ }
+
+ /* Process available complete blocks. */
+ if (len >= 64)
+ {
+#if !_STRING_ARCH_unaligned
+# define alignof(type) offsetof (struct { char c; type x; }, x)
+# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
+ if (UNALIGNED_P (buffer))
+ while (len > 64)
+ {
+ sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
+ buffer = (const char *) buffer + 64;
+ len -= 64;
+ }
+ else
+#endif
+ {
+ sha1_process_block (buffer, len & ~63, ctx);
+ buffer = (const char *) buffer + (len & ~63);
+ len &= 63;
+ }
+ }
+
+ /* Move remaining bytes in internal buffer. */
+ if (len > 0)
+ {
+ size_t left_over = ctx->buflen;
+
+ memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
+ left_over += len;
+ if (left_over >= 64)
+ {
+ sha1_process_block (ctx->buffer, 64, ctx);
+ left_over -= 64;
+ memcpy (ctx->buffer, &ctx->buffer[16], left_over);
+ }
+ ctx->buflen = left_over;
+ }
+}
+
+/* --- Code below is the primary difference between md5.c and sha1.c --- */
+
+/* SHA1 round constants */
+#define K1 0x5a827999
+#define K2 0x6ed9eba1
+#define K3 0x8f1bbcdc
+#define K4 0xca62c1d6
+
+/* Round functions. Note that F2 is the same as F4. */
+#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
+#define F2(B,C,D) (B ^ C ^ D)
+#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
+#define F4(B,C,D) (B ^ C ^ D)
+
+/* Process LEN bytes of BUFFER, accumulating context into CTX.
+ It is assumed that LEN % 64 == 0.
+ Most of this code comes from GnuPG's cipher/sha1.c. */
+
+void
+sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
+{
+ const uint32_t *words = buffer;
+ size_t nwords = len / sizeof (uint32_t);
+ const uint32_t *endp = words + nwords;
+ uint32_t x[16];
+ uint32_t a = ctx->A;
+ uint32_t b = ctx->B;
+ uint32_t c = ctx->C;
+ uint32_t d = ctx->D;
+ uint32_t e = ctx->E;
+
+ /* First increment the byte count. RFC 1321 specifies the possible
+ length of the file up to 2^64 bits. Here we only compute the
+ number of bytes. Do a double word increment. */
+ ctx->total[0] += len;
+ if (ctx->total[0] < len)
+ ++ctx->total[1];
+
+#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
+
+#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
+ ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
+ , (x[I&0x0f] = rol(tm, 1)) )
+
+#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
+ + F( B, C, D ) \
+ + K \
+ + M; \
+ B = rol( B, 30 ); \
+ } while(0)
+
+ while (words < endp)
+ {
+ uint32_t tm;
+ int t;
+ for (t = 0; t < 16; t++)
+ {
+ x[t] = SWAP (*words);
+ words++;
+ }
+
+ R( a, b, c, d, e, F1, K1, x[ 0] );
+ R( e, a, b, c, d, F1, K1, x[ 1] );
+ R( d, e, a, b, c, F1, K1, x[ 2] );
+ R( c, d, e, a, b, F1, K1, x[ 3] );
+ R( b, c, d, e, a, F1, K1, x[ 4] );
+ R( a, b, c, d, e, F1, K1, x[ 5] );
+ R( e, a, b, c, d, F1, K1, x[ 6] );
+ R( d, e, a, b, c, F1, K1, x[ 7] );
+ R( c, d, e, a, b, F1, K1, x[ 8] );
+ R( b, c, d, e, a, F1, K1, x[ 9] );
+ R( a, b, c, d, e, F1, K1, x[10] );
+ R( e, a, b, c, d, F1, K1, x[11] );
+ R( d, e, a, b, c, F1, K1, x[12] );
+ R( c, d, e, a, b, F1, K1, x[13] );
+ R( b, c, d, e, a, F1, K1, x[14] );
+ R( a, b, c, d, e, F1, K1, x[15] );
+ R( e, a, b, c, d, F1, K1, M(16) );
+ R( d, e, a, b, c, F1, K1, M(17) );
+ R( c, d, e, a, b, F1, K1, M(18) );
+ R( b, c, d, e, a, F1, K1, M(19) );
+ R( a, b, c, d, e, F2, K2, M(20) );
+ R( e, a, b, c, d, F2, K2, M(21) );
+ R( d, e, a, b, c, F2, K2, M(22) );
+ R( c, d, e, a, b, F2, K2, M(23) );
+ R( b, c, d, e, a, F2, K2, M(24) );
+ R( a, b, c, d, e, F2, K2, M(25) );
+ R( e, a, b, c, d, F2, K2, M(26) );
+ R( d, e, a, b, c, F2, K2, M(27) );
+ R( c, d, e, a, b, F2, K2, M(28) );
+ R( b, c, d, e, a, F2, K2, M(29) );
+ R( a, b, c, d, e, F2, K2, M(30) );
+ R( e, a, b, c, d, F2, K2, M(31) );
+ R( d, e, a, b, c, F2, K2, M(32) );
+ R( c, d, e, a, b, F2, K2, M(33) );
+ R( b, c, d, e, a, F2, K2, M(34) );
+ R( a, b, c, d, e, F2, K2, M(35) );
+ R( e, a, b, c, d, F2, K2, M(36) );
+ R( d, e, a, b, c, F2, K2, M(37) );
+ R( c, d, e, a, b, F2, K2, M(38) );
+ R( b, c, d, e, a, F2, K2, M(39) );
+ R( a, b, c, d, e, F3, K3, M(40) );
+ R( e, a, b, c, d, F3, K3, M(41) );
+ R( d, e, a, b, c, F3, K3, M(42) );
+ R( c, d, e, a, b, F3, K3, M(43) );
+ R( b, c, d, e, a, F3, K3, M(44) );
+ R( a, b, c, d, e, F3, K3, M(45) );
+ R( e, a, b, c, d, F3, K3, M(46) );
+ R( d, e, a, b, c, F3, K3, M(47) );
+ R( c, d, e, a, b, F3, K3, M(48) );
+ R( b, c, d, e, a, F3, K3, M(49) );
+ R( a, b, c, d, e, F3, K3, M(50) );
+ R( e, a, b, c, d, F3, K3, M(51) );
+ R( d, e, a, b, c, F3, K3, M(52) );
+ R( c, d, e, a, b, F3, K3, M(53) );
+ R( b, c, d, e, a, F3, K3, M(54) );
+ R( a, b, c, d, e, F3, K3, M(55) );
+ R( e, a, b, c, d, F3, K3, M(56) );
+ R( d, e, a, b, c, F3, K3, M(57) );
+ R( c, d, e, a, b, F3, K3, M(58) );
+ R( b, c, d, e, a, F3, K3, M(59) );
+ R( a, b, c, d, e, F4, K4, M(60) );
+ R( e, a, b, c, d, F4, K4, M(61) );
+ R( d, e, a, b, c, F4, K4, M(62) );
+ R( c, d, e, a, b, F4, K4, M(63) );
+ R( b, c, d, e, a, F4, K4, M(64) );
+ R( a, b, c, d, e, F4, K4, M(65) );
+ R( e, a, b, c, d, F4, K4, M(66) );
+ R( d, e, a, b, c, F4, K4, M(67) );
+ R( c, d, e, a, b, F4, K4, M(68) );
+ R( b, c, d, e, a, F4, K4, M(69) );
+ R( a, b, c, d, e, F4, K4, M(70) );
+ R( e, a, b, c, d, F4, K4, M(71) );
+ R( d, e, a, b, c, F4, K4, M(72) );
+ R( c, d, e, a, b, F4, K4, M(73) );
+ R( b, c, d, e, a, F4, K4, M(74) );
+ R( a, b, c, d, e, F4, K4, M(75) );
+ R( e, a, b, c, d, F4, K4, M(76) );
+ R( d, e, a, b, c, F4, K4, M(77) );
+ R( c, d, e, a, b, F4, K4, M(78) );
+ R( b, c, d, e, a, F4, K4, M(79) );
+
+ a = ctx->A += a;
+ b = ctx->B += b;
+ c = ctx->C += c;
+ d = ctx->D += d;
+ e = ctx->E += e;
+ }
+}
diff --git a/lib/sha1.h b/lib/sha1.h
new file mode 100644
index 0000000..0a4d3b9
--- /dev/null
+++ b/lib/sha1.h
@@ -0,0 +1,98 @@
+/* Declarations of functions and data types used for SHA1 sum
+ library functions.
+ Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _ECLAT_SHA1_H
+# define _ECLAT_SHA1_H 1
+
+# include <stdio.h>
+# include <stdint.h>
+
+/* Rename to avoid name clashes */
+# define sha1_ctx eclat_sha1_ctx
+# define sha1_init_ctx eclat_sha1_init_ctx
+# define sha1_process_block eclat_sha1_process_block
+# define sha1_process_bytes eclat_sha1_process_bytes
+# define sha1_finish_ctx eclat_sha1_finish_ctx
+# define sha1_read_ctx eclat_sha1_read_ctx
+# define sha1_stream eclat_sha1_stream
+# define sha1_buffer eclat_sha1_buffer
+# define sha1_ctx eclat_sha1_ctx
+
+/* Structure to save state of computation between the single steps. */
+struct sha1_ctx
+{
+ uint32_t A;
+ uint32_t B;
+ uint32_t C;
+ uint32_t D;
+ uint32_t E;
+
+ uint32_t total[2];
+ uint32_t buflen;
+ uint32_t buffer[32];
+};
+
+
+/* Initialize structure containing state of computation. */
+extern void sha1_init_ctx (struct sha1_ctx *ctx);
+
+/* Starting with the result of former calls of this function (or the
+ initialization function update the context for the next LEN bytes
+ starting at BUFFER.
+ It is necessary that LEN is a multiple of 64!!! */
+extern void sha1_process_block (const void *buffer, size_t len,
+ struct sha1_ctx *ctx);
+
+/* Starting with the result of former calls of this function (or the
+ initialization function update the context for the next LEN bytes
+ starting at BUFFER.
+ It is NOT required that LEN is a multiple of 64. */
+extern void sha1_process_bytes (const void *buffer, size_t len,
+ struct sha1_ctx *ctx);
+
+/* Process the remaining bytes in the buffer and put result from CTX
+ in first 20 bytes following RESBUF. The result is always in little
+ endian byte order, so that a byte-wise output yields to the wanted
+ ASCII representation of the message digest.
+
+ IMPORTANT: On some systems it is required that RESBUF be correctly
+ aligned for a 32 bits value. */
+extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
+
+
+/* Put result from CTX in first 20 bytes following RESBUF. The result is
+ always in little endian byte order, so that a byte-wise output yields
+ to the wanted ASCII representation of the message digest.
+
+ IMPORTANT: On some systems it is required that RESBUF is correctly
+ aligned for a 32 bits value. */
+extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
+
+
+/* Compute SHA1 message digest for bytes read from STREAM. The
+ resulting message digest number will be written into the 20 bytes
+ beginning at RESBLOCK. */
+extern int sha1_stream (FILE *stream, void *resblock);
+
+/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
+ result is always in little endian byte order, so that a byte-wise
+ output yields to the wanted ASCII representation of the message
+ digest. */
+extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
+
+#endif
diff --git a/lib/urlencode.c b/lib/urlencode.c
new file mode 100644
index 0000000..829d461
--- /dev/null
+++ b/lib/urlencode.c
@@ -0,0 +1,68 @@
+/* This file is part of Eclat
+ Copyright (C) 2012 Sergey Poznyakoff
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "libeclat.h"
+#include <grecs.h>
+
+static int prtch[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+void
+urlencode(const char *input, size_t len, char **poutput, size_t *poutlen)
+{
+ size_t i, outlen;
+ char *output;
+ static char xdig[] = "0123456789ABCDEF";
+
+ outlen = len;
+ for (i = 0; i < len; i++)
+ if (!prtch[input[i]])
+ outlen += 2;
+
+ if (poutlen)
+ *poutlen = outlen;
+
+ output = grecs_malloc(outlen + 1);
+ *poutput = output;
+
+ for (i = 0; i < len; i++) {
+ if (prtch[input[i]])
+ *output++ = input[i];
+ else {
+ *output++ = '%';
+ *output++ = xdig[((unsigned char)input[i]) >> 4];
+ *output++ = xdig[((unsigned char)input[i]) & 0x0f];
+ }
+ }
+ *output = 0;
+}
+
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..2f6973f
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,2 @@
+cmdline.h
+eclat
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..a16aff8
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,44 @@
+# This file is part of Eclat
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+bin_PROGRAMS=eclat
+
+eclat_SOURCES=\
+ accfile.c\
+ cmdline.h\
+ config.c\
+ diag.c\
+ eclat.c\
+ eclat.h\
+ startinst.c
+
+AM_LDFLAGS = $(CURL_LIBS)
+LDADD=../lib/libeclat.a @LIBOBJS@ ../grecs/src/libgrecs.a
+INCLUDES = -I$(top_srcdir)/grecs/src/ -I$(top_srcdir)/lib $(CURL_CFLAGS)
+AM_CPPFLAGS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\"\
+ -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\
+ -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\
+ -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)"
+
+BUILT_SOURCES=cmdline.h
+EXTRA_DIST=cmdline.opt
+
+SUFFIXES=.opt .c .h
+
+.opt.h:
+ m4 -s $(top_srcdir)/grecs/build-aux/getopt.m4 $< | sed '1d' > $@
+
diff --git a/src/accfile.c b/src/accfile.c
new file mode 100644
index 0000000..3fe669d
--- /dev/null
+++ b/src/accfile.c
@@ -0,0 +1,105 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "eclat.h"
+
+char *access_file_name;
+
+static void
+skipline(FILE *fp)
+{
+ int c;
+
+ while ((c = getc(fp)) != EOF && c != '\n')
+ ;
+}
+
+int
+access_file_lookup(const char *id, char **access_key_ptr, char **secret_key_ptr)
+{
+ int rc;
+ int c;
+ FILE *fp;
+ size_t line = 0;
+ struct grecs_txtacc *acc;
+
+ if (!access_file_name)
+ return 1;
+ fp = fopen(access_file_name, "r");
+ if (!fp) {
+ err("cannot open \"%s\": %s",
+ access_file_name, strerror(errno));
+ return 1;
+ }
+
+ while ((c = getc(fp)) != EOF) {
+ line++;
+ while (c != EOF && (c == ' ' || c == '\t'))
+ c = getc(fp);
+ if (c == '\n')
+ continue;
+ if (c == '#') {
+ skipline(fp);
+ continue;
+ }
+ if (c == EOF)
+ break;
+ if (id) {
+ const char *p;
+
+ for (p = id; c != EOF && c != ':' && *p == c; p++)
+ c = getc(fp);
+ if (c == EOF)
+ break;
+ if (c == '\n')
+ continue;
+ if (c != ':') {
+ skipline(fp);
+ continue;
+ }
+ } else {
+ acc = grecs_txtacc_create();
+ while ((c = getc(fp)) != EOF && c != ':') {
+ if (c == '\n') {
+ err("%s:%u: incomplete line",
+ access_file_name, line);
+ break;
+ }
+ grecs_txtacc_grow_char(acc, c);
+ }
+ if (c == ':') {
+ grecs_txtacc_grow_char(acc, 0);
+ *access_key_ptr = grecs_txtacc_finish(acc, 1);
+ }
+ grecs_txtacc_free(acc);
+ }
+ break;
+ }
+
+ if (c == ':') {
+ acc = grecs_txtacc_create();
+ while ((c = getc(fp)) != EOF && c != '\n')
+ grecs_txtacc_grow_char(acc, c);
+ grecs_txtacc_grow_char(acc, 0);
+ *secret_key_ptr = grecs_txtacc_finish(acc, 1);
+ rc = 0;
+ } else
+ rc = 1;
+
+ fclose(fp);
+
+ return rc;
+}
diff --git a/src/cmdline.opt b/src/cmdline.opt
new file mode 100644
index 0000000..25dc542
--- /dev/null
+++ b/src/cmdline.opt
@@ -0,0 +1,226 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_GETOPT_H
+# include <getopt.h>
+#endif
+
+static char *pp_cmd_buffer;
+static size_t pp_cmd_bufsize;
+static size_t pp_cmd_buflevel;
+
+struct replvar {
+ char **s_ptr;
+ char *s_val;
+};
+
+int
+replace_string_var(void *p)
+{
+ struct replvar *rv = p;
+ *rv->s_ptr = rv->s_val;
+ return 0;
+}
+
+OPTIONS_BEGIN("eclat",
+ [<EC2 Command Line Administrator Tool>],[<>],
+ [<gnu>],
+ [<copyright_year=2012>],
+ [<copyright_holder=Sergey Poznyakoff>])
+
+GROUP(Selecting program mode)
+
+OPTION(lint,t,,
+ [<parse configuration file and exit>])
+BEGIN
+ lint_mode = 1;
+END
+
+OPTION(,E,,
+ [<preprocess config and exit>])
+BEGIN
+ preprocess_only = 1;
+END
+
+OPTION(dry-run,n,,
+ [<do nothing, print almost everything>])
+BEGIN
+ dry_run_mode = 1;
+END
+
+OPTION(config-file,c,FILE,
+ [<use FILE instead of the default configuration>])
+BEGIN
+ conffile = optarg;
+END
+
+GROUP(Commands)
+
+OPTION(start-instances,,,
+ [<Start named instances>])
+BEGIN
+ eclat_command = eclat_command_start_instances;
+END
+
+OPTION(stop-instances,,,
+ [<Stop named instances>])
+BEGIN
+ eclat_command = eclat_command_stop_instances;
+END
+
+GROUP(Modifiers)
+
+OPTION(region,,NAME,
+ [<define AWS region>])
+BEGIN
+ struct replvar *rv = grecs_malloc(sizeof(*rv));
+ rv->s_ptr = &region_name;
+ rv->s_val = optarg;
+ add_config_finish_hook(replace_string_var, rv);
+END
+
+OPTION(access-file,a,NAME,
+ [<set access file>])
+BEGIN
+ struct replvar *rv = grecs_malloc(sizeof(*rv));
+ rv->s_ptr = &access_file_name;
+ rv->s_val = optarg;
+ add_config_finish_hook(replace_string_var, rv);
+END
+
+OPTION(access-key,O,KEY,
+ [<set access key to use>])
+BEGIN
+ access_key = optarg;
+END
+
+OPTION(secret-key,W,KEY,
+ [<set secret key to use>])
+BEGIN
+ secret_key = optarg;
+END
+
+OPTION(ssl,,,
+ [<use SSL (HTTPS) connection>])
+BEGIN
+ use_ssl = 1;
+END
+
+GROUP(Preprocessor control)
+
+OPTION(include-directory,I,DIR,
+ [<add include directory>])
+BEGIN
+ grecs_preproc_add_include_dir(optarg);
+END
+
+OPTION(define,D,SYMBOL[=VALUE],
+ [<define a preprocessor symbol>])
+BEGIN
+ size_t len;
+ char *p;
+
+ len = 4;
+ for (p = optarg; *p; p++) {
+ if (*p == '\\' || *p == '"')
+ len++;
+ len++;
+ }
+
+ if (pp_cmd_buflevel + len + 1 > pp_cmd_bufsize) {
+ pp_cmd_bufsize = pp_cmd_buflevel + len + 1;
+ pp_cmd_buffer = grecs_realloc(pp_cmd_buffer, pp_cmd_bufsize);
+ }
+ memcpy(pp_cmd_buffer + pp_cmd_buflevel, " \"-D", 4);
+ pp_cmd_buflevel += 4;
+
+ p = optarg;
+ do {
+ if (*p == '\\' || *p == '"')
+ pp_cmd_buffer[pp_cmd_buflevel++] = '\\';
+ pp_cmd_buffer[pp_cmd_buflevel++] = *p;
+ } while (*p++);
+END
+
+OPTION(preprocessor,,COMMAND,
+ [<use COMMAND instead of the default preprocessor>])
+BEGIN
+ grecs_preprocessor = optarg;
+END
+
+OPTION(no-preprocessor,,,
+ [<disable preprocessing>])
+BEGIN
+ grecs_preprocessor = NULL;
+END
+
+GROUP(Debugging)
+
+OPTION(dump-grammar-trace,,,
+ [<dump configuration grammar traces>])
+BEGIN
+ grecs_gram_trace (1);
+END
+
+OPTION(dump-lex-trace,,,
+ [<dump lexical analyzer traces>])
+BEGIN
+ grecs_lex_trace (1);
+END
+
+OPTION(debug,d,CAT[.LEVEL],
+ [<set debugging level>])
+BEGIN
+ if (parse_debug_level(optarg)) {
+ die(EX_USAGE, "invalid debugging category or level");
+ }
+END
+
+GROUP([<Additional help>])
+OPTION(config-help,,,
+ [<show configuration file summary>])
+BEGIN
+ config_help();
+ exit(0);
+END
+
+OPTIONS_END
+
+void
+set_program_name(const char *arg)
+{
+ program_name = strrchr(arg, '/');
+ if (!program_name)
+ program_name = arg;
+ else
+ program_name++;
+}
+
+void
+parse_options(int argc, char *argv[], int *index)
+{
+ GETOPT(argc, argv, *index, exit(EX_USAGE))
+
+ if (pp_cmd_buffer && grecs_preprocessor) {
+ char *cmd = grecs_malloc(strlen(grecs_preprocessor) +
+ pp_cmd_buflevel + 1);
+ strcpy(cmd, grecs_preprocessor);
+ strcat(cmd, pp_cmd_buffer);
+ grecs_preprocessor = cmd;
+ free(pp_cmd_buffer);
+ }
+}
+
diff --git a/src/config.c b/src/config.c
new file mode 100644
index 0000000..184b42a
--- /dev/null
+++ b/src/config.c
@@ -0,0 +1,110 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "eclat.h"
+
+struct config_finish_hook_entry
+{
+ struct config_finish_hook_entry *next;
+ config_finish_hook_t fun;
+ void *data;
+};
+
+static struct config_finish_hook_entry *cfh_head, *cfh_tail;
+
+void
+add_config_finish_hook(config_finish_hook_t fun, void *data)
+{
+ struct config_finish_hook_entry *ent = grecs_malloc(sizeof(*ent));
+ ent->next = NULL;
+ ent->fun = fun;
+ ent->data = data;
+ if (cfh_tail)
+ cfh_tail->next = ent;
+ else
+ cfh_head = ent;
+ cfh_tail = ent;
+}
+
+int
+run_config_finish_hooks()
+{
+ struct config_finish_hook_entry *p;
+ int rc = 0;
+
+ for (p = cfh_head; p; p = p->next)
+ rc |= p->fun(p->data);
+ return rc;
+}
+
+static struct grecs_keyword eclat_kw[] = {
+ { "host", "hostname",
+ "Send queries to <hostname> instead of the default host",
+ grecs_type_string, GRECS_DFLT, &default_host },
+ { "access-file", "file",
+ "Specify a file containing `accessID:accessKey' pairs",
+ grecs_type_string, GRECS_DFLT, &access_file_name },
+ { "region", "name",
+ "Define default AWS region",
+ grecs_type_string, GRECS_DFLT, &region_name },
+
+ { NULL }
+};
+
+void
+config_help()
+{
+ static char docstring[] =
+ N_("Configuration file structure for eclat.\n"
+ "For more information, use `info eclat configuration'.");
+ grecs_print_docstring(docstring, 0, stdout);
+ grecs_print_statement_array(eclat_kw, 1, 0, stdout);
+}
+
+static void
+grecs_print_diag(grecs_locus_t const *locus, int err, int errcode,
+ const char *msg)
+{
+ diag(locus, err ? NULL : "warning", "%s", msg);
+}
+
+void
+config_init()
+{
+ grecs_include_path_setup(DEFAULT_VERSION_INCLUDE_DIR,
+ DEFAULT_INCLUDE_DIR, NULL);
+ grecs_preprocessor = DEFAULT_PREPROCESSOR;
+ grecs_log_to_stderr = 1;
+ grecs_adjust_string_locations = 1;
+ grecs_print_diag_fun = grecs_print_diag;
+}
+
+void
+config_finish(struct grecs_node *tree)
+{
+ struct grecs_node *node;
+
+ grecs_tree_reduce(tree, eclat_kw, GRECS_AGGR);
+ if (debug_level[ECLAT_DEBCAT_CONF]) {
+ grecs_print_node(tree, GRECS_NODE_FLAG_DEFAULT, stderr);
+ fputc('\n', stdout);
+ }
+ if (grecs_error_count || run_config_finish_hooks())
+ exit(EX_CONFIG);
+}
+
+
+
diff --git a/src/diag.c b/src/diag.c
new file mode 100644
index 0000000..30ffa34
--- /dev/null
+++ b/src/diag.c
@@ -0,0 +1,108 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "eclat.h"
+
+const char *program_name;
+
+void
+vdiag(grecs_locus_t const *locus, const char *qual, const char *fmt, va_list ap)
+{
+ if (program_name)
+ fprintf(stderr, "%s: ", program_name);
+
+ if (locus) {
+ size_t size = 0;
+
+ if (locus->beg.col == 0)
+ fprintf(stderr, "%s:%u",
+ locus->beg.file,
+ locus->beg.line);
+ else if (strcmp(locus->beg.file, locus->end.file))
+ fprintf(stderr, "%s:%u.%u-%s:%u.%u",
+ locus->beg.file,
+ locus->beg.line, locus->beg.col,
+ locus->end.file,
+ locus->end.line, locus->end.col);
+ else if (locus->beg.line != locus->end.line)
+ fprintf(stderr, "%s:%u.%u-%u.%u",
+ locus->beg.file,
+ locus->beg.line, locus->beg.col,
+ locus->end.line, locus->end.col);
+ else
+ fprintf(stderr, "%s:%u.%u-%u",
+ locus->beg.file,
+ locus->beg.line, locus->beg.col,
+ locus->end.col);
+ fprintf(stderr, ": ");
+ }
+
+ if (qual)
+ fprintf(stderr, "%s: ", qual);
+ vfprintf(stderr, fmt, ap);
+ fputc('\n', stderr);
+}
+
+void
+diag(grecs_locus_t const *locus, const char *qual, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vdiag(locus, qual, fmt, ap);
+ va_end(ap);
+}
+
+void
+die(int status, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vdiag(NULL, NULL, fmt, ap);
+ va_end(ap);
+ exit(status);
+}
+
+void
+err(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vdiag(NULL, NULL, fmt, ap);
+ va_end(ap);
+}
+
+void
+warn(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vdiag(NULL, "warning", fmt, ap);
+ va_end(ap);
+}
+
+void
+debug_printf(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vdiag(NULL, "debug", fmt, ap);
+ va_end(ap);
+}
diff --git a/src/eclat.c b/src/eclat.c
new file mode 100644
index 0000000..3d2572d
--- /dev/null
+++ b/src/eclat.c
@@ -0,0 +1,162 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "eclat.h"
+
+char *conffile = SYSCONFDIR "/eclat.conf" ;
+int lint_mode;
+int debug_level[ECLAT_DEBCAT_MAX];
+int dry_run_mode;
+int preprocess_only = 0;
+
+char *default_host = "ec2.amazonaws.com";
+int use_ssl;
+char *access_key;
+char *secret_key;
+char *region_name;
+enum eclat_command eclat_command;
+
+char *url_base;
+
+
+struct debug_trans {
+ const char *name;
+ size_t length;
+ int cat;
+};
+
+static struct debug_trans debug_trans[] = {
+#define S(s) #s, sizeof(#s)-1
+ { S(main), ECLAT_DEBCAT_MAIN },
+ { S(cfgram), ECLAT_DEBCAT_CFGRAM },
+ { S(cflex), ECLAT_DEBCAT_CFLEX },
+ { S(conf), ECLAT_DEBCAT_CONF },
+ { NULL }
+};
+
+static int
+parse_debug_level(const char *arg)
+{
+ unsigned long cat, lev;
+ char *p;
+
+ if (isascii(*arg) && isdigit(*arg)) {
+ cat = strtoul(arg, &p, 10);
+ if (cat > ECLAT_DEBCAT_MAX)
+ return -1;
+ } else {
+ size_t len = strcspn(arg, ".");
+ struct debug_trans *dp;
+
+ for (dp = debug_trans; dp->name; dp++)
+ if (dp->length == len &&
+ memcmp(dp->name, arg, len) == 0)
+ break;
+
+ if (!dp->name)
+ return -1;
+ cat = dp->cat;
+ p = (char*) arg + len;
+ }
+
+ if (*p == 0)
+ lev = 100;
+ else if (*p != '.')
+ return -1;
+ else {
+ lev = strtoul(p + 1, &p, 10);
+ if (*p)
+ return -1;
+ }
+ debug_level[cat] = lev;
+ return 0;
+}
+
+#include "cmdline.h"
+
+eclat_command_handler_t handler_tab[] = {
+ NULL,
+ eclat_start_instance,
+ eclat_stop_instance
+};
+
+int
+main(int argc, char **argv)
+{
+ int index, rc;
+ struct grecs_node *tree;
+ CURL *curl;
+ size_t size;
+
+ set_program_name(argv[0]);
+ config_init();
+ parse_options(argc, argv, &index);
+
+ argc -= index;
+ argv += index;
+
+ grecs_gram_trace(debug_level[ECLAT_DEBCAT_CFGRAM]);
+ grecs_lex_trace(debug_level[ECLAT_DEBCAT_CFLEX]);
+
+ if (preprocess_only)
+ exit(grecs_preproc_run(conffile, grecs_preprocessor) ?
+ EX_CONFIG : 0);
+
+ if (access(conffile, R_OK) == 0) {
+ tree = grecs_parse(conffile);
+ if (!tree)
+ exit(EX_CONFIG);
+ config_finish(tree);
+ /* Prevent texttab from being freed by grecs_tree_free.
+ FIXME: A dirty kludge, needed to preserve file names
+ in locus structures. A proper solution would be to have
+ our own texttab for that purpose. */
+ tree->v.texttab = NULL;
+ grecs_tree_free(tree);
+ } else if (errno == ENOENT) {
+ warn("no configuration file");
+ run_config_finish_hooks();
+ } else
+ die(EX_OSFILE, "cannot access \"%s\": %s",
+ conffile, strerror(errno));
+
+ if (lint_mode)
+ exit(0);
+
+ if (!secret_key) {
+ if (access_file_lookup(access_key, &access_key, &secret_key))
+ die(EX_UNAVAILABLE,
+ "cannot find authentication credentials");
+ }
+
+ if (eclat_command == eclat_command_unspecified)
+ die(EX_USAGE, "no command given");
+
+ url_base = NULL;
+ size = 0;
+ if (use_ssl)
+ grecs_asprintf(&url_base, &size, "https://%s", default_host);
+ else
+ grecs_asprintf(&url_base, &size, "http://%s", default_host);
+
+
+ curl = curl_easy_init();
+ if (!curl)
+ die(EX_UNAVAILABLE, "curl_easy_init failed");
+ rc = handler_tab[eclat_command](curl, argc, argv);
+ curl_easy_cleanup(curl);
+ exit(rc);
+}
diff --git a/src/eclat.h b/src/eclat.h
new file mode 100644
index 0000000..0fb4fd7
--- /dev/null
+++ b/src/eclat.h
@@ -0,0 +1,81 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <sysexits.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <curl/curl.h>
+#include "grecs.h"
+#include "wordsplit.h"
+#include "libeclat.h"
+
+#define ECLAT_DEBCAT_MAIN 0
+#define ECLAT_DEBCAT_CFGRAM 1
+#define ECLAT_DEBCAT_CFLEX 2
+#define ECLAT_DEBCAT_CONF 3
+#define ECLAT_DEBCAT_MAX 4
+
+extern const char *program_name;
+extern int debug_level[];
+
+extern char *default_host;
+extern int use_ssl;
+extern char *region_name;
+extern char *access_file_name;
+extern char *access_key;
+extern char *secret_key;
+extern char *url_base;
+
+#define debug(cat, lev, s) \
+ do { \
+ if (debug_level[cat] >= (lev)) \
+ debug_printf s; \
+ } while(0)
+
+void die(int status, const char *fmt, ...);
+void vdiag(grecs_locus_t const *locus, const char *qual, const char *fmt,
+ va_list ap);
+void diag(grecs_locus_t const *locus, const char *qual, const char *fmt, ...);
+void err(const char *fmt, ...);
+void warn(const char *fmt, ...);
+void debug_printf(const char *fmt, ...);
+
+typedef int (*config_finish_hook_t) (void*);
+
+void add_config_finish_hook(config_finish_hook_t fun, void *data);
+
+void config_help(void);
+void config_init(void);
+void config_finish(struct grecs_node *tree);
+int run_config_finish_hooks(void);
+
+enum eclat_command {
+ eclat_command_unspecified,
+ eclat_command_start_instances,
+ eclat_command_stop_instances
+};
+
+extern enum eclat_command eclat_command;
+
+typedef int (*eclat_command_handler_t) (CURL *curl, int argc, char **argv);
+
+int eclat_start_instance(CURL *curl, int argc, char **argv);
+int eclat_stop_instance(CURL *curl, int argc, char **argv);
diff --git a/src/error.c b/src/error.c
new file mode 100644
index 0000000..6c86d34
--- /dev/null
+++ b/src/error.c
@@ -0,0 +1,64 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "eclat.h"
+#include <stdargs.h>
+#include <stdio.h>
+
+char *program_name;
+
+void
+diag(const char *qual, const char *fmt, va_list ap)
+{
+ if (program_name)
+ fprintf(stderr, "%s: ", program_name);
+ if (qual)
+ fprintf(stderr, "%s: ", qual);
+ va_start(ap, fmt);
+ vfprintf(stderr, ftm, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+}
+
+void
+err(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ diag(NULL, ftm, ap);
+ va_end(ap);
+}
+
+void
+warn(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ diag("warning", ftm, ap);
+ va_end(ap);
+}
+
+void
+debug_printf(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ diag("debug", ftm, ap);
+ va_end(ap);
+}
diff --git a/src/startinst.c b/src/startinst.c
new file mode 100644
index 0000000..f07e50a
--- /dev/null
+++ b/src/startinst.c
@@ -0,0 +1,28 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "eclat.h"
+
+int
+eclat_start_instance(CURL *curl, int argc, char **argv)
+{
+}
+
+int
+eclat_stop_instance(CURL *curl, int argc, char **argv)
+{
+}
+
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..9a2f830
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1,8 @@
+atconfig
+atlocal
+package.m4
+testsuite
+testsuite.dir
+testsuite.log
+thmac
+turlenc
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..6d95607
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,79 @@
+# This file is part of Eclat
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
+DISTCLEANFILES = atconfig $(check_SCRIPTS)
+MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
+
+
+## ------------ ##
+## package.m4. ##
+## ------------ ##
+
+$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+ $(AM_V_GEN){ \
+ echo '# Signature of the current package.'; \
+ echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
+ echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
+ echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
+ echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
+ } >$(srcdir)/package.m4
+
+#
+
+## ------------ ##
+## Test suite. ##
+## ------------ ##
+
+TESTSUITE_AT = \
+ hmac01.at\
+ hmac02.at\
+ hmac03.at\
+ testsuite.at\
+ urlenc01.at
+
+TESTSUITE = $(srcdir)/testsuite
+M4=m4
+
+AUTOTEST = $(AUTOM4TE) --language=autotest
+$(TESTSUITE): package.m4 $(TESTSUITE_AT)
+ $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp
+ mv $@.tmp $@
+
+atconfig: $(top_builddir)/config.status
+ cd $(top_builddir) && ./config.status tests/$@
+
+clean-local:
+ test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
+
+check-local: atconfig atlocal $(TESTSUITE)
+ $(SHELL) $(TESTSUITE)
+
+# Run the test suite on the *installed* tree.
+#installcheck-local:
+# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
+
+noinst_PROGRAMS = \
+ thmac\
+ turlenc
+
+LDADD = ../lib/libeclat.a ../grecs/src/libgrecs.a
+INCLUDES = -I$(top_srcdir)/lib
+
+
+
+
diff --git a/tests/atlocal.in b/tests/atlocal.in
new file mode 100644
index 0000000..f75356d
--- /dev/null
+++ b/tests/atlocal.in
@@ -0,0 +1,6 @@
+# @configure_input@ -*- shell-script -*-
+# Configurable variable values for Eclat test suite.
+# Copyright (C) 2012 Sergey Poznyakoff
+
+PATH=@abs_builddir@:@abs_top_builddir@/src:@abs_top_srcdir@/build-aux:$top_srcdir:$srcdir:$PATH
+
diff --git a/tests/hmac01.at b/tests/hmac01.at
new file mode 100644
index 0000000..ecef3c5
--- /dev/null
+++ b/tests/hmac01.at
@@ -0,0 +1,25 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([hmac01])
+AT_KEYWORDS([hmac hmac01])
+
+AT_CHECK([thmac 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b "Hi There"],
+[0],
+[0x675b0b3a1b4ddf4e124872da6c2f632bfed957e9
+])
+
+AT_CLEANUP
diff --git a/tests/hmac02.at b/tests/hmac02.at
new file mode 100644
index 0000000..d2ab2d7
--- /dev/null
+++ b/tests/hmac02.at
@@ -0,0 +1,25 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([hmac02])
+AT_KEYWORDS([hmac hmac02])
+
+AT_CHECK([thmac Jefe "what do ya want for nothing?"],
+[0],
+[0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79
+])
+
+AT_CLEANUP
diff --git a/tests/hmac03.at b/tests/hmac03.at
new file mode 100644
index 0000000..ffa35da
--- /dev/null
+++ b/tests/hmac03.at
@@ -0,0 +1,26 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([hmac03])
+AT_KEYWORDS([hmac hmac03])
+
+AT_CHECK([thmac "0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \
+ "0xDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"],
+[0],
+[0xd730594d167e35d5956fd8003d0db3d3f46dc7bb
+])
+
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
new file mode 100644
index 0000000..c368490
--- /dev/null
+++ b/tests/testsuite.at
@@ -0,0 +1,30 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+m4_version_prereq([2.52g])
+
+m4_define([AT_SKIP_TEST],[exit 77])
+
+AT_INIT
+AT_BANNER([HMAC-SHA1])
+m4_include(hmac01.at)
+m4_include(hmac02.at)
+m4_include(hmac03.at)
+
+AT_BANNER([URL encode])
+m4_include([urlenc01.at])
+
+# End of testsuite.at
diff --git a/tests/thmac.c b/tests/thmac.c
new file mode 100644
index 0000000..cda0777
--- /dev/null
+++ b/tests/thmac.c
@@ -0,0 +1,128 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "libeclat.h"
+
+char *progname;
+
+static int
+xdecode(const char *in, void **pout, size_t *outlen)
+{
+ unsigned char *out;
+ size_t len;
+
+ if (in[0] == '0' && in[1] == 'x') {
+ size_t i, slen;
+ unsigned char *p;
+
+ slen = strlen(in);
+ if (slen % 2)
+ return -1;
+ len = slen / 2 - 1;
+ out = malloc(len);
+ if (!out) {
+ perror("malloc");
+ abort();
+ }
+ for (i = 2, p = out; i < slen; i+=2, p++) {
+ static char xchar[] = "0123456789abcdef";
+ char *q;
+ unsigned char c;
+
+ q = strchr(xchar, tolower(in[i]));
+ if (q == 0)
+ return i;
+ c = (q - xchar);
+
+ q = strchr(xchar, tolower(in[i+1]));
+ if (q == 0)
+ return i+1;
+ *p = (c << 4) + (q - xchar);
+ }
+ } else {
+ len = strlen(in);
+ out = malloc(len);
+ if (!out) {
+ perror("malloc");
+ abort();
+ }
+ memcpy(out, in, len);
+ }
+ *pout = out;
+ *outlen = len;
+ return 0;
+}
+
+void
+xdecode_assert(int rc, char *in, char *what)
+{
+ switch (rc) {
+ case -1:
+ fprintf(stderr, "%s: odd %s length\n", progname, what);
+ exit(1);
+
+ case 0:
+ break;
+
+ default:
+ fprintf(stderr, "%s: invalid hex character in %s near %s\n",
+ progname, what, in + rc);
+ exit(1);
+ }
+}
+
+void
+xdump(unsigned char *in, size_t len)
+{
+ printf("0x");
+ while (len--)
+ printf("%02x", *in++);
+ printf("\n");
+}
+
+int
+main(int argc, char **argv)
+{
+ int rc;
+ void *key;
+ size_t keylen;
+ void *text;
+ size_t textlen;
+ unsigned char digest[20];
+
+ progname = argv[0];
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s key data\n", progname);
+ return 1;
+ }
+
+ rc = xdecode(argv[1], &key, &keylen);
+ xdecode_assert(rc, argv[1], "key");
+
+ rc = xdecode(argv[2], &text, &textlen);
+ xdecode_assert(rc, argv[2], "text");
+
+ hmac_sha1(text, textlen, key, keylen, digest);
+
+ xdump(digest, sizeof(digest));
+ return 0;
+}
+
+
diff --git a/tests/turlenc.c b/tests/turlenc.c
new file mode 100644
index 0000000..94b2513
--- /dev/null
+++ b/tests/turlenc.c
@@ -0,0 +1,46 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat 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, or (at your option)
+ any later version.
+
+ Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "libeclat.h"
+
+int
+main(int argc, char **argv)
+{
+ char *output;
+ size_t outlen;
+
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s string\n", argv[0]);
+ return 1;
+ }
+
+ urlencode(argv[1], strlen(argv[1]), &output, &outlen);
+
+ printf("%lu\n", (unsigned long) outlen);
+ printf("%s\n", output);
+ return 0;
+}
+
+
+
+
+
+
+
diff --git a/tests/urlenc01.at b/tests/urlenc01.at
new file mode 100644
index 0000000..83f67f3
--- /dev/null
+++ b/tests/urlenc01.at
@@ -0,0 +1,28 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat 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, or (at your option)
+# any later version.
+#
+# Eclat 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 Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([url encode])
+AT_KEYWORDS([urlenc urlent01])
+
+AT_CHECK([
+turlenc 'http://example.com/~us.er?a-string="a b"&n_1=10'
+],
+[0],
+[69
+http%3A%2F%2Fexample.com%2F~us.er%3Fa-string%3D%22a%20b%22%26n_1%3D10
+])
+
+AT_CLEANUP \ No newline at end of file

Return to:

Send suggestions and report system problems to the System administrator.