Codebase list gtkwave / 492b230
Imported Upstream version 3.3.52 أحمد المحمودي (Ahmed El-Mahmoudy) 10 years ago
108 changed file(s) with 3383 addition(s) and 1253 deletion(s). Raw diff Collapse all Expand all
1010 Hierarchy marker icons from the Silk icons set by Mark James found at the http://www.famfamfam.com/lab/icons/silk/ website.
1111 Portions of the TCL implementation, tcl_np.c and tcl_np.h are copyrighted by the Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState Corporation, and other parties.
1212 NSAlert is Copyright (C) 2011-2013 Philipp Mayerhofer.
13 LZ4 is Copyright (C) 2011-2013 Yann Collet.
13841384 Fixed timezero in vcd2fst as it was only parsing unsigned
13851385 numbers.
13861386 Fixed Open Hierarchy crash on blank signals.
1387 3.3.52 11nov13 Added LZ4 as compression type for FST. When enabled with
1388 --fourpack in vcd2fst, this compresses both signal data
1389 and the hierarchy using LZ4.
1390 Added WLF support via wlf2vcd. To use, specify -o
1391 at the command line. (e.g., gtkwave -o test.wlf)
1392 Changed left/right arrow function in signal/wave windows to
1393 find next transition of selected signal(s).
1394 Re-enabled DnD scroll beyond top/bottom of Signals pane.
1395 Added debounce for baseline (middle) mouse button.
1396 Another partial VCD loader fix.
1397 Now use libcomdlg32 file requesters on MinGW.
1398 Added --extensions flag to fstvcd to enable emission of
1399 FST extensions/attributes to VCD files. This is to keep FST
1400 attributes from making VCD files unparseable with other tools.
1401 Fix in FsdbReader interface for version 1.x files.
1402 Many warnings fixes found from gcc -Wextra flag.
1403 Fixed thread-unsafe static allocations in fstapi.c.
1404
00 ##########################################################################
11
2 GTKWave 3.3.50 Wave Viewer is Copyright (C) 1999-2013 Tony Bybell.
2 GTKWave 3.3.52 Wave Viewer is Copyright (C) 1999-2013 Tony Bybell.
33 Portions of GTKWave are Copyright (C) 1999-2013 Udi Finkelstein.
44 Context support is Copyright (C) 2007-2013 Kermin Elliott Fleming.
55 Trace group support is Copyright (C) 2009-2013 Donald Baltus.
193193 EXTDEBUG = @EXTDEBUG@
194194 EXTDEBUG2 = @EXTDEBUG2@
195195 EXTDEBUG3 = @EXTDEBUG3@
196 EXTDEBUG4 = @EXTDEBUG4@
196197 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
197198 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
198199 FSDB_CFLAGS = @FSDB_CFLAGS@
235236 LTLIBOBJS = @LTLIBOBJS@
236237 MAINT = @MAINT@
237238 MAKEINFO = @MAKEINFO@
239 MINGW_LDADD = @MINGW_LDADD@
238240 MKDIR_P = @MKDIR_P@
239241 OBJEXT = @OBJEXT@
240242 PACKAGE = @PACKAGE@
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for gtkwave 3.3.51.
2 # Generated by GNU Autoconf 2.69 for gtkwave 3.3.52.
33 #
44 # Report bugs to <bybell@rocketmail.com>.
55 #
579579 # Identity of this package.
580580 PACKAGE_NAME='gtkwave'
581581 PACKAGE_TARNAME='gtkwave'
582 PACKAGE_VERSION='3.3.51'
583 PACKAGE_STRING='gtkwave 3.3.51'
582 PACKAGE_VERSION='3.3.52'
583 PACKAGE_STRING='gtkwave 3.3.52'
584584 PACKAGE_BUGREPORT='bybell@rocketmail.com'
585585 PACKAGE_URL=''
586586
628628 TK_LDADD
629629 TCL_DEFADD
630630 TCL_LDADD
631 MINGW_LDADD
631632 POW_LIB
632633 LIBOBJS
633634 ALLOCA
660661 LIBZ_CFLAGS
661662 GPERF
662663 EXTLOAD_CFLAGS
664 EXTDEBUG4
663665 EXTDEBUG3
664666 EXTDEBUG2
665667 EXTDEBUG
13811383 # Omit some internal or obsolete options to make the list less imposing.
13821384 # This message is too long to be a string in the A/UX 3.1 sh.
13831385 cat <<_ACEOF
1384 \`configure' configures gtkwave 3.3.51 to adapt to many kinds of systems.
1386 \`configure' configures gtkwave 3.3.52 to adapt to many kinds of systems.
13851387
13861388 Usage: $0 [OPTION]... [VAR=VALUE]...
13871389
14471449
14481450 if test -n "$ac_init_help"; then
14491451 case $ac_init_help in
1450 short | recursive ) echo "Configuration of gtkwave 3.3.51:";;
1452 short | recursive ) echo "Configuration of gtkwave 3.3.52:";;
14511453 esac
14521454 cat <<\_ACEOF
14531455
15931595 test -n "$ac_init_help" && exit $ac_status
15941596 if $ac_init_version; then
15951597 cat <<\_ACEOF
1596 gtkwave configure 3.3.51
1598 gtkwave configure 3.3.52
15971599 generated by GNU Autoconf 2.69
15981600
15991601 Copyright (C) 2012 Free Software Foundation, Inc.
22372239 This file contains any messages produced by compilers while
22382240 running configure, to aid debugging if configure makes a mistake.
22392241
2240 It was created by gtkwave $as_me 3.3.51, which was
2242 It was created by gtkwave $as_me 3.3.52, which was
22412243 generated by GNU Autoconf 2.69. Invocation command line was
22422244
22432245 $ $0 $@
31043106
31053107 # Define the identity of the package.
31063108 PACKAGE='gtkwave'
3107 VERSION='3.3.51'
3109 VERSION='3.3.52'
31083110
31093111
31103112 cat >>confdefs.h <<_ACEOF
63716373 EXTLOAD_CFLAGS="$EXTLOAD_CFLAGS -DEXT2CONV_PATH=\\\"$EXTDEBUG3\\\" -DEXT2LOAD_SUFFIX=\\\"vpd\\\""
63726374 fi
63736375
6376 # enables .wlf as input filetype in vcd2fst, and also gtkwave -o
6377
6378 # Extract the first word of "wlf2vcd", so it can be a program name with args.
6379 set dummy wlf2vcd; ac_word=$2
6380 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6381 $as_echo_n "checking for $ac_word... " >&6; }
6382 if ${ac_cv_path_EXTDEBUG4+:} false; then :
6383 $as_echo_n "(cached) " >&6
6384 else
6385 case $EXTDEBUG4 in
6386 [\\/]* | ?:[\\/]*)
6387 ac_cv_path_EXTDEBUG4="$EXTDEBUG4" # Let the user override the test with a path.
6388 ;;
6389 *)
6390 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6391 for as_dir in $PATH
6392 do
6393 IFS=$as_save_IFS
6394 test -z "$as_dir" && as_dir=.
6395 for ac_exec_ext in '' $ac_executable_extensions; do
6396 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6397 ac_cv_path_EXTDEBUG4="$as_dir/$ac_word$ac_exec_ext"
6398 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6399 break 2
6400 fi
6401 done
6402 done
6403 IFS=$as_save_IFS
6404
6405 test -z "$ac_cv_path_EXTDEBUG4" && ac_cv_path_EXTDEBUG4="notfound"
6406 ;;
6407 esac
6408 fi
6409 EXTDEBUG4=$ac_cv_path_EXTDEBUG4
6410 if test -n "$EXTDEBUG4"; then
6411 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EXTDEBUG4" >&5
6412 $as_echo "$EXTDEBUG4" >&6; }
6413 else
6414 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6415 $as_echo "no" >&6; }
6416 fi
6417
6418
6419 if test "$EXTDEBUG4" != "notfound" ; then
6420 EXTLOAD_CFLAGS="$EXTLOAD_CFLAGS -DEXT3CONV_PATH=\\\"$EXTDEBUG4\\\" -DEXT3LOAD_SUFFIX=\\\"wlf\\\""
6421 fi
6422
63746423
63756424
63766425 #
1017510224 fi
1017610225 else
1017710226 if test "X$OSTYPE" = "Xmsys" ; then
10227 # add library for common dialog found in file.c
10228 MINGW_LDADD="-lcomdlg32"
1017810229 # skip Tcl_CreateInterp check on mingw (until we figure out)...
1017910230 if test "X$STUBIFY" = "Xyes" ; then
1018010231 TCL_DEFADD="-DHAVE_LIBTCL -DWAVE_TCL_STUBIFY -DUSE_TCL_STUBS -DUSE_TK_STUBS"
1031110362 LIBS : $LIBS
1031210363 INLINE_ASM : $INLINE_ASM
1031310364
10365 MINGW_LDADD : $MINGW_LDADD
1031410366 GTK_MAC_CFLAGS : $GTK_MAC_CFLAGS
1031510367 GTK_MAC_LIBS : $GTK_MAC_LIBS
1031610368 COCOA_GTK_CFLAGS : $COCOA_GTK_CFLAGS
1037210424 LIBS : $LIBS
1037310425 INLINE_ASM : $INLINE_ASM
1037410426
10427 MINGW_LDADD : $MINGW_LDADD
1037510428 GTK_MAC_CFLAGS : $GTK_MAC_CFLAGS
1037610429 GTK_MAC_LIBS : $GTK_MAC_LIBS
1037710430 COCOA_GTK_CFLAGS : $COCOA_GTK_CFLAGS
1093010983 # report actual input values of CONFIG_FILES etc. instead of their
1093110984 # values after options handling.
1093210985 ac_log="
10933 This file was extended by gtkwave $as_me 3.3.51, which was
10986 This file was extended by gtkwave $as_me 3.3.52, which was
1093410987 generated by GNU Autoconf 2.69. Invocation command line was
1093510988
1093610989 CONFIG_FILES = $CONFIG_FILES
1099611049 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1099711050 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1099811051 ac_cs_version="\\
10999 gtkwave config.status 3.3.51
11052 gtkwave config.status 3.3.52
1100011053 configured by $0, generated by GNU Autoconf 2.69,
1100111054 with options \\"\$ac_cs_config\\"
1100211055
11 # Process this file with autoconf to produce a configure script.
22
33 AC_PREREQ(2.59)
4 AC_INIT(gtkwave, 3.3.51, bybell@rocketmail.com)
4 AC_INIT(gtkwave, 3.3.52, bybell@rocketmail.com)
55 AC_CONFIG_SRCDIR([src/vcd.c])
66 AM_INIT_AUTOMAKE
77 AC_CONFIG_HEADER([config.h])
448448 AC_PATH_PROG(EXTDEBUG3, [vpd2vcd], [notfound])
449449 if test "$EXTDEBUG3" != "notfound" ; then
450450 EXTLOAD_CFLAGS="$EXTLOAD_CFLAGS -DEXT2CONV_PATH=\\\"$EXTDEBUG3\\\" -DEXT2LOAD_SUFFIX=\\\"vpd\\\""
451 fi
452
453 # enables .wlf as input filetype in vcd2fst, and also gtkwave -o
454
455 AC_PATH_PROG(EXTDEBUG4, [wlf2vcd], [notfound])
456 if test "$EXTDEBUG4" != "notfound" ; then
457 EXTLOAD_CFLAGS="$EXTLOAD_CFLAGS -DEXT3CONV_PATH=\\\"$EXTDEBUG4\\\" -DEXT3LOAD_SUFFIX=\\\"wlf\\\""
451458 fi
452459
453460 AC_SUBST(EXTLOAD_CFLAGS)
805812 fi
806813 else
807814 if test "X$OSTYPE" = "Xmsys" ; then
815 # add library for common dialog found in file.c
816 MINGW_LDADD="-lcomdlg32"
808817 # skip Tcl_CreateInterp check on mingw (until we figure out)...
809818 if test "X$STUBIFY" = "Xyes" ; then
810819 TCL_DEFADD="-DHAVE_LIBTCL -DWAVE_TCL_STUBIFY -DUSE_TCL_STUBS -DUSE_TK_STUBS"
841850 fi
842851 fi
843852
844
853 AC_SUBST(MINGW_LDADD)
845854 AC_SUBST(TCL_LDADD)
846855 AC_SUBST(TCL_DEFADD)
847856 AC_SUBST(TK_LDADD)
941950 LIBS : $LIBS
942951 INLINE_ASM : $INLINE_ASM
943952
953 MINGW_LDADD : $MINGW_LDADD
944954 GTK_MAC_CFLAGS : $GTK_MAC_CFLAGS
945955 GTK_MAC_LIBS : $GTK_MAC_LIBS
946956 COCOA_GTK_CFLAGS : $COCOA_GTK_CFLAGS
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
77 <key>CFBundleExecutable</key>
88 <string>gtkwave</string>
99 <key>CFBundleGetInfoString</key>
10 <string>3.3.51, (C) 1999-2013 Tony Bybell http://gtkwave.sourceforge.net</string>
10 <string>3.3.52, (C) 1999-2013 Tony Bybell http://gtkwave.sourceforge.net</string>
1111 <key>CFBundleIconFile</key>
1212 <string>gtkwave.icns</string>
1313 <key>CFBundleIdentifier</key>
1717 <key>CFBundlePackageType</key>
1818 <string>APPL</string>
1919 <key>CFBundleShortVersionString</key>
20 <string>3.3.51</string>
20 <string>3.3.52</string>
2121 <key>CFBundleSignature</key>
2222 <string>????</string>
2323 <key>CFBundleVersion</key>
24 <string>3.3.51</string>
24 <string>3.3.52</string>
2525 <key>NSHumanReadableCopyright</key>
2626 <string>Copyright 1999 - 2013 Tony Bybell, GNU General Public License.</string>
2727 <key>LSMinimumSystemVersion</key>
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
2020 fstVarDir.java \
2121 fstVarType.java \
2222 fstWriter.java \
23 fstWriterPackType.java \
2324 Main.java \
2425 zzz_test.csh
2526
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
244246 fstVarDir.java \
245247 fstVarType.java \
246248 fstWriter.java \
249 fstWriterPackType.java \
247250 Main.java \
248251 zzz_test.csh
249252
458458 }
459459
460460
461 JNIEXPORT void JNICALL Java_fstAPI_fstReaderSetVcdExtensions
462 (JNIEnv *env, jobject obj, jlong ctx, jboolean enable)
463 {
464 fstReaderSetVcdExtensions((void *)(long)ctx, (int)enable);
465 }
466
467
461468 JNIEXPORT jint JNICALL Java_fstAPI_fstReaderGetNumberDumpActivityChanges
462469 (JNIEnv *env, jobject obj, jlong ctx)
463470 {
400400
401401 /*
402402 * Class: fstAPI
403 * Method: fstReaderSetVcdExtensions
404 * Signature: (JZ)V
405 */
406 JNIEXPORT void JNICALL Java_fstAPI_fstReaderSetVcdExtensions
407 (JNIEnv *, jobject, jlong, jboolean);
408
409 /*
410 * Class: fstAPI
403411 * Method: fstReaderGetNumberDumpActivityChanges
404412 * Signature: (J)I
405413 */
9090 protected native boolean fstReaderGetFseekFailed(long ctx);
9191 protected native void fstReaderSetUnlimitedTimeRange(long ctx);
9292 protected native void fstReaderSetLimitTimeRange(long ctx, long start_time, long end_time);
93 protected native void fstReaderSetVcdExtensions(long ctx, boolean enable);
9394 protected native int fstReaderGetNumberDumpActivityChanges(long ctx);
9495 protected native long fstReaderGetDumpActivityChangeTime(long ctx, int idx);
9596 protected native boolean fstReaderGetFacProcessMask(long ctx, int facidx);
7272 public void fstReaderResetScope() { fstReaderResetScope(ctx); }
7373 public void fstReaderSetFacProcessMaskAll() { fstReaderSetFacProcessMaskAll(ctx); }
7474 public void fstReaderSetFacProcessMask(int facidx) { fstReaderSetFacProcessMask(ctx, facidx); }
75 public void fstReaderSetVcdExtensions(boolean enable) { fstReaderSetVcdExtensions(ctx, enable); }
7576 public void fstReaderSetLimitTimeRange(long start_time, long end_time) { fstReaderSetLimitTimeRange(ctx, start_time, end_time); }
7677 public void fstReaderSetUnlimitedTimeRange() { fstReaderSetUnlimitedTimeRange(ctx); }
7778
0 /*
1 * Copyright (c) 2013 Tony Bybell.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
20 */
21
22 public class fstWriterPackType
23 {
24 private fstWriterPackType( ) { }
25
26 public static final int FST_WR_PT_ZLIB = 0;
27 public static final int FST_WR_PT_FASTLZ = 1;
28 public static final int FST_WR_PT_LZ4 = 2;
29 };
1616 fstVarDir.java \
1717 fstVarType.java \
1818 fstWriter.java \
19 fstWriterPackType.java \
1920 fstReader.java
2021
2122 javac \
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
158158 EXTDEBUG = @EXTDEBUG@
159159 EXTDEBUG2 = @EXTDEBUG2@
160160 EXTDEBUG3 = @EXTDEBUG3@
161 EXTDEBUG4 = @EXTDEBUG4@
161162 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
162163 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
163164 FSDB_CFLAGS = @FSDB_CFLAGS@
200201 LTLIBOBJS = @LTLIBOBJS@
201202 MAINT = @MAINT@
202203 MAKEINFO = @MAKEINFO@
204 MINGW_LDADD = @MINGW_LDADD@
203205 MKDIR_P = @MKDIR_P@
204206 OBJEXT = @OBJEXT@
205207 PACKAGE = @PACKAGE@
156156 EXTDEBUG = @EXTDEBUG@
157157 EXTDEBUG2 = @EXTDEBUG2@
158158 EXTDEBUG3 = @EXTDEBUG3@
159 EXTDEBUG4 = @EXTDEBUG4@
159160 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
160161 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
161162 FSDB_CFLAGS = @FSDB_CFLAGS@
198199 LTLIBOBJS = @LTLIBOBJS@
199200 MAINT = @MAINT@
200201 MAKEINFO = @MAKEINFO@
202 MINGW_LDADD = @MINGW_LDADD@
201203 MKDIR_P = @MKDIR_P@
202204 OBJEXT = @OBJEXT@
203205 PACKAGE = @PACKAGE@
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
198198 EXTDEBUG = @EXTDEBUG@
199199 EXTDEBUG2 = @EXTDEBUG2@
200200 EXTDEBUG3 = @EXTDEBUG3@
201 EXTDEBUG4 = @EXTDEBUG4@
201202 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
202203 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
203204 FSDB_CFLAGS = @FSDB_CFLAGS@
240241 LTLIBOBJS = @LTLIBOBJS@
241242 MAINT = @MAINT@
242243 MAKEINFO = @MAKEINFO@
244 MINGW_LDADD = @MINGW_LDADD@
243245 MKDIR_P = @MKDIR_P@
244246 OBJEXT = @OBJEXT@
245247 PACKAGE = @PACKAGE@
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
113113 EXTDEBUG = @EXTDEBUG@
114114 EXTDEBUG2 = @EXTDEBUG2@
115115 EXTDEBUG3 = @EXTDEBUG3@
116 EXTDEBUG4 = @EXTDEBUG4@
116117 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
117118 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
118119 FSDB_CFLAGS = @FSDB_CFLAGS@
155156 LTLIBOBJS = @LTLIBOBJS@
156157 MAINT = @MAINT@
157158 MAKEINFO = @MAKEINFO@
159 MINGW_LDADD = @MINGW_LDADD@
158160 MKDIR_P = @MKDIR_P@
159161 OBJEXT = @OBJEXT@
160162 PACKAGE = @PACKAGE@
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
182182 EXTDEBUG = @EXTDEBUG@
183183 EXTDEBUG2 = @EXTDEBUG2@
184184 EXTDEBUG3 = @EXTDEBUG3@
185 EXTDEBUG4 = @EXTDEBUG4@
185186 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
186187 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
187188 FSDB_CFLAGS = @FSDB_CFLAGS@
224225 LTLIBOBJS = @LTLIBOBJS@
225226 MAINT = @MAINT@
226227 MAKEINFO = @MAKEINFO@
228 MINGW_LDADD = @MINGW_LDADD@
227229 MKDIR_P = @MKDIR_P@
228230 OBJEXT = @OBJEXT@
229231 PACKAGE = @PACKAGE@
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
150150 EXTDEBUG = @EXTDEBUG@
151151 EXTDEBUG2 = @EXTDEBUG2@
152152 EXTDEBUG3 = @EXTDEBUG3@
153 EXTDEBUG4 = @EXTDEBUG4@
153154 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
154155 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
155156 FSDB_CFLAGS = @FSDB_CFLAGS@
192193 LTLIBOBJS = @LTLIBOBJS@
193194 MAINT = @MAINT@
194195 MAKEINFO = @MAKEINFO@
196 MINGW_LDADD = @MINGW_LDADD@
195197 MKDIR_P = @MKDIR_P@
196198 OBJEXT = @OBJEXT@
197199 PACKAGE = @PACKAGE@
150150 EXTDEBUG = @EXTDEBUG@
151151 EXTDEBUG2 = @EXTDEBUG2@
152152 EXTDEBUG3 = @EXTDEBUG3@
153 EXTDEBUG4 = @EXTDEBUG4@
153154 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
154155 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
155156 FSDB_CFLAGS = @FSDB_CFLAGS@
192193 LTLIBOBJS = @LTLIBOBJS@
193194 MAINT = @MAINT@
194195 MAKEINFO = @MAKEINFO@
196 MINGW_LDADD = @MINGW_LDADD@
195197 MKDIR_P = @MKDIR_P@
196198 OBJEXT = @OBJEXT@
197199 PACKAGE = @PACKAGE@
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
109109 EXTDEBUG = @EXTDEBUG@
110110 EXTDEBUG2 = @EXTDEBUG2@
111111 EXTDEBUG3 = @EXTDEBUG3@
112 EXTDEBUG4 = @EXTDEBUG4@
112113 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
113114 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
114115 FSDB_CFLAGS = @FSDB_CFLAGS@
151152 LTLIBOBJS = @LTLIBOBJS@
152153 MAINT = @MAINT@
153154 MAKEINFO = @MAKEINFO@
155 MINGW_LDADD = @MINGW_LDADD@
154156 MKDIR_P = @MKDIR_P@
155157 OBJEXT = @OBJEXT@
156158 PACKAGE = @PACKAGE@
1616
1717 rtlbrowse_SOURCES = definehash.c fgetdynamic.c fgetdynamic.h \
1818 logfile.c splay.c tcl_helper.c tree_widget.c \
19 $(srcdir)/../../src/helpers/fst/lz4.c \
20 $(srcdir)/../../src/helpers/fst/lz4.h \
1921 $(srcdir)/../../src/helpers/fst/fastlz.c \
22 $(srcdir)/../../src/helpers/fst/fastlz.h \
2023 $(srcdir)/../../src/helpers/fst/fstapi.c \
21 stem_recurse.c jrb.c jrb.h $(srcdir)/../../src/helpers/vzt_read.c \
22 $(srcdir)/../../src/helpers/lxt2_read.c splay.h \
24 $(srcdir)/../../src/helpers/fst/fstapi.h \
25 stem_recurse.c jrb.c jrb.h $(srcdir)/../../src/helpers/vzt_read.c $(srcdir)/../../src/helpers/vzt_read.h \
26 $(srcdir)/../../src/helpers/lxt2_read.c $(srcdir)/../../src/helpers/lxt2_read.h splay.h \
2327 vlex.l vlex.h wavelink.h $(srcdir)/../../src/liblzma/LzmaLib.c $(srcdir)/../../src/liblzma/LzmaLib.h
2428
2529 LDADD= $(GTK_LIBS) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBLZMA_LDADD) $(AET2_LDADD) \
6363 PROGRAMS = $(bin_PROGRAMS)
6464 am_rtlbrowse_OBJECTS = definehash.$(OBJEXT) fgetdynamic.$(OBJEXT) \
6565 logfile.$(OBJEXT) splay.$(OBJEXT) tcl_helper.$(OBJEXT) \
66 tree_widget.$(OBJEXT) fastlz.$(OBJEXT) fstapi.$(OBJEXT) \
67 stem_recurse.$(OBJEXT) jrb.$(OBJEXT) vzt_read.$(OBJEXT) \
68 lxt2_read.$(OBJEXT) vlex.$(OBJEXT) LzmaLib.$(OBJEXT)
66 tree_widget.$(OBJEXT) lz4.$(OBJEXT) fastlz.$(OBJEXT) \
67 fstapi.$(OBJEXT) stem_recurse.$(OBJEXT) jrb.$(OBJEXT) \
68 vzt_read.$(OBJEXT) lxt2_read.$(OBJEXT) vlex.$(OBJEXT) \
69 LzmaLib.$(OBJEXT)
6970 rtlbrowse_OBJECTS = $(am_rtlbrowse_OBJECTS)
7071 rtlbrowse_LDADD = $(LDADD)
7172 am__DEPENDENCIES_1 =
214215 EXTDEBUG = @EXTDEBUG@
215216 EXTDEBUG2 = @EXTDEBUG2@
216217 EXTDEBUG3 = @EXTDEBUG3@
218 EXTDEBUG4 = @EXTDEBUG4@
217219 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
218220 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
219221 FSDB_CFLAGS = @FSDB_CFLAGS@
256258 LTLIBOBJS = @LTLIBOBJS@
257259 MAINT = @MAINT@
258260 MAKEINFO = @MAKEINFO@
261 MINGW_LDADD = @MINGW_LDADD@
259262 MKDIR_P = @MKDIR_P@
260263 OBJEXT = @OBJEXT@
261264 PACKAGE = @PACKAGE@
341344 LIBLZMA_LDADD = $(LIBXZ_LDADD)
342345 rtlbrowse_SOURCES = definehash.c fgetdynamic.c fgetdynamic.h \
343346 logfile.c splay.c tcl_helper.c tree_widget.c \
347 $(srcdir)/../../src/helpers/fst/lz4.c \
348 $(srcdir)/../../src/helpers/fst/lz4.h \
344349 $(srcdir)/../../src/helpers/fst/fastlz.c \
350 $(srcdir)/../../src/helpers/fst/fastlz.h \
345351 $(srcdir)/../../src/helpers/fst/fstapi.c \
346 stem_recurse.c jrb.c jrb.h $(srcdir)/../../src/helpers/vzt_read.c \
347 $(srcdir)/../../src/helpers/lxt2_read.c splay.h \
352 $(srcdir)/../../src/helpers/fst/fstapi.h \
353 stem_recurse.c jrb.c jrb.h $(srcdir)/../../src/helpers/vzt_read.c $(srcdir)/../../src/helpers/vzt_read.h \
354 $(srcdir)/../../src/helpers/lxt2_read.c $(srcdir)/../../src/helpers/lxt2_read.h splay.h \
348355 vlex.l vlex.h wavelink.h $(srcdir)/../../src/liblzma/LzmaLib.c $(srcdir)/../../src/liblzma/LzmaLib.h
349356
350357 LDADD = $(GTK_LIBS) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBLZMA_LDADD) $(AET2_LDADD) \
452459 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jrb.Po@am__quote@
453460 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logfile.Po@am__quote@
454461 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2_read.Po@am__quote@
462 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lz4.Po@am__quote@
455463 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/splay.Po@am__quote@
456464 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stem_recurse.Po@am__quote@
457465 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcl_helper.Po@am__quote@
472480 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
473481 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
474482 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
483
484 lz4.o: $(srcdir)/../../src/helpers/fst/lz4.c
485 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lz4.o -MD -MP -MF $(DEPDIR)/lz4.Tpo -c -o lz4.o `test -f '$(srcdir)/../../src/helpers/fst/lz4.c' || echo '$(srcdir)/'`$(srcdir)/../../src/helpers/fst/lz4.c
486 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lz4.Tpo $(DEPDIR)/lz4.Po
487 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../../src/helpers/fst/lz4.c' object='lz4.o' libtool=no @AMDEPBACKSLASH@
488 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
489 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lz4.o `test -f '$(srcdir)/../../src/helpers/fst/lz4.c' || echo '$(srcdir)/'`$(srcdir)/../../src/helpers/fst/lz4.c
490
491 lz4.obj: $(srcdir)/../../src/helpers/fst/lz4.c
492 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lz4.obj -MD -MP -MF $(DEPDIR)/lz4.Tpo -c -o lz4.obj `if test -f '$(srcdir)/../../src/helpers/fst/lz4.c'; then $(CYGPATH_W) '$(srcdir)/../../src/helpers/fst/lz4.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../../src/helpers/fst/lz4.c'; fi`
493 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lz4.Tpo $(DEPDIR)/lz4.Po
494 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../../src/helpers/fst/lz4.c' object='lz4.obj' libtool=no @AMDEPBACKSLASH@
495 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
496 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lz4.obj `if test -f '$(srcdir)/../../src/helpers/fst/lz4.c'; then $(CYGPATH_W) '$(srcdir)/../../src/helpers/fst/lz4.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../../src/helpers/fst/lz4.c'; fi`
475497
476498 fastlz.o: $(srcdir)/../../src/helpers/fst/fastlz.c
477499 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fastlz.o -MD -MP -MF $(DEPDIR)/fastlz.Tpo -c -o fastlz.o `test -f '$(srcdir)/../../src/helpers/fst/fastlz.c' || echo '$(srcdir)/'`$(srcdir)/../../src/helpers/fst/fastlz.c
154154 EXTDEBUG = @EXTDEBUG@
155155 EXTDEBUG2 = @EXTDEBUG2@
156156 EXTDEBUG3 = @EXTDEBUG3@
157 EXTDEBUG4 = @EXTDEBUG4@
157158 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
158159 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
159160 FSDB_CFLAGS = @FSDB_CFLAGS@
196197 LTLIBOBJS = @LTLIBOBJS@
197198 MAINT = @MAINT@
198199 MAKEINFO = @MAKEINFO@
200 MINGW_LDADD = @MINGW_LDADD@
199201 MKDIR_P = @MKDIR_P@
200202 OBJEXT = @OBJEXT@
201203 PACKAGE = @PACKAGE@
140140 EXTDEBUG = @EXTDEBUG@
141141 EXTDEBUG2 = @EXTDEBUG2@
142142 EXTDEBUG3 = @EXTDEBUG3@
143 EXTDEBUG4 = @EXTDEBUG4@
143144 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
144145 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
145146 FSDB_CFLAGS = @FSDB_CFLAGS@
182183 LTLIBOBJS = @LTLIBOBJS@
183184 MAINT = @MAINT@
184185 MAKEINFO = @MAKEINFO@
186 MINGW_LDADD = @MINGW_LDADD@
185187 MKDIR_P = @MKDIR_P@
186188 OBJEXT = @OBJEXT@
187189 PACKAGE = @PACKAGE@
Binary diff not shown
140140 EXTDEBUG = @EXTDEBUG@
141141 EXTDEBUG2 = @EXTDEBUG2@
142142 EXTDEBUG3 = @EXTDEBUG3@
143 EXTDEBUG4 = @EXTDEBUG4@
143144 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
144145 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
145146 FSDB_CFLAGS = @FSDB_CFLAGS@
182183 LTLIBOBJS = @LTLIBOBJS@
183184 MAINT = @MAINT@
184185 MAKEINFO = @MAKEINFO@
186 MINGW_LDADD = @MINGW_LDADD@
185187 MKDIR_P = @MKDIR_P@
186188 OBJEXT = @OBJEXT@
187189 PACKAGE = @PACKAGE@
142142 EXTDEBUG = @EXTDEBUG@
143143 EXTDEBUG2 = @EXTDEBUG2@
144144 EXTDEBUG3 = @EXTDEBUG3@
145 EXTDEBUG4 = @EXTDEBUG4@
145146 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
146147 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
147148 FSDB_CFLAGS = @FSDB_CFLAGS@
184185 LTLIBOBJS = @LTLIBOBJS@
185186 MAINT = @MAINT@
186187 MAKEINFO = @MAKEINFO@
188 MINGW_LDADD = @MINGW_LDADD@
187189 MKDIR_P = @MKDIR_P@
188190 OBJEXT = @OBJEXT@
189191 PACKAGE = @PACKAGE@
0 .TH "FST2VCD" "1" "3.3.29" "Anthony Bybell" "Filetype Conversion"
0 .TH "FST2VCD" "1" "3.3.52" "Anthony Bybell" "Filetype Conversion"
11 .SH "NAME"
22 .LP
33 fst2vcd \- Converts FST files to VCD
1717 \fB\-o,\-\-output\fR <\fIfilename\fP>
1818 Specify optional VCD output filename.
1919 .TP
20 \fB\-e,\-\-extensions\Fr
21 Emit FST extensions to VCD. Enabling this may create VCD files unreadable by other tools. This is generally intended to be used as a debugging tool when developing FST writer interfaces to simulators.
22 .TP
2023 \fB\-h,\-\-help\fR
2124 Display help then exit.
2225
0 .TH "VCD2FST" "1" "3.3.35" "Anthony Bybell" "Filetype Conversion"
0 .TH "VCD2FST" "1" "3.3.52" "Anthony Bybell" "Filetype Conversion"
11 .SH "NAME"
22 .LP
33 vcd2fst \- Converts VCD files to FST files
1818 .TP
1919 \fB\-F,\-\-fastpack\fR
2020 Indicates that fastlz should be used instead of gzip for block data.
21 .TP
22 \fB\-4,\-\-fourpack\fR
23 Indicates that LZ4 should be used instead of gzip/fastlz for block data and hierarchy data.
2124 .TP
2225 \fB\-c,\-\-compress\fR
2326 Indicates that the entire file should be run through gzip on close. This
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
139139 EXTDEBUG = @EXTDEBUG@
140140 EXTDEBUG2 = @EXTDEBUG2@
141141 EXTDEBUG3 = @EXTDEBUG3@
142 EXTDEBUG4 = @EXTDEBUG4@
142143 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
143144 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
144145 FSDB_CFLAGS = @FSDB_CFLAGS@
181182 LTLIBOBJS = @LTLIBOBJS@
182183 MAINT = @MAINT@
183184 MAKEINFO = @MAKEINFO@
185 MINGW_LDADD = @MINGW_LDADD@
184186 MKDIR_P = @MKDIR_P@
185187 OBJEXT = @OBJEXT@
186188 PACKAGE = @PACKAGE@
199199 EXTDEBUG = @EXTDEBUG@
200200 EXTDEBUG2 = @EXTDEBUG2@
201201 EXTDEBUG3 = @EXTDEBUG3@
202 EXTDEBUG4 = @EXTDEBUG4@
202203 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
203204 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
204205 FSDB_CFLAGS = @FSDB_CFLAGS@
241242 LTLIBOBJS = @LTLIBOBJS@
242243 MAINT = @MAINT@
243244 MAKEINFO = @MAKEINFO@
245 MINGW_LDADD = @MINGW_LDADD@
244246 MKDIR_P = @MKDIR_P@
245247 OBJEXT = @OBJEXT@
246248 PACKAGE = @PACKAGE@
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
139139 EXTDEBUG = @EXTDEBUG@
140140 EXTDEBUG2 = @EXTDEBUG2@
141141 EXTDEBUG3 = @EXTDEBUG3@
142 EXTDEBUG4 = @EXTDEBUG4@
142143 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
143144 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
144145 FSDB_CFLAGS = @FSDB_CFLAGS@
181182 LTLIBOBJS = @LTLIBOBJS@
182183 MAINT = @MAINT@
183184 MAKEINFO = @MAKEINFO@
185 MINGW_LDADD = @MINGW_LDADD@
184186 MKDIR_P = @MKDIR_P@
185187 OBJEXT = @OBJEXT@
186188 PACKAGE = @PACKAGE@
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
139139 EXTDEBUG = @EXTDEBUG@
140140 EXTDEBUG2 = @EXTDEBUG2@
141141 EXTDEBUG3 = @EXTDEBUG3@
142 EXTDEBUG4 = @EXTDEBUG4@
142143 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
143144 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
144145 FSDB_CFLAGS = @FSDB_CFLAGS@
181182 LTLIBOBJS = @LTLIBOBJS@
182183 MAINT = @MAINT@
183184 MAKEINFO = @MAKEINFO@
185 MINGW_LDADD = @MINGW_LDADD@
184186 MKDIR_P = @MKDIR_P@
185187 OBJEXT = @OBJEXT@
186188 PACKAGE = @PACKAGE@
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
139139 EXTDEBUG = @EXTDEBUG@
140140 EXTDEBUG2 = @EXTDEBUG2@
141141 EXTDEBUG3 = @EXTDEBUG3@
142 EXTDEBUG4 = @EXTDEBUG4@
142143 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
143144 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
144145 FSDB_CFLAGS = @FSDB_CFLAGS@
181182 LTLIBOBJS = @LTLIBOBJS@
182183 MAINT = @MAINT@
183184 MAKEINFO = @MAKEINFO@
185 MINGW_LDADD = @MINGW_LDADD@
184186 MKDIR_P = @MKDIR_P@
185187 OBJEXT = @OBJEXT@
186188 PACKAGE = @PACKAGE@
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
169169 EXTDEBUG = @EXTDEBUG@
170170 EXTDEBUG2 = @EXTDEBUG2@
171171 EXTDEBUG3 = @EXTDEBUG3@
172 EXTDEBUG4 = @EXTDEBUG4@
172173 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
173174 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
174175 FSDB_CFLAGS = @FSDB_CFLAGS@
211212 LTLIBOBJS = @LTLIBOBJS@
212213 MAINT = @MAINT@
213214 MAKEINFO = @MAKEINFO@
215 MINGW_LDADD = @MINGW_LDADD@
214216 MKDIR_P = @MKDIR_P@
215217 OBJEXT = @OBJEXT@
216218 PACKAGE = @PACKAGE@
139139 EXTDEBUG = @EXTDEBUG@
140140 EXTDEBUG2 = @EXTDEBUG2@
141141 EXTDEBUG3 = @EXTDEBUG3@
142 EXTDEBUG4 = @EXTDEBUG4@
142143 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
143144 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
144145 FSDB_CFLAGS = @FSDB_CFLAGS@
181182 LTLIBOBJS = @LTLIBOBJS@
182183 MAINT = @MAINT@
183184 MAKEINFO = @MAKEINFO@
185 MINGW_LDADD = @MINGW_LDADD@
184186 MKDIR_P = @MKDIR_P@
185187 OBJEXT = @OBJEXT@
186188 PACKAGE = @PACKAGE@
5151 vcd_partial.c vcd_recoder.c vcd_saver.c vcd_saver.h version.h vlist.c vlist.h vzt.c vzt.h wavealloca.h \
5252 wavewindow.c zoombuttons.c
5353
54 gtkwave_LDADD= $(LIBCOCOA_LDADD) $(GTK_LIBS) $(LIBLZMA_LDADD) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBFST_LDADD) $(AET2_LDADD) $(FSDB_LDADD) $(TCL_LDADD) $(TK_LDADD) $(LIBJUDY_LDADD) $(GTK_MAC_LIBS) $(GCONF_LIBS) $(GTK_UNIX_PRINT_LIBS)
54 gtkwave_LDADD= $(LIBCOCOA_LDADD) $(GTK_LIBS) $(LIBLZMA_LDADD) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBFST_LDADD) $(AET2_LDADD) $(FSDB_LDADD) $(TCL_LDADD) $(TK_LDADD) $(LIBJUDY_LDADD) $(GTK_MAC_LIBS) $(GCONF_LIBS) $(GTK_UNIX_PRINT_LIBS) $(MINGW_LDADD)
5555 gtkwave_LDFLAGS = $(COCOA_GTK_LDFLAGS)
5656
5757 twinwave_SOURCES= twinwave.c
100100 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
101101 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
102102 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
103 $(am__DEPENDENCIES_1)
103 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
104104 gtkwave_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(gtkwave_LDFLAGS) \
105105 $(LDFLAGS) -o $@
106106 am_twinwave_OBJECTS = twinwave.$(OBJEXT)
252252 EXTDEBUG = @EXTDEBUG@
253253 EXTDEBUG2 = @EXTDEBUG2@
254254 EXTDEBUG3 = @EXTDEBUG3@
255 EXTDEBUG4 = @EXTDEBUG4@
255256 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
256257 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
257258 FSDB_CFLAGS = @FSDB_CFLAGS@
294295 LTLIBOBJS = @LTLIBOBJS@
295296 MAINT = @MAINT@
296297 MAKEINFO = @MAKEINFO@
298 MINGW_LDADD = @MINGW_LDADD@
297299 MKDIR_P = @MKDIR_P@
298300 OBJEXT = @OBJEXT@
299301 PACKAGE = @PACKAGE@
406408 vcd_partial.c vcd_recoder.c vcd_saver.c vcd_saver.h version.h vlist.c vlist.h vzt.c vzt.h wavealloca.h \
407409 wavewindow.c zoombuttons.c
408410
409 gtkwave_LDADD = $(LIBCOCOA_LDADD) $(GTK_LIBS) $(LIBLZMA_LDADD) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBFST_LDADD) $(AET2_LDADD) $(FSDB_LDADD) $(TCL_LDADD) $(TK_LDADD) $(LIBJUDY_LDADD) $(GTK_MAC_LIBS) $(GCONF_LIBS) $(GTK_UNIX_PRINT_LIBS)
411 gtkwave_LDADD = $(LIBCOCOA_LDADD) $(GTK_LIBS) $(LIBLZMA_LDADD) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBFST_LDADD) $(AET2_LDADD) $(FSDB_LDADD) $(TCL_LDADD) $(TK_LDADD) $(LIBJUDY_LDADD) $(GTK_MAC_LIBS) $(GCONF_LIBS) $(GTK_UNIX_PRINT_LIBS) $(MINGW_LDADD)
410412 gtkwave_LDFLAGS = $(COCOA_GTK_LDFLAGS)
411413 twinwave_SOURCES = twinwave.c
412414 twinwave_LDADD = $(GTK_LIBS) $(GTK_MAC_LIBS) $(GCONF_LIBS)
162162 EXTDEBUG = @EXTDEBUG@
163163 EXTDEBUG2 = @EXTDEBUG2@
164164 EXTDEBUG3 = @EXTDEBUG3@
165 EXTDEBUG4 = @EXTDEBUG4@
165166 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
166167 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
167168 FSDB_CFLAGS = @FSDB_CFLAGS@
204205 LTLIBOBJS = @LTLIBOBJS@
205206 MAINT = @MAINT@
206207 MAKEINFO = @MAKEINFO@
208 MINGW_LDADD = @MINGW_LDADD@
207209 MKDIR_P = @MKDIR_P@
208210 OBJEXT = @OBJEXT@
209211 PACKAGE = @PACKAGE@
781781 }
782782
783783 attempt_count++;
784 gs = fsdbReaderGetStatistics(GLOBALS->extload_ffr_ctx);
785 if(gs)
786 {
787 GLOBALS->numfacs = gs->varCount;
788 free(gs);
789 success_count++;
790 }
791
792 attempt_count++;
784793 max_idcode = fsdbReaderGetMaxVarIdcode(GLOBALS->extload_ffr_ctx);
785794 if(max_idcode)
786795 {
787796 success_count++;
788797 }
789
790 attempt_count++;
791 gs = fsdbReaderGetStatistics(GLOBALS->extload_ffr_ctx);
792 if(gs)
793 {
794 GLOBALS->numfacs = gs->varCount;
795 free(gs);
798 else
799 {
800 max_idcode = GLOBALS->numfacs; /* for 1.x format files */
796801 success_count++;
797802 }
798803
00 /*
1 * Copyright (c) Tony Bybell 1999-2009.
1 * Copyright (c) Tony Bybell 1999-2013.
22 *
33 * This program is free software; you can redistribute it and/or
44 * modify it under the terms of the GNU General Public License
2020 #include <cocoa_misc.h>
2121 #endif
2222
23 #if defined __MINGW32__
24 #include <windows.h>
25 #endif
26
2327 #if GTK_CHECK_VERSION(2,4,0)
2428
2529 #ifndef MAC_INTEGRATION
135139 if(GLOBALS->bad_cleanup_file_c_1) GLOBALS->bad_cleanup_file_c_1();
136140 }
137141
138 void fileselbox_old(char *title, char **filesel_path, GtkSignalFunc ok_func, GtkSignalFunc notok_func, char *pattn)
139 {
142 void fileselbox_old(char *title, char **filesel_path, GtkSignalFunc ok_func, GtkSignalFunc notok_func, char *pattn, int is_writemode)
143 {
144 #if defined __MINGW32__
145 OPENFILENAME ofn;
146 char szFile[260]; /* buffer for file name */
147 char szPath[260]; /* buffer for path name */
148 char lpstrFilter[260]; /* more than enough room for some patterns */
149 BOOL rc;
150 #endif
151
140152 GLOBALS->fileselbox_text=filesel_path;
141153 GLOBALS->filesel_ok=0;
142154 GLOBALS->cleanup_file_c_2=ok_func;
143155 GLOBALS->bad_cleanup_file_c_1=notok_func;
156
157 #if defined __MINGW32__
158 ZeroMemory(&ofn, sizeof(ofn));
159 ofn.lStructSize = sizeof(ofn);
160 ofn.lpstrFile = szFile;
161 ofn.lpstrFile[0] = '\0';
162 ofn.lpstrFilter = lpstrFilter;
163 ofn.nMaxFile = sizeof(szFile);
164 ofn.lpstrFileTitle = NULL;
165 ofn.nMaxFileTitle = 0;
166 ofn.lpstrInitialDir = NULL;
167 ofn.Flags = is_writemode ? (OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT) : (OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST);
168
169 if((!pattn)||(!strcmp(pattn, "*")))
170 {
171 sprintf(lpstrFilter, "%s%c%s%c", "All", 0, "*.*", 0);
172 ofn.nFilterIndex = 0;
173 }
174 else
175 {
176 sprintf(lpstrFilter, "%s%c%s%c%s%c%s%c", pattn, 0, pattn, 0, "All", 0, "*.*");
177 ofn.nFilterIndex = 0;
178 }
179
180 if(*filesel_path)
181 {
182 char *fsp = *filesel_path;
183 int ch_idx = 0;
184 char ch = 0;
185
186 while(*fsp)
187 {
188 ch = *fsp;
189 szFile[ch_idx++] = (ch != '/') ? ch : '\\';
190 fsp++;
191 }
192
193 szFile[ch_idx] = 0;
194
195 if((ch == '/') || (ch == '\\'))
196 {
197 strcpy(szPath, szFile);
198 szFile[0] = 0;
199 ofn.lpstrInitialDir = szPath;
200 }
201 }
202
203 rc = is_writemode ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn);
204
205 if (rc==TRUE)
206 {
207 GLOBALS->filesel_ok=1;
208 if(*GLOBALS->fileselbox_text) free_2(*GLOBALS->fileselbox_text);
209 *GLOBALS->fileselbox_text=(char *)strdup_2(szFile);
210 GLOBALS->cleanup_file_c_2();
211 }
212 else
213 {
214 if(GLOBALS->bad_cleanup_file_c_1) GLOBALS->bad_cleanup_file_c_1();
215 }
216
217 #else
144218
145219 GLOBALS->fs_file_c_1=gtk_file_selection_new(title);
146220 gtkwave_signal_connect(GTK_OBJECT(GLOBALS->fs_file_c_1), "destroy", (GtkSignalFunc) destroy_callback, NULL);
156230
157231 gtk_widget_show(GLOBALS->fs_file_c_1);
158232 wave_gtk_grab_add(GLOBALS->fs_file_c_1);
233
234 #endif
159235 }
160236
161237
244320
245321 #if defined __MINGW32__ || !GTK_CHECK_VERSION(2,4,0)
246322
247 fileselbox_old(title, filesel_path, ok_func, notok_func, pattn);
323 fileselbox_old(title, filesel_path, ok_func, notok_func, pattn, is_writemode);
248324 return;
249325
250326 #else
00 /*
1 * Copyright (c) Tony Bybell 2010
1 * Copyright (c) Tony Bybell 2010-2013
22 *
33 * This program is free software; you can redistribute it and/or
44 * modify it under the terms of the GNU General Public License
99 #ifndef WAVE_FILESEL_H
1010 #define WAVE_FILESEL_H
1111
12 void fileselbox_old(char *title, char **filesel_path, GtkSignalFunc ok_func, GtkSignalFunc notok_func, char *pattn);
12 void fileselbox_old(char *title, char **filesel_path, GtkSignalFunc ok_func, GtkSignalFunc notok_func, char *pattn, int is_writemode);
1313 void fileselbox(char *title, char **filesel_path, GtkSignalFunc ok_func, GtkSignalFunc notok_func, char *pattn, int is_writemode);
1414
1515 #endif
312312
313313 if(rc == FSDB_RC_SUCCESS)
314314 {
315 *mult = ((int)digit);
315 *mult = digit ? ((int)digit) : 1; /* in case digit is zero */
316316 *scale = unit[0];
317317 }
318318
103103 * analyzer.c
104104 */
105105 TR_RJUSTIFY, /* default_flags 5 */
106 {0, 0, 0, 0, 0, 0, 0}, /* tims 6 */
107 {0, 0, NULL, NULL, NULL, NULL, 0, NULL, NULL}, /* traces 9 */
106 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0}, /* tims 6 */
107 {0, 0, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0}, /* traces 9 */
108108 0, /* hier_max_level 8 */
109109 0, /* hier_max_level_shadow */
110110 0, /* timestart_from_savefile */
368368 0, /* text_help_c_1 111 */
369369 0, /* vscrollbar_help_c_1 112 */
370370 #if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN)
371 {0}, /* iter_help_c_1 113 */
371 {NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, NULL}, /* iter_help_c_1 113 */
372372 0, /* bold_tag_help_c_1 114 */
373373 #endif
374374 0, /* window_help_c_2 115 */
415415 NULL, /* fontname_logfile 133 */
416416 NULL, /* font_logfile_c_1 134 */
417417 #if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN)
418 {0}, /* iter_logfile_c_2 135 */
418 {NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, NULL}, /* iter_logfile_c_2 135 */
419419 NULL, /* bold_tag_logfile_c_2 136 */
420420 NULL, /* mono_tag_logfile_c_1 137 */
421421 NULL, /* size_tag_logfile_c_1 138 */
874874 0, /* cached_mouseover_x */
875875 0, /* cached_mouseover_y */
876876 0, /* mouseover_counter */
877 0, /* button2_debounce_flag */
878
877879
878880 /*
879881 * simplereq.c
905907 NULL, /* text_status_c_2 398 */
906908 NULL, /* vscrollbar_status_c_2 399 */
907909 #if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN)
908 {0}, /* iter_status_c_3 400 */
910 {NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, NULL}, /* iter_status_c_3 400 */
909911 NULL, /* bold_tag_status_c_3 401 */
910912 #endif
911913
10781080 0, /* bundle_direction_treesearch_gtk2_c_3 467 */
10791081 NULL, /* cleanup_treesearch_gtk2_c_8 468 */
10801082 0, /* pre_import_treesearch_gtk2_c_1 469 */
1081 {0,0,0,NULL,NULL,NULL,0}, /* tcache_treesearch_gtk2_c_2 470 */
1083 {0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0}, /* tcache_treesearch_gtk2_c_2 470 */
10821084 0, /* dnd_tgt_on_signalarea_treesearch_gtk2_c_1 471 */
10831085 0, /* dnd_tgt_on_wavearea_treesearch_gtk2_c_1 */
10841086 NULL, /* dnd_sigview */
871871 gint cached_mouseover_x; /* from signalwindow.c */
872872 gint cached_mouseover_y; /* from signalwindow.c */
873873 gint mouseover_counter; /* from signalwindow.c */
874 unsigned button2_debounce_flag : 1;
874875
875876
876877 /*
1111 shmidcat vcd2lxt vcd2lxt2 vcd2vzt \
1212 vzt2vcd vztminer
1313
14 vcd2fst_SOURCES= vcd2fst.c $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c
14 vcd2fst_SOURCES= vcd2fst.c $(srcdir)/fst/lz4.c $(srcdir)/fst/lz4.h $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c
1515 vcd2fst_LDADD= $(LIBZ_LDADD) $(LIBJUDY_LDADD)
1616
17 fst2vcd_SOURCES= fst2vcd.c $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h
17 fst2vcd_SOURCES= fst2vcd.c $(srcdir)/fst/lz4.c $(srcdir)/fst/lz4.h $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h
1818 fst2vcd_LDADD= $(LIBZ_LDADD) $(LIBJUDY_LDADD)
1919
20 fstminer_SOURCES= fstminer.c $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h
20 fstminer_SOURCES= fstminer.c $(srcdir)/fst/lz4.c $(srcdir)/fst/lz4.h $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h
2121 fstminer_LDADD= $(LIBZ_LDADD) $(LIBJUDY_LDADD)
2222
2323 vcd2lxt_SOURCES= vcd2lxt.c lxt_write.c lxt_write.h v2l_analyzer.h v2l_debug.c v2l_debug.h
6868 am_evcd2vcd_OBJECTS = evcd2vcd.$(OBJEXT) jrb.$(OBJEXT)
6969 evcd2vcd_OBJECTS = $(am_evcd2vcd_OBJECTS)
7070 evcd2vcd_LDADD = $(LDADD)
71 am_fst2vcd_OBJECTS = fst2vcd.$(OBJEXT) fastlz.$(OBJEXT) \
71 am_fst2vcd_OBJECTS = fst2vcd.$(OBJEXT) lz4.$(OBJEXT) fastlz.$(OBJEXT) \
7272 fstapi.$(OBJEXT)
7373 fst2vcd_OBJECTS = $(am_fst2vcd_OBJECTS)
7474 am__DEPENDENCIES_1 =
7575 fst2vcd_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
76 am_fstminer_OBJECTS = fstminer.$(OBJEXT) fastlz.$(OBJEXT) \
77 fstapi.$(OBJEXT)
76 am_fstminer_OBJECTS = fstminer.$(OBJEXT) lz4.$(OBJEXT) \
77 fastlz.$(OBJEXT) fstapi.$(OBJEXT)
7878 fstminer_OBJECTS = $(am_fstminer_OBJECTS)
7979 fstminer_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
8080 am_ghwdump_OBJECTS = ghwdump.$(OBJEXT) ghwlib.$(OBJEXT)
9090 shmidcat_SOURCES = shmidcat.c
9191 shmidcat_OBJECTS = shmidcat.$(OBJEXT)
9292 shmidcat_LDADD = $(LDADD)
93 am_vcd2fst_OBJECTS = vcd2fst.$(OBJEXT) fastlz.$(OBJEXT) \
93 am_vcd2fst_OBJECTS = vcd2fst.$(OBJEXT) lz4.$(OBJEXT) fastlz.$(OBJEXT) \
9494 fstapi.$(OBJEXT) jrb.$(OBJEXT)
9595 vcd2fst_OBJECTS = $(am_vcd2fst_OBJECTS)
9696 vcd2fst_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
217217 EXTDEBUG = @EXTDEBUG@
218218 EXTDEBUG2 = @EXTDEBUG2@
219219 EXTDEBUG3 = @EXTDEBUG3@
220 EXTDEBUG4 = @EXTDEBUG4@
220221 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
221222 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
222223 FSDB_CFLAGS = @FSDB_CFLAGS@
259260 LTLIBOBJS = @LTLIBOBJS@
260261 MAINT = @MAINT@
261262 MAKEINFO = @MAKEINFO@
263 MINGW_LDADD = @MINGW_LDADD@
262264 MKDIR_P = @MKDIR_P@
263265 OBJEXT = @OBJEXT@
264266 PACKAGE = @PACKAGE@
337339 LIBLZMA_CFLAGS = -I$(srcdir)/../liblzma $(LIBXZ_CFLAGS)
338340 LIBLZMA_LDADD = $(LIBXZ_LDADD)
339341 AM_CFLAGS = -I$(srcdir)/.. -I$(srcdir)/../.. $(LIBZ_CFLAGS) $(LIBBZ2_CFLAGS) $(LIBLZMA_CFLAGS) $(LIBJUDY_CFLAGS) $(INLINE_ASM) $(EXTLOAD_CFLAGS) -I$(srcdir)/fst -I$(srcdir)/../../contrib/rtlbrowse
340 vcd2fst_SOURCES = vcd2fst.c $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c
342 vcd2fst_SOURCES = vcd2fst.c $(srcdir)/fst/lz4.c $(srcdir)/fst/lz4.h $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c
341343 vcd2fst_LDADD = $(LIBZ_LDADD) $(LIBJUDY_LDADD)
342 fst2vcd_SOURCES = fst2vcd.c $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h
344 fst2vcd_SOURCES = fst2vcd.c $(srcdir)/fst/lz4.c $(srcdir)/fst/lz4.h $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h
343345 fst2vcd_LDADD = $(LIBZ_LDADD) $(LIBJUDY_LDADD)
344 fstminer_SOURCES = fstminer.c $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h
346 fstminer_SOURCES = fstminer.c $(srcdir)/fst/lz4.c $(srcdir)/fst/lz4.h $(srcdir)/fst/fastlz.c $(srcdir)/fst/fastlz.h $(srcdir)/fst/fstapi.c $(srcdir)/fst/fstapi.h
345347 fstminer_LDADD = $(LIBZ_LDADD) $(LIBJUDY_LDADD)
346348 vcd2lxt_SOURCES = vcd2lxt.c lxt_write.c lxt_write.h v2l_analyzer.h v2l_debug.c v2l_debug.h
347349 vcd2lxt_LDADD = $(LIBZ_LDADD) $(LIBBZ2_LDADD)
495497 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2miner.Po@am__quote@
496498 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2vcd.Po@am__quote@
497499 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt_write.Po@am__quote@
500 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lz4.Po@am__quote@
498501 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scopenav.Po@am__quote@
499502 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shmidcat.Po@am__quote@
500503 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/v2l_debug.Po@am__quote@
535538 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../../contrib/rtlbrowse/jrb.c' object='jrb.obj' libtool=no @AMDEPBACKSLASH@
536539 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
537540 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o jrb.obj `if test -f '$(srcdir)/../../contrib/rtlbrowse/jrb.c'; then $(CYGPATH_W) '$(srcdir)/../../contrib/rtlbrowse/jrb.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../../contrib/rtlbrowse/jrb.c'; fi`
541
542 lz4.o: $(srcdir)/fst/lz4.c
543 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lz4.o -MD -MP -MF $(DEPDIR)/lz4.Tpo -c -o lz4.o `test -f '$(srcdir)/fst/lz4.c' || echo '$(srcdir)/'`$(srcdir)/fst/lz4.c
544 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lz4.Tpo $(DEPDIR)/lz4.Po
545 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/fst/lz4.c' object='lz4.o' libtool=no @AMDEPBACKSLASH@
546 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
547 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lz4.o `test -f '$(srcdir)/fst/lz4.c' || echo '$(srcdir)/'`$(srcdir)/fst/lz4.c
548
549 lz4.obj: $(srcdir)/fst/lz4.c
550 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lz4.obj -MD -MP -MF $(DEPDIR)/lz4.Tpo -c -o lz4.obj `if test -f '$(srcdir)/fst/lz4.c'; then $(CYGPATH_W) '$(srcdir)/fst/lz4.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/fst/lz4.c'; fi`
551 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lz4.Tpo $(DEPDIR)/lz4.Po
552 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/fst/lz4.c' object='lz4.obj' libtool=no @AMDEPBACKSLASH@
553 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
554 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lz4.obj `if test -f '$(srcdir)/fst/lz4.c'; then $(CYGPATH_W) '$(srcdir)/fst/lz4.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/fst/lz4.c'; fi`
538555
539556 fastlz.o: $(srcdir)/fst/fastlz.c
540557 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fastlz.o -MD -MP -MF $(DEPDIR)/fastlz.Tpo -c -o fastlz.o `test -f '$(srcdir)/fst/fastlz.c' || echo '$(srcdir)/'`$(srcdir)/fst/fastlz.c
44
55 noinst_LIBRARIES= libfst.a
66
7 libfst_a_SOURCES= fastlz.c fastlz.h fstapi.c fstapi.h
7 libfst_a_SOURCES= fastlz.c fastlz.h lz4.c lz4.h fstapi.c fstapi.h
88
99 EXTRA_DIST= block_format.txt
6767 am__v_AR_1 =
6868 libfst_a_AR = $(AR) $(ARFLAGS)
6969 libfst_a_LIBADD =
70 am_libfst_a_OBJECTS = fastlz.$(OBJEXT) fstapi.$(OBJEXT)
70 am_libfst_a_OBJECTS = fastlz.$(OBJEXT) lz4.$(OBJEXT) fstapi.$(OBJEXT)
7171 libfst_a_OBJECTS = $(am_libfst_a_OBJECTS)
7272 AM_V_P = $(am__v_P_@AM_V@)
7373 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
156156 EXTDEBUG = @EXTDEBUG@
157157 EXTDEBUG2 = @EXTDEBUG2@
158158 EXTDEBUG3 = @EXTDEBUG3@
159 EXTDEBUG4 = @EXTDEBUG4@
159160 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
160161 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
161162 FSDB_CFLAGS = @FSDB_CFLAGS@
198199 LTLIBOBJS = @LTLIBOBJS@
199200 MAINT = @MAINT@
200201 MAKEINFO = @MAKEINFO@
202 MINGW_LDADD = @MINGW_LDADD@
201203 MKDIR_P = @MKDIR_P@
202204 OBJEXT = @OBJEXT@
203205 PACKAGE = @PACKAGE@
273275 top_srcdir = @top_srcdir@
274276 AM_CFLAGS = $(LIBZ_CFLAGS) $(LIBJUDY_CFLAGS)
275277 noinst_LIBRARIES = libfst.a
276 libfst_a_SOURCES = fastlz.c fastlz.h fstapi.c fstapi.h
278 libfst_a_SOURCES = fastlz.c fastlz.h lz4.c lz4.h fstapi.c fstapi.h
277279 EXTRA_DIST = block_format.txt
278280 all: all-am
279281
325327
326328 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fastlz.Po@am__quote@
327329 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstapi.Po@am__quote@
330 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lz4.Po@am__quote@
328331
329332 .c.o:
330333 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
4545 uint8_t FST_BL_HIER
4646 uint64_t section length
4747 uint64_t length of uncompressed hier data
48 [compressed data]
48 [zlib compressed data]
49
50 or
51
52 uint8_t FST_BL_HIER_LZ4
53 uint64_t section length
54 uint64_t length of uncompressed hier data
55 [lz4 compressed data]
4956
5057 ===========================================================================
5158
8087 // value changes
8188
8289 varint maxhandle associated with the value change data
83 uint8_t pack type ('F' is fastlz, 'Z' is zlib)
90 uint8_t pack type ('F' is fastlz, '4' is lz4,
91 others ['Z'/'!'] are zlib)
8492
8593 varint chain 0 compressed data length (0 = uncompressed)
8694 [compressed data]
2323
2424 #include "fstapi.h"
2525 #include "fastlz.h"
26 #include "lz4.h"
2627
2728 #ifndef HAVE_LIBPTHREAD
2829 #undef FST_WRITER_PARALLEL
543544
544545 unsigned vc_emitted : 1;
545546 unsigned is_initial_time : 1;
547 unsigned fourpack : 1;
546548 unsigned fastpack : 1;
547549
548550 int64_t timezero;
10631065
10641066 f = xc->handle;
10651067 fstWriterVarint(f, xc->maxhandle); /* emit current number of handles */
1066 fputc(xc->fastpack ? 'F' : 'Z', f);
1068 fputc(xc->fourpack ? '4' : (xc->fastpack ? 'F' : 'Z'), f);
10671069 fpos = 1;
10681070
10691071 packmemlen = 1024; /* maintain a running "longest" allocation to */
12821284 dmem = packmem = malloc(packmemlen = (wrlen * 2) + 2);
12831285 }
12841286
1285 rc = fastlz_compress(scratchpnt, wrlen, dmem);
1287 rc = (xc->fourpack) ? LZ4_compress((char *)scratchpnt, (char *)dmem, wrlen) : fastlz_compress(scratchpnt, wrlen, dmem);
12861288 if(rc < destlen)
12871289 {
12881290 #ifndef FST_DYNAMIC_ALIAS_DISABLE
17071709
17081710 if(xc->compress_hier)
17091711 {
1710 unsigned char *mem = malloc(FST_GZIO_LEN);
17111712 off_t hl, eos;
17121713 gzFile zhandle;
17131714 int zfd;
17211722 fstWriterUint64(xc->handle, 0); /* section length */
17221723 fstWriterUint64(xc->handle, xc->hier_file_len); /* uncompressed length */
17231724
1724 fflush(xc->handle);
1725 zfd = dup(fileno(xc->handle));
1726 zhandle = gzdopen(zfd, "wb4");
1727 if(zhandle)
1728 {
1729 fstWriterFseeko(xc, xc->hier_handle, 0, SEEK_SET);
1730 for(hl = 0; hl < xc->hier_file_len; hl += FST_GZIO_LEN)
1725 if(!xc->fourpack)
1726 {
1727 unsigned char *mem = malloc(FST_GZIO_LEN);
1728 zfd = dup(fileno(xc->handle));
1729 fflush(xc->handle);
1730 zhandle = gzdopen(zfd, "wb4");
1731 if(zhandle)
17311732 {
1732 unsigned len = ((xc->hier_file_len - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (xc->hier_file_len - hl);
1733 fstFread(mem, len, 1, xc->hier_handle);
1734 gzwrite(zhandle, mem, len);
1733 fstWriterFseeko(xc, xc->hier_handle, 0, SEEK_SET);
1734 for(hl = 0; hl < xc->hier_file_len; hl += FST_GZIO_LEN)
1735 {
1736 unsigned len = ((xc->hier_file_len - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (xc->hier_file_len - hl);
1737 fstFread(mem, len, 1, xc->hier_handle);
1738 gzwrite(zhandle, mem, len);
1739 }
1740 gzclose(zhandle);
17351741 }
1736 gzclose(zhandle);
1742 else
1743 {
1744 close(zfd);
1745 }
1746 free(mem);
17371747 }
17381748 else
17391749 {
1740 close(zfd);
1741 }
1742 free(mem);
1750 int lz4_maxlen;
1751 unsigned char *mem;
1752 unsigned char *hmem;
1753 int packed_len;
1754
1755 fflush(xc->handle);
1756
1757 lz4_maxlen = LZ4_compressBound(xc->hier_file_len);
1758 mem = malloc(lz4_maxlen);
1759 hmem = fstMmap(NULL, xc->hier_file_len, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->hier_handle), 0);
1760 packed_len = LZ4_compress((char *)hmem, (char *)mem, xc->hier_file_len);
1761 fstFwrite(mem, packed_len, 1, xc->handle);
1762 fstMunmap(hmem, xc->hier_file_len);
1763 free(mem);
1764 }
17431765
17441766 fstWriterFseeko(xc, xc->handle, 0, SEEK_END);
17451767 eos = ftello(xc->handle);
17481770 fflush(xc->handle);
17491771
17501772 fstWriterFseeko(xc, xc->handle, fixup_offs, SEEK_SET);
1751 fputc(FST_BL_HIER, xc->handle); /* actual tag */
1773 fputc(xc->fourpack ? FST_BL_HIER_LZ4 : FST_BL_HIER, xc->handle); /* actual tag now also == compression type */
17521774
17531775 fstWriterFseeko(xc, xc->handle, 0, SEEK_END); /* move file pointer to end for any section adds */
17541776 fflush(xc->handle);
21282150 }
21292151
21302152
2131 void fstWriterSetPackType(void *ctx, int typ)
2153 void fstWriterSetPackType(void *ctx, enum fstWriterPackType typ)
21322154 {
21332155 struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
21342156 if(xc)
21352157 {
2136 xc->fastpack = (typ != 0);
2158 xc->fastpack = (typ != FST_WR_PT_ZLIB);
2159 xc->fourpack = (typ == FST_WR_PT_LZ4);
21372160 }
21382161 }
21392162
27192742 signed char timescale;
27202743 unsigned char filetype;
27212744
2745 unsigned use_vcd_extensions : 1;
27222746 unsigned double_endian_match : 1;
27232747 unsigned native_doubles_for_cb : 1;
27242748 unsigned contains_geom_section : 1;
27252749 unsigned contains_hier_section : 1; /* valid for hier_pos */
2750 unsigned contains_hier_section_lz4 : 1; /* valid for hier_pos */
27262751 unsigned limit_range_valid : 1; /* valid for limit_range_start, limit_range_end */
27272752
27282753 char version[FST_HDR_SIM_VERSION_SIZE + 1];
31733198 }
31743199
31753200
3201 void fstReaderSetVcdExtensions(void *ctx, int enable)
3202 {
3203 struct fstReaderContext *xc = (struct fstReaderContext *)ctx;
3204
3205 if(xc)
3206 {
3207 xc->use_vcd_extensions = (enable != 0);
3208 }
3209 }
3210
3211
31763212 void fstReaderIterBlocksSetNativeDoublesOnCallback(void *ctx, int enable)
31773213 {
31783214 struct fstReaderContext *xc = (struct fstReaderContext *)ctx;
31853221 /*
31863222 * hierarchy processing
31873223 */
3188 static char *fstVcdID(int value)
3189 {
3190 static char buf[16];
3224 static void fstVcdID(char *buf, int value)
3225 {
31913226 char *pnt = buf;
31923227 int vmod;
31933228
32073242 }
32083243
32093244 *pnt = 0;
3210 return(buf);
3211 }
3212
3213 static char *fstVcdIDForFwrite(int value, int *len)
3214 {
3215 static char buf[16];
3245 }
3246
3247 static int fstVcdIDForFwrite(char *buf, int value)
3248 {
32163249 char *pnt = buf;
32173250 int vmod;
32183251
32313264 if(!value) { break; }
32323265 }
32333266
3234 *len = pnt-buf;
3235 return(buf);
3267 return(pnt - buf);
32363268 }
32373269
32383270
32463278 char *fnam = malloc(strlen(xc->filename) + 6 + 16 + 32 + 1);
32473279 unsigned char *mem = malloc(FST_GZIO_LEN);
32483280 off_t hl, uclen;
3281 off_t clen = 0;
32493282 gzFile zhandle;
32503283 int zfd;
3284 int htyp = FST_BL_SKIP;
3285
3286 /* can't handle both set at once should never happen in a real file */
3287 if(!xc->contains_hier_section_lz4 && xc->contains_hier_section)
3288 {
3289 htyp = FST_BL_HIER;
3290 }
3291 else
3292 if(xc->contains_hier_section_lz4 && !xc->contains_hier_section)
3293 {
3294 htyp = FST_BL_HIER_LZ4;
3295 }
32513296
32523297 sprintf(fnam, "%s.hier_%d_%p", xc->filename, getpid(), (void *)xc);
32533298 fstReaderFseeko(xc, xc->f, xc->hier_pos, SEEK_SET);
32543299 uclen = fstReaderUint64(xc->f);
32553300 fflush(xc->f);
3256 zfd = dup(fileno(xc->f));
3257 zhandle = gzdopen(zfd, "rb");
3258 if(!zhandle)
3259 {
3260 close(zfd);
3261 free(mem);
3262 free(fnam);
3263 return(0);
3301
3302 if(htyp == FST_BL_HIER)
3303 {
3304 fstReaderFseeko(xc, xc->f, xc->hier_pos, SEEK_SET);
3305 uclen = fstReaderUint64(xc->f);
3306 fflush(xc->f);
3307
3308 zfd = dup(fileno(xc->f));
3309 zhandle = gzdopen(zfd, "rb");
3310 if(!zhandle)
3311 {
3312 close(zfd);
3313 free(mem);
3314 free(fnam);
3315 return(0);
3316 }
3317 }
3318 else
3319 if(htyp == FST_BL_HIER_LZ4)
3320 {
3321 fstReaderFseeko(xc, xc->f, xc->hier_pos - 8, SEEK_SET); /* get section len */
3322 clen = fstReaderUint64(xc->f) - 16;
3323 uclen = fstReaderUint64(xc->f);
3324 fflush(xc->f);
32643325 }
32653326
32663327 #ifndef __MINGW32__
32813342 if(fnam) unlink(fnam);
32823343 #endif
32833344
3284 for(hl = 0; hl < uclen; hl += FST_GZIO_LEN)
3285 {
3286 size_t len = ((uclen - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - hl);
3287 size_t gzreadlen = gzread(zhandle, mem, len); /* rc should equal len... */
3288 size_t fwlen;
3289
3290 if(gzreadlen != len)
3345 if(htyp == FST_BL_HIER)
3346 {
3347 for(hl = 0; hl < uclen; hl += FST_GZIO_LEN)
3348 {
3349 size_t len = ((uclen - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - hl);
3350 size_t gzreadlen = gzread(zhandle, mem, len); /* rc should equal len... */
3351 size_t fwlen;
3352
3353 if(gzreadlen != len)
3354 {
3355 pass_status = 0;
3356 break;
3357 }
3358
3359 fwlen = fstFwrite(mem, len, 1, xc->fh);
3360 if(fwlen != 1)
3361 {
3362 pass_status = 0;
3363 break;
3364 }
3365 }
3366 gzclose(zhandle);
3367 }
3368 else
3369 if(htyp == FST_BL_HIER_LZ4)
3370 {
3371 unsigned char *lz4_cmem = malloc(clen);
3372 unsigned char *lz4_ucmem = malloc(uclen);
3373
3374 fstFread(lz4_cmem, clen, 1, xc->f);
3375 pass_status = (uclen == LZ4_decompress_safe_partial ((char *)lz4_cmem, (char *)lz4_ucmem, clen, uclen, uclen));
3376
3377 if(fstFwrite(lz4_ucmem, uclen, 1, xc->fh) != 1)
32913378 {
32923379 pass_status = 0;
3293 break;
3294 }
3295
3296 fwlen = fstFwrite(mem, len, 1, xc->fh);
3297 if(fwlen != 1)
3298 {
3299 pass_status = 0;
3300 break;
3301 }
3302 }
3303 gzclose(zhandle);
3380 }
3381
3382 free(lz4_ucmem);
3383 free(lz4_cmem);
3384 }
3385 else /* FST_BL_SKIP */
3386 {
3387 pass_status = 0;
3388 }
3389
33043390 free(mem);
33053391 free(fnam);
33063392
36123698
36133699 attrarg = fstReaderVarint64(xc->fh);
36143700
3615 if(fv)
3701 if(fv && xc->use_vcd_extensions)
36163702 {
36173703 switch(attrtype)
36183704 {
36513737 break;
36523738
36533739 case FST_ST_GEN_ATTREND:
3654 if(fv) fprintf(fv, "$attrend $end\n");
3740 if(fv && xc->use_vcd_extensions) fprintf(fv, "$attrend $end\n");
36553741 break;
36563742
36573743 case FST_VT_VCD_EVENT:
37193805 }
37203806 if(fv)
37213807 {
3808 char vcdid_buf[16];
37223809 uint32_t modlen = (vartype != FST_VT_VCD_PORT) ? len : ((len - 2) / 3);
3723 fprintf(fv, "$var %s %"PRIu32" %s %s $end\n", vartypes[vartype], modlen, fstVcdID(xc->maxhandle+1), str);
3810 fstVcdID(vcdid_buf, xc->maxhandle+1);
3811 fprintf(fv, "$var %s %"PRIu32" %s %s $end\n", vartypes[vartype], modlen, vcdid_buf, str);
37243812 }
37253813 xc->maxhandle++;
37263814 }
37333821 }
37343822 if(fv)
37353823 {
3824 char vcdid_buf[16];
37363825 uint32_t modlen = (vartype != FST_VT_VCD_PORT) ? len : ((len - 2) / 3);
3737 fprintf(fv, "$var %s %"PRIu32" %s %s $end\n", vartypes[vartype], modlen, fstVcdID(alias), str);
3826 fstVcdID(vcdid_buf, alias);
3827 fprintf(fv, "$var %s %"PRIu32" %s %s $end\n", vartypes[vartype], modlen, vcdid_buf, str);
37383828 }
37393829 xc->num_alias++;
37403830 }
40284118 xc->contains_hier_section = 1;
40294119 xc->hier_pos = ftello(xc->f);
40304120 }
4121 else if(sectype == FST_BL_HIER_LZ4)
4122 {
4123 xc->contains_hier_section_lz4 = 1;
4124 xc->hier_pos = ftello(xc->f);
4125 }
40314126 else if(sectype == FST_BL_BLACKOUT)
40324127 {
40334128 uint32_t i;
41064201 xc->filename = strdup(nam);
41074202 rc = fstReaderInit(xc);
41084203
4109 if((rc) && (xc->vc_section_count) && (xc->maxhandle) && ((xc->fh)||(xc->contains_hier_section)))
4204 if((rc) && (xc->vc_section_count) && (xc->maxhandle) && ((xc->fh)||(xc->contains_hier_section||(xc->contains_hier_section_lz4))))
41104205 {
41114206 /* more init */
41124207 xc->do_rewind = 1;
42254320 uint32_t *scatterptr, *headptr, *length_remaining;
42264321 uint32_t cur_blackout = 0;
42274322 int packtype;
4323 unsigned char *mc_mem = NULL;
4324 uint32_t mc_mem_len; /* corresponds to largest value encountered in chain_table_lengths[i] */
42284325
42294326 if(!xc) return(0);
42304327
44234520 {
44244521 if(fv)
44254522 {
4426 int vcdid_len;
4427 const char *vcd_id = fstVcdIDForFwrite(idx+1, &vcdid_len);
4523 char vcd_id[16];
4524 int vcdid_len = fstVcdIDForFwrite(vcd_id, idx+1);
44284525 fputc(val, fv);
44294526 fstFwrite(vcd_id, vcdid_len, 1, fv);
44304527 fputc('\n', fv);
44504547 {
44514548 if(fv)
44524549 {
4453 int vcdid_len;
4454 const char *vcd_id = fstVcdIDForFwrite(idx+1, &vcdid_len);
4550 char vcd_id[16];
4551 int vcdid_len = fstVcdIDForFwrite(vcd_id, idx+1);
44554552 fputc((xc->signal_typs[idx] != FST_VT_VCD_PORT) ? 'b' : 'p', fv);
44564553 fstFwrite(mu+sig_offs, xc->signal_lens[idx], 1, fv);
44574554 fputc(' ', fv);
45104607 {
45114608 if(fv)
45124609 {
4610 char vcdid_buf[16];
45134611 clone_d = (unsigned char *)&d;
45144612 if(xc->double_endian_match)
45154613 {
45254623 }
45264624 }
45274625
4528 fprintf(fv, "r%.16g %s\n", d, fstVcdID(idx+1));
4626 fstVcdID(vcdid_buf, idx+1);
4627 fprintf(fv, "r%.16g %s\n", d, vcdid_buf);
45294628 }
45304629 }
45314630 }
46324731 #ifdef FST_DEBUG
46334732 printf("\tdecompressed chain idx len: %"PRIu32"\n", idx);
46344733 #endif
4734
4735 mc_mem_len = 16384;
4736 mc_mem = malloc(mc_mem_len); /* buffer for compressed reads */
4737
46354738 /* check compressed VC data */
46364739 if(idx > xc->maxhandle) idx = xc->maxhandle;
46374740 for(i=0;i<idx;i++)
46524755 val = fstReaderVarint32WithSkip(xc->f, &skiplen);
46534756 if(val)
46544757 {
4655 unsigned char *mu = mem_for_traversal + traversal_mem_offs;
4656 unsigned char *mc = malloc(chain_table_lengths[i]);
4758 unsigned char *mu = mem_for_traversal + traversal_mem_offs; /* uncomp: dst */
4759 unsigned char *mc; /* comp: src */
46574760 unsigned long destlen = val;
46584761 unsigned long sourcelen = chain_table_lengths[i];
4659
4762
4763 if(mc_mem_len < chain_table_lengths[i])
4764 {
4765 free(mc_mem);
4766 mc_mem = malloc(mc_mem_len = chain_table_lengths[i]);
4767 }
4768 mc = mc_mem;
4769
46604770 fstFread(mc, chain_table_lengths[i], 1, xc->f);
4661 if(packtype == 'F')
4771
4772 switch(packtype)
46624773 {
4663 rc = fastlz_decompress(mc, sourcelen, mu, destlen);
4774 case '4': rc = (destlen == LZ4_decompress_safe_partial((char *)mc, (char *)mu, sourcelen, destlen, destlen)) ? Z_OK : Z_DATA_ERROR;
4775 break;
4776 case 'F': fastlz_decompress(mc, sourcelen, mu, destlen); /* rc appears unreliable */
4777 break;
4778 default: rc = uncompress(mu, &destlen, mc, sourcelen);
4779 break;
46644780 }
4665 else
4666 {
4667 rc = uncompress(mu, &destlen, mc, sourcelen);
4668 }
4669 free(mc);
4781
46704782 /* data to process is for(j=0;j<destlen;j++) in mu[j] */
46714783 headptr[i] = traversal_mem_offs;
46724784 length_remaining[i] = val;
47074819 }
47084820 }
47094821
4822 free(mc_mem); /* there is no usage below for this, no real need to clear out mc_mem or mc_mem_len */
4823
47104824 for(i=0;i<tsec_nitems;i++)
47114825 {
47124826 uint32_t tdelta;
47684882 {
47694883 if(fv)
47704884 {
4771 int vcdid_len;
4772 const char *vcd_id = fstVcdIDForFwrite(idx+1, &vcdid_len);
4885 char vcd_id[16];
4886 int vcdid_len = fstVcdIDForFwrite(vcd_id, idx+1);
47734887 fputc(val, fv);
47744888 fstFwrite(vcd_id, vcdid_len, 1, fv);
47754889 fputc('\n', fv);
48134927 {
48144928 if(fv)
48154929 {
4816 int vcdid_len;
4817 const char *vcd_id = fstVcdIDForFwrite(idx+1, &vcdid_len);
4930 char vcd_id[16];
4931 int vcdid_len = fstVcdIDForFwrite(vcd_id, idx+1);
48184932
48194933 fputc('s', fv);
48204934 {
50025116
50035117 if(fv)
50045118 {
5005 int vcdid_len;
5006 const char *vcd_id = fstVcdIDForFwrite(idx+1, &vcdid_len);
5119 char vcd_id[16];
5120 int vcdid_len = fstVcdIDForFwrite(vcd_id, idx+1);
50075121 fputc(' ', fv);
50085122 fstFwrite(vcd_id, vcdid_len, 1, fv);
50095123 fputc('\n', fv);
3939
4040 typedef uint32_t fstHandle;
4141
42 enum fstWriterPackType {
43 FST_WR_PT_ZLIB = 0,
44 FST_WR_PT_FASTLZ = 1,
45 FST_WR_PT_LZ4 = 2
46 };
47
4248 enum fstFileType {
4349 FST_FT_MIN = 0,
4450
5662 FST_BL_GEOM = 3,
5763 FST_BL_HIER = 4,
5864 FST_BL_VCDATA_DYN_ALIAS = 5,
65 FST_BL_HIER_LZ4 = 6,
5966
6067 FST_BL_ZWRAPPER = 254, /* indicates that whole trace is gz wrapped */
6168 FST_BL_SKIP = 255 /* used while block is being written */
337344 void fstWriterSetDumpSizeLimit(void *ctx, uint64_t numbytes);
338345 void fstWriterSetEnvVar(void *ctx, const char *envvar);
339346 void fstWriterSetFileType(void *ctx, enum fstFileType filetype);
340 void fstWriterSetPackType(void *ctx, int typ); /* type = 0 (libz), 1 (fastlz) */
347 void fstWriterSetPackType(void *ctx, enum fstWriterPackType typ);
341348 void fstWriterSetParallelMode(void *ctx, int enable);
342349 void fstWriterSetRepackOnClose(void *ctx, int enable); /* type = 0 (none), 1 (libz) */
343350 void fstWriterSetScope(void *ctx, enum fstScopeType scopetype,
400407 void fstReaderSetFacProcessMaskAll(void *ctx);
401408 void fstReaderSetLimitTimeRange(void *ctx, uint64_t start_time, uint64_t end_time);
402409 void fstReaderSetUnlimitedTimeRange(void *ctx);
410 void fstReaderSetVcdExtensions(void *ctx, int enable);
403411
404412
405413 /*
0 /*
1 LZ4 - Fast LZ compression algorithm
2 Copyright (C) 2011-2013, Yann Collet.
3 BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above
12 copyright notice, this list of conditions and the following disclaimer
13 in the documentation and/or other materials provided with the
14 distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 You can contact the author at :
29 - LZ4 source repository : http://code.google.com/p/lz4/
30 - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
31 */
32
33 //**************************************
34 // Tuning parameters
35 //**************************************
36 // MEMORY_USAGE :
37 // Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.)
38 // Increasing memory usage improves compression ratio
39 // Reduced memory usage can improve speed, due to cache effect
40 // Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
41 #define MEMORY_USAGE 14
42
43 // HEAPMODE :
44 // Select how default compression functions will allocate memory for their hash table,
45 // in memory stack (0:default, fastest), or in memory heap (1:requires memory allocation (malloc)).
46 #define HEAPMODE 0
47
48
49 //**************************************
50 // CPU Feature Detection
51 //**************************************
52 // 32 or 64 bits ?
53 #if (defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) \
54 || defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) \
55 || defined(__64BIT__) || defined(_LP64) || defined(__LP64__) \
56 || defined(__ia64) || defined(__itanium__) || defined(_M_IA64) ) // Detects 64 bits mode
57 # define LZ4_ARCH64 1
58 #else
59 # define LZ4_ARCH64 0
60 #endif
61
62 // Little Endian or Big Endian ?
63 // Overwrite the #define below if you know your architecture endianess
64 #if defined (__GLIBC__)
65 # include <endian.h>
66 # if (__BYTE_ORDER == __BIG_ENDIAN)
67 # define LZ4_BIG_ENDIAN 1
68 # endif
69 #elif (defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN)) && !(defined(__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN) || defined(_LITTLE_ENDIAN))
70 # define LZ4_BIG_ENDIAN 1
71 #elif defined(__sparc) || defined(__sparc__) \
72 || defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) \
73 || defined(__hpux) || defined(__hppa) \
74 || defined(_MIPSEB) || defined(__s390__)
75 # define LZ4_BIG_ENDIAN 1
76 #else
77 // Little Endian assumed. PDP Endian and other very rare endian format are unsupported.
78 #endif
79
80 // Unaligned memory access is automatically enabled for "common" CPU, such as x86.
81 // For others CPU, such as ARM, the compiler may be more cautious, inserting unnecessary extra code to ensure aligned access property
82 // If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance
83 #if defined(__ARM_FEATURE_UNALIGNED)
84 # define LZ4_FORCE_UNALIGNED_ACCESS 1
85 #endif
86
87 // Define this parameter if your target system or compiler does not support hardware bit count
88 #if defined(_MSC_VER) && defined(_WIN32_WCE) // Visual Studio for Windows CE does not support Hardware bit count
89 # define LZ4_FORCE_SW_BITCOUNT
90 #endif
91
92 // BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE :
93 // This option may provide a small boost to performance for some big endian cpu, although probably modest.
94 // You may set this option to 1 if data will remain within closed environment.
95 // This option is useless on Little_Endian CPU (such as x86)
96 //#define BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE 1
97
98
99 //**************************************
100 // Compiler Options
101 //**************************************
102 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) // C99
103 /* "restrict" is a known keyword */
104 #else
105 # define restrict // Disable restrict
106 #endif
107
108 #ifdef _MSC_VER // Visual Studio
109 # define FORCE_INLINE static __forceinline
110 # include <intrin.h> // For Visual 2005
111 # if LZ4_ARCH64 // 64-bits
112 # pragma intrinsic(_BitScanForward64) // For Visual 2005
113 # pragma intrinsic(_BitScanReverse64) // For Visual 2005
114 # else // 32-bits
115 # pragma intrinsic(_BitScanForward) // For Visual 2005
116 # pragma intrinsic(_BitScanReverse) // For Visual 2005
117 # endif
118 # pragma warning(disable : 4127) // disable: C4127: conditional expression is constant
119 #else
120 # ifdef __GNUC__
121 # define FORCE_INLINE static inline __attribute__((always_inline))
122 # else
123 # define FORCE_INLINE static inline
124 # endif
125 #endif
126
127 #ifdef _MSC_VER
128 # define lz4_bswap16(x) _byteswap_ushort(x)
129 #else
130 # define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
131 #endif
132
133 #define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
134
135 #if (GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__)
136 # define expect(expr,value) (__builtin_expect ((expr),(value)) )
137 #else
138 # define expect(expr,value) (expr)
139 #endif
140
141 #define likely(expr) expect((expr) != 0, 1)
142 #define unlikely(expr) expect((expr) != 0, 0)
143
144
145 //**************************************
146 // Memory routines
147 //**************************************
148 #include <stdlib.h> // malloc, calloc, free
149 #define ALLOCATOR(n,s) calloc(n,s)
150 #define FREEMEM free
151 #include <string.h> // memset, memcpy
152 #define MEM_INIT memset
153
154
155 //**************************************
156 // Includes
157 //**************************************
158 #include "lz4.h"
159
160
161 //**************************************
162 // Basic Types
163 //**************************************
164 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L // C99
165 # include <stdint.h>
166 typedef uint8_t BYTE;
167 typedef uint16_t U16;
168 typedef uint32_t U32;
169 typedef int32_t S32;
170 typedef uint64_t U64;
171 #else
172 typedef unsigned char BYTE;
173 typedef unsigned short U16;
174 typedef unsigned int U32;
175 typedef signed int S32;
176 typedef unsigned long long U64;
177 #endif
178
179 #if defined(__GNUC__) && !defined(LZ4_FORCE_UNALIGNED_ACCESS)
180 # define _PACKED __attribute__ ((packed))
181 #else
182 # define _PACKED
183 #endif
184
185 #if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__)
186 # if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
187 # pragma pack(1)
188 # else
189 # pragma pack(push, 1)
190 # endif
191 #endif
192
193 typedef struct { U16 v; } _PACKED U16_S;
194 typedef struct { U32 v; } _PACKED U32_S;
195 typedef struct { U64 v; } _PACKED U64_S;
196 typedef struct {size_t v;} _PACKED size_t_S;
197
198 #if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__)
199 # if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
200 # pragma pack(0)
201 # else
202 # pragma pack(pop)
203 # endif
204 #endif
205
206 #define A16(x) (((U16_S *)(x))->v)
207 #define A32(x) (((U32_S *)(x))->v)
208 #define A64(x) (((U64_S *)(x))->v)
209 #define AARCH(x) (((size_t_S *)(x))->v)
210
211
212 //**************************************
213 // Constants
214 //**************************************
215 #define LZ4_HASHLOG (MEMORY_USAGE-2)
216 #define HASHTABLESIZE (1 << MEMORY_USAGE)
217 #define HASHNBCELLS4 (1 << LZ4_HASHLOG)
218
219 #define MINMATCH 4
220
221 #define COPYLENGTH 8
222 #define LASTLITERALS 5
223 #define MFLIMIT (COPYLENGTH+MINMATCH)
224 const int LZ4_minLength = (MFLIMIT+1);
225
226 #define LZ4_64KLIMIT ((1<<16) + (MFLIMIT-1))
227 #define SKIPSTRENGTH 6 // Increasing this value will make the compression run slower on incompressible data
228
229 #define MAXD_LOG 16
230 #define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
231
232 #define ML_BITS 4
233 #define ML_MASK ((1U<<ML_BITS)-1)
234 #define RUN_BITS (8-ML_BITS)
235 #define RUN_MASK ((1U<<RUN_BITS)-1)
236
237 #define KB *(1U<<10)
238 #define MB *(1U<<20)
239 #define GB *(1U<<30)
240
241
242 //**************************************
243 // Structures and local types
244 //**************************************
245
246 typedef struct {
247 U32 hashTable[HASHNBCELLS4];
248 const BYTE* bufferStart;
249 const BYTE* base;
250 const BYTE* nextBlock;
251 } LZ4_Data_Structure;
252
253 typedef enum { notLimited = 0, limited = 1 } limitedOutput_directive;
254 typedef enum { byPtr, byU32, byU16 } tableType_t;
255
256 typedef enum { noPrefix = 0, withPrefix = 1 } prefix64k_directive;
257
258 typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive;
259 typedef enum { full = 0, partial = 1 } earlyEnd_directive;
260
261
262 //**************************************
263 // Architecture-specific macros
264 //**************************************
265 #define STEPSIZE sizeof(size_t)
266 #define LZ4_COPYSTEP(d,s) { AARCH(d) = AARCH(s); d+=STEPSIZE; s+=STEPSIZE; }
267 #define LZ4_COPY8(d,s) { LZ4_COPYSTEP(d,s); if (STEPSIZE<8) LZ4_COPYSTEP(d,s); }
268 #define LZ4_SECURECOPY(d,s,e) { if ((STEPSIZE==4)||(d<e)) LZ4_WILDCOPY(d,s,e); }
269
270 #if LZ4_ARCH64 // 64-bit
271 # define HTYPE U32
272 # define INITBASE(base) const BYTE* const base = ip
273 #else // 32-bit
274 # define HTYPE const BYTE*
275 # define INITBASE(base) const int base = 0
276 #endif
277
278 #if (defined(LZ4_BIG_ENDIAN) && !defined(BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE))
279 # define LZ4_READ_LITTLEENDIAN_16(d,s,p) { U16 v = A16(p); v = lz4_bswap16(v); d = (s) - v; }
280 # define LZ4_WRITE_LITTLEENDIAN_16(p,i) { U16 v = (U16)(i); v = lz4_bswap16(v); A16(p) = v; p+=2; }
281 #else // Little Endian
282 # define LZ4_READ_LITTLEENDIAN_16(d,s,p) { d = (s) - A16(p); }
283 # define LZ4_WRITE_LITTLEENDIAN_16(p,v) { A16(p) = v; p+=2; }
284 #endif
285
286
287 //**************************************
288 // Macros
289 //**************************************
290 #define LZ4_WILDCOPY(d,s,e) { do { LZ4_COPY8(d,s) } while (d<e); } // at the end, d>=e;
291
292
293 //****************************
294 // Private functions
295 //****************************
296 #if LZ4_ARCH64
297
298 FORCE_INLINE int LZ4_NbCommonBytes (register U64 val)
299 {
300 # if defined(LZ4_BIG_ENDIAN)
301 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
302 unsigned long r = 0;
303 _BitScanReverse64( &r, val );
304 return (int)(r>>3);
305 # elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
306 return (__builtin_clzll(val) >> 3);
307 # else
308 int r;
309 if (!(val>>32)) { r=4; } else { r=0; val>>=32; }
310 if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
311 r += (!val);
312 return r;
313 # endif
314 # else
315 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
316 unsigned long r = 0;
317 _BitScanForward64( &r, val );
318 return (int)(r>>3);
319 # elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
320 return (__builtin_ctzll(val) >> 3);
321 # else
322 static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
323 return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
324 # endif
325 # endif
326 }
327
328 #else
329
330 FORCE_INLINE int LZ4_NbCommonBytes (register U32 val)
331 {
332 # if defined(LZ4_BIG_ENDIAN)
333 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
334 unsigned long r = 0;
335 _BitScanReverse( &r, val );
336 return (int)(r>>3);
337 # elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
338 return (__builtin_clz(val) >> 3);
339 # else
340 int r;
341 if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
342 r += (!val);
343 return r;
344 # endif
345 # else
346 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
347 unsigned long r;
348 _BitScanForward( &r, val );
349 return (int)(r>>3);
350 # elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
351 return (__builtin_ctz(val) >> 3);
352 # else
353 static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
354 return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
355 # endif
356 # endif
357 }
358
359 #endif
360
361
362 //****************************
363 // Compression functions
364 //****************************
365 FORCE_INLINE int LZ4_hashSequence(U32 sequence, tableType_t tableType)
366 {
367 if (tableType == byU16)
368 return (((sequence) * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1)));
369 else
370 return (((sequence) * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
371 }
372
373 FORCE_INLINE int LZ4_hashPosition(const BYTE* p, tableType_t tableType) { return LZ4_hashSequence(A32(p), tableType); }
374
375 FORCE_INLINE void LZ4_putPositionOnHash(const BYTE* p, U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase)
376 {
377 switch (tableType)
378 {
379 case byPtr: { const BYTE** hashTable = (const BYTE**) tableBase; hashTable[h] = p; break; }
380 case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); break; }
381 case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); break; }
382 }
383 }
384
385 FORCE_INLINE void LZ4_putPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase)
386 {
387 U32 h = LZ4_hashPosition(p, tableType);
388 LZ4_putPositionOnHash(p, h, tableBase, tableType, srcBase);
389 }
390
391 FORCE_INLINE const BYTE* LZ4_getPositionOnHash(U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase)
392 {
393 if (tableType == byPtr) { const BYTE** hashTable = (const BYTE**) tableBase; return hashTable[h]; }
394 if (tableType == byU32) { U32* hashTable = (U32*) tableBase; return hashTable[h] + srcBase; }
395 { U16* hashTable = (U16*) tableBase; return hashTable[h] + srcBase; } // default, to ensure a return
396 }
397
398 FORCE_INLINE const BYTE* LZ4_getPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase)
399 {
400 U32 h = LZ4_hashPosition(p, tableType);
401 return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase);
402 }
403
404
405 FORCE_INLINE int LZ4_compress_generic(
406 void* ctx,
407 const char* source,
408 char* dest,
409 int inputSize,
410 int maxOutputSize,
411
412 limitedOutput_directive limitedOutput,
413 tableType_t tableType,
414 prefix64k_directive prefix)
415 {
416 const BYTE* ip = (const BYTE*) source;
417 const BYTE* const base = (prefix==withPrefix) ? ((LZ4_Data_Structure*)ctx)->base : (const BYTE*) source;
418 const BYTE* const lowLimit = ((prefix==withPrefix) ? ((LZ4_Data_Structure*)ctx)->bufferStart : (const BYTE*)source);
419 const BYTE* anchor = (const BYTE*) source;
420 const BYTE* const iend = ip + inputSize;
421 const BYTE* const mflimit = iend - MFLIMIT;
422 const BYTE* const matchlimit = iend - LASTLITERALS;
423
424 BYTE* op = (BYTE*) dest;
425 BYTE* const oend = op + maxOutputSize;
426
427 int length;
428 const int skipStrength = SKIPSTRENGTH;
429 U32 forwardH;
430
431 // Init conditions
432 if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; // Unsupported input size, too large (or negative)
433 if ((prefix==withPrefix) && (ip != ((LZ4_Data_Structure*)ctx)->nextBlock)) return 0; // must continue from end of previous block
434 if (prefix==withPrefix) ((LZ4_Data_Structure*)ctx)->nextBlock=iend; // do it now, due to potential early exit
435 if ((tableType == byU16) && (inputSize>=LZ4_64KLIMIT)) return 0; // Size too large (not within 64K limit)
436 if (inputSize<LZ4_minLength) goto _last_literals; // Input too small, no compression (all literals)
437
438 // First Byte
439 LZ4_putPosition(ip, ctx, tableType, base);
440 ip++; forwardH = LZ4_hashPosition(ip, tableType);
441
442 // Main Loop
443 for ( ; ; )
444 {
445 int findMatchAttempts = (1U << skipStrength) + 3;
446 const BYTE* forwardIp = ip;
447 const BYTE* ref;
448 BYTE* token;
449
450 // Find a match
451 do {
452 U32 h = forwardH;
453 int step = findMatchAttempts++ >> skipStrength;
454 ip = forwardIp;
455 forwardIp = ip + step;
456
457 if unlikely(forwardIp > mflimit) { goto _last_literals; }
458
459 forwardH = LZ4_hashPosition(forwardIp, tableType);
460 ref = LZ4_getPositionOnHash(h, ctx, tableType, base);
461 LZ4_putPositionOnHash(ip, h, ctx, tableType, base);
462
463 } while ((ref + MAX_DISTANCE < ip) || (A32(ref) != A32(ip)));
464
465 // Catch up
466 while ((ip>anchor) && (ref > lowLimit) && unlikely(ip[-1]==ref[-1])) { ip--; ref--; }
467
468 // Encode Literal length
469 length = (int)(ip - anchor);
470 token = op++;
471 if ((limitedOutput) && unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) > oend)) return 0; // Check output limit
472 if (length>=(int)RUN_MASK)
473 {
474 int len = length-RUN_MASK;
475 *token=(RUN_MASK<<ML_BITS);
476 for(; len >= 255 ; len-=255) *op++ = 255;
477 *op++ = (BYTE)len;
478 }
479 else *token = (BYTE)(length<<ML_BITS);
480
481 // Copy Literals
482 { BYTE* end=(op)+(length); LZ4_WILDCOPY(op,anchor,end); op=end; }
483
484 _next_match:
485 // Encode Offset
486 LZ4_WRITE_LITTLEENDIAN_16(op,(U16)(ip-ref));
487
488 // Start Counting
489 ip+=MINMATCH; ref+=MINMATCH; // MinMatch already verified
490 anchor = ip;
491 while likely(ip<matchlimit-(STEPSIZE-1))
492 {
493 size_t diff = AARCH(ref) ^ AARCH(ip);
494 if (!diff) { ip+=STEPSIZE; ref+=STEPSIZE; continue; }
495 ip += LZ4_NbCommonBytes(diff);
496 goto _endCount;
497 }
498 if (LZ4_ARCH64) if ((ip<(matchlimit-3)) && (A32(ref) == A32(ip))) { ip+=4; ref+=4; }
499 if ((ip<(matchlimit-1)) && (A16(ref) == A16(ip))) { ip+=2; ref+=2; }
500 if ((ip<matchlimit) && (*ref == *ip)) ip++;
501 _endCount:
502
503 // Encode MatchLength
504 length = (int)(ip - anchor);
505 if ((limitedOutput) && unlikely(op + (1 + LASTLITERALS) + (length>>8) > oend)) return 0; // Check output limit
506 if (length>=(int)ML_MASK)
507 {
508 *token += ML_MASK;
509 length -= ML_MASK;
510 for (; length > 509 ; length-=510) { *op++ = 255; *op++ = 255; }
511 if (length >= 255) { length-=255; *op++ = 255; }
512 *op++ = (BYTE)length;
513 }
514 else *token += (BYTE)(length);
515
516 // Test end of chunk
517 if (ip > mflimit) { anchor = ip; break; }
518
519 // Fill table
520 LZ4_putPosition(ip-2, ctx, tableType, base);
521
522 // Test next position
523 ref = LZ4_getPosition(ip, ctx, tableType, base);
524 LZ4_putPosition(ip, ctx, tableType, base);
525 if ((ref + MAX_DISTANCE >= ip) && (A32(ref) == A32(ip))) { token = op++; *token=0; goto _next_match; }
526
527 // Prepare next loop
528 anchor = ip++;
529 forwardH = LZ4_hashPosition(ip, tableType);
530 }
531
532 _last_literals:
533 // Encode Last Literals
534 {
535 int lastRun = (int)(iend - anchor);
536 if ((limitedOutput) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) return 0; // Check output limit
537 if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun >= 255 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
538 else *op++ = (BYTE)(lastRun<<ML_BITS);
539 memcpy(op, anchor, iend - anchor);
540 op += iend-anchor;
541 }
542
543 // End
544 return (int) (((char*)op)-dest);
545 }
546
547
548 int LZ4_compress(const char* source, char* dest, int inputSize)
549 {
550 #if (HEAPMODE)
551 void* ctx = ALLOCATOR(HASHNBCELLS4, 4); // Aligned on 4-bytes boundaries
552 #else
553 U32 ctx[1U<<(MEMORY_USAGE-2)] = {0}; // Ensure data is aligned on 4-bytes boundaries
554 #endif
555 int result;
556
557 if (inputSize < (int)LZ4_64KLIMIT)
558 result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, byU16, noPrefix);
559 else
560 result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, (sizeof(void*)==8) ? byU32 : byPtr, noPrefix);
561
562 #if (HEAPMODE)
563 FREEMEM(ctx);
564 #endif
565 return result;
566 }
567
568 int LZ4_compress_continue (void* LZ4_Data, const char* source, char* dest, int inputSize)
569 {
570 return LZ4_compress_generic(LZ4_Data, source, dest, inputSize, 0, notLimited, byU32, withPrefix);
571 }
572
573
574 int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize)
575 {
576 #if (HEAPMODE)
577 void* ctx = ALLOCATOR(HASHNBCELLS4, 4); // Aligned on 4-bytes boundaries
578 #else
579 U32 ctx[1U<<(MEMORY_USAGE-2)] = {0}; // Ensure data is aligned on 4-bytes boundaries
580 #endif
581 int result;
582
583 if (inputSize < (int)LZ4_64KLIMIT)
584 result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limited, byU16, noPrefix);
585 else
586 result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limited, (sizeof(void*)==8) ? byU32 : byPtr, noPrefix);
587
588 #if (HEAPMODE)
589 FREEMEM(ctx);
590 #endif
591 return result;
592 }
593
594 int LZ4_compress_limitedOutput_continue (void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize)
595 {
596 return LZ4_compress_generic(LZ4_Data, source, dest, inputSize, maxOutputSize, limited, byU32, withPrefix);
597 }
598
599
600 //****************************
601 // Stream functions
602 //****************************
603
604 FORCE_INLINE void LZ4_init(LZ4_Data_Structure* lz4ds, const BYTE* base)
605 {
606 MEM_INIT(lz4ds->hashTable, 0, sizeof(lz4ds->hashTable));
607 lz4ds->bufferStart = base;
608 lz4ds->base = base;
609 lz4ds->nextBlock = base;
610 }
611
612
613 void* LZ4_create (const char* inputBuffer)
614 {
615 void* lz4ds = ALLOCATOR(1, sizeof(LZ4_Data_Structure));
616 LZ4_init ((LZ4_Data_Structure*)lz4ds, (const BYTE*)inputBuffer);
617 return lz4ds;
618 }
619
620
621 int LZ4_free (void* LZ4_Data)
622 {
623 FREEMEM(LZ4_Data);
624 return (0);
625 }
626
627
628 char* LZ4_slideInputBuffer (void* LZ4_Data)
629 {
630 LZ4_Data_Structure* lz4ds = (LZ4_Data_Structure*)LZ4_Data;
631 size_t delta = lz4ds->nextBlock - (lz4ds->bufferStart + 64 KB);
632
633 if ( (lz4ds->base - delta > lz4ds->base) // underflow control
634 || ((size_t)(lz4ds->nextBlock - lz4ds->base) > 0xE0000000) ) // close to 32-bits limit
635 {
636 size_t deltaLimit = (lz4ds->nextBlock - 64 KB) - lz4ds->base;
637 int nH;
638
639 for (nH=0; nH < HASHNBCELLS4; nH++)
640 {
641 if ((size_t)(lz4ds->hashTable[nH]) < deltaLimit) lz4ds->hashTable[nH] = 0;
642 else lz4ds->hashTable[nH] -= (U32)deltaLimit;
643 }
644 memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
645 lz4ds->base = lz4ds->bufferStart;
646 lz4ds->nextBlock = lz4ds->base + 64 KB;
647 }
648 else
649 {
650 memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
651 lz4ds->nextBlock -= delta;
652 lz4ds->base -= delta;
653 }
654
655 return (char*)(lz4ds->nextBlock);
656 }
657
658
659 //****************************
660 // Decompression functions
661 //****************************
662
663 // This generic decompression function cover all use cases.
664 // It shall be instanciated several times, using different sets of directives
665 // Note that it is essential this generic function is really inlined,
666 // in order to remove useless branches during compilation optimisation.
667 FORCE_INLINE int LZ4_decompress_generic(
668 const char* source,
669 char* dest,
670 int inputSize, //
671 int outputSize, // If endOnInput==endOnInputSize, this value is the max size of Output Buffer.
672
673 int endOnInput, // endOnOutputSize, endOnInputSize
674 int prefix64k, // noPrefix, withPrefix
675 int partialDecoding, // full, partial
676 int targetOutputSize // only used if partialDecoding==partial
677 )
678 {
679 // Local Variables
680 const BYTE* restrict ip = (const BYTE*) source;
681 const BYTE* ref;
682 const BYTE* const iend = ip + inputSize;
683
684 BYTE* op = (BYTE*) dest;
685 BYTE* const oend = op + outputSize;
686 BYTE* cpy;
687 BYTE* oexit = op + targetOutputSize;
688
689 const size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; // static reduces speed for LZ4_decompress_safe() on GCC64
690 static const size_t dec64table[] = {0, 0, 0, (size_t)-1, 0, 1, 2, 3};
691
692
693 // Special cases
694 if ((partialDecoding) && (oexit> oend-MFLIMIT)) oexit = oend-MFLIMIT; // targetOutputSize too high => decode everything
695 if ((endOnInput) && unlikely(outputSize==0)) return ((inputSize==1) && (*ip==0)) ? 0 : -1; // Empty output buffer
696 if ((!endOnInput) && unlikely(outputSize==0)) return (*ip==0?1:-1);
697
698
699 // Main Loop
700 while (1)
701 {
702 unsigned token;
703 size_t length;
704
705 // get runlength
706 token = *ip++;
707 if ((length=(token>>ML_BITS)) == RUN_MASK)
708 {
709 unsigned s=255;
710 while (((endOnInput)?ip<iend:1) && (s==255))
711 {
712 s = *ip++;
713 length += s;
714 }
715 }
716
717 // copy literals
718 cpy = op+length;
719 if (((endOnInput) && ((cpy>(partialDecoding?oexit:oend-MFLIMIT)) || (ip+length>iend-(2+1+LASTLITERALS))) )
720 || ((!endOnInput) && (cpy>oend-COPYLENGTH)))
721 {
722 if (partialDecoding)
723 {
724 if (cpy > oend) goto _output_error; // Error : write attempt beyond end of output buffer
725 if ((endOnInput) && (ip+length > iend)) goto _output_error; // Error : read attempt beyond end of input buffer
726 }
727 else
728 {
729 if ((!endOnInput) && (cpy != oend)) goto _output_error; // Error : block decoding must stop exactly there
730 if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error; // Error : input must be consumed
731 }
732 memcpy(op, ip, length);
733 ip += length;
734 op += length;
735 break; // Necessarily EOF, due to parsing restrictions
736 }
737 LZ4_WILDCOPY(op, ip, cpy); ip -= (op-cpy); op = cpy;
738
739 // get offset
740 LZ4_READ_LITTLEENDIAN_16(ref,cpy,ip); ip+=2;
741 if ((prefix64k==noPrefix) && unlikely(ref < (BYTE* const)dest)) goto _output_error; // Error : offset outside destination buffer
742
743 // get matchlength
744 if ((length=(token&ML_MASK)) == ML_MASK)
745 {
746 while ((!endOnInput) || (ip<iend-(LASTLITERALS+1))) // Ensure enough bytes remain for LASTLITERALS + token
747 {
748 unsigned s = *ip++;
749 length += s;
750 if (s==255) continue;
751 break;
752 }
753 }
754
755 // copy repeated sequence
756 if unlikely((op-ref)<(int)STEPSIZE)
757 {
758 const size_t dec64 = dec64table[(sizeof(void*)==4) ? 0 : op-ref];
759 op[0] = ref[0];
760 op[1] = ref[1];
761 op[2] = ref[2];
762 op[3] = ref[3];
763 op += 4, ref += 4; ref -= dec32table[op-ref];
764 A32(op) = A32(ref);
765 op += STEPSIZE-4; ref -= dec64;
766 } else { LZ4_COPYSTEP(op,ref); }
767 cpy = op + length - (STEPSIZE-4);
768
769 if unlikely(cpy>oend-COPYLENGTH-(STEPSIZE-4))
770 {
771 if (cpy > oend-LASTLITERALS) goto _output_error; // Error : last 5 bytes must be literals
772 LZ4_SECURECOPY(op, ref, (oend-COPYLENGTH));
773 while(op<cpy) *op++=*ref++;
774 op=cpy;
775 continue;
776 }
777 LZ4_WILDCOPY(op, ref, cpy);
778 op=cpy; // correction
779 }
780
781 // end of decoding
782 if (endOnInput)
783 return (int) (((char*)op)-dest); // Nb of output bytes decoded
784 else
785 return (int) (((char*)ip)-source); // Nb of input bytes read
786
787 // Overflow error detected
788 _output_error:
789 return (int) (-(((char*)ip)-source))-1;
790 }
791
792
793 int LZ4_decompress_safe(const char* source, char* dest, int inputSize, int maxOutputSize)
794 {
795 return LZ4_decompress_generic(source, dest, inputSize, maxOutputSize, endOnInputSize, noPrefix, full, 0);
796 }
797
798 int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int inputSize, int maxOutputSize)
799 {
800 return LZ4_decompress_generic(source, dest, inputSize, maxOutputSize, endOnInputSize, withPrefix, full, 0);
801 }
802
803 int LZ4_decompress_safe_partial(const char* source, char* dest, int inputSize, int targetOutputSize, int maxOutputSize)
804 {
805 return LZ4_decompress_generic(source, dest, inputSize, maxOutputSize, endOnInputSize, noPrefix, partial, targetOutputSize);
806 }
807
808 int LZ4_decompress_fast_withPrefix64k(const char* source, char* dest, int outputSize)
809 {
810 return LZ4_decompress_generic(source, dest, 0, outputSize, endOnOutputSize, withPrefix, full, 0);
811 }
812
813 int LZ4_decompress_fast(const char* source, char* dest, int outputSize)
814 {
815 #ifdef _MSC_VER // This version is faster with Visual
816 return LZ4_decompress_generic(source, dest, 0, outputSize, endOnOutputSize, noPrefix, full, 0);
817 #else
818 return LZ4_decompress_generic(source, dest, 0, outputSize, endOnOutputSize, withPrefix, full, 0);
819 #endif
820 }
821
0 /*
1 LZ4 - Fast LZ compression algorithm
2 Header File
3 Copyright (C) 2011-2013, Yann Collet.
4 BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are
8 met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following disclaimer
14 in the documentation and/or other materials provided with the
15 distribution.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 You can contact the author at :
30 - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
31 - LZ4 source repository : http://code.google.com/p/lz4/
32 */
33 #pragma once
34
35 #if defined (__cplusplus)
36 extern "C" {
37 #endif
38
39
40 //**************************************
41 // Compiler Options
42 //**************************************
43 #if defined(_MSC_VER) && !defined(__cplusplus) // Visual Studio
44 # define inline __inline // Visual C is not C99, but supports some kind of inline
45 #endif
46
47
48 //****************************
49 // Simple Functions
50 //****************************
51
52 int LZ4_compress (const char* source, char* dest, int inputSize);
53 int LZ4_decompress_safe (const char* source, char* dest, int inputSize, int maxOutputSize);
54
55 /*
56 LZ4_compress() :
57 Compresses 'inputSize' bytes from 'source' into 'dest'.
58 Destination buffer must be already allocated,
59 and must be sized to handle worst cases situations (input data not compressible)
60 Worst case size evaluation is provided by function LZ4_compressBound()
61 inputSize : Max supported value is LZ4_MAX_INPUT_VALUE
62 return : the number of bytes written in buffer dest
63 or 0 if the compression fails
64
65 LZ4_decompress_safe() :
66 maxOutputSize : is the size of the destination buffer (which must be already allocated)
67 return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
68 If the source stream is detected malformed, the function will stop decoding and return a negative result.
69 This function is protected against buffer overflow exploits (never writes outside of output buffer, and never reads outside of input buffer). Therefore, it is protected against malicious data packets
70 */
71
72
73 //****************************
74 // Advanced Functions
75 //****************************
76 #define LZ4_MAX_INPUT_SIZE 0x7E000000 // 2 113 929 216 bytes
77 #define LZ4_COMPRESSBOUND(isize) ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
78 static inline int LZ4_compressBound(int isize) { return LZ4_COMPRESSBOUND(isize); }
79
80 /*
81 LZ4_compressBound() :
82 Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible)
83 primarily useful for memory allocation of output buffer.
84 inline function is recommended for the general case,
85 macro is also provided when result needs to be evaluated at compilation (such as stack memory allocation).
86
87 isize : is the input size. Max supported value is LZ4_MAX_INPUT_SIZE
88 return : maximum output size in a "worst case" scenario
89 or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE)
90 */
91
92
93 int LZ4_compress_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
94
95 /*
96 LZ4_compress_limitedOutput() :
97 Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
98 If it cannot achieve it, compression will stop, and result of the function will be zero.
99 This function never writes outside of provided output buffer.
100
101 inputSize : Max supported value is LZ4_MAX_INPUT_VALUE
102 maxOutputSize : is the size of the destination buffer (which must be already allocated)
103 return : the number of bytes written in buffer 'dest'
104 or 0 if the compression fails
105 */
106
107
108 int LZ4_decompress_fast (const char* source, char* dest, int outputSize);
109
110 /*
111 LZ4_decompress_fast() :
112 outputSize : is the original (uncompressed) size
113 return : the number of bytes read from the source buffer (in other words, the compressed size)
114 If the source stream is malformed, the function will stop decoding and return a negative result.
115 note : This function is a bit faster than LZ4_decompress_safe()
116 This function never writes outside of output buffers, but may read beyond input buffer in case of malicious data packet.
117 Use this function preferably into a trusted environment (data to decode comes from a trusted source).
118 Destination buffer must be already allocated. Its size must be a minimum of 'outputSize' bytes.
119 */
120
121 int LZ4_decompress_safe_partial (const char* source, char* dest, int inputSize, int targetOutputSize, int maxOutputSize);
122
123 /*
124 LZ4_decompress_safe_partial() :
125 This function decompress a compressed block of size 'inputSize' at position 'source'
126 into output buffer 'dest' of size 'maxOutputSize'.
127 The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached,
128 reducing decompression time.
129 return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
130 Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller.
131 Always control how many bytes were decoded.
132 If the source stream is detected malformed, the function will stop decoding and return a negative result.
133 This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
134 */
135
136
137 //****************************
138 // Stream Functions
139 //****************************
140
141 void* LZ4_create (const char* inputBuffer);
142 int LZ4_compress_continue (void* LZ4_Data, const char* source, char* dest, int inputSize);
143 int LZ4_compress_limitedOutput_continue (void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
144 char* LZ4_slideInputBuffer (void* LZ4_Data);
145 int LZ4_free (void* LZ4_Data);
146
147 /*
148 These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.
149 In order to achieve this, it is necessary to start creating the LZ4 Data Structure, thanks to the function :
150
151 void* LZ4_create (const char* inputBuffer);
152 The result of the function is the (void*) pointer on the LZ4 Data Structure.
153 This pointer will be needed in all other functions.
154 If the pointer returned is NULL, then the allocation has failed, and compression must be aborted.
155 The only parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer.
156 The input buffer must be already allocated, and size at least 192KB.
157 'inputBuffer' will also be the 'const char* source' of the first block.
158
159 All blocks are expected to lay next to each other within the input buffer, starting from 'inputBuffer'.
160 To compress each block, use either LZ4_compress_continue() or LZ4_compress_limitedOutput_continue().
161 Their behavior are identical to LZ4_compress() or LZ4_compress_limitedOutput(),
162 but require the LZ4 Data Structure as their first argument, and check that each block starts right after the previous one.
163 If next block does not begin immediately after the previous one, the compression will fail (return 0).
164
165 When it's no longer possible to lay the next block after the previous one (not enough space left into input buffer), a call to :
166 char* LZ4_slideInputBuffer(void* LZ4_Data);
167 must be performed. It will typically copy the latest 64KB of input at the beginning of input buffer.
168 Note that, for this function to work properly, minimum size of an input buffer must be 192KB.
169 ==> The memory position where the next input data block must start is provided as the result of the function.
170
171 Compression can then resume, using LZ4_compress_continue() or LZ4_compress_limitedOutput_continue(), as usual.
172
173 When compression is completed, a call to LZ4_free() will release the memory used by the LZ4 Data Structure.
174 */
175
176
177 int LZ4_decompress_safe_withPrefix64k (const char* source, char* dest, int inputSize, int maxOutputSize);
178 int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int outputSize);
179
180 /*
181 *_withPrefix64k() :
182 These decoding functions work the same as their "normal name" versions,
183 but can use up to 64KB of data in front of 'char* dest'.
184 These functions are necessary to decode inter-dependant blocks.
185 */
186
187
188 //****************************
189 // Obsolete Functions
190 //****************************
191
192 static inline int LZ4_uncompress (const char* source, char* dest, int outputSize) { return LZ4_decompress_fast(source, dest, outputSize); }
193 static inline int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize) { return LZ4_decompress_safe(source, dest, isize, maxOutputSize); }
194
195 /*
196 These functions are deprecated and should no longer be used.
197 They are provided here for compatibility with existing user programs.
198 */
199
200
201
202 #if defined (__cplusplus)
203 }
204 #endif
00 /*
1 * Copyright (c) 2003-2009 Tony Bybell.
1 * Copyright (c) 2003-2013 Tony Bybell.
22 *
33 * Permission is hereby granted, free of charge, to any person obtaining a
44 * copy of this software and associated documentation files (the "Software"),
3737 "Usage: %s [OPTION]... [FSTFILE]\n\n"
3838 " -f, --fstname=FILE specify FST input filename\n"
3939 " -o, --output=FILE specify output filename\n"
40 " -e, --extensions emit FST extensions to VCD\n"
4041 " -h, --help display this help then exit\n\n"
4142 "VCD is emitted to stdout if output filename is unspecified.\n\n"
4243 "Report bugs to <"PACKAGE_BUGREPORT">.\n",nam);
4546 "Usage: %s [OPTION]... [FSTFILE]\n\n"
4647 " -f specify FST input filename\n"
4748 " -o specify output filename\n"
49 " -e emit FST extensions to VCD\n"
4850 " -h display this help then exit\n\n"
4951 "VCD is emitted to stdout if output filename is unspecified.\n\n"
5052 "Report bugs to <"PACKAGE_BUGREPORT">.\n",nam);
6365 int c;
6466 struct fstReaderContext *xc;
6567 FILE *fv;
68 int use_extensions = 0;
6669
6770 WAVE_LOCALE_FIX
6871
7376
7477 static struct option long_options[] =
7578 {
79 {"extensions", 0, 0, 'e'},
7680 {"fstname", 1, 0, 'f'},
7781 {"output", 1, 0, 'o'},
7882 {"help", 0, 0, 'h'},
7983 {0, 0, 0, 0}
8084 };
8185
82 c = getopt_long (argc, argv, "f:o:h", long_options, &option_index);
86 c = getopt_long (argc, argv, "ef:o:h", long_options, &option_index);
8387 #else
84 c = getopt (argc, argv, "f:o:h");
88 c = getopt (argc, argv, "ef:o:h");
8589 #endif
8690
8791 if (c == -1) break; /* no more args */
8892
8993 switch (c)
9094 {
95 case 'e':
96 use_extensions = 1;
97 break;
98
9199 case 'f':
92100 if(fstname) free(fstname);
93101 fstname = malloc(strlen(optarg)+1);
166174 fv = stdout;
167175 }
168176
177 fstReaderSetVcdExtensions(xc, use_extensions); /* TRUE is incompatible with vfast and other tools */
169178 if(!fstReaderProcessHier(xc, fv)) /* these 3 lines do all the VCD writing work */
170179 {
171180 fprintf(stderr, "could not process hierarchy for '%s', exiting.\n", fstname);
4141 #endif
4242 #endif
4343
44 #if defined(VCD2FST_EXTLOAD_CONV) || defined(VCD2FST_EXT2LOAD_CONV)
44 #ifdef EXT3LOAD_SUFFIX
45 #ifdef EXT3CONV_PATH
46 #define VCD2FST_EXT3LOAD_CONV
47 #endif
48 #endif
49
50 #if defined(VCD2FST_EXTLOAD_CONV) || defined(VCD2FST_EXT2LOAD_CONV) || defined(VCD2FST_EXT3LOAD_CONV)
4551 #define VCD2FST_EXTLOADERS_CONV
4652 #endif
4753
411417 return(val);
412418 }
413419
414 int pack_type = 0; /* set to 1 for fastlz */
420 int pack_type = FST_WR_PT_ZLIB; /* set to fstWriterPackType */
415421 int repack_all = 0; /* 0 is normal, 1 does the repack (via fstapi) at end */
416422 int parallel_mode = 0; /* 0 is is single threaded, 1 is multi-threaded */
417423
477483 }
478484 else
479485 #endif
486 #ifdef VCD2FST_EXT3LOAD_CONV
487 if(suffix_check(vname, "."EXT3LOAD_SUFFIX))
488 {
489 sprintf(bin_fixbuff, EXT3CONV_PATH" %s", vname);
490 f = popen(bin_fixbuff, "r");
491 is_popen = 1;
492 }
493 else
494 #endif
480495 {
481496 f = fopen(vname, "rb");
482497 }
15241539 void print_help(char *nam)
15251540 {
15261541 #ifdef VCD2FST_EXTLOADERS_CONV
1527 #if defined(VCD2FST_EXTLOAD_CONV) && defined(VCD2FST_EXT2LOAD_CONV)
1528
1529 int slen = strlen(EXTLOAD_SUFFIX) + 1 + strlen(EXT2LOAD_SUFFIX);
1530 char *ucase_ext = calloc(1, slen+1);
1542
1543 int slen;
1544 char *ucase_ext = calloc(1, 1024);
15311545 int i;
15321546
1533 sprintf(ucase_ext, "%s/%s", EXTLOAD_SUFFIX, EXT2LOAD_SUFFIX);
1547 ucase_ext[0] = 0;
1548
1549 #if defined(VCD2FST_EXTLOAD_CONV)
1550 strcat(ucase_ext, "/");
1551 strcat(ucase_ext, EXTLOAD_SUFFIX);
1552 #endif
1553
1554 #if defined(VCD2FST_EXT2LOAD_CONV)
1555 strcat(ucase_ext, "/");
1556 strcat(ucase_ext, EXT2LOAD_SUFFIX);
1557 #endif
1558
1559 #if defined(VCD2FST_EXT3LOAD_CONV)
1560 strcat(ucase_ext, "/");
1561 strcat(ucase_ext, EXT3LOAD_SUFFIX);
1562 #endif
1563
1564 slen = strlen(ucase_ext);
15341565
15351566 for(i=0;i<slen;i++)
15361567 {
15371568 ucase_ext[i] = toupper(ucase_ext[i]);
15381569 }
15391570
1540 #else
1541 #ifdef VCD2FST_EXTLOAD_CONV
1542 int slen = strlen(EXTLOAD_SUFFIX);
1543 char *ucase_ext = calloc(1, slen+1);
1544 int i;
1545
1546 for(i=0;i<slen;i++)
1547 {
1548 ucase_ext[i] = toupper(EXTLOAD_SUFFIX[i]);
1549 }
1550 #endif
1551 #ifdef VCD2FST_EXT2LOAD_CONV
1552 int slen = strlen(EXT2LOAD_SUFFIX);
1553 char *ucase_ext = calloc(1, slen+1);
1554 int i;
1555
1556 for(i=0;i<slen;i++)
1557 {
1558 ucase_ext[i] = toupper(EXT2LOAD_SUFFIX[i]);
1559 }
1560 #endif
1561 #endif
1562
1563 #endif
1564
1565
1566
1567
1571 #endif
15681572
15691573
15701574 #ifdef __linux__
15711575 printf(
15721576 "Usage: %s [OPTION]... [VCDFILE] [FSTFILE]\n\n"
15731577 #ifdef VCD2FST_EXTLOADERS_CONV
1574 " -v, --vcdname=FILE specify VCD/%s input filename\n"
1578 " -v, --vcdname=FILE specify VCD%s input filename\n"
15751579 #else
15761580 " -v, --vcdname=FILE specify VCD input filename\n"
15771581 #endif
15781582 " -f, --fstname=FILE specify FST output filename\n"
15791583 " -F, --fastpack use fastlz algorithm for speed\n"
1584 " -4, --fourpack use lz4 algorithm for speed\n"
15801585 " -c, --compress compress entire file on close\n"
15811586 " -p, --parallel enable parallel mode\n"
15821587 " -h, --help display this help then exit\n\n"
15921597 printf(
15931598 "Usage: %s [OPTION]... [VCDFILE] [FSTFILE]\n\n"
15941599 #ifdef VCD2FST_EXTLOADERS_CONV
1595 " -v FILE specify VCD/%s input filename\n"
1600 " -v FILE specify VCD%s input filename\n"
15961601 #else
15971602 " -v FILE specify VCD input filename\n"
15981603 #endif
15991604 " -f FILE specify FST output filename\n"
16001605 " -F use fastlz algorithm for speed\n"
1606 " -4 use lz4 algorithm for speed\n"
16011607 " -c compress entire file on close\n"
16021608 " -p enable parallel mode\n"
16031609 " -h display this help then exit\n\n"
16371643 {"vcdname", 1, 0, 'v'},
16381644 {"fstname", 1, 0, 'f'},
16391645 {"fastpack", 0, 0, 'F'},
1646 {"fourpack", 0, 0, '4'},
16401647 {"compress", 0, 0, 'c'},
16411648 {"parallel", 0, 0, 'p'},
16421649 {"help", 0, 0, 'h'},
16431650 {0, 0, 0, 0}
16441651 };
16451652
1646 c = getopt_long (argc, argv, "v:f:Fcph", long_options, &option_index);
1653 c = getopt_long (argc, argv, "v:f:F4cph", long_options, &option_index);
16471654 #else
1648 c = getopt (argc, argv, "v:f:Fcph");
1655 c = getopt (argc, argv, "v:f:F4cph");
16491656 #endif
16501657
16511658 if (c == -1) break; /* no more args */
16651672 break;
16661673
16671674 case 'F':
1668 pack_type = 1;
1675 if(pack_type == FST_WR_PT_ZLIB)
1676 {
1677 pack_type = FST_WR_PT_FASTLZ;
1678 }
1679 break;
1680
1681 case '4':
1682 pack_type = FST_WR_PT_LZ4;
16691683 break;
16701684
16711685 case 'c':
158158 EXTDEBUG = @EXTDEBUG@
159159 EXTDEBUG2 = @EXTDEBUG2@
160160 EXTDEBUG3 = @EXTDEBUG3@
161 EXTDEBUG4 = @EXTDEBUG4@
161162 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
162163 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
163164 FSDB_CFLAGS = @FSDB_CFLAGS@
200201 LTLIBOBJS = @LTLIBOBJS@
201202 MAINT = @MAINT@
202203 MAKEINFO = @MAKEINFO@
204 MINGW_LDADD = @MINGW_LDADD@
203205 MKDIR_P = @MKDIR_P@
204206 OBJEXT = @OBJEXT@
205207 PACKAGE = @PACKAGE@
156156 EXTDEBUG = @EXTDEBUG@
157157 EXTDEBUG2 = @EXTDEBUG2@
158158 EXTDEBUG3 = @EXTDEBUG3@
159 EXTDEBUG4 = @EXTDEBUG4@
159160 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
160161 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
161162 FSDB_CFLAGS = @FSDB_CFLAGS@
198199 LTLIBOBJS = @LTLIBOBJS@
199200 MAINT = @MAINT@
200201 MAKEINFO = @MAKEINFO@
202 MINGW_LDADD = @MINGW_LDADD@
201203 MKDIR_P = @MKDIR_P@
202204 OBJEXT = @OBJEXT@
203205 PACKAGE = @PACKAGE@
161161 EXTDEBUG = @EXTDEBUG@
162162 EXTDEBUG2 = @EXTDEBUG2@
163163 EXTDEBUG3 = @EXTDEBUG3@
164 EXTDEBUG4 = @EXTDEBUG4@
164165 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
165166 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
166167 FSDB_CFLAGS = @FSDB_CFLAGS@
203204 LTLIBOBJS = @LTLIBOBJS@
204205 MAINT = @MAINT@
205206 MAKEINFO = @MAKEINFO@
207 MINGW_LDADD = @MINGW_LDADD@
206208 MKDIR_P = @MKDIR_P@
207209 OBJEXT = @OBJEXT@
208210 PACKAGE = @PACKAGE@
00 ZLIB DATA COMPRESSION LIBRARY
11
2 zlib 1.2.1 is a general purpose data compression library. All the code is
2 zlib 1.2.8 is a general purpose data compression library. All the code is
33 thread safe. The data format used by the zlib library is described by RFCs
44 (Request for Comments) 1950 to 1952 in the files
5 http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
6 and rfc1952.txt (gzip format). These documents are also available in other
7 formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
5 http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
6 rfc1952 (gzip format).
87
98 All functions of the compression library are documented in the file zlib.h
10 (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
11 of the library is given in the file example.c which also tests that the library
12 is working correctly. Another example is given in the file minigzip.c. The
13 compression library itself is composed of all source files except example.c and
14 minigzip.c.
9 (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
10 of the library is given in the file test/example.c which also tests that
11 the library is working correctly. Another example is given in the file
12 test/minigzip.c. The compression library itself is composed of all source
13 files in the root directory.
1514
1615 To compile all files and run the test program, follow the instructions given at
17 the top of Makefile. In short "make test; make install" should work for most
18 machines. For Unix: "./configure; make test; make install" For MSDOS, use one
19 of the special makefiles such as Makefile.msc. For VMS, use Make_vms.com or
20 descrip.mms.
16 the top of Makefile.in. In short "./configure; make test", and if that goes
17 well, "make install" should work for most flavors of Unix. For Windows, use
18 one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
19 make_vms.com.
2120
2221 Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
23 <info@winimage.com> for the Windows DLL version. The zlib home page is
24 http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
25 please check this site to verify that you have the latest version of zlib;
26 otherwise get the latest version and check whether the problem still exists or
27 not.
22 <info@winimage.com> for the Windows DLL version. The zlib home page is
23 http://zlib.net/ . Before reporting a problem, please check this site to
24 verify that you have the latest version of zlib; otherwise get the latest
25 version and check whether the problem still exists or not.
2826
29 PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
30 for help.
27 PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
3128
32 Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
33 issue of Dr. Dobb's Journal; a copy of the article is available in
34 http://dogma.net/markn/articles/zlibtool/zlibtool.htm
29 Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
30 issue of Dr. Dobb's Journal; a copy of the article is available at
31 http://marknelson.us/1997/01/01/zlib-engine/ .
3532
36 The changes made in version 1.2.1 are documented in the file ChangeLog.
33 The changes made in version 1.2.8 are documented in the file ChangeLog.
3734
38 Unsupported third party contributions are provided in directory "contrib".
35 Unsupported third party contributions are provided in directory contrib/ .
3936
40 A Java implementation of zlib is available in the Java Development Kit
41 http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
42 See the zlib home page http://www.zlib.org for details.
37 zlib is available in Java using the java.util.zip package, documented at
38 http://java.sun.com/developer/technicalArticles/Programming/compression/ .
4339
44 A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
45 CPAN (Comprehensive Perl Archive Network) sites
46 http://www.cpan.org/modules/by-module/Compress/
40 A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
41 at CPAN (Comprehensive Perl Archive Network) sites, including
42 http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
4743
48 A Python interface to zlib written by A.M. Kuchling <amk@magnet.com> is
44 A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
4945 available in Python 1.5 and later versions, see
50 http://www.python.org/doc/lib/module-zlib.html
46 http://docs.python.org/library/zlib.html .
5147
52 A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
53 availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
48 zlib is built into tcl: http://wiki.tcl.tk/4610 .
5449
5550 An experimental package to read and write files in .zip format, written on top
5651 of zlib by Gilles Vollant <info@winimage.com>, is available in the
7469 - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
7570 other compilers. Use "make test" to check your compiler.
7671
77 - gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
72 - gzdopen is not supported on RISCOS or BEOS.
7873
7974 - For PalmOs, see http://palmzlib.sourceforge.net/
80
81 - When building a shared, i.e. dynamic library on Mac OS X, the library must be
82 installed before testing (do "make install" before "make test"), since the
83 library location is specified in the library.
8475
8576
8677 Acknowledgments:
8778
88 The deflate format used by zlib was defined by Phil Katz. The deflate
89 and zlib specifications were written by L. Peter Deutsch. Thanks to all the
90 people who reported problems and suggested various improvements in zlib;
91 they are too numerous to cite here.
79 The deflate format used by zlib was defined by Phil Katz. The deflate and
80 zlib specifications were written by L. Peter Deutsch. Thanks to all the
81 people who reported problems and suggested various improvements in zlib; they
82 are too numerous to cite here.
9283
9384 Copyright notice:
9485
95 (C) 1995-2003 Jean-loup Gailly and Mark Adler
86 (C) 1995-2013 Jean-loup Gailly and Mark Adler
9687
9788 This software is provided 'as-is', without any express or implied
9889 warranty. In no event will the authors be held liable for any damages
113104 Jean-loup Gailly Mark Adler
114105 jloup@gzip.org madler@alumni.caltech.edu
115106
116 If you use the zlib library in a product, we would appreciate *not*
117 receiving lengthy legal documents to sign. The sources are provided
118 for free but without warranty of any kind. The library has been
119 entirely written by Jean-loup Gailly and Mark Adler; it does not
120 include third-party code.
107 If you use the zlib library in a product, we would appreciate *not* receiving
108 lengthy legal documents to sign. The sources are provided for free but without
109 warranty of any kind. The library has been entirely written by Jean-loup
110 Gailly and Mark Adler; it does not include third-party code.
121111
122 If you redistribute modified sources, we would appreciate that you include
123 in the file ChangeLog history information documenting your changes. Please
124 read the FAQ for more information on the distribution of modified source
125 versions.
112 If you redistribute modified sources, we would appreciate that you include in
113 the file ChangeLog history information documenting your changes. Please read
114 the FAQ for more information on the distribution of modified source versions.
00 /* adler32.c -- compute the Adler-32 checksum of a data stream
1 * Copyright (C) 1995-2007 Mark Adler
1 * Copyright (C) 1995-2011 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
5 /* @(#) $Id: adler32.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
5 /* @(#) $Id$ */
66
77 #include "zutil.h"
88
99 #define local static
1010
11 local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
11 local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
1212
13 #define BASE 65521UL /* largest prime smaller than 65536 */
13 #define BASE 65521 /* largest prime smaller than 65536 */
1414 #define NMAX 5552
1515 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
1616
2020 #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
2121 #define DO16(buf) DO8(buf,0); DO8(buf,8);
2222
23 /* use NO_DIVIDE if your processor does not do division in hardware */
23 /* use NO_DIVIDE if your processor does not do division in hardware --
24 try it both ways to see which is faster */
2425 #ifdef NO_DIVIDE
26 /* note that this assumes BASE is 65521, where 65536 % 65521 == 15
27 (thank you to John Reiser for pointing this out) */
28 # define CHOP(a) \
29 do { \
30 unsigned long tmp = a >> 16; \
31 a &= 0xffffUL; \
32 a += (tmp << 4) - tmp; \
33 } while (0)
34 # define MOD28(a) \
35 do { \
36 CHOP(a); \
37 if (a >= BASE) a -= BASE; \
38 } while (0)
2539 # define MOD(a) \
2640 do { \
27 if (a >= (BASE << 16)) a -= (BASE << 16); \
28 if (a >= (BASE << 15)) a -= (BASE << 15); \
29 if (a >= (BASE << 14)) a -= (BASE << 14); \
30 if (a >= (BASE << 13)) a -= (BASE << 13); \
31 if (a >= (BASE << 12)) a -= (BASE << 12); \
32 if (a >= (BASE << 11)) a -= (BASE << 11); \
33 if (a >= (BASE << 10)) a -= (BASE << 10); \
34 if (a >= (BASE << 9)) a -= (BASE << 9); \
35 if (a >= (BASE << 8)) a -= (BASE << 8); \
36 if (a >= (BASE << 7)) a -= (BASE << 7); \
37 if (a >= (BASE << 6)) a -= (BASE << 6); \
38 if (a >= (BASE << 5)) a -= (BASE << 5); \
39 if (a >= (BASE << 4)) a -= (BASE << 4); \
40 if (a >= (BASE << 3)) a -= (BASE << 3); \
41 if (a >= (BASE << 2)) a -= (BASE << 2); \
42 if (a >= (BASE << 1)) a -= (BASE << 1); \
43 if (a >= BASE) a -= BASE; \
41 CHOP(a); \
42 MOD28(a); \
4443 } while (0)
45 # define MOD4(a) \
46 do { \
47 if (a >= (BASE << 4)) a -= (BASE << 4); \
48 if (a >= (BASE << 3)) a -= (BASE << 3); \
49 if (a >= (BASE << 2)) a -= (BASE << 2); \
50 if (a >= (BASE << 1)) a -= (BASE << 1); \
44 # define MOD63(a) \
45 do { /* this assumes a is not negative */ \
46 z_off64_t tmp = a >> 32; \
47 a &= 0xffffffffL; \
48 a += (tmp << 8) - (tmp << 5) + tmp; \
49 tmp = a >> 16; \
50 a &= 0xffffL; \
51 a += (tmp << 4) - tmp; \
52 tmp = a >> 16; \
53 a &= 0xffffL; \
54 a += (tmp << 4) - tmp; \
5155 if (a >= BASE) a -= BASE; \
5256 } while (0)
5357 #else
5458 # define MOD(a) a %= BASE
55 # define MOD4(a) a %= BASE
59 # define MOD28(a) a %= BASE
60 # define MOD63(a) a %= BASE
5661 #endif
5762
5863 /* ========================================================================= */
9196 }
9297 if (adler >= BASE)
9398 adler -= BASE;
94 MOD4(sum2); /* only added so many BASE's */
99 MOD28(sum2); /* only added so many BASE's */
95100 return adler | (sum2 << 16);
96101 }
97102
136141 unsigned long sum2;
137142 unsigned rem;
138143
144 /* for negative len, return invalid adler32 as a clue for debugging */
145 if (len2 < 0)
146 return 0xffffffffUL;
147
139148 /* the derivation of this formula is left as an exercise for the reader */
140 rem = (unsigned)(len2 % BASE);
149 MOD63(len2); /* assumes len2 >= 0 */
150 rem = (unsigned)len2;
141151 sum1 = adler1 & 0xffff;
142152 sum2 = rem * sum1;
143153 MOD(sum2);
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
5 /* @(#) $Id: compress.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
5 /* @(#) $Id$ */
66
77 #define ZLIB_INTERNAL
88 #include "zlib.h"
2828 z_stream stream;
2929 int err;
3030
31 stream.next_in = (Bytef*)source;
31 stream.next_in = (z_const Bytef *)source;
3232 stream.avail_in = (uInt)sourceLen;
3333 #ifdef MAXSEG_64K
3434 /* Check for source > 64K on 16-bit machine: */
00 /* crc32.c -- compute the CRC-32 of a data stream
1 * Copyright (C) 1995-2006, 2010 Mark Adler
1 * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 *
44 * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
88 * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
99 */
1010
11 /* @(#) $Id: crc32.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
11 /* @(#) $Id$ */
1212
1313 /*
1414 Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
1616 of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
1717 first call get_crc_table() to initialize the tables before allowing more than
1818 one thread to use crc32().
19
20 DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
1921 */
2022
2123 #ifdef MAKECRCH
2931
3032 #define local static
3133
32 /* Find a four-byte integer type for crc32_little() and crc32_big(). */
33 #ifndef NOBYFOUR
34 # ifdef STDC /* need ANSI C limits.h to determine sizes */
35 # include <limits.h>
36 # define BYFOUR
37 # if (UINT_MAX == 0xffffffffUL)
38 typedef unsigned int u4;
39 # else
40 # if (ULONG_MAX == 0xffffffffUL)
41 typedef unsigned long u4;
42 # else
43 # if (USHRT_MAX == 0xffffffffUL)
44 typedef unsigned short u4;
45 # else
46 # undef BYFOUR /* can't find a four-byte integer type! */
47 # endif
48 # endif
49 # endif
50 # endif /* STDC */
51 #endif /* !NOBYFOUR */
52
5334 /* Definitions for doing the crc four data bytes at a time. */
35 #if !defined(NOBYFOUR) && defined(Z_U4)
36 # define BYFOUR
37 #endif
5438 #ifdef BYFOUR
55 # define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
56 (((w)&0xff00)<<8)+(((w)&0xff)<<24))
5739 local unsigned long crc32_little OF((unsigned long,
5840 const unsigned char FAR *, unsigned));
5941 local unsigned long crc32_big OF((unsigned long,
6749 local unsigned long gf2_matrix_times OF((unsigned long *mat,
6850 unsigned long vec));
6951 local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
70 local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
52 local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
7153
7254
7355 #ifdef DYNAMIC_CRC_TABLE
7456
7557 local volatile int crc_table_empty = 1;
76 local unsigned long FAR crc_table[TBLS][256];
58 local z_crc_t FAR crc_table[TBLS][256];
7759 local void make_crc_table OF((void));
7860 #ifdef MAKECRCH
79 local void write_table OF((FILE *, const unsigned long FAR *));
61 local void write_table OF((FILE *, const z_crc_t FAR *));
8062 #endif /* MAKECRCH */
8163 /*
8264 Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
10688 */
10789 local void make_crc_table()
10890 {
109 unsigned long c;
91 z_crc_t c;
11092 int n, k;
111 unsigned long poly; /* polynomial exclusive-or pattern */
93 z_crc_t poly; /* polynomial exclusive-or pattern */
11294 /* terms of polynomial defining this crc (except x^32): */
11395 static volatile int first = 1; /* flag to limit concurrent making */
11496 static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
120102 first = 0;
121103
122104 /* make exclusive-or pattern from polynomial (0xedb88320UL) */
123 poly = 0UL;
124 for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
125 poly |= 1UL << (31 - p[n]);
105 poly = 0;
106 for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
107 poly |= (z_crc_t)1 << (31 - p[n]);
126108
127109 /* generate a crc for every 8-bit value */
128110 for (n = 0; n < 256; n++) {
129 c = (unsigned long)n;
111 c = (z_crc_t)n;
130112 for (k = 0; k < 8; k++)
131113 c = c & 1 ? poly ^ (c >> 1) : c >> 1;
132114 crc_table[0][n] = c;
137119 and then the byte reversal of those as well as the first table */
138120 for (n = 0; n < 256; n++) {
139121 c = crc_table[0][n];
140 crc_table[4][n] = REV(c);
122 crc_table[4][n] = ZSWAP32(c);
141123 for (k = 1; k < 4; k++) {
142124 c = crc_table[0][c & 0xff] ^ (c >> 8);
143125 crc_table[k][n] = c;
144 crc_table[k + 4][n] = REV(c);
126 crc_table[k + 4][n] = ZSWAP32(c);
145127 }
146128 }
147129 #endif /* BYFOUR */
163145 if (out == NULL) return;
164146 fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
165147 fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
166 fprintf(out, "local const unsigned long FAR ");
148 fprintf(out, "local const z_crc_t FAR ");
167149 fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
168150 write_table(out, crc_table[0]);
169151 # ifdef BYFOUR
183165 #ifdef MAKECRCH
184166 local void write_table(out, table)
185167 FILE *out;
186 const unsigned long FAR *table;
168 const z_crc_t FAR *table;
187169 {
188170 int n;
189171
190172 for (n = 0; n < 256; n++)
191 fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
173 fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
174 (unsigned long)(table[n]),
192175 n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
193176 }
194177 #endif /* MAKECRCH */
203186 /* =========================================================================
204187 * This function can be used by asm versions of crc32()
205188 */
206 const unsigned long FAR * ZEXPORT get_crc_table()
189 const z_crc_t FAR * ZEXPORT get_crc_table()
207190 {
208191 #ifdef DYNAMIC_CRC_TABLE
209192 if (crc_table_empty)
210193 make_crc_table();
211194 #endif /* DYNAMIC_CRC_TABLE */
212 return (const unsigned long FAR *)crc_table;
195 return (const z_crc_t FAR *)crc_table;
213196 }
214197
215198 /* ========================================================================= */
231214
232215 #ifdef BYFOUR
233216 if (sizeof(void *) == sizeof(ptrdiff_t)) {
234 u4 endian;
217 z_crc_t endian;
235218
236219 endian = 1;
237220 if (*((unsigned char *)(&endian)))
265248 const unsigned char FAR *buf;
266249 unsigned len;
267250 {
268 register u4 c;
269 register const u4 FAR *buf4;
270
271 c = (u4)crc;
251 register z_crc_t c;
252 register const z_crc_t FAR *buf4;
253
254 c = (z_crc_t)crc;
272255 c = ~c;
273256 while (len && ((ptrdiff_t)buf & 3)) {
274257 c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
275258 len--;
276259 }
277260
278 buf4 = (const u4 FAR *)(const void FAR *)buf;
261 buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
279262 while (len >= 32) {
280263 DOLIT32;
281264 len -= 32;
305288 const unsigned char FAR *buf;
306289 unsigned len;
307290 {
308 register u4 c;
309 register const u4 FAR *buf4;
310
311 c = REV((u4)crc);
291 register z_crc_t c;
292 register const z_crc_t FAR *buf4;
293
294 c = ZSWAP32((z_crc_t)crc);
312295 c = ~c;
313296 while (len && ((ptrdiff_t)buf & 3)) {
314297 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
315298 len--;
316299 }
317300
318 buf4 = (const u4 FAR *)(const void FAR *)buf;
301 buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
319302 buf4--;
320303 while (len >= 32) {
321304 DOBIG32;
332315 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
333316 } while (--len);
334317 c = ~c;
335 return (unsigned long)(REV(c));
318 return (unsigned long)(ZSWAP32(c));
336319 }
337320
338321 #endif /* BYFOUR */
11 * Generated automatically by crc32.c
22 */
33
4 local const unsigned long FAR crc_table[TBLS][256] =
4 local const z_crc_t FAR crc_table[TBLS][256] =
55 {
66 {
77 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
00 /* deflate.c -- compress data using the deflation algorithm
1 * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
1 * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
3636 * REFERENCES
3737 *
3838 * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
39 * Available in http://www.ietf.org/rfc/rfc1951.txt
39 * Available in http://tools.ietf.org/html/rfc1951
4040 *
4141 * A description of the Rabin and Karp algorithm is given in the book
4242 * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
4646 *
4747 */
4848
49 /* @(#) $Id: deflate.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
49 /* @(#) $Id$ */
5050
5151 #include "deflate.h"
5252
5353 const char deflate_copyright[] =
54 " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
54 " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
5555 /*
5656 If you use the zlib library in a product, an acknowledgment is welcome
5757 in the documentation of your product. If for some reason you cannot
154154 struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
155155 #endif
156156
157 /* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
158 #define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
159
157160 /* ===========================================================================
158161 * Update a hash value with the given input byte
159162 * IN assertion: all calls to to UPDATE_HASH are made with consecutive
234237
235238 strm->msg = Z_NULL;
236239 if (strm->zalloc == (alloc_func)0) {
240 #ifdef Z_SOLO
241 return Z_STREAM_ERROR;
242 #else
237243 strm->zalloc = zcalloc;
238244 strm->opaque = (voidpf)0;
239 }
240 if (strm->zfree == (free_func)0) strm->zfree = zcfree;
245 #endif
246 }
247 if (strm->zfree == (free_func)0)
248 #ifdef Z_SOLO
249 return Z_STREAM_ERROR;
250 #else
251 strm->zfree = zcfree;
252 #endif
241253
242254 #ifdef FASTEST
243255 if (level != 0) level = 1;
292304 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
293305 s->pending_buf == Z_NULL) {
294306 s->status = FINISH_STATE;
295 strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
307 strm->msg = ERR_MSG(Z_MEM_ERROR);
296308 deflateEnd (strm);
297309 return Z_MEM_ERROR;
298310 }
313325 uInt dictLength;
314326 {
315327 deflate_state *s;
316 uInt length = dictLength;
317 uInt n;
318 IPos hash_head = 0;
319
320 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
321 strm->state->wrap == 2 ||
322 (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
328 uInt str, n;
329 int wrap;
330 unsigned avail;
331 z_const unsigned char *next;
332
333 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
323334 return Z_STREAM_ERROR;
324
325335 s = strm->state;
326 if (s->wrap)
336 wrap = s->wrap;
337 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
338 return Z_STREAM_ERROR;
339
340 /* when using zlib wrappers, compute Adler-32 for provided dictionary */
341 if (wrap == 1)
327342 strm->adler = adler32(strm->adler, dictionary, dictLength);
328
329 if (length < MIN_MATCH) return Z_OK;
330 if (length > s->w_size) {
331 length = s->w_size;
332 dictionary += dictLength - length; /* use the tail of the dictionary */
333 }
334 zmemcpy(s->window, dictionary, length);
335 s->strstart = length;
336 s->block_start = (long)length;
337
338 /* Insert all strings in the hash table (except for the last two bytes).
339 * s->lookahead stays null, so s->ins_h will be recomputed at the next
340 * call of fill_window.
341 */
342 s->ins_h = s->window[0];
343 UPDATE_HASH(s, s->ins_h, s->window[1]);
344 for (n = 0; n <= length - MIN_MATCH; n++) {
345 INSERT_STRING(s, n, hash_head);
346 }
347 if (hash_head) hash_head = 0; /* to make compiler happy */
343 s->wrap = 0; /* avoid computing Adler-32 in read_buf */
344
345 /* if dictionary would fill window, just replace the history */
346 if (dictLength >= s->w_size) {
347 if (wrap == 0) { /* already empty otherwise */
348 CLEAR_HASH(s);
349 s->strstart = 0;
350 s->block_start = 0L;
351 s->insert = 0;
352 }
353 dictionary += dictLength - s->w_size; /* use the tail */
354 dictLength = s->w_size;
355 }
356
357 /* insert dictionary into window and hash */
358 avail = strm->avail_in;
359 next = strm->next_in;
360 strm->avail_in = dictLength;
361 strm->next_in = (z_const Bytef *)dictionary;
362 fill_window(s);
363 while (s->lookahead >= MIN_MATCH) {
364 str = s->strstart;
365 n = s->lookahead - (MIN_MATCH-1);
366 do {
367 UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
368 #ifndef FASTEST
369 s->prev[str & s->w_mask] = s->head[s->ins_h];
370 #endif
371 s->head[s->ins_h] = (Pos)str;
372 str++;
373 } while (--n);
374 s->strstart = str;
375 s->lookahead = MIN_MATCH-1;
376 fill_window(s);
377 }
378 s->strstart += s->lookahead;
379 s->block_start = (long)s->strstart;
380 s->insert = s->lookahead;
381 s->lookahead = 0;
382 s->match_length = s->prev_length = MIN_MATCH-1;
383 s->match_available = 0;
384 strm->next_in = next;
385 strm->avail_in = avail;
386 s->wrap = wrap;
348387 return Z_OK;
349388 }
350389
351390 /* ========================================================================= */
352 int ZEXPORT deflateReset (strm)
391 int ZEXPORT deflateResetKeep (strm)
353392 z_streamp strm;
354393 {
355394 deflate_state *s;
379418 s->last_flush = Z_NO_FLUSH;
380419
381420 _tr_init(s);
382 lm_init(s);
383421
384422 return Z_OK;
423 }
424
425 /* ========================================================================= */
426 int ZEXPORT deflateReset (strm)
427 z_streamp strm;
428 {
429 int ret;
430
431 ret = deflateResetKeep(strm);
432 if (ret == Z_OK)
433 lm_init(strm->state);
434 return ret;
385435 }
386436
387437 /* ========================================================================= */
392442 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
393443 if (strm->state->wrap != 2) return Z_STREAM_ERROR;
394444 strm->state->gzhead = head;
445 return Z_OK;
446 }
447
448 /* ========================================================================= */
449 int ZEXPORT deflatePending (strm, pending, bits)
450 unsigned *pending;
451 int *bits;
452 z_streamp strm;
453 {
454 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
455 if (pending != Z_NULL)
456 *pending = strm->state->pending;
457 if (bits != Z_NULL)
458 *bits = strm->state->bi_valid;
395459 return Z_OK;
396460 }
397461
401465 int bits;
402466 int value;
403467 {
468 deflate_state *s;
469 int put;
470
404471 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
405 strm->state->bi_valid = bits;
406 strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
472 s = strm->state;
473 if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
474 return Z_BUF_ERROR;
475 do {
476 put = Buf_size - s->bi_valid;
477 if (put > bits)
478 put = bits;
479 s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
480 s->bi_valid += put;
481 _tr_flush_bits(s);
482 value >>= put;
483 bits -= put;
484 } while (bits);
407485 return Z_OK;
408486 }
409487
434512 strm->total_in != 0) {
435513 /* Flush the last buffer: */
436514 err = deflate(strm, Z_BLOCK);
515 if (err == Z_BUF_ERROR && s->pending == 0)
516 err = Z_OK;
437517 }
438518 if (s->level != level) {
439519 s->level = level;
561641 local void flush_pending(strm)
562642 z_streamp strm;
563643 {
564 unsigned len = strm->state->pending;
565
644 unsigned len;
645 deflate_state *s = strm->state;
646
647 _tr_flush_bits(s);
648 len = s->pending;
566649 if (len > strm->avail_out) len = strm->avail_out;
567650 if (len == 0) return;
568651
569 zmemcpy(strm->next_out, strm->state->pending_out, len);
652 zmemcpy(strm->next_out, s->pending_out, len);
570653 strm->next_out += len;
571 strm->state->pending_out += len;
654 s->pending_out += len;
572655 strm->total_out += len;
573656 strm->avail_out -= len;
574 strm->state->pending -= len;
575 if (strm->state->pending == 0) {
576 strm->state->pending_out = strm->state->pending_buf;
657 s->pending -= len;
658 if (s->pending == 0) {
659 s->pending_out = s->pending_buf;
577660 }
578661 }
579662
800883 * flushes. For repeated and useless calls with Z_FINISH, we keep
801884 * returning Z_STREAM_END instead of Z_BUF_ERROR.
802885 */
803 } else if (strm->avail_in == 0 && flush <= old_flush &&
886 } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
804887 flush != Z_FINISH) {
805888 ERR_RETURN(strm, Z_BUF_ERROR);
806889 }
849932 if (s->lookahead == 0) {
850933 s->strstart = 0;
851934 s->block_start = 0L;
935 s->insert = 0;
852936 }
853937 }
854938 }
9441028
9451029 ss = source->state;
9461030
947 zmemcpy(dest, source, sizeof(z_stream));
1031 zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
9481032
9491033 ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
9501034 if (ds == Z_NULL) return Z_MEM_ERROR;
9511035 dest->state = (struct internal_state FAR *) ds;
952 zmemcpy(ds, ss, sizeof(deflate_state));
1036 zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
9531037 ds->strm = dest;
9541038
9551039 ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
9651049 }
9661050 /* following zmemcpy do not work for 16-bit MSDOS */
9671051 zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
968 zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
969 zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
1052 zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
1053 zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
9701054 zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
9711055
9721056 ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
10001084
10011085 strm->avail_in -= len;
10021086
1087 zmemcpy(buf, strm->next_in, len);
10031088 if (strm->state->wrap == 1) {
1004 strm->adler = adler32(strm->adler, strm->next_in, len);
1089 strm->adler = adler32(strm->adler, buf, len);
10051090 }
10061091 #ifdef GZIP
10071092 else if (strm->state->wrap == 2) {
1008 strm->adler = crc32(strm->adler, strm->next_in, len);
1009 }
1010 #endif
1011 zmemcpy(buf, strm->next_in, len);
1093 strm->adler = crc32(strm->adler, buf, len);
1094 }
1095 #endif
10121096 strm->next_in += len;
10131097 strm->total_in += len;
10141098
10351119 s->strstart = 0;
10361120 s->block_start = 0L;
10371121 s->lookahead = 0;
1122 s->insert = 0;
10381123 s->match_length = s->prev_length = MIN_MATCH-1;
10391124 s->match_available = 0;
10401125 s->ins_h = 0;
13091394 unsigned more; /* Amount of free space at the end of the window. */
13101395 uInt wsize = s->w_size;
13111396
1397 Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
1398
13121399 do {
13131400 more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
13141401
13611448 #endif
13621449 more += wsize;
13631450 }
1364 if (s->strm->avail_in == 0) return;
1451 if (s->strm->avail_in == 0) break;
13651452
13661453 /* If there was no sliding:
13671454 * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
13801467 s->lookahead += n;
13811468
13821469 /* Initialize the hash value now that we have some input: */
1383 if (s->lookahead >= MIN_MATCH) {
1384 s->ins_h = s->window[s->strstart];
1385 UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
1470 if (s->lookahead + s->insert >= MIN_MATCH) {
1471 uInt str = s->strstart - s->insert;
1472 s->ins_h = s->window[str];
1473 UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
13861474 #if MIN_MATCH != 3
13871475 Call UPDATE_HASH() MIN_MATCH-3 more times
13881476 #endif
1477 while (s->insert) {
1478 UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
1479 #ifndef FASTEST
1480 s->prev[str & s->w_mask] = s->head[s->ins_h];
1481 #endif
1482 s->head[s->ins_h] = (Pos)str;
1483 str++;
1484 s->insert--;
1485 if (s->lookahead + s->insert < MIN_MATCH)
1486 break;
1487 }
13891488 }
13901489 /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
13911490 * but this is not important since only literal bytes will be emitted.
14261525 s->high_water += init;
14271526 }
14281527 }
1528
1529 Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
1530 "not enough room for search");
14291531 }
14301532
14311533 /* ===========================================================================
15051607 FLUSH_BLOCK(s, 0);
15061608 }
15071609 }
1508 FLUSH_BLOCK(s, flush == Z_FINISH);
1509 return flush == Z_FINISH ? finish_done : block_done;
1610 s->insert = 0;
1611 if (flush == Z_FINISH) {
1612 FLUSH_BLOCK(s, 1);
1613 return finish_done;
1614 }
1615 if ((long)s->strstart > s->block_start)
1616 FLUSH_BLOCK(s, 0);
1617 return block_done;
15101618 }
15111619
15121620 /* ===========================================================================
16021710 }
16031711 if (bflush) FLUSH_BLOCK(s, 0);
16041712 }
1605 FLUSH_BLOCK(s, flush == Z_FINISH);
1606 return flush == Z_FINISH ? finish_done : block_done;
1713 s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
1714 if (flush == Z_FINISH) {
1715 FLUSH_BLOCK(s, 1);
1716 return finish_done;
1717 }
1718 if (s->last_lit)
1719 FLUSH_BLOCK(s, 0);
1720 return block_done;
16071721 }
16081722
16091723 #ifndef FASTEST
17271841 _tr_tally_lit(s, s->window[s->strstart-1], bflush);
17281842 s->match_available = 0;
17291843 }
1730 FLUSH_BLOCK(s, flush == Z_FINISH);
1731 return flush == Z_FINISH ? finish_done : block_done;
1844 s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
1845 if (flush == Z_FINISH) {
1846 FLUSH_BLOCK(s, 1);
1847 return finish_done;
1848 }
1849 if (s->last_lit)
1850 FLUSH_BLOCK(s, 0);
1851 return block_done;
17321852 }
17331853 #endif /* FASTEST */
17341854
17481868 for (;;) {
17491869 /* Make sure that we always have enough lookahead, except
17501870 * at the end of the input file. We need MAX_MATCH bytes
1751 * for the longest encodable run.
1871 * for the longest run, plus one for the unrolled loop.
17521872 */
1753 if (s->lookahead < MAX_MATCH) {
1873 if (s->lookahead <= MAX_MATCH) {
17541874 fill_window(s);
1755 if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
1875 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
17561876 return need_more;
17571877 }
17581878 if (s->lookahead == 0) break; /* flush the current block */
17751895 if (s->match_length > s->lookahead)
17761896 s->match_length = s->lookahead;
17771897 }
1898 Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
17781899 }
17791900
17801901 /* Emit match if have run of MIN_MATCH or longer, else emit literal */
17951916 }
17961917 if (bflush) FLUSH_BLOCK(s, 0);
17971918 }
1798 FLUSH_BLOCK(s, flush == Z_FINISH);
1799 return flush == Z_FINISH ? finish_done : block_done;
1919 s->insert = 0;
1920 if (flush == Z_FINISH) {
1921 FLUSH_BLOCK(s, 1);
1922 return finish_done;
1923 }
1924 if (s->last_lit)
1925 FLUSH_BLOCK(s, 0);
1926 return block_done;
18001927 }
18011928
18021929 /* ===========================================================================
18281955 s->strstart++;
18291956 if (bflush) FLUSH_BLOCK(s, 0);
18301957 }
1831 FLUSH_BLOCK(s, flush == Z_FINISH);
1832 return flush == Z_FINISH ? finish_done : block_done;
1833 }
1958 s->insert = 0;
1959 if (flush == Z_FINISH) {
1960 FLUSH_BLOCK(s, 1);
1961 return finish_done;
1962 }
1963 if (s->last_lit)
1964 FLUSH_BLOCK(s, 0);
1965 return block_done;
1966 }
00 /* deflate.h -- internal compression state
1 * Copyright (C) 1995-2010 Jean-loup Gailly
1 * Copyright (C) 1995-2012 Jean-loup Gailly
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
77 subject to change. Applications should only use zlib.h.
88 */
99
10 /* @(#) $Id: deflate.h,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
10 /* @(#) $Id$ */
1111
1212 #ifndef DEFLATE_H
1313 #define DEFLATE_H
4646
4747 #define MAX_BITS 15
4848 /* All codes must not exceed MAX_BITS bits */
49
50 #define Buf_size 16
51 /* size of bit buffer in bi_buf */
4952
5053 #define INIT_STATE 42
5154 #define EXTRA_STATE 69
100103 int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
101104 gz_headerp gzhead; /* gzip header information to write */
102105 uInt gzindex; /* where in extra, name, or comment */
103 Byte method; /* STORED (for zip only) or DEFLATED */
106 Byte method; /* can only be DEFLATED */
104107 int last_flush; /* value of flush param for previous deflate call */
105108
106109 /* used by deflate.c: */
187190 int nice_match; /* Stop searching when current match exceeds this */
188191
189192 /* used by trees.c: */
190 /* Didn't use ct_data typedef below to supress compiler warning */
193 /* Didn't use ct_data typedef below to suppress compiler warning */
191194 struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
192195 struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
193196 struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
243246 ulg opt_len; /* bit length of current block with optimal trees */
244247 ulg static_len; /* bit length of current block with static trees */
245248 uInt matches; /* number of string matches in current block */
246 int last_eob_len; /* bit length of EOB code for last block */
249 uInt insert; /* bytes at end of window left to insert */
247250
248251 #ifdef DEBUG
249252 ulg compressed_len; /* total bit length of compressed file mod 2^32 */
293296 int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
294297 void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
295298 ulg stored_len, int last));
299 void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
296300 void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
297301 void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
298302 ulg stored_len, int last));
00 /* gzguts.h -- zlib internal header definitions for gz* operations
1 * Copyright (C) 2004, 2005, 2010 Mark Adler
1 * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
1111 # endif
1212 #endif
1313
14 #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
14 #ifdef HAVE_HIDDEN
1515 # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
1616 #else
1717 # define ZLIB_INTERNAL
2626 #endif
2727 #include <fcntl.h>
2828
29 #ifdef _WIN32
30 # include <stddef.h>
31 #endif
32
33 #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
34 # include <io.h>
35 #endif
36
37 #ifdef WINAPI_FAMILY
38 # define open _open
39 # define read _read
40 # define write _write
41 # define close _close
42 #endif
43
2944 #ifdef NO_DEFLATE /* for compatibility with old definition */
3045 # define NO_GZCOMPRESS
3146 #endif
3247
48 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
49 # ifndef HAVE_VSNPRINTF
50 # define HAVE_VSNPRINTF
51 # endif
52 #endif
53
54 #if defined(__CYGWIN__)
55 # ifndef HAVE_VSNPRINTF
56 # define HAVE_VSNPRINTF
57 # endif
58 #endif
59
60 #if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
61 # ifndef HAVE_VSNPRINTF
62 # define HAVE_VSNPRINTF
63 # endif
64 #endif
65
66 #ifndef HAVE_VSNPRINTF
67 # ifdef MSDOS
68 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
69 but for now we just assume it doesn't. */
70 # define NO_vsnprintf
71 # endif
72 # ifdef __TURBOC__
73 # define NO_vsnprintf
74 # endif
75 # ifdef WIN32
76 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
77 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
78 # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
79 # define vsnprintf _vsnprintf
80 # endif
81 # endif
82 # endif
83 # ifdef __SASC
84 # define NO_vsnprintf
85 # endif
86 # ifdef VMS
87 # define NO_vsnprintf
88 # endif
89 # ifdef __OS400__
90 # define NO_vsnprintf
91 # endif
92 # ifdef __MVS__
93 # define NO_vsnprintf
94 # endif
95 #endif
96
97 /* unlike snprintf (which is required in C99, yet still not supported by
98 Microsoft more than a decade later!), _snprintf does not guarantee null
99 termination of the result -- however this is only used in gzlib.c where
100 the result is assured to fit in the space provided */
33101 #ifdef _MSC_VER
34 # include <io.h>
35 # define vsnprintf _vsnprintf
102 # define snprintf _snprintf
36103 #endif
37104
38105 #ifndef local
51118 # include <windows.h>
52119 # define zstrerror() gz_strwinerror((DWORD)GetLastError())
53120 #else
54 # ifdef STDC
121 # ifndef NO_STRERROR
55122 # include <errno.h>
56123 # define zstrerror() strerror(errno)
57124 # else
67134 ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
68135 #endif
69136
70 /* default i/o buffer size -- double this for output when reading */
137 /* default memLevel */
138 #if MAX_MEM_LEVEL >= 8
139 # define DEF_MEM_LEVEL 8
140 #else
141 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
142 #endif
143
144 /* default i/o buffer size -- double this for output when reading (this and
145 twice this must be able to fit in an unsigned type) */
71146 #define GZBUFSIZE 8192
72147
73148 /* gzip modes, also provide a little integrity check on the passed structure */
83158
84159 /* internal gzip file state data structure */
85160 typedef struct {
161 /* exposed contents for gzgetc() macro */
162 struct gzFile_s x; /* "x" for exposed */
163 /* x.have: number of bytes available at x.next */
164 /* x.next: next output data to deliver or write */
165 /* x.pos: current position in uncompressed data */
86166 /* used for both reading and writing */
87167 int mode; /* see gzip modes above */
88168 int fd; /* file descriptor */
89169 char *path; /* path or fd for error messages */
90 z_off64_t pos; /* current position in uncompressed data */
91170 unsigned size; /* buffer size, zero if not allocated yet */
92171 unsigned want; /* requested buffer size, default is GZBUFSIZE */
93172 unsigned char *in; /* input buffer */
94173 unsigned char *out; /* output buffer (double-sized when reading) */
95 unsigned char *next; /* next output data to deliver or write */
174 int direct; /* 0 if processing gzip, 1 if transparent */
96175 /* just for reading */
97 unsigned have; /* amount of output data unused at next */
176 int how; /* 0: get header, 1: copy, 2: decompress */
177 z_off64_t start; /* where the gzip data started, for rewinding */
98178 int eof; /* true if end of input file reached */
99 z_off64_t start; /* where the gzip data started, for rewinding */
100 z_off64_t raw; /* where the raw data started, for seeking */
101 int how; /* 0: get header, 1: copy, 2: decompress */
102 int direct; /* true if last read direct, false if gzip */
179 int past; /* true if read requested past end */
103180 /* just for writing */
104181 int level; /* compression level */
105182 int strategy; /* compression strategy */
00 /* gzlib.c -- zlib functions common to reading and writing gzip files
1 * Copyright (C) 2004, 2010 Mark Adler
1 * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
55 #include "gzguts.h"
66
7 #if defined(_WIN32) && !defined(__BORLANDC__)
8 # define LSEEK _lseeki64
9 #else
710 #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
811 # define LSEEK lseek64
912 #else
1013 # define LSEEK lseek
1114 #endif
15 #endif
1216
1317 /* Local functions */
1418 local void gz_reset OF((gz_statep));
15 local gzFile gz_open OF((const char *, int, const char *));
19 local gzFile gz_open OF((const void *, int, const char *));
1620
1721 #if defined UNDER_CE
1822
7074 local void gz_reset(state)
7175 gz_statep state;
7276 {
77 state->x.have = 0; /* no output data available */
7378 if (state->mode == GZ_READ) { /* for reading ... */
74 state->have = 0; /* no output data available */
7579 state->eof = 0; /* not at end of file */
80 state->past = 0; /* have not read past end yet */
7681 state->how = LOOK; /* look for gzip header */
77 state->direct = 1; /* default for empty file */
7882 }
7983 state->seek = 0; /* no seek request pending */
8084 gz_error(state, Z_OK, NULL); /* clear error */
81 state->pos = 0; /* no uncompressed data yet */
85 state->x.pos = 0; /* no uncompressed data yet */
8286 state->strm.avail_in = 0; /* no input data yet */
8387 }
8488
8589 /* Open a gzip file either by name or file descriptor. */
8690 local gzFile gz_open(path, fd, mode)
87 const char *path;
91 const void *path;
8892 int fd;
8993 const char *mode;
9094 {
9195 gz_statep state;
96 size_t len;
97 int oflag;
98 #ifdef O_CLOEXEC
99 int cloexec = 0;
100 #endif
101 #ifdef O_EXCL
102 int exclusive = 0;
103 #endif
104
105 /* check input */
106 if (path == NULL)
107 return NULL;
92108
93109 /* allocate gzFile structure to return */
94 state = malloc(sizeof(gz_state));
110 state = (gz_statep)malloc(sizeof(gz_state));
95111 if (state == NULL)
96112 return NULL;
97113 state->size = 0; /* no buffers allocated yet */
102118 state->mode = GZ_NONE;
103119 state->level = Z_DEFAULT_COMPRESSION;
104120 state->strategy = Z_DEFAULT_STRATEGY;
121 state->direct = 0;
105122 while (*mode) {
106123 if (*mode >= '0' && *mode <= '9')
107124 state->level = *mode - '0';
123140 return NULL;
124141 case 'b': /* ignore -- will request binary anyway */
125142 break;
143 #ifdef O_CLOEXEC
144 case 'e':
145 cloexec = 1;
146 break;
147 #endif
148 #ifdef O_EXCL
149 case 'x':
150 exclusive = 1;
151 break;
152 #endif
126153 case 'f':
127154 state->strategy = Z_FILTERED;
128155 break;
134161 break;
135162 case 'F':
136163 state->strategy = Z_FIXED;
164 break;
165 case 'T':
166 state->direct = 1;
167 break;
137168 default: /* could consider as an error, but just ignore */
138169 ;
139170 }
146177 return NULL;
147178 }
148179
180 /* can't force transparent read */
181 if (state->mode == GZ_READ) {
182 if (state->direct) {
183 free(state);
184 return NULL;
185 }
186 state->direct = 1; /* for empty file */
187 }
188
149189 /* save the path name for error messages */
150 state->path = malloc(strlen(path) + 1);
190 #ifdef _WIN32
191 if (fd == -2) {
192 len = wcstombs(NULL, path, 0);
193 if (len == (size_t)-1)
194 len = 0;
195 }
196 else
197 #endif
198 len = strlen((const char *)path);
199 state->path = (char *)malloc(len + 1);
151200 if (state->path == NULL) {
152201 free(state);
153202 return NULL;
154203 }
155 strcpy(state->path, path);
156
157 /* open the file with the appropriate mode (or just use fd) */
158 state->fd = fd != -1 ? fd :
159 open(path,
204 #ifdef _WIN32
205 if (fd == -2)
206 if (len)
207 wcstombs(state->path, path, len + 1);
208 else
209 *(state->path) = 0;
210 else
211 #endif
212 #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
213 snprintf(state->path, len + 1, "%s", (const char *)path);
214 #else
215 strcpy(state->path, path);
216 #endif
217
218 /* compute the flags for open() */
219 oflag =
160220 #ifdef O_LARGEFILE
161 O_LARGEFILE |
221 O_LARGEFILE |
162222 #endif
163223 #ifdef O_BINARY
164 O_BINARY |
165 #endif
166 (state->mode == GZ_READ ?
167 O_RDONLY :
168 (O_WRONLY | O_CREAT | (
169 state->mode == GZ_WRITE ?
170 O_TRUNC :
171 O_APPEND))),
172 0666);
224 O_BINARY |
225 #endif
226 #ifdef O_CLOEXEC
227 (cloexec ? O_CLOEXEC : 0) |
228 #endif
229 (state->mode == GZ_READ ?
230 O_RDONLY :
231 (O_WRONLY | O_CREAT |
232 #ifdef O_EXCL
233 (exclusive ? O_EXCL : 0) |
234 #endif
235 (state->mode == GZ_WRITE ?
236 O_TRUNC :
237 O_APPEND)));
238
239 /* open the file with the appropriate flags (or just use fd) */
240 state->fd = fd > -1 ? fd : (
241 #ifdef _WIN32
242 fd == -2 ? _wopen(path, oflag, 0666) :
243 #endif
244 open((const char *)path, oflag, 0666));
173245 if (state->fd == -1) {
174246 free(state->path);
175247 free(state);
215287 char *path; /* identifier for error messages */
216288 gzFile gz;
217289
218 if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
219 return NULL;
290 if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
291 return NULL;
292 #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
293 snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
294 #else
220295 sprintf(path, "<fd:%d>", fd); /* for debugging */
296 #endif
221297 gz = gz_open(path, fd, mode);
222298 free(path);
223299 return gz;
224300 }
225301
226302 /* -- see zlib.h -- */
303 #ifdef _WIN32
304 gzFile ZEXPORT gzopen_w(path, mode)
305 const wchar_t *path;
306 const char *mode;
307 {
308 return gz_open(path, -2, mode);
309 }
310 #endif
311
312 /* -- see zlib.h -- */
227313 int ZEXPORT gzbuffer(file, size)
228314 gzFile file;
229315 unsigned size;
242328 return -1;
243329
244330 /* check and set requested size */
245 if (size == 0)
246 return -1;
331 if (size < 2)
332 size = 2; /* need two bytes to check magic header */
247333 state->want = size;
248334 return 0;
249335 }
260346 state = (gz_statep)file;
261347
262348 /* check that we're reading and that there's no error */
263 if (state->mode != GZ_READ || state->err != Z_OK)
349 if (state->mode != GZ_READ ||
350 (state->err != Z_OK && state->err != Z_BUF_ERROR))
264351 return -1;
265352
266353 /* back up and start over */
288375 return -1;
289376
290377 /* check that there's no error */
291 if (state->err != Z_OK)
378 if (state->err != Z_OK && state->err != Z_BUF_ERROR)
292379 return -1;
293380
294381 /* can only seek from start or relative to current position */
297384
298385 /* normalize offset to a SEEK_CUR specification */
299386 if (whence == SEEK_SET)
300 offset -= state->pos;
387 offset -= state->x.pos;
301388 else if (state->seek)
302389 offset += state->skip;
303390 state->seek = 0;
304391
305392 /* if within raw area while reading, just go there */
306393 if (state->mode == GZ_READ && state->how == COPY &&
307 state->pos + offset >= state->raw) {
308 ret = LSEEK(state->fd, offset - state->have, SEEK_CUR);
394 state->x.pos + offset >= 0) {
395 ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
309396 if (ret == -1)
310397 return -1;
311 state->have = 0;
398 state->x.have = 0;
312399 state->eof = 0;
400 state->past = 0;
313401 state->seek = 0;
314402 gz_error(state, Z_OK, NULL);
315403 state->strm.avail_in = 0;
316 state->pos += offset;
317 return state->pos;
404 state->x.pos += offset;
405 return state->x.pos;
318406 }
319407
320408 /* calculate skip amount, rewinding if needed for back seek when reading */
321409 if (offset < 0) {
322410 if (state->mode != GZ_READ) /* writing -- can't go backwards */
323411 return -1;
324 offset += state->pos;
412 offset += state->x.pos;
325413 if (offset < 0) /* before start of file! */
326414 return -1;
327415 if (gzrewind(file) == -1) /* rewind, then skip to offset */
330418
331419 /* if reading, skip what's in output buffer (one less gzgetc() check) */
332420 if (state->mode == GZ_READ) {
333 n = GT_OFF(state->have) || (z_off64_t)state->have > offset ?
334 (unsigned)offset : state->have;
335 state->have -= n;
336 state->next += n;
337 state->pos += n;
421 n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ?
422 (unsigned)offset : state->x.have;
423 state->x.have -= n;
424 state->x.next += n;
425 state->x.pos += n;
338426 offset -= n;
339427 }
340428
343431 state->seek = 1;
344432 state->skip = offset;
345433 }
346 return state->pos + offset;
434 return state->x.pos + offset;
347435 }
348436
349437 /* -- see zlib.h -- */
372460 return -1;
373461
374462 /* return position */
375 return state->pos + (state->seek ? state->skip : 0);
463 return state->x.pos + (state->seek ? state->skip : 0);
376464 }
377465
378466 /* -- see zlib.h -- */
432520 return 0;
433521
434522 /* return end-of-file state */
435 return state->mode == GZ_READ ?
436 (state->eof && state->strm.avail_in == 0 && state->have == 0) : 0;
523 return state->mode == GZ_READ ? state->past : 0;
437524 }
438525
439526 /* -- see zlib.h -- */
453540 /* return error information */
454541 if (errnum != NULL)
455542 *errnum = state->err;
456 return state->msg == NULL ? "" : state->msg;
543 return state->err == Z_MEM_ERROR ? "out of memory" :
544 (state->msg == NULL ? "" : state->msg);
457545 }
458546
459547 /* -- see zlib.h -- */
470558 return;
471559
472560 /* clear error and end-of-file */
473 if (state->mode == GZ_READ)
561 if (state->mode == GZ_READ) {
474562 state->eof = 0;
563 state->past = 0;
564 }
475565 gz_error(state, Z_OK, NULL);
476566 }
477567
493583 state->msg = NULL;
494584 }
495585
586 /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
587 if (err != Z_OK && err != Z_BUF_ERROR)
588 state->x.have = 0;
589
496590 /* set error code, and if no message, then done */
497591 state->err = err;
498592 if (msg == NULL)
499593 return;
500594
501 /* for an out of memory error, save as static string */
502 if (err == Z_MEM_ERROR) {
503 state->msg = (char *)msg;
595 /* for an out of memory error, return literal string when requested */
596 if (err == Z_MEM_ERROR)
504597 return;
505 }
506598
507599 /* construct error message with path */
508 if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
600 if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) ==
601 NULL) {
509602 state->err = Z_MEM_ERROR;
510 state->msg = (char *)"out of memory";
511603 return;
512604 }
605 #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
606 snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
607 "%s%s%s", state->path, ": ", msg);
608 #else
513609 strcpy(state->msg, state->path);
514610 strcat(state->msg, ": ");
515611 strcat(state->msg, msg);
612 #endif
516613 return;
517614 }
518615
00 /* gzread.c -- zlib functions for reading gzip files
1 * Copyright (C) 2004, 2005, 2010 Mark Adler
1 * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
77 /* Local functions */
88 local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
99 local int gz_avail OF((gz_statep));
10 local int gz_next4 OF((gz_statep, unsigned long *));
11 local int gz_head OF((gz_statep));
10 local int gz_look OF((gz_statep));
1211 local int gz_decomp OF((gz_statep));
13 local int gz_make OF((gz_statep));
12 local int gz_fetch OF((gz_statep));
1413 local int gz_skip OF((gz_statep, z_off64_t));
1514
1615 /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
4544 error, 0 otherwise. Note that the eof flag is set when the end of the input
4645 file is reached, even though there may be unused data in the buffer. Once
4746 that data has been used, no more attempts will be made to read the file.
48 gz_avail() assumes that strm->avail_in == 0. */
47 If strm->avail_in != 0, then the current data is moved to the beginning of
48 the input buffer, and then the remainder of the buffer is loaded with the
49 available data from the input file. */
4950 local int gz_avail(state)
5051 gz_statep state;
5152 {
53 unsigned got;
5254 z_streamp strm = &(state->strm);
5355
54 if (state->err != Z_OK)
56 if (state->err != Z_OK && state->err != Z_BUF_ERROR)
5557 return -1;
5658 if (state->eof == 0) {
57 if (gz_load(state, state->in, state->size,
58 (unsigned *)&(strm->avail_in)) == -1)
59 return -1;
59 if (strm->avail_in) { /* copy what's there to the start */
60 unsigned char *p = state->in;
61 unsigned const char *q = strm->next_in;
62 unsigned n = strm->avail_in;
63 do {
64 *p++ = *q++;
65 } while (--n);
66 }
67 if (gz_load(state, state->in + strm->avail_in,
68 state->size - strm->avail_in, &got) == -1)
69 return -1;
70 strm->avail_in += got;
6071 strm->next_in = state->in;
6172 }
6273 return 0;
6374 }
6475
65 /* Get next byte from input, or -1 if end or error. */
66 #define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \
67 (strm->avail_in == 0 ? -1 : \
68 (strm->avail_in--, *(strm->next_in)++)))
69
70 /* Get a four-byte little-endian integer and return 0 on success and the value
71 in *ret. Otherwise -1 is returned and *ret is not modified. */
72 local int gz_next4(state, ret)
73 gz_statep state;
74 unsigned long *ret;
75 {
76 int ch;
77 unsigned long val;
78 z_streamp strm = &(state->strm);
79
80 val = NEXT();
81 val += (unsigned)NEXT() << 8;
82 val += (unsigned long)NEXT() << 16;
83 ch = NEXT();
84 if (ch == -1)
85 return -1;
86 val += (unsigned long)ch << 24;
87 *ret = val;
88 return 0;
89 }
90
91 /* Look for gzip header, set up for inflate or copy. state->have must be zero.
76 /* Look for gzip header, set up for inflate or copy. state->x.have must be 0.
9277 If this is the first time in, allocate required memory. state->how will be
9378 left unchanged if there is no more input data available, will be set to COPY
9479 if there is no gzip header and direct copying will be performed, or it will
95 be set to GZIP for decompression, and the gzip header will be skipped so
96 that the next available input data is the raw deflate stream. If direct
97 copying, then leftover input data from the input buffer will be copied to
98 the output buffer. In that case, all further file reads will be directly to
99 either the output buffer or a user buffer. If decompressing, the inflate
100 state and the check value will be initialized. gz_head() will return 0 on
101 success or -1 on failure. Failures may include read errors or gzip header
102 errors. */
103 local int gz_head(state)
80 be set to GZIP for decompression. If direct copying, then leftover input
81 data from the input buffer will be copied to the output buffer. In that
82 case, all further file reads will be directly to either the output buffer or
83 a user buffer. If decompressing, the inflate state will be initialized.
84 gz_look() will return 0 on success or -1 on failure. */
85 local int gz_look(state)
10486 gz_statep state;
10587 {
10688 z_streamp strm = &(state->strm);
107 int flags;
108 unsigned len;
10989
11090 /* allocate read buffers and inflate memory */
11191 if (state->size == 0) {
11292 /* allocate buffers */
113 state->in = malloc(state->want);
114 state->out = malloc(state->want << 1);
93 state->in = (unsigned char *)malloc(state->want);
94 state->out = (unsigned char *)malloc(state->want << 1);
11595 if (state->in == NULL || state->out == NULL) {
11696 if (state->out != NULL)
11797 free(state->out);
128108 state->strm.opaque = Z_NULL;
129109 state->strm.avail_in = 0;
130110 state->strm.next_in = Z_NULL;
131 if (inflateInit2(&(state->strm), -15) != Z_OK) { /* raw inflate */
111 if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */
132112 free(state->out);
133113 free(state->in);
134114 state->size = 0;
137117 }
138118 }
139119
140 /* get some data in the input buffer */
141 if (strm->avail_in == 0) {
120 /* get at least the magic bytes in the input buffer */
121 if (strm->avail_in < 2) {
142122 if (gz_avail(state) == -1)
143123 return -1;
144124 if (strm->avail_in == 0)
145125 return 0;
146126 }
147127
148 /* look for the gzip magic header bytes 31 and 139 */
149 if (strm->next_in[0] == 31) {
150 strm->avail_in--;
151 strm->next_in++;
152 if (strm->avail_in == 0 && gz_avail(state) == -1)
153 return -1;
154 if (strm->avail_in && strm->next_in[0] == 139) {
155 /* we have a gzip header, woo hoo! */
156 strm->avail_in--;
157 strm->next_in++;
158
159 /* skip rest of header */
160 if (NEXT() != 8) { /* compression method */
161 gz_error(state, Z_DATA_ERROR, "unknown compression method");
162 return -1;
163 }
164 flags = NEXT();
165 if (flags & 0xe0) { /* reserved flag bits */
166 gz_error(state, Z_DATA_ERROR, "unknown header flags set");
167 return -1;
168 }
169 NEXT(); /* modification time */
170 NEXT();
171 NEXT();
172 NEXT();
173 NEXT(); /* extra flags */
174 NEXT(); /* operating system */
175 if (flags & 4) { /* extra field */
176 len = (unsigned)NEXT();
177 len += (unsigned)NEXT() << 8;
178 while (len--)
179 if (NEXT() < 0)
180 break;
181 }
182 if (flags & 8) /* file name */
183 while (NEXT() > 0)
184 ;
185 if (flags & 16) /* comment */
186 while (NEXT() > 0)
187 ;
188 if (flags & 2) { /* header crc */
189 NEXT();
190 NEXT();
191 }
192 /* an unexpected end of file is not checked for here -- it will be
193 noticed on the first request for uncompressed data */
194
195 /* set up for decompression */
196 inflateReset(strm);
197 strm->adler = crc32(0L, Z_NULL, 0);
198 state->how = GZIP;
199 state->direct = 0;
200 return 0;
201 }
202 else {
203 /* not a gzip file -- save first byte (31) and fall to raw i/o */
204 state->out[0] = 31;
205 state->have = 1;
206 }
207 }
208
209 /* doing raw i/o, save start of raw data for seeking, copy any leftover
210 input to output -- this assumes that the output buffer is larger than
211 the input buffer, which also assures space for gzungetc() */
212 state->raw = state->pos;
213 state->next = state->out;
128 /* look for gzip magic bytes -- if there, do gzip decoding (note: there is
129 a logical dilemma here when considering the case of a partially written
130 gzip file, to wit, if a single 31 byte is written, then we cannot tell
131 whether this is a single-byte file, or just a partially written gzip
132 file -- for here we assume that if a gzip file is being written, then
133 the header will be written in a single operation, so that reading a
134 single byte is sufficient indication that it is not a gzip file) */
135 if (strm->avail_in > 1 &&
136 strm->next_in[0] == 31 && strm->next_in[1] == 139) {
137 inflateReset(strm);
138 state->how = GZIP;
139 state->direct = 0;
140 return 0;
141 }
142
143 /* no gzip header -- if we were decoding gzip before, then this is trailing
144 garbage. Ignore the trailing garbage and finish. */
145 if (state->direct == 0) {
146 strm->avail_in = 0;
147 state->eof = 1;
148 state->x.have = 0;
149 return 0;
150 }
151
152 /* doing raw i/o, copy any leftover input to output -- this assumes that
153 the output buffer is larger than the input buffer, which also assures
154 space for gzungetc() */
155 state->x.next = state->out;
214156 if (strm->avail_in) {
215 memcpy(state->next + state->have, strm->next_in, strm->avail_in);
216 state->have += strm->avail_in;
157 memcpy(state->x.next, strm->next_in, strm->avail_in);
158 state->x.have = strm->avail_in;
217159 strm->avail_in = 0;
218160 }
219161 state->how = COPY;
222164 }
223165
224166 /* Decompress from input to the provided next_out and avail_out in the state.
225 If the end of the compressed data is reached, then verify the gzip trailer
226 check value and length (modulo 2^32). state->have and state->next are set
227 to point to the just decompressed data, and the crc is updated. If the
228 trailer is verified, state->how is reset to LOOK to look for the next gzip
229 stream or raw data, once state->have is depleted. Returns 0 on success, -1
230 on failure. Failures may include invalid compressed data or a failed gzip
231 trailer verification. */
167 On return, state->x.have and state->x.next point to the just decompressed
168 data. If the gzip stream completes, state->how is reset to LOOK to look for
169 the next gzip stream or raw data, once state->x.have is depleted. Returns 0
170 on success, -1 on failure. */
232171 local int gz_decomp(state)
233172 gz_statep state;
234173 {
235 int ret;
174 int ret = Z_OK;
236175 unsigned had;
237 unsigned long crc, len;
238176 z_streamp strm = &(state->strm);
239177
240178 /* fill output buffer up to end of deflate stream */
244182 if (strm->avail_in == 0 && gz_avail(state) == -1)
245183 return -1;
246184 if (strm->avail_in == 0) {
247 gz_error(state, Z_DATA_ERROR, "unexpected end of file");
248 return -1;
185 gz_error(state, Z_BUF_ERROR, "unexpected end of file");
186 break;
249187 }
250188
251189 /* decompress and handle errors */
252190 ret = inflate(strm, Z_NO_FLUSH);
253191 if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
254192 gz_error(state, Z_STREAM_ERROR,
255 "internal error: inflate stream corrupt");
193 "internal error: inflate stream corrupt");
256194 return -1;
257195 }
258196 if (ret == Z_MEM_ERROR) {
261199 }
262200 if (ret == Z_DATA_ERROR) { /* deflate stream invalid */
263201 gz_error(state, Z_DATA_ERROR,
264 strm->msg == NULL ? "compressed data error" : strm->msg);
202 strm->msg == NULL ? "compressed data error" : strm->msg);
265203 return -1;
266204 }
267205 } while (strm->avail_out && ret != Z_STREAM_END);
268206
269 /* update available output and crc check value */
270 state->have = had - strm->avail_out;
271 state->next = strm->next_out - state->have;
272 strm->adler = crc32(strm->adler, state->next, state->have);
273
274 /* check gzip trailer if at end of deflate stream */
275 if (ret == Z_STREAM_END) {
276 if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) {
277 gz_error(state, Z_DATA_ERROR, "unexpected end of file");
278 return -1;
279 }
280 if (crc != strm->adler) {
281 gz_error(state, Z_DATA_ERROR, "incorrect data check");
282 return -1;
283 }
284 if (len != (strm->total_out & 0xffffffffL)) {
285 gz_error(state, Z_DATA_ERROR, "incorrect length check");
286 return -1;
287 }
288 state->how = LOOK; /* ready for next stream, once have is 0 (leave
289 state->direct unchanged to remember how) */
290 }
207 /* update available output */
208 state->x.have = had - strm->avail_out;
209 state->x.next = strm->next_out - state->x.have;
210
211 /* if the gzip stream completed successfully, look for another */
212 if (ret == Z_STREAM_END)
213 state->how = LOOK;
291214
292215 /* good decompression */
293216 return 0;
294217 }
295218
296 /* Make data and put in the output buffer. Assumes that state->have == 0.
219 /* Fetch data and put it in the output buffer. Assumes state->x.have is 0.
297220 Data is either copied from the input file or decompressed from the input
298221 file depending on state->how. If state->how is LOOK, then a gzip header is
299 looked for (and skipped if found) to determine wither to copy or decompress.
300 Returns -1 on error, otherwise 0. gz_make() will leave state->have as COPY
301 or GZIP unless the end of the input file has been reached and all data has
302 been processed. */
303 local int gz_make(state)
222 looked for to determine whether to copy or decompress. Returns -1 on error,
223 otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
224 end of the input file has been reached and all data has been processed. */
225 local int gz_fetch(state)
304226 gz_statep state;
305227 {
306228 z_streamp strm = &(state->strm);
307229
308 if (state->how == LOOK) { /* look for gzip header */
309 if (gz_head(state) == -1)
310 return -1;
311 if (state->have) /* got some data from gz_head() */
230 do {
231 switch(state->how) {
232 case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */
233 if (gz_look(state) == -1)
234 return -1;
235 if (state->how == LOOK)
236 return 0;
237 break;
238 case COPY: /* -> COPY */
239 if (gz_load(state, state->out, state->size << 1, &(state->x.have))
240 == -1)
241 return -1;
242 state->x.next = state->out;
312243 return 0;
313 }
314 if (state->how == COPY) { /* straight copy */
315 if (gz_load(state, state->out, state->size << 1, &(state->have)) == -1)
316 return -1;
317 state->next = state->out;
318 }
319 else if (state->how == GZIP) { /* decompress */
320 strm->avail_out = state->size << 1;
321 strm->next_out = state->out;
322 if (gz_decomp(state) == -1)
323 return -1;
324 }
244 case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */
245 strm->avail_out = state->size << 1;
246 strm->next_out = state->out;
247 if (gz_decomp(state) == -1)
248 return -1;
249 }
250 } while (state->x.have == 0 && (!state->eof || strm->avail_in));
325251 return 0;
326252 }
327253
335261 /* skip over len bytes or reach end-of-file, whichever comes first */
336262 while (len)
337263 /* skip over whatever is in output buffer */
338 if (state->have) {
339 n = GT_OFF(state->have) || (z_off64_t)state->have > len ?
340 (unsigned)len : state->have;
341 state->have -= n;
342 state->next += n;
343 state->pos += n;
264 if (state->x.have) {
265 n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
266 (unsigned)len : state->x.have;
267 state->x.have -= n;
268 state->x.next += n;
269 state->x.pos += n;
344270 len -= n;
345271 }
346272
351277 /* need more data to skip -- load up output buffer */
352278 else {
353279 /* get more output, looking for header if required */
354 if (gz_make(state) == -1)
280 if (gz_fetch(state) == -1)
355281 return -1;
356282 }
357283 return 0;
373299 state = (gz_statep)file;
374300 strm = &(state->strm);
375301
376 /* check that we're reading and that there's no error */
377 if (state->mode != GZ_READ || state->err != Z_OK)
302 /* check that we're reading and that there's no (serious) error */
303 if (state->mode != GZ_READ ||
304 (state->err != Z_OK && state->err != Z_BUF_ERROR))
378305 return -1;
379306
380307 /* since an int is returned, make sure len fits in one, otherwise return
381308 with an error (this avoids the flaw in the interface) */
382309 if ((int)len < 0) {
383 gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
310 gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
384311 return -1;
385312 }
386313
399326 got = 0;
400327 do {
401328 /* first just try copying data from the output buffer */
402 if (state->have) {
403 n = state->have > len ? len : state->have;
404 memcpy(buf, state->next, n);
405 state->next += n;
406 state->have -= n;
329 if (state->x.have) {
330 n = state->x.have > len ? len : state->x.have;
331 memcpy(buf, state->x.next, n);
332 state->x.next += n;
333 state->x.have -= n;
407334 }
408335
409336 /* output buffer empty -- return if we're at the end of the input */
410 else if (state->eof && strm->avail_in == 0)
337 else if (state->eof && strm->avail_in == 0) {
338 state->past = 1; /* tried to read past end */
411339 break;
340 }
412341
413342 /* need output data -- for small len or new stream load up our output
414343 buffer */
415344 else if (state->how == LOOK || len < (state->size << 1)) {
416345 /* get more output, looking for header if required */
417 if (gz_make(state) == -1)
418 return -1;
419 continue; /* no progress yet -- go back to memcpy() above */
346 if (gz_fetch(state) == -1)
347 return -1;
348 continue; /* no progress yet -- go back to copy above */
420349 /* the copy above assures that we will leave with space in the
421350 output buffer, allowing at least one gzungetc() to succeed */
422351 }
423352
424353 /* large len -- read directly into user buffer */
425354 else if (state->how == COPY) { /* read directly */
426 if (gz_load(state, buf, len, &n) == -1)
355 if (gz_load(state, (unsigned char *)buf, len, &n) == -1)
427356 return -1;
428357 }
429358
430359 /* large len -- decompress directly into user buffer */
431360 else { /* state->how == GZIP */
432361 strm->avail_out = len;
433 strm->next_out = buf;
362 strm->next_out = (unsigned char *)buf;
434363 if (gz_decomp(state) == -1)
435364 return -1;
436 n = state->have;
437 state->have = 0;
365 n = state->x.have;
366 state->x.have = 0;
438367 }
439368
440369 /* update progress */
441370 len -= n;
442371 buf = (char *)buf + n;
443372 got += n;
444 state->pos += n;
373 state->x.pos += n;
445374 } while (len);
446375
447376 /* return number of bytes read into user buffer (will fit in int) */
449378 }
450379
451380 /* -- see zlib.h -- */
381 #ifdef Z_PREFIX_SET
382 # undef z_gzgetc
383 #else
384 # undef gzgetc
385 #endif
452386 int ZEXPORT gzgetc(file)
453387 gzFile file;
454388 {
461395 return -1;
462396 state = (gz_statep)file;
463397
464 /* check that we're reading and that there's no error */
465 if (state->mode != GZ_READ || state->err != Z_OK)
398 /* check that we're reading and that there's no (serious) error */
399 if (state->mode != GZ_READ ||
400 (state->err != Z_OK && state->err != Z_BUF_ERROR))
466401 return -1;
467402
468403 /* try output buffer (no need to check for skip request) */
469 if (state->have) {
470 state->have--;
471 state->pos++;
472 return *(state->next)++;
404 if (state->x.have) {
405 state->x.have--;
406 state->x.pos++;
407 return *(state->x.next)++;
473408 }
474409
475410 /* nothing there -- try gzread() */
476411 ret = gzread(file, buf, 1);
477412 return ret < 1 ? -1 : buf[0];
413 }
414
415 int ZEXPORT gzgetc_(file)
416 gzFile file;
417 {
418 return gzgetc(file);
478419 }
479420
480421 /* -- see zlib.h -- */
489430 return -1;
490431 state = (gz_statep)file;
491432
492 /* check that we're reading and that there's no error */
493 if (state->mode != GZ_READ || state->err != Z_OK)
433 /* check that we're reading and that there's no (serious) error */
434 if (state->mode != GZ_READ ||
435 (state->err != Z_OK && state->err != Z_BUF_ERROR))
494436 return -1;
495437
496438 /* process a skip request */
505447 return -1;
506448
507449 /* if output buffer empty, put byte at end (allows more pushing) */
508 if (state->have == 0) {
509 state->have = 1;
510 state->next = state->out + (state->size << 1) - 1;
511 state->next[0] = c;
512 state->pos--;
450 if (state->x.have == 0) {
451 state->x.have = 1;
452 state->x.next = state->out + (state->size << 1) - 1;
453 state->x.next[0] = c;
454 state->x.pos--;
455 state->past = 0;
513456 return c;
514457 }
515458
516459 /* if no room, give up (must have already done a gzungetc()) */
517 if (state->have == (state->size << 1)) {
518 gz_error(state, Z_BUF_ERROR, "out of room to push characters");
460 if (state->x.have == (state->size << 1)) {
461 gz_error(state, Z_DATA_ERROR, "out of room to push characters");
519462 return -1;
520463 }
521464
522465 /* slide output data if needed and insert byte before existing data */
523 if (state->next == state->out) {
524 unsigned char *src = state->out + state->have;
466 if (state->x.next == state->out) {
467 unsigned char *src = state->out + state->x.have;
525468 unsigned char *dest = state->out + (state->size << 1);
526469 while (src > state->out)
527470 *--dest = *--src;
528 state->next = dest;
529 }
530 state->have++;
531 state->next--;
532 state->next[0] = c;
533 state->pos--;
471 state->x.next = dest;
472 }
473 state->x.have++;
474 state->x.next--;
475 state->x.next[0] = c;
476 state->x.pos--;
477 state->past = 0;
534478 return c;
535479 }
536480
550494 return NULL;
551495 state = (gz_statep)file;
552496
553 /* check that we're reading and that there's no error */
554 if (state->mode != GZ_READ || state->err != Z_OK)
497 /* check that we're reading and that there's no (serious) error */
498 if (state->mode != GZ_READ ||
499 (state->err != Z_OK && state->err != Z_BUF_ERROR))
555500 return NULL;
556501
557502 /* process a skip request */
568513 left = (unsigned)len - 1;
569514 if (left) do {
570515 /* assure that something is in the output buffer */
571 if (state->have == 0) {
572 if (gz_make(state) == -1)
573 return NULL; /* error */
574 if (state->have == 0) { /* end of file */
575 if (buf == str) /* got bupkus */
576 return NULL;
577 break; /* got something -- return it */
578 }
516 if (state->x.have == 0 && gz_fetch(state) == -1)
517 return NULL; /* error */
518 if (state->x.have == 0) { /* end of file */
519 state->past = 1; /* read past end */
520 break; /* return what we have */
579521 }
580522
581523 /* look for end-of-line in current output buffer */
582 n = state->have > left ? left : state->have;
583 eol = memchr(state->next, '\n', n);
524 n = state->x.have > left ? left : state->x.have;
525 eol = (unsigned char *)memchr(state->x.next, '\n', n);
584526 if (eol != NULL)
585 n = (unsigned)(eol - state->next) + 1;
527 n = (unsigned)(eol - state->x.next) + 1;
586528
587529 /* copy through end-of-line, or remainder if not found */
588 memcpy(buf, state->next, n);
589 state->have -= n;
590 state->next += n;
591 state->pos += n;
530 memcpy(buf, state->x.next, n);
531 state->x.have -= n;
532 state->x.next += n;
533 state->x.pos += n;
592534 left -= n;
593535 buf += n;
594536 } while (left && eol == NULL);
595537
596 /* found end-of-line or out of space -- terminate string and return it */
538 /* return terminated string, or if nothing, end of file */
539 if (buf == str)
540 return NULL;
597541 buf[0] = 0;
598542 return str;
599543 }
609553 return 0;
610554 state = (gz_statep)file;
611555
612 /* check that we're reading */
613 if (state->mode != GZ_READ)
614 return 0;
615
616556 /* if the state is not known, but we can find out, then do so (this is
617557 mainly for right after a gzopen() or gzdopen()) */
618 if (state->how == LOOK && state->have == 0)
619 (void)gz_head(state);
620
621 /* return 1 if reading direct, 0 if decompressing a gzip stream */
558 if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
559 (void)gz_look(state);
560
561 /* return 1 if transparent, 0 if processing a gzip stream */
622562 return state->direct;
623563 }
624564
626566 int ZEXPORT gzclose_r(file)
627567 gzFile file;
628568 {
629 int ret;
569 int ret, err;
630570 gz_statep state;
631571
632572 /* get internal structure */
644584 free(state->out);
645585 free(state->in);
646586 }
587 err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK;
647588 gz_error(state, Z_OK, NULL);
648589 free(state->path);
649590 ret = close(state->fd);
650591 free(state);
651 return ret ? Z_ERRNO : Z_OK;
652 }
592 return ret ? Z_ERRNO : err;
593 }
00 /* gzwrite.c -- zlib functions for writing gzip files
1 * Copyright (C) 2004, 2005, 2010 Mark Adler
1 * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
1717 int ret;
1818 z_streamp strm = &(state->strm);
1919
20 /* allocate input and output buffers */
21 state->in = malloc(state->want);
22 state->out = malloc(state->want);
23 if (state->in == NULL || state->out == NULL) {
24 if (state->out != NULL)
20 /* allocate input buffer */
21 state->in = (unsigned char *)malloc(state->want);
22 if (state->in == NULL) {
23 gz_error(state, Z_MEM_ERROR, "out of memory");
24 return -1;
25 }
26
27 /* only need output buffer and deflate state if compressing */
28 if (!state->direct) {
29 /* allocate output buffer */
30 state->out = (unsigned char *)malloc(state->want);
31 if (state->out == NULL) {
32 free(state->in);
33 gz_error(state, Z_MEM_ERROR, "out of memory");
34 return -1;
35 }
36
37 /* allocate deflate memory, set up for gzip compression */
38 strm->zalloc = Z_NULL;
39 strm->zfree = Z_NULL;
40 strm->opaque = Z_NULL;
41 ret = deflateInit2(strm, state->level, Z_DEFLATED,
42 MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
43 if (ret != Z_OK) {
2544 free(state->out);
26 if (state->in != NULL)
2745 free(state->in);
28 gz_error(state, Z_MEM_ERROR, "out of memory");
29 return -1;
30 }
31
32 /* allocate deflate memory, set up for gzip compression */
33 strm->zalloc = Z_NULL;
34 strm->zfree = Z_NULL;
35 strm->opaque = Z_NULL;
36 ret = deflateInit2(strm, state->level, Z_DEFLATED,
37 15 + 16, 8, state->strategy);
38 if (ret != Z_OK) {
39 free(state->in);
40 gz_error(state, Z_MEM_ERROR, "out of memory");
41 return -1;
46 gz_error(state, Z_MEM_ERROR, "out of memory");
47 return -1;
48 }
4249 }
4350
4451 /* mark state as initialized */
4552 state->size = state->want;
4653
47 /* initialize write buffer */
48 strm->avail_out = state->size;
49 strm->next_out = state->out;
50 state->next = strm->next_out;
54 /* initialize write buffer if compressing */
55 if (!state->direct) {
56 strm->avail_out = state->size;
57 strm->next_out = state->out;
58 state->x.next = strm->next_out;
59 }
5160 return 0;
5261 }
5362
5463 /* Compress whatever is at avail_in and next_in and write to the output file.
5564 Return -1 if there is an error writing to the output file, otherwise 0.
5665 flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH,
57 then the deflate() state is reset to start a new gzip stream. */
66 then the deflate() state is reset to start a new gzip stream. If gz->direct
67 is true, then simply write to the output file without compressing, and
68 ignore flush. */
5869 local int gz_comp(state, flush)
5970 gz_statep state;
6071 int flush;
6677 /* allocate memory if this is the first time through */
6778 if (state->size == 0 && gz_init(state) == -1)
6879 return -1;
80
81 /* write directly if requested */
82 if (state->direct) {
83 got = write(state->fd, strm->next_in, strm->avail_in);
84 if (got < 0 || (unsigned)got != strm->avail_in) {
85 gz_error(state, Z_ERRNO, zstrerror());
86 return -1;
87 }
88 strm->avail_in = 0;
89 return 0;
90 }
6991
7092 /* run deflate() on provided input until it produces no more output */
7193 ret = Z_OK;
7496 doing Z_FINISH then don't write until we get to Z_STREAM_END */
7597 if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
7698 (flush != Z_FINISH || ret == Z_STREAM_END))) {
77 have = (unsigned)(strm->next_out - state->next);
78 if (have && ((got = write(state->fd, state->next, have)) < 0 ||
99 have = (unsigned)(strm->next_out - state->x.next);
100 if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
79101 (unsigned)got != have)) {
80102 gz_error(state, Z_ERRNO, zstrerror());
81103 return -1;
84106 strm->avail_out = state->size;
85107 strm->next_out = state->out;
86108 }
87 state->next = strm->next_out;
109 state->x.next = strm->next_out;
88110 }
89111
90112 /* compress */
130152 }
131153 strm->avail_in = n;
132154 strm->next_in = state->in;
133 state->pos += n;
155 state->x.pos += n;
134156 if (gz_comp(state, Z_NO_FLUSH) == -1)
135157 return -1;
136158 len -= n;
145167 unsigned len;
146168 {
147169 unsigned put = len;
148 unsigned n;
149170 gz_statep state;
150171 z_streamp strm;
151172
162183 /* since an int is returned, make sure len fits in one, otherwise return
163184 with an error (this avoids the flaw in the interface) */
164185 if ((int)len < 0) {
165 gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
186 gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
166187 return 0;
167188 }
168189
185206 if (len < state->size) {
186207 /* copy to input buffer, compress when full */
187208 do {
209 unsigned have, copy;
210
188211 if (strm->avail_in == 0)
189212 strm->next_in = state->in;
190 n = state->size - strm->avail_in;
191 if (n > len)
192 n = len;
193 memcpy(strm->next_in + strm->avail_in, buf, n);
194 strm->avail_in += n;
195 state->pos += n;
196 buf = (char *)buf + n;
197 len -= n;
213 have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
214 copy = state->size - have;
215 if (copy > len)
216 copy = len;
217 memcpy(state->in + have, buf, copy);
218 strm->avail_in += copy;
219 state->x.pos += copy;
220 buf = (const char *)buf + copy;
221 len -= copy;
198222 if (len && gz_comp(state, Z_NO_FLUSH) == -1)
199223 return 0;
200224 } while (len);
206230
207231 /* directly compress user buffer to file */
208232 strm->avail_in = len;
209 strm->next_in = (voidp)buf;
210 state->pos += len;
233 strm->next_in = (z_const Bytef *)buf;
234 state->x.pos += len;
211235 if (gz_comp(state, Z_NO_FLUSH) == -1)
212236 return 0;
213237 }
221245 gzFile file;
222246 int c;
223247 {
248 unsigned have;
224249 unsigned char buf[1];
225250 gz_statep state;
226251 z_streamp strm;
244269
245270 /* try writing to input buffer for speed (state->size == 0 if buffer not
246271 initialized) */
247 if (strm->avail_in < state->size) {
272 if (state->size) {
248273 if (strm->avail_in == 0)
249274 strm->next_in = state->in;
250 strm->next_in[strm->avail_in++] = c;
251 state->pos++;
252 return c;
275 have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
276 if (have < state->size) {
277 state->in[have] = c;
278 strm->avail_in++;
279 state->x.pos++;
280 return c & 0xff;
281 }
253282 }
254283
255284 /* no room in buffer or not initialized, use gz_write() */
256285 buf[0] = c;
257286 if (gzwrite(file, buf, 1) != 1)
258287 return -1;
259 return c;
288 return c & 0xff;
260289 }
261290
262291 /* -- see zlib.h -- */
273302 return ret == 0 && len != 0 ? -1 : ret;
274303 }
275304
276 #ifdef STDC
305 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
277306 #include <stdarg.h>
278307
279308 /* -- see zlib.h -- */
280 int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
309 int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
281310 {
282311 int size, len;
283312 gz_statep state;
284313 z_streamp strm;
285 va_list va;
286314
287315 /* get internal structure */
288316 if (file == NULL)
312340 /* do the printf() into the input buffer, put length in len */
313341 size = (int)(state->size);
314342 state->in[size - 1] = 0;
315 va_start(va, format);
316343 #ifdef NO_vsnprintf
317344 # ifdef HAS_vsprintf_void
318 (void)vsprintf(state->in, format, va);
319 va_end(va);
345 (void)vsprintf((char *)(state->in), format, va);
320346 for (len = 0; len < size; len++)
321347 if (state->in[len] == 0) break;
322348 # else
323 len = vsprintf(state->in, format, va);
324 va_end(va);
349 len = vsprintf((char *)(state->in), format, va);
325350 # endif
326351 #else
327352 # ifdef HAS_vsnprintf_void
328 (void)vsnprintf(state->in, size, format, va);
329 va_end(va);
330 len = strlen(state->in);
353 (void)vsnprintf((char *)(state->in), size, format, va);
354 len = strlen((char *)(state->in));
331355 # else
332356 len = vsnprintf((char *)(state->in), size, format, va);
333 va_end(va);
334357 # endif
335358 #endif
336359
341364 /* update buffer and position, defer compression until needed */
342365 strm->avail_in = (unsigned)len;
343366 strm->next_in = state->in;
344 state->pos += len;
367 state->x.pos += len;
345368 return len;
346369 }
347370
348 #else /* !STDC */
371 int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
372 {
373 va_list va;
374 int ret;
375
376 va_start(va, format);
377 ret = gzvprintf(file, format, va);
378 va_end(va);
379 return ret;
380 }
381
382 #else /* !STDC && !Z_HAVE_STDARG_H */
349383
350384 /* -- see zlib.h -- */
351385 int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
364398 return -1;
365399 state = (gz_statep)file;
366400 strm = &(state->strm);
401
402 /* check that can really pass pointer in ints */
403 if (sizeof(int) != sizeof(void *))
404 return 0;
367405
368406 /* check that we're writing and that there's no error */
369407 if (state->mode != GZ_WRITE || state->err != Z_OK)
389427 state->in[size - 1] = 0;
390428 #ifdef NO_snprintf
391429 # ifdef HAS_sprintf_void
392 sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
430 sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
393431 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
394432 for (len = 0; len < size; len++)
395433 if (state->in[len] == 0) break;
396434 # else
397 len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
398 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
435 len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
436 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
399437 # endif
400438 #else
401439 # ifdef HAS_snprintf_void
402 snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
440 snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
403441 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
404 len = strlen(state->in);
442 len = strlen((char *)(state->in));
405443 # else
406 len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
407 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
444 len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
445 a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
446 a19, a20);
408447 # endif
409448 #endif
410449
415454 /* update buffer and position, defer compression until needed */
416455 strm->avail_in = (unsigned)len;
417456 strm->next_in = state->in;
418 state->pos += len;
457 state->x.pos += len;
419458 return len;
420459 }
421460
499538 int ZEXPORT gzclose_w(file)
500539 gzFile file;
501540 {
502 int ret = 0;
541 int ret = Z_OK;
503542 gz_statep state;
504543
505544 /* get internal structure */
514553 /* check for seek request */
515554 if (state->seek) {
516555 state->seek = 0;
517 ret += gz_zero(state, state->skip);
556 if (gz_zero(state, state->skip) == -1)
557 ret = state->err;
518558 }
519559
520560 /* flush, free memory, and close file */
521 ret += gz_comp(state, Z_FINISH);
522 (void)deflateEnd(&(state->strm));
523 free(state->out);
524 free(state->in);
561 if (gz_comp(state, Z_FINISH) == -1)
562 ret = state->err;
563 if (state->size) {
564 if (!state->direct) {
565 (void)deflateEnd(&(state->strm));
566 free(state->out);
567 }
568 free(state->in);
569 }
525570 gz_error(state, Z_OK, NULL);
526571 free(state->path);
527 ret += close(state->fd);
572 if (close(state->fd) == -1)
573 ret = Z_ERRNO;
528574 free(state);
529 return ret ? Z_ERRNO : Z_OK;
530 }
575 return ret;
576 }
00 /* infback.c -- inflate using a call-back interface
1 * Copyright (C) 1995-2009 Mark Adler
1 * Copyright (C) 1995-2011 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
4141 return Z_STREAM_ERROR;
4242 strm->msg = Z_NULL; /* in case we return an error */
4343 if (strm->zalloc == (alloc_func)0) {
44 #ifdef Z_SOLO
45 return Z_STREAM_ERROR;
46 #else
4447 strm->zalloc = zcalloc;
4548 strm->opaque = (voidpf)0;
49 #endif
4650 }
47 if (strm->zfree == (free_func)0) strm->zfree = zcfree;
51 if (strm->zfree == (free_func)0)
52 #ifdef Z_SOLO
53 return Z_STREAM_ERROR;
54 #else
55 strm->zfree = zcfree;
56 #endif
4857 state = (struct inflate_state FAR *)ZALLOC(strm, 1,
4958 sizeof(struct inflate_state));
5059 if (state == Z_NULL) return Z_MEM_ERROR;
245254 void FAR *out_desc;
246255 {
247256 struct inflate_state FAR *state;
248 unsigned char FAR *next; /* next input */
257 z_const unsigned char FAR *next; /* next input */
249258 unsigned char FAR *put; /* next output */
250259 unsigned have, left; /* available input and output */
251260 unsigned long hold; /* bit buffer */
393402 PULLBYTE();
394403 }
395404 if (here.val < 16) {
396 NEEDBITS(here.bits);
397405 DROPBITS(here.bits);
398406 state->lens[state->have++] = here.val;
399407 }
00 /* inffast.c -- fast decoding
1 * Copyright (C) 1995-2008, 2010 Mark Adler
1 * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
6868 unsigned start; /* inflate()'s starting value for strm->avail_out */
6969 {
7070 struct inflate_state FAR *state;
71 unsigned char FAR *in; /* local strm->next_in */
72 unsigned char FAR *last; /* while in < last, enough input available */
71 z_const unsigned char FAR *in; /* local strm->next_in */
72 z_const unsigned char FAR *last; /* have enough input while in < last */
7373 unsigned char FAR *out; /* local strm->next_out */
7474 unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
7575 unsigned char FAR *end; /* while out < end, enough space available */
11 * Generated automatically by makefixed().
22 */
33
4 /* WARNING: this file should *not* be used by applications. It
5 is part of the implementation of the compression library and
6 is subject to change. Applications should only use zlib.h.
4 /* WARNING: this file should *not* be used by applications.
5 It is part of the implementation of this library and is
6 subject to change. Applications should only use zlib.h.
77 */
88
99 static const code lenfix[512] = {
00 /* inflate.c -- zlib decompression
1 * Copyright (C) 1995-2010 Mark Adler
1 * Copyright (C) 1995-2012 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
9292
9393 /* function prototypes */
9494 local void fixedtables OF((struct inflate_state FAR *state));
95 local int updatewindow OF((z_streamp strm, unsigned out));
95 local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
96 unsigned copy));
9697 #ifdef BUILDFIXED
9798 void makefixed OF((void));
9899 #endif
99 local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
100 local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
100101 unsigned len));
101102
102 int ZEXPORT inflateReset(strm)
103 int ZEXPORT inflateResetKeep(strm)
103104 z_streamp strm;
104105 {
105106 struct inflate_state FAR *state;
108109 state = (struct inflate_state FAR *)strm->state;
109110 strm->total_in = strm->total_out = state->total = 0;
110111 strm->msg = Z_NULL;
111 strm->adler = 1; /* to support ill-conceived Java test suite */
112 if (state->wrap) /* to support ill-conceived Java test suite */
113 strm->adler = state->wrap & 1;
112114 state->mode = HEAD;
113115 state->last = 0;
114116 state->havedict = 0;
115117 state->dmax = 32768U;
116118 state->head = Z_NULL;
117 state->wsize = 0;
118 state->whave = 0;
119 state->wnext = 0;
120119 state->hold = 0;
121120 state->bits = 0;
122121 state->lencode = state->distcode = state->next = state->codes;
126125 return Z_OK;
127126 }
128127
128 int ZEXPORT inflateReset(strm)
129 z_streamp strm;
130 {
131 struct inflate_state FAR *state;
132
133 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
134 state = (struct inflate_state FAR *)strm->state;
135 state->wsize = 0;
136 state->whave = 0;
137 state->wnext = 0;
138 return inflateResetKeep(strm);
139 }
140
129141 int ZEXPORT inflateReset2(strm, windowBits)
130142 z_streamp strm;
131143 int windowBits;
179191 if (strm == Z_NULL) return Z_STREAM_ERROR;
180192 strm->msg = Z_NULL; /* in case we return an error */
181193 if (strm->zalloc == (alloc_func)0) {
194 #ifdef Z_SOLO
195 return Z_STREAM_ERROR;
196 #else
182197 strm->zalloc = zcalloc;
183198 strm->opaque = (voidpf)0;
184 }
185 if (strm->zfree == (free_func)0) strm->zfree = zcfree;
199 #endif
200 }
201 if (strm->zfree == (free_func)0)
202 #ifdef Z_SOLO
203 return Z_STREAM_ERROR;
204 #else
205 strm->zfree = zcfree;
206 #endif
186207 state = (struct inflate_state FAR *)
187208 ZALLOC(strm, 1, sizeof(struct inflate_state));
188209 if (state == Z_NULL) return Z_MEM_ERROR;
320341 low = 0;
321342 for (;;) {
322343 if ((low % 7) == 0) printf("\n ");
323 printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
324 state.lencode[low].val);
344 printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
345 state.lencode[low].bits, state.lencode[low].val);
325346 if (++low == size) break;
326347 putchar(',');
327348 }
354375 output will fall in the output data, making match copies simpler and faster.
355376 The advantage may be dependent on the size of the processor's data caches.
356377 */
357 local int updatewindow(strm, out)
378 local int updatewindow(strm, end, copy)
358379 z_streamp strm;
359 unsigned out;
380 const Bytef *end;
381 unsigned copy;
360382 {
361383 struct inflate_state FAR *state;
362 unsigned copy, dist;
384 unsigned dist;
363385
364386 state = (struct inflate_state FAR *)strm->state;
365387
379401 }
380402
381403 /* copy state->wsize or less output bytes into the circular window */
382 copy = out - strm->avail_out;
383404 if (copy >= state->wsize) {
384 zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
405 zmemcpy(state->window, end - state->wsize, state->wsize);
385406 state->wnext = 0;
386407 state->whave = state->wsize;
387408 }
388409 else {
389410 dist = state->wsize - state->wnext;
390411 if (dist > copy) dist = copy;
391 zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
412 zmemcpy(state->window + state->wnext, end - copy, dist);
392413 copy -= dist;
393414 if (copy) {
394 zmemcpy(state->window, strm->next_out - copy, copy);
415 zmemcpy(state->window, end - copy, copy);
395416 state->wnext = copy;
396417 state->whave = state->wsize;
397418 }
498519 bits -= bits & 7; \
499520 } while (0)
500521
501 /* Reverse the bytes in a 32-bit value */
502 #define REVERSE(q) \
503 ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
504 (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
505
506522 /*
507523 inflate() uses a state machine to process as much input data and generate as
508524 much output data as possible before returning. The state machine is
590606 int flush;
591607 {
592608 struct inflate_state FAR *state;
593 unsigned char FAR *next; /* next input */
609 z_const unsigned char FAR *next; /* next input */
594610 unsigned char FAR *put; /* next output */
595611 unsigned have, left; /* available input and output */
596612 unsigned long hold; /* bit buffer */
796812 #endif
797813 case DICTID:
798814 NEEDBITS(32);
799 strm->adler = state->check = REVERSE(hold);
815 strm->adler = state->check = ZSWAP32(hold);
800816 INITBITS();
801817 state->mode = DICT;
802818 case DICT:
904920 while (state->have < 19)
905921 state->lens[order[state->have++]] = 0;
906922 state->next = state->codes;
907 state->lencode = (code const FAR *)(state->next);
923 state->lencode = (const code FAR *)(state->next);
908924 state->lenbits = 7;
909925 ret = inflate_table(CODES, state->lens, 19, &(state->next),
910926 &(state->lenbits), state->work);
924940 PULLBYTE();
925941 }
926942 if (here.val < 16) {
927 NEEDBITS(here.bits);
928943 DROPBITS(here.bits);
929944 state->lens[state->have++] = here.val;
930945 }
979994 values here (9 and 6) without reading the comments in inftrees.h
980995 concerning the ENOUGH constants, which depend on those values */
981996 state->next = state->codes;
982 state->lencode = (code const FAR *)(state->next);
997 state->lencode = (const code FAR *)(state->next);
983998 state->lenbits = 9;
984999 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
9851000 &(state->lenbits), state->work);
9881003 state->mode = BAD;
9891004 break;
9901005 }
991 state->distcode = (code const FAR *)(state->next);
1006 state->distcode = (const code FAR *)(state->next);
9921007 state->distbits = 6;
9931008 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
9941009 &(state->next), &(state->distbits), state->work);
11691184 #ifdef GUNZIP
11701185 state->flags ? hold :
11711186 #endif
1172 REVERSE(hold)) != state->check) {
1187 ZSWAP32(hold)) != state->check) {
11731188 strm->msg = (char *)"incorrect data check";
11741189 state->mode = BAD;
11751190 break;
12131228 */
12141229 inf_leave:
12151230 RESTORE();
1216 if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
1217 if (updatewindow(strm, out)) {
1231 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1232 (state->mode < CHECK || flush != Z_FINISH)))
1233 if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
12181234 state->mode = MEM;
12191235 return Z_MEM_ERROR;
12201236 }
12481264 return Z_OK;
12491265 }
12501266
1267 int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
1268 z_streamp strm;
1269 Bytef *dictionary;
1270 uInt *dictLength;
1271 {
1272 struct inflate_state FAR *state;
1273
1274 /* check state */
1275 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1276 state = (struct inflate_state FAR *)strm->state;
1277
1278 /* copy dictionary */
1279 if (state->whave && dictionary != Z_NULL) {
1280 zmemcpy(dictionary, state->window + state->wnext,
1281 state->whave - state->wnext);
1282 zmemcpy(dictionary + state->whave - state->wnext,
1283 state->window, state->wnext);
1284 }
1285 if (dictLength != Z_NULL)
1286 *dictLength = state->whave;
1287 return Z_OK;
1288 }
1289
12511290 int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
12521291 z_streamp strm;
12531292 const Bytef *dictionary;
12541293 uInt dictLength;
12551294 {
12561295 struct inflate_state FAR *state;
1257 unsigned long id;
1296 unsigned long dictid;
1297 int ret;
12581298
12591299 /* check state */
12601300 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
12621302 if (state->wrap != 0 && state->mode != DICT)
12631303 return Z_STREAM_ERROR;
12641304
1265 /* check for correct dictionary id */
1305 /* check for correct dictionary identifier */
12661306 if (state->mode == DICT) {
1267 id = adler32(0L, Z_NULL, 0);
1268 id = adler32(id, dictionary, dictLength);
1269 if (id != state->check)
1307 dictid = adler32(0L, Z_NULL, 0);
1308 dictid = adler32(dictid, dictionary, dictLength);
1309 if (dictid != state->check)
12701310 return Z_DATA_ERROR;
12711311 }
12721312
1273 /* copy dictionary to window */
1274 if (updatewindow(strm, strm->avail_out)) {
1313 /* copy dictionary to window using updatewindow(), which will amend the
1314 existing dictionary if appropriate */
1315 ret = updatewindow(strm, dictionary + dictLength, dictLength);
1316 if (ret) {
12751317 state->mode = MEM;
12761318 return Z_MEM_ERROR;
1277 }
1278 if (dictLength > state->wsize) {
1279 zmemcpy(state->window, dictionary + dictLength - state->wsize,
1280 state->wsize);
1281 state->whave = state->wsize;
1282 }
1283 else {
1284 zmemcpy(state->window + state->wsize - dictLength, dictionary,
1285 dictLength);
1286 state->whave = dictLength;
12871319 }
12881320 state->havedict = 1;
12891321 Tracev((stderr, "inflate: dictionary set\n"));
13201352 */
13211353 local unsigned syncsearch(have, buf, len)
13221354 unsigned FAR *have;
1323 unsigned char FAR *buf;
1355 const unsigned char FAR *buf;
13241356 unsigned len;
13251357 {
13261358 unsigned got;
14321464 }
14331465
14341466 /* copy state */
1435 zmemcpy(dest, source, sizeof(z_stream));
1436 zmemcpy(copy, state, sizeof(struct inflate_state));
1467 zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
1468 zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
14371469 if (state->lencode >= state->codes &&
14381470 state->lencode <= state->codes + ENOUGH - 1) {
14391471 copy->lencode = copy->codes + (state->lencode - state->codes);
00 /* inftrees.c -- generate Huffman trees for efficient decoding
1 * Copyright (C) 1995-2010 Mark Adler
1 * Copyright (C) 1995-2013 Mark Adler
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
88 #define MAXBITS 15
99
1010 const char inflate_copyright[] =
11 " inflate 1.2.5 Copyright 1995-2010 Mark Adler ";
11 " inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
1212 /*
1313 If you use the zlib library in a product, an acknowledgment is welcome
1414 in the documentation of your product. If for some reason you cannot
6161 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
6262 static const unsigned short lext[31] = { /* Length codes 257..285 extra */
6363 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
64 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195};
64 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
6565 static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
6666 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
6767 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
207207 mask = used - 1; /* mask for comparing low */
208208
209209 /* check available table space */
210 if ((type == LENS && used >= ENOUGH_LENS) ||
211 (type == DISTS && used >= ENOUGH_DISTS))
210 if ((type == LENS && used > ENOUGH_LENS) ||
211 (type == DISTS && used > ENOUGH_DISTS))
212212 return 1;
213213
214214 /* process all codes and make table entries */
276276
277277 /* check for enough space */
278278 used += 1U << curr;
279 if ((type == LENS && used >= ENOUGH_LENS) ||
280 (type == DISTS && used >= ENOUGH_DISTS))
279 if ((type == LENS && used > ENOUGH_LENS) ||
280 (type == DISTS && used > ENOUGH_DISTS))
281281 return 1;
282282
283283 /* point entry in root table to sub-table */
288288 }
289289 }
290290
291 /*
292 Fill in rest of table for incomplete codes. This loop is similar to the
293 loop above in incrementing huff for table indices. It is assumed that
294 len is equal to curr + drop, so there is no loop needed to increment
295 through high index bits. When the current sub-table is filled, the loop
296 drops back to the root table to fill in any remaining entries there.
297 */
298 here.op = (unsigned char)64; /* invalid code marker */
299 here.bits = (unsigned char)(len - drop);
300 here.val = (unsigned short)0;
301 while (huff != 0) {
302 /* when done with sub-table, drop back to root table */
303 if (drop != 0 && (huff & mask) != low) {
304 drop = 0;
305 len = root;
306 next = *table;
307 here.bits = (unsigned char)len;
308 }
309
310 /* put invalid code marker in table */
311 next[huff >> drop] = here;
312
313 /* backwards increment the len-bit code huff */
314 incr = 1U << (len - 1);
315 while (huff & incr)
316 incr >>= 1;
317 if (incr != 0) {
318 huff &= incr - 1;
319 huff += incr;
320 }
321 else
322 huff = 0;
291 /* fill in remaining table entry if code is incomplete (guaranteed to have
292 at most one remaining entry, since if the code is incomplete, the
293 maximum code length that was allowed to get this far is one bit) */
294 if (huff != 0) {
295 here.op = (unsigned char)64; /* invalid code marker */
296 here.bits = (unsigned char)(len - drop);
297 here.val = (unsigned short)0;
298 next[huff] = here;
323299 }
324300
325301 /* set return parameters */
00 /* trees.c -- output deflated data using Huffman coding
1 * Copyright (C) 1995-2010 Jean-loup Gailly
1 * Copyright (C) 1995-2012 Jean-loup Gailly
22 * detect_data_type() function provided freely by Cosmin Truta, 2006
33 * For conditions of distribution and use, see copyright notice in zlib.h
44 */
2929 * Addison-Wesley, 1983. ISBN 0-201-06672-6.
3030 */
3131
32 /* @(#) $Id: trees.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
32 /* @(#) $Id$ */
3333
3434 /* #define GEN_TREES_H */
3535
7171 = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
7272 /* The lengths of the bit length codes are sent in order of decreasing
7373 * probability, to avoid transmitting the lengths for unused bit length codes.
74 */
75
76 #define Buf_size (8 * 2*sizeof(char))
77 /* Number of bits used within bi_buf. (bi_buf might be implemented on
78 * more than 16 bits on some systems.)
7974 */
8075
8176 /* ===========================================================================
150145 local int build_bl_tree OF((deflate_state *s));
151146 local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
152147 int blcodes));
153 local void compress_block OF((deflate_state *s, ct_data *ltree,
154 ct_data *dtree));
148 local void compress_block OF((deflate_state *s, const ct_data *ltree,
149 const ct_data *dtree));
155150 local int detect_data_type OF((deflate_state *s));
156151 local unsigned bi_reverse OF((unsigned value, int length));
157152 local void bi_windup OF((deflate_state *s));
398393
399394 s->bi_buf = 0;
400395 s->bi_valid = 0;
401 s->last_eob_len = 8; /* enough lookahead for inflate */
402396 #ifdef DEBUG
403397 s->compressed_len = 0L;
404398 s->bits_sent = 0L;
882876 }
883877
884878 /* ===========================================================================
879 * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
880 */
881 void ZLIB_INTERNAL _tr_flush_bits(s)
882 deflate_state *s;
883 {
884 bi_flush(s);
885 }
886
887 /* ===========================================================================
885888 * Send one empty static block to give enough lookahead for inflate.
886889 * This takes 10 bits, of which 7 may remain in the bit buffer.
887 * The current inflate code requires 9 bits of lookahead. If the
888 * last two codes for the previous block (real code plus EOB) were coded
889 * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
890 * the last real code. In this case we send two empty static blocks instead
891 * of one. (There are no problems if the previous block is stored or fixed.)
892 * To simplify the code, we assume the worst case of last real code encoded
893 * on one bit only.
894890 */
895891 void ZLIB_INTERNAL _tr_align(s)
896892 deflate_state *s;
901897 s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
902898 #endif
903899 bi_flush(s);
904 /* Of the 10 bits for the empty block, we have already sent
905 * (10 - bi_valid) bits. The lookahead for the last real code (before
906 * the EOB of the previous block) was thus at least one plus the length
907 * of the EOB plus what we have just sent of the empty static block.
908 */
909 if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
910 send_bits(s, STATIC_TREES<<1, 3);
911 send_code(s, END_BLOCK, static_ltree);
912 #ifdef DEBUG
913 s->compressed_len += 10L;
914 #endif
915 bi_flush(s);
916 }
917 s->last_eob_len = 7;
918900 }
919901
920902 /* ===========================================================================
989971 } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
990972 #endif
991973 send_bits(s, (STATIC_TREES<<1)+last, 3);
992 compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
974 compress_block(s, (const ct_data *)static_ltree,
975 (const ct_data *)static_dtree);
993976 #ifdef DEBUG
994977 s->compressed_len += 3 + s->static_len;
995978 #endif
997980 send_bits(s, (DYN_TREES<<1)+last, 3);
998981 send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
999982 max_blindex+1);
1000 compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
983 compress_block(s, (const ct_data *)s->dyn_ltree,
984 (const ct_data *)s->dyn_dtree);
1001985 #ifdef DEBUG
1002986 s->compressed_len += 3 + s->opt_len;
1003987 #endif
10741058 */
10751059 local void compress_block(s, ltree, dtree)
10761060 deflate_state *s;
1077 ct_data *ltree; /* literal tree */
1078 ct_data *dtree; /* distance tree */
1061 const ct_data *ltree; /* literal tree */
1062 const ct_data *dtree; /* distance tree */
10791063 {
10801064 unsigned dist; /* distance of matched string */
10811065 int lc; /* match length or unmatched char (if dist == 0) */
11171101 } while (lx < s->last_lit);
11181102
11191103 send_code(s, END_BLOCK, ltree);
1120 s->last_eob_len = ltree[END_BLOCK].Len;
11211104 }
11221105
11231106 /* ===========================================================================
12251208 int header; /* true if block header must be written */
12261209 {
12271210 bi_windup(s); /* align on byte boundary */
1228 s->last_eob_len = 8; /* enough lookahead for inflate */
12291211
12301212 if (header) {
12311213 put_short(s, (ush)len);
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
5 /* @(#) $Id: uncompr.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
5 /* @(#) $Id$ */
66
77 #define ZLIB_INTERNAL
88 #include "zlib.h"
2929 z_stream stream;
3030 int err;
3131
32 stream.next_in = (Bytef*)source;
32 stream.next_in = (z_const Bytef *)source;
3333 stream.avail_in = (uInt)sourceLen;
3434 /* Check for source > 64K on 16-bit machine: */
3535 if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
00 /* zconf.h -- configuration of the zlib compression library
1 * Copyright (C) 1995-2010 Jean-loup Gailly.
1 * Copyright (C) 1995-2013 Jean-loup Gailly.
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
5 /* @(#) $Id: zconf.h,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
5 /* @(#) $Id$ */
66
77 #ifndef ZCONF_H
88 #define ZCONF_H
1414 * this permanently in zconf.h using "./configure --zprefix".
1515 */
1616 #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
17 # define Z_PREFIX_SET
1718
1819 /* all linked symbols */
1920 # define _dist_code z__dist_code
2021 # define _length_code z__length_code
2122 # define _tr_align z__tr_align
23 # define _tr_flush_bits z__tr_flush_bits
2224 # define _tr_flush_block z__tr_flush_block
2325 # define _tr_init z__tr_init
2426 # define _tr_stored_block z__tr_stored_block
2628 # define adler32 z_adler32
2729 # define adler32_combine z_adler32_combine
2830 # define adler32_combine64 z_adler32_combine64
29 # define compress z_compress
30 # define compress2 z_compress2
31 # define compressBound z_compressBound
31 # ifndef Z_SOLO
32 # define compress z_compress
33 # define compress2 z_compress2
34 # define compressBound z_compressBound
35 # endif
3236 # define crc32 z_crc32
3337 # define crc32_combine z_crc32_combine
3438 # define crc32_combine64 z_crc32_combine64
3943 # define deflateInit2_ z_deflateInit2_
4044 # define deflateInit_ z_deflateInit_
4145 # define deflateParams z_deflateParams
46 # define deflatePending z_deflatePending
4247 # define deflatePrime z_deflatePrime
4348 # define deflateReset z_deflateReset
49 # define deflateResetKeep z_deflateResetKeep
4450 # define deflateSetDictionary z_deflateSetDictionary
4551 # define deflateSetHeader z_deflateSetHeader
4652 # define deflateTune z_deflateTune
4753 # define deflate_copyright z_deflate_copyright
4854 # define get_crc_table z_get_crc_table
49 # define gz_error z_gz_error
50 # define gz_intmax z_gz_intmax
51 # define gz_strwinerror z_gz_strwinerror
52 # define gzbuffer z_gzbuffer
53 # define gzclearerr z_gzclearerr
54 # define gzclose z_gzclose
55 # define gzclose_r z_gzclose_r
56 # define gzclose_w z_gzclose_w
57 # define gzdirect z_gzdirect
58 # define gzdopen z_gzdopen
59 # define gzeof z_gzeof
60 # define gzerror z_gzerror
61 # define gzflush z_gzflush
62 # define gzgetc z_gzgetc
63 # define gzgets z_gzgets
64 # define gzoffset z_gzoffset
65 # define gzoffset64 z_gzoffset64
66 # define gzopen z_gzopen
67 # define gzopen64 z_gzopen64
68 # define gzprintf z_gzprintf
69 # define gzputc z_gzputc
70 # define gzputs z_gzputs
71 # define gzread z_gzread
72 # define gzrewind z_gzrewind
73 # define gzseek z_gzseek
74 # define gzseek64 z_gzseek64
75 # define gzsetparams z_gzsetparams
76 # define gztell z_gztell
77 # define gztell64 z_gztell64
78 # define gzungetc z_gzungetc
79 # define gzwrite z_gzwrite
55 # ifndef Z_SOLO
56 # define gz_error z_gz_error
57 # define gz_intmax z_gz_intmax
58 # define gz_strwinerror z_gz_strwinerror
59 # define gzbuffer z_gzbuffer
60 # define gzclearerr z_gzclearerr
61 # define gzclose z_gzclose
62 # define gzclose_r z_gzclose_r
63 # define gzclose_w z_gzclose_w
64 # define gzdirect z_gzdirect
65 # define gzdopen z_gzdopen
66 # define gzeof z_gzeof
67 # define gzerror z_gzerror
68 # define gzflush z_gzflush
69 # define gzgetc z_gzgetc
70 # define gzgetc_ z_gzgetc_
71 # define gzgets z_gzgets
72 # define gzoffset z_gzoffset
73 # define gzoffset64 z_gzoffset64
74 # define gzopen z_gzopen
75 # define gzopen64 z_gzopen64
76 # ifdef _WIN32
77 # define gzopen_w z_gzopen_w
78 # endif
79 # define gzprintf z_gzprintf
80 # define gzvprintf z_gzvprintf
81 # define gzputc z_gzputc
82 # define gzputs z_gzputs
83 # define gzread z_gzread
84 # define gzrewind z_gzrewind
85 # define gzseek z_gzseek
86 # define gzseek64 z_gzseek64
87 # define gzsetparams z_gzsetparams
88 # define gztell z_gztell
89 # define gztell64 z_gztell64
90 # define gzungetc z_gzungetc
91 # define gzwrite z_gzwrite
92 # endif
8093 # define inflate z_inflate
8194 # define inflateBack z_inflateBack
8295 # define inflateBackEnd z_inflateBackEnd
91104 # define inflateReset z_inflateReset
92105 # define inflateReset2 z_inflateReset2
93106 # define inflateSetDictionary z_inflateSetDictionary
107 # define inflateGetDictionary z_inflateGetDictionary
94108 # define inflateSync z_inflateSync
95109 # define inflateSyncPoint z_inflateSyncPoint
96110 # define inflateUndermine z_inflateUndermine
111 # define inflateResetKeep z_inflateResetKeep
97112 # define inflate_copyright z_inflate_copyright
98113 # define inflate_fast z_inflate_fast
99114 # define inflate_table z_inflate_table
100 # define uncompress z_uncompress
115 # ifndef Z_SOLO
116 # define uncompress z_uncompress
117 # endif
101118 # define zError z_zError
102 # define zcalloc z_zcalloc
103 # define zcfree z_zcfree
119 # ifndef Z_SOLO
120 # define zcalloc z_zcalloc
121 # define zcfree z_zcfree
122 # endif
104123 # define zlibCompileFlags z_zlibCompileFlags
105124 # define zlibVersion z_zlibVersion
106125
110129 # define alloc_func z_alloc_func
111130 # define charf z_charf
112131 # define free_func z_free_func
113 # define gzFile z_gzFile
132 # ifndef Z_SOLO
133 # define gzFile z_gzFile
134 # endif
114135 # define gz_header z_gz_header
115136 # define gz_headerp z_gz_headerp
116137 # define in_func z_in_func
196217 # endif
197218 #endif
198219
220 #if defined(ZLIB_CONST) && !defined(z_const)
221 # define z_const const
222 #else
223 # define z_const
224 #endif
225
199226 /* Some Mac compilers merge all .h files incorrectly: */
200227 #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
201228 # define NO_DUMMY_DECL
239266 # define OF(args) args
240267 # else
241268 # define OF(args) ()
269 # endif
270 #endif
271
272 #ifndef Z_ARG /* function prototypes for stdarg */
273 # if defined(STDC) || defined(Z_HAVE_STDARG_H)
274 # define Z_ARG(args) args
275 # else
276 # define Z_ARG(args) ()
242277 # endif
243278 #endif
244279
355390 typedef Byte *voidp;
356391 #endif
357392
393 #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
394 # include <limits.h>
395 # if (UINT_MAX == 0xffffffffUL)
396 # define Z_U4 unsigned
397 # elif (ULONG_MAX == 0xffffffffUL)
398 # define Z_U4 unsigned long
399 # elif (USHRT_MAX == 0xffffffffUL)
400 # define Z_U4 unsigned short
401 # endif
402 #endif
403
404 #ifdef Z_U4
405 typedef Z_U4 z_crc_t;
406 #else
407 typedef unsigned long z_crc_t;
408 #endif
409
358410 #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
359411 # define Z_HAVE_UNISTD_H
360412 #endif
361413
414 #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
415 # define Z_HAVE_STDARG_H
416 #endif
417
362418 #ifdef STDC
363 # include <sys/types.h> /* for off_t */
419 # ifndef Z_SOLO
420 # include <sys/types.h> /* for off_t */
421 # endif
422 #endif
423
424 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
425 # ifndef Z_SOLO
426 # include <stdarg.h> /* for va_list */
427 # endif
428 #endif
429
430 #ifdef _WIN32
431 # ifndef Z_SOLO
432 # include <stddef.h> /* for wchar_t */
433 # endif
364434 #endif
365435
366436 /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
369439 * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
370440 * equivalently requesting no 64-bit operations
371441 */
372 #if -_LARGEFILE64_SOURCE - -1 == 1
442 #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
373443 # undef _LARGEFILE64_SOURCE
374444 #endif
375445
376 #if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
377 # include <unistd.h> /* for SEEK_* and off_t */
378 # ifdef VMS
379 # include <unixio.h> /* for off_t */
380 # endif
381 # ifndef z_off_t
382 # define z_off_t off_t
383 # endif
384 #endif
385
386 #ifndef SEEK_SET
446 #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
447 # define Z_HAVE_UNISTD_H
448 #endif
449 #ifndef Z_SOLO
450 # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
451 # include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
452 # ifdef VMS
453 # include <unixio.h> /* for off_t */
454 # endif
455 # ifndef z_off_t
456 # define z_off_t off_t
457 # endif
458 # endif
459 #endif
460
461 #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
462 # define Z_LFS64
463 #endif
464
465 #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
466 # define Z_LARGE64
467 #endif
468
469 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
470 # define Z_WANT64
471 #endif
472
473 #if !defined(SEEK_SET) && !defined(Z_SOLO)
387474 # define SEEK_SET 0 /* Seek from beginning of file. */
388475 # define SEEK_CUR 1 /* Seek from current position. */
389476 # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
393480 # define z_off_t long
394481 #endif
395482
396 #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
483 #if !defined(_WIN32) && defined(Z_LARGE64)
397484 # define z_off64_t off64_t
398485 #else
399 # define z_off64_t z_off_t
400 #endif
401
402 #if defined(__OS400__)
403 # define NO_vsnprintf
404 #endif
405
406 #if defined(__MVS__)
407 # define NO_vsnprintf
486 # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
487 # define z_off64_t __int64
488 # else
489 # define z_off64_t z_off_t
490 # endif
408491 #endif
409492
410493 /* MVS linker does not support external names larger than 8 bytes */
00 /* zlib.h -- interface of the 'zlib' general purpose compression library
1 version 1.2.5, April 19th, 2010
2
3 Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
1 version 1.2.8, April 28th, 2013
2
3 Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
44
55 This software is provided 'as-is', without any express or implied
66 warranty. In no event will the authors be held liable for any damages
2323
2424
2525 The data format used by the zlib library is described by RFCs (Request for
26 Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
27 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
26 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
27 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
2828 */
2929
3030 #ifndef ZLIB_H
3636 extern "C" {
3737 #endif
3838
39 #define ZLIB_VERSION "1.2.5"
40 #define ZLIB_VERNUM 0x1250
39 #define ZLIB_VERSION "1.2.8"
40 #define ZLIB_VERNUM 0x1280
4141 #define ZLIB_VER_MAJOR 1
4242 #define ZLIB_VER_MINOR 2
43 #define ZLIB_VER_REVISION 5
43 #define ZLIB_VER_REVISION 8
4444 #define ZLIB_VER_SUBREVISION 0
4545
4646 /*
8282 struct internal_state;
8383
8484 typedef struct z_stream_s {
85 Bytef *next_in; /* next input byte */
85 z_const Bytef *next_in; /* next input byte */
8686 uInt avail_in; /* number of bytes available at next_in */
87 uLong total_in; /* total nb of input bytes read so far */
87 uLong total_in; /* total number of input bytes read so far */
8888
8989 Bytef *next_out; /* next output byte should be put there */
9090 uInt avail_out; /* remaining free space at next_out */
91 uLong total_out; /* total nb of bytes output so far */
92
93 char *msg; /* last error message, NULL if no error */
91 uLong total_out; /* total number of bytes output so far */
92
93 z_const char *msg; /* last error message, NULL if no error */
9494 struct internal_state FAR *state; /* not visible by applications */
9595
9696 alloc_func zalloc; /* used to allocate the internal state */
326326
327327 Z_FINISH can be used immediately after deflateInit if all the compression
328328 is to be done in a single step. In this case, avail_out must be at least the
329 value returned by deflateBound (see below). If deflate does not return
330 Z_STREAM_END, then it must be called again as described above.
329 value returned by deflateBound (see below). Then deflate is guaranteed to
330 return Z_STREAM_END. If not enough output space is provided, deflate will
331 not return Z_STREAM_END, and it must be called again as described above.
331332
332333 deflate() sets strm->adler to the adler32 checksum of all input read
333334 so far (that is, total_in bytes).
450451 error. However if all decompression is to be performed in a single step (a
451452 single call of inflate), the parameter flush should be set to Z_FINISH. In
452453 this case all pending input is processed and all pending output is flushed;
453 avail_out must be large enough to hold all the uncompressed data. (The size
454 of the uncompressed data may have been saved by the compressor for this
455 purpose.) The next operation on this stream must be inflateEnd to deallocate
456 the decompression state. The use of Z_FINISH is never required, but can be
457 used to inform inflate that a faster approach may be used for the single
458 inflate() call.
454 avail_out must be large enough to hold all of the uncompressed data for the
455 operation to complete. (The size of the uncompressed data may have been
456 saved by the compressor for this purpose.) The use of Z_FINISH is not
457 required to perform an inflation in one step. However it may be used to
458 inform inflate that a faster approach can be used for the single inflate()
459 call. Z_FINISH also informs inflate to not maintain a sliding window if the
460 stream completes, which reduces inflate's memory footprint. If the stream
461 does not complete, either because not all of the stream is provided or not
462 enough output space is provided, then a sliding window will be allocated and
463 inflate() can be called again to continue the operation as if Z_NO_FLUSH had
464 been used.
459465
460466 In this implementation, inflate() always flushes as much output as
461467 possible to the output buffer, and always uses the faster approach on the
462 first call. So the only effect of the flush parameter in this implementation
463 is on the return value of inflate(), as noted below, or when it returns early
464 because Z_BLOCK or Z_TREES is used.
468 first call. So the effects of the flush parameter in this implementation are
469 on the return value of inflate() as noted below, when inflate() returns early
470 when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
471 memory for a sliding window when Z_FINISH is used.
465472
466473 If a preset dictionary is needed after this call (see inflateSetDictionary
467 below), inflate sets strm->adler to the adler32 checksum of the dictionary
474 below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
468475 chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
469 strm->adler to the adler32 checksum of all output produced so far (that is,
476 strm->adler to the Adler-32 checksum of all output produced so far (that is,
470477 total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
471478 below. At the end of the stream, inflate() checks that its computed adler32
472479 checksum is equal to that saved by the compressor and returns Z_STREAM_END
477484 initializing with inflateInit2(). Any information contained in the gzip
478485 header is not retained, so applications that need that information should
479486 instead use raw inflate, see inflateInit2() below, or inflateBack() and
480 perform their own processing of the gzip header and trailer.
487 perform their own processing of the gzip header and trailer. When processing
488 gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
489 producted so far. The CRC-32 is checked against the gzip trailer.
481490
482491 inflate() returns Z_OK if some progress has been made (more input processed
483492 or more output produced), Z_STREAM_END if the end of the compressed data has
579588 uInt dictLength));
580589 /*
581590 Initializes the compression dictionary from the given byte sequence
582 without producing any compressed output. This function must be called
583 immediately after deflateInit, deflateInit2 or deflateReset, before any call
584 of deflate. The compressor and decompressor must use exactly the same
585 dictionary (see inflateSetDictionary).
591 without producing any compressed output. When using the zlib format, this
592 function must be called immediately after deflateInit, deflateInit2 or
593 deflateReset, and before any call of deflate. When doing raw deflate, this
594 function must be called either before any call of deflate, or immediately
595 after the completion of a deflate block, i.e. after all input has been
596 consumed and all output has been delivered when using any of the flush
597 options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The
598 compressor and decompressor must use exactly the same dictionary (see
599 inflateSetDictionary).
586600
587601 The dictionary should consist of strings (byte sequences) that are likely
588602 to be encountered later in the data to be compressed, with the most commonly
609623 deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
610624 parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
611625 inconsistent (for example if deflate has already been called for this stream
612 or if the compression method is bsort). deflateSetDictionary does not
613 perform any compression: this will be done by deflate().
626 or if not at a block boundary for raw deflate). deflateSetDictionary does
627 not perform any compression: this will be done by deflate().
614628 */
615629
616630 ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
687701 deflation of sourceLen bytes. It must be called after deflateInit() or
688702 deflateInit2(), and after deflateSetHeader(), if used. This would be used
689703 to allocate an output buffer for deflation in a single pass, and so would be
690 called before deflate().
691 */
704 called before deflate(). If that first deflate() call is provided the
705 sourceLen input bytes, an output buffer allocated to the size returned by
706 deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
707 to return Z_STREAM_END. Note that it is possible for the compressed size to
708 be larger than the value returned by deflateBound() if flush options other
709 than Z_FINISH or Z_NO_FLUSH are used.
710 */
711
712 ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
713 unsigned *pending,
714 int *bits));
715 /*
716 deflatePending() returns the number of bytes and bits of output that have
717 been generated, but not yet provided in the available output. The bytes not
718 provided would be due to the available output space having being consumed.
719 The number of bits of output not provided are between 0 and 7, where they
720 await more bits to join them in order to fill out a full byte. If pending
721 or bits are Z_NULL, then those values are not set.
722
723 deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
724 stream state was inconsistent.
725 */
692726
693727 ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
694728 int bits,
702736 than or equal to 16, and that many of the least significant bits of value
703737 will be inserted in the output.
704738
705 deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
706 stream state was inconsistent.
739 deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
740 room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
741 source stream state was inconsistent.
707742 */
708743
709744 ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
789824 if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
790825 can be determined from the adler32 value returned by that call of inflate.
791826 The compressor and decompressor must use exactly the same dictionary (see
792 deflateSetDictionary). For raw inflate, this function can be called
793 immediately after inflateInit2() or inflateReset() and before any call of
794 inflate() to set the dictionary. The application must insure that the
795 dictionary that was used for compression is provided.
827 deflateSetDictionary). For raw inflate, this function can be called at any
828 time to set the dictionary. If the provided dictionary is smaller than the
829 window and there is already data in the window, then the provided dictionary
830 will amend what's there. The application must insure that the dictionary
831 that was used for compression is provided.
796832
797833 inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
798834 parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
802838 inflate().
803839 */
804840
841 ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
842 Bytef *dictionary,
843 uInt *dictLength));
844 /*
845 Returns the sliding dictionary being maintained by inflate. dictLength is
846 set to the number of bytes in the dictionary, and that many bytes are copied
847 to dictionary. dictionary must have enough space, where 32768 bytes is
848 always enough. If inflateGetDictionary() is called with dictionary equal to
849 Z_NULL, then only the dictionary length is returned, and nothing is copied.
850 Similary, if dictLength is Z_NULL, then it is not set.
851
852 inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
853 stream state is inconsistent.
854 */
855
805856 ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
806857 /*
807 Skips invalid compressed data until a full flush point (see above the
808 description of deflate with Z_FULL_FLUSH) can be found, or until all
858 Skips invalid compressed data until a possible full flush point (see above
859 for the description of deflate with Z_FULL_FLUSH) can be found, or until all
809860 available input is skipped. No output is provided.
810861
811 inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
812 if no more input was provided, Z_DATA_ERROR if no flush point has been
813 found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the
814 success case, the application may save the current current value of total_in
815 which indicates where valid compressed data was found. In the error case,
816 the application may repeatedly call inflateSync, providing more input each
817 time, until success or end of the input data.
862 inflateSync searches for a 00 00 FF FF pattern in the compressed data.
863 All full flush points have this pattern, but not all occurrences of this
864 pattern are full flush points.
865
866 inflateSync returns Z_OK if a possible full flush point has been found,
867 Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
868 has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
869 In the success case, the application may save the current current value of
870 total_in which indicates where valid compressed data was found. In the
871 error case, the application may repeatedly call inflateSync, providing more
872 input each time, until success or end of the input data.
818873 */
819874
820875 ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
9611016 See inflateBack() for the usage of these routines.
9621017
9631018 inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
964 the paramaters are invalid, Z_MEM_ERROR if the internal state could not be
1019 the parameters are invalid, Z_MEM_ERROR if the internal state could not be
9651020 allocated, or Z_VERSION_ERROR if the version of the library does not match
9661021 the version of the header file.
9671022 */
9681023
969 typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
1024 typedef unsigned (*in_func) OF((void FAR *,
1025 z_const unsigned char FAR * FAR *));
9701026 typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
9711027
9721028 ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
9741030 out_func out, void FAR *out_desc));
9751031 /*
9761032 inflateBack() does a raw inflate with a single call using a call-back
977 interface for input and output. This is more efficient than inflate() for
978 file i/o applications in that it avoids copying between the output and the
979 sliding window by simply making the window itself the output buffer. This
980 function trusts the application to not change the output buffer passed by
981 the output function, at least until inflateBack() returns.
1033 interface for input and output. This is potentially more efficient than
1034 inflate() for file i/o applications, in that it avoids copying between the
1035 output and the sliding window by simply making the window itself the output
1036 buffer. inflate() can be faster on modern CPUs when used with large
1037 buffers. inflateBack() trusts the application to not change the output
1038 buffer passed by the output function, at least until inflateBack() returns.
9821039
9831040 inflateBackInit() must be called first to allocate the internal state
9841041 and to initialize the state with the user-provided window buffer.
10871144 27-31: 0 (reserved)
10881145 */
10891146
1147 #ifndef Z_SOLO
10901148
10911149 /* utility functions */
10921150
11481206
11491207 uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
11501208 enough memory, Z_BUF_ERROR if there was not enough room in the output
1151 buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
1152 */
1153
1209 buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
1210 the case where there is not enough room, uncompress() will fill the output
1211 buffer with the uncompressed data up to that point.
1212 */
11541213
11551214 /* gzip file access functions */
11561215
11611220 wrapper, documented in RFC 1952, wrapped around a deflate stream.
11621221 */
11631222
1164 typedef voidp gzFile; /* opaque gzip file descriptor */
1223 typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
11651224
11661225 /*
11671226 ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
11711230 a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
11721231 compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
11731232 for fixed code compression as in "wb9F". (See the description of
1174 deflateInit2 for more information about the strategy parameter.) Also "a"
1175 can be used instead of "w" to request that the gzip stream that will be
1176 written be appended to the file. "+" will result in an error, since reading
1177 and writing to the same gzip file is not supported.
1233 deflateInit2 for more information about the strategy parameter.) 'T' will
1234 request transparent writing or appending with no compression and not using
1235 the gzip format.
1236
1237 "a" can be used instead of "w" to request that the gzip stream that will
1238 be written be appended to the file. "+" will result in an error, since
1239 reading and writing to the same gzip file is not supported. The addition of
1240 "x" when writing will create the file exclusively, which fails if the file
1241 already exists. On systems that support it, the addition of "e" when
1242 reading or writing will set the flag to close the file on an execve() call.
1243
1244 These functions, as well as gzip, will read and decode a sequence of gzip
1245 streams in a file. The append function of gzopen() can be used to create
1246 such a file. (Also see gzflush() for another way to do this.) When
1247 appending, gzopen does not test whether the file begins with a gzip stream,
1248 nor does it look for the end of the gzip streams to begin appending. gzopen
1249 will simply append a gzip stream to the existing file.
11781250
11791251 gzopen can be used to read a file which is not in gzip format; in this
1180 case gzread will directly read from the file without decompression.
1252 case gzread will directly read from the file without decompression. When
1253 reading, this will be detected automatically by looking for the magic two-
1254 byte gzip header.
11811255
11821256 gzopen returns NULL if the file could not be opened, if there was
11831257 insufficient memory to allocate the gzFile state, or if an invalid mode was
11961270 descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
11971271 fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
11981272 mode);. The duplicated descriptor should be saved to avoid a leak, since
1199 gzdopen does not close fd if it fails.
1273 gzdopen does not close fd if it fails. If you are using fileno() to get the
1274 file descriptor from a FILE *, then you will have to use dup() to avoid
1275 double-close()ing the file descriptor. Both gzclose() and fclose() will
1276 close the associated file descriptor, so they need to have different file
1277 descriptors.
12001278
12011279 gzdopen returns NULL if there was insufficient memory to allocate the
12021280 gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
12341312 ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
12351313 /*
12361314 Reads the given number of uncompressed bytes from the compressed file. If
1237 the input file was not in gzip format, gzread copies the given number of
1238 bytes into the buffer.
1315 the input file is not in gzip format, gzread copies the given number of
1316 bytes into the buffer directly from the file.
12391317
12401318 After reaching the end of a gzip stream in the input, gzread will continue
1241 to read, looking for another gzip stream, or failing that, reading the rest
1242 of the input file directly without decompression. The entire input file
1243 will be read if gzread is called until it returns less than the requested
1244 len.
1319 to read, looking for another gzip stream. Any number of gzip streams may be
1320 concatenated in the input file, and will all be decompressed by gzread().
1321 If something other than a gzip stream is encountered after a gzip stream,
1322 that remaining trailing garbage is ignored (and no error is returned).
1323
1324 gzread can be used to read a gzip file that is being concurrently written.
1325 Upon reaching the end of the input, gzread will return with the available
1326 data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
1327 gzclearerr can be used to clear the end of file indicator in order to permit
1328 gzread to be tried again. Z_OK indicates that a gzip stream was completed
1329 on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
1330 middle of a gzip stream. Note that gzread does not return -1 in the event
1331 of an incomplete gzip stream. This error is deferred until gzclose(), which
1332 will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
1333 stream. Alternatively, gzerror can be used before gzclose to detect this
1334 case.
12451335
12461336 gzread returns the number of uncompressed bytes actually read, less than
12471337 len for end of file, or -1 for error.
12551345 error.
12561346 */
12571347
1258 ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
1348 ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
12591349 /*
12601350 Converts, formats, and writes the arguments to the compressed file under
12611351 control of the format string, as in fprintf. gzprintf returns the number of
13001390 ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
13011391 /*
13021392 Reads one byte from the compressed file. gzgetc returns this byte or -1
1303 in case of end of file or error.
1393 in case of end of file or error. This is implemented as a macro for speed.
1394 As such, it does not do all of the checking the other functions do. I.e.
1395 it does not check to see if file is NULL, nor whether the structure file
1396 points to has been clobbered or not.
13041397 */
13051398
13061399 ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
13961489 ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
13971490 /*
13981491 Returns true (1) if file is being copied directly while reading, or false
1399 (0) if file is a gzip stream being decompressed. This state can change from
1400 false to true while reading the input file if the end of a gzip stream is
1401 reached, but is followed by data that is not another gzip stream.
1492 (0) if file is a gzip stream being decompressed.
14021493
14031494 If the input file is empty, gzdirect() will return true, since the input
14041495 does not contain a gzip stream.
14071498 cause buffers to be allocated to allow reading the file to determine if it
14081499 is a gzip file. Therefore if gzbuffer() is used, it should be called before
14091500 gzdirect().
1501
1502 When writing, gzdirect() returns true (1) if transparent writing was
1503 requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
1504 gzdirect() is not needed when writing. Transparent writing must be
1505 explicitly requested, so the application already knows the answer. When
1506 linking statically, using gzdirect() will include all of the zlib code for
1507 gzip file reading and decompression, which may not be desired.)
14101508 */
14111509
14121510 ZEXTERN int ZEXPORT gzclose OF((gzFile file));
14181516 must not be called more than once on the same allocation.
14191517
14201518 gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
1421 file operation error, or Z_OK on success.
1519 file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
1520 last read ended in the middle of a gzip stream, or Z_OK on success.
14221521 */
14231522
14241523 ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
14561555 file that is being written concurrently.
14571556 */
14581557
1558 #endif /* !Z_SOLO */
14591559
14601560 /* checksum functions */
14611561
14911591 Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
14921592 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
14931593 each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
1494 seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
1594 seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
1595 that the z_off_t type (like off_t) is a signed integer. If len2 is
1596 negative, the result has no meaning or utility.
14951597 */
14961598
14971599 ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
14981600 /*
14991601 Update a running CRC-32 with the bytes buf[0..len-1] and return the
15001602 updated CRC-32. If buf is Z_NULL, this function returns the required
1501 initial value for the for the crc. Pre- and post-conditioning (one's
1502 complement) is performed within this function so it shouldn't be done by the
1503 application.
1603 initial value for the crc. Pre- and post-conditioning (one's complement) is
1604 performed within this function so it shouldn't be done by the application.
15041605
15051606 Usage example:
15061607
15431644 const char *version,
15441645 int stream_size));
15451646 #define deflateInit(strm, level) \
1546 deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
1647 deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
15471648 #define inflateInit(strm) \
1548 inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
1649 inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
15491650 #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
15501651 deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
1551 (strategy), ZLIB_VERSION, sizeof(z_stream))
1652 (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
15521653 #define inflateInit2(strm, windowBits) \
1553 inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
1654 inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
1655 (int)sizeof(z_stream))
15541656 #define inflateBackInit(strm, windowBits, window) \
15551657 inflateBackInit_((strm), (windowBits), (window), \
1556 ZLIB_VERSION, sizeof(z_stream))
1658 ZLIB_VERSION, (int)sizeof(z_stream))
1659
1660 #ifndef Z_SOLO
1661
1662 /* gzgetc() macro and its supporting function and exposed data structure. Note
1663 * that the real internal state is much larger than the exposed structure.
1664 * This abbreviated structure exposes just enough for the gzgetc() macro. The
1665 * user should not mess with these exposed elements, since their names or
1666 * behavior could change in the future, perhaps even capriciously. They can
1667 * only be used by the gzgetc() macro. You have been warned.
1668 */
1669 struct gzFile_s {
1670 unsigned have;
1671 unsigned char *next;
1672 z_off64_t pos;
1673 };
1674 ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
1675 #ifdef Z_PREFIX_SET
1676 # undef z_gzgetc
1677 # define z_gzgetc(g) \
1678 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
1679 #else
1680 # define gzgetc(g) \
1681 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
1682 #endif
15571683
15581684 /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
15591685 * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
15611687 * functions are changed to 64 bits) -- in case these are set on systems
15621688 * without large file support, _LFS64_LARGEFILE must also be true
15631689 */
1564 #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
1690 #ifdef Z_LARGE64
15651691 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
15661692 ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
15671693 ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
15701696 ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
15711697 #endif
15721698
1573 #if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
1574 # define gzopen gzopen64
1575 # define gzseek gzseek64
1576 # define gztell gztell64
1577 # define gzoffset gzoffset64
1578 # define adler32_combine adler32_combine64
1579 # define crc32_combine crc32_combine64
1580 # ifdef _LARGEFILE64_SOURCE
1699 #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
1700 # ifdef Z_PREFIX_SET
1701 # define z_gzopen z_gzopen64
1702 # define z_gzseek z_gzseek64
1703 # define z_gztell z_gztell64
1704 # define z_gzoffset z_gzoffset64
1705 # define z_adler32_combine z_adler32_combine64
1706 # define z_crc32_combine z_crc32_combine64
1707 # else
1708 # define gzopen gzopen64
1709 # define gzseek gzseek64
1710 # define gztell gztell64
1711 # define gzoffset gzoffset64
1712 # define adler32_combine adler32_combine64
1713 # define crc32_combine crc32_combine64
1714 # endif
1715 # ifndef Z_LARGE64
15811716 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
15821717 ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
15831718 ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
15941729 ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
15951730 #endif
15961731
1732 #else /* Z_SOLO */
1733
1734 ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
1735 ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
1736
1737 #endif /* !Z_SOLO */
1738
15971739 /* hack for buggy compilers */
15981740 #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
15991741 struct internal_state {int dummy;};
16021744 /* undocumented functions */
16031745 ZEXTERN const char * ZEXPORT zError OF((int));
16041746 ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
1605 ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
1747 ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
16061748 ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
1749 ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
1750 ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
1751 #if defined(_WIN32) && !defined(Z_SOLO)
1752 ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
1753 const char *mode));
1754 #endif
1755 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
1756 # ifndef Z_SOLO
1757 ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
1758 const char *format,
1759 va_list va));
1760 # endif
1761 #endif
16071762
16081763 #ifdef __cplusplus
16091764 }
00 /* zutil.c -- target dependent utility functions for the compression library
1 * Copyright (C) 1995-2005, 2010 Jean-loup Gailly.
1 * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
5 /* @(#) $Id: zutil.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
5 /* @(#) $Id$ */
66
77 #include "zutil.h"
8 #ifndef Z_SOLO
9 # include "gzguts.h"
10 #endif
811
912 #ifndef NO_DUMMY_DECL
1013 struct internal_state {int dummy;}; /* for buggy compilers */
1114 #endif
1215
13 const char * const z_errmsg[10] = {
16 z_const char * const z_errmsg[10] = {
1417 "need dictionary", /* Z_NEED_DICT 2 */
1518 "stream end", /* Z_STREAM_END 1 */
1619 "", /* Z_OK 0 */
8487 #ifdef FASTEST
8588 flags += 1L << 21;
8689 #endif
87 #ifdef STDC
90 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
8891 # ifdef NO_vsnprintf
89 flags += 1L << 25;
92 flags += 1L << 25;
9093 # ifdef HAS_vsprintf_void
91 flags += 1L << 26;
94 flags += 1L << 26;
9295 # endif
9396 # else
9497 # ifdef HAS_vsnprintf_void
95 flags += 1L << 26;
98 flags += 1L << 26;
9699 # endif
97100 # endif
98101 #else
99 flags += 1L << 24;
102 flags += 1L << 24;
100103 # ifdef NO_snprintf
101 flags += 1L << 25;
104 flags += 1L << 25;
102105 # ifdef HAS_sprintf_void
103 flags += 1L << 26;
106 flags += 1L << 26;
104107 # endif
105108 # else
106109 # ifdef HAS_snprintf_void
107 flags += 1L << 26;
110 flags += 1L << 26;
108111 # endif
109112 # endif
110113 #endif
180183 }
181184 #endif
182185
186 #ifndef Z_SOLO
183187
184188 #ifdef SYS16BIT
185189
315319 }
316320
317321 #endif /* MY_ZCALLOC */
322
323 #endif /* !Z_SOLO */
00 /* zutil.h -- internal interface and configuration of the compression library
1 * Copyright (C) 1995-2010 Jean-loup Gailly.
1 * Copyright (C) 1995-2013 Jean-loup Gailly.
22 * For conditions of distribution and use, see copyright notice in zlib.h
33 */
44
77 subject to change. Applications should only use zlib.h.
88 */
99
10 /* @(#) $Id: zutil.h,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */
10 /* @(#) $Id$ */
1111
1212 #ifndef ZUTIL_H
1313 #define ZUTIL_H
1414
15 #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
15 #ifdef HAVE_HIDDEN
1616 # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
1717 #else
1818 # define ZLIB_INTERNAL
2020
2121 #include "zlib.h"
2222
23 #ifdef STDC
23 #if defined(STDC) && !defined(Z_SOLO)
2424 # if !(defined(_WIN32_WCE) && defined(_MSC_VER))
2525 # include <stddef.h>
2626 # endif
2727 # include <string.h>
2828 # include <stdlib.h>
29 #endif
30
31 #ifdef Z_SOLO
32 typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
2933 #endif
3034
3135 #ifndef local
3943 typedef ush FAR ushf;
4044 typedef unsigned long ulg;
4145
42 extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
46 extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
4347 /* (size given to avoid silly warnings with Visual C++) */
4448
4549 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
4650
4751 #define ERR_RETURN(strm,err) \
48 return (strm->msg = (char*)ERR_MSG(err), (err))
52 return (strm->msg = ERR_MSG(err), (err))
4953 /* To be used only when the state is known to be valid */
5054
5155 /* common constants */
7781
7882 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
7983 # define OS_CODE 0x00
80 # if defined(__TURBOC__) || defined(__BORLANDC__)
81 # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
82 /* Allow compilation with ANSI keywords only enabled */
83 void _Cdecl farfree( void *block );
84 void *_Cdecl farmalloc( unsigned long nbytes );
85 # else
86 # include <alloc.h>
84 # ifndef Z_SOLO
85 # if defined(__TURBOC__) || defined(__BORLANDC__)
86 # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
87 /* Allow compilation with ANSI keywords only enabled */
88 void _Cdecl farfree( void *block );
89 void *_Cdecl farmalloc( unsigned long nbytes );
90 # else
91 # include <alloc.h>
92 # endif
93 # else /* MSC or DJGPP */
94 # include <malloc.h>
8795 # endif
88 # else /* MSC or DJGPP */
89 # include <malloc.h>
9096 # endif
9197 #endif
9298
106112
107113 #ifdef OS2
108114 # define OS_CODE 0x06
109 # ifdef M_I86
115 # if defined(M_I86) && !defined(Z_SOLO)
110116 # include <malloc.h>
111117 # endif
112118 #endif
113119
114120 #if defined(MACOS) || defined(TARGET_OS_MAC)
115121 # define OS_CODE 0x07
116 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
117 # include <unix.h> /* for fdopen */
118 # else
119 # ifndef fdopen
120 # define fdopen(fd,mode) NULL /* No fdopen() */
122 # ifndef Z_SOLO
123 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
124 # include <unix.h> /* for fdopen */
125 # else
126 # ifndef fdopen
127 # define fdopen(fd,mode) NULL /* No fdopen() */
128 # endif
121129 # endif
122130 # endif
123131 #endif
152160 # endif
153161 #endif
154162
155 #if defined(__BORLANDC__)
163 #if defined(__BORLANDC__) && !defined(MSDOS)
156164 #pragma warn -8004
157165 #pragma warn -8008
158166 #pragma warn -8066
159167 #endif
160168
161169 /* provide prototypes for these when building zlib without LFS */
162 #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
170 #if !defined(_WIN32) && \
171 (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
163172 ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
164173 ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
165174 #endif
176185
177186 /* functions */
178187
179 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
180 # ifndef HAVE_VSNPRINTF
181 # define HAVE_VSNPRINTF
182 # endif
183 #endif
184 #if defined(__CYGWIN__)
185 # ifndef HAVE_VSNPRINTF
186 # define HAVE_VSNPRINTF
187 # endif
188 #endif
189 #ifndef HAVE_VSNPRINTF
190 # ifdef MSDOS
191 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
192 but for now we just assume it doesn't. */
193 # define NO_vsnprintf
194 # endif
195 # ifdef __TURBOC__
196 # define NO_vsnprintf
197 # endif
198 # ifdef WIN32
199 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
200 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
201 # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
202 # define vsnprintf _vsnprintf
203 # endif
204 # endif
205 # endif
206 # ifdef __SASC
207 # define NO_vsnprintf
208 # endif
209 #endif
210 #ifdef VMS
211 # define NO_vsnprintf
212 #endif
213
214 #if defined(pyr)
188 #if defined(pyr) || defined(Z_SOLO)
215189 # define NO_MEMCPY
216190 #endif
217191 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
260234 # define Tracecv(c,x)
261235 #endif
262236
263
264 voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
265 unsigned size));
266 void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
237 #ifndef Z_SOLO
238 voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
239 unsigned size));
240 void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
241 #endif
267242
268243 #define ZALLOC(strm, items, size) \
269244 (*((strm)->zalloc))((strm)->opaque, (items), (size))
270245 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
271246 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
272247
248 /* Reverse the bytes in a 32-bit value */
249 #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
250 (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
251
273252 #endif /* ZUTIL_H */
00 /*
1 * Copyright (c) Tony Bybell 2001-2011.
1 * Copyright (c) Tony Bybell 2001-2013.
22 *
33 * This program is free software; you can redistribute it and/or
44 * modify it under the terms of the GNU General Public License
182182
183183 #ifdef USE_X86_INLINE_ASM
184184
185 inline static unsigned int get_byte(offset) {
185 inline static unsigned int get_byte(off_t offset) {
186186 return ((unsigned int)(*((unsigned char *) GLOBALS->mm_lxt_c_1+offset)));
187187 }
188188
00 /*
1 * Copyright (c) Tony Bybell 1999-2012.
1 * Copyright (c) Tony Bybell 1999-2013.
22 *
33 * This program is free software; you can redistribute it and/or
44 * modify it under the terms of the GNU General Public License
369369 }
370370 #endif
371371 }
372 fileselbox_old("GTKWave: Select a dumpfile...",&GLOBALS->ftext_main_main_c_1,GTK_SIGNAL_FUNC(wave_get_filename_cleanup), GTK_SIGNAL_FUNC(wave_get_filename_cleanup), NULL);
372 fileselbox_old("GTKWave: Select a dumpfile...",&GLOBALS->ftext_main_main_c_1,GTK_SIGNAL_FUNC(wave_get_filename_cleanup), GTK_SIGNAL_FUNC(wave_get_filename_cleanup), NULL, 0);
373373 gtk_main();
374374
375375 return(GLOBALS->ftext_main_main_c_1);
54255425 static void
54265426 menu_open_hierarchy_2a(gpointer null_data, guint callback_action, GtkWidget *widget, int typ)
54275427 {
5428 Trptr t;
5429 int fix=0;
54305428 if(GLOBALS->helpbox_is_active)
54315429 {
54325430 if((typ == FST_MT_SOURCESTEM) || (typ == FST_MT_SOURCEISTEM))
00 /*
1 * Copyright (c) Tony Bybell 1999-2012.
1 * Copyright (c) Tony Bybell 1999-2013.
22 *
33 * This program is free software; you can redistribute it and/or
44 * modify it under the terms of the GNU General Public License
412412 */
413413 static gint keypress_local(GtkWidget *widget, GdkEventKey *event, gpointer data)
414414 {
415 GtkAdjustment *wadj, *hadj;
415 GtkAdjustment *wadj;
416416 int num_traces_displayable;
417417 int target;
418418 int which;
526526 case GDK_Left:
527527 case GDK_KP_Left:
528528
529 service_left_edge(NULL, 0);
530 /*
529531 hadj=GTK_ADJUSTMENT(GLOBALS->signal_hslider);
530532
531533 if(hadj->value < hadj->page_increment)
537539 hadj->value = hadj->value - hadj->page_increment;
538540 }
539541
540 gtk_signal_emit_by_name (GTK_OBJECT (hadj), "changed"); /* force bar update */
541 gtk_signal_emit_by_name (GTK_OBJECT (hadj), "value_changed"); /* force text update */
542 gtk_signal_emit_by_name (GTK_OBJECT (hadj), "changed");
543 gtk_signal_emit_by_name (GTK_OBJECT (hadj), "value_changed");
542544 signalarea_configure_event(GLOBALS->signalarea, NULL);
545 */
543546
544547 rc = TRUE;
545548 break;
547550 case GDK_Right:
548551 case GDK_KP_Right:
549552
550 /* fill in left/right hscroll here */
553 service_right_edge(NULL, 0);
554 /*
551555 hadj=GTK_ADJUSTMENT(GLOBALS->signal_hslider);
552556
553557 if( ((int) hadj->value + hadj->page_increment) >= hadj->upper)
559563 hadj->value = hadj->value + hadj->page_increment;
560564 }
561565
562 gtk_signal_emit_by_name (GTK_OBJECT (hadj), "changed"); /* force bar update */
563 gtk_signal_emit_by_name (GTK_OBJECT (hadj), "value_changed"); /* force text update */
566 gtk_signal_emit_by_name (GTK_OBJECT (hadj), "changed");
567 gtk_signal_emit_by_name (GTK_OBJECT (hadj), "value_changed");
564568 signalarea_configure_event(GLOBALS->signalarea, NULL);
569 */
565570
566571 rc = TRUE;
567572 break;
714719 GdkEventMotion event[1];
715720 event[0].deviceid = GDK_CORE_POINTER;
716721 #endif
722
723 if(GLOBALS->button2_debounce_flag)
724 {
725 GLOBALS->button2_debounce_flag = 0;
726 }
727
728 if((GLOBALS->dnd_state)||(GLOBALS->tree_dnd_begin)) /* drag scroll on DnD */
729 {
730 GtkAdjustment *wadj;
731 int num_traces_displayable;
732 int target;
733 int which;
734 int yscroll;
735
736 WAVE_GDK_GET_POINTER(GLOBALS->signalarea->window, &x, &y, &xi, &yi, &state);
737 WAVE_GDK_GET_POINTER_COPY;
738
739 if(y > GLOBALS->signalarea->allocation.height)
740 {
741 wadj=GTK_ADJUSTMENT(GLOBALS->wave_vslider);
742 num_traces_displayable=(GLOBALS->signalarea->allocation.height)/(GLOBALS->fontheight);
743 num_traces_displayable--; /* for the time trace that is always there */
744
745 if(num_traces_displayable<GLOBALS->traces.visible)
746 {
747 yscroll = 1;
748 target=((int)wadj->value)+yscroll;
749 which=num_traces_displayable-1;
750
751 if(target+which>=(GLOBALS->traces.visible-1)) target=GLOBALS->traces.visible-which-1;
752 wadj->value=target;
753
754 if(GLOBALS->cachedwhich_signalwindow_c_1==which) GLOBALS->cachedwhich_signalwindow_c_1=which-1; /* force update */
755
756 gtk_signal_emit_by_name (GTK_OBJECT (wadj), "changed"); /* force bar update */
757 gtk_signal_emit_by_name (GTK_OBJECT (wadj), "value_changed"); /* force text update */
758 }
759 }
760 else
761 if(y < 0)
762 {
763 wadj=GTK_ADJUSTMENT(GLOBALS->wave_vslider);
764 num_traces_displayable=(GLOBALS->signalarea->allocation.height)/(GLOBALS->fontheight);
765 num_traces_displayable--; /* for the time trace that is always there */
766
767 if(num_traces_displayable<GLOBALS->traces.visible)
768 {
769 yscroll = 1;
770 target=((int)wadj->value)-yscroll;
771 if(target<0) target=0;
772 wadj->value=target;
773
774 which=0;
775 if(GLOBALS->cachedwhich_signalwindow_c_1==which) GLOBALS->cachedwhich_signalwindow_c_1=-1; /* force update */
776
777 gtk_signal_emit_by_name (GTK_OBJECT (wadj), "changed"); /* force bar update */
778 gtk_signal_emit_by_name (GTK_OBJECT (wadj), "value_changed"); /* force text update */
779 }
780 }
781 }
717782
718783 if(in_main_iteration()) return(TRUE);
719784
00 /*
1 * Copyright (c) Tony Bybell 1999-2011.
1 * Copyright (c) Tony Bybell 1999-2013.
22 *
33 * This program is free software; you can redistribute it and/or
44 * modify it under the terms of the GNU General Public License
3838
3939 static struct item_mark_string item_mark_start_strings[]=
4040 {
41 { "Start of Time" },
42 { "Named Marker A" },
43 { "Named Marker B" },
44 { "Named Marker C" },
45 { "Named Marker D" },
46 { "Named Marker E" },
47 { "Named Marker F" },
48 { "Named Marker G" },
49 { "Named Marker H" },
50 { "Named Marker I" },
51 { "Named Marker J" },
52 { "Named Marker K" },
53 { "Named Marker L" },
54 { "Named Marker M" },
55 { "Named Marker N" },
56 { "Named Marker O" },
57 { "Named Marker P" },
58 { "Named Marker Q" },
59 { "Named Marker R" },
60 { "Named Marker S" },
61 { "Named Marker T" },
62 { "Named Marker U" },
63 { "Named Marker V" },
64 { "Named Marker W" },
65 { "Named Marker X" },
66 { "Named Marker Y" },
67 { "Named Marker Z" }
41 { "Start of Time", 0 },
42 { "Named Marker A", 0 },
43 { "Named Marker B", 0 },
44 { "Named Marker C", 0 },
45 { "Named Marker D", 0 },
46 { "Named Marker E", 0 },
47 { "Named Marker F", 0 },
48 { "Named Marker G", 0 },
49 { "Named Marker H", 0 },
50 { "Named Marker I", 0 },
51 { "Named Marker J", 0 },
52 { "Named Marker K", 0 },
53 { "Named Marker L", 0 },
54 { "Named Marker M", 0 },
55 { "Named Marker N", 0 },
56 { "Named Marker O", 0 },
57 { "Named Marker P", 0 },
58 { "Named Marker Q", 0 },
59 { "Named Marker R", 0 },
60 { "Named Marker S", 0 },
61 { "Named Marker T", 0 },
62 { "Named Marker U", 0 },
63 { "Named Marker V", 0 },
64 { "Named Marker W", 0 },
65 { "Named Marker X", 0 },
66 { "Named Marker Y", 0 },
67 { "Named Marker Z", 0 }
6868 };
6969
7070 static struct item_mark_string item_mark_end_strings[]=
7171 {
72 { "End of Time" },
73 { "Named Marker A" },
74 { "Named Marker B" },
75 { "Named Marker C" },
76 { "Named Marker D" },
77 { "Named Marker E" },
78 { "Named Marker F" },
79 { "Named Marker G" },
80 { "Named Marker H" },
81 { "Named Marker I" },
82 { "Named Marker J" },
83 { "Named Marker K" },
84 { "Named Marker L" },
85 { "Named Marker M" },
86 { "Named Marker N" },
87 { "Named Marker O" },
88 { "Named Marker P" },
89 { "Named Marker Q" },
90 { "Named Marker R" },
91 { "Named Marker S" },
92 { "Named Marker T" },
93 { "Named Marker U" },
94 { "Named Marker V" },
95 { "Named Marker W" },
96 { "Named Marker X" },
97 { "Named Marker Y" },
98 { "Named Marker Z" }
72 { "End of Time", 0 },
73 { "Named Marker A", 0 },
74 { "Named Marker B", 0 },
75 { "Named Marker C", 0 },
76 { "Named Marker D", 0 },
77 { "Named Marker E", 0 },
78 { "Named Marker F", 0 },
79 { "Named Marker G", 0 },
80 { "Named Marker H", 0 },
81 { "Named Marker I", 0 },
82 { "Named Marker J", 0 },
83 { "Named Marker K", 0 },
84 { "Named Marker L", 0 },
85 { "Named Marker M", 0 },
86 { "Named Marker N", 0 },
87 { "Named Marker O", 0 },
88 { "Named Marker P", 0 },
89 { "Named Marker Q", 0 },
90 { "Named Marker R", 0 },
91 { "Named Marker S", 0 },
92 { "Named Marker T", 0 },
93 { "Named Marker U", 0 },
94 { "Named Marker V", 0 },
95 { "Named Marker W", 0 },
96 { "Named Marker X", 0 },
97 { "Named Marker Y", 0 },
98 { "Named Marker Z", 0 }
9999 };
100100
101101
24772477 bts->nodes[i]->harray = NULL;
24782478 }
24792479 }
2480 else
2481 {
2482 t->interactive_vector_needs_regeneration = 1;
2483 }
24802484 }
24812485 }
24822486
26502654 gtkwave_main_iteration();
26512655 }
26522656
2657
2658 static void vcd_partial_regen_node_expansion(Trptr t)
2659 {
2660 if(!t->vector)
2661 {
2662 if(t->n.nd && t->n.nd->expansion)
2663 {
2664 nptr np_ex = ExtractNodeSingleBit(t->n.nd->expansion->parent, t->n.nd->expansion->parentbit);
2665
2666 DeleteNode(t->n.nd);
2667 t->n.nd = np_ex;
2668 t->name_full = np_ex->nname;
2669 t->name = (GLOBALS->hier_max_level) ? hier_extract(t->name_full, GLOBALS->hier_max_level) : t->name_full;
2670 }
2671 }
2672
2673 }
2674
26532675 void vcd_partial_mark_and_sweep(int mandclear)
26542676 {
26552677 Trptr t;
2678
2679
26562680
26572681 /* node */
26582682 t = GLOBALS->traces.first; while(t) { if(!t->vector) regen_trace_mark(t, mandclear); t = t->t_next; }
26612685 t = GLOBALS->traces.first; while(t) { if(!t->vector) regen_trace_sweep(t); t = t->t_next; }
26622686 t = GLOBALS->traces.buffer; while(t) { if(!t->vector) regen_trace_sweep(t); t = t->t_next; }
26632687
2688 /* node that is single bit extracted */
2689 t = GLOBALS->traces.first; while(t) { vcd_partial_regen_node_expansion(t); t = t->t_next; }
2690 t = GLOBALS->traces.buffer; while(t) { vcd_partial_regen_node_expansion(t); t = t->t_next; }
2691
26642692 /* vector */
26652693 t = GLOBALS->traces.first; while(t) { if(t->vector) regen_trace_mark(t, mandclear); t = t->t_next; }
26662694 t = GLOBALS->traces.buffer; while(t) { if(t->vector) regen_trace_mark(t, mandclear); t = t->t_next; }
14681468 else
14691469 if(event->button==2)
14701470 {
1471 button_motion_common(event->x,event->y,1,1);
1471 if(!GLOBALS->button2_debounce_flag)
1472 {
1473 GLOBALS->button2_debounce_flag = 1; /* cleared by mouseover_timer() interrupt */
1474 button_motion_common(event->x,event->y,1,1);
1475 }
14721476 }
14731477
14741478 return(TRUE);