File pngcheck-remove-auxiliary-tools.patch of Package pngcheck
diff --git a/CHANGELOG b/CHANGELOG
index b20a881..6d6bfb8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -281,4 +281,5 @@
* 20250304 CT: Added a CMake file and an installation instructions file
* 20250304 CL: released version 4.0.0
* ----------------------
-
+ * 20250305 CT: Removed gpl/pngsplit and gpl/png-fix-IDAT-windowsize from this
+ project; we're moving them to a new home
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 41f2a98..919c65b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,25 +10,11 @@ project(pngcheck
option(PNGCHECK_USE_ZLIB "Enable zlib support" ON)
option(PNGCHECK_USE_SYSTEM_ZLIB "Use the system-installed zlib" ON)
-# Options for supplemental builds
-option(PNGCHECK_ENABLE_AUX_TOOLS "Build and install the auxiliary tools" OFF)
-if(PNGCHECK_ENABLE_AUX_TOOLS AND NOT PNGCHECK_USE_ZLIB)
- message(FATAL_ERROR "The auxiliary tools require zlib support")
-endif()
-
# Source files
set(PNGCHECK_SOURCES pngcheck.c)
-if(PNGCHECK_ENABLE_AUX_TOOLS)
- set(PNGSPLIT_SOURCES gpl/pngsplit.c)
- set(PNG_FIX_IDAT_WINDOWSIZE_SOURCES gpl/png-fix-IDAT-windowsize.c)
-endif()
# Executables
add_executable(pngcheck ${PNGCHECK_SOURCES})
-if(PNGCHECK_ENABLE_AUX_TOOLS)
- add_executable(pngsplit ${PNGSPLIT_SOURCES})
- add_executable(png-fix-IDAT-windowsize ${PNG_FIX_IDAT_WINDOWSIZE_SOURCES})
-endif()
# Dependency handling
if(PNGCHECK_USE_ZLIB)
@@ -36,10 +22,6 @@ if(PNGCHECK_USE_ZLIB)
find_package(ZLIB)
if(ZLIB_FOUND)
target_link_libraries(pngcheck PRIVATE ZLIB::ZLIB)
- if(PNGCHECK_ENABLE_AUX_TOOLS)
- target_link_libraries(pngsplit PRIVATE ZLIB::ZLIB)
- target_link_libraries(png-fix-IDAT-windowsize PRIVATE ZLIB::ZLIB)
- endif()
else()
message(WARNING "System zlib not found, falling back to FetchContent")
set(PNGCHECK_USE_SYSTEM_ZLIB OFF)
@@ -53,10 +35,6 @@ if(PNGCHECK_USE_ZLIB)
)
FetchContent_MakeAvailable(zlib)
target_link_libraries(pngcheck PRIVATE zlibstatic)
- if(PNGCHECK_ENABLE_AUX_TOOLS)
- target_link_libraries(pngsplit PRIVATE zlibstatic)
- target_link_libraries(png-fix-IDAT-windowsize PRIVATE zlibstatic)
- endif()
endif()
target_compile_definitions(pngcheck PRIVATE USE_ZLIB)
endif()
@@ -72,17 +50,6 @@ install(FILES pngcheck.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
COMPONENT Documentation
)
-if(PNGCHECK_ENABLE_AUX_TOOLS)
- install(TARGETS pngsplit png-fix-IDAT-windowsize
- RUNTIME
- DESTINATION ${CMAKE_INSTALL_BINDIR}
- COMPONENT Runtime
- )
- install(FILES gpl/pngsplit.1 gpl/png-fix-IDAT-windowsize.1
- DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
- COMPONENT Documentation
- )
-endif()
# Package generation
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
diff --git a/LICENSE b/LICENSE
index 5d5dc62..328c4bd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -14,10 +14,7 @@
[This license applies to pngcheck.c and its associated makefiles and
- documentation in the main directory. The files in the "gpl" subdirectory--
- specifically, pngsplit.c and png-fix-IDAT-windowsize.c--are licensed under the
- GNU General Public License. The files in "amiga" subdirectory are Copyright
- 2003 Simon Goodwin and were contributed without an explicit license statement,
- but insofar as the "gpl" subdirectory didn't exist at the time, it's safe to
- assume their intended license was similar to pngcheck's, just with Simon's
- copyright replacing the one above.]
+ documentation in the main directory. The files in "amiga" subdirectory are
+ Copyright 2003 Simon Goodwin and were contributed without an explicit license
+ statement, but we assume assume that their intended license was the same as
+ pngcheck's, just with Simon's copyright replacing the one above.]
diff --git a/Makefile.mingw32 b/Makefile.mingw32
index 4a2bd53..9d42c17 100644
--- a/Makefile.mingw32
+++ b/Makefile.mingw32
@@ -40,10 +40,7 @@ O = .o
E = .win32.exe
PROG = pngcheck
-PROG2 = pngsplit
-PROG3 = png-fix-IDAT-windowsize
-
-EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E)
+EXES = $(PROG)$(E)
# implicit make rules -------------------------------------------------------
@@ -59,13 +56,6 @@ all: $(EXES)
$(PROG)$(E): $(PROG).c
$(CC) $(CFLAGS) -o $@ $(PROG).c $(LIBS)
-# both of these require zlib, too (for crc32() function)
-$(PROG2)$(E): gpl/$(PROG2).c
- $(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LIBS)
-
-$(PROG3)$(E): gpl/$(PROG3).c
- $(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LIBS)
-
# maintenance ---------------------------------------------------------------
diff --git a/Makefile.mingw64 b/Makefile.mingw64
index 3760ef4..ed417c2 100644
--- a/Makefile.mingw64
+++ b/Makefile.mingw64
@@ -40,10 +40,8 @@ O = .o
E = .win64.exe
PROG = pngcheck
-PROG2 = pngsplit
-PROG3 = png-fix-IDAT-windowsize
-EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E)
+EXES = $(PROG)$(E)
# implicit make rules -------------------------------------------------------
@@ -59,13 +57,6 @@ all: $(EXES)
$(PROG)$(E): $(PROG).c
$(CC) $(CFLAGS) -o $@ $(PROG).c $(LIBS)
-# both of these require zlib, too (for crc32() function)
-$(PROG2)$(E): gpl/$(PROG2).c
- $(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LIBS)
-
-$(PROG3)$(E): gpl/$(PROG3).c
- $(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LIBS)
-
# maintenance ---------------------------------------------------------------
diff --git a/Makefile.unx b/Makefile.unx
index 8705831..5197809 100644
--- a/Makefile.unx
+++ b/Makefile.unx
@@ -41,13 +41,11 @@ E =
LDFLAGS =
PROG = pngcheck
-PROG2 = pngsplit
-PROG3 = png-fix-IDAT-windowsize
#OBJS = $(PROG)$(O)
OBJS =
-EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E)
+EXES = $(PROG)$(E)
# implicit make rules -------------------------------------------------------
@@ -63,12 +61,6 @@ all: $(EXES)
$(PROG)$(E): $(PROG).c
$(CC) $(CFLAGS) -o $@ $(PROG).c $(LIBS)
-$(PROG2)$(E): gpl/$(PROG2).c
- $(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LIBS)
-
-$(PROG3)$(E): gpl/$(PROG3).c
- $(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LIBS)
-
# maintenance ---------------------------------------------------------------
diff --git a/Makefile.w32 b/Makefile.w32
index 31b765e..8021edd 100644
--- a/Makefile.w32
+++ b/Makefile.w32
@@ -47,21 +47,14 @@ E = .exe
LDFLAGS = -nologo
PROG = pngcheck
-PROG2 = pngsplit
-PROG3 = png-fix-IDAT-windowsize
OBJS = $(PROG)$(O)
-OBJS2 = $(PROG2)$(O)
-OBJS3 = $(PROG3)$(O)
-EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E)
+EXES = $(PROG)$(E)
# implicit make rules -------------------------------------------------------
-# GRR 20060617: Can't remember if this dumps objects in current dir or in
-# same dir as source. If latter, will need to modify PROG2/PROG3 targets
-# below (and/or OBJS* macros above) to include "gpl/" prefix on objects.
.c$(O):
$(CC) -c $(CFLAGS) $<
@@ -75,16 +68,6 @@ all: $(EXES)
$(PROG)$(E): $(OBJS)
$(LD) $(LDFLAGS) -out:$@ $(OBJS) setargv.obj $(LIBS)
-$(PROG2)$(E): $(OBJS2)
- $(CC) $(CFLAGS) -out:$@ $(OBJS2) setargv.obj $(LIBS)
-
-$(PROG3)$(E): $(OBJS3)
- $(CC) $(CFLAGS) -out:$@ $(OBJS3) setargv.obj $(LIBS)
-
-$(PROG)$(O): gpl/$(PROG).c
-$(PROG2)$(O): gpl/$(PROG2).c
-$(PROG3)$(O): gpl/$(PROG3).c
-
# maintenance ---------------------------------------------------------------
@@ -94,7 +77,3 @@ clean:
# ...but the Windows "DEL" command is none too bright, so:
$(RM) $(PROG)$(E)
$(RM) $(PROG)$(O)
- $(RM) $(PROG2)$(E)
- $(RM) $(PROG2)$(O)
- $(RM) $(PROG3)$(E)
- $(RM) $(PROG3)$(O)
diff --git a/gpl/COPYING b/gpl/COPYING
deleted file mode 100644
index d159169..0000000
--- a/gpl/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
diff --git a/gpl/png-fix-IDAT-windowsize.1 b/gpl/png-fix-IDAT-windowsize.1
deleted file mode 100644
index 1f04db5..0000000
--- a/gpl/png-fix-IDAT-windowsize.1
+++ /dev/null
@@ -1,27 +0,0 @@
-.TH PNG-FIX-IDAT-WINDOWSIZE "1" "October 2020" "png-fix-IDAT-windowsize 1.0" "User Commands"
-.SH NAME
-png-fix-IDAT-windowsize \- manual page for png-fix-IDAT-windowsize 1.0
-.SH SYNOPSIS
-.B png\-fix\-IDAT\-windowsize
-.RI [ options ]
-.I pngfile
-.RI [ pngfile \ ...]
-.SH DESCRIPTION
-png\-fix\-IDAT\-windowsize, version 1.0 of 31 October 2020, by Greg Roelofs.
-.PP
-Uses explicit, hardcoded compression settings and line filters, writing
-result to output file with extension "\-fixed.png".
-.PP
-This software is licensed under the GNU General Public License.
-There is NO warranty.
-.SH OPTIONS
-.TP
-.B \-force
-overwrite existing output files
-.TP
-.B \-verbose
-print more status messages (synonym:
-.BR \-noquiet )
-.SH "SEE ALSO"
-.BR pngcheck (1),
-.BR pngsplit (1)
diff --git a/gpl/png-fix-IDAT-windowsize.c b/gpl/png-fix-IDAT-windowsize.c
deleted file mode 100644
index 6543d20..0000000
--- a/gpl/png-fix-IDAT-windowsize.c
+++ /dev/null
@@ -1,642 +0,0 @@
-/* png-fix-IDAT-windowsize.c - simple utility to reset first IDAT's zlib
-** window-size bytes and fix up CRC to match
-**
-** Downloads:
-**
-** http://gregroelofs.com/greg_software.html
-**
-** To compile:
-**
-** gcc -Wall -O2 -I/path-to-zlib png-fix-IDAT-windowsize.c \
- -o png-fix-IDAT-windowsize -L/path-to-zlib -lz
-**
-**
-** Copyright 2005-2020 Greg Roelofs
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#define VERSION "1.0 of 31 October 2020"
-
-/*
- * TO DO:
- * - output dir (required) instead of "-fixed.png" name (=> strip existing
- * path components)
- * - same timestamp
- * - summary of how many done (and maybe also "fixing ..." msg)
- * - own crc32() function => no zlib dependency
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#include <zlib.h> // for crc32() only
-
-typedef unsigned long ulg;
-typedef unsigned short ush;
-typedef unsigned char uch;
-
-#define PNG_FIX_IDAT_WINDOWSIZE_USAGE "\
- usage: png-fix-IDAT-windowsize [options] pngfile [pngfile ...]\n\
- options:\n\
- -force overwrite existing output files\n\
- -verbose print more status messages (synonym: -noquiet)\n\n\
- Uses explicit, hardcoded compression settings and line filters, writing\n\
- result to output file with extension \"-fixed.png\".\n"
-
-#ifndef TRUE
-# define TRUE 1
-#endif
-#ifndef FALSE
-# define FALSE 0
-#endif
-
-#define FNMAX 1024 /* max filename length */
-#define BUFSZ 4096
-
-#define MIN_PNG_SIZE (8 + 4+4+13+4 + 4+4+10+4 + 4+4+4) // 67 (IDAT = 10: empir.)
-
-#define U16(x) ( ((ush)(((uch *)(x))[0]) << 8) | \
- ((ush)(((uch *)(x))[1]) ) )
-
-#define U32(x) ( ((ulg)(((uch *)(x))[0]) << 24) | \
- ((ulg)(((uch *)(x))[1]) << 16) | \
- ((ulg)(((uch *)(x))[2]) << 8) | \
- ((ulg)(((uch *)(x))[3]) ) )
-
-uch pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
-ulg IHDR = ( (73L << 24) | (72L << 16) | (68L << 8) | (82L) ); // 0x49484452
-ulg IDAT = ( (73L << 24) | (68L << 16) | (65L << 8) | (84L) ); // 0x49444154
-
-
-static int png_fix_IDAT_windowsize (char *filename, int force, int verbose);
-static char *chunkstr (ulg typ);
-
-
-
-int main(int argc, char *argv[])
-{
- char *filename;
- int argn;
- int force = FALSE;
- int verbose = 0;
- int latest_error=0, error_count=0, file_count=0;
-
-
-#ifdef __EMX__
- _wildcard(&argc, &argv); /* Unix-like globbing for OS/2 and DOS */
-#endif
-
-#ifdef GRR_MALLOC_DEBUG
- mtrace();
-#endif
-
- argn = 1;
-
- while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) {
- if ( 0 == strncmp( argv[argn], "-force", 2 ) )
- force = TRUE;
- else if ( 0 == strncmp( argv[argn], "-noforce", 4 ) )
- force = FALSE;
- else if ( 0 == strncmp( argv[argn], "-verbose", 2 ) ||
- 0 == strncmp( argv[argn], "-noquiet", 4 ) )
- ++verbose;
- else if ( 0 == strncmp( argv[argn], "-noverbose", 4 ) ||
- 0 == strncmp( argv[argn], "-quiet", 2 ) )
- verbose = 0;
- else {
- fprintf(stderr, "png-fix-IDAT-windowsize, version %s, by Greg Roelofs.\n",
- VERSION);
- fprintf(stderr, " This software is licensed under the GNU "
- "General Public License.\n There is NO warranty.\n");
- fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
- ZLIB_VERSION, zlib_version);
- fprintf(stderr, "\n");
- fprintf(stderr, PNG_FIX_IDAT_WINDOWSIZE_USAGE);
- fflush(stderr);
- return 1;
- }
- ++argn;
- }
-
- printf("png-fix-IDAT-windowsize, version %s, by Greg Roelofs.\n", VERSION);
- printf(" This software is licensed under the GNU "
- "General Public License.\n There is NO warranty.\n");
- printf(" Compiled with zlib %s; using zlib %s.\n",
- ZLIB_VERSION, zlib_version);
- printf("\n");
- fflush(stdout);
-
- if ( argn == argc ) {
- fprintf(stderr, PNG_FIX_IDAT_WINDOWSIZE_USAGE);
- fflush(stderr);
- return 5;
- } else {
- filename = argv[argn];
- ++argn;
- }
-
-
- /*============================= MAIN LOOP =============================*/
-
- while (argn <= argc) {
- int retval;
-
- if (verbose) {
- printf("%s:\n", filename);
- fflush(stdout);
- }
-
- retval = png_fix_IDAT_windowsize(filename, force, verbose);
-
- if (retval) {
- latest_error = retval;
- ++error_count;
- }
- ++file_count;
-
- if (verbose) {
- printf("\n");
- fflush(stdout);
- }
-
- filename = argv[argn];
- ++argn;
- }
-
- /*=======================================================================*/
-
-
- if (verbose) {
- if (error_count)
- printf("There were errors fixing %d PNG file%s out of a"
- " total of %d file%s.\n",
- error_count, (error_count == 1)? "" : "s",
- file_count, (file_count == 1)? "" : "s");
- else
- printf("No errors detected while fixing %d PNG image%s.\n",
- file_count, (file_count == 1)? "" : "s");
- fflush(stdout);
- }
-
- return latest_error;
-}
-
-
-
-
-static int png_fix_IDAT_windowsize(char *filename, int force, int verbose)
-{
- FILE *infile, *outfile;
- uch inbuf[BUFSZ], *inptr, *endptr;
- uch *cbuf=NULL, *cptr;
- char outname[FNMAX];
- static char *colortype_name[] = {
- "grayscale", "[INVALID]", "RGB", "palette",
- "gray+alpha", "[INVALID]", "RGBA"
- };
- int fnlen, incnt;
- int depth, colortype, /* compress_method, filter_method, */ interlaced;
- int channels, bitsperpixel, error;
- int haveIDAT, haveEOF;
- long width, height, bitwidth, bytewidth;
- long chunklen, /* numfilters, */ ucsize;
- //long csize, csize_orig;
- ulg chunktyp, chunkcrc, calc_crc;
- ulg file_offset, file_offset_IDATs=0L;
- ulg bytes_remaining;
-
-
- if ((infile = fopen(filename, "rb")) == NULL) {
- fprintf(stderr, " error: cannot open %s for reading\n", filename);
- fflush(stderr);
- return 2;
- }
-
- /* build the output filename from the input name by inserting "-fixed"
- * before the ".png" extension (or by appending that plus ".png" if
- * there isn't any extension), then make sure it doesn't exist already */
-
- fnlen = strlen(filename);
-
- if (fnlen > FNMAX-9) {
- fprintf(stderr,
- " warning: base filename [%s] will be truncated\n", filename);
- fflush(stderr);
- fnlen = FNMAX-9;
- }
- strncpy(outname, filename, fnlen);
- if (strncmp(outname+fnlen-4, ".png", 4) == 0)
- strcpy(outname+fnlen-4, "-fixed.png");
- else
- strcpy(outname+fnlen, "-fixed.png");
- if (!force) {
- if ((outfile = fopen(outname, "rb")) != NULL) {
- fprintf(stderr, " error: %s exists; not overwriting\n",
- outname);
- fflush(stderr);
- fclose(outfile);
- return 15;
- }
- }
-
-
- /*
- ** Step 1: read in the input image.
- */
-
- // check PNG header
- inptr = endptr = inbuf;
- incnt = fread(endptr, 1, BUFSZ, infile); // 4096 bytes
- endptr += incnt;
-
- if (incnt < MIN_PNG_SIZE || memcmp(inbuf, pngsig, 8) != 0) {
- fprintf(stderr, " error: %s is not a PNG file\n", filename);
- fflush(stderr);
- return 17;
- }
- inptr += 8;
-
- // check IHDR length, name/ID bytes, and CRC over data
- chunklen = U32(inptr);
- inptr += 4;
- chunktyp = U32(inptr);
- if (chunklen != 13 || chunktyp != IHDR) {
- fprintf(stderr, " error: %s has bad IHDR chunk\n", filename);
- fflush(stderr);
- return 18;
- }
- //inptr += 4; still pointing at chunk name/ID for now
- calc_crc = crc32(0L, Z_NULL, 0);
- calc_crc = crc32(calc_crc, inptr, 4+chunklen);
- inptr += 4; // now pointing at start of chunk data
- chunkcrc = U32(inptr+chunklen);
- if (calc_crc != chunkcrc) {
- fprintf(stderr, " error: %s has bad IHDR CRC (got 0x%08lx, "
- "expected 0x%08lx)\n", filename, calc_crc, chunkcrc);
- fflush(stderr);
- return 19;
- }
-
- // store IHDR data
- width = U32(inptr);
- inptr += 4;
- height = U32(inptr);
- inptr += 4;
- depth = *inptr++;
- colortype = *inptr++;
- ++inptr; //compress_method = *inptr++;
- ++inptr; //filter_method = *inptr++;
- interlaced = *inptr++;
- inptr += 4; // skip over IHDR CRC
- incnt = endptr - inptr;
- file_offset = inptr - inbuf;
-
- if (width <= 0 || height <= 0) {
- fprintf(stderr, " error: %s has invalid dimensions (%ld x %ld)\n",
- filename, width, height);
- fflush(stderr);
- return 20;
- }
-
- error = 0;
-
- switch (colortype) {
- case 0:
- channels = 1;
- if (depth != 1 && depth !=2 && depth != 4 && depth != 8 && depth != 16)
- ++error;
- break;
-
- case 2:
- channels = 3;
- if (depth != 8 && depth != 16)
- ++error;
- break;
-
- case 3:
- channels = 1;
- if (depth != 1 && depth !=2 && depth != 4 && depth != 8)
- ++error;
- break;
-
- case 4:
- channels = 2;
- if (depth != 8 && depth != 16)
- ++error;
- break;
-
- case 6:
- channels = 4;
- if (depth != 8 && depth != 16)
- ++error;
- break;
-
- default:
- fprintf(stderr, " error: %s has invalid colortype (%d)\n", filename,
- colortype);
- fflush(stderr);
- return 22;
- }
-
- if (error) {
- fprintf(stderr, " error: %s has invalid sample depth (%d) for "
- "colortype (%d = %s)\n", filename, depth, colortype,
- colortype_name[colortype]);
- fflush(stderr);
- return 23;
- }
-
- bitsperpixel = depth * channels; /* can't overflow */
-
- if (verbose) {
- printf(" %ldx%ld, %d-bit, %sinterlaced, %s (type %d) image\n",
- width, height, bitsperpixel, interlaced? "" : "non-",
- colortype_name[colortype], colortype);
- }
-
-
- /* Calculate uncompressed image size and check for overflows. Strictly
- * speaking, this doesn't apply to interlaced images, but since no
- * interlace-pass subimage can be bigger than the complete image, the
- * latter checks are sufficient. */
-
- /* (this calculation works for both sub-8-bit and 8-bit or greater) */
- bitwidth = width * bitsperpixel;
- bytewidth = 1 + (bitwidth + 7) / 8; // 1 -> row-filter byte
- ucsize = bytewidth * height;
- //numfilters = height;
-
- if (bitwidth/width != bitsperpixel || bytewidth <= 0 ||
- ucsize/bytewidth != height)
- {
- fprintf(stderr, " error: %s has invalid dimensions\n", filename);
- fflush(stderr);
- return 20;
- }
-
-
-#define GET_U32(val, docrc) \
- if (incnt < 4) { \
- int j=incnt, remainder=(4-incnt); \
- uch tmpbuf[4]; \
- uch *tptr = tmpbuf; \
- \
- /* copy bytes to temporary buffer */ \
- for (; j > 0; --j) \
- *tptr++ = *inptr++; \
- /* read more bytes into main buffer */ \
- inptr = endptr = inbuf; \
- incnt = fread(endptr, 1, BUFSZ, infile); /* 4096 bytes */ \
- endptr += incnt; \
- /* if still fewer than 4 bytes, bail */ \
- if (incnt < remainder) { \
- haveEOF = TRUE; \
- break; \
- } \
- /* copy remaining bytes to temporary buffer... */ \
- for (j = remainder; j > 0; --j) \
- *tptr++ = *inptr++; \
- incnt -= remainder; \
- /* ...and assemble into 32-bit int */ \
- val = U32(tmpbuf); \
- if (docrc) \
- calc_crc = crc32(calc_crc, tmpbuf, 4); \
- file_offset += 4; \
- } else { \
- val = U32(inptr); \
- if (docrc) \
- calc_crc = crc32(calc_crc, inptr, 4); \
- inptr += 4; \
- incnt -= 4; \
- file_offset += 4; \
- }
-
- // FIXME: change GET_U32() macro into a function (too big => cache trash)
-
- /* Next loop over remaining chunks, verifying CRC of each but otherwise
- * ignoring them. Stop as soon as find first IDAT. */
-
-//inptr currently points at "length" bytes of first chunk after IHDR
-
- //csize_orig = 0L;
- error = haveEOF = haveIDAT = FALSE;
-
- while (!error && !haveEOF) {
- // check chunk length, name/ID bytes, and CRC over data
- GET_U32(chunklen, 0) // this advances inptr, refills buffer as needed
- calc_crc = crc32(0L, Z_NULL, 0);
- GET_U32(chunktyp, 1) // ...and also updates calc_crc in this case
-
- // NOTE: The displayed file offset is that of the chunk name/ID,
- // *not* the true beginning of the chunk (length-bytes,
- // 4 bytes earlier). This matches pngcheck's behavior.
- if (verbose) {
- printf(" %s chunk (0x%lx), length %ld, at file offset %lu "
- "(0x%05lx)\n", chunkstr(chunktyp), chunktyp, chunklen,
- file_offset-4, file_offset-4);
- }
-
- if (chunktyp == IDAT) {
- haveIDAT = TRUE;
- file_offset_IDATs = file_offset - 8; // start of chunklen
- //csize_orig += chunklen;
- break;
- }
-
- // now pointing at chunk data (i.e., AFTER chunk name/ID)
- while (chunklen > incnt) {
- calc_crc = crc32(calc_crc, inptr, incnt);
- chunklen -= incnt;
- file_offset += incnt;
-
- /* read more bytes into buffer */
- inptr = inbuf;
- incnt = fread(inbuf, 1, BUFSZ, infile); /* 4096 bytes */
- if (incnt <= 0) {
- fprintf(stderr, " error: unexpected EOF while reading %s "
- "(chunk is missing %ld bytes)\n", filename, chunklen);
- fflush(stderr);
- error = haveEOF = TRUE;
- break;
- }
- endptr = inbuf + incnt; // rarely used, but maybe sometimes?
- }
- if (error)
- break;
- calc_crc = crc32(calc_crc, inptr, chunklen);
- inptr += chunklen;
- incnt -= chunklen;
- file_offset += chunklen;
-
- GET_U32(chunkcrc, 0)
- if (calc_crc != chunkcrc) {
- fprintf(stderr, " error: %s has bad %s CRC (got 0x%08lx, "
- "expected 0x%08lx)\n", filename, chunkstr(chunktyp), chunkcrc,
- chunkcrc);
- fflush(stderr);
- error = TRUE;
- break;
- }
-
- } // end of while-loop over post-IHDR chunks (first pass)
-
- if (!haveIDAT) {
- fprintf(stderr, " error: found no IDAT chunks in %s\n", filename);
- fflush(stderr);
- error = TRUE;
- }
-
- if (error) {
- fclose(infile);
- return 24;
- }
-
- /* end of "sniffer" pass; now read first IDAT into buffer */
-
- if (fseek(infile, file_offset_IDATs, SEEK_SET) < 0) {
- fprintf(stderr, " error: %s: can't seek back to start of IDATs?!\n",
- filename);
- fflush(stderr);
- fclose(infile);
- return 25;
- }
-
- // allocate compressed-image buffer (unless more than 10 MB?)
- if ((cbuf = (uch *)malloc(chunklen+12)) == NULL) {
- fprintf(stderr, " error: %s: can't allocate buffer for first IDAT\n",
- filename);
- fflush(stderr);
- fclose(infile);
- return 26;
- }
-
- // second pass through file: loop over IDATs, reading data into cbuf
-
- file_offset = file_offset_IDATs;
- cptr = cbuf;
- //csize = csize_orig;
-
- incnt = fread(cbuf, 1, chunklen+12, infile);
-
- calc_crc = crc32(0L, Z_NULL, 0);
- calc_crc = crc32(calc_crc, cbuf+4, chunklen+4);
- chunkcrc = U32(cbuf+4 + chunklen+4);
- if (calc_crc != chunkcrc) {
- fprintf(stderr, " error: %s has bad %s CRC (got 0x%08lx, "
- "expected 0x%08lx)\n", filename, chunkstr(chunktyp), chunkcrc,
- chunkcrc);
- fflush(stderr);
- fclose(infile);
- return 23;
- }
-
- cptr = cbuf + 8;
-// if (cptr[0] == 0x68 && cptr[1] == 0x81) // (overly) conservative check
- if (cptr[0] != 0x78 || cptr[1] != 0x9c) // aggressive check
- {
- cptr[0] = 0x78;
- cptr[1] = 0x9c;
- } else {
- fprintf(stderr, " note: %s does not appear to have bad zlib "
- "windowBits; skipping\n", filename);
- fflush(stderr);
- fclose(infile);
- return 0;
- }
- calc_crc = crc32(0L, Z_NULL, 0);
- calc_crc = crc32(calc_crc, cbuf+4, chunklen+4);
- cptr = cbuf+4 + chunklen+4;
- cptr[0] = (calc_crc >> 24);
- cptr[1] = (calc_crc >> 16) & 0xff;
- cptr[2] = (calc_crc >> 8) & 0xff;
- cptr[3] = (calc_crc ) & 0xff;
-
- if ((outfile = fopen(outname, "wb")) == NULL) {
- fprintf(stderr, " error: cannot open %s for writing\n", outname);
- fflush(stderr);
- return 16;
- }
-
-
- /* Now copy infile up to first IDAT; copy cbuf (replaced IDAT); and finally
- * copy infile from end of first IDAT to end of file. */
-
- // copy infile to outfile, up to file_offset_IDATs
- fseek(infile, 0, SEEK_SET);
- bytes_remaining = file_offset_IDATs;
- while (bytes_remaining > 0) {
- /* read more bytes into buffer */
- incnt = (bytes_remaining > BUFSZ)? BUFSZ : bytes_remaining;
- incnt = fread(inbuf, 1, incnt, infile); /* 4096 bytes (or less) */
- if (incnt <= 0) {
- fprintf(stderr, " error: unexpected EOF while copying %s\n",
- filename);
- fflush(stderr);
- error = haveEOF = TRUE;
- break;
- }
- fwrite(inbuf, 1, incnt, outfile);
- bytes_remaining -= incnt;
- }
-
- // copy modified IDAT (cbuf) to outfile
- fwrite(cbuf, 1, chunklen+12, outfile);
-
- // copy rest of infile to outfile
- fseek(infile, file_offset_IDATs + chunklen+12, SEEK_SET);
- while (!haveEOF) {
- /* read more bytes into buffer */
- incnt = fread(inbuf, 1, BUFSZ, infile); /* 4096 bytes */
- if (incnt <= 0) {
- // apparently we're done
- haveEOF = TRUE;
- break;
- }
- fwrite(inbuf, 1, incnt, outfile);
- }
-
- fclose(outfile);
-
- if (cbuf) {
- free(cbuf);
- cbuf = NULL;
- }
-
- fclose(infile);
-
- return error? 27 : 0;
-
-} /* end of function png_fix_IDAT_windowsize() */
-
-
-
-
-
-/* convert chunk type to character-string "name" (assuming charset is ASCII!) */
-static char *chunkstr(ulg typ)
-{
- static char str[5];
-
- str[0] = ((typ >> 24) & 0xff);
- str[1] = ((typ >> 16) & 0xff);
- str[2] = ((typ >> 8) & 0xff);
- str[3] = ((typ ) & 0xff);
- str[4] = '\0';
-
- return str;
-}
diff --git a/gpl/pngsplit.1 b/gpl/pngsplit.1
deleted file mode 100644
index d19c581..0000000
--- a/gpl/pngsplit.1
+++ /dev/null
@@ -1,28 +0,0 @@
-.TH PNGSPLIT "1" "October 2020" "pngsplit 1.0" "User Commands"
-.SH NAME
-pngsplit \- manual page for pngsplit 1.0
-.SH SYNOPSIS
-.B pngsplit
-.RI [ options ]
-.I pngfile
-.RI [ pngfile \ [...]]
-.SH DESCRIPTION
-pngsplit, version 1.0 of 31 October 2020, by Greg Roelofs.
-.PP
-Split a PNG, MNG or JNG file into individual, numbered chunks (filenames
-"foo.png.0000.sig", "foo.png.0001.IHDR", etc.).
-.PP
-This software is licensed under the GNU General Public License.
-There is NO warranty.
-.SH OPTIONS
-.TP
-.B \-force
-overwrite existing output files
-.TP
-.B \-verbose
-print more status messages (synonym:
-.BR \-noquiet )
-.IP
-.SH "SEE ALSO"
-.BR pngcheck (1),
-.BR png-fix-IDAT-windowsize (1)
diff --git a/gpl/pngsplit.c b/gpl/pngsplit.c
deleted file mode 100644
index ca4567b..0000000
--- a/gpl/pngsplit.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/* pngsplit.c - split a PNG file into individual chunk-files (and check CRCs)
-**
-** Downloads:
-**
-** http://www.libpng.org/pub/png/apps/pngcheck.html
-**
-** To compile (assuming zlib path is ../zlib):
-**
-** gcc -Wall -O2 -I../zlib pngsplit.c -o pngsplit -L../zlib -lz
-**
-**
-** Copyright 2005-2020 Greg Roelofs
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-**
-*/
-
-#define VERSION "1.0 of 31 October 2020"
-
-/*
- * TO DO:
- * - fix filename-mismatch bookkeeping error (2nd FIXME below)
- * - convert GET_U32() macro to function (optionally inlinable)
- * - clean up code, promote to 1.0
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#include <zlib.h> // for crc32()
-
-/* to use this, define and setenv MALLOC_TRACE /path/to/pngsplit-mtrace.log */
-#undef GRR_MALLOC_DEBUG
-#ifdef GRR_MALLOC_DEBUG
-# include <mcheck.h>
-#endif
-
-typedef unsigned long ulg;
-typedef unsigned short ush;
-typedef unsigned char uch;
-
-#ifndef TRUE
-# define TRUE 1
-#endif
-#ifndef FALSE
-# define FALSE 0
-#endif
-
-#define FNMAX 1024 /* max filename length */
-#define BUFSZ 4096
-
-/* flag bits for writing chunk files */
-#define WR_FORCE 0x01
-#define WR_OPEN 0x02
-#define WR_CLOSE 0x04
-
-#define MIN_PNG_SIZE (8 + 4+4+13+4 + 4+4+10+4 + 4+4+4) // 67 (IDAT = 10: empir.)
-
-#define U16(x) ( ((ush)(((uch *)(x))[0]) << 8) | \
- ((ush)(((uch *)(x))[1]) ) )
-
-#define U32(x) ( ((ulg)(((uch *)(x))[0]) << 24) | \
- ((ulg)(((uch *)(x))[1]) << 16) | \
- ((ulg)(((uch *)(x))[2]) << 8) | \
- ((ulg)(((uch *)(x))[3]) ) )
-
-#define PNGSPLIT_HDR "\
-pngsplit, version " VERSION ", by Greg Roelofs.\n\
- This software is licensed under the GNU General Public License.\n\
- There is NO warranty.\n\n"
-
-#define PNGSPLIT_USAGE "\
- usage: pngsplit [options] pngfile [pngfile [...]]\n\
- options:\n\
- -force overwrite existing output files\n\
- -verbose print more status messages (synonym: -noquiet)\n\n\
- Split a PNG, MNG or JNG file into individual, numbered chunks (filenames\n\
- \"foo.png.0000.sig\", \"foo.png.0001.IHDR\", etc.).\n"
-
-static const uch pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
-static const uch mngsig[8] = {138, 77, 78, 71, 13, 10, 26, 10};
-static const uch jngsig[8] = {139, 74, 78, 71, 13, 10, 26, 10};
-
-/*
- * ulg IHDR = ( (73L << 24) | (72L << 16) | (68L << 8) | (82L) ); // 0x49484452
- * ulg IDAT = ( (73L << 24) | (68L << 16) | (65L << 8) | (84L) ); // 0x49444154
- * ulg IEND = ( (73L << 24) | (69L << 16) | (78L << 8) | (68L) ); // 0x49454e44
- */
-
-
-static int pngsplit (char *filename, int force, int verbose);
-static char *chunkstr (ulg typ);
-static int write_chunk_to_file (char *basename, int baselen, ulg num,
- ulg chunklen, ulg chunktyp, ulg chunkcrc,
- uch *buf, ulg len, int flags);
-
-
-
-int main(int argc, char *argv[])
-{
- char *filename;
- int argn;
- int force = FALSE;
- int verbose = 0;
- int latest_error=0, error_count=0, file_count=0;
-
-
-#ifdef __EMX__
- _wildcard(&argc, &argv); /* Unix-like globbing for OS/2 and DOS */
-#endif
-
-#ifdef GRR_MALLOC_DEBUG
- mtrace();
-#endif
-
- argn = 1;
-
- while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) {
- if ( 0 == strncmp( argv[argn], "-force", 2 ) )
- force = TRUE;
- else if ( 0 == strncmp( argv[argn], "-noforce", 4 ) )
- force = FALSE;
- else if ( 0 == strncmp( argv[argn], "-verbose", 2 ) ||
- 0 == strncmp( argv[argn], "-noquiet", 4 ) )
- ++verbose;
- else if ( 0 == strncmp( argv[argn], "-noverbose", 4 ) ||
- 0 == strncmp( argv[argn], "-quiet", 2 ) )
- verbose = 0;
- else {
- fprintf(stderr, PNGSPLIT_HDR);
- fprintf(stderr, PNGSPLIT_USAGE);
- fflush(stderr);
- return 1;
- }
- ++argn;
- }
-
- if ( argn == argc ) {
- fprintf(stderr, PNGSPLIT_HDR);
- fprintf(stderr, PNGSPLIT_USAGE);
- fflush(stderr);
- return 5;
- } else {
- filename = argv[argn];
- ++argn;
- }
-
-
- /*============================= MAIN LOOP =============================*/
-
- fprintf(stdout, PNGSPLIT_HDR);
- fflush(stdout);
-
- while (argn <= argc) {
- int retval;
-
- if (verbose >= 0) {
- printf("%s:\n", filename);
- fflush(stdout);
- }
-
- retval = pngsplit(filename, force, verbose);
-
- if (retval) {
- latest_error = retval;
- ++error_count;
- }
- ++file_count;
-
- if (verbose) {
- printf("\n");
- fflush(stdout);
- }
-
- filename = argv[argn];
- ++argn;
- }
-
- /*=======================================================================*/
-
-
- if (verbose) {
- if (error_count)
- printf("There were errors splitting %d PNG file%s out of a"
- " total of %d file%s.\n",
- error_count, (error_count == 1)? "" : "s",
- file_count, (file_count == 1)? "" : "s");
- else
- printf("No errors detected while splitting %d PNG image%s.\n",
- file_count, (file_count == 1)? "" : "s");
- fflush(stdout);
- }
-
- return latest_error;
-}
-
-
-
-
-
-#define GET_U32(val, docrc) \
- if (incnt < 4) { \
- int j=incnt, remainder=(4-incnt); \
- uch tmpbuf[4]; \
- uch *tptr = tmpbuf; \
- \
- /* copy bytes to temporary buffer */ \
- for (; j > 0; --j) \
- *tptr++ = *inptr++; \
- /* read more bytes into main buffer */ \
- inptr = inbuf; \
- incnt = fread(inbuf, 1, BUFSZ, infile); /* 4096 bytes */ \
- /* if still fewer than 4 bytes, bail */ \
- if (incnt < remainder) { \
- haveEOF = TRUE; \
- break; \
- } \
- /* copy remaining bytes to temporary buffer... */ \
- for (j = remainder; j > 0; --j) \
- *tptr++ = *inptr++; \
- incnt -= remainder; \
- /* ...and assemble into 32-bit int */ \
- val = U32(tmpbuf); \
- if (docrc) \
- calc_crc = crc32(calc_crc, tmpbuf, 4); \
- file_offset += 4; \
- } else { \
- val = U32(inptr); \
- if (docrc) \
- calc_crc = crc32(calc_crc, inptr, 4); \
- inptr += 4; \
- incnt -= 4; \
- file_offset += 4; \
- }
-
- // FIXME: change GET_U32() macro into a function (too big => cache trash)
-
-
-
-
-
-static int pngsplit(char *filename, int force, int verbose)
-{
- FILE *infile;
- uch inbuf[BUFSZ], *inptr;
- int fnlen, incnt, flags, error, haveEOF;
- ulg chunknum=0L, chunklen, chunktyp, chunkcrc, calc_crc;
- ulg file_offset=0L;
-
-
- if (force)
- force = WR_FORCE; // ensure compatibility with flags below
-
- if ((infile = fopen(filename, "rb")) == NULL) {
- fprintf(stderr, " error: cannot open %s for reading\n", filename);
- fflush(stderr);
- return 2;
- }
-
- fnlen = strlen(filename);
-
- if (fnlen > FNMAX-12) {
- fprintf(stderr,
- " warning: base filename [%s] will be truncated\n", filename);
- fflush(stderr);
- fnlen = FNMAX-12;
- }
-
-
- /*
- ** Step 1: read in the input image.
- */
-
- // check PNG/MNG/JNG header
- inptr = inbuf;
- incnt = fread(inbuf, 1, BUFSZ, infile); // 4096 bytes
-
- if (incnt < MIN_PNG_SIZE || (memcmp(inbuf, pngsig, 8) != 0 &&
- memcmp(inbuf, mngsig, 8) != 0 && memcmp(inbuf, jngsig, 8) != 0))
- {
- fprintf(stderr, " error: %s does not appear to be a PNG, MNG, or "
- "JNG file\n", filename);
- fflush(stderr);
- return 17;
- }
- inptr += 8;
- incnt -= 8;
- file_offset = 8L;
-
- flags = force | WR_OPEN | WR_CLOSE;
- if (write_chunk_to_file(filename, fnlen, chunknum, 0,0,0, inbuf, 8, flags))
- return 18;
-
- error = haveEOF = FALSE;
-
- while (!error && !haveEOF) {
- // check chunk length, name/ID bytes, and CRC over data
- GET_U32(chunklen, 0) // this advances inptr, refills buffer as needed
- calc_crc = crc32(0L, Z_NULL, 0);
- GET_U32(chunktyp, 1) // ...and also updates calc_crc in this case
-
- ++chunknum;
-
- error = write_chunk_to_file(filename, fnlen, chunknum, chunklen,
- chunktyp, 0, inbuf, 0, WR_OPEN | force);
- if (error)
- return 19;
-
- // NOTE: The displayed file offset is that of the chunk name/ID,
- // *not* the true beginning of the chunk (length-bytes,
- // 4 bytes earlier). This matches pngcheck's behavior.
- if (verbose) {
- printf(" %s chunk (0x%lx), length %ld, at file offset %lu "
- "(0x%05lx)\n", chunkstr(chunktyp), chunktyp, chunklen,
- file_offset-4, file_offset-4);
- }
-
- // now pointing at chunk data (i.e., AFTER chunk name/ID)
- while (chunklen > incnt) {
- calc_crc = crc32(calc_crc, inptr, incnt);
- error = write_chunk_to_file(filename, fnlen, chunknum, 0,
- 0, 0, inptr, incnt, force);
- if (error)
- return 20;
-
- chunklen -= incnt;
- file_offset += incnt;
-
- /* read more bytes into buffer */
- inptr = inbuf;
- incnt = fread(inbuf, 1, BUFSZ, infile); /* 4096 bytes */
- if (incnt <= 0) {
- fprintf(stderr, " error: unexpected EOF while reading %s "
- "(chunk is missing %ld bytes)\n", filename, chunklen);
- fflush(stderr);
- return 21;
- }
- }
- calc_crc = crc32(calc_crc, inptr, chunklen);
- error = write_chunk_to_file(filename, fnlen, chunknum, 0,
- 0, 0, inptr, chunklen, force);
- if (error)
- return 22;
-
- inptr += chunklen;
- incnt -= chunklen;
- file_offset += chunklen;
-
- GET_U32(chunkcrc, 0)
- error = write_chunk_to_file(filename, fnlen, chunknum, 0,
- 0, chunkcrc, inbuf, 0, WR_CLOSE | force);
- if (error)
- return 23;
-
- if (calc_crc != chunkcrc) {
- fprintf(stderr, " error: %s has bad %s CRC (got 0x%08lx, "
- "expected 0x%08lx)\n", filename, chunkstr(chunktyp), calc_crc,
- chunkcrc);
- fflush(stderr);
- return 24;
- }
- } // end of while-loop over chunks
-
- fclose(infile);
-
- return 0; /* success! */
-
-} /* end of function pngsplit() */
-
-
-
-
-
-/* convert chunk type to character-string "name" (assuming charset is ASCII!) */
-static char *chunkstr(ulg typ)
-{
- static char str[5];
-
- str[0] = ((typ >> 24) & 0xff);
- str[1] = ((typ >> 16) & 0xff);
- str[2] = ((typ >> 8) & 0xff);
- str[3] = ((typ ) & 0xff);
- str[4] = '\0';
-
- return str;
-}
-
-
-
-
-/*
- GRR FIXME: have bookkeeping error when file already exists: note name
- mismatch on 2nd-4th file/error messages:
-
-ArcTriomphe-cHRM-red-blue-swap.png:
- warning: ArcTriomphe-cHRM-red-blue-swap.png.0000.sig exists; not overwriting
-ArcTriomphe-cHRM-red-green-swap.png:
- write_chunk_to_file() logic error: OPEN flag set but ArcTriomphe-cHRM-red-blue-swap.png.0000.sig still open
-ArcTriomphe-iCCP-red-blue-swap.png:
- write_chunk_to_file() logic error: OPEN flag set but ArcTriomphe-cHRM-red-blue-swap.png.0000.sig still open
-ArcTriomphe-iCCP-red-green-swap.png:
- write_chunk_to_file() logic error: OPEN flag set but ArcTriomphe-cHRM-red-blue-swap.png.0000.sig still open
-
- */
-// 0 = OK, 1 = warning (exists but continuing), 2 = error
-static int
-write_chunk_to_file(char *basename, int baselen, ulg num, ulg chunklen, ulg chunktyp, ulg chunkcrc, uch *buf, ulg len, int flags)
-{
- static FILE *outfile=NULL;
- static char outname[FNMAX];
- ulg wlen;
-
- if (flags & WR_OPEN) {
- if (outfile) {
- fprintf(stderr, " write_chunk_to_file() logic error: OPEN flag "
- "set but %s still open\n", outname);
- fflush(stderr);
- return 2;
- }
-
- strncpy(outname, basename, baselen);
-
- if (num == 0L) {
- strcpy(outname+baselen, ".0000.sig");
- } else {
- sprintf(outname+baselen, ".%04lu.%s", num, chunkstr(chunktyp));
- }
-
- if (!(flags & WR_FORCE)) {
- if ((outfile = fopen(outname, "rb")) != NULL) {
- fprintf(stderr, " warning: %s exists; not overwriting\n",
- outname);
- fflush(stderr);
- fclose(outfile);
- return 1;
- }
- }
-
- if ((outfile = fopen(outname, "wb")) == NULL) {
- fprintf(stderr, " error: cannot open %s for writing\n", outname);
- fflush(stderr);
- return 2;
- }
-
- if (num != 0L) {
- fputc((int)((chunklen >> 24) & 0xff), outfile);
- fputc((int)((chunklen >> 16) & 0xff), outfile);
- fputc((int)((chunklen >> 8) & 0xff), outfile);
- fputc((int)((chunklen ) & 0xff), outfile);
-
- fputc((int)((chunktyp >> 24) & 0xff), outfile);
- fputc((int)((chunktyp >> 16) & 0xff), outfile);
- fputc((int)((chunktyp >> 8) & 0xff), outfile);
- fputc((int)((chunktyp ) & 0xff), outfile);
- }
- }
-
- if (!outfile) {
- fprintf(stderr, " write_chunk_to_file() logic error: about to "
- "fwrite() but no file is open\n");
- fflush(stderr);
- return 2;
- }
- wlen = len? fwrite(buf, 1L, len, outfile) : 0L;
-
- if (flags & WR_CLOSE) {
- if (num != 0L) {
- fputc((int)((chunkcrc >> 24) & 0xff), outfile);
- fputc((int)((chunkcrc >> 16) & 0xff), outfile);
- fputc((int)((chunkcrc >> 8) & 0xff), outfile);
- fputc((int)((chunkcrc ) & 0xff), outfile);
- }
-
- if (!outfile) {
- fprintf(stderr, " write_chunk_to_file() logic error: CLOSE flag "
- "set but no file is open\n");
- fflush(stderr);
- return 2;
- }
-
- fclose(outfile);
- outfile = NULL;
- outname[0] = '\0';
- }
-
- if (wlen != len) {
- fprintf(stderr, " error: wrote %lu of %lu bytes (%s)\n", wlen, len,
- outname);
- fflush(stderr);
- return 2;
- }
-
- return 0;
-}
diff --git a/pngcheck.1 b/pngcheck.1
index d9e41ca..c9371ec 100644
--- a/pngcheck.1
+++ b/pngcheck.1
@@ -52,6 +52,3 @@ suppress windowBits test (more\-stringent compression check)
search for PNGs within another file and extract them when found
.SH NOTE
MNG support is more informational than conformance\-oriented.
-.SH "SEE ALSO"
-.BR pngsplit (1),
-.BR png-fix-IDAT-windowsize (1)