diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml
index c6ddd98..d6bdd5d 100644
--- a/.github/workflows/build-windows.yml
+++ b/.github/workflows/build-windows.yml
@@ -9,6 +9,9 @@ on:
paths:
- ".github/workflows/build-windows.yml"
+env:
+ DYNAMIC_OPENSSL_VERSION: 3_3_0
+
jobs:
build:
name: Build
@@ -28,12 +31,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- - name: Setup OpenSSL 1.1.1 for Win32
- if: matrix.arch == 'Win32'
+ - name: Setup OpenSSL v$DYNAMIC_OPENSSL_VERSION (dynamic)
# https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1 & Win32OpenSSL.exe /? & Win32OpenSSL.exe /LOG="a.log" /SAVEINF="inf.inf"
run: |
- $url = "https://slproweb.com/download/Win32OpenSSL-1_1_1w.exe"
- $path = "C:\temp\Win32OpenSSL.exe"
+ $url = "https://slproweb.com/download/Win${{ matrix.arch == 'Win32' && '32' || matrix.arch == 'Win64' && '64' }}OpenSSL-${{ $env.DYNAMIC_OPENSSL_VERSION }}.exe"
+ $path = "C:\OpenSSL.exe"
Invoke-WebRequest -Uri $url -OutFile $path
Start-Process -FilePath $path -ArgumentList "/silent","/sp-","/suppressmsgboxes","/DIR=`"$env:ProgramFiles\OpenSSL`"","/TASKS=copytobin" -Wait
@@ -50,7 +52,7 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- - name: Setup OpenSSL (static)
+ - name: Setup OpenSSL latest (static)
# https://blog.hamaluik.ca/posts/statically-linking-sqlcipher-on-windows
run: |
vcpkg install openssl:${{ env.VCPKG_DEFAULT_TRIPLET }} --binarysource="clear;x-gha,readwrite"
@@ -87,6 +89,12 @@ jobs:
copy sqlite3.c,sqlite3.h,sqlcipher.dll,sqlcipher.lib,sqlcipher-dynamic.exe,"$env:ProgramFiles\OpenSSL\libcrypto-*" sqlcipher
working-directory: C:\dev\SQLCipher-${{ matrix.arch }}
+ - name: Copy LICENSE
+ # ref: https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1#L12
+ run: |
+ copy LICENSE* sqlcipher
+ working-directory: C:\dev\SQLCipher-${{ matrix.arch }}
+
- name: Prepare artifacts
run: |
Compress-Archive -Path C:\dev\SQLCipher-${{ matrix.arch }}\sqlcipher -DestinationPath build-artifacts-${{ matrix.arch }}.zip
@@ -104,4 +112,4 @@ jobs:
tag_name: latest
files: |
build-artifacts-${{ matrix.arch }}.zip
- C:\dev\SQLCipher-${{ matrix.arch }}\sqlcipher-${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}.exe
+ C:/dev/SQLCipher-${{ matrix.arch }}/sqlcipher-${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}.exe
diff --git a/LICENSE b/LICENSE
index aae69a9..535195f 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,1058 +1,21 @@
-DB Browser for SQLite is bi-licensed under the Mozilla Public License
-Version 2, as well as the GNU General Public License Version 3 or later.
-
-You can modify or redistribute it under the conditions of these
-licenses. Check also `LICENSE-PLUGINS`.
-
------------------------------------------------------------------------
-
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
-
------------------------------------------------------------------------
-
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0.
+MIT License
+
+Copyright (c) 2024 LY
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/LICENSE-EXTENSIONS b/LICENSE-EXTENSIONS
deleted file mode 100644
index 3e67ad9..0000000
--- a/LICENSE-EXTENSIONS
+++ /dev/null
@@ -1,27 +0,0 @@
-DB Browser for SQLite includes support for SQLite extensions. The support for
-for these comes from the nalgeon/sqlean projects, which have their own (Open
-Source) licenses, different to ours.
-
-nalgeon/sqlean - https://github.com/nalgeon/sqlean/
-
- MIT License
-
- Copyright (c) 2021+ Anton Zhiyanov
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
diff --git a/LICENSE-EXTRA b/LICENSE-EXTRA
new file mode 100644
index 0000000..8bccd6c
--- /dev/null
+++ b/LICENSE-EXTRA
@@ -0,0 +1,595 @@
+sqlitebrowser/sqlitebrowser -
+
+Changes: .github/workflows/build-windows.yml - Fix CI script
+
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+
+************************************************************************
+
+************************************************************************
+
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+
+************************************************************************
+
+8. Litigation
+
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at .
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
+
+sqlcipher/sqlcipher
+
+Copyright (c) 2008-2023, ZETETIC LLC
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ *Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the ZETETIC LLC nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+OpenSSL
+
+ Apache License
+ Version 2.0, January 2004
+ https://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/LICENSE-PLUGINS b/LICENSE-PLUGINS
deleted file mode 100644
index c95f128..0000000
--- a/LICENSE-PLUGINS
+++ /dev/null
@@ -1,78 +0,0 @@
-DB Browser for SQLite includes support for TIFF and WebP images. The
-support for these comes from the LibTIFF and WebP projects, which have
-their own (Open Source) licenses, different to ours.
-
-LibTIFF - http://www.simplesystems.org/libtiff/
-
- Copyright (c) 1988-1997 Sam Leffler
- Copyright (c) 1991-1997 Silicon Graphics, Inc.
-
- Permission to use, copy, modify, distribute, and sell this software and
- its documentation for any purpose is hereby granted without fee, provided
- that (i) the above copyright notices and this permission notice appear in
- all copies of the software and related documentation, and (ii) the names of
- Sam Leffler and Silicon Graphics may not be used in any advertising or
- publicity relating to the software without the specific, prior written
- permission of Sam Leffler and Silicon Graphics.
-
- THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-
- IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- OF THIS SOFTWARE.
-
-WebP - https://developers.google.com/speed/webp/
-
- Copyright (c) 2010, Google Inc. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Google nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Icons - https://codefisher.org/pastel-svg/
-
-Most of the icons come from the Pastel SVG icon set created by Michael
-Buckley. We have obtained a special license (Creative Commons
-Attribution Share Alike 4.0
-http://creativecommons.org/licenses/by-sa/4.0/) but you might be
-required to redistribute it under Creative Commons Attribution
-NonCommercial Share Alike 4.0
-http://creativecommons.org/licenses/by-nc-sa/4.0/
-Check https://codefisher.org/pastel-svg/ for clarification.
-
-The construction emoji for the icon used in the nightly version come
-from the OpenMoji under CC BY-SA 4.0 license.
-Check https://openmoji.org/library/emoji-1F6A7/ and
-https://openmoji.org/faq/ for clarification.
-
-Some icons might have other open licenses, check history of the files
-under `src/icons`.
\ No newline at end of file
diff --git a/src/extensions/extension-formats.c b/src/extensions/extension-formats.c
deleted file mode 100644
index 53306b1..0000000
--- a/src/extensions/extension-formats.c
+++ /dev/null
@@ -1,971 +0,0 @@
-/*** Extension-formats
- *
- * This file adds the following file format support to SQLite.
- *
- * Plist - An XML like encoding
- * Base64 - Standard binary to text conversion
- *
- * Compile using:
- *
- * gcc -g -fPIC -shared extension-formats.c -o libsqlite-formats.so
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE 1
-#include "sqlite3ext.h"
-SQLITE_EXTENSION_INIT1
-
-#define INDENT_INCREMENT 4
-
-#define ERROR_NONE 0
-#define ERROR_INSUFFICIENT_MEMORY 1
-#define ERROR_INVALID_HEADER 2
-#define ERROR_INVALID_TRAILER 3
-#define ERROR_INVALID_OFFSET 4
-#define ERROR_INVALID_OBJECT_LENGTH 5
-#define ERROR_INVALID_REFERENCE 6
-#define ERROR_INVALID_CHARACTER 7
-
-typedef struct KEY {
- struct OBJECT *key;
- struct OBJECT *value;
-} KEY;
-
-typedef struct OBJECT {
- int type;
- int length;
- union {
- time_t date;
- double real;
- long integer;
- unsigned long uid;
- unsigned char binary[1];
- char text[1];
- short int utf16[1];
- int refs[1];
- KEY keys[1];
- struct OBJECT *objects[1];
- } data;
-} OBJECT;
-
-typedef struct CONFIG {
- int bytesPerOffset;
- int bytesPerReference;
- int objectCount;
- int rootObjectReference;
- int offsetTableOffset;
- size_t bufferLength;
- size_t outputBufferLength;
- size_t outputBufferIn;
- long *offsetTable;
- unsigned char *buffer;
- unsigned char *outputBuffer;
-} CONFIG;
-
-int createObject(int type, int length, int extra, OBJECT **ptr2);
-int readObject(CONFIG *cfg, long offset, OBJECT **ptr2);
-
-static int indent = 2;
-
-int outputText(CONFIG *cfg, const char *text)
-{
- size_t textLength = strlen(text);
- size_t availableSpace = cfg->outputBufferLength - cfg->outputBufferIn;
- while (textLength >= availableSpace) {
- unsigned char *tmp = cfg->outputBuffer;
- cfg->outputBufferLength += textLength + 1024;
- cfg->outputBuffer = (unsigned char *)realloc(cfg->outputBuffer, cfg->outputBufferLength);
- if (cfg->outputBuffer == NULL) {
- if (tmp != NULL)
- free(tmp);
- return ERROR_INSUFFICIENT_MEMORY;
- }
- availableSpace = cfg->outputBufferLength - cfg->outputBufferIn;
- }
- strcpy((char *)(cfg->outputBuffer+cfg->outputBufferIn), text);
- cfg->outputBufferIn += textLength;
- return ERROR_NONE;
-}
-
-int printWithIndent(CONFIG *cfg, const char *text, int newline)
-{
- int err = ERROR_NONE;
- char spaces[9] = " ";
- int n = indent;
- while ((n > 8) && (err == ERROR_NONE)) {
- err = outputText(cfg, spaces);
- n -= 8;
- }
- if ((n > 0) && (err == ERROR_NONE))
- err = outputText(cfg, spaces + 8 - n);
- if (err == ERROR_NONE)
- err = outputText(cfg, text);
- if (newline && (err == ERROR_NONE))
- err = outputText(cfg, "\n");
- return err;
-}
-
-int readHeader(CONFIG *cfg)
-{
- if ((cfg->bufferLength < 40) ||
- (strncmp((const char *)(cfg->buffer), "bplist0", 7) != 0) ||
- ((cfg->buffer[7] != '0') && (cfg->buffer[7] != '1')))
- return ERROR_INVALID_HEADER;
- return ERROR_NONE;
-}
-
-int readTrailer(CONFIG *cfg)
-{
- int i, j;
- int objectCount = 0;
- int rootObjectReference = 0;
- int offsetTableOffset = 0;
- unsigned char *ptr;
- unsigned char *buffer = cfg->buffer + cfg->bufferLength - 32;
-
- // Extract the relevant fields
- for (i=12; i < 16; i++)
- objectCount = (objectCount << 8) + buffer[i];
- for (i=20; i < 24; i++)
- rootObjectReference = (rootObjectReference << 8) + buffer[i];
- for (i=28; i < 32; i++)
- offsetTableOffset = (offsetTableOffset << 8) + buffer[i];
-
- // Populate the configurartion structure
- cfg->bytesPerOffset = buffer[6];
- cfg->bytesPerReference = buffer[7];
- cfg->objectCount = objectCount;
- cfg->rootObjectReference = rootObjectReference;
- cfg->offsetTableOffset = offsetTableOffset;
- cfg->offsetTable = (long *)malloc((size_t)objectCount * sizeof(long));
- if (cfg->offsetTable == NULL)
- return ERROR_INSUFFICIENT_MEMORY;
- ptr = cfg->buffer + offsetTableOffset;
- for (i=0; i < objectCount; i++) {
- long n = 0;
- for (j=0; j < cfg->bytesPerOffset; j++)
- n = (n << 8) | *(ptr++);
- cfg->offsetTable[i] = n;
- }
- return ERROR_NONE;
-}
-
-int createObject(int type, int length, int extra, OBJECT **ptr2)
-{
- *ptr2 = NULL;
- OBJECT *ptr = (OBJECT *)malloc(sizeof(OBJECT) + (size_t)extra);
- if (ptr == NULL)
- return ERROR_INSUFFICIENT_MEMORY;
- ptr->type = type;
- ptr->length = length;
- *ptr2 = ptr;
- return ERROR_NONE;
-}
-
-long readInteger(unsigned char *ptr, int desc)
-{
- long value = 0L;
- int n = 1 << (desc & 0x03);
- while (n--)
- value = (value << 8) | (long)(*(ptr++));
- return value;
-}
-
-unsigned long readUid(unsigned char *ptr, int desc)
-{
- unsigned long value = 0L;
- int n = 1 << (desc & 0x03);
- while (n--)
- value = (value << 8) | (unsigned long)(*(ptr++));
- return value;
-}
-
-double readDouble(unsigned char *ptr, int desc)
-{
- union {
- double v;
- float f[2];
- unsigned char b[8];
- } value;
- int n = 1 << (desc & 0x03);
- for (int i=0; i < n; i++)
- value.b[7-i] = *(ptr++);
- if (n == 4)
- value.v = (double)(value.f[1]);
- return value.v;
-}
-
-int readArray(CONFIG *cfg, unsigned char *ptr, int type, int length, OBJECT **array2)
-{
- int i;
- long offset;
- OBJECT *array;
- int err = createObject(type, length, ((length-1) * (int)sizeof(OBJECT)), &array);
- *array2 = NULL;
- for (i=0; (i < length) && (err == ERROR_NONE); i++) {
- offset = 0L;
- for (int j=0; j < cfg->bytesPerReference; j++)
- offset = (offset << 8) | (long)(*(ptr++));
- if (offset >= cfg->objectCount)
- return ERROR_INVALID_REFERENCE;
- offset = cfg->offsetTable[offset];
- err = readObject(cfg, offset, &(array->data.objects[i]));
- }
- if (err == ERROR_NONE)
- *array2 = array;
- return err;
-}
-
-int readDictionary(CONFIG *cfg, unsigned char *ptr, int type, int length, OBJECT **dict2)
-{
- int i;
- long offset;
- OBJECT *dict;
- int err = createObject(type, length, ((length-1) * (int)sizeof(KEY)), &dict);
- *dict2 = NULL;
- if (err != ERROR_NONE)
- return err;
- for (i=0; (i < length) && (err == ERROR_NONE); i++) {
- offset = 0L;
- for (int j=0; j < cfg->bytesPerReference; j++)
- offset = (offset << 8) | (long)(*(ptr++));
- if (offset >= cfg->objectCount)
- return ERROR_INVALID_REFERENCE;
- offset = cfg->offsetTable[offset];
- err = readObject(cfg, offset, &(dict->data.keys[i].key));
- }
- for (i=0; (i < length) && (err == ERROR_NONE); i++) {
- offset = 0L;
- for (int j=0; j < cfg->bytesPerReference; j++)
- offset = (offset << 8) | (long)(*(ptr++));
- if (offset >= cfg->objectCount)
- return ERROR_INVALID_REFERENCE;
- offset = cfg->offsetTable[offset];
- err = readObject(cfg, offset, &(dict->data.keys[i].value));
- }
- if (err == ERROR_NONE)
- *dict2 = dict;
- return err;
-}
-
-int readObject(CONFIG *cfg, long offset, OBJECT **ptr2)
-{
- int i;
- int length;
- int type;
- int err = ERROR_NONE;
- OBJECT *obj;
- unsigned char *ptr;
-
- *ptr2 = NULL;
- if ((size_t)offset >= cfg->bufferLength)
- return ERROR_INVALID_OFFSET;
- ptr = cfg->buffer + offset;
- type = *(ptr++);
- length = (type & 0x0F);
- type >>= 4;
- if ((type != 0) && (length == 0x0F)) {
- length = *(ptr++);
- if ((length >> 4) != 0x01)
- return ERROR_INVALID_OBJECT_LENGTH;
- i = (int)readInteger(ptr, length);
- ptr += (1 << (length & 0x03));
- length = i;
- }
- switch (type) {
- case 0x00: // Singleton
- err = createObject(type, length, 5, &obj);
- if (err != ERROR_NONE)
- return err;
- switch(length) {
- case 0: // NULL
- strcpy(obj->data.text, "");
- break;
- case 8: // False
- strcpy(obj->data.text, "");
- break;
- case 9: // True
- strcpy(obj->data.text, "");
- break;
- case 15: // Fill
- strcpy(obj->data.text, "");
- break;
- default: // Illegal
- strcpy(obj->data.text, "***Error***");
- break;
- }
- break;
- case 0x01: // Integer
- err = createObject(type, length, 0, &obj);
- if (err != ERROR_NONE)
- return err;
- obj->data.integer = readInteger(ptr, length);
- break;
- case 0x02: // Float
- err = createObject(type, length, 0, &obj);
- if (err != ERROR_NONE)
- return err;
- obj->data.real = readDouble(ptr, length);
- break;
- case 0x03: // Date in Elapsed seconds
- err = createObject(type, length, 0, &obj);
- if (err != ERROR_NONE)
- return err;
- obj->data.date = (time_t)readDouble(ptr, length);
- break;
- case 0x04: // binary data
- err = createObject(type, length, length, &obj);
- if (err != ERROR_NONE)
- return err;
- for (i=0; i < length; i++)
- obj->data.binary[i] = *(ptr++);
- break;
- case 0x05: // ASCII string
- err = createObject(type, length, length, &obj);
- if (err != ERROR_NONE)
- return err;
- for (i=0; i < length; i++)
- obj->data.text[i] = (char)*(ptr++);
- obj->data.text[length] = '\0';
- break;
- case 0x06: // UTF16 string
- err = createObject(type, length, 2 * length, &obj);
- if (err != ERROR_NONE)
- return err;
- for (i=0; i < length; i++) {
- short int d = *(ptr++);
- obj->data.utf16[i] = (short int)((d << 8) | *(ptr++));
- }
- obj->data.utf16[length] = '\0';
- break;
- case 0x08: // UID
- err = createObject(type, length, 0, &obj);
- if (err != ERROR_NONE)
- return err;
- obj->data.uid = readUid(ptr, length);
- break;
- case 0x0A: // Array
- err = readArray(cfg, ptr, type, length, &obj);
- break;
- case 0x0D: // Dictionary
- err = readDictionary(cfg, ptr, type, length, &obj);
- break;
- default:
- fprintf(stderr, "Unknown object type: %d\n", type);
- err = createObject(type, length, 0, &obj);
- break;
- }
- if (err == ERROR_NONE)
- *ptr2 = obj;
- return err;
-}
-
-void displayHex(CONFIG *cfg, int data)
-{
- static int in = 0;
- static char buffer[76];
- static long offset = 0L;
- static char hex[] = "0123456789ABCDEF";
- char *tmp;
-
- // If -ve then flush buffer
- if (data < 0) {
- if (in > 0) {
- tmp = buffer + in * 3 + 8 + 2 * (in / 8);
- while (tmp < buffer+59)
- *(tmp++) = ' ';
- buffer[in+59] = '\0';
- printWithIndent(cfg, buffer, 1);
- }
- offset = 0L;
- in = 0;
- return;
- }
-
- // If start of line add offset
- if (in == 0) {
- sprintf((char *)buffer, "%06lX ", offset);
- offset += 16;
- buffer[8] = '\0';
- }
-
- // Add Byte in hex
- tmp = buffer + in * 3 + 8 + 2 * (in / 8);
- *(tmp++) = hex[(data >> 4) & 0x0F];
- *(tmp++) = hex[data & 0x0F];
- *(tmp++) = ' ';
-
- // Add to character buffer
- buffer[in+59] = (char)data;
-
- // Check if midpoint of buffer
- if (++in == 8) {
- *(tmp++) = '-';
- *(tmp++) = ' ';
- }
-
- // Check if buffer full
- if (in == 16) {
- buffer[75] = '\0';
- printWithIndent(cfg, buffer, 1);
- in = 0;
- }
- return;
-}
-
-int displayObject(CONFIG *cfg, OBJECT *obj, int raw)
-{
- char text[32];
- switch (obj->type) {
- case 0x00: // Singleton
- printWithIndent(cfg, obj->data.text, 1);
- break;
- case 0x01: // Integer
- if (raw == 0)
- printWithIndent(cfg, "", 0);
- sprintf(text, "%ld", obj->data.integer);
- outputText(cfg, text);
- if (raw == 0)
- outputText(cfg, "\n");
- break;
- case 0x02: // Float
- if (raw == 0)
- printWithIndent(cfg, "", 0);
- sprintf(text, "%f", obj->data.real);
- outputText(cfg, text);
- if (raw == 0)
- outputText(cfg, "\n");
- break;
- case 0x03: // Date
- if (raw == 0)
- printWithIndent(cfg, "", 0);
- outputText(cfg, ctime(&(obj->data.date)));
- if (raw == 0)
- outputText(cfg, "\n");
- break;
- case 0x04: // Binary data
- if (raw == 0)
- printWithIndent(cfg, "", 1);
- indent += INDENT_INCREMENT;
- for (int i=0; i < obj->length; i++)
- displayHex(cfg, obj->data.binary[i]);
- displayHex(cfg, -1);
- indent -= INDENT_INCREMENT;
- if (raw == 0)
- printWithIndent(cfg, "", 1);
- break;
- case 0x05: // String
- if (raw == 0)
- printWithIndent(cfg, "", 0);
- outputText(cfg, (obj->data.text));
- if (raw == 0)
- outputText(cfg, "\n");
- break;
- case 0x06: // UTF16 string
- if (raw == 0)
- printWithIndent(cfg, "", 1);
- indent += INDENT_INCREMENT;
- for (int i=0; i < obj->length; i++)
- displayHex(cfg, obj->data.binary[i]);
- displayHex(cfg, -1);
- indent -= INDENT_INCREMENT;
- if (raw == 0)
- printWithIndent(cfg, "", 1);
- break;
- case 0x08: // UID
- if (raw == 0)
- printWithIndent(cfg, "", 0);
- sprintf(text, "%lu", obj->data.uid);
- outputText(cfg, text);
- if (raw == 0)
- outputText(cfg, "\n");
- break;
- case 0x0A: // Array
- printWithIndent(cfg, "", 1);
- indent += INDENT_INCREMENT;
- for (int i=0; i < obj->length; i++)
- displayObject(cfg, obj->data.objects[i], 0);
- indent -= INDENT_INCREMENT;
- printWithIndent(cfg, "", 1);
- break;
- case 0x0D: // Dictionary
- printWithIndent(cfg, "", 1);
- indent += INDENT_INCREMENT;
- for (int i=0; i < obj->length; i++) {
- printWithIndent(cfg, "", 0);
- displayObject(cfg, obj->data.keys[i].key, 1);
- outputText(cfg, "\n");
- displayObject(cfg, obj->data.keys[i].value, 0);
- }
- indent -= INDENT_INCREMENT;
- printWithIndent(cfg, "", 1);
- break;
- default:
- sprintf(text, "Cannot display type: %d\n", obj->type);
- outputText(cfg, text);
- break;
- }
- return ERROR_NONE;
-}
-
-int releaseObject(OBJECT *obj)
-{
- int i;
- switch (obj->type) {
- case 0x00: // Singleton
- case 0x01: // Int
- case 0x02: // Float
- case 0x03: // Date
- case 0x04: // Binary
- case 0x05: // ASCII
- case 0x06: // UTF16
- case 0x08: // UID
- break;
- case 0x0A: // Array
- for (i=0; i < obj->length; i++)
- releaseObject(obj->data.objects[i]);
- break;
- case 0x0D: // Dictionary
- for (i=0; i < obj->length; i++) {
- releaseObject(obj->data.keys[i].key);
- releaseObject(obj->data.keys[i].value);
- }
- break;
- }
- free(obj);
- return ERROR_NONE;
-}
-
-int parsePlist(char **result, const char *data, int dataLength)
-{
- CONFIG cfg;
- char *ptr;
- OBJECT *obj;
- int err = ERROR_NONE;
- int version;
- long offset;
- long length;
- char text[32];
-
- // Determine the file size and save
- cfg.buffer = (unsigned char *)data;
- cfg.bufferLength = dataLength;
-
- // Preset the output buffer
- cfg.outputBufferLength = 0;
- cfg.outputBufferIn = 0;
- cfg.outputBuffer = NULL;
-
- // Read the header
- err = readHeader(&cfg);
- if (err != ERROR_NONE)
- return err;
- version = (int)(cfg.buffer[7] - '0');
-
- // Read the trailer
- err = readTrailer(&cfg);
- if (err != ERROR_NONE)
- return err; // ERROR_INVALID_TRAILER;
-
- // Locate and read the root object
- offset = cfg.offsetTable[cfg.rootObjectReference];
- err = readObject(&cfg, offset, &obj);
-
- // If no error display the root object and hence the whole object tree
- if (err != ERROR_NONE)
- return err;
-
- sprintf(text, "\n", version);
- outputText(&cfg, text);
- displayObject(&cfg, obj, 0);
- outputText(&cfg, "\n");
-
- // Create return data
- length = strlen((const char *)(cfg.outputBuffer));
- ptr = malloc(length + 1);
- *result = ptr;
- if (ptr != NULL) {
- for (int i=0; i < length; i++)
- *(ptr++) = cfg.outputBuffer[i];
- *ptr = '\0';
- }
- else
- err = ERROR_INSUFFICIENT_MEMORY;
-
- // Release assigned memory
- releaseObject(obj);
- free(cfg.offsetTable);
- free(cfg.outputBuffer);
- return err;
-}
-
-static char map[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-/** Encode Base64
- *
- */
-
-int encodeBase64(char **result, const unsigned char *data, int dataLength)
-{
- unsigned char d;
- int b;
- int bitsLeft = 0;
- int in = 0;
- int out = 0;
- int encodedLength = dataLength * 4 / 3 + 4;
- char *encoded = malloc(encodedLength);
- *result = encoded;
- if (encoded == NULL)
- return ERROR_INSUFFICIENT_MEMORY;
-
- while (out < dataLength) {
- d = data[out++];
- switch (bitsLeft) {
- case 0:
- encoded[in++] = map[d >> 2];
- b = d & 0x03;
- bitsLeft = 2;
- break;
- case 2:
- b = (b << 8) | d;
- encoded[in++] = map[b >> 4];
- b &= 0x0F;
- bitsLeft = 4;
- break;
- case 4:
- b = (b << 8) | d;
- encoded[in++] = map[b >> 6];
- encoded[in++] = map[b & 0x03F];
- bitsLeft = 0;
- break;
- }
- }
-
- /* Flush remaining bits */
- switch (bitsLeft) {
- case 2:
- encoded[in++] = map[b << 4];
- encoded[in++] = '=';
- encoded[in++] = '=';
- break;
- case 4:
- encoded[in++] = map[b << 2];
- encoded[in++] = '=';
- break;
- default:
- break;
- }
-
- /* Terminate as string */
- encoded[in] = '\0';
- return ERROR_NONE;
-}
-
-static unsigned char unmap[256] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 00 - 07
- 0x81, 0x80, 0x81, 0x80, 0x80, 0x81, 0x80, 0x80, // 08 - 0F
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 10 - 17
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 18 - 1F
- 0x80, 0x81, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 20 - 27
- 0x80, 0x80, 0x80, 0x3E, 0x80, 0x80, 0x80, 0x3F, // 28 - 2F
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, // 30 - 37
- 0x3C, 0x3D, 0x80, 0x80, 0x80, 0x40, 0x80, 0x80, // 38 - 3F
- 0x80, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // 40 - 47
- 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, // 48 - 4F
- 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, // 50 - 57
- 0x17, 0x18, 0x19, 0x80, 0x80, 0x80, 0x80, 0x80, // 58 - 5F
- 0x80, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, // 60 - 67
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, // 68 - 6F
- 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, // 70 - 77
- 0x31, 0x32, 0x33, 0x80, 0x80, 0x80, 0x80, 0x80, // 78 - 7F
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 80 - 87
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 88 - 8F
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 90 - 97
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 98 - 9F
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // A0 - A7
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // A8 - AF
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // B0 - B7
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // B8 - BF
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // C0 - C7
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // C8 - CF
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // D0 - D7
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // D8 - DF
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // E0 - E7
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // E8 - EF
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // F0 - F7
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // F8 - FF
-};
-
-/*** decodeBase64
- *
- * Returns decoded data and length.
- */
-
-int decodeBase64(unsigned char **result, int *resultLength, const char *data, int dataLength)
-{
- int bitsLeft = 8;
- int in = 0;
- unsigned char b;
- unsigned char d;
- unsigned char *decoded = malloc(dataLength * 3 / 4 + 3);
- *result = decoded;
- *resultLength = 0;
- if (decoded == NULL)
- return ERROR_INSUFFICIENT_MEMORY;
-
- while (*data != '\0') {
- // Get character and check valid
- d = unmap[*(data++)];
- if (d > 0x3F) {
- if (d == 0x80) {
- free(decoded);
- return ERROR_INVALID_CHARACTER;
- }
- break; // padding space
- }
-
- switch (bitsLeft) {
- case 8:
- decoded[in] = d;
- bitsLeft = 2;
- break;
- case 2:
- decoded[in] = (decoded[in] << 2) | (d >> 4);
- decoded[++in] = d & 0x0F;
- bitsLeft = 4;
- break;
- case 4:
- decoded[in] = (decoded[in] << 4) | (d >> 2);
- decoded[++in] = d & 0x03;
- bitsLeft = 6;
- break;
- case 6:
- decoded[in] = (decoded[in] << 6) | d;
- in++;
- bitsLeft = 8;
- break;
- }
- }
- *resultLength = in;
- return ERROR_NONE;
-}
-
-/** Wrapper functions
- *
- */
-
-void freeResult(void *ptr)
-{
- if (ptr != NULL)
- free(ptr);
- return;
-}
-
-static void plistFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- int resultLength;
- int errorCode = 0;
- char *result = NULL;
- assert( argc==1 );
- switch( sqlite3_value_type(argv[0]) ){
- case SQLITE_TEXT:
- case SQLITE_BLOB: {
- const char *data = sqlite3_value_text(argv[0]);
- const int dataLength = sqlite3_value_bytes(argv[0]);
- errorCode = parsePlist(&result, data, dataLength);
- if (errorCode == ERROR_NONE) {
- resultLength = strlen(result);
- sqlite3_result_text(context, result, resultLength, &freeResult);
- } else {
- if (sqlite3_value_type(argv[0]) == SQLITE_TEXT)
- sqlite3_result_text(context, data, dataLength, NULL);
- else
- sqlite3_result_blob(context, data, dataLength, NULL);
- }
- break;
- }
- default: {
- sqlite3_result_null(context);
- break;
- }
- }
-}
-
-static void encodeBase64Func(sqlite3_context *context, int argc, sqlite3_value **argv){
- int resultLength;
- int errorCode = 0;
- int dataLength;
- const unsigned char *data;
- char *result = NULL;
- assert( argc==1 );
- switch( sqlite3_value_type(argv[0]) ){
- case SQLITE_BLOB:
- data = sqlite3_value_blob(argv[0]);
- dataLength = sqlite3_value_bytes(argv[0]);
- errorCode = encodeBase64(&result, data, dataLength);
- if (errorCode == ERROR_NONE) {
- resultLength = strlen(result);
- sqlite3_result_text(context, result, resultLength, &freeResult);
- } else {
- sqlite3_result_blob(context, data, dataLength, NULL);
- }
- break;
- case SQLITE_TEXT: {
- data = sqlite3_value_text(argv[0]);
- dataLength = sqlite3_value_bytes(argv[0]);
- sqlite3_result_text(context, data, dataLength, NULL);
- errorCode = encodeBase64(&result, data, dataLength);
- if (errorCode == ERROR_NONE) {
- resultLength = strlen(result);
- sqlite3_result_text(context, result, resultLength, &freeResult);
- } else {
- sqlite3_result_text(context, data, dataLength, NULL);
- }
- break;
- }
- default: {
- sqlite3_result_null(context);
- break;
- }
- }
-}
-
-
-/*** isText
- *
- * Returns zero if supplied data is entirely
- * ASCII printable characters or white space.
- */
-
-int isText(unsigned char *data, int dataLength)
-{
- static unsigned char map[256] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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, 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, 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
- };
- int result = 0;
- for (int i=0; i < dataLength; i++)
- result |= map[*(data++)];
- return result;
-}
-
-/** isUTF8
- *
- * Returns one if the characters conform to UTF8 format in so
- * far as all the byte lengths are consistent. It does not
- * check for overlong encodings or invalid characters. A zero
- * is returned if the format is not consistent.
- * Note that a file of all zeros will be returned as UTF8.
- */
-
-int isUTF8(unsigned char *data, int length)
-{
- int count = 0;
- while (length-- > 0) {
- unsigned char d = *(data++);
- switch (count) {
- case 0: /* First character */
- if ((d & 0x80) == 0)
- continue; /* 7 bit ASCII */
- if ((d & 0xE0) == 0xC0) {
- count = 1; /* 2 byte code */
- break;
- }
- if ((d & 0xF0) == 0xE0) {
- count = 2; /* 3 byte code */
- break;
- }
- if ((d & 0xF8) == 0xF0) {
- count = 3; /* 4 byte code */
- break;
- }
- return 0;
- default:
- count--;
- if ((d & 0xC0) != 0x80)
- return 0;
- break;
- }
- }
- return (count == 0) ? 1 : 0;
-}
-
-static void decodeBase64Func(sqlite3_context *context, int argc, sqlite3_value **argv){
- int resultLength;
- int errorCode = 0;
- unsigned char *result = NULL;
- assert( argc==1 );
- switch( sqlite3_value_type(argv[0]) ){
- case SQLITE_BLOB:
- case SQLITE_TEXT: {
- const char *data = sqlite3_value_text(argv[0]);
- int dataLength = sqlite3_value_bytes(argv[0]);
- errorCode = decodeBase64(&result, &resultLength, data, dataLength);
- if (errorCode == ERROR_NONE) {
- if (isUTF8(result, resultLength))
- sqlite3_result_text(context, result, resultLength, &freeResult);
- else
- sqlite3_result_blob(context, result, resultLength, &freeResult);
- } else {
- if (sqlite3_value_type(argv[0]) == SQLITE_TEXT)
- sqlite3_result_text(context, data, dataLength, NULL);
- else
- sqlite3_result_blob(context, data, dataLength, NULL);
- }
- break;
- }
- default: {
- sqlite3_result_null(context);
- break;
- }
- }
-}
-
-/** RegisterExtensionFormats
- *
- * Register the parsing functions with sqlite
- */
-
-int RegisterExtensionFormats(sqlite3 *db)
-{
- sqlite3_create_function(db, "plist", 1, 0, db, plistFunc, 0, 0);
- sqlite3_create_function(db, "unBase64", 1, 0, db, decodeBase64Func, 0, 0);
- sqlite3_create_function(db, "toBase64", 1, 0, db, encodeBase64Func, 0, 0);
-}
-
-#ifdef COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE
-
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-
-int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi)
-{
- int rc = SQLITE_OK;
- SQLITE_EXTENSION_INIT2(pApi);
- RegisterExtensionFormats(db);
- return rc;
-}
-
-#endif
-
-
diff --git a/src/extensions/extension-formats.def b/src/extensions/extension-formats.def
deleted file mode 100644
index 2bfb84f..0000000
--- a/src/extensions/extension-formats.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- RegisterExtensionFormats
- sqlite3_api
- sqlite3_extension_init
- freeResult
diff --git a/src/extensions/extension-functions.c b/src/extensions/extension-functions.c
deleted file mode 100644
index cb43fbb..0000000
--- a/src/extensions/extension-functions.c
+++ /dev/null
@@ -1,1947 +0,0 @@
-/*
-This library will provide common mathematical and string functions in
-SQL queries using the operating system libraries or provided
-definitions. It includes the following functions:
-
-Math: acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference,
-degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp,
-log, log10, power, sign, sqrt, square, ceil, floor, pi.
-
-String: replicate, charindex, leftstr, rightstr, ltrim, rtrim, trim,
-replace, reverse, proper, padl, padr, padc, strfilter.
-
-Aggregate: stdev, variance, mode, median, lower_quartile,
-upper_quartile.
-
-The string functions ltrim, rtrim, trim, replace are included in
-recent versions of SQLite and so by default do not build.
-
-Compilation instructions:
- Compile this C source file into a dynamic library as follows:
- * Linux:
- gcc -fPIC -lm -shared extension-functions.c -o libsqlitefunctions.so
- * macOS:
- gcc -fno-common -dynamiclib extension-functions.c -o libsqlitefunctions.dylib
- (You may need to add flags
- -I /opt/local/include/ -L/opt/local/lib -lsqlite3
- if your sqlite3 is installed from Mac ports, or
- -I /sw/include/ -L/sw/lib -lsqlite3
- if installed with Fink.)
- * Windows:
- 1. Install MinGW (http://www.mingw.org/) and you will get the gcc
- (gnu compiler collection)
- 2. add the path to your path variable (isn't done during the
- installation!)
- 3. compile:
- gcc -shared -I "path" -o libsqlitefunctions.so extension-functions.c
- (path = path of sqlite3ext.h; i.e. C:\programs\sqlite)
-
-Usage instructions for applications calling the sqlite3 API functions:
- In your application, call sqlite3_enable_load_extension(db,1) to
- allow loading external libraries. Then load the library libsqlitefunctions
- using sqlite3_load_extension; the third argument should be 0.
- See http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions.
- Select statements may now use these functions, as in
- SELECT cos(radians(inclination)) FROM satsum WHERE satnum = 25544;
-
-Usage instructions for the sqlite3 program:
- If the program is built so that loading extensions is permitted,
- the following will work:
- sqlite> SELECT load_extension('./libsqlitefunctions.so');
- sqlite> select cos(radians(45));
- 0.707106781186548
- Note: Loading extensions is by default prohibited as a
- security measure; see "Security Considerations" in
- http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions.
- If the sqlite3 program and library are built this
- way, you cannot use these functions from the program, you
- must write your own program using the sqlite3 API, and call
- sqlite3_enable_load_extension as described above, or else
- rebuilt the sqlite3 program to allow loadable extensions.
-
-Alterations:
-The instructions are for Linux, Mac OS X, and Windows; users of other
-OSes may need to modify this procedure. In particular, if your math
-library lacks one or more of the needed trig or log functions, comment
-out the appropriate HAVE_ #define at the top of file. If you do not
-wish to make a loadable module, comment out the define for
-COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE. If you are using a
-version of SQLite without the trim functions and replace, comment out
-the HAVE_TRIM #define.
-
-Liam Healy
-
-History:
-2010-01-06 Correct check for argc in squareFunc, and add Windows
-compilation instructions.
-2009-06-24 Correct check for argc in properFunc.
-2008-09-14 Add check that memory was actually allocated after
-sqlite3_malloc or sqlite3StrDup, call sqlite3_result_error_nomem if
-not. Thanks to Robert Simpson.
-2008-06-13 Change to instructions to indicate use of the math library
-and that program might work.
-2007-10-01 Minor clarification to instructions.
-2007-09-29 Compilation as loadable module is optional with
-COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE.
-2007-09-28 Use sqlite3_extension_init and macros
-SQLITE_EXTENSION_INIT1, SQLITE_EXTENSION_INIT2, so that it works with
-sqlite3_load_extension. Thanks to Eric Higashino and Joe Wilson.
-New instructions for Mac compilation.
-2007-09-17 With help from Joe Wilson and Nuno Luca, made use of
-external interfaces so that compilation is no longer dependent on
-SQLite source code. Merged source, header, and README into a single
-file. Added casts so that Mac will compile without warnings (unsigned
-and signed char).
-2007-09-05 Included some definitions from sqlite 3.3.13 so that this
-will continue to work in newer versions of sqlite. Completed
-description of functions available.
-2007-03-27 Revised description.
-2007-03-23 Small cleanup and a bug fix on the code. This was mainly
-letting errno flag errors encountered in the math library and checking
-the result, rather than pre-checking. This fixes a bug in power that
-would cause an error if any non-positive number was raised to any
-power.
-2007-02-07 posted by Mikey C to sqlite mailing list.
-Original code 2006 June 05 by relicoder.
-
-*/
-
-//#include "config.h"
-
-#define COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE 1
-#define HAVE_ACOSH 1
-#define HAVE_ASINH 1
-#define HAVE_ATANH 1
-#define HAVE_SINH 1
-#define HAVE_COSH 1
-#define HAVE_TANH 1
-#define HAVE_LOG10 1
-#define HAVE_ISBLANK 1
-#define SQLITE_SOUNDEX 1
-#define HAVE_TRIM 1 /* LMH 2007-03-25 if sqlite has trim functions */
-
-#ifdef COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE
-#include "sqlite3ext.h"
-SQLITE_EXTENSION_INIT1
-#else
-#include "sqlite3.h"
-#endif
-
-#include
-/* relicoder */
-#include
-#include
-#include
-#include /* LMH 2007-03-25 */
-
-#include
-#include
-
-#ifndef _MAP_H_
-#define _MAP_H_
-
-#include
-
-/*
-** Simple binary tree implementation to use in median, mode and quartile calculations
-** Tree is not necessarily balanced. That would require something like red&black trees of AVL
-*/
-
-typedef int(*cmp_func)(const void *, const void *);
-typedef void(*map_iterator)(void*, int64_t, void*);
-
-typedef struct node{
- struct node *l;
- struct node *r;
- void* data;
- int64_t count;
-} node;
-
-typedef struct map{
- node *base;
- cmp_func cmp;
- short free;
-} map;
-
-/*
-** creates a map given a comparison function
-*/
-map map_make(cmp_func cmp);
-
-/*
-** inserts the element e into map m
-*/
-void map_insert(map *m, void *e);
-
-/*
-** executes function iter over all elements in the map, in key increasing order
-*/
-void map_iterate(map *m, map_iterator iter, void* p);
-
-/*
-** frees all memory used by a map
-*/
-void map_destroy(map *m);
-
-/*
-** compares 2 integers
-** to use with map_make
-*/
-int int_cmp(const void *a, const void *b);
-
-/*
-** compares 2 doubles
-** to use with map_make
-*/
-int double_cmp(const void *a, const void *b);
-
-#endif /* _MAP_H_ */
-
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef int64_t i64;
-
-static char *sqlite3StrDup( const char *z ) {
- char *res = sqlite3_malloc( strlen(z)+1 );
- return strcpy( res, z );
-}
-
-/*
-** These are copied verbatim from fun.c so as to not have the names exported
-*/
-
-/* LMH from sqlite3 3.3.13 */
-/*
-** This table maps from the first byte of a UTF-8 character to the number
-** of trailing bytes expected. A value '4' indicates that the table key
-** is not a legal first byte for a UTF-8 character.
-*/
-static const u8 xtra_utf8_bytes[256] = {
-/* 0xxxxxxx */
-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,
-
-/* 10wwwwww */
-4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-
-/* 110yyyyy */
-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,
-
-/* 1110zzzz */
-2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-
-/* 11110yyy */
-3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-
-
-/*
-** This table maps from the number of trailing bytes in a UTF-8 character
-** to an integer constant that is effectively calculated for each character
-** read by a naive implementation of a UTF-8 character reader. The code
-** in the READ_UTF8 macro explains things best.
-*/
-static const int xtra_utf8_bits[] = {
- 0,
- 12416, /* (0xC0 << 6) + (0x80) */
- 925824, /* (0xE0 << 12) + (0x80 << 6) + (0x80) */
- 63447168 /* (0xF0 << 18) + (0x80 << 12) + (0x80 << 6) + 0x80 */
-};
-
-/*
-** If a UTF-8 character contains N bytes extra bytes (N bytes follow
-** the initial byte so that the total character length is N+1) then
-** masking the character with utf8_mask[N] must produce a non-zero
-** result. Otherwise, we have an (illegal) overlong encoding.
-*/
-static const int utf_mask[] = {
- 0x00000000,
- 0xffffff80,
- 0xfffff800,
- 0xffff0000,
-};
-
-/* LMH salvaged from sqlite3 3.3.13 source code src/utf.c */
-#define READ_UTF8(zIn, c) { \
- int xtra; \
- c = *(zIn)++; \
- xtra = xtra_utf8_bytes[c]; \
- switch( xtra ){ \
- case 4: c = (int)0xFFFD; break; \
- case 3: c = (c<<6) + *(zIn)++; \
- case 2: c = (c<<6) + *(zIn)++; \
- case 1: c = (c<<6) + *(zIn)++; \
- c -= xtra_utf8_bits[xtra]; \
- if( (utf_mask[xtra]&c)==0 \
- || (c&0xFFFFF800)==0xD800 \
- || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
- } \
-}
-
-static int sqlite3ReadUtf8(const unsigned char *z){
- int c;
- READ_UTF8(z, c);
- return c;
-}
-
-#define SKIP_UTF8(zIn) { \
- zIn += (xtra_utf8_bytes[*(u8 *)zIn] + 1); \
-}
-
-/*
-** pZ is a UTF-8 encoded unicode string. If nByte is less than zero,
-** return the number of unicode characters in pZ up to (but not including)
-** the first 0x00 byte. If nByte is not less than zero, return the
-** number of unicode characters in the first nByte of pZ (or up to
-** the first 0x00, whichever comes first).
-*/
-static int sqlite3Utf8CharLen(const char *z, int nByte){
- int r = 0;
- const char *zTerm;
- if( nByte>=0 ){
- zTerm = &z[nByte];
- }else{
- zTerm = (const char *)(-1);
- }
- assert( z<=zTerm );
- while( *z!=0 && z 0) ? 1: ( iVal < 0 ) ? -1: 0;
- sqlite3_result_int64(context, iVal);
- break;
- }
- case SQLITE_NULL: {
- sqlite3_result_null(context);
- break;
- }
- default: {
- /* 2nd change below. Line for abs was: if( rVal<0 ) rVal = rVal * -1.0; */
-
- rVal = sqlite3_value_double(argv[0]);
- rVal = ( rVal > 0) ? 1: ( rVal < 0 ) ? -1: 0;
- sqlite3_result_double(context, rVal);
- break;
- }
- }
-}
-
-
-/*
-** smallest integer value not less than argument
-*/
-static void ceilFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- double rVal=0.0;
- i64 iVal=0;
- assert( argc==1 );
- switch( sqlite3_value_type(argv[0]) ){
- case SQLITE_INTEGER: {
- i64 iVal = sqlite3_value_int64(argv[0]);
- sqlite3_result_int64(context, iVal);
- break;
- }
- case SQLITE_NULL: {
- sqlite3_result_null(context);
- break;
- }
- default: {
- rVal = sqlite3_value_double(argv[0]);
- sqlite3_result_int64(context, (i64) ceil(rVal));
- break;
- }
- }
-}
-
-/*
-** largest integer value not greater than argument
-*/
-static void floorFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- double rVal=0.0;
- i64 iVal=0;
- assert( argc==1 );
- switch( sqlite3_value_type(argv[0]) ){
- case SQLITE_INTEGER: {
- i64 iVal = sqlite3_value_int64(argv[0]);
- sqlite3_result_int64(context, iVal);
- break;
- }
- case SQLITE_NULL: {
- sqlite3_result_null(context);
- break;
- }
- default: {
- rVal = sqlite3_value_double(argv[0]);
- sqlite3_result_int64(context, (i64) floor(rVal));
- break;
- }
- }
-}
-
-/*
-** Given a string (s) in the first argument and an integer (n) in the second returns the
-** string that constains s contatenated n times
-*/
-static void replicateFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- unsigned char *z; /* input string */
- unsigned char *zo; /* result string */
- i64 iCount; /* times to repeat */
- i64 nLen; /* length of the input string (no multibyte considerations) */
- i64 nTLen; /* length of the result string (no multibyte considerations) */
- i64 i=0;
-
- if( argc!=2 || SQLITE_NULL==sqlite3_value_type(argv[0]) )
- return;
-
- iCount = sqlite3_value_int64(argv[1]);
-
- if( iCount<0 ){
- sqlite3_result_error(context, "domain error", -1);
- }else{
-
- nLen = sqlite3_value_bytes(argv[0]);
- nTLen = nLen*iCount;
- z=sqlite3_malloc(nTLen+1);
- zo=sqlite3_malloc(nLen+1);
- if (!z || !zo){
- sqlite3_result_error_nomem(context);
- if (z) sqlite3_free(z);
- if (zo) sqlite3_free(zo);
- return;
- }
- strcpy((char*)zo, (char*)sqlite3_value_text(argv[0]));
-
- for(i=0; i=n it's a NOP
-** padl(NULL) = NULL
-*/
-static void padlFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- i64 ilen; /* length to pad to */
- i64 zl; /* length of the input string (UTF-8 chars) */
- int i = 0;
- const char *zi; /* input string */
- char *zo; /* output string */
- char *zt;
-
- assert( argc==2 );
-
- if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){
- sqlite3_result_null(context);
- }else{
- zi = (char *)sqlite3_value_text(argv[0]);
- ilen = sqlite3_value_int64(argv[1]);
- /* check domain */
- if(ilen<0){
- sqlite3_result_error(context, "domain error", -1);
- return;
- }
- zl = sqlite3Utf8CharLen(zi, -1);
- if( zl>=ilen ){
- /* string is longer than the requested pad length, return the same string (dup it) */
- zo = sqlite3StrDup(zi);
- if (!zo){
- sqlite3_result_error_nomem(context);
- return;
- }
- sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT);
- }else{
- zo = sqlite3_malloc(strlen(zi)+ilen-zl+1);
- if (!zo){
- sqlite3_result_error_nomem(context);
- return;
- }
- zt = zo;
- for(i=1; i+zl<=ilen; ++i){
- *(zt++)=' ';
- }
- /* no need to take UTF-8 into consideration here */
- strcpy(zt,zi);
- }
- sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT);
- sqlite3_free(zo);
- }
-}
-
-/*
-** given an input string (s) and an integer (n) appends spaces at the end of s
-** until it has a length of n characters.
-** When s has a length >=n it's a NOP
-** padl(NULL) = NULL
-*/
-static void padrFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- i64 ilen; /* length to pad to */
- i64 zl; /* length of the input string (UTF-8 chars) */
- i64 zll; /* length of the input string (bytes) */
- int i = 0;
- const char *zi; /* input string */
- char *zo; /* output string */
- char *zt;
-
- assert( argc==2 );
-
- if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){
- sqlite3_result_null(context);
- }else{
- zi = (char *)sqlite3_value_text(argv[0]);
- ilen = sqlite3_value_int64(argv[1]);
- /* check domain */
- if(ilen<0){
- sqlite3_result_error(context, "domain error", -1);
- return;
- }
- zl = sqlite3Utf8CharLen(zi, -1);
- if( zl>=ilen ){
- /* string is longer than the requested pad length, return the same string (dup it) */
- zo = sqlite3StrDup(zi);
- if (!zo){
- sqlite3_result_error_nomem(context);
- return;
- }
- sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT);
- }else{
- zll = strlen(zi);
- zo = sqlite3_malloc(zll+ilen-zl+1);
- if (!zo){
- sqlite3_result_error_nomem(context);
- return;
- }
- zt = strcpy(zo,zi)+zll;
- for(i=1; i+zl<=ilen; ++i){
- *(zt++) = ' ';
- }
- *zt = '\0';
- }
- sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT);
- sqlite3_free(zo);
- }
-}
-
-/*
-** given an input string (s) and an integer (n) appends spaces at the end of s
-** and adds spaces at the beginning of s until it has a length of n characters.
-** Tries to add has many characters at the left as at the right.
-** When s has a length >=n it's a NOP
-** padl(NULL) = NULL
-*/
-static void padcFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- i64 ilen; /* length to pad to */
- i64 zl; /* length of the input string (UTF-8 chars) */
- i64 zll; /* length of the input string (bytes) */
- int i = 0;
- const char *zi; /* input string */
- char *zo; /* output string */
- char *zt;
-
- assert( argc==2 );
-
- if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){
- sqlite3_result_null(context);
- }else{
- zi = (char *)sqlite3_value_text(argv[0]);
- ilen = sqlite3_value_int64(argv[1]);
- /* check domain */
- if(ilen<0){
- sqlite3_result_error(context, "domain error", -1);
- return;
- }
- zl = sqlite3Utf8CharLen(zi, -1);
- if( zl>=ilen ){
- /* string is longer than the requested pad length, return the same string (dup it) */
- zo = sqlite3StrDup(zi);
- if (!zo){
- sqlite3_result_error_nomem(context);
- return;
- }
- sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT);
- }else{
- zll = strlen(zi);
- zo = sqlite3_malloc(zll+ilen-zl+1);
- if (!zo){
- sqlite3_result_error_nomem(context);
- return;
- }
- zt = zo;
- for(i=1; 2*i+zl<=ilen; ++i){
- *(zt++) = ' ';
- }
- strcpy(zt, zi);
- zt+=zll;
- for(; i+zl<=ilen; ++i){
- *(zt++) = ' ';
- }
- *zt = '\0';
- }
- sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT);
- sqlite3_free(zo);
- }
-}
-
-/*
-** given 2 string (s1,s2) returns the string s1 with the characters NOT in s2 removed
-** assumes strings are UTF-8 encoded
-*/
-static void strfilterFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- const char *zi1; /* first parameter string (searched string) */
- const char *zi2; /* second parameter string (vcontains valid characters) */
- const char *z1;
- const char *z21;
- const char *z22;
- char *zo; /* output string */
- char *zot;
- int c1 = 0;
- int c2 = 0;
-
- assert( argc==2 );
-
- if( sqlite3_value_type(argv[0]) == SQLITE_NULL || sqlite3_value_type(argv[1]) == SQLITE_NULL ){
- sqlite3_result_null(context);
- }else{
- zi1 = (char *)sqlite3_value_text(argv[0]);
- zi2 = (char *)sqlite3_value_text(argv[1]);
- /*
- ** maybe I could allocate less, but that would imply 2 passes, rather waste
- ** (possibly) some memory
- */
- zo = sqlite3_malloc(strlen(zi1)+1);
- if (!zo){
- sqlite3_result_error_nomem(context);
- return;
- }
- zot = zo;
- z1 = zi1;
- while( (c1=sqliteCharVal((unsigned char *)z1))!=0 ){
- z21=zi2;
- while( (c2=sqliteCharVal((unsigned char *)z21))!=0 && c2!=c1 ){
- sqliteNextChar(z21);
- }
- if( c2!=0){
- z22=z21;
- sqliteNextChar(z22);
- strncpy(zot, z21, z22-z21);
- zot+=z22-z21;
- }
- sqliteNextChar(z1);
- }
- *zot = '\0';
-
- sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT);
- sqlite3_free(zo);
- }
-}
-
-/*
-** Given a string z1, retutns the (0 based) index of it's first occurence
-** in z2 after the first s characters.
-** Returns -1 when there isn't a match.
-** updates p to point to the character where the match occured.
-** This is an auxiliary function.
-*/
-static int _substr(const char* z1, const char* z2, int s, const char** p){
- int c = 0;
- int rVal=-1;
- const char* zt1;
- const char* zt2;
- int c1,c2;
-
- if( '\0'==*z1 ){
- return -1;
- }
-
- while( (sqliteCharVal((unsigned char *)z2) != 0) && (c++)=0 ? rVal+s : rVal;
-}
-
-/*
-** given 2 input strings (s1,s2) and an integer (n) searches from the nth character
-** for the string s1. Returns the position where the match occured.
-** Characters are counted from 1.
-** 0 is returned when no match occurs.
-*/
-
-static void charindexFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- const u8 *z1; /* s1 string */
- u8 *z2; /* s2 string */
- int s=0;
- int rVal=0;
-
- assert( argc==3 ||argc==2);
-
- if( SQLITE_NULL==sqlite3_value_type(argv[0]) || SQLITE_NULL==sqlite3_value_type(argv[1])){
- sqlite3_result_null(context);
- return;
- }
-
- z1 = sqlite3_value_text(argv[0]);
- if( z1==0 ) return;
- z2 = (u8*) sqlite3_value_text(argv[1]);
- if(argc==3){
- s = sqlite3_value_int(argv[2])-1;
- if(s<0){
- s=0;
- }
- }else{
- s = 0;
- }
-
- rVal = _substr((char *)z1,(char *)z2,s,NULL);
- sqlite3_result_int(context, rVal+1);
-}
-
-/*
-** given a string (s) and an integer (n) returns the n leftmost (UTF-8) characters
-** if the string has a length<=n or is NULL this function is NOP
-*/
-static void leftFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- int c=0;
- int cc=0;
- int l=0;
- const unsigned char *z; /* input string */
- const unsigned char *zt;
- unsigned char *rz; /* output string */
-
- assert( argc==2);
-
- if( SQLITE_NULL==sqlite3_value_type(argv[0]) || SQLITE_NULL==sqlite3_value_type(argv[1])){
- sqlite3_result_null(context);
- return;
- }
-
- z = sqlite3_value_text(argv[0]);
- l = sqlite3_value_int(argv[1]);
- zt = z;
-
- while( sqliteCharVal(zt) && c++ 0 ){
- sqliteNextChar(zt);
- }
-
- rz = sqlite3_malloc(ze-zt+1);
- if (!rz){
- sqlite3_result_error_nomem(context);
- return;
- }
- strcpy((char*) rz, (char*) (zt));
- sqlite3_result_text(context, (char*)rz, -1, SQLITE_TRANSIENT);
- sqlite3_free(rz);
-}
-
-#ifndef HAVE_TRIM
-/*
-** removes the whitespaces at the beginning of a string.
-*/
-const char* ltrim(const char* s){
- while( *s==' ' )
- ++s;
- return s;
-}
-
-/*
-** removes the whitespaces at the end of a string.
-** !mutates the input string!
-*/
-void rtrim(char* s){
- char* ss = s+strlen(s)-1;
- while( ss>=s && *ss==' ' )
- --ss;
- *(ss+1)='\0';
-}
-
-/*
-** Removes the whitespace at the beginning of a string
-*/
-static void ltrimFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- const char *z;
-
- assert( argc==1);
-
- if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){
- sqlite3_result_null(context);
- return;
- }
- z = sqlite3_value_text(argv[0]);
- sqlite3_result_text(context, ltrim(z), -1, SQLITE_TRANSIENT);
-}
-
-/*
-** Removes the whitespace at the end of a string
-*/
-static void rtrimFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- const char *z;
- char *rz;
- /* try not to change data in argv */
-
- assert( argc==1);
-
- if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){
- sqlite3_result_null(context);
- return;
- }
- z = sqlite3_value_text(argv[0]);
- rz = sqlite3StrDup(z);
- rtrim(rz);
- sqlite3_result_text(context, rz, -1, SQLITE_TRANSIENT);
- sqlite3_free(rz);
-}
-
-/*
-** Removes the whitespace at the beginning and end of a string
-*/
-static void trimFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- const char *z;
- char *rz;
- /* try not to change data in argv */
-
- assert( argc==1);
-
- if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){
- sqlite3_result_null(context);
- return;
- }
- z = sqlite3_value_text(argv[0]);
- rz = sqlite3StrDup(z);
- rtrim(rz);
- sqlite3_result_text(context, ltrim(rz), -1, SQLITE_TRANSIENT);
- sqlite3_free(rz);
-}
-#endif
-
-/*
-** given a pointer to a string s1, the length of that string (l1), a new string (s2)
-** and it's length (l2) appends s2 to s1.
-** All lengths in bytes.
-** This is just an auxiliary function
-*/
-// static void _append(char **s1, int l1, const char *s2, int l2){
-// *s1 = realloc(*s1, (l1+l2+1)*sizeof(char));
-// strncpy((*s1)+l1, s2, l2);
-// *(*(s1)+l1+l2) = '\0';
-// }
-
-#ifndef HAVE_TRIM
-
-/*
-** given strings s, s1 and s2 replaces occurrences of s1 in s by s2
-*/
-static void replaceFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- const char *z1; /* string s (first parameter) */
- const char *z2; /* string s1 (second parameter) string to look for */
- const char *z3; /* string s2 (third parameter) string to replace occurrences of s1 with */
- int lz1;
- int lz2;
- int lz3;
- int lzo=0;
- char *zo=0;
- int ret=0;
- const char *zt1;
- const char *zt2;
-
- assert( 3==argc );
-
- if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){
- sqlite3_result_null(context);
- return;
- }
-
- z1 = sqlite3_value_text(argv[0]);
- z2 = sqlite3_value_text(argv[1]);
- z3 = sqlite3_value_text(argv[2]);
- /* handle possible null values */
- if( 0==z2 ){
- z2="";
- }
- if( 0==z3 ){
- z3="";
- }
-
- lz1 = strlen(z1);
- lz2 = strlen(z2);
- lz3 = strlen(z3);
-
-#if 0
- /* special case when z2 is empty (or null) nothing will be changed */
- if( 0==lz2 ){
- sqlite3_result_text(context, z1, -1, SQLITE_TRANSIENT);
- return;
- }
-#endif
-
- zt1=z1;
- zt2=z1;
-
- while(1){
- ret=_substr(z2,zt1 , 0, &zt2);
-
- if( ret<0 )
- break;
-
- _append(&zo, lzo, zt1, zt2-zt1);
- lzo+=zt2-zt1;
- _append(&zo, lzo, z3, lz3);
- lzo+=lz3;
-
- zt1=zt2+lz2;
- }
- _append(&zo, lzo, zt1, lz1-(zt1-z1));
- sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT);
- sqlite3_free(zo);
-}
-#endif
-
-/*
-** given a string returns the same string but with the characters in reverse order
-*/
-static void reverseFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- const char *z;
- const char *zt;
- char *rz;
- char *rzt;
- int l = 0;
- int i = 0;
-
- assert( 1==argc );
-
- if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){
- sqlite3_result_null(context);
- return;
- }
- z = (char *)sqlite3_value_text(argv[0]);
- l = strlen(z);
- rz = sqlite3_malloc(l+1);
- if (!rz){
- sqlite3_result_error_nomem(context);
- return;
- }
- rzt = rz+l;
- *(rzt--) = '\0';
-
- zt=z;
- while( sqliteCharVal((unsigned char *)zt)!=0 ){
- z=zt;
- sqliteNextChar(zt);
- for(i=1; zt-i>=z; ++i){
- *(rzt--)=*(zt-i);
- }
- }
-
- sqlite3_result_text(context, rz, -1, SQLITE_TRANSIENT);
- sqlite3_free(rz);
-}
-
-/*
-** An instance of the following structure holds the context of a
-** stdev() or variance() aggregate computation.
-** implementaion of http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Algorithm_II
-** less prone to rounding errors
-*/
-typedef struct StdevCtx StdevCtx;
-struct StdevCtx {
- double rM;
- double rS;
- i64 cnt; /* number of elements */
-};
-
-/*
-** An instance of the following structure holds the context of a
-** mode() or median() aggregate computation.
-** Depends on structures defined in map.c (see map & map)
-** These aggregate functions only work for integers and floats although
-** they could be made to work for strings. This is usually considered meaningless.
-** Only usuall order (for median), no use of collation functions (would this even make sense?)
-*/
-typedef struct ModeCtx ModeCtx;
-struct ModeCtx {
- i64 riM; /* integer value found so far */
- double rdM; /* double value found so far */
- i64 cnt; /* number of elements so far */
- double pcnt; /* number of elements smaller than a percentile */
- i64 mcnt; /* maximum number of occurrences (for mode) */
- i64 mn; /* number of occurrences (for mode and percentiles) */
- i64 is_double; /* whether the computation is being done for doubles (>0) or integers (=0) */
- map* m; /* map structure used for the computation */
- int done; /* whether the answer has been found */
-};
-
-/*
-** called for each value received during a calculation of stdev or variance
-*/
-static void varianceStep(sqlite3_context *context, int argc, sqlite3_value **argv){
- StdevCtx *p;
-
- double delta;
- double x;
-
- assert( argc==1 );
- p = sqlite3_aggregate_context(context, sizeof(*p));
- /* only consider non-null values */
- if( SQLITE_NULL != sqlite3_value_numeric_type(argv[0]) ){
- p->cnt++;
- x = sqlite3_value_double(argv[0]);
- delta = (x-p->rM);
- p->rM += delta/p->cnt;
- p->rS += delta*(x-p->rM);
- }
-}
-
-/*
-** called for each value received during a calculation of mode of median
-*/
-static void modeStep(sqlite3_context *context, int argc, sqlite3_value **argv){
- ModeCtx *p;
- i64 xi=0;
- double xd=0.0;
- i64 *iptr;
- double *dptr;
- int type;
-
- assert( argc==1 );
- type = sqlite3_value_numeric_type(argv[0]);
-
- if( type == SQLITE_NULL)
- return;
-
- p = sqlite3_aggregate_context(context, sizeof(*p));
-
- if( 0==(p->m) ){
- p->m = calloc(1, sizeof(map));
- if( type==SQLITE_INTEGER ){
- /* map will be used for integers */
- *(p->m) = map_make(int_cmp);
- p->is_double = 0;
- }else{
- p->is_double = 1;
- /* map will be used for doubles */
- *(p->m) = map_make(double_cmp);
- }
- }
-
- ++(p->cnt);
-
- if( 0==p->is_double ){
- xi = sqlite3_value_int64(argv[0]);
- iptr = (i64*)calloc(1,sizeof(i64));
- *iptr = xi;
- map_insert(p->m, iptr);
- }else{
- xd = sqlite3_value_double(argv[0]);
- dptr = (double*)calloc(1,sizeof(double));
- *dptr = xd;
- map_insert(p->m, dptr);
- }
-}
-
-/*
-** Auxiliary function that iterates all elements in a map and finds the mode
-** (most frequent value)
-*/
-static void modeIterate(void* e, i64 c, void* pp){
- i64 ei;
- double ed;
- ModeCtx *p = (ModeCtx*)pp;
-
- if( 0==p->is_double ){
- ei = *(int*)(e);
-
- if( p->mcnt==c ){
- ++p->mn;
- }else if( p->mcntriM = ei;
- p->mcnt = c;
- p->mn=1;
- }
- }else{
- ed = *(double*)(e);
-
- if( p->mcnt==c ){
- ++p->mn;
- }else if(p->mcntrdM = ed;
- p->mcnt = c;
- p->mn=1;
- }
- }
-}
-
-/*
-** Auxiliary function that iterates all elements in a map and finds the median
-** (the value such that the number of elements smaller is equal the the number of
-** elements larger)
-*/
-static void medianIterate(void* e, i64 c, void* pp){
- i64 ei;
- double ed;
- double iL;
- double iR;
- int il;
- int ir;
- ModeCtx *p = (ModeCtx*)pp;
-
- if(p->done>0)
- return;
-
- iL = p->pcnt;
- iR = p->cnt - p->pcnt;
- il = p->mcnt + c;
- ir = p->cnt - p->mcnt;
-
- if( il >= iL ){
- if( ir >= iR ){
- ++p->mn;
- if( 0==p->is_double ){
- ei = *(int*)(e);
- p->riM += ei;
- }else{
- ed = *(double*)(e);
- p->rdM += ed;
- }
- }else{
- p->done=1;
- }
- }
- p->mcnt+=c;
-}
-
-/*
-** Returns the mode value
-*/
-static void modeFinalize(sqlite3_context *context){
- ModeCtx *p;
- p = sqlite3_aggregate_context(context, 0);
- if( p && p->m ){
- map_iterate(p->m, modeIterate, p);
- map_destroy(p->m);
- free(p->m);
-
- if( 1==p->mn ){
- if( 0==p->is_double )
- sqlite3_result_int64(context, p->riM);
- else
- sqlite3_result_double(context, p->rdM);
- }
- }
-}
-
-/*
-** auxiliary function for percentiles
-*/
-static void _medianFinalize(sqlite3_context *context){
- ModeCtx *p;
- p = (ModeCtx*) sqlite3_aggregate_context(context, 0);
- if( p && p->m ){
- p->done=0;
- map_iterate(p->m, medianIterate, p);
- map_destroy(p->m);
- free(p->m);
-
- if( 0==p->is_double )
- if( 1==p->mn )
- sqlite3_result_int64(context, p->riM);
- else
- sqlite3_result_double(context, p->riM*1.0/p->mn);
- else
- sqlite3_result_double(context, p->rdM/p->mn);
- }
-}
-
-/*
-** Returns the median value
-*/
-static void medianFinalize(sqlite3_context *context){
- ModeCtx *p;
- p = (ModeCtx*) sqlite3_aggregate_context(context, 0);
- if( p!=0 ){
- p->pcnt = (p->cnt)/2.0;
- _medianFinalize(context);
- }
-}
-
-/*
-** Returns the lower_quartile value
-*/
-static void lower_quartileFinalize(sqlite3_context *context){
- ModeCtx *p;
- p = (ModeCtx*) sqlite3_aggregate_context(context, 0);
- if( p!=0 ){
- p->pcnt = (p->cnt)/4.0;
- _medianFinalize(context);
- }
-}
-
-/*
-** Returns the upper_quartile value
-*/
-static void upper_quartileFinalize(sqlite3_context *context){
- ModeCtx *p;
- p = (ModeCtx*) sqlite3_aggregate_context(context, 0);
- if( p!=0 ){
- p->pcnt = (p->cnt)*3/4.0;
- _medianFinalize(context);
- }
-}
-
-/*
-** Returns the stdev value
-*/
-static void stdevFinalize(sqlite3_context *context){
- StdevCtx *p;
- p = sqlite3_aggregate_context(context, 0);
- if( p && p->cnt>1 ){
- sqlite3_result_double(context, sqrt(p->rS/(p->cnt-1)));
- }else{
- sqlite3_result_double(context, 0.0);
- }
-}
-
-/*
-** Returns the variance value
-*/
-static void varianceFinalize(sqlite3_context *context){
- StdevCtx *p;
- p = sqlite3_aggregate_context(context, 0);
- if( p && p->cnt>1 ){
- sqlite3_result_double(context, p->rS/(p->cnt-1));
- }else{
- sqlite3_result_double(context, 0.0);
- }
-}
-
-#ifdef SQLITE_SOUNDEX
-
-/* relicoder factored code */
-/*
-** Calculates the soundex value of a string
-*/
-
-static void soundex(const u8 *zIn, char *zResult){
- int i, j;
- static const unsigned char iCode[] = {
- 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, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,
- 1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,
- 0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,
- 1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,
- };
-
- for(i=0; zIn[i] && !isalpha(zIn[i]); i++){}
- if( zIn[i] ){
- zResult[0] = toupper(zIn[i]);
- for(j=1; j<4 && zIn[i]; i++){
- int code = iCode[zIn[i]&0x7f];
- if( code>0 ){
- zResult[j++] = code + '0';
- }
- }
- while( j<4 ){
- zResult[j++] = '0';
- }
- zResult[j] = 0;
- }else{
- strcpy(zResult, "?000");
- }
-}
-
-/*
-** computes the number of different characters between the soundex value fo 2 strings
-*/
-static void differenceFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- char zResult1[8];
- char zResult2[8];
- char *zR1 = zResult1;
- char *zR2 = zResult2;
- int rVal = 0;
- int i = 0;
- const u8 *zIn1;
- const u8 *zIn2;
-
- assert( argc==2 );
-
- if( sqlite3_value_type(argv[0])==SQLITE_NULL || sqlite3_value_type(argv[1])==SQLITE_NULL ){
- sqlite3_result_null(context);
- return;
- }
-
- zIn1 = (u8*)sqlite3_value_text(argv[0]);
- zIn2 = (u8*)sqlite3_value_text(argv[1]);
-
- soundex(zIn1, zR1);
- soundex(zIn2, zR2);
-
- for(i=0; i<4; ++i){
- if( sqliteCharVal((unsigned char *)zR1)==sqliteCharVal((unsigned char *)zR2) )
- ++rVal;
- sqliteNextChar(zR1);
- sqliteNextChar(zR2);
- }
- sqlite3_result_int(context, rVal);
-}
-#endif
-
-/*
-** This function registered all of the above C functions as SQL
-** functions. This should be the only routine in this file with
-** external linkage.
-*/
-int RegisterExtensionFunctions(sqlite3 *db){
- static const struct FuncDef {
- char *zName;
- signed char nArg;
- u8 argType; /* 0: none. 1: db 2: (-1) */
- u8 eTextRep; /* 1: UTF-16. 0: UTF-8 */
- u8 needCollSeq;
- void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
- } aFuncs[] = {
- /* math.h */
- { "acos", 1, 0, SQLITE_UTF8, 0, acosFunc },
- { "asin", 1, 0, SQLITE_UTF8, 0, asinFunc },
- { "atan", 1, 0, SQLITE_UTF8, 0, atanFunc },
- { "atn2", 2, 0, SQLITE_UTF8, 0, atn2Func },
- /* XXX alias */
- { "atan2", 2, 0, SQLITE_UTF8, 0, atn2Func },
- { "acosh", 1, 0, SQLITE_UTF8, 0, acoshFunc },
- { "asinh", 1, 0, SQLITE_UTF8, 0, asinhFunc },
- { "atanh", 1, 0, SQLITE_UTF8, 0, atanhFunc },
-
- { "difference", 2, 0, SQLITE_UTF8, 0, differenceFunc},
- { "degrees", 1, 0, SQLITE_UTF8, 0, rad2degFunc },
- { "radians", 1, 0, SQLITE_UTF8, 0, deg2radFunc },
-
- { "cos", 1, 0, SQLITE_UTF8, 0, cosFunc },
- { "sin", 1, 0, SQLITE_UTF8, 0, sinFunc },
- { "tan", 1, 0, SQLITE_UTF8, 0, tanFunc },
- { "cot", 1, 0, SQLITE_UTF8, 0, cotFunc },
- { "cosh", 1, 0, SQLITE_UTF8, 0, coshFunc },
- { "sinh", 1, 0, SQLITE_UTF8, 0, sinhFunc },
- { "tanh", 1, 0, SQLITE_UTF8, 0, tanhFunc },
- { "coth", 1, 0, SQLITE_UTF8, 0, cothFunc },
-
- { "exp", 1, 0, SQLITE_UTF8, 0, expFunc },
- { "log", 1, 0, SQLITE_UTF8, 0, logFunc },
- { "log10", 1, 0, SQLITE_UTF8, 0, log10Func },
- { "power", 2, 0, SQLITE_UTF8, 0, powerFunc },
- { "sign", 1, 0, SQLITE_UTF8, 0, signFunc },
- { "sqrt", 1, 0, SQLITE_UTF8, 0, sqrtFunc },
- { "square", 1, 0, SQLITE_UTF8, 0, squareFunc },
-
- { "ceil", 1, 0, SQLITE_UTF8, 0, ceilFunc },
- { "floor", 1, 0, SQLITE_UTF8, 0, floorFunc },
-
- { "pi", 0, 0, SQLITE_UTF8, 1, piFunc },
-
-
- /* string */
- { "replicate", 2, 0, SQLITE_UTF8, 0, replicateFunc },
- { "charindex", 2, 0, SQLITE_UTF8, 0, charindexFunc },
- { "charindex", 3, 0, SQLITE_UTF8, 0, charindexFunc },
- { "leftstr", 2, 0, SQLITE_UTF8, 0, leftFunc },
- { "rightstr", 2, 0, SQLITE_UTF8, 0, rightFunc },
-#ifndef HAVE_TRIM
- { "ltrim", 1, 0, SQLITE_UTF8, 0, ltrimFunc },
- { "rtrim", 1, 0, SQLITE_UTF8, 0, rtrimFunc },
- { "trim", 1, 0, SQLITE_UTF8, 0, trimFunc },
- { "replace", 3, 0, SQLITE_UTF8, 0, replaceFunc },
-#endif
- { "reverse", 1, 0, SQLITE_UTF8, 0, reverseFunc },
- { "proper", 1, 0, SQLITE_UTF8, 0, properFunc },
- { "padl", 2, 0, SQLITE_UTF8, 0, padlFunc },
- { "padr", 2, 0, SQLITE_UTF8, 0, padrFunc },
- { "padc", 2, 0, SQLITE_UTF8, 0, padcFunc },
- { "strfilter", 2, 0, SQLITE_UTF8, 0, strfilterFunc },
-
- };
- /* Aggregate functions */
- static const struct FuncDefAgg {
- char *zName;
- signed char nArg;
- u8 argType;
- u8 needCollSeq;
- void (*xStep)(sqlite3_context*,int,sqlite3_value**);
- void (*xFinalize)(sqlite3_context*);
- } aAggs[] = {
- { "stdev", 1, 0, 0, varianceStep, stdevFinalize },
- { "variance", 1, 0, 0, varianceStep, varianceFinalize },
- { "mode", 1, 0, 0, modeStep, modeFinalize },
- { "median", 1, 0, 0, modeStep, medianFinalize },
- { "lower_quartile", 1, 0, 0, modeStep, lower_quartileFinalize },
- { "upper_quartile", 1, 0, 0, modeStep, upper_quartileFinalize },
- };
- int i;
-
- for(i=0; ineedCollSeq = 1;
- }
- }
-#endif
- }
-
- for(i=0; ineedCollSeq = 1;
- }
- }
-#endif
- }
- return 0;
-}
-
-#ifdef COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE
-int sqlite3_extension_init(
- sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi){
- SQLITE_EXTENSION_INIT2(pApi);
- RegisterExtensionFunctions(db);
- return 0;
-}
-#endif /* COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE */
-
-map map_make(cmp_func cmp){
- map r;
- r.cmp=cmp;
- r.base = 0;
-
- return r;
-}
-
-void* xcalloc(size_t nmemb, size_t size, char* s){
- void* ret = calloc(nmemb, size);
- return ret;
-}
-
-void xfree(void* p){
- free(p);
-}
-
-void node_insert(node** n, cmp_func cmp, void *e){
- int c;
- node* nn;
- if(*n==0){
- nn = (node*)xcalloc(1,sizeof(node), "for node");
- nn->data = e;
- nn->count = 1;
- *n=nn;
- }else{
- c=cmp((*n)->data,e);
- if(0==c){
- ++((*n)->count);
- xfree(e);
- }else if(c>0){
- /* put it right here */
- node_insert(&((*n)->l), cmp, e);
- }else{
- node_insert(&((*n)->r), cmp, e);
- }
- }
-}
-
-void map_insert(map *m, void *e){
- node_insert(&(m->base), m->cmp, e);
-}
-
-void node_iterate(node *n, map_iterator iter, void* p){
- if(n){
- if(n->l)
- node_iterate(n->l, iter, p);
- iter(n->data, n->count, p);
- if(n->r)
- node_iterate(n->r, iter, p);
- }
-}
-
-void map_iterate(map *m, map_iterator iter, void* p){
- node_iterate(m->base, iter, p);
-}
-
-void node_destroy(node *n){
- if(0!=n){
- xfree(n->data);
- if(n->l)
- node_destroy(n->l);
- if(n->r)
- node_destroy(n->r);
-
- xfree(n);
- }
-}
-
-void map_destroy(map *m){
- node_destroy(m->base);
-}
-
-int int_cmp(const void *a, const void *b){
- int64_t aa = *(int64_t *)(a);
- int64_t bb = *(int64_t *)(b);
- /* printf("cmp %d <=> %d\n",aa,bb); */
- if(aa==bb)
- return 0;
- else if(aa %d\n",aa,bb); */
- if(aa==bb)
- return 0;
- else if(aa %lld\n", ee,c);
-}
-
diff --git a/src/extensions/extension-functions.def b/src/extensions/extension-functions.def
deleted file mode 100644
index df979a4..0000000
--- a/src/extensions/extension-functions.def
+++ /dev/null
@@ -1,16 +0,0 @@
-EXPORTS
- RegisterExtensionFunctions
- double_cmp
- int_cmp
- map_destroy
- map_insert
- map_iterate
- map_make
- node_destroy
- node_insert
- node_iterate
- print_elem
- sqlite3_api
- sqlite3_extension_init
- xcalloc
- xfree