Imported Upstream version 3.3.52
أحمد المحمودي (Ahmed El-Mahmoudy)
10 years ago
10 | 10 | Hierarchy marker icons from the Silk icons set by Mark James found at the http://www.famfamfam.com/lab/icons/silk/ website. |
11 | 11 | 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. |
12 | 12 | NSAlert is Copyright (C) 2011-2013 Philipp Mayerhofer. |
13 | LZ4 is Copyright (C) 2011-2013 Yann Collet. |
1384 | 1384 | Fixed timezero in vcd2fst as it was only parsing unsigned |
1385 | 1385 | numbers. |
1386 | 1386 | 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 |
0 | 0 | ########################################################################## |
1 | 1 | |
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. | |
3 | 3 | Portions of GTKWave are Copyright (C) 1999-2013 Udi Finkelstein. |
4 | 4 | Context support is Copyright (C) 2007-2013 Kermin Elliott Fleming. |
5 | 5 | Trace group support is Copyright (C) 2009-2013 Donald Baltus. |
193 | 193 | EXTDEBUG = @EXTDEBUG@ |
194 | 194 | EXTDEBUG2 = @EXTDEBUG2@ |
195 | 195 | EXTDEBUG3 = @EXTDEBUG3@ |
196 | EXTDEBUG4 = @EXTDEBUG4@ | |
196 | 197 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
197 | 198 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
198 | 199 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
235 | 236 | LTLIBOBJS = @LTLIBOBJS@ |
236 | 237 | MAINT = @MAINT@ |
237 | 238 | MAKEINFO = @MAKEINFO@ |
239 | MINGW_LDADD = @MINGW_LDADD@ | |
238 | 240 | MKDIR_P = @MKDIR_P@ |
239 | 241 | OBJEXT = @OBJEXT@ |
240 | 242 | PACKAGE = @PACKAGE@ |
0 | 0 | #! /bin/sh |
1 | 1 | # 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. | |
3 | 3 | # |
4 | 4 | # Report bugs to <bybell@rocketmail.com>. |
5 | 5 | # |
579 | 579 | # Identity of this package. |
580 | 580 | PACKAGE_NAME='gtkwave' |
581 | 581 | 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' | |
584 | 584 | PACKAGE_BUGREPORT='bybell@rocketmail.com' |
585 | 585 | PACKAGE_URL='' |
586 | 586 | |
628 | 628 | TK_LDADD |
629 | 629 | TCL_DEFADD |
630 | 630 | TCL_LDADD |
631 | MINGW_LDADD | |
631 | 632 | POW_LIB |
632 | 633 | LIBOBJS |
633 | 634 | ALLOCA |
660 | 661 | LIBZ_CFLAGS |
661 | 662 | GPERF |
662 | 663 | EXTLOAD_CFLAGS |
664 | EXTDEBUG4 | |
663 | 665 | EXTDEBUG3 |
664 | 666 | EXTDEBUG2 |
665 | 667 | EXTDEBUG |
1381 | 1383 | # Omit some internal or obsolete options to make the list less imposing. |
1382 | 1384 | # This message is too long to be a string in the A/UX 3.1 sh. |
1383 | 1385 | 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. | |
1385 | 1387 | |
1386 | 1388 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1387 | 1389 | |
1447 | 1449 | |
1448 | 1450 | if test -n "$ac_init_help"; then |
1449 | 1451 | 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:";; | |
1451 | 1453 | esac |
1452 | 1454 | cat <<\_ACEOF |
1453 | 1455 | |
1593 | 1595 | test -n "$ac_init_help" && exit $ac_status |
1594 | 1596 | if $ac_init_version; then |
1595 | 1597 | cat <<\_ACEOF |
1596 | gtkwave configure 3.3.51 | |
1598 | gtkwave configure 3.3.52 | |
1597 | 1599 | generated by GNU Autoconf 2.69 |
1598 | 1600 | |
1599 | 1601 | Copyright (C) 2012 Free Software Foundation, Inc. |
2237 | 2239 | This file contains any messages produced by compilers while |
2238 | 2240 | running configure, to aid debugging if configure makes a mistake. |
2239 | 2241 | |
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 | |
2241 | 2243 | generated by GNU Autoconf 2.69. Invocation command line was |
2242 | 2244 | |
2243 | 2245 | $ $0 $@ |
3104 | 3106 | |
3105 | 3107 | # Define the identity of the package. |
3106 | 3108 | PACKAGE='gtkwave' |
3107 | VERSION='3.3.51' | |
3109 | VERSION='3.3.52' | |
3108 | 3110 | |
3109 | 3111 | |
3110 | 3112 | cat >>confdefs.h <<_ACEOF |
6371 | 6373 | EXTLOAD_CFLAGS="$EXTLOAD_CFLAGS -DEXT2CONV_PATH=\\\"$EXTDEBUG3\\\" -DEXT2LOAD_SUFFIX=\\\"vpd\\\"" |
6372 | 6374 | fi |
6373 | 6375 | |
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 | ||
6374 | 6423 | |
6375 | 6424 | |
6376 | 6425 | # |
10175 | 10224 | fi |
10176 | 10225 | else |
10177 | 10226 | if test "X$OSTYPE" = "Xmsys" ; then |
10227 | # add library for common dialog found in file.c | |
10228 | MINGW_LDADD="-lcomdlg32" | |
10178 | 10229 | # skip Tcl_CreateInterp check on mingw (until we figure out)... |
10179 | 10230 | if test "X$STUBIFY" = "Xyes" ; then |
10180 | 10231 | TCL_DEFADD="-DHAVE_LIBTCL -DWAVE_TCL_STUBIFY -DUSE_TCL_STUBS -DUSE_TK_STUBS" |
10311 | 10362 | LIBS : $LIBS |
10312 | 10363 | INLINE_ASM : $INLINE_ASM |
10313 | 10364 | |
10365 | MINGW_LDADD : $MINGW_LDADD | |
10314 | 10366 | GTK_MAC_CFLAGS : $GTK_MAC_CFLAGS |
10315 | 10367 | GTK_MAC_LIBS : $GTK_MAC_LIBS |
10316 | 10368 | COCOA_GTK_CFLAGS : $COCOA_GTK_CFLAGS |
10372 | 10424 | LIBS : $LIBS |
10373 | 10425 | INLINE_ASM : $INLINE_ASM |
10374 | 10426 | |
10427 | MINGW_LDADD : $MINGW_LDADD | |
10375 | 10428 | GTK_MAC_CFLAGS : $GTK_MAC_CFLAGS |
10376 | 10429 | GTK_MAC_LIBS : $GTK_MAC_LIBS |
10377 | 10430 | COCOA_GTK_CFLAGS : $COCOA_GTK_CFLAGS |
10930 | 10983 | # report actual input values of CONFIG_FILES etc. instead of their |
10931 | 10984 | # values after options handling. |
10932 | 10985 | 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 | |
10934 | 10987 | generated by GNU Autoconf 2.69. Invocation command line was |
10935 | 10988 | |
10936 | 10989 | CONFIG_FILES = $CONFIG_FILES |
10996 | 11049 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
10997 | 11050 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
10998 | 11051 | ac_cs_version="\\ |
10999 | gtkwave config.status 3.3.51 | |
11052 | gtkwave config.status 3.3.52 | |
11000 | 11053 | configured by $0, generated by GNU Autoconf 2.69, |
11001 | 11054 | with options \\"\$ac_cs_config\\" |
11002 | 11055 |
1 | 1 | # Process this file with autoconf to produce a configure script. |
2 | 2 | |
3 | 3 | AC_PREREQ(2.59) |
4 | AC_INIT(gtkwave, 3.3.51, bybell@rocketmail.com) | |
4 | AC_INIT(gtkwave, 3.3.52, bybell@rocketmail.com) | |
5 | 5 | AC_CONFIG_SRCDIR([src/vcd.c]) |
6 | 6 | AM_INIT_AUTOMAKE |
7 | 7 | AC_CONFIG_HEADER([config.h]) |
448 | 448 | AC_PATH_PROG(EXTDEBUG3, [vpd2vcd], [notfound]) |
449 | 449 | if test "$EXTDEBUG3" != "notfound" ; then |
450 | 450 | 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\\\"" | |
451 | 458 | fi |
452 | 459 | |
453 | 460 | AC_SUBST(EXTLOAD_CFLAGS) |
805 | 812 | fi |
806 | 813 | else |
807 | 814 | if test "X$OSTYPE" = "Xmsys" ; then |
815 | # add library for common dialog found in file.c | |
816 | MINGW_LDADD="-lcomdlg32" | |
808 | 817 | # skip Tcl_CreateInterp check on mingw (until we figure out)... |
809 | 818 | if test "X$STUBIFY" = "Xyes" ; then |
810 | 819 | TCL_DEFADD="-DHAVE_LIBTCL -DWAVE_TCL_STUBIFY -DUSE_TCL_STUBS -DUSE_TK_STUBS" |
841 | 850 | fi |
842 | 851 | fi |
843 | 852 | |
844 | ||
853 | AC_SUBST(MINGW_LDADD) | |
845 | 854 | AC_SUBST(TCL_LDADD) |
846 | 855 | AC_SUBST(TCL_DEFADD) |
847 | 856 | AC_SUBST(TK_LDADD) |
941 | 950 | LIBS : $LIBS |
942 | 951 | INLINE_ASM : $INLINE_ASM |
943 | 952 | |
953 | MINGW_LDADD : $MINGW_LDADD | |
944 | 954 | GTK_MAC_CFLAGS : $GTK_MAC_CFLAGS |
945 | 955 | GTK_MAC_LIBS : $GTK_MAC_LIBS |
946 | 956 | COCOA_GTK_CFLAGS : $COCOA_GTK_CFLAGS |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
7 | 7 | <key>CFBundleExecutable</key> |
8 | 8 | <string>gtkwave</string> |
9 | 9 | <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> | |
11 | 11 | <key>CFBundleIconFile</key> |
12 | 12 | <string>gtkwave.icns</string> |
13 | 13 | <key>CFBundleIdentifier</key> |
17 | 17 | <key>CFBundlePackageType</key> |
18 | 18 | <string>APPL</string> |
19 | 19 | <key>CFBundleShortVersionString</key> |
20 | <string>3.3.51</string> | |
20 | <string>3.3.52</string> | |
21 | 21 | <key>CFBundleSignature</key> |
22 | 22 | <string>????</string> |
23 | 23 | <key>CFBundleVersion</key> |
24 | <string>3.3.51</string> | |
24 | <string>3.3.52</string> | |
25 | 25 | <key>NSHumanReadableCopyright</key> |
26 | 26 | <string>Copyright 1999 - 2013 Tony Bybell, GNU General Public License.</string> |
27 | 27 | <key>LSMinimumSystemVersion</key> |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
20 | 20 | fstVarDir.java \ |
21 | 21 | fstVarType.java \ |
22 | 22 | fstWriter.java \ |
23 | fstWriterPackType.java \ | |
23 | 24 | Main.java \ |
24 | 25 | zzz_test.csh |
25 | 26 |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
244 | 246 | fstVarDir.java \ |
245 | 247 | fstVarType.java \ |
246 | 248 | fstWriter.java \ |
249 | fstWriterPackType.java \ | |
247 | 250 | Main.java \ |
248 | 251 | zzz_test.csh |
249 | 252 |
458 | 458 | } |
459 | 459 | |
460 | 460 | |
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 | ||
461 | 468 | JNIEXPORT jint JNICALL Java_fstAPI_fstReaderGetNumberDumpActivityChanges |
462 | 469 | (JNIEnv *env, jobject obj, jlong ctx) |
463 | 470 | { |
400 | 400 | |
401 | 401 | /* |
402 | 402 | * 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 | |
403 | 411 | * Method: fstReaderGetNumberDumpActivityChanges |
404 | 412 | * Signature: (J)I |
405 | 413 | */ |
90 | 90 | protected native boolean fstReaderGetFseekFailed(long ctx); |
91 | 91 | protected native void fstReaderSetUnlimitedTimeRange(long ctx); |
92 | 92 | protected native void fstReaderSetLimitTimeRange(long ctx, long start_time, long end_time); |
93 | protected native void fstReaderSetVcdExtensions(long ctx, boolean enable); | |
93 | 94 | protected native int fstReaderGetNumberDumpActivityChanges(long ctx); |
94 | 95 | protected native long fstReaderGetDumpActivityChangeTime(long ctx, int idx); |
95 | 96 | protected native boolean fstReaderGetFacProcessMask(long ctx, int facidx); |
72 | 72 | public void fstReaderResetScope() { fstReaderResetScope(ctx); } |
73 | 73 | public void fstReaderSetFacProcessMaskAll() { fstReaderSetFacProcessMaskAll(ctx); } |
74 | 74 | public void fstReaderSetFacProcessMask(int facidx) { fstReaderSetFacProcessMask(ctx, facidx); } |
75 | public void fstReaderSetVcdExtensions(boolean enable) { fstReaderSetVcdExtensions(ctx, enable); } | |
75 | 76 | public void fstReaderSetLimitTimeRange(long start_time, long end_time) { fstReaderSetLimitTimeRange(ctx, start_time, end_time); } |
76 | 77 | public void fstReaderSetUnlimitedTimeRange() { fstReaderSetUnlimitedTimeRange(ctx); } |
77 | 78 |
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 | }; |
16 | 16 | fstVarDir.java \ |
17 | 17 | fstVarType.java \ |
18 | 18 | fstWriter.java \ |
19 | fstWriterPackType.java \ | |
19 | 20 | fstReader.java |
20 | 21 | |
21 | 22 | javac \ |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
158 | 158 | EXTDEBUG = @EXTDEBUG@ |
159 | 159 | EXTDEBUG2 = @EXTDEBUG2@ |
160 | 160 | EXTDEBUG3 = @EXTDEBUG3@ |
161 | EXTDEBUG4 = @EXTDEBUG4@ | |
161 | 162 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
162 | 163 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
163 | 164 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
200 | 201 | LTLIBOBJS = @LTLIBOBJS@ |
201 | 202 | MAINT = @MAINT@ |
202 | 203 | MAKEINFO = @MAKEINFO@ |
204 | MINGW_LDADD = @MINGW_LDADD@ | |
203 | 205 | MKDIR_P = @MKDIR_P@ |
204 | 206 | OBJEXT = @OBJEXT@ |
205 | 207 | PACKAGE = @PACKAGE@ |
156 | 156 | EXTDEBUG = @EXTDEBUG@ |
157 | 157 | EXTDEBUG2 = @EXTDEBUG2@ |
158 | 158 | EXTDEBUG3 = @EXTDEBUG3@ |
159 | EXTDEBUG4 = @EXTDEBUG4@ | |
159 | 160 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
160 | 161 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
161 | 162 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
198 | 199 | LTLIBOBJS = @LTLIBOBJS@ |
199 | 200 | MAINT = @MAINT@ |
200 | 201 | MAKEINFO = @MAKEINFO@ |
202 | MINGW_LDADD = @MINGW_LDADD@ | |
201 | 203 | MKDIR_P = @MKDIR_P@ |
202 | 204 | OBJEXT = @OBJEXT@ |
203 | 205 | PACKAGE = @PACKAGE@ |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
198 | 198 | EXTDEBUG = @EXTDEBUG@ |
199 | 199 | EXTDEBUG2 = @EXTDEBUG2@ |
200 | 200 | EXTDEBUG3 = @EXTDEBUG3@ |
201 | EXTDEBUG4 = @EXTDEBUG4@ | |
201 | 202 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
202 | 203 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
203 | 204 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
240 | 241 | LTLIBOBJS = @LTLIBOBJS@ |
241 | 242 | MAINT = @MAINT@ |
242 | 243 | MAKEINFO = @MAKEINFO@ |
244 | MINGW_LDADD = @MINGW_LDADD@ | |
243 | 245 | MKDIR_P = @MKDIR_P@ |
244 | 246 | OBJEXT = @OBJEXT@ |
245 | 247 | PACKAGE = @PACKAGE@ |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
113 | 113 | EXTDEBUG = @EXTDEBUG@ |
114 | 114 | EXTDEBUG2 = @EXTDEBUG2@ |
115 | 115 | EXTDEBUG3 = @EXTDEBUG3@ |
116 | EXTDEBUG4 = @EXTDEBUG4@ | |
116 | 117 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
117 | 118 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
118 | 119 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
155 | 156 | LTLIBOBJS = @LTLIBOBJS@ |
156 | 157 | MAINT = @MAINT@ |
157 | 158 | MAKEINFO = @MAKEINFO@ |
159 | MINGW_LDADD = @MINGW_LDADD@ | |
158 | 160 | MKDIR_P = @MKDIR_P@ |
159 | 161 | OBJEXT = @OBJEXT@ |
160 | 162 | PACKAGE = @PACKAGE@ |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
182 | 182 | EXTDEBUG = @EXTDEBUG@ |
183 | 183 | EXTDEBUG2 = @EXTDEBUG2@ |
184 | 184 | EXTDEBUG3 = @EXTDEBUG3@ |
185 | EXTDEBUG4 = @EXTDEBUG4@ | |
185 | 186 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
186 | 187 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
187 | 188 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
224 | 225 | LTLIBOBJS = @LTLIBOBJS@ |
225 | 226 | MAINT = @MAINT@ |
226 | 227 | MAKEINFO = @MAKEINFO@ |
228 | MINGW_LDADD = @MINGW_LDADD@ | |
227 | 229 | MKDIR_P = @MKDIR_P@ |
228 | 230 | OBJEXT = @OBJEXT@ |
229 | 231 | PACKAGE = @PACKAGE@ |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
150 | 150 | EXTDEBUG = @EXTDEBUG@ |
151 | 151 | EXTDEBUG2 = @EXTDEBUG2@ |
152 | 152 | EXTDEBUG3 = @EXTDEBUG3@ |
153 | EXTDEBUG4 = @EXTDEBUG4@ | |
153 | 154 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
154 | 155 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
155 | 156 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
192 | 193 | LTLIBOBJS = @LTLIBOBJS@ |
193 | 194 | MAINT = @MAINT@ |
194 | 195 | MAKEINFO = @MAKEINFO@ |
196 | MINGW_LDADD = @MINGW_LDADD@ | |
195 | 197 | MKDIR_P = @MKDIR_P@ |
196 | 198 | OBJEXT = @OBJEXT@ |
197 | 199 | PACKAGE = @PACKAGE@ |
150 | 150 | EXTDEBUG = @EXTDEBUG@ |
151 | 151 | EXTDEBUG2 = @EXTDEBUG2@ |
152 | 152 | EXTDEBUG3 = @EXTDEBUG3@ |
153 | EXTDEBUG4 = @EXTDEBUG4@ | |
153 | 154 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
154 | 155 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
155 | 156 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
192 | 193 | LTLIBOBJS = @LTLIBOBJS@ |
193 | 194 | MAINT = @MAINT@ |
194 | 195 | MAKEINFO = @MAKEINFO@ |
196 | MINGW_LDADD = @MINGW_LDADD@ | |
195 | 197 | MKDIR_P = @MKDIR_P@ |
196 | 198 | OBJEXT = @OBJEXT@ |
197 | 199 | PACKAGE = @PACKAGE@ |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
109 | 109 | EXTDEBUG = @EXTDEBUG@ |
110 | 110 | EXTDEBUG2 = @EXTDEBUG2@ |
111 | 111 | EXTDEBUG3 = @EXTDEBUG3@ |
112 | EXTDEBUG4 = @EXTDEBUG4@ | |
112 | 113 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
113 | 114 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
114 | 115 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
151 | 152 | LTLIBOBJS = @LTLIBOBJS@ |
152 | 153 | MAINT = @MAINT@ |
153 | 154 | MAKEINFO = @MAKEINFO@ |
155 | MINGW_LDADD = @MINGW_LDADD@ | |
154 | 156 | MKDIR_P = @MKDIR_P@ |
155 | 157 | OBJEXT = @OBJEXT@ |
156 | 158 | PACKAGE = @PACKAGE@ |
16 | 16 | |
17 | 17 | rtlbrowse_SOURCES = definehash.c fgetdynamic.c fgetdynamic.h \ |
18 | 18 | logfile.c splay.c tcl_helper.c tree_widget.c \ |
19 | $(srcdir)/../../src/helpers/fst/lz4.c \ | |
20 | $(srcdir)/../../src/helpers/fst/lz4.h \ | |
19 | 21 | $(srcdir)/../../src/helpers/fst/fastlz.c \ |
22 | $(srcdir)/../../src/helpers/fst/fastlz.h \ | |
20 | 23 | $(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 \ | |
23 | 27 | vlex.l vlex.h wavelink.h $(srcdir)/../../src/liblzma/LzmaLib.c $(srcdir)/../../src/liblzma/LzmaLib.h |
24 | 28 | |
25 | 29 | LDADD= $(GTK_LIBS) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBLZMA_LDADD) $(AET2_LDADD) \ |
63 | 63 | PROGRAMS = $(bin_PROGRAMS) |
64 | 64 | am_rtlbrowse_OBJECTS = definehash.$(OBJEXT) fgetdynamic.$(OBJEXT) \ |
65 | 65 | 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) | |
69 | 70 | rtlbrowse_OBJECTS = $(am_rtlbrowse_OBJECTS) |
70 | 71 | rtlbrowse_LDADD = $(LDADD) |
71 | 72 | am__DEPENDENCIES_1 = |
214 | 215 | EXTDEBUG = @EXTDEBUG@ |
215 | 216 | EXTDEBUG2 = @EXTDEBUG2@ |
216 | 217 | EXTDEBUG3 = @EXTDEBUG3@ |
218 | EXTDEBUG4 = @EXTDEBUG4@ | |
217 | 219 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
218 | 220 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
219 | 221 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
256 | 258 | LTLIBOBJS = @LTLIBOBJS@ |
257 | 259 | MAINT = @MAINT@ |
258 | 260 | MAKEINFO = @MAKEINFO@ |
261 | MINGW_LDADD = @MINGW_LDADD@ | |
259 | 262 | MKDIR_P = @MKDIR_P@ |
260 | 263 | OBJEXT = @OBJEXT@ |
261 | 264 | PACKAGE = @PACKAGE@ |
341 | 344 | LIBLZMA_LDADD = $(LIBXZ_LDADD) |
342 | 345 | rtlbrowse_SOURCES = definehash.c fgetdynamic.c fgetdynamic.h \ |
343 | 346 | logfile.c splay.c tcl_helper.c tree_widget.c \ |
347 | $(srcdir)/../../src/helpers/fst/lz4.c \ | |
348 | $(srcdir)/../../src/helpers/fst/lz4.h \ | |
344 | 349 | $(srcdir)/../../src/helpers/fst/fastlz.c \ |
350 | $(srcdir)/../../src/helpers/fst/fastlz.h \ | |
345 | 351 | $(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 \ | |
348 | 355 | vlex.l vlex.h wavelink.h $(srcdir)/../../src/liblzma/LzmaLib.c $(srcdir)/../../src/liblzma/LzmaLib.h |
349 | 356 | |
350 | 357 | LDADD = $(GTK_LIBS) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBLZMA_LDADD) $(AET2_LDADD) \ |
452 | 459 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jrb.Po@am__quote@ |
453 | 460 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logfile.Po@am__quote@ |
454 | 461 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2_read.Po@am__quote@ |
462 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lz4.Po@am__quote@ | |
455 | 463 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/splay.Po@am__quote@ |
456 | 464 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stem_recurse.Po@am__quote@ |
457 | 465 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcl_helper.Po@am__quote@ |
472 | 480 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
473 | 481 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
474 | 482 | @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` | |
475 | 497 | |
476 | 498 | fastlz.o: $(srcdir)/../../src/helpers/fst/fastlz.c |
477 | 499 | @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 |
154 | 154 | EXTDEBUG = @EXTDEBUG@ |
155 | 155 | EXTDEBUG2 = @EXTDEBUG2@ |
156 | 156 | EXTDEBUG3 = @EXTDEBUG3@ |
157 | EXTDEBUG4 = @EXTDEBUG4@ | |
157 | 158 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
158 | 159 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
159 | 160 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
196 | 197 | LTLIBOBJS = @LTLIBOBJS@ |
197 | 198 | MAINT = @MAINT@ |
198 | 199 | MAKEINFO = @MAKEINFO@ |
200 | MINGW_LDADD = @MINGW_LDADD@ | |
199 | 201 | MKDIR_P = @MKDIR_P@ |
200 | 202 | OBJEXT = @OBJEXT@ |
201 | 203 | PACKAGE = @PACKAGE@ |
140 | 140 | EXTDEBUG = @EXTDEBUG@ |
141 | 141 | EXTDEBUG2 = @EXTDEBUG2@ |
142 | 142 | EXTDEBUG3 = @EXTDEBUG3@ |
143 | EXTDEBUG4 = @EXTDEBUG4@ | |
143 | 144 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
144 | 145 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
145 | 146 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
182 | 183 | LTLIBOBJS = @LTLIBOBJS@ |
183 | 184 | MAINT = @MAINT@ |
184 | 185 | MAKEINFO = @MAKEINFO@ |
186 | MINGW_LDADD = @MINGW_LDADD@ | |
185 | 187 | MKDIR_P = @MKDIR_P@ |
186 | 188 | OBJEXT = @OBJEXT@ |
187 | 189 | PACKAGE = @PACKAGE@ |
Binary diff not shown
140 | 140 | EXTDEBUG = @EXTDEBUG@ |
141 | 141 | EXTDEBUG2 = @EXTDEBUG2@ |
142 | 142 | EXTDEBUG3 = @EXTDEBUG3@ |
143 | EXTDEBUG4 = @EXTDEBUG4@ | |
143 | 144 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
144 | 145 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
145 | 146 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
182 | 183 | LTLIBOBJS = @LTLIBOBJS@ |
183 | 184 | MAINT = @MAINT@ |
184 | 185 | MAKEINFO = @MAKEINFO@ |
186 | MINGW_LDADD = @MINGW_LDADD@ | |
185 | 187 | MKDIR_P = @MKDIR_P@ |
186 | 188 | OBJEXT = @OBJEXT@ |
187 | 189 | PACKAGE = @PACKAGE@ |
142 | 142 | EXTDEBUG = @EXTDEBUG@ |
143 | 143 | EXTDEBUG2 = @EXTDEBUG2@ |
144 | 144 | EXTDEBUG3 = @EXTDEBUG3@ |
145 | EXTDEBUG4 = @EXTDEBUG4@ | |
145 | 146 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
146 | 147 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
147 | 148 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
184 | 185 | LTLIBOBJS = @LTLIBOBJS@ |
185 | 186 | MAINT = @MAINT@ |
186 | 187 | MAKEINFO = @MAKEINFO@ |
188 | MINGW_LDADD = @MINGW_LDADD@ | |
187 | 189 | MKDIR_P = @MKDIR_P@ |
188 | 190 | OBJEXT = @OBJEXT@ |
189 | 191 | PACKAGE = @PACKAGE@ |
0 | .TH "FST2VCD" "1" "3.3.29" "Anthony Bybell" "Filetype Conversion" | |
0 | .TH "FST2VCD" "1" "3.3.52" "Anthony Bybell" "Filetype Conversion" | |
1 | 1 | .SH "NAME" |
2 | 2 | .LP |
3 | 3 | fst2vcd \- Converts FST files to VCD |
17 | 17 | \fB\-o,\-\-output\fR <\fIfilename\fP> |
18 | 18 | Specify optional VCD output filename. |
19 | 19 | .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 | |
20 | 23 | \fB\-h,\-\-help\fR |
21 | 24 | Display help then exit. |
22 | 25 |
0 | .TH "VCD2FST" "1" "3.3.35" "Anthony Bybell" "Filetype Conversion" | |
0 | .TH "VCD2FST" "1" "3.3.52" "Anthony Bybell" "Filetype Conversion" | |
1 | 1 | .SH "NAME" |
2 | 2 | .LP |
3 | 3 | vcd2fst \- Converts VCD files to FST files |
18 | 18 | .TP |
19 | 19 | \fB\-F,\-\-fastpack\fR |
20 | 20 | 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. | |
21 | 24 | .TP |
22 | 25 | \fB\-c,\-\-compress\fR |
23 | 26 | Indicates that the entire file should be run through gzip on close. This |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
139 | 139 | EXTDEBUG = @EXTDEBUG@ |
140 | 140 | EXTDEBUG2 = @EXTDEBUG2@ |
141 | 141 | EXTDEBUG3 = @EXTDEBUG3@ |
142 | EXTDEBUG4 = @EXTDEBUG4@ | |
142 | 143 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
143 | 144 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
144 | 145 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
181 | 182 | LTLIBOBJS = @LTLIBOBJS@ |
182 | 183 | MAINT = @MAINT@ |
183 | 184 | MAKEINFO = @MAKEINFO@ |
185 | MINGW_LDADD = @MINGW_LDADD@ | |
184 | 186 | MKDIR_P = @MKDIR_P@ |
185 | 187 | OBJEXT = @OBJEXT@ |
186 | 188 | PACKAGE = @PACKAGE@ |
199 | 199 | EXTDEBUG = @EXTDEBUG@ |
200 | 200 | EXTDEBUG2 = @EXTDEBUG2@ |
201 | 201 | EXTDEBUG3 = @EXTDEBUG3@ |
202 | EXTDEBUG4 = @EXTDEBUG4@ | |
202 | 203 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
203 | 204 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
204 | 205 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
241 | 242 | LTLIBOBJS = @LTLIBOBJS@ |
242 | 243 | MAINT = @MAINT@ |
243 | 244 | MAKEINFO = @MAKEINFO@ |
245 | MINGW_LDADD = @MINGW_LDADD@ | |
244 | 246 | MKDIR_P = @MKDIR_P@ |
245 | 247 | OBJEXT = @OBJEXT@ |
246 | 248 | PACKAGE = @PACKAGE@ |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
139 | 139 | EXTDEBUG = @EXTDEBUG@ |
140 | 140 | EXTDEBUG2 = @EXTDEBUG2@ |
141 | 141 | EXTDEBUG3 = @EXTDEBUG3@ |
142 | EXTDEBUG4 = @EXTDEBUG4@ | |
142 | 143 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
143 | 144 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
144 | 145 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
181 | 182 | LTLIBOBJS = @LTLIBOBJS@ |
182 | 183 | MAINT = @MAINT@ |
183 | 184 | MAKEINFO = @MAKEINFO@ |
185 | MINGW_LDADD = @MINGW_LDADD@ | |
184 | 186 | MKDIR_P = @MKDIR_P@ |
185 | 187 | OBJEXT = @OBJEXT@ |
186 | 188 | PACKAGE = @PACKAGE@ |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
139 | 139 | EXTDEBUG = @EXTDEBUG@ |
140 | 140 | EXTDEBUG2 = @EXTDEBUG2@ |
141 | 141 | EXTDEBUG3 = @EXTDEBUG3@ |
142 | EXTDEBUG4 = @EXTDEBUG4@ | |
142 | 143 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
143 | 144 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
144 | 145 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
181 | 182 | LTLIBOBJS = @LTLIBOBJS@ |
182 | 183 | MAINT = @MAINT@ |
183 | 184 | MAKEINFO = @MAKEINFO@ |
185 | MINGW_LDADD = @MINGW_LDADD@ | |
184 | 186 | MKDIR_P = @MKDIR_P@ |
185 | 187 | OBJEXT = @OBJEXT@ |
186 | 188 | PACKAGE = @PACKAGE@ |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
139 | 139 | EXTDEBUG = @EXTDEBUG@ |
140 | 140 | EXTDEBUG2 = @EXTDEBUG2@ |
141 | 141 | EXTDEBUG3 = @EXTDEBUG3@ |
142 | EXTDEBUG4 = @EXTDEBUG4@ | |
142 | 143 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
143 | 144 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
144 | 145 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
181 | 182 | LTLIBOBJS = @LTLIBOBJS@ |
182 | 183 | MAINT = @MAINT@ |
183 | 184 | MAKEINFO = @MAKEINFO@ |
185 | MINGW_LDADD = @MINGW_LDADD@ | |
184 | 186 | MKDIR_P = @MKDIR_P@ |
185 | 187 | OBJEXT = @OBJEXT@ |
186 | 188 | PACKAGE = @PACKAGE@ |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
169 | 169 | EXTDEBUG = @EXTDEBUG@ |
170 | 170 | EXTDEBUG2 = @EXTDEBUG2@ |
171 | 171 | EXTDEBUG3 = @EXTDEBUG3@ |
172 | EXTDEBUG4 = @EXTDEBUG4@ | |
172 | 173 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
173 | 174 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
174 | 175 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
211 | 212 | LTLIBOBJS = @LTLIBOBJS@ |
212 | 213 | MAINT = @MAINT@ |
213 | 214 | MAKEINFO = @MAKEINFO@ |
215 | MINGW_LDADD = @MINGW_LDADD@ | |
214 | 216 | MKDIR_P = @MKDIR_P@ |
215 | 217 | OBJEXT = @OBJEXT@ |
216 | 218 | PACKAGE = @PACKAGE@ |
139 | 139 | EXTDEBUG = @EXTDEBUG@ |
140 | 140 | EXTDEBUG2 = @EXTDEBUG2@ |
141 | 141 | EXTDEBUG3 = @EXTDEBUG3@ |
142 | EXTDEBUG4 = @EXTDEBUG4@ | |
142 | 143 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
143 | 144 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
144 | 145 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
181 | 182 | LTLIBOBJS = @LTLIBOBJS@ |
182 | 183 | MAINT = @MAINT@ |
183 | 184 | MAKEINFO = @MAKEINFO@ |
185 | MINGW_LDADD = @MINGW_LDADD@ | |
184 | 186 | MKDIR_P = @MKDIR_P@ |
185 | 187 | OBJEXT = @OBJEXT@ |
186 | 188 | PACKAGE = @PACKAGE@ |
51 | 51 | vcd_partial.c vcd_recoder.c vcd_saver.c vcd_saver.h version.h vlist.c vlist.h vzt.c vzt.h wavealloca.h \ |
52 | 52 | wavewindow.c zoombuttons.c |
53 | 53 | |
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) | |
55 | 55 | gtkwave_LDFLAGS = $(COCOA_GTK_LDFLAGS) |
56 | 56 | |
57 | 57 | twinwave_SOURCES= twinwave.c |
100 | 100 | $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ |
101 | 101 | $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ |
102 | 102 | $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ |
103 | $(am__DEPENDENCIES_1) | |
103 | $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) | |
104 | 104 | gtkwave_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(gtkwave_LDFLAGS) \ |
105 | 105 | $(LDFLAGS) -o $@ |
106 | 106 | am_twinwave_OBJECTS = twinwave.$(OBJEXT) |
252 | 252 | EXTDEBUG = @EXTDEBUG@ |
253 | 253 | EXTDEBUG2 = @EXTDEBUG2@ |
254 | 254 | EXTDEBUG3 = @EXTDEBUG3@ |
255 | EXTDEBUG4 = @EXTDEBUG4@ | |
255 | 256 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
256 | 257 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
257 | 258 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
294 | 295 | LTLIBOBJS = @LTLIBOBJS@ |
295 | 296 | MAINT = @MAINT@ |
296 | 297 | MAKEINFO = @MAKEINFO@ |
298 | MINGW_LDADD = @MINGW_LDADD@ | |
297 | 299 | MKDIR_P = @MKDIR_P@ |
298 | 300 | OBJEXT = @OBJEXT@ |
299 | 301 | PACKAGE = @PACKAGE@ |
406 | 408 | vcd_partial.c vcd_recoder.c vcd_saver.c vcd_saver.h version.h vlist.c vlist.h vzt.c vzt.h wavealloca.h \ |
407 | 409 | wavewindow.c zoombuttons.c |
408 | 410 | |
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) | |
410 | 412 | gtkwave_LDFLAGS = $(COCOA_GTK_LDFLAGS) |
411 | 413 | twinwave_SOURCES = twinwave.c |
412 | 414 | twinwave_LDADD = $(GTK_LIBS) $(GTK_MAC_LIBS) $(GCONF_LIBS) |
162 | 162 | EXTDEBUG = @EXTDEBUG@ |
163 | 163 | EXTDEBUG2 = @EXTDEBUG2@ |
164 | 164 | EXTDEBUG3 = @EXTDEBUG3@ |
165 | EXTDEBUG4 = @EXTDEBUG4@ | |
165 | 166 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
166 | 167 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
167 | 168 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
204 | 205 | LTLIBOBJS = @LTLIBOBJS@ |
205 | 206 | MAINT = @MAINT@ |
206 | 207 | MAKEINFO = @MAKEINFO@ |
208 | MINGW_LDADD = @MINGW_LDADD@ | |
207 | 209 | MKDIR_P = @MKDIR_P@ |
208 | 210 | OBJEXT = @OBJEXT@ |
209 | 211 | PACKAGE = @PACKAGE@ |
781 | 781 | } |
782 | 782 | |
783 | 783 | 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++; | |
784 | 793 | max_idcode = fsdbReaderGetMaxVarIdcode(GLOBALS->extload_ffr_ctx); |
785 | 794 | if(max_idcode) |
786 | 795 | { |
787 | 796 | success_count++; |
788 | 797 | } |
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 */ | |
796 | 801 | success_count++; |
797 | 802 | } |
798 | 803 |
0 | 0 | /* |
1 | * Copyright (c) Tony Bybell 1999-2009. | |
1 | * Copyright (c) Tony Bybell 1999-2013. | |
2 | 2 | * |
3 | 3 | * This program is free software; you can redistribute it and/or |
4 | 4 | * modify it under the terms of the GNU General Public License |
20 | 20 | #include <cocoa_misc.h> |
21 | 21 | #endif |
22 | 22 | |
23 | #if defined __MINGW32__ | |
24 | #include <windows.h> | |
25 | #endif | |
26 | ||
23 | 27 | #if GTK_CHECK_VERSION(2,4,0) |
24 | 28 | |
25 | 29 | #ifndef MAC_INTEGRATION |
135 | 139 | if(GLOBALS->bad_cleanup_file_c_1) GLOBALS->bad_cleanup_file_c_1(); |
136 | 140 | } |
137 | 141 | |
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 | ||
140 | 152 | GLOBALS->fileselbox_text=filesel_path; |
141 | 153 | GLOBALS->filesel_ok=0; |
142 | 154 | GLOBALS->cleanup_file_c_2=ok_func; |
143 | 155 | 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 | |
144 | 218 | |
145 | 219 | GLOBALS->fs_file_c_1=gtk_file_selection_new(title); |
146 | 220 | gtkwave_signal_connect(GTK_OBJECT(GLOBALS->fs_file_c_1), "destroy", (GtkSignalFunc) destroy_callback, NULL); |
156 | 230 | |
157 | 231 | gtk_widget_show(GLOBALS->fs_file_c_1); |
158 | 232 | wave_gtk_grab_add(GLOBALS->fs_file_c_1); |
233 | ||
234 | #endif | |
159 | 235 | } |
160 | 236 | |
161 | 237 | |
244 | 320 | |
245 | 321 | #if defined __MINGW32__ || !GTK_CHECK_VERSION(2,4,0) |
246 | 322 | |
247 | fileselbox_old(title, filesel_path, ok_func, notok_func, pattn); | |
323 | fileselbox_old(title, filesel_path, ok_func, notok_func, pattn, is_writemode); | |
248 | 324 | return; |
249 | 325 | |
250 | 326 | #else |
0 | 0 | /* |
1 | * Copyright (c) Tony Bybell 2010 | |
1 | * Copyright (c) Tony Bybell 2010-2013 | |
2 | 2 | * |
3 | 3 | * This program is free software; you can redistribute it and/or |
4 | 4 | * modify it under the terms of the GNU General Public License |
9 | 9 | #ifndef WAVE_FILESEL_H |
10 | 10 | #define WAVE_FILESEL_H |
11 | 11 | |
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); | |
13 | 13 | void fileselbox(char *title, char **filesel_path, GtkSignalFunc ok_func, GtkSignalFunc notok_func, char *pattn, int is_writemode); |
14 | 14 | |
15 | 15 | #endif |
312 | 312 | |
313 | 313 | if(rc == FSDB_RC_SUCCESS) |
314 | 314 | { |
315 | *mult = ((int)digit); | |
315 | *mult = digit ? ((int)digit) : 1; /* in case digit is zero */ | |
316 | 316 | *scale = unit[0]; |
317 | 317 | } |
318 | 318 |
103 | 103 | * analyzer.c |
104 | 104 | */ |
105 | 105 | 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 */ | |
108 | 108 | 0, /* hier_max_level 8 */ |
109 | 109 | 0, /* hier_max_level_shadow */ |
110 | 110 | 0, /* timestart_from_savefile */ |
368 | 368 | 0, /* text_help_c_1 111 */ |
369 | 369 | 0, /* vscrollbar_help_c_1 112 */ |
370 | 370 | #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 */ | |
372 | 372 | 0, /* bold_tag_help_c_1 114 */ |
373 | 373 | #endif |
374 | 374 | 0, /* window_help_c_2 115 */ |
415 | 415 | NULL, /* fontname_logfile 133 */ |
416 | 416 | NULL, /* font_logfile_c_1 134 */ |
417 | 417 | #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 */ | |
419 | 419 | NULL, /* bold_tag_logfile_c_2 136 */ |
420 | 420 | NULL, /* mono_tag_logfile_c_1 137 */ |
421 | 421 | NULL, /* size_tag_logfile_c_1 138 */ |
874 | 874 | 0, /* cached_mouseover_x */ |
875 | 875 | 0, /* cached_mouseover_y */ |
876 | 876 | 0, /* mouseover_counter */ |
877 | 0, /* button2_debounce_flag */ | |
878 | ||
877 | 879 | |
878 | 880 | /* |
879 | 881 | * simplereq.c |
905 | 907 | NULL, /* text_status_c_2 398 */ |
906 | 908 | NULL, /* vscrollbar_status_c_2 399 */ |
907 | 909 | #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 */ | |
909 | 911 | NULL, /* bold_tag_status_c_3 401 */ |
910 | 912 | #endif |
911 | 913 | |
1078 | 1080 | 0, /* bundle_direction_treesearch_gtk2_c_3 467 */ |
1079 | 1081 | NULL, /* cleanup_treesearch_gtk2_c_8 468 */ |
1080 | 1082 | 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 */ | |
1082 | 1084 | 0, /* dnd_tgt_on_signalarea_treesearch_gtk2_c_1 471 */ |
1083 | 1085 | 0, /* dnd_tgt_on_wavearea_treesearch_gtk2_c_1 */ |
1084 | 1086 | NULL, /* dnd_sigview */ |
871 | 871 | gint cached_mouseover_x; /* from signalwindow.c */ |
872 | 872 | gint cached_mouseover_y; /* from signalwindow.c */ |
873 | 873 | gint mouseover_counter; /* from signalwindow.c */ |
874 | unsigned button2_debounce_flag : 1; | |
874 | 875 | |
875 | 876 | |
876 | 877 | /* |
11 | 11 | shmidcat vcd2lxt vcd2lxt2 vcd2vzt \ |
12 | 12 | vzt2vcd vztminer |
13 | 13 | |
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 | |
15 | 15 | vcd2fst_LDADD= $(LIBZ_LDADD) $(LIBJUDY_LDADD) |
16 | 16 | |
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 | |
18 | 18 | fst2vcd_LDADD= $(LIBZ_LDADD) $(LIBJUDY_LDADD) |
19 | 19 | |
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 | |
21 | 21 | fstminer_LDADD= $(LIBZ_LDADD) $(LIBJUDY_LDADD) |
22 | 22 | |
23 | 23 | vcd2lxt_SOURCES= vcd2lxt.c lxt_write.c lxt_write.h v2l_analyzer.h v2l_debug.c v2l_debug.h |
68 | 68 | am_evcd2vcd_OBJECTS = evcd2vcd.$(OBJEXT) jrb.$(OBJEXT) |
69 | 69 | evcd2vcd_OBJECTS = $(am_evcd2vcd_OBJECTS) |
70 | 70 | evcd2vcd_LDADD = $(LDADD) |
71 | am_fst2vcd_OBJECTS = fst2vcd.$(OBJEXT) fastlz.$(OBJEXT) \ | |
71 | am_fst2vcd_OBJECTS = fst2vcd.$(OBJEXT) lz4.$(OBJEXT) fastlz.$(OBJEXT) \ | |
72 | 72 | fstapi.$(OBJEXT) |
73 | 73 | fst2vcd_OBJECTS = $(am_fst2vcd_OBJECTS) |
74 | 74 | am__DEPENDENCIES_1 = |
75 | 75 | 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) | |
78 | 78 | fstminer_OBJECTS = $(am_fstminer_OBJECTS) |
79 | 79 | fstminer_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) |
80 | 80 | am_ghwdump_OBJECTS = ghwdump.$(OBJEXT) ghwlib.$(OBJEXT) |
90 | 90 | shmidcat_SOURCES = shmidcat.c |
91 | 91 | shmidcat_OBJECTS = shmidcat.$(OBJEXT) |
92 | 92 | shmidcat_LDADD = $(LDADD) |
93 | am_vcd2fst_OBJECTS = vcd2fst.$(OBJEXT) fastlz.$(OBJEXT) \ | |
93 | am_vcd2fst_OBJECTS = vcd2fst.$(OBJEXT) lz4.$(OBJEXT) fastlz.$(OBJEXT) \ | |
94 | 94 | fstapi.$(OBJEXT) jrb.$(OBJEXT) |
95 | 95 | vcd2fst_OBJECTS = $(am_vcd2fst_OBJECTS) |
96 | 96 | vcd2fst_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) |
217 | 217 | EXTDEBUG = @EXTDEBUG@ |
218 | 218 | EXTDEBUG2 = @EXTDEBUG2@ |
219 | 219 | EXTDEBUG3 = @EXTDEBUG3@ |
220 | EXTDEBUG4 = @EXTDEBUG4@ | |
220 | 221 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
221 | 222 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
222 | 223 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
259 | 260 | LTLIBOBJS = @LTLIBOBJS@ |
260 | 261 | MAINT = @MAINT@ |
261 | 262 | MAKEINFO = @MAKEINFO@ |
263 | MINGW_LDADD = @MINGW_LDADD@ | |
262 | 264 | MKDIR_P = @MKDIR_P@ |
263 | 265 | OBJEXT = @OBJEXT@ |
264 | 266 | PACKAGE = @PACKAGE@ |
337 | 339 | LIBLZMA_CFLAGS = -I$(srcdir)/../liblzma $(LIBXZ_CFLAGS) |
338 | 340 | LIBLZMA_LDADD = $(LIBXZ_LDADD) |
339 | 341 | 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 | |
341 | 343 | 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 | |
343 | 345 | 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 | |
345 | 347 | fstminer_LDADD = $(LIBZ_LDADD) $(LIBJUDY_LDADD) |
346 | 348 | vcd2lxt_SOURCES = vcd2lxt.c lxt_write.c lxt_write.h v2l_analyzer.h v2l_debug.c v2l_debug.h |
347 | 349 | vcd2lxt_LDADD = $(LIBZ_LDADD) $(LIBBZ2_LDADD) |
495 | 497 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2miner.Po@am__quote@ |
496 | 498 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2vcd.Po@am__quote@ |
497 | 499 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt_write.Po@am__quote@ |
500 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lz4.Po@am__quote@ | |
498 | 501 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scopenav.Po@am__quote@ |
499 | 502 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shmidcat.Po@am__quote@ |
500 | 503 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/v2l_debug.Po@am__quote@ |
535 | 538 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../../contrib/rtlbrowse/jrb.c' object='jrb.obj' libtool=no @AMDEPBACKSLASH@ |
536 | 539 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
537 | 540 | @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` | |
538 | 555 | |
539 | 556 | fastlz.o: $(srcdir)/fst/fastlz.c |
540 | 557 | @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 |
4 | 4 | |
5 | 5 | noinst_LIBRARIES= libfst.a |
6 | 6 | |
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 | |
8 | 8 | |
9 | 9 | EXTRA_DIST= block_format.txt |
67 | 67 | am__v_AR_1 = |
68 | 68 | libfst_a_AR = $(AR) $(ARFLAGS) |
69 | 69 | libfst_a_LIBADD = |
70 | am_libfst_a_OBJECTS = fastlz.$(OBJEXT) fstapi.$(OBJEXT) | |
70 | am_libfst_a_OBJECTS = fastlz.$(OBJEXT) lz4.$(OBJEXT) fstapi.$(OBJEXT) | |
71 | 71 | libfst_a_OBJECTS = $(am_libfst_a_OBJECTS) |
72 | 72 | AM_V_P = $(am__v_P_@AM_V@) |
73 | 73 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) |
156 | 156 | EXTDEBUG = @EXTDEBUG@ |
157 | 157 | EXTDEBUG2 = @EXTDEBUG2@ |
158 | 158 | EXTDEBUG3 = @EXTDEBUG3@ |
159 | EXTDEBUG4 = @EXTDEBUG4@ | |
159 | 160 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
160 | 161 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
161 | 162 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
198 | 199 | LTLIBOBJS = @LTLIBOBJS@ |
199 | 200 | MAINT = @MAINT@ |
200 | 201 | MAKEINFO = @MAKEINFO@ |
202 | MINGW_LDADD = @MINGW_LDADD@ | |
201 | 203 | MKDIR_P = @MKDIR_P@ |
202 | 204 | OBJEXT = @OBJEXT@ |
203 | 205 | PACKAGE = @PACKAGE@ |
273 | 275 | top_srcdir = @top_srcdir@ |
274 | 276 | AM_CFLAGS = $(LIBZ_CFLAGS) $(LIBJUDY_CFLAGS) |
275 | 277 | 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 | |
277 | 279 | EXTRA_DIST = block_format.txt |
278 | 280 | all: all-am |
279 | 281 | |
325 | 327 | |
326 | 328 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fastlz.Po@am__quote@ |
327 | 329 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstapi.Po@am__quote@ |
330 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lz4.Po@am__quote@ | |
328 | 331 | |
329 | 332 | .c.o: |
330 | 333 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
45 | 45 | uint8_t FST_BL_HIER |
46 | 46 | uint64_t section length |
47 | 47 | 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] | |
49 | 56 | |
50 | 57 | =========================================================================== |
51 | 58 | |
80 | 87 | // value changes |
81 | 88 | |
82 | 89 | 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) | |
84 | 92 | |
85 | 93 | varint chain 0 compressed data length (0 = uncompressed) |
86 | 94 | [compressed data] |
23 | 23 | |
24 | 24 | #include "fstapi.h" |
25 | 25 | #include "fastlz.h" |
26 | #include "lz4.h" | |
26 | 27 | |
27 | 28 | #ifndef HAVE_LIBPTHREAD |
28 | 29 | #undef FST_WRITER_PARALLEL |
543 | 544 | |
544 | 545 | unsigned vc_emitted : 1; |
545 | 546 | unsigned is_initial_time : 1; |
547 | unsigned fourpack : 1; | |
546 | 548 | unsigned fastpack : 1; |
547 | 549 | |
548 | 550 | int64_t timezero; |
1063 | 1065 | |
1064 | 1066 | f = xc->handle; |
1065 | 1067 | 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); | |
1067 | 1069 | fpos = 1; |
1068 | 1070 | |
1069 | 1071 | packmemlen = 1024; /* maintain a running "longest" allocation to */ |
1282 | 1284 | dmem = packmem = malloc(packmemlen = (wrlen * 2) + 2); |
1283 | 1285 | } |
1284 | 1286 | |
1285 | rc = fastlz_compress(scratchpnt, wrlen, dmem); | |
1287 | rc = (xc->fourpack) ? LZ4_compress((char *)scratchpnt, (char *)dmem, wrlen) : fastlz_compress(scratchpnt, wrlen, dmem); | |
1286 | 1288 | if(rc < destlen) |
1287 | 1289 | { |
1288 | 1290 | #ifndef FST_DYNAMIC_ALIAS_DISABLE |
1707 | 1709 | |
1708 | 1710 | if(xc->compress_hier) |
1709 | 1711 | { |
1710 | unsigned char *mem = malloc(FST_GZIO_LEN); | |
1711 | 1712 | off_t hl, eos; |
1712 | 1713 | gzFile zhandle; |
1713 | 1714 | int zfd; |
1721 | 1722 | fstWriterUint64(xc->handle, 0); /* section length */ |
1722 | 1723 | fstWriterUint64(xc->handle, xc->hier_file_len); /* uncompressed length */ |
1723 | 1724 | |
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) | |
1731 | 1732 | { |
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); | |
1735 | 1741 | } |
1736 | gzclose(zhandle); | |
1742 | else | |
1743 | { | |
1744 | close(zfd); | |
1745 | } | |
1746 | free(mem); | |
1737 | 1747 | } |
1738 | 1748 | else |
1739 | 1749 | { |
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 | } | |
1743 | 1765 | |
1744 | 1766 | fstWriterFseeko(xc, xc->handle, 0, SEEK_END); |
1745 | 1767 | eos = ftello(xc->handle); |
1748 | 1770 | fflush(xc->handle); |
1749 | 1771 | |
1750 | 1772 | 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 */ | |
1752 | 1774 | |
1753 | 1775 | fstWriterFseeko(xc, xc->handle, 0, SEEK_END); /* move file pointer to end for any section adds */ |
1754 | 1776 | fflush(xc->handle); |
2128 | 2150 | } |
2129 | 2151 | |
2130 | 2152 | |
2131 | void fstWriterSetPackType(void *ctx, int typ) | |
2153 | void fstWriterSetPackType(void *ctx, enum fstWriterPackType typ) | |
2132 | 2154 | { |
2133 | 2155 | struct fstWriterContext *xc = (struct fstWriterContext *)ctx; |
2134 | 2156 | if(xc) |
2135 | 2157 | { |
2136 | xc->fastpack = (typ != 0); | |
2158 | xc->fastpack = (typ != FST_WR_PT_ZLIB); | |
2159 | xc->fourpack = (typ == FST_WR_PT_LZ4); | |
2137 | 2160 | } |
2138 | 2161 | } |
2139 | 2162 | |
2719 | 2742 | signed char timescale; |
2720 | 2743 | unsigned char filetype; |
2721 | 2744 | |
2745 | unsigned use_vcd_extensions : 1; | |
2722 | 2746 | unsigned double_endian_match : 1; |
2723 | 2747 | unsigned native_doubles_for_cb : 1; |
2724 | 2748 | unsigned contains_geom_section : 1; |
2725 | 2749 | unsigned contains_hier_section : 1; /* valid for hier_pos */ |
2750 | unsigned contains_hier_section_lz4 : 1; /* valid for hier_pos */ | |
2726 | 2751 | unsigned limit_range_valid : 1; /* valid for limit_range_start, limit_range_end */ |
2727 | 2752 | |
2728 | 2753 | char version[FST_HDR_SIM_VERSION_SIZE + 1]; |
3173 | 3198 | } |
3174 | 3199 | |
3175 | 3200 | |
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 | ||
3176 | 3212 | void fstReaderIterBlocksSetNativeDoublesOnCallback(void *ctx, int enable) |
3177 | 3213 | { |
3178 | 3214 | struct fstReaderContext *xc = (struct fstReaderContext *)ctx; |
3185 | 3221 | /* |
3186 | 3222 | * hierarchy processing |
3187 | 3223 | */ |
3188 | static char *fstVcdID(int value) | |
3189 | { | |
3190 | static char buf[16]; | |
3224 | static void fstVcdID(char *buf, int value) | |
3225 | { | |
3191 | 3226 | char *pnt = buf; |
3192 | 3227 | int vmod; |
3193 | 3228 | |
3207 | 3242 | } |
3208 | 3243 | |
3209 | 3244 | *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 | { | |
3216 | 3249 | char *pnt = buf; |
3217 | 3250 | int vmod; |
3218 | 3251 | |
3231 | 3264 | if(!value) { break; } |
3232 | 3265 | } |
3233 | 3266 | |
3234 | *len = pnt-buf; | |
3235 | return(buf); | |
3267 | return(pnt - buf); | |
3236 | 3268 | } |
3237 | 3269 | |
3238 | 3270 | |
3246 | 3278 | char *fnam = malloc(strlen(xc->filename) + 6 + 16 + 32 + 1); |
3247 | 3279 | unsigned char *mem = malloc(FST_GZIO_LEN); |
3248 | 3280 | off_t hl, uclen; |
3281 | off_t clen = 0; | |
3249 | 3282 | gzFile zhandle; |
3250 | 3283 | 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 | } | |
3251 | 3296 | |
3252 | 3297 | sprintf(fnam, "%s.hier_%d_%p", xc->filename, getpid(), (void *)xc); |
3253 | 3298 | fstReaderFseeko(xc, xc->f, xc->hier_pos, SEEK_SET); |
3254 | 3299 | uclen = fstReaderUint64(xc->f); |
3255 | 3300 | 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); | |
3264 | 3325 | } |
3265 | 3326 | |
3266 | 3327 | #ifndef __MINGW32__ |
3281 | 3342 | if(fnam) unlink(fnam); |
3282 | 3343 | #endif |
3283 | 3344 | |
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) | |
3291 | 3378 | { |
3292 | 3379 | 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 | ||
3304 | 3390 | free(mem); |
3305 | 3391 | free(fnam); |
3306 | 3392 | |
3612 | 3698 | |
3613 | 3699 | attrarg = fstReaderVarint64(xc->fh); |
3614 | 3700 | |
3615 | if(fv) | |
3701 | if(fv && xc->use_vcd_extensions) | |
3616 | 3702 | { |
3617 | 3703 | switch(attrtype) |
3618 | 3704 | { |
3651 | 3737 | break; |
3652 | 3738 | |
3653 | 3739 | 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"); | |
3655 | 3741 | break; |
3656 | 3742 | |
3657 | 3743 | case FST_VT_VCD_EVENT: |
3719 | 3805 | } |
3720 | 3806 | if(fv) |
3721 | 3807 | { |
3808 | char vcdid_buf[16]; | |
3722 | 3809 | 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); | |
3724 | 3812 | } |
3725 | 3813 | xc->maxhandle++; |
3726 | 3814 | } |
3733 | 3821 | } |
3734 | 3822 | if(fv) |
3735 | 3823 | { |
3824 | char vcdid_buf[16]; | |
3736 | 3825 | 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); | |
3738 | 3828 | } |
3739 | 3829 | xc->num_alias++; |
3740 | 3830 | } |
4028 | 4118 | xc->contains_hier_section = 1; |
4029 | 4119 | xc->hier_pos = ftello(xc->f); |
4030 | 4120 | } |
4121 | else if(sectype == FST_BL_HIER_LZ4) | |
4122 | { | |
4123 | xc->contains_hier_section_lz4 = 1; | |
4124 | xc->hier_pos = ftello(xc->f); | |
4125 | } | |
4031 | 4126 | else if(sectype == FST_BL_BLACKOUT) |
4032 | 4127 | { |
4033 | 4128 | uint32_t i; |
4106 | 4201 | xc->filename = strdup(nam); |
4107 | 4202 | rc = fstReaderInit(xc); |
4108 | 4203 | |
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)))) | |
4110 | 4205 | { |
4111 | 4206 | /* more init */ |
4112 | 4207 | xc->do_rewind = 1; |
4225 | 4320 | uint32_t *scatterptr, *headptr, *length_remaining; |
4226 | 4321 | uint32_t cur_blackout = 0; |
4227 | 4322 | int packtype; |
4323 | unsigned char *mc_mem = NULL; | |
4324 | uint32_t mc_mem_len; /* corresponds to largest value encountered in chain_table_lengths[i] */ | |
4228 | 4325 | |
4229 | 4326 | if(!xc) return(0); |
4230 | 4327 | |
4423 | 4520 | { |
4424 | 4521 | if(fv) |
4425 | 4522 | { |
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); | |
4428 | 4525 | fputc(val, fv); |
4429 | 4526 | fstFwrite(vcd_id, vcdid_len, 1, fv); |
4430 | 4527 | fputc('\n', fv); |
4450 | 4547 | { |
4451 | 4548 | if(fv) |
4452 | 4549 | { |
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); | |
4455 | 4552 | fputc((xc->signal_typs[idx] != FST_VT_VCD_PORT) ? 'b' : 'p', fv); |
4456 | 4553 | fstFwrite(mu+sig_offs, xc->signal_lens[idx], 1, fv); |
4457 | 4554 | fputc(' ', fv); |
4510 | 4607 | { |
4511 | 4608 | if(fv) |
4512 | 4609 | { |
4610 | char vcdid_buf[16]; | |
4513 | 4611 | clone_d = (unsigned char *)&d; |
4514 | 4612 | if(xc->double_endian_match) |
4515 | 4613 | { |
4525 | 4623 | } |
4526 | 4624 | } |
4527 | 4625 | |
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); | |
4529 | 4628 | } |
4530 | 4629 | } |
4531 | 4630 | } |
4632 | 4731 | #ifdef FST_DEBUG |
4633 | 4732 | printf("\tdecompressed chain idx len: %"PRIu32"\n", idx); |
4634 | 4733 | #endif |
4734 | ||
4735 | mc_mem_len = 16384; | |
4736 | mc_mem = malloc(mc_mem_len); /* buffer for compressed reads */ | |
4737 | ||
4635 | 4738 | /* check compressed VC data */ |
4636 | 4739 | if(idx > xc->maxhandle) idx = xc->maxhandle; |
4637 | 4740 | for(i=0;i<idx;i++) |
4652 | 4755 | val = fstReaderVarint32WithSkip(xc->f, &skiplen); |
4653 | 4756 | if(val) |
4654 | 4757 | { |
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 */ | |
4657 | 4760 | unsigned long destlen = val; |
4658 | 4761 | 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 | ||
4660 | 4770 | fstFread(mc, chain_table_lengths[i], 1, xc->f); |
4661 | if(packtype == 'F') | |
4771 | ||
4772 | switch(packtype) | |
4662 | 4773 | { |
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; | |
4664 | 4780 | } |
4665 | else | |
4666 | { | |
4667 | rc = uncompress(mu, &destlen, mc, sourcelen); | |
4668 | } | |
4669 | free(mc); | |
4781 | ||
4670 | 4782 | /* data to process is for(j=0;j<destlen;j++) in mu[j] */ |
4671 | 4783 | headptr[i] = traversal_mem_offs; |
4672 | 4784 | length_remaining[i] = val; |
4707 | 4819 | } |
4708 | 4820 | } |
4709 | 4821 | |
4822 | free(mc_mem); /* there is no usage below for this, no real need to clear out mc_mem or mc_mem_len */ | |
4823 | ||
4710 | 4824 | for(i=0;i<tsec_nitems;i++) |
4711 | 4825 | { |
4712 | 4826 | uint32_t tdelta; |
4768 | 4882 | { |
4769 | 4883 | if(fv) |
4770 | 4884 | { |
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); | |
4773 | 4887 | fputc(val, fv); |
4774 | 4888 | fstFwrite(vcd_id, vcdid_len, 1, fv); |
4775 | 4889 | fputc('\n', fv); |
4813 | 4927 | { |
4814 | 4928 | if(fv) |
4815 | 4929 | { |
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); | |
4818 | 4932 | |
4819 | 4933 | fputc('s', fv); |
4820 | 4934 | { |
5002 | 5116 | |
5003 | 5117 | if(fv) |
5004 | 5118 | { |
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); | |
5007 | 5121 | fputc(' ', fv); |
5008 | 5122 | fstFwrite(vcd_id, vcdid_len, 1, fv); |
5009 | 5123 | fputc('\n', fv); |
39 | 39 | |
40 | 40 | typedef uint32_t fstHandle; |
41 | 41 | |
42 | enum fstWriterPackType { | |
43 | FST_WR_PT_ZLIB = 0, | |
44 | FST_WR_PT_FASTLZ = 1, | |
45 | FST_WR_PT_LZ4 = 2 | |
46 | }; | |
47 | ||
42 | 48 | enum fstFileType { |
43 | 49 | FST_FT_MIN = 0, |
44 | 50 | |
56 | 62 | FST_BL_GEOM = 3, |
57 | 63 | FST_BL_HIER = 4, |
58 | 64 | FST_BL_VCDATA_DYN_ALIAS = 5, |
65 | FST_BL_HIER_LZ4 = 6, | |
59 | 66 | |
60 | 67 | FST_BL_ZWRAPPER = 254, /* indicates that whole trace is gz wrapped */ |
61 | 68 | FST_BL_SKIP = 255 /* used while block is being written */ |
337 | 344 | void fstWriterSetDumpSizeLimit(void *ctx, uint64_t numbytes); |
338 | 345 | void fstWriterSetEnvVar(void *ctx, const char *envvar); |
339 | 346 | 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); | |
341 | 348 | void fstWriterSetParallelMode(void *ctx, int enable); |
342 | 349 | void fstWriterSetRepackOnClose(void *ctx, int enable); /* type = 0 (none), 1 (libz) */ |
343 | 350 | void fstWriterSetScope(void *ctx, enum fstScopeType scopetype, |
400 | 407 | void fstReaderSetFacProcessMaskAll(void *ctx); |
401 | 408 | void fstReaderSetLimitTimeRange(void *ctx, uint64_t start_time, uint64_t end_time); |
402 | 409 | void fstReaderSetUnlimitedTimeRange(void *ctx); |
410 | void fstReaderSetVcdExtensions(void *ctx, int enable); | |
403 | 411 | |
404 | 412 | |
405 | 413 | /* |
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 |
0 | 0 | /* |
1 | * Copyright (c) 2003-2009 Tony Bybell. | |
1 | * Copyright (c) 2003-2013 Tony Bybell. | |
2 | 2 | * |
3 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a |
4 | 4 | * copy of this software and associated documentation files (the "Software"), |
37 | 37 | "Usage: %s [OPTION]... [FSTFILE]\n\n" |
38 | 38 | " -f, --fstname=FILE specify FST input filename\n" |
39 | 39 | " -o, --output=FILE specify output filename\n" |
40 | " -e, --extensions emit FST extensions to VCD\n" | |
40 | 41 | " -h, --help display this help then exit\n\n" |
41 | 42 | "VCD is emitted to stdout if output filename is unspecified.\n\n" |
42 | 43 | "Report bugs to <"PACKAGE_BUGREPORT">.\n",nam); |
45 | 46 | "Usage: %s [OPTION]... [FSTFILE]\n\n" |
46 | 47 | " -f specify FST input filename\n" |
47 | 48 | " -o specify output filename\n" |
49 | " -e emit FST extensions to VCD\n" | |
48 | 50 | " -h display this help then exit\n\n" |
49 | 51 | "VCD is emitted to stdout if output filename is unspecified.\n\n" |
50 | 52 | "Report bugs to <"PACKAGE_BUGREPORT">.\n",nam); |
63 | 65 | int c; |
64 | 66 | struct fstReaderContext *xc; |
65 | 67 | FILE *fv; |
68 | int use_extensions = 0; | |
66 | 69 | |
67 | 70 | WAVE_LOCALE_FIX |
68 | 71 | |
73 | 76 | |
74 | 77 | static struct option long_options[] = |
75 | 78 | { |
79 | {"extensions", 0, 0, 'e'}, | |
76 | 80 | {"fstname", 1, 0, 'f'}, |
77 | 81 | {"output", 1, 0, 'o'}, |
78 | 82 | {"help", 0, 0, 'h'}, |
79 | 83 | {0, 0, 0, 0} |
80 | 84 | }; |
81 | 85 | |
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); | |
83 | 87 | #else |
84 | c = getopt (argc, argv, "f:o:h"); | |
88 | c = getopt (argc, argv, "ef:o:h"); | |
85 | 89 | #endif |
86 | 90 | |
87 | 91 | if (c == -1) break; /* no more args */ |
88 | 92 | |
89 | 93 | switch (c) |
90 | 94 | { |
95 | case 'e': | |
96 | use_extensions = 1; | |
97 | break; | |
98 | ||
91 | 99 | case 'f': |
92 | 100 | if(fstname) free(fstname); |
93 | 101 | fstname = malloc(strlen(optarg)+1); |
166 | 174 | fv = stdout; |
167 | 175 | } |
168 | 176 | |
177 | fstReaderSetVcdExtensions(xc, use_extensions); /* TRUE is incompatible with vfast and other tools */ | |
169 | 178 | if(!fstReaderProcessHier(xc, fv)) /* these 3 lines do all the VCD writing work */ |
170 | 179 | { |
171 | 180 | fprintf(stderr, "could not process hierarchy for '%s', exiting.\n", fstname); |
41 | 41 | #endif |
42 | 42 | #endif |
43 | 43 | |
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) | |
45 | 51 | #define VCD2FST_EXTLOADERS_CONV |
46 | 52 | #endif |
47 | 53 | |
411 | 417 | return(val); |
412 | 418 | } |
413 | 419 | |
414 | int pack_type = 0; /* set to 1 for fastlz */ | |
420 | int pack_type = FST_WR_PT_ZLIB; /* set to fstWriterPackType */ | |
415 | 421 | int repack_all = 0; /* 0 is normal, 1 does the repack (via fstapi) at end */ |
416 | 422 | int parallel_mode = 0; /* 0 is is single threaded, 1 is multi-threaded */ |
417 | 423 | |
477 | 483 | } |
478 | 484 | else |
479 | 485 | #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 | |
480 | 495 | { |
481 | 496 | f = fopen(vname, "rb"); |
482 | 497 | } |
1524 | 1539 | void print_help(char *nam) |
1525 | 1540 | { |
1526 | 1541 | #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); | |
1531 | 1545 | int i; |
1532 | 1546 | |
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); | |
1534 | 1565 | |
1535 | 1566 | for(i=0;i<slen;i++) |
1536 | 1567 | { |
1537 | 1568 | ucase_ext[i] = toupper(ucase_ext[i]); |
1538 | 1569 | } |
1539 | 1570 | |
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 | |
1568 | 1572 | |
1569 | 1573 | |
1570 | 1574 | #ifdef __linux__ |
1571 | 1575 | printf( |
1572 | 1576 | "Usage: %s [OPTION]... [VCDFILE] [FSTFILE]\n\n" |
1573 | 1577 | #ifdef VCD2FST_EXTLOADERS_CONV |
1574 | " -v, --vcdname=FILE specify VCD/%s input filename\n" | |
1578 | " -v, --vcdname=FILE specify VCD%s input filename\n" | |
1575 | 1579 | #else |
1576 | 1580 | " -v, --vcdname=FILE specify VCD input filename\n" |
1577 | 1581 | #endif |
1578 | 1582 | " -f, --fstname=FILE specify FST output filename\n" |
1579 | 1583 | " -F, --fastpack use fastlz algorithm for speed\n" |
1584 | " -4, --fourpack use lz4 algorithm for speed\n" | |
1580 | 1585 | " -c, --compress compress entire file on close\n" |
1581 | 1586 | " -p, --parallel enable parallel mode\n" |
1582 | 1587 | " -h, --help display this help then exit\n\n" |
1592 | 1597 | printf( |
1593 | 1598 | "Usage: %s [OPTION]... [VCDFILE] [FSTFILE]\n\n" |
1594 | 1599 | #ifdef VCD2FST_EXTLOADERS_CONV |
1595 | " -v FILE specify VCD/%s input filename\n" | |
1600 | " -v FILE specify VCD%s input filename\n" | |
1596 | 1601 | #else |
1597 | 1602 | " -v FILE specify VCD input filename\n" |
1598 | 1603 | #endif |
1599 | 1604 | " -f FILE specify FST output filename\n" |
1600 | 1605 | " -F use fastlz algorithm for speed\n" |
1606 | " -4 use lz4 algorithm for speed\n" | |
1601 | 1607 | " -c compress entire file on close\n" |
1602 | 1608 | " -p enable parallel mode\n" |
1603 | 1609 | " -h display this help then exit\n\n" |
1637 | 1643 | {"vcdname", 1, 0, 'v'}, |
1638 | 1644 | {"fstname", 1, 0, 'f'}, |
1639 | 1645 | {"fastpack", 0, 0, 'F'}, |
1646 | {"fourpack", 0, 0, '4'}, | |
1640 | 1647 | {"compress", 0, 0, 'c'}, |
1641 | 1648 | {"parallel", 0, 0, 'p'}, |
1642 | 1649 | {"help", 0, 0, 'h'}, |
1643 | 1650 | {0, 0, 0, 0} |
1644 | 1651 | }; |
1645 | 1652 | |
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); | |
1647 | 1654 | #else |
1648 | c = getopt (argc, argv, "v:f:Fcph"); | |
1655 | c = getopt (argc, argv, "v:f:F4cph"); | |
1649 | 1656 | #endif |
1650 | 1657 | |
1651 | 1658 | if (c == -1) break; /* no more args */ |
1665 | 1672 | break; |
1666 | 1673 | |
1667 | 1674 | 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; | |
1669 | 1683 | break; |
1670 | 1684 | |
1671 | 1685 | case 'c': |
158 | 158 | EXTDEBUG = @EXTDEBUG@ |
159 | 159 | EXTDEBUG2 = @EXTDEBUG2@ |
160 | 160 | EXTDEBUG3 = @EXTDEBUG3@ |
161 | EXTDEBUG4 = @EXTDEBUG4@ | |
161 | 162 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
162 | 163 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
163 | 164 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
200 | 201 | LTLIBOBJS = @LTLIBOBJS@ |
201 | 202 | MAINT = @MAINT@ |
202 | 203 | MAKEINFO = @MAKEINFO@ |
204 | MINGW_LDADD = @MINGW_LDADD@ | |
203 | 205 | MKDIR_P = @MKDIR_P@ |
204 | 206 | OBJEXT = @OBJEXT@ |
205 | 207 | PACKAGE = @PACKAGE@ |
156 | 156 | EXTDEBUG = @EXTDEBUG@ |
157 | 157 | EXTDEBUG2 = @EXTDEBUG2@ |
158 | 158 | EXTDEBUG3 = @EXTDEBUG3@ |
159 | EXTDEBUG4 = @EXTDEBUG4@ | |
159 | 160 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
160 | 161 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
161 | 162 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
198 | 199 | LTLIBOBJS = @LTLIBOBJS@ |
199 | 200 | MAINT = @MAINT@ |
200 | 201 | MAKEINFO = @MAKEINFO@ |
202 | MINGW_LDADD = @MINGW_LDADD@ | |
201 | 203 | MKDIR_P = @MKDIR_P@ |
202 | 204 | OBJEXT = @OBJEXT@ |
203 | 205 | PACKAGE = @PACKAGE@ |
161 | 161 | EXTDEBUG = @EXTDEBUG@ |
162 | 162 | EXTDEBUG2 = @EXTDEBUG2@ |
163 | 163 | EXTDEBUG3 = @EXTDEBUG3@ |
164 | EXTDEBUG4 = @EXTDEBUG4@ | |
164 | 165 | EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@ |
165 | 166 | FASTTREE_CFLAGS = @FASTTREE_CFLAGS@ |
166 | 167 | FSDB_CFLAGS = @FSDB_CFLAGS@ |
203 | 204 | LTLIBOBJS = @LTLIBOBJS@ |
204 | 205 | MAINT = @MAINT@ |
205 | 206 | MAKEINFO = @MAKEINFO@ |
207 | MINGW_LDADD = @MINGW_LDADD@ | |
206 | 208 | MKDIR_P = @MKDIR_P@ |
207 | 209 | OBJEXT = @OBJEXT@ |
208 | 210 | PACKAGE = @PACKAGE@ |
0 | 0 | ZLIB DATA COMPRESSION LIBRARY |
1 | 1 | |
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 | |
3 | 3 | thread safe. The data format used by the zlib library is described by RFCs |
4 | 4 | (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). | |
8 | 7 | |
9 | 8 | 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. | |
15 | 14 | |
16 | 15 | 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. | |
21 | 20 | |
22 | 21 | 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. | |
28 | 26 | |
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. | |
31 | 28 | |
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/ . | |
35 | 32 | |
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. | |
37 | 34 | |
38 | Unsupported third party contributions are provided in directory "contrib". | |
35 | Unsupported third party contributions are provided in directory contrib/ . | |
39 | 36 | |
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/ . | |
43 | 39 | |
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/ . | |
47 | 43 | |
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 | |
49 | 45 | 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 . | |
51 | 47 | |
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 . | |
54 | 49 | |
55 | 50 | An experimental package to read and write files in .zip format, written on top |
56 | 51 | of zlib by Gilles Vollant <info@winimage.com>, is available in the |
74 | 69 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with |
75 | 70 | other compilers. Use "make test" to check your compiler. |
76 | 71 | |
77 | - gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. | |
72 | - gzdopen is not supported on RISCOS or BEOS. | |
78 | 73 | |
79 | 74 | - 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. | |
84 | 75 | |
85 | 76 | |
86 | 77 | Acknowledgments: |
87 | 78 | |
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. | |
92 | 83 | |
93 | 84 | Copyright notice: |
94 | 85 | |
95 | (C) 1995-2003 Jean-loup Gailly and Mark Adler | |
86 | (C) 1995-2013 Jean-loup Gailly and Mark Adler | |
96 | 87 | |
97 | 88 | This software is provided 'as-is', without any express or implied |
98 | 89 | warranty. In no event will the authors be held liable for any damages |
113 | 104 | Jean-loup Gailly Mark Adler |
114 | 105 | jloup@gzip.org madler@alumni.caltech.edu |
115 | 106 | |
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. | |
121 | 111 | |
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. |
0 | 0 | /* 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 | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
5 | /* @(#) $Id: adler32.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
5 | /* @(#) $Id$ */ | |
6 | 6 | |
7 | 7 | #include "zutil.h" |
8 | 8 | |
9 | 9 | #define local static |
10 | 10 | |
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)); | |
12 | 12 | |
13 | #define BASE 65521UL /* largest prime smaller than 65536 */ | |
13 | #define BASE 65521 /* largest prime smaller than 65536 */ | |
14 | 14 | #define NMAX 5552 |
15 | 15 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ |
16 | 16 | |
20 | 20 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); |
21 | 21 | #define DO16(buf) DO8(buf,0); DO8(buf,8); |
22 | 22 | |
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 */ | |
24 | 25 | #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) | |
25 | 39 | # define MOD(a) \ |
26 | 40 | 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); \ | |
44 | 43 | } 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; \ | |
51 | 55 | if (a >= BASE) a -= BASE; \ |
52 | 56 | } while (0) |
53 | 57 | #else |
54 | 58 | # define MOD(a) a %= BASE |
55 | # define MOD4(a) a %= BASE | |
59 | # define MOD28(a) a %= BASE | |
60 | # define MOD63(a) a %= BASE | |
56 | 61 | #endif |
57 | 62 | |
58 | 63 | /* ========================================================================= */ |
91 | 96 | } |
92 | 97 | if (adler >= BASE) |
93 | 98 | adler -= BASE; |
94 | MOD4(sum2); /* only added so many BASE's */ | |
99 | MOD28(sum2); /* only added so many BASE's */ | |
95 | 100 | return adler | (sum2 << 16); |
96 | 101 | } |
97 | 102 | |
136 | 141 | unsigned long sum2; |
137 | 142 | unsigned rem; |
138 | 143 | |
144 | /* for negative len, return invalid adler32 as a clue for debugging */ | |
145 | if (len2 < 0) | |
146 | return 0xffffffffUL; | |
147 | ||
139 | 148 | /* 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; | |
141 | 151 | sum1 = adler1 & 0xffff; |
142 | 152 | sum2 = rem * sum1; |
143 | 153 | MOD(sum2); |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
5 | /* @(#) $Id: compress.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
5 | /* @(#) $Id$ */ | |
6 | 6 | |
7 | 7 | #define ZLIB_INTERNAL |
8 | 8 | #include "zlib.h" |
28 | 28 | z_stream stream; |
29 | 29 | int err; |
30 | 30 | |
31 | stream.next_in = (Bytef*)source; | |
31 | stream.next_in = (z_const Bytef *)source; | |
32 | 32 | stream.avail_in = (uInt)sourceLen; |
33 | 33 | #ifdef MAXSEG_64K |
34 | 34 | /* Check for source > 64K on 16-bit machine: */ |
0 | 0 | /* 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 | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | * |
4 | 4 | * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster |
8 | 8 | * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. |
9 | 9 | */ |
10 | 10 | |
11 | /* @(#) $Id: crc32.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
11 | /* @(#) $Id$ */ | |
12 | 12 | |
13 | 13 | /* |
14 | 14 | Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore |
16 | 16 | of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should |
17 | 17 | first call get_crc_table() to initialize the tables before allowing more than |
18 | 18 | one thread to use crc32(). |
19 | ||
20 | DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. | |
19 | 21 | */ |
20 | 22 | |
21 | 23 | #ifdef MAKECRCH |
29 | 31 | |
30 | 32 | #define local static |
31 | 33 | |
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 | ||
53 | 34 | /* Definitions for doing the crc four data bytes at a time. */ |
35 | #if !defined(NOBYFOUR) && defined(Z_U4) | |
36 | # define BYFOUR | |
37 | #endif | |
54 | 38 | #ifdef BYFOUR |
55 | # define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ | |
56 | (((w)&0xff00)<<8)+(((w)&0xff)<<24)) | |
57 | 39 | local unsigned long crc32_little OF((unsigned long, |
58 | 40 | const unsigned char FAR *, unsigned)); |
59 | 41 | local unsigned long crc32_big OF((unsigned long, |
67 | 49 | local unsigned long gf2_matrix_times OF((unsigned long *mat, |
68 | 50 | unsigned long vec)); |
69 | 51 | 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)); | |
71 | 53 | |
72 | 54 | |
73 | 55 | #ifdef DYNAMIC_CRC_TABLE |
74 | 56 | |
75 | 57 | 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]; | |
77 | 59 | local void make_crc_table OF((void)); |
78 | 60 | #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 *)); | |
80 | 62 | #endif /* MAKECRCH */ |
81 | 63 | /* |
82 | 64 | Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: |
106 | 88 | */ |
107 | 89 | local void make_crc_table() |
108 | 90 | { |
109 | unsigned long c; | |
91 | z_crc_t c; | |
110 | 92 | int n, k; |
111 | unsigned long poly; /* polynomial exclusive-or pattern */ | |
93 | z_crc_t poly; /* polynomial exclusive-or pattern */ | |
112 | 94 | /* terms of polynomial defining this crc (except x^32): */ |
113 | 95 | static volatile int first = 1; /* flag to limit concurrent making */ |
114 | 96 | static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; |
120 | 102 | first = 0; |
121 | 103 | |
122 | 104 | /* 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]); | |
126 | 108 | |
127 | 109 | /* generate a crc for every 8-bit value */ |
128 | 110 | for (n = 0; n < 256; n++) { |
129 | c = (unsigned long)n; | |
111 | c = (z_crc_t)n; | |
130 | 112 | for (k = 0; k < 8; k++) |
131 | 113 | c = c & 1 ? poly ^ (c >> 1) : c >> 1; |
132 | 114 | crc_table[0][n] = c; |
137 | 119 | and then the byte reversal of those as well as the first table */ |
138 | 120 | for (n = 0; n < 256; n++) { |
139 | 121 | c = crc_table[0][n]; |
140 | crc_table[4][n] = REV(c); | |
122 | crc_table[4][n] = ZSWAP32(c); | |
141 | 123 | for (k = 1; k < 4; k++) { |
142 | 124 | c = crc_table[0][c & 0xff] ^ (c >> 8); |
143 | 125 | crc_table[k][n] = c; |
144 | crc_table[k + 4][n] = REV(c); | |
126 | crc_table[k + 4][n] = ZSWAP32(c); | |
145 | 127 | } |
146 | 128 | } |
147 | 129 | #endif /* BYFOUR */ |
163 | 145 | if (out == NULL) return; |
164 | 146 | fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); |
165 | 147 | 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 "); | |
167 | 149 | fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); |
168 | 150 | write_table(out, crc_table[0]); |
169 | 151 | # ifdef BYFOUR |
183 | 165 | #ifdef MAKECRCH |
184 | 166 | local void write_table(out, table) |
185 | 167 | FILE *out; |
186 | const unsigned long FAR *table; | |
168 | const z_crc_t FAR *table; | |
187 | 169 | { |
188 | 170 | int n; |
189 | 171 | |
190 | 172 | 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]), | |
192 | 175 | n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); |
193 | 176 | } |
194 | 177 | #endif /* MAKECRCH */ |
203 | 186 | /* ========================================================================= |
204 | 187 | * This function can be used by asm versions of crc32() |
205 | 188 | */ |
206 | const unsigned long FAR * ZEXPORT get_crc_table() | |
189 | const z_crc_t FAR * ZEXPORT get_crc_table() | |
207 | 190 | { |
208 | 191 | #ifdef DYNAMIC_CRC_TABLE |
209 | 192 | if (crc_table_empty) |
210 | 193 | make_crc_table(); |
211 | 194 | #endif /* DYNAMIC_CRC_TABLE */ |
212 | return (const unsigned long FAR *)crc_table; | |
195 | return (const z_crc_t FAR *)crc_table; | |
213 | 196 | } |
214 | 197 | |
215 | 198 | /* ========================================================================= */ |
231 | 214 | |
232 | 215 | #ifdef BYFOUR |
233 | 216 | if (sizeof(void *) == sizeof(ptrdiff_t)) { |
234 | u4 endian; | |
217 | z_crc_t endian; | |
235 | 218 | |
236 | 219 | endian = 1; |
237 | 220 | if (*((unsigned char *)(&endian))) |
265 | 248 | const unsigned char FAR *buf; |
266 | 249 | unsigned len; |
267 | 250 | { |
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; | |
272 | 255 | c = ~c; |
273 | 256 | while (len && ((ptrdiff_t)buf & 3)) { |
274 | 257 | c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); |
275 | 258 | len--; |
276 | 259 | } |
277 | 260 | |
278 | buf4 = (const u4 FAR *)(const void FAR *)buf; | |
261 | buf4 = (const z_crc_t FAR *)(const void FAR *)buf; | |
279 | 262 | while (len >= 32) { |
280 | 263 | DOLIT32; |
281 | 264 | len -= 32; |
305 | 288 | const unsigned char FAR *buf; |
306 | 289 | unsigned len; |
307 | 290 | { |
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); | |
312 | 295 | c = ~c; |
313 | 296 | while (len && ((ptrdiff_t)buf & 3)) { |
314 | 297 | c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); |
315 | 298 | len--; |
316 | 299 | } |
317 | 300 | |
318 | buf4 = (const u4 FAR *)(const void FAR *)buf; | |
301 | buf4 = (const z_crc_t FAR *)(const void FAR *)buf; | |
319 | 302 | buf4--; |
320 | 303 | while (len >= 32) { |
321 | 304 | DOBIG32; |
332 | 315 | c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); |
333 | 316 | } while (--len); |
334 | 317 | c = ~c; |
335 | return (unsigned long)(REV(c)); | |
318 | return (unsigned long)(ZSWAP32(c)); | |
336 | 319 | } |
337 | 320 | |
338 | 321 | #endif /* BYFOUR */ |
1 | 1 | * Generated automatically by crc32.c |
2 | 2 | */ |
3 | 3 | |
4 | local const unsigned long FAR crc_table[TBLS][256] = | |
4 | local const z_crc_t FAR crc_table[TBLS][256] = | |
5 | 5 | { |
6 | 6 | { |
7 | 7 | 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, |
0 | 0 | /* 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 | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
36 | 36 | * REFERENCES |
37 | 37 | * |
38 | 38 | * 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 | |
40 | 40 | * |
41 | 41 | * A description of the Rabin and Karp algorithm is given in the book |
42 | 42 | * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. |
46 | 46 | * |
47 | 47 | */ |
48 | 48 | |
49 | /* @(#) $Id: deflate.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
49 | /* @(#) $Id$ */ | |
50 | 50 | |
51 | 51 | #include "deflate.h" |
52 | 52 | |
53 | 53 | 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 "; | |
55 | 55 | /* |
56 | 56 | If you use the zlib library in a product, an acknowledgment is welcome |
57 | 57 | in the documentation of your product. If for some reason you cannot |
154 | 154 | struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ |
155 | 155 | #endif |
156 | 156 | |
157 | /* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ | |
158 | #define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) | |
159 | ||
157 | 160 | /* =========================================================================== |
158 | 161 | * Update a hash value with the given input byte |
159 | 162 | * IN assertion: all calls to to UPDATE_HASH are made with consecutive |
234 | 237 | |
235 | 238 | strm->msg = Z_NULL; |
236 | 239 | if (strm->zalloc == (alloc_func)0) { |
240 | #ifdef Z_SOLO | |
241 | return Z_STREAM_ERROR; | |
242 | #else | |
237 | 243 | strm->zalloc = zcalloc; |
238 | 244 | 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 | |
241 | 253 | |
242 | 254 | #ifdef FASTEST |
243 | 255 | if (level != 0) level = 1; |
292 | 304 | if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || |
293 | 305 | s->pending_buf == Z_NULL) { |
294 | 306 | s->status = FINISH_STATE; |
295 | strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); | |
307 | strm->msg = ERR_MSG(Z_MEM_ERROR); | |
296 | 308 | deflateEnd (strm); |
297 | 309 | return Z_MEM_ERROR; |
298 | 310 | } |
313 | 325 | uInt dictLength; |
314 | 326 | { |
315 | 327 | 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) | |
323 | 334 | return Z_STREAM_ERROR; |
324 | ||
325 | 335 | 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) | |
327 | 342 | 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; | |
348 | 387 | return Z_OK; |
349 | 388 | } |
350 | 389 | |
351 | 390 | /* ========================================================================= */ |
352 | int ZEXPORT deflateReset (strm) | |
391 | int ZEXPORT deflateResetKeep (strm) | |
353 | 392 | z_streamp strm; |
354 | 393 | { |
355 | 394 | deflate_state *s; |
379 | 418 | s->last_flush = Z_NO_FLUSH; |
380 | 419 | |
381 | 420 | _tr_init(s); |
382 | lm_init(s); | |
383 | 421 | |
384 | 422 | 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; | |
385 | 435 | } |
386 | 436 | |
387 | 437 | /* ========================================================================= */ |
392 | 442 | if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; |
393 | 443 | if (strm->state->wrap != 2) return Z_STREAM_ERROR; |
394 | 444 | 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; | |
395 | 459 | return Z_OK; |
396 | 460 | } |
397 | 461 | |
401 | 465 | int bits; |
402 | 466 | int value; |
403 | 467 | { |
468 | deflate_state *s; | |
469 | int put; | |
470 | ||
404 | 471 | 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); | |
407 | 485 | return Z_OK; |
408 | 486 | } |
409 | 487 | |
434 | 512 | strm->total_in != 0) { |
435 | 513 | /* Flush the last buffer: */ |
436 | 514 | err = deflate(strm, Z_BLOCK); |
515 | if (err == Z_BUF_ERROR && s->pending == 0) | |
516 | err = Z_OK; | |
437 | 517 | } |
438 | 518 | if (s->level != level) { |
439 | 519 | s->level = level; |
561 | 641 | local void flush_pending(strm) |
562 | 642 | z_streamp strm; |
563 | 643 | { |
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; | |
566 | 649 | if (len > strm->avail_out) len = strm->avail_out; |
567 | 650 | if (len == 0) return; |
568 | 651 | |
569 | zmemcpy(strm->next_out, strm->state->pending_out, len); | |
652 | zmemcpy(strm->next_out, s->pending_out, len); | |
570 | 653 | strm->next_out += len; |
571 | strm->state->pending_out += len; | |
654 | s->pending_out += len; | |
572 | 655 | strm->total_out += len; |
573 | 656 | 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; | |
577 | 660 | } |
578 | 661 | } |
579 | 662 | |
800 | 883 | * flushes. For repeated and useless calls with Z_FINISH, we keep |
801 | 884 | * returning Z_STREAM_END instead of Z_BUF_ERROR. |
802 | 885 | */ |
803 | } else if (strm->avail_in == 0 && flush <= old_flush && | |
886 | } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && | |
804 | 887 | flush != Z_FINISH) { |
805 | 888 | ERR_RETURN(strm, Z_BUF_ERROR); |
806 | 889 | } |
849 | 932 | if (s->lookahead == 0) { |
850 | 933 | s->strstart = 0; |
851 | 934 | s->block_start = 0L; |
935 | s->insert = 0; | |
852 | 936 | } |
853 | 937 | } |
854 | 938 | } |
944 | 1028 | |
945 | 1029 | ss = source->state; |
946 | 1030 | |
947 | zmemcpy(dest, source, sizeof(z_stream)); | |
1031 | zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); | |
948 | 1032 | |
949 | 1033 | ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); |
950 | 1034 | if (ds == Z_NULL) return Z_MEM_ERROR; |
951 | 1035 | dest->state = (struct internal_state FAR *) ds; |
952 | zmemcpy(ds, ss, sizeof(deflate_state)); | |
1036 | zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); | |
953 | 1037 | ds->strm = dest; |
954 | 1038 | |
955 | 1039 | ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); |
965 | 1049 | } |
966 | 1050 | /* following zmemcpy do not work for 16-bit MSDOS */ |
967 | 1051 | 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)); | |
970 | 1054 | zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); |
971 | 1055 | |
972 | 1056 | ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); |
1000 | 1084 | |
1001 | 1085 | strm->avail_in -= len; |
1002 | 1086 | |
1087 | zmemcpy(buf, strm->next_in, len); | |
1003 | 1088 | if (strm->state->wrap == 1) { |
1004 | strm->adler = adler32(strm->adler, strm->next_in, len); | |
1089 | strm->adler = adler32(strm->adler, buf, len); | |
1005 | 1090 | } |
1006 | 1091 | #ifdef GZIP |
1007 | 1092 | 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 | |
1012 | 1096 | strm->next_in += len; |
1013 | 1097 | strm->total_in += len; |
1014 | 1098 | |
1035 | 1119 | s->strstart = 0; |
1036 | 1120 | s->block_start = 0L; |
1037 | 1121 | s->lookahead = 0; |
1122 | s->insert = 0; | |
1038 | 1123 | s->match_length = s->prev_length = MIN_MATCH-1; |
1039 | 1124 | s->match_available = 0; |
1040 | 1125 | s->ins_h = 0; |
1309 | 1394 | unsigned more; /* Amount of free space at the end of the window. */ |
1310 | 1395 | uInt wsize = s->w_size; |
1311 | 1396 | |
1397 | Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); | |
1398 | ||
1312 | 1399 | do { |
1313 | 1400 | more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); |
1314 | 1401 | |
1361 | 1448 | #endif |
1362 | 1449 | more += wsize; |
1363 | 1450 | } |
1364 | if (s->strm->avail_in == 0) return; | |
1451 | if (s->strm->avail_in == 0) break; | |
1365 | 1452 | |
1366 | 1453 | /* If there was no sliding: |
1367 | 1454 | * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && |
1380 | 1467 | s->lookahead += n; |
1381 | 1468 | |
1382 | 1469 | /* 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]); | |
1386 | 1474 | #if MIN_MATCH != 3 |
1387 | 1475 | Call UPDATE_HASH() MIN_MATCH-3 more times |
1388 | 1476 | #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 | } | |
1389 | 1488 | } |
1390 | 1489 | /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, |
1391 | 1490 | * but this is not important since only literal bytes will be emitted. |
1426 | 1525 | s->high_water += init; |
1427 | 1526 | } |
1428 | 1527 | } |
1528 | ||
1529 | Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, | |
1530 | "not enough room for search"); | |
1429 | 1531 | } |
1430 | 1532 | |
1431 | 1533 | /* =========================================================================== |
1505 | 1607 | FLUSH_BLOCK(s, 0); |
1506 | 1608 | } |
1507 | 1609 | } |
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; | |
1510 | 1618 | } |
1511 | 1619 | |
1512 | 1620 | /* =========================================================================== |
1602 | 1710 | } |
1603 | 1711 | if (bflush) FLUSH_BLOCK(s, 0); |
1604 | 1712 | } |
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; | |
1607 | 1721 | } |
1608 | 1722 | |
1609 | 1723 | #ifndef FASTEST |
1727 | 1841 | _tr_tally_lit(s, s->window[s->strstart-1], bflush); |
1728 | 1842 | s->match_available = 0; |
1729 | 1843 | } |
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; | |
1732 | 1852 | } |
1733 | 1853 | #endif /* FASTEST */ |
1734 | 1854 | |
1748 | 1868 | for (;;) { |
1749 | 1869 | /* Make sure that we always have enough lookahead, except |
1750 | 1870 | * 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. | |
1752 | 1872 | */ |
1753 | if (s->lookahead < MAX_MATCH) { | |
1873 | if (s->lookahead <= MAX_MATCH) { | |
1754 | 1874 | fill_window(s); |
1755 | if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { | |
1875 | if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { | |
1756 | 1876 | return need_more; |
1757 | 1877 | } |
1758 | 1878 | if (s->lookahead == 0) break; /* flush the current block */ |
1775 | 1895 | if (s->match_length > s->lookahead) |
1776 | 1896 | s->match_length = s->lookahead; |
1777 | 1897 | } |
1898 | Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); | |
1778 | 1899 | } |
1779 | 1900 | |
1780 | 1901 | /* Emit match if have run of MIN_MATCH or longer, else emit literal */ |
1795 | 1916 | } |
1796 | 1917 | if (bflush) FLUSH_BLOCK(s, 0); |
1797 | 1918 | } |
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; | |
1800 | 1927 | } |
1801 | 1928 | |
1802 | 1929 | /* =========================================================================== |
1828 | 1955 | s->strstart++; |
1829 | 1956 | if (bflush) FLUSH_BLOCK(s, 0); |
1830 | 1957 | } |
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 | } |
0 | 0 | /* deflate.h -- internal compression state |
1 | * Copyright (C) 1995-2010 Jean-loup Gailly | |
1 | * Copyright (C) 1995-2012 Jean-loup Gailly | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
7 | 7 | subject to change. Applications should only use zlib.h. |
8 | 8 | */ |
9 | 9 | |
10 | /* @(#) $Id: deflate.h,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
10 | /* @(#) $Id$ */ | |
11 | 11 | |
12 | 12 | #ifndef DEFLATE_H |
13 | 13 | #define DEFLATE_H |
46 | 46 | |
47 | 47 | #define MAX_BITS 15 |
48 | 48 | /* All codes must not exceed MAX_BITS bits */ |
49 | ||
50 | #define Buf_size 16 | |
51 | /* size of bit buffer in bi_buf */ | |
49 | 52 | |
50 | 53 | #define INIT_STATE 42 |
51 | 54 | #define EXTRA_STATE 69 |
100 | 103 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ |
101 | 104 | gz_headerp gzhead; /* gzip header information to write */ |
102 | 105 | uInt gzindex; /* where in extra, name, or comment */ |
103 | Byte method; /* STORED (for zip only) or DEFLATED */ | |
106 | Byte method; /* can only be DEFLATED */ | |
104 | 107 | int last_flush; /* value of flush param for previous deflate call */ |
105 | 108 | |
106 | 109 | /* used by deflate.c: */ |
187 | 190 | int nice_match; /* Stop searching when current match exceeds this */ |
188 | 191 | |
189 | 192 | /* 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 */ | |
191 | 194 | struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ |
192 | 195 | struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ |
193 | 196 | struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ |
243 | 246 | ulg opt_len; /* bit length of current block with optimal trees */ |
244 | 247 | ulg static_len; /* bit length of current block with static trees */ |
245 | 248 | 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 */ | |
247 | 250 | |
248 | 251 | #ifdef DEBUG |
249 | 252 | ulg compressed_len; /* total bit length of compressed file mod 2^32 */ |
293 | 296 | int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); |
294 | 297 | void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, |
295 | 298 | ulg stored_len, int last)); |
299 | void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); | |
296 | 300 | void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); |
297 | 301 | void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, |
298 | 302 | ulg stored_len, int last)); |
0 | 0 | /* 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 | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
11 | 11 | # endif |
12 | 12 | #endif |
13 | 13 | |
14 | #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) | |
14 | #ifdef HAVE_HIDDEN | |
15 | 15 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
16 | 16 | #else |
17 | 17 | # define ZLIB_INTERNAL |
26 | 26 | #endif |
27 | 27 | #include <fcntl.h> |
28 | 28 | |
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 | ||
29 | 44 | #ifdef NO_DEFLATE /* for compatibility with old definition */ |
30 | 45 | # define NO_GZCOMPRESS |
31 | 46 | #endif |
32 | 47 | |
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 */ | |
33 | 101 | #ifdef _MSC_VER |
34 | # include <io.h> | |
35 | # define vsnprintf _vsnprintf | |
102 | # define snprintf _snprintf | |
36 | 103 | #endif |
37 | 104 | |
38 | 105 | #ifndef local |
51 | 118 | # include <windows.h> |
52 | 119 | # define zstrerror() gz_strwinerror((DWORD)GetLastError()) |
53 | 120 | #else |
54 | # ifdef STDC | |
121 | # ifndef NO_STRERROR | |
55 | 122 | # include <errno.h> |
56 | 123 | # define zstrerror() strerror(errno) |
57 | 124 | # else |
67 | 134 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); |
68 | 135 | #endif |
69 | 136 | |
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) */ | |
71 | 146 | #define GZBUFSIZE 8192 |
72 | 147 | |
73 | 148 | /* gzip modes, also provide a little integrity check on the passed structure */ |
83 | 158 | |
84 | 159 | /* internal gzip file state data structure */ |
85 | 160 | 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 */ | |
86 | 166 | /* used for both reading and writing */ |
87 | 167 | int mode; /* see gzip modes above */ |
88 | 168 | int fd; /* file descriptor */ |
89 | 169 | char *path; /* path or fd for error messages */ |
90 | z_off64_t pos; /* current position in uncompressed data */ | |
91 | 170 | unsigned size; /* buffer size, zero if not allocated yet */ |
92 | 171 | unsigned want; /* requested buffer size, default is GZBUFSIZE */ |
93 | 172 | unsigned char *in; /* input buffer */ |
94 | 173 | 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 */ | |
96 | 175 | /* 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 */ | |
98 | 178 | 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 */ | |
103 | 180 | /* just for writing */ |
104 | 181 | int level; /* compression level */ |
105 | 182 | int strategy; /* compression strategy */ |
0 | 0 | /* 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 | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
5 | 5 | #include "gzguts.h" |
6 | 6 | |
7 | #if defined(_WIN32) && !defined(__BORLANDC__) | |
8 | # define LSEEK _lseeki64 | |
9 | #else | |
7 | 10 | #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 |
8 | 11 | # define LSEEK lseek64 |
9 | 12 | #else |
10 | 13 | # define LSEEK lseek |
11 | 14 | #endif |
15 | #endif | |
12 | 16 | |
13 | 17 | /* Local functions */ |
14 | 18 | 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 *)); | |
16 | 20 | |
17 | 21 | #if defined UNDER_CE |
18 | 22 | |
70 | 74 | local void gz_reset(state) |
71 | 75 | gz_statep state; |
72 | 76 | { |
77 | state->x.have = 0; /* no output data available */ | |
73 | 78 | if (state->mode == GZ_READ) { /* for reading ... */ |
74 | state->have = 0; /* no output data available */ | |
75 | 79 | state->eof = 0; /* not at end of file */ |
80 | state->past = 0; /* have not read past end yet */ | |
76 | 81 | state->how = LOOK; /* look for gzip header */ |
77 | state->direct = 1; /* default for empty file */ | |
78 | 82 | } |
79 | 83 | state->seek = 0; /* no seek request pending */ |
80 | 84 | 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 */ | |
82 | 86 | state->strm.avail_in = 0; /* no input data yet */ |
83 | 87 | } |
84 | 88 | |
85 | 89 | /* Open a gzip file either by name or file descriptor. */ |
86 | 90 | local gzFile gz_open(path, fd, mode) |
87 | const char *path; | |
91 | const void *path; | |
88 | 92 | int fd; |
89 | 93 | const char *mode; |
90 | 94 | { |
91 | 95 | 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; | |
92 | 108 | |
93 | 109 | /* allocate gzFile structure to return */ |
94 | state = malloc(sizeof(gz_state)); | |
110 | state = (gz_statep)malloc(sizeof(gz_state)); | |
95 | 111 | if (state == NULL) |
96 | 112 | return NULL; |
97 | 113 | state->size = 0; /* no buffers allocated yet */ |
102 | 118 | state->mode = GZ_NONE; |
103 | 119 | state->level = Z_DEFAULT_COMPRESSION; |
104 | 120 | state->strategy = Z_DEFAULT_STRATEGY; |
121 | state->direct = 0; | |
105 | 122 | while (*mode) { |
106 | 123 | if (*mode >= '0' && *mode <= '9') |
107 | 124 | state->level = *mode - '0'; |
123 | 140 | return NULL; |
124 | 141 | case 'b': /* ignore -- will request binary anyway */ |
125 | 142 | 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 | |
126 | 153 | case 'f': |
127 | 154 | state->strategy = Z_FILTERED; |
128 | 155 | break; |
134 | 161 | break; |
135 | 162 | case 'F': |
136 | 163 | state->strategy = Z_FIXED; |
164 | break; | |
165 | case 'T': | |
166 | state->direct = 1; | |
167 | break; | |
137 | 168 | default: /* could consider as an error, but just ignore */ |
138 | 169 | ; |
139 | 170 | } |
146 | 177 | return NULL; |
147 | 178 | } |
148 | 179 | |
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 | ||
149 | 189 | /* 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); | |
151 | 200 | if (state->path == NULL) { |
152 | 201 | free(state); |
153 | 202 | return NULL; |
154 | 203 | } |
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 = | |
160 | 220 | #ifdef O_LARGEFILE |
161 | O_LARGEFILE | | |
221 | O_LARGEFILE | | |
162 | 222 | #endif |
163 | 223 | #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)); | |
173 | 245 | if (state->fd == -1) { |
174 | 246 | free(state->path); |
175 | 247 | free(state); |
215 | 287 | char *path; /* identifier for error messages */ |
216 | 288 | gzFile gz; |
217 | 289 | |
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 | |
220 | 295 | sprintf(path, "<fd:%d>", fd); /* for debugging */ |
296 | #endif | |
221 | 297 | gz = gz_open(path, fd, mode); |
222 | 298 | free(path); |
223 | 299 | return gz; |
224 | 300 | } |
225 | 301 | |
226 | 302 | /* -- 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 -- */ | |
227 | 313 | int ZEXPORT gzbuffer(file, size) |
228 | 314 | gzFile file; |
229 | 315 | unsigned size; |
242 | 328 | return -1; |
243 | 329 | |
244 | 330 | /* 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 */ | |
247 | 333 | state->want = size; |
248 | 334 | return 0; |
249 | 335 | } |
260 | 346 | state = (gz_statep)file; |
261 | 347 | |
262 | 348 | /* 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)) | |
264 | 351 | return -1; |
265 | 352 | |
266 | 353 | /* back up and start over */ |
288 | 375 | return -1; |
289 | 376 | |
290 | 377 | /* check that there's no error */ |
291 | if (state->err != Z_OK) | |
378 | if (state->err != Z_OK && state->err != Z_BUF_ERROR) | |
292 | 379 | return -1; |
293 | 380 | |
294 | 381 | /* can only seek from start or relative to current position */ |
297 | 384 | |
298 | 385 | /* normalize offset to a SEEK_CUR specification */ |
299 | 386 | if (whence == SEEK_SET) |
300 | offset -= state->pos; | |
387 | offset -= state->x.pos; | |
301 | 388 | else if (state->seek) |
302 | 389 | offset += state->skip; |
303 | 390 | state->seek = 0; |
304 | 391 | |
305 | 392 | /* if within raw area while reading, just go there */ |
306 | 393 | 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); | |
309 | 396 | if (ret == -1) |
310 | 397 | return -1; |
311 | state->have = 0; | |
398 | state->x.have = 0; | |
312 | 399 | state->eof = 0; |
400 | state->past = 0; | |
313 | 401 | state->seek = 0; |
314 | 402 | gz_error(state, Z_OK, NULL); |
315 | 403 | state->strm.avail_in = 0; |
316 | state->pos += offset; | |
317 | return state->pos; | |
404 | state->x.pos += offset; | |
405 | return state->x.pos; | |
318 | 406 | } |
319 | 407 | |
320 | 408 | /* calculate skip amount, rewinding if needed for back seek when reading */ |
321 | 409 | if (offset < 0) { |
322 | 410 | if (state->mode != GZ_READ) /* writing -- can't go backwards */ |
323 | 411 | return -1; |
324 | offset += state->pos; | |
412 | offset += state->x.pos; | |
325 | 413 | if (offset < 0) /* before start of file! */ |
326 | 414 | return -1; |
327 | 415 | if (gzrewind(file) == -1) /* rewind, then skip to offset */ |
330 | 418 | |
331 | 419 | /* if reading, skip what's in output buffer (one less gzgetc() check) */ |
332 | 420 | 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; | |
338 | 426 | offset -= n; |
339 | 427 | } |
340 | 428 | |
343 | 431 | state->seek = 1; |
344 | 432 | state->skip = offset; |
345 | 433 | } |
346 | return state->pos + offset; | |
434 | return state->x.pos + offset; | |
347 | 435 | } |
348 | 436 | |
349 | 437 | /* -- see zlib.h -- */ |
372 | 460 | return -1; |
373 | 461 | |
374 | 462 | /* return position */ |
375 | return state->pos + (state->seek ? state->skip : 0); | |
463 | return state->x.pos + (state->seek ? state->skip : 0); | |
376 | 464 | } |
377 | 465 | |
378 | 466 | /* -- see zlib.h -- */ |
432 | 520 | return 0; |
433 | 521 | |
434 | 522 | /* 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; | |
437 | 524 | } |
438 | 525 | |
439 | 526 | /* -- see zlib.h -- */ |
453 | 540 | /* return error information */ |
454 | 541 | if (errnum != NULL) |
455 | 542 | *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); | |
457 | 545 | } |
458 | 546 | |
459 | 547 | /* -- see zlib.h -- */ |
470 | 558 | return; |
471 | 559 | |
472 | 560 | /* clear error and end-of-file */ |
473 | if (state->mode == GZ_READ) | |
561 | if (state->mode == GZ_READ) { | |
474 | 562 | state->eof = 0; |
563 | state->past = 0; | |
564 | } | |
475 | 565 | gz_error(state, Z_OK, NULL); |
476 | 566 | } |
477 | 567 | |
493 | 583 | state->msg = NULL; |
494 | 584 | } |
495 | 585 | |
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 | ||
496 | 590 | /* set error code, and if no message, then done */ |
497 | 591 | state->err = err; |
498 | 592 | if (msg == NULL) |
499 | 593 | return; |
500 | 594 | |
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) | |
504 | 597 | return; |
505 | } | |
506 | 598 | |
507 | 599 | /* 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) { | |
509 | 602 | state->err = Z_MEM_ERROR; |
510 | state->msg = (char *)"out of memory"; | |
511 | 603 | return; |
512 | 604 | } |
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 | |
513 | 609 | strcpy(state->msg, state->path); |
514 | 610 | strcat(state->msg, ": "); |
515 | 611 | strcat(state->msg, msg); |
612 | #endif | |
516 | 613 | return; |
517 | 614 | } |
518 | 615 |
0 | 0 | /* 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 | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
7 | 7 | /* Local functions */ |
8 | 8 | local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); |
9 | 9 | 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)); | |
12 | 11 | local int gz_decomp OF((gz_statep)); |
13 | local int gz_make OF((gz_statep)); | |
12 | local int gz_fetch OF((gz_statep)); | |
14 | 13 | local int gz_skip OF((gz_statep, z_off64_t)); |
15 | 14 | |
16 | 15 | /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from |
45 | 44 | error, 0 otherwise. Note that the eof flag is set when the end of the input |
46 | 45 | file is reached, even though there may be unused data in the buffer. Once |
47 | 46 | 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. */ | |
49 | 50 | local int gz_avail(state) |
50 | 51 | gz_statep state; |
51 | 52 | { |
53 | unsigned got; | |
52 | 54 | z_streamp strm = &(state->strm); |
53 | 55 | |
54 | if (state->err != Z_OK) | |
56 | if (state->err != Z_OK && state->err != Z_BUF_ERROR) | |
55 | 57 | return -1; |
56 | 58 | 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; | |
60 | 71 | strm->next_in = state->in; |
61 | 72 | } |
62 | 73 | return 0; |
63 | 74 | } |
64 | 75 | |
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. | |
92 | 77 | If this is the first time in, allocate required memory. state->how will be |
93 | 78 | left unchanged if there is no more input data available, will be set to COPY |
94 | 79 | 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) | |
104 | 86 | gz_statep state; |
105 | 87 | { |
106 | 88 | z_streamp strm = &(state->strm); |
107 | int flags; | |
108 | unsigned len; | |
109 | 89 | |
110 | 90 | /* allocate read buffers and inflate memory */ |
111 | 91 | if (state->size == 0) { |
112 | 92 | /* 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); | |
115 | 95 | if (state->in == NULL || state->out == NULL) { |
116 | 96 | if (state->out != NULL) |
117 | 97 | free(state->out); |
128 | 108 | state->strm.opaque = Z_NULL; |
129 | 109 | state->strm.avail_in = 0; |
130 | 110 | 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 */ | |
132 | 112 | free(state->out); |
133 | 113 | free(state->in); |
134 | 114 | state->size = 0; |
137 | 117 | } |
138 | 118 | } |
139 | 119 | |
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) { | |
142 | 122 | if (gz_avail(state) == -1) |
143 | 123 | return -1; |
144 | 124 | if (strm->avail_in == 0) |
145 | 125 | return 0; |
146 | 126 | } |
147 | 127 | |
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; | |
214 | 156 | 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; | |
217 | 159 | strm->avail_in = 0; |
218 | 160 | } |
219 | 161 | state->how = COPY; |
222 | 164 | } |
223 | 165 | |
224 | 166 | /* 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. */ | |
232 | 171 | local int gz_decomp(state) |
233 | 172 | gz_statep state; |
234 | 173 | { |
235 | int ret; | |
174 | int ret = Z_OK; | |
236 | 175 | unsigned had; |
237 | unsigned long crc, len; | |
238 | 176 | z_streamp strm = &(state->strm); |
239 | 177 | |
240 | 178 | /* fill output buffer up to end of deflate stream */ |
244 | 182 | if (strm->avail_in == 0 && gz_avail(state) == -1) |
245 | 183 | return -1; |
246 | 184 | 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; | |
249 | 187 | } |
250 | 188 | |
251 | 189 | /* decompress and handle errors */ |
252 | 190 | ret = inflate(strm, Z_NO_FLUSH); |
253 | 191 | if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { |
254 | 192 | gz_error(state, Z_STREAM_ERROR, |
255 | "internal error: inflate stream corrupt"); | |
193 | "internal error: inflate stream corrupt"); | |
256 | 194 | return -1; |
257 | 195 | } |
258 | 196 | if (ret == Z_MEM_ERROR) { |
261 | 199 | } |
262 | 200 | if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ |
263 | 201 | gz_error(state, Z_DATA_ERROR, |
264 | strm->msg == NULL ? "compressed data error" : strm->msg); | |
202 | strm->msg == NULL ? "compressed data error" : strm->msg); | |
265 | 203 | return -1; |
266 | 204 | } |
267 | 205 | } while (strm->avail_out && ret != Z_STREAM_END); |
268 | 206 | |
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; | |
291 | 214 | |
292 | 215 | /* good decompression */ |
293 | 216 | return 0; |
294 | 217 | } |
295 | 218 | |
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. | |
297 | 220 | Data is either copied from the input file or decompressed from the input |
298 | 221 | 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) | |
304 | 226 | gz_statep state; |
305 | 227 | { |
306 | 228 | z_streamp strm = &(state->strm); |
307 | 229 | |
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; | |
312 | 243 | 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)); | |
325 | 251 | return 0; |
326 | 252 | } |
327 | 253 | |
335 | 261 | /* skip over len bytes or reach end-of-file, whichever comes first */ |
336 | 262 | while (len) |
337 | 263 | /* 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; | |
344 | 270 | len -= n; |
345 | 271 | } |
346 | 272 | |
351 | 277 | /* need more data to skip -- load up output buffer */ |
352 | 278 | else { |
353 | 279 | /* get more output, looking for header if required */ |
354 | if (gz_make(state) == -1) | |
280 | if (gz_fetch(state) == -1) | |
355 | 281 | return -1; |
356 | 282 | } |
357 | 283 | return 0; |
373 | 299 | state = (gz_statep)file; |
374 | 300 | strm = &(state->strm); |
375 | 301 | |
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)) | |
378 | 305 | return -1; |
379 | 306 | |
380 | 307 | /* since an int is returned, make sure len fits in one, otherwise return |
381 | 308 | with an error (this avoids the flaw in the interface) */ |
382 | 309 | 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"); | |
384 | 311 | return -1; |
385 | 312 | } |
386 | 313 | |
399 | 326 | got = 0; |
400 | 327 | do { |
401 | 328 | /* 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; | |
407 | 334 | } |
408 | 335 | |
409 | 336 | /* 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 */ | |
411 | 339 | break; |
340 | } | |
412 | 341 | |
413 | 342 | /* need output data -- for small len or new stream load up our output |
414 | 343 | buffer */ |
415 | 344 | else if (state->how == LOOK || len < (state->size << 1)) { |
416 | 345 | /* 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 */ | |
420 | 349 | /* the copy above assures that we will leave with space in the |
421 | 350 | output buffer, allowing at least one gzungetc() to succeed */ |
422 | 351 | } |
423 | 352 | |
424 | 353 | /* large len -- read directly into user buffer */ |
425 | 354 | 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) | |
427 | 356 | return -1; |
428 | 357 | } |
429 | 358 | |
430 | 359 | /* large len -- decompress directly into user buffer */ |
431 | 360 | else { /* state->how == GZIP */ |
432 | 361 | strm->avail_out = len; |
433 | strm->next_out = buf; | |
362 | strm->next_out = (unsigned char *)buf; | |
434 | 363 | if (gz_decomp(state) == -1) |
435 | 364 | return -1; |
436 | n = state->have; | |
437 | state->have = 0; | |
365 | n = state->x.have; | |
366 | state->x.have = 0; | |
438 | 367 | } |
439 | 368 | |
440 | 369 | /* update progress */ |
441 | 370 | len -= n; |
442 | 371 | buf = (char *)buf + n; |
443 | 372 | got += n; |
444 | state->pos += n; | |
373 | state->x.pos += n; | |
445 | 374 | } while (len); |
446 | 375 | |
447 | 376 | /* return number of bytes read into user buffer (will fit in int) */ |
449 | 378 | } |
450 | 379 | |
451 | 380 | /* -- see zlib.h -- */ |
381 | #ifdef Z_PREFIX_SET | |
382 | # undef z_gzgetc | |
383 | #else | |
384 | # undef gzgetc | |
385 | #endif | |
452 | 386 | int ZEXPORT gzgetc(file) |
453 | 387 | gzFile file; |
454 | 388 | { |
461 | 395 | return -1; |
462 | 396 | state = (gz_statep)file; |
463 | 397 | |
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)) | |
466 | 401 | return -1; |
467 | 402 | |
468 | 403 | /* 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)++; | |
473 | 408 | } |
474 | 409 | |
475 | 410 | /* nothing there -- try gzread() */ |
476 | 411 | ret = gzread(file, buf, 1); |
477 | 412 | return ret < 1 ? -1 : buf[0]; |
413 | } | |
414 | ||
415 | int ZEXPORT gzgetc_(file) | |
416 | gzFile file; | |
417 | { | |
418 | return gzgetc(file); | |
478 | 419 | } |
479 | 420 | |
480 | 421 | /* -- see zlib.h -- */ |
489 | 430 | return -1; |
490 | 431 | state = (gz_statep)file; |
491 | 432 | |
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)) | |
494 | 436 | return -1; |
495 | 437 | |
496 | 438 | /* process a skip request */ |
505 | 447 | return -1; |
506 | 448 | |
507 | 449 | /* 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; | |
513 | 456 | return c; |
514 | 457 | } |
515 | 458 | |
516 | 459 | /* 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"); | |
519 | 462 | return -1; |
520 | 463 | } |
521 | 464 | |
522 | 465 | /* 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; | |
525 | 468 | unsigned char *dest = state->out + (state->size << 1); |
526 | 469 | while (src > state->out) |
527 | 470 | *--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; | |
534 | 478 | return c; |
535 | 479 | } |
536 | 480 | |
550 | 494 | return NULL; |
551 | 495 | state = (gz_statep)file; |
552 | 496 | |
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)) | |
555 | 500 | return NULL; |
556 | 501 | |
557 | 502 | /* process a skip request */ |
568 | 513 | left = (unsigned)len - 1; |
569 | 514 | if (left) do { |
570 | 515 | /* 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 */ | |
579 | 521 | } |
580 | 522 | |
581 | 523 | /* 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); | |
584 | 526 | if (eol != NULL) |
585 | n = (unsigned)(eol - state->next) + 1; | |
527 | n = (unsigned)(eol - state->x.next) + 1; | |
586 | 528 | |
587 | 529 | /* 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; | |
592 | 534 | left -= n; |
593 | 535 | buf += n; |
594 | 536 | } while (left && eol == NULL); |
595 | 537 | |
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; | |
597 | 541 | buf[0] = 0; |
598 | 542 | return str; |
599 | 543 | } |
609 | 553 | return 0; |
610 | 554 | state = (gz_statep)file; |
611 | 555 | |
612 | /* check that we're reading */ | |
613 | if (state->mode != GZ_READ) | |
614 | return 0; | |
615 | ||
616 | 556 | /* if the state is not known, but we can find out, then do so (this is |
617 | 557 | 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 */ | |
622 | 562 | return state->direct; |
623 | 563 | } |
624 | 564 | |
626 | 566 | int ZEXPORT gzclose_r(file) |
627 | 567 | gzFile file; |
628 | 568 | { |
629 | int ret; | |
569 | int ret, err; | |
630 | 570 | gz_statep state; |
631 | 571 | |
632 | 572 | /* get internal structure */ |
644 | 584 | free(state->out); |
645 | 585 | free(state->in); |
646 | 586 | } |
587 | err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; | |
647 | 588 | gz_error(state, Z_OK, NULL); |
648 | 589 | free(state->path); |
649 | 590 | ret = close(state->fd); |
650 | 591 | free(state); |
651 | return ret ? Z_ERRNO : Z_OK; | |
652 | } | |
592 | return ret ? Z_ERRNO : err; | |
593 | } |
0 | 0 | /* 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 | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
17 | 17 | int ret; |
18 | 18 | z_streamp strm = &(state->strm); |
19 | 19 | |
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) { | |
25 | 44 | free(state->out); |
26 | if (state->in != NULL) | |
27 | 45 | 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 | } | |
42 | 49 | } |
43 | 50 | |
44 | 51 | /* mark state as initialized */ |
45 | 52 | state->size = state->want; |
46 | 53 | |
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 | } | |
51 | 60 | return 0; |
52 | 61 | } |
53 | 62 | |
54 | 63 | /* Compress whatever is at avail_in and next_in and write to the output file. |
55 | 64 | Return -1 if there is an error writing to the output file, otherwise 0. |
56 | 65 | 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. */ | |
58 | 69 | local int gz_comp(state, flush) |
59 | 70 | gz_statep state; |
60 | 71 | int flush; |
66 | 77 | /* allocate memory if this is the first time through */ |
67 | 78 | if (state->size == 0 && gz_init(state) == -1) |
68 | 79 | 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 | } | |
69 | 91 | |
70 | 92 | /* run deflate() on provided input until it produces no more output */ |
71 | 93 | ret = Z_OK; |
74 | 96 | doing Z_FINISH then don't write until we get to Z_STREAM_END */ |
75 | 97 | if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && |
76 | 98 | (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 || | |
79 | 101 | (unsigned)got != have)) { |
80 | 102 | gz_error(state, Z_ERRNO, zstrerror()); |
81 | 103 | return -1; |
84 | 106 | strm->avail_out = state->size; |
85 | 107 | strm->next_out = state->out; |
86 | 108 | } |
87 | state->next = strm->next_out; | |
109 | state->x.next = strm->next_out; | |
88 | 110 | } |
89 | 111 | |
90 | 112 | /* compress */ |
130 | 152 | } |
131 | 153 | strm->avail_in = n; |
132 | 154 | strm->next_in = state->in; |
133 | state->pos += n; | |
155 | state->x.pos += n; | |
134 | 156 | if (gz_comp(state, Z_NO_FLUSH) == -1) |
135 | 157 | return -1; |
136 | 158 | len -= n; |
145 | 167 | unsigned len; |
146 | 168 | { |
147 | 169 | unsigned put = len; |
148 | unsigned n; | |
149 | 170 | gz_statep state; |
150 | 171 | z_streamp strm; |
151 | 172 | |
162 | 183 | /* since an int is returned, make sure len fits in one, otherwise return |
163 | 184 | with an error (this avoids the flaw in the interface) */ |
164 | 185 | 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"); | |
166 | 187 | return 0; |
167 | 188 | } |
168 | 189 | |
185 | 206 | if (len < state->size) { |
186 | 207 | /* copy to input buffer, compress when full */ |
187 | 208 | do { |
209 | unsigned have, copy; | |
210 | ||
188 | 211 | if (strm->avail_in == 0) |
189 | 212 | 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; | |
198 | 222 | if (len && gz_comp(state, Z_NO_FLUSH) == -1) |
199 | 223 | return 0; |
200 | 224 | } while (len); |
206 | 230 | |
207 | 231 | /* directly compress user buffer to file */ |
208 | 232 | 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; | |
211 | 235 | if (gz_comp(state, Z_NO_FLUSH) == -1) |
212 | 236 | return 0; |
213 | 237 | } |
221 | 245 | gzFile file; |
222 | 246 | int c; |
223 | 247 | { |
248 | unsigned have; | |
224 | 249 | unsigned char buf[1]; |
225 | 250 | gz_statep state; |
226 | 251 | z_streamp strm; |
244 | 269 | |
245 | 270 | /* try writing to input buffer for speed (state->size == 0 if buffer not |
246 | 271 | initialized) */ |
247 | if (strm->avail_in < state->size) { | |
272 | if (state->size) { | |
248 | 273 | if (strm->avail_in == 0) |
249 | 274 | 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 | } | |
253 | 282 | } |
254 | 283 | |
255 | 284 | /* no room in buffer or not initialized, use gz_write() */ |
256 | 285 | buf[0] = c; |
257 | 286 | if (gzwrite(file, buf, 1) != 1) |
258 | 287 | return -1; |
259 | return c; | |
288 | return c & 0xff; | |
260 | 289 | } |
261 | 290 | |
262 | 291 | /* -- see zlib.h -- */ |
273 | 302 | return ret == 0 && len != 0 ? -1 : ret; |
274 | 303 | } |
275 | 304 | |
276 | #ifdef STDC | |
305 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | |
277 | 306 | #include <stdarg.h> |
278 | 307 | |
279 | 308 | /* -- see zlib.h -- */ |
280 | int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) | |
309 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |
281 | 310 | { |
282 | 311 | int size, len; |
283 | 312 | gz_statep state; |
284 | 313 | z_streamp strm; |
285 | va_list va; | |
286 | 314 | |
287 | 315 | /* get internal structure */ |
288 | 316 | if (file == NULL) |
312 | 340 | /* do the printf() into the input buffer, put length in len */ |
313 | 341 | size = (int)(state->size); |
314 | 342 | state->in[size - 1] = 0; |
315 | va_start(va, format); | |
316 | 343 | #ifdef NO_vsnprintf |
317 | 344 | # ifdef HAS_vsprintf_void |
318 | (void)vsprintf(state->in, format, va); | |
319 | va_end(va); | |
345 | (void)vsprintf((char *)(state->in), format, va); | |
320 | 346 | for (len = 0; len < size; len++) |
321 | 347 | if (state->in[len] == 0) break; |
322 | 348 | # else |
323 | len = vsprintf(state->in, format, va); | |
324 | va_end(va); | |
349 | len = vsprintf((char *)(state->in), format, va); | |
325 | 350 | # endif |
326 | 351 | #else |
327 | 352 | # 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)); | |
331 | 355 | # else |
332 | 356 | len = vsnprintf((char *)(state->in), size, format, va); |
333 | va_end(va); | |
334 | 357 | # endif |
335 | 358 | #endif |
336 | 359 | |
341 | 364 | /* update buffer and position, defer compression until needed */ |
342 | 365 | strm->avail_in = (unsigned)len; |
343 | 366 | strm->next_in = state->in; |
344 | state->pos += len; | |
367 | state->x.pos += len; | |
345 | 368 | return len; |
346 | 369 | } |
347 | 370 | |
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 */ | |
349 | 383 | |
350 | 384 | /* -- see zlib.h -- */ |
351 | 385 | int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, |
364 | 398 | return -1; |
365 | 399 | state = (gz_statep)file; |
366 | 400 | strm = &(state->strm); |
401 | ||
402 | /* check that can really pass pointer in ints */ | |
403 | if (sizeof(int) != sizeof(void *)) | |
404 | return 0; | |
367 | 405 | |
368 | 406 | /* check that we're writing and that there's no error */ |
369 | 407 | if (state->mode != GZ_WRITE || state->err != Z_OK) |
389 | 427 | state->in[size - 1] = 0; |
390 | 428 | #ifdef NO_snprintf |
391 | 429 | # 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, | |
393 | 431 | a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); |
394 | 432 | for (len = 0; len < size; len++) |
395 | 433 | if (state->in[len] == 0) break; |
396 | 434 | # 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); | |
399 | 437 | # endif |
400 | 438 | #else |
401 | 439 | # 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, | |
403 | 441 | a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); |
404 | len = strlen(state->in); | |
442 | len = strlen((char *)(state->in)); | |
405 | 443 | # 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); | |
408 | 447 | # endif |
409 | 448 | #endif |
410 | 449 | |
415 | 454 | /* update buffer and position, defer compression until needed */ |
416 | 455 | strm->avail_in = (unsigned)len; |
417 | 456 | strm->next_in = state->in; |
418 | state->pos += len; | |
457 | state->x.pos += len; | |
419 | 458 | return len; |
420 | 459 | } |
421 | 460 | |
499 | 538 | int ZEXPORT gzclose_w(file) |
500 | 539 | gzFile file; |
501 | 540 | { |
502 | int ret = 0; | |
541 | int ret = Z_OK; | |
503 | 542 | gz_statep state; |
504 | 543 | |
505 | 544 | /* get internal structure */ |
514 | 553 | /* check for seek request */ |
515 | 554 | if (state->seek) { |
516 | 555 | state->seek = 0; |
517 | ret += gz_zero(state, state->skip); | |
556 | if (gz_zero(state, state->skip) == -1) | |
557 | ret = state->err; | |
518 | 558 | } |
519 | 559 | |
520 | 560 | /* 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 | } | |
525 | 570 | gz_error(state, Z_OK, NULL); |
526 | 571 | free(state->path); |
527 | ret += close(state->fd); | |
572 | if (close(state->fd) == -1) | |
573 | ret = Z_ERRNO; | |
528 | 574 | free(state); |
529 | return ret ? Z_ERRNO : Z_OK; | |
530 | } | |
575 | return ret; | |
576 | } |
0 | 0 | /* infback.c -- inflate using a call-back interface |
1 | * Copyright (C) 1995-2009 Mark Adler | |
1 | * Copyright (C) 1995-2011 Mark Adler | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
41 | 41 | return Z_STREAM_ERROR; |
42 | 42 | strm->msg = Z_NULL; /* in case we return an error */ |
43 | 43 | if (strm->zalloc == (alloc_func)0) { |
44 | #ifdef Z_SOLO | |
45 | return Z_STREAM_ERROR; | |
46 | #else | |
44 | 47 | strm->zalloc = zcalloc; |
45 | 48 | strm->opaque = (voidpf)0; |
49 | #endif | |
46 | 50 | } |
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 | |
48 | 57 | state = (struct inflate_state FAR *)ZALLOC(strm, 1, |
49 | 58 | sizeof(struct inflate_state)); |
50 | 59 | if (state == Z_NULL) return Z_MEM_ERROR; |
245 | 254 | void FAR *out_desc; |
246 | 255 | { |
247 | 256 | struct inflate_state FAR *state; |
248 | unsigned char FAR *next; /* next input */ | |
257 | z_const unsigned char FAR *next; /* next input */ | |
249 | 258 | unsigned char FAR *put; /* next output */ |
250 | 259 | unsigned have, left; /* available input and output */ |
251 | 260 | unsigned long hold; /* bit buffer */ |
393 | 402 | PULLBYTE(); |
394 | 403 | } |
395 | 404 | if (here.val < 16) { |
396 | NEEDBITS(here.bits); | |
397 | 405 | DROPBITS(here.bits); |
398 | 406 | state->lens[state->have++] = here.val; |
399 | 407 | } |
0 | 0 | /* inffast.c -- fast decoding |
1 | * Copyright (C) 1995-2008, 2010 Mark Adler | |
1 | * Copyright (C) 1995-2008, 2010, 2013 Mark Adler | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
68 | 68 | unsigned start; /* inflate()'s starting value for strm->avail_out */ |
69 | 69 | { |
70 | 70 | 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 */ | |
73 | 73 | unsigned char FAR *out; /* local strm->next_out */ |
74 | 74 | unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ |
75 | 75 | unsigned char FAR *end; /* while out < end, enough space available */ |
1 | 1 | * Generated automatically by makefixed(). |
2 | 2 | */ |
3 | 3 | |
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. | |
7 | 7 | */ |
8 | 8 | |
9 | 9 | static const code lenfix[512] = { |
0 | 0 | /* inflate.c -- zlib decompression |
1 | * Copyright (C) 1995-2010 Mark Adler | |
1 | * Copyright (C) 1995-2012 Mark Adler | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
92 | 92 | |
93 | 93 | /* function prototypes */ |
94 | 94 | 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)); | |
96 | 97 | #ifdef BUILDFIXED |
97 | 98 | void makefixed OF((void)); |
98 | 99 | #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, | |
100 | 101 | unsigned len)); |
101 | 102 | |
102 | int ZEXPORT inflateReset(strm) | |
103 | int ZEXPORT inflateResetKeep(strm) | |
103 | 104 | z_streamp strm; |
104 | 105 | { |
105 | 106 | struct inflate_state FAR *state; |
108 | 109 | state = (struct inflate_state FAR *)strm->state; |
109 | 110 | strm->total_in = strm->total_out = state->total = 0; |
110 | 111 | 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; | |
112 | 114 | state->mode = HEAD; |
113 | 115 | state->last = 0; |
114 | 116 | state->havedict = 0; |
115 | 117 | state->dmax = 32768U; |
116 | 118 | state->head = Z_NULL; |
117 | state->wsize = 0; | |
118 | state->whave = 0; | |
119 | state->wnext = 0; | |
120 | 119 | state->hold = 0; |
121 | 120 | state->bits = 0; |
122 | 121 | state->lencode = state->distcode = state->next = state->codes; |
126 | 125 | return Z_OK; |
127 | 126 | } |
128 | 127 | |
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 | ||
129 | 141 | int ZEXPORT inflateReset2(strm, windowBits) |
130 | 142 | z_streamp strm; |
131 | 143 | int windowBits; |
179 | 191 | if (strm == Z_NULL) return Z_STREAM_ERROR; |
180 | 192 | strm->msg = Z_NULL; /* in case we return an error */ |
181 | 193 | if (strm->zalloc == (alloc_func)0) { |
194 | #ifdef Z_SOLO | |
195 | return Z_STREAM_ERROR; | |
196 | #else | |
182 | 197 | strm->zalloc = zcalloc; |
183 | 198 | 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 | |
186 | 207 | state = (struct inflate_state FAR *) |
187 | 208 | ZALLOC(strm, 1, sizeof(struct inflate_state)); |
188 | 209 | if (state == Z_NULL) return Z_MEM_ERROR; |
320 | 341 | low = 0; |
321 | 342 | for (;;) { |
322 | 343 | 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); | |
325 | 346 | if (++low == size) break; |
326 | 347 | putchar(','); |
327 | 348 | } |
354 | 375 | output will fall in the output data, making match copies simpler and faster. |
355 | 376 | The advantage may be dependent on the size of the processor's data caches. |
356 | 377 | */ |
357 | local int updatewindow(strm, out) | |
378 | local int updatewindow(strm, end, copy) | |
358 | 379 | z_streamp strm; |
359 | unsigned out; | |
380 | const Bytef *end; | |
381 | unsigned copy; | |
360 | 382 | { |
361 | 383 | struct inflate_state FAR *state; |
362 | unsigned copy, dist; | |
384 | unsigned dist; | |
363 | 385 | |
364 | 386 | state = (struct inflate_state FAR *)strm->state; |
365 | 387 | |
379 | 401 | } |
380 | 402 | |
381 | 403 | /* copy state->wsize or less output bytes into the circular window */ |
382 | copy = out - strm->avail_out; | |
383 | 404 | if (copy >= state->wsize) { |
384 | zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); | |
405 | zmemcpy(state->window, end - state->wsize, state->wsize); | |
385 | 406 | state->wnext = 0; |
386 | 407 | state->whave = state->wsize; |
387 | 408 | } |
388 | 409 | else { |
389 | 410 | dist = state->wsize - state->wnext; |
390 | 411 | 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); | |
392 | 413 | copy -= dist; |
393 | 414 | if (copy) { |
394 | zmemcpy(state->window, strm->next_out - copy, copy); | |
415 | zmemcpy(state->window, end - copy, copy); | |
395 | 416 | state->wnext = copy; |
396 | 417 | state->whave = state->wsize; |
397 | 418 | } |
498 | 519 | bits -= bits & 7; \ |
499 | 520 | } while (0) |
500 | 521 | |
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 | ||
506 | 522 | /* |
507 | 523 | inflate() uses a state machine to process as much input data and generate as |
508 | 524 | much output data as possible before returning. The state machine is |
590 | 606 | int flush; |
591 | 607 | { |
592 | 608 | struct inflate_state FAR *state; |
593 | unsigned char FAR *next; /* next input */ | |
609 | z_const unsigned char FAR *next; /* next input */ | |
594 | 610 | unsigned char FAR *put; /* next output */ |
595 | 611 | unsigned have, left; /* available input and output */ |
596 | 612 | unsigned long hold; /* bit buffer */ |
796 | 812 | #endif |
797 | 813 | case DICTID: |
798 | 814 | NEEDBITS(32); |
799 | strm->adler = state->check = REVERSE(hold); | |
815 | strm->adler = state->check = ZSWAP32(hold); | |
800 | 816 | INITBITS(); |
801 | 817 | state->mode = DICT; |
802 | 818 | case DICT: |
904 | 920 | while (state->have < 19) |
905 | 921 | state->lens[order[state->have++]] = 0; |
906 | 922 | state->next = state->codes; |
907 | state->lencode = (code const FAR *)(state->next); | |
923 | state->lencode = (const code FAR *)(state->next); | |
908 | 924 | state->lenbits = 7; |
909 | 925 | ret = inflate_table(CODES, state->lens, 19, &(state->next), |
910 | 926 | &(state->lenbits), state->work); |
924 | 940 | PULLBYTE(); |
925 | 941 | } |
926 | 942 | if (here.val < 16) { |
927 | NEEDBITS(here.bits); | |
928 | 943 | DROPBITS(here.bits); |
929 | 944 | state->lens[state->have++] = here.val; |
930 | 945 | } |
979 | 994 | values here (9 and 6) without reading the comments in inftrees.h |
980 | 995 | concerning the ENOUGH constants, which depend on those values */ |
981 | 996 | state->next = state->codes; |
982 | state->lencode = (code const FAR *)(state->next); | |
997 | state->lencode = (const code FAR *)(state->next); | |
983 | 998 | state->lenbits = 9; |
984 | 999 | ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), |
985 | 1000 | &(state->lenbits), state->work); |
988 | 1003 | state->mode = BAD; |
989 | 1004 | break; |
990 | 1005 | } |
991 | state->distcode = (code const FAR *)(state->next); | |
1006 | state->distcode = (const code FAR *)(state->next); | |
992 | 1007 | state->distbits = 6; |
993 | 1008 | ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, |
994 | 1009 | &(state->next), &(state->distbits), state->work); |
1169 | 1184 | #ifdef GUNZIP |
1170 | 1185 | state->flags ? hold : |
1171 | 1186 | #endif |
1172 | REVERSE(hold)) != state->check) { | |
1187 | ZSWAP32(hold)) != state->check) { | |
1173 | 1188 | strm->msg = (char *)"incorrect data check"; |
1174 | 1189 | state->mode = BAD; |
1175 | 1190 | break; |
1213 | 1228 | */ |
1214 | 1229 | inf_leave: |
1215 | 1230 | 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)) { | |
1218 | 1234 | state->mode = MEM; |
1219 | 1235 | return Z_MEM_ERROR; |
1220 | 1236 | } |
1248 | 1264 | return Z_OK; |
1249 | 1265 | } |
1250 | 1266 | |
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 | ||
1251 | 1290 | int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) |
1252 | 1291 | z_streamp strm; |
1253 | 1292 | const Bytef *dictionary; |
1254 | 1293 | uInt dictLength; |
1255 | 1294 | { |
1256 | 1295 | struct inflate_state FAR *state; |
1257 | unsigned long id; | |
1296 | unsigned long dictid; | |
1297 | int ret; | |
1258 | 1298 | |
1259 | 1299 | /* check state */ |
1260 | 1300 | if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; |
1262 | 1302 | if (state->wrap != 0 && state->mode != DICT) |
1263 | 1303 | return Z_STREAM_ERROR; |
1264 | 1304 | |
1265 | /* check for correct dictionary id */ | |
1305 | /* check for correct dictionary identifier */ | |
1266 | 1306 | 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) | |
1270 | 1310 | return Z_DATA_ERROR; |
1271 | 1311 | } |
1272 | 1312 | |
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) { | |
1275 | 1317 | state->mode = MEM; |
1276 | 1318 | 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; | |
1287 | 1319 | } |
1288 | 1320 | state->havedict = 1; |
1289 | 1321 | Tracev((stderr, "inflate: dictionary set\n")); |
1320 | 1352 | */ |
1321 | 1353 | local unsigned syncsearch(have, buf, len) |
1322 | 1354 | unsigned FAR *have; |
1323 | unsigned char FAR *buf; | |
1355 | const unsigned char FAR *buf; | |
1324 | 1356 | unsigned len; |
1325 | 1357 | { |
1326 | 1358 | unsigned got; |
1432 | 1464 | } |
1433 | 1465 | |
1434 | 1466 | /* 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)); | |
1437 | 1469 | if (state->lencode >= state->codes && |
1438 | 1470 | state->lencode <= state->codes + ENOUGH - 1) { |
1439 | 1471 | copy->lencode = copy->codes + (state->lencode - state->codes); |
0 | 0 | /* inftrees.c -- generate Huffman trees for efficient decoding |
1 | * Copyright (C) 1995-2010 Mark Adler | |
1 | * Copyright (C) 1995-2013 Mark Adler | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
8 | 8 | #define MAXBITS 15 |
9 | 9 | |
10 | 10 | const char inflate_copyright[] = |
11 | " inflate 1.2.5 Copyright 1995-2010 Mark Adler "; | |
11 | " inflate 1.2.8 Copyright 1995-2013 Mark Adler "; | |
12 | 12 | /* |
13 | 13 | If you use the zlib library in a product, an acknowledgment is welcome |
14 | 14 | in the documentation of your product. If for some reason you cannot |
61 | 61 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
62 | 62 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
63 | 63 | 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}; | |
65 | 65 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ |
66 | 66 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
67 | 67 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
207 | 207 | mask = used - 1; /* mask for comparing low */ |
208 | 208 | |
209 | 209 | /* 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)) | |
212 | 212 | return 1; |
213 | 213 | |
214 | 214 | /* process all codes and make table entries */ |
276 | 276 | |
277 | 277 | /* check for enough space */ |
278 | 278 | 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)) | |
281 | 281 | return 1; |
282 | 282 | |
283 | 283 | /* point entry in root table to sub-table */ |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
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; | |
323 | 299 | } |
324 | 300 | |
325 | 301 | /* set return parameters */ |
0 | 0 | /* trees.c -- output deflated data using Huffman coding |
1 | * Copyright (C) 1995-2010 Jean-loup Gailly | |
1 | * Copyright (C) 1995-2012 Jean-loup Gailly | |
2 | 2 | * detect_data_type() function provided freely by Cosmin Truta, 2006 |
3 | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | 4 | */ |
29 | 29 | * Addison-Wesley, 1983. ISBN 0-201-06672-6. |
30 | 30 | */ |
31 | 31 | |
32 | /* @(#) $Id: trees.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
32 | /* @(#) $Id$ */ | |
33 | 33 | |
34 | 34 | /* #define GEN_TREES_H */ |
35 | 35 | |
71 | 71 | = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; |
72 | 72 | /* The lengths of the bit length codes are sent in order of decreasing |
73 | 73 | * 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.) | |
79 | 74 | */ |
80 | 75 | |
81 | 76 | /* =========================================================================== |
150 | 145 | local int build_bl_tree OF((deflate_state *s)); |
151 | 146 | local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, |
152 | 147 | 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)); | |
155 | 150 | local int detect_data_type OF((deflate_state *s)); |
156 | 151 | local unsigned bi_reverse OF((unsigned value, int length)); |
157 | 152 | local void bi_windup OF((deflate_state *s)); |
398 | 393 | |
399 | 394 | s->bi_buf = 0; |
400 | 395 | s->bi_valid = 0; |
401 | s->last_eob_len = 8; /* enough lookahead for inflate */ | |
402 | 396 | #ifdef DEBUG |
403 | 397 | s->compressed_len = 0L; |
404 | 398 | s->bits_sent = 0L; |
882 | 876 | } |
883 | 877 | |
884 | 878 | /* =========================================================================== |
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 | /* =========================================================================== | |
885 | 888 | * Send one empty static block to give enough lookahead for inflate. |
886 | 889 | * 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. | |
894 | 890 | */ |
895 | 891 | void ZLIB_INTERNAL _tr_align(s) |
896 | 892 | deflate_state *s; |
901 | 897 | s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ |
902 | 898 | #endif |
903 | 899 | 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; | |
918 | 900 | } |
919 | 901 | |
920 | 902 | /* =========================================================================== |
989 | 971 | } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { |
990 | 972 | #endif |
991 | 973 | 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); | |
993 | 976 | #ifdef DEBUG |
994 | 977 | s->compressed_len += 3 + s->static_len; |
995 | 978 | #endif |
997 | 980 | send_bits(s, (DYN_TREES<<1)+last, 3); |
998 | 981 | send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, |
999 | 982 | 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); | |
1001 | 985 | #ifdef DEBUG |
1002 | 986 | s->compressed_len += 3 + s->opt_len; |
1003 | 987 | #endif |
1074 | 1058 | */ |
1075 | 1059 | local void compress_block(s, ltree, dtree) |
1076 | 1060 | 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 */ | |
1079 | 1063 | { |
1080 | 1064 | unsigned dist; /* distance of matched string */ |
1081 | 1065 | int lc; /* match length or unmatched char (if dist == 0) */ |
1117 | 1101 | } while (lx < s->last_lit); |
1118 | 1102 | |
1119 | 1103 | send_code(s, END_BLOCK, ltree); |
1120 | s->last_eob_len = ltree[END_BLOCK].Len; | |
1121 | 1104 | } |
1122 | 1105 | |
1123 | 1106 | /* =========================================================================== |
1225 | 1208 | int header; /* true if block header must be written */ |
1226 | 1209 | { |
1227 | 1210 | bi_windup(s); /* align on byte boundary */ |
1228 | s->last_eob_len = 8; /* enough lookahead for inflate */ | |
1229 | 1211 | |
1230 | 1212 | if (header) { |
1231 | 1213 | put_short(s, (ush)len); |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
5 | /* @(#) $Id: uncompr.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
5 | /* @(#) $Id$ */ | |
6 | 6 | |
7 | 7 | #define ZLIB_INTERNAL |
8 | 8 | #include "zlib.h" |
29 | 29 | z_stream stream; |
30 | 30 | int err; |
31 | 31 | |
32 | stream.next_in = (Bytef*)source; | |
32 | stream.next_in = (z_const Bytef *)source; | |
33 | 33 | stream.avail_in = (uInt)sourceLen; |
34 | 34 | /* Check for source > 64K on 16-bit machine: */ |
35 | 35 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; |
0 | 0 | /* zconf.h -- configuration of the zlib compression library |
1 | * Copyright (C) 1995-2010 Jean-loup Gailly. | |
1 | * Copyright (C) 1995-2013 Jean-loup Gailly. | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
5 | /* @(#) $Id: zconf.h,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
5 | /* @(#) $Id$ */ | |
6 | 6 | |
7 | 7 | #ifndef ZCONF_H |
8 | 8 | #define ZCONF_H |
14 | 14 | * this permanently in zconf.h using "./configure --zprefix". |
15 | 15 | */ |
16 | 16 | #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ |
17 | # define Z_PREFIX_SET | |
17 | 18 | |
18 | 19 | /* all linked symbols */ |
19 | 20 | # define _dist_code z__dist_code |
20 | 21 | # define _length_code z__length_code |
21 | 22 | # define _tr_align z__tr_align |
23 | # define _tr_flush_bits z__tr_flush_bits | |
22 | 24 | # define _tr_flush_block z__tr_flush_block |
23 | 25 | # define _tr_init z__tr_init |
24 | 26 | # define _tr_stored_block z__tr_stored_block |
26 | 28 | # define adler32 z_adler32 |
27 | 29 | # define adler32_combine z_adler32_combine |
28 | 30 | # 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 | |
32 | 36 | # define crc32 z_crc32 |
33 | 37 | # define crc32_combine z_crc32_combine |
34 | 38 | # define crc32_combine64 z_crc32_combine64 |
39 | 43 | # define deflateInit2_ z_deflateInit2_ |
40 | 44 | # define deflateInit_ z_deflateInit_ |
41 | 45 | # define deflateParams z_deflateParams |
46 | # define deflatePending z_deflatePending | |
42 | 47 | # define deflatePrime z_deflatePrime |
43 | 48 | # define deflateReset z_deflateReset |
49 | # define deflateResetKeep z_deflateResetKeep | |
44 | 50 | # define deflateSetDictionary z_deflateSetDictionary |
45 | 51 | # define deflateSetHeader z_deflateSetHeader |
46 | 52 | # define deflateTune z_deflateTune |
47 | 53 | # define deflate_copyright z_deflate_copyright |
48 | 54 | # 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 | |
80 | 93 | # define inflate z_inflate |
81 | 94 | # define inflateBack z_inflateBack |
82 | 95 | # define inflateBackEnd z_inflateBackEnd |
91 | 104 | # define inflateReset z_inflateReset |
92 | 105 | # define inflateReset2 z_inflateReset2 |
93 | 106 | # define inflateSetDictionary z_inflateSetDictionary |
107 | # define inflateGetDictionary z_inflateGetDictionary | |
94 | 108 | # define inflateSync z_inflateSync |
95 | 109 | # define inflateSyncPoint z_inflateSyncPoint |
96 | 110 | # define inflateUndermine z_inflateUndermine |
111 | # define inflateResetKeep z_inflateResetKeep | |
97 | 112 | # define inflate_copyright z_inflate_copyright |
98 | 113 | # define inflate_fast z_inflate_fast |
99 | 114 | # define inflate_table z_inflate_table |
100 | # define uncompress z_uncompress | |
115 | # ifndef Z_SOLO | |
116 | # define uncompress z_uncompress | |
117 | # endif | |
101 | 118 | # 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 | |
104 | 123 | # define zlibCompileFlags z_zlibCompileFlags |
105 | 124 | # define zlibVersion z_zlibVersion |
106 | 125 | |
110 | 129 | # define alloc_func z_alloc_func |
111 | 130 | # define charf z_charf |
112 | 131 | # define free_func z_free_func |
113 | # define gzFile z_gzFile | |
132 | # ifndef Z_SOLO | |
133 | # define gzFile z_gzFile | |
134 | # endif | |
114 | 135 | # define gz_header z_gz_header |
115 | 136 | # define gz_headerp z_gz_headerp |
116 | 137 | # define in_func z_in_func |
196 | 217 | # endif |
197 | 218 | #endif |
198 | 219 | |
220 | #if defined(ZLIB_CONST) && !defined(z_const) | |
221 | # define z_const const | |
222 | #else | |
223 | # define z_const | |
224 | #endif | |
225 | ||
199 | 226 | /* Some Mac compilers merge all .h files incorrectly: */ |
200 | 227 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) |
201 | 228 | # define NO_DUMMY_DECL |
239 | 266 | # define OF(args) args |
240 | 267 | # else |
241 | 268 | # 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) () | |
242 | 277 | # endif |
243 | 278 | #endif |
244 | 279 | |
355 | 390 | typedef Byte *voidp; |
356 | 391 | #endif |
357 | 392 | |
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 | ||
358 | 410 | #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ |
359 | 411 | # define Z_HAVE_UNISTD_H |
360 | 412 | #endif |
361 | 413 | |
414 | #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ | |
415 | # define Z_HAVE_STDARG_H | |
416 | #endif | |
417 | ||
362 | 418 | #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 | |
364 | 434 | #endif |
365 | 435 | |
366 | 436 | /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and |
369 | 439 | * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as |
370 | 440 | * equivalently requesting no 64-bit operations |
371 | 441 | */ |
372 | #if -_LARGEFILE64_SOURCE - -1 == 1 | |
442 | #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 | |
373 | 443 | # undef _LARGEFILE64_SOURCE |
374 | 444 | #endif |
375 | 445 | |
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) | |
387 | 474 | # define SEEK_SET 0 /* Seek from beginning of file. */ |
388 | 475 | # define SEEK_CUR 1 /* Seek from current position. */ |
389 | 476 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ |
393 | 480 | # define z_off_t long |
394 | 481 | #endif |
395 | 482 | |
396 | #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 | |
483 | #if !defined(_WIN32) && defined(Z_LARGE64) | |
397 | 484 | # define z_off64_t off64_t |
398 | 485 | #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 | |
408 | 491 | #endif |
409 | 492 | |
410 | 493 | /* MVS linker does not support external names larger than 8 bytes */ |
0 | 0 | /* 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 | |
4 | 4 | |
5 | 5 | This software is provided 'as-is', without any express or implied |
6 | 6 | warranty. In no event will the authors be held liable for any damages |
23 | 23 | |
24 | 24 | |
25 | 25 | 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). | |
28 | 28 | */ |
29 | 29 | |
30 | 30 | #ifndef ZLIB_H |
36 | 36 | extern "C" { |
37 | 37 | #endif |
38 | 38 | |
39 | #define ZLIB_VERSION "1.2.5" | |
40 | #define ZLIB_VERNUM 0x1250 | |
39 | #define ZLIB_VERSION "1.2.8" | |
40 | #define ZLIB_VERNUM 0x1280 | |
41 | 41 | #define ZLIB_VER_MAJOR 1 |
42 | 42 | #define ZLIB_VER_MINOR 2 |
43 | #define ZLIB_VER_REVISION 5 | |
43 | #define ZLIB_VER_REVISION 8 | |
44 | 44 | #define ZLIB_VER_SUBREVISION 0 |
45 | 45 | |
46 | 46 | /* |
82 | 82 | struct internal_state; |
83 | 83 | |
84 | 84 | typedef struct z_stream_s { |
85 | Bytef *next_in; /* next input byte */ | |
85 | z_const Bytef *next_in; /* next input byte */ | |
86 | 86 | 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 */ | |
88 | 88 | |
89 | 89 | Bytef *next_out; /* next output byte should be put there */ |
90 | 90 | 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 */ | |
94 | 94 | struct internal_state FAR *state; /* not visible by applications */ |
95 | 95 | |
96 | 96 | alloc_func zalloc; /* used to allocate the internal state */ |
326 | 326 | |
327 | 327 | Z_FINISH can be used immediately after deflateInit if all the compression |
328 | 328 | 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. | |
331 | 332 | |
332 | 333 | deflate() sets strm->adler to the adler32 checksum of all input read |
333 | 334 | so far (that is, total_in bytes). |
450 | 451 | error. However if all decompression is to be performed in a single step (a |
451 | 452 | single call of inflate), the parameter flush should be set to Z_FINISH. In |
452 | 453 | 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. | |
459 | 465 | |
460 | 466 | In this implementation, inflate() always flushes as much output as |
461 | 467 | 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. | |
465 | 472 | |
466 | 473 | 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 | |
468 | 475 | 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, | |
470 | 477 | total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described |
471 | 478 | below. At the end of the stream, inflate() checks that its computed adler32 |
472 | 479 | checksum is equal to that saved by the compressor and returns Z_STREAM_END |
477 | 484 | initializing with inflateInit2(). Any information contained in the gzip |
478 | 485 | header is not retained, so applications that need that information should |
479 | 486 | 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. | |
481 | 490 | |
482 | 491 | inflate() returns Z_OK if some progress has been made (more input processed |
483 | 492 | or more output produced), Z_STREAM_END if the end of the compressed data has |
579 | 588 | uInt dictLength)); |
580 | 589 | /* |
581 | 590 | 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). | |
586 | 600 | |
587 | 601 | The dictionary should consist of strings (byte sequences) that are likely |
588 | 602 | to be encountered later in the data to be compressed, with the most commonly |
609 | 623 | deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a |
610 | 624 | parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is |
611 | 625 | 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(). | |
614 | 628 | */ |
615 | 629 | |
616 | 630 | ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, |
687 | 701 | deflation of sourceLen bytes. It must be called after deflateInit() or |
688 | 702 | deflateInit2(), and after deflateSetHeader(), if used. This would be used |
689 | 703 | 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 | */ | |
692 | 726 | |
693 | 727 | ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, |
694 | 728 | int bits, |
702 | 736 | than or equal to 16, and that many of the least significant bits of value |
703 | 737 | will be inserted in the output. |
704 | 738 | |
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. | |
707 | 742 | */ |
708 | 743 | |
709 | 744 | ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, |
789 | 824 | if that call returned Z_NEED_DICT. The dictionary chosen by the compressor |
790 | 825 | can be determined from the adler32 value returned by that call of inflate. |
791 | 826 | 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. | |
796 | 832 | |
797 | 833 | inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a |
798 | 834 | parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is |
802 | 838 | inflate(). |
803 | 839 | */ |
804 | 840 | |
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 | ||
805 | 856 | ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); |
806 | 857 | /* |
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 | |
809 | 860 | available input is skipped. No output is provided. |
810 | 861 | |
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. | |
818 | 873 | */ |
819 | 874 | |
820 | 875 | ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, |
961 | 1016 | See inflateBack() for the usage of these routines. |
962 | 1017 | |
963 | 1018 | 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 | |
965 | 1020 | allocated, or Z_VERSION_ERROR if the version of the library does not match |
966 | 1021 | the version of the header file. |
967 | 1022 | */ |
968 | 1023 | |
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 *)); | |
970 | 1026 | typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); |
971 | 1027 | |
972 | 1028 | ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, |
974 | 1030 | out_func out, void FAR *out_desc)); |
975 | 1031 | /* |
976 | 1032 | 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. | |
982 | 1039 | |
983 | 1040 | inflateBackInit() must be called first to allocate the internal state |
984 | 1041 | and to initialize the state with the user-provided window buffer. |
1087 | 1144 | 27-31: 0 (reserved) |
1088 | 1145 | */ |
1089 | 1146 | |
1147 | #ifndef Z_SOLO | |
1090 | 1148 | |
1091 | 1149 | /* utility functions */ |
1092 | 1150 | |
1148 | 1206 | |
1149 | 1207 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not |
1150 | 1208 | 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 | */ | |
1154 | 1213 | |
1155 | 1214 | /* gzip file access functions */ |
1156 | 1215 | |
1161 | 1220 | wrapper, documented in RFC 1952, wrapped around a deflate stream. |
1162 | 1221 | */ |
1163 | 1222 | |
1164 | typedef voidp gzFile; /* opaque gzip file descriptor */ | |
1223 | typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ | |
1165 | 1224 | |
1166 | 1225 | /* |
1167 | 1226 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); |
1171 | 1230 | a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only |
1172 | 1231 | compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' |
1173 | 1232 | 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. | |
1178 | 1250 | |
1179 | 1251 | 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. | |
1181 | 1255 | |
1182 | 1256 | gzopen returns NULL if the file could not be opened, if there was |
1183 | 1257 | insufficient memory to allocate the gzFile state, or if an invalid mode was |
1196 | 1270 | descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor |
1197 | 1271 | fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, |
1198 | 1272 | 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. | |
1200 | 1278 | |
1201 | 1279 | gzdopen returns NULL if there was insufficient memory to allocate the |
1202 | 1280 | gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not |
1234 | 1312 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); |
1235 | 1313 | /* |
1236 | 1314 | 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. | |
1239 | 1317 | |
1240 | 1318 | 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. | |
1245 | 1335 | |
1246 | 1336 | gzread returns the number of uncompressed bytes actually read, less than |
1247 | 1337 | len for end of file, or -1 for error. |
1255 | 1345 | error. |
1256 | 1346 | */ |
1257 | 1347 | |
1258 | ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); | |
1348 | ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); | |
1259 | 1349 | /* |
1260 | 1350 | Converts, formats, and writes the arguments to the compressed file under |
1261 | 1351 | control of the format string, as in fprintf. gzprintf returns the number of |
1300 | 1390 | ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); |
1301 | 1391 | /* |
1302 | 1392 | 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. | |
1304 | 1397 | */ |
1305 | 1398 | |
1306 | 1399 | ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); |
1396 | 1489 | ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); |
1397 | 1490 | /* |
1398 | 1491 | 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. | |
1402 | 1493 | |
1403 | 1494 | If the input file is empty, gzdirect() will return true, since the input |
1404 | 1495 | does not contain a gzip stream. |
1407 | 1498 | cause buffers to be allocated to allow reading the file to determine if it |
1408 | 1499 | is a gzip file. Therefore if gzbuffer() is used, it should be called before |
1409 | 1500 | 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.) | |
1410 | 1508 | */ |
1411 | 1509 | |
1412 | 1510 | ZEXTERN int ZEXPORT gzclose OF((gzFile file)); |
1418 | 1516 | must not be called more than once on the same allocation. |
1419 | 1517 | |
1420 | 1518 | 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. | |
1422 | 1521 | */ |
1423 | 1522 | |
1424 | 1523 | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); |
1456 | 1555 | file that is being written concurrently. |
1457 | 1556 | */ |
1458 | 1557 | |
1558 | #endif /* !Z_SOLO */ | |
1459 | 1559 | |
1460 | 1560 | /* checksum functions */ |
1461 | 1561 | |
1491 | 1591 | Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 |
1492 | 1592 | and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for |
1493 | 1593 | 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. | |
1495 | 1597 | */ |
1496 | 1598 | |
1497 | 1599 | ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); |
1498 | 1600 | /* |
1499 | 1601 | Update a running CRC-32 with the bytes buf[0..len-1] and return the |
1500 | 1602 | 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. | |
1504 | 1605 | |
1505 | 1606 | Usage example: |
1506 | 1607 | |
1543 | 1644 | const char *version, |
1544 | 1645 | int stream_size)); |
1545 | 1646 | #define deflateInit(strm, level) \ |
1546 | deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) | |
1647 | deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) | |
1547 | 1648 | #define inflateInit(strm) \ |
1548 | inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) | |
1649 | inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) | |
1549 | 1650 | #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ |
1550 | 1651 | deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ |
1551 | (strategy), ZLIB_VERSION, sizeof(z_stream)) | |
1652 | (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) | |
1552 | 1653 | #define inflateInit2(strm, windowBits) \ |
1553 | inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) | |
1654 | inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ | |
1655 | (int)sizeof(z_stream)) | |
1554 | 1656 | #define inflateBackInit(strm, windowBits, window) \ |
1555 | 1657 | 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 | |
1557 | 1683 | |
1558 | 1684 | /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or |
1559 | 1685 | * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if |
1561 | 1687 | * functions are changed to 64 bits) -- in case these are set on systems |
1562 | 1688 | * without large file support, _LFS64_LARGEFILE must also be true |
1563 | 1689 | */ |
1564 | #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 | |
1690 | #ifdef Z_LARGE64 | |
1565 | 1691 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
1566 | 1692 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); |
1567 | 1693 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); |
1570 | 1696 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); |
1571 | 1697 | #endif |
1572 | 1698 | |
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 | |
1581 | 1716 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
1582 | 1717 | ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); |
1583 | 1718 | ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); |
1594 | 1729 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); |
1595 | 1730 | #endif |
1596 | 1731 | |
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 | ||
1597 | 1739 | /* hack for buggy compilers */ |
1598 | 1740 | #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) |
1599 | 1741 | struct internal_state {int dummy;}; |
1602 | 1744 | /* undocumented functions */ |
1603 | 1745 | ZEXTERN const char * ZEXPORT zError OF((int)); |
1604 | 1746 | 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)); | |
1606 | 1748 | 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 | |
1607 | 1762 | |
1608 | 1763 | #ifdef __cplusplus |
1609 | 1764 | } |
0 | 0 | /* 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. | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
5 | /* @(#) $Id: zutil.c,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
5 | /* @(#) $Id$ */ | |
6 | 6 | |
7 | 7 | #include "zutil.h" |
8 | #ifndef Z_SOLO | |
9 | # include "gzguts.h" | |
10 | #endif | |
8 | 11 | |
9 | 12 | #ifndef NO_DUMMY_DECL |
10 | 13 | struct internal_state {int dummy;}; /* for buggy compilers */ |
11 | 14 | #endif |
12 | 15 | |
13 | const char * const z_errmsg[10] = { | |
16 | z_const char * const z_errmsg[10] = { | |
14 | 17 | "need dictionary", /* Z_NEED_DICT 2 */ |
15 | 18 | "stream end", /* Z_STREAM_END 1 */ |
16 | 19 | "", /* Z_OK 0 */ |
84 | 87 | #ifdef FASTEST |
85 | 88 | flags += 1L << 21; |
86 | 89 | #endif |
87 | #ifdef STDC | |
90 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | |
88 | 91 | # ifdef NO_vsnprintf |
89 | flags += 1L << 25; | |
92 | flags += 1L << 25; | |
90 | 93 | # ifdef HAS_vsprintf_void |
91 | flags += 1L << 26; | |
94 | flags += 1L << 26; | |
92 | 95 | # endif |
93 | 96 | # else |
94 | 97 | # ifdef HAS_vsnprintf_void |
95 | flags += 1L << 26; | |
98 | flags += 1L << 26; | |
96 | 99 | # endif |
97 | 100 | # endif |
98 | 101 | #else |
99 | flags += 1L << 24; | |
102 | flags += 1L << 24; | |
100 | 103 | # ifdef NO_snprintf |
101 | flags += 1L << 25; | |
104 | flags += 1L << 25; | |
102 | 105 | # ifdef HAS_sprintf_void |
103 | flags += 1L << 26; | |
106 | flags += 1L << 26; | |
104 | 107 | # endif |
105 | 108 | # else |
106 | 109 | # ifdef HAS_snprintf_void |
107 | flags += 1L << 26; | |
110 | flags += 1L << 26; | |
108 | 111 | # endif |
109 | 112 | # endif |
110 | 113 | #endif |
180 | 183 | } |
181 | 184 | #endif |
182 | 185 | |
186 | #ifndef Z_SOLO | |
183 | 187 | |
184 | 188 | #ifdef SYS16BIT |
185 | 189 | |
315 | 319 | } |
316 | 320 | |
317 | 321 | #endif /* MY_ZCALLOC */ |
322 | ||
323 | #endif /* !Z_SOLO */ |
0 | 0 | /* 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. | |
2 | 2 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | */ |
4 | 4 | |
7 | 7 | subject to change. Applications should only use zlib.h. |
8 | 8 | */ |
9 | 9 | |
10 | /* @(#) $Id: zutil.h,v 1.2 2010/06/30 04:58:25 gtkwave Exp $ */ | |
10 | /* @(#) $Id$ */ | |
11 | 11 | |
12 | 12 | #ifndef ZUTIL_H |
13 | 13 | #define ZUTIL_H |
14 | 14 | |
15 | #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) | |
15 | #ifdef HAVE_HIDDEN | |
16 | 16 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
17 | 17 | #else |
18 | 18 | # define ZLIB_INTERNAL |
20 | 20 | |
21 | 21 | #include "zlib.h" |
22 | 22 | |
23 | #ifdef STDC | |
23 | #if defined(STDC) && !defined(Z_SOLO) | |
24 | 24 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) |
25 | 25 | # include <stddef.h> |
26 | 26 | # endif |
27 | 27 | # include <string.h> |
28 | 28 | # include <stdlib.h> |
29 | #endif | |
30 | ||
31 | #ifdef Z_SOLO | |
32 | typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ | |
29 | 33 | #endif |
30 | 34 | |
31 | 35 | #ifndef local |
39 | 43 | typedef ush FAR ushf; |
40 | 44 | typedef unsigned long ulg; |
41 | 45 | |
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 */ | |
43 | 47 | /* (size given to avoid silly warnings with Visual C++) */ |
44 | 48 | |
45 | 49 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] |
46 | 50 | |
47 | 51 | #define ERR_RETURN(strm,err) \ |
48 | return (strm->msg = (char*)ERR_MSG(err), (err)) | |
52 | return (strm->msg = ERR_MSG(err), (err)) | |
49 | 53 | /* To be used only when the state is known to be valid */ |
50 | 54 | |
51 | 55 | /* common constants */ |
77 | 81 | |
78 | 82 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
79 | 83 | # 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> | |
87 | 95 | # endif |
88 | # else /* MSC or DJGPP */ | |
89 | # include <malloc.h> | |
90 | 96 | # endif |
91 | 97 | #endif |
92 | 98 | |
106 | 112 | |
107 | 113 | #ifdef OS2 |
108 | 114 | # define OS_CODE 0x06 |
109 | # ifdef M_I86 | |
115 | # if defined(M_I86) && !defined(Z_SOLO) | |
110 | 116 | # include <malloc.h> |
111 | 117 | # endif |
112 | 118 | #endif |
113 | 119 | |
114 | 120 | #if defined(MACOS) || defined(TARGET_OS_MAC) |
115 | 121 | # 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 | |
121 | 129 | # endif |
122 | 130 | # endif |
123 | 131 | #endif |
152 | 160 | # endif |
153 | 161 | #endif |
154 | 162 | |
155 | #if defined(__BORLANDC__) | |
163 | #if defined(__BORLANDC__) && !defined(MSDOS) | |
156 | 164 | #pragma warn -8004 |
157 | 165 | #pragma warn -8008 |
158 | 166 | #pragma warn -8066 |
159 | 167 | #endif |
160 | 168 | |
161 | 169 | /* 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) | |
163 | 172 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
164 | 173 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
165 | 174 | #endif |
176 | 185 | |
177 | 186 | /* functions */ |
178 | 187 | |
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) | |
215 | 189 | # define NO_MEMCPY |
216 | 190 | #endif |
217 | 191 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) |
260 | 234 | # define Tracecv(c,x) |
261 | 235 | #endif |
262 | 236 | |
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 | |
267 | 242 | |
268 | 243 | #define ZALLOC(strm, items, size) \ |
269 | 244 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
270 | 245 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
271 | 246 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} |
272 | 247 | |
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 | ||
273 | 252 | #endif /* ZUTIL_H */ |
0 | 0 | /* |
1 | * Copyright (c) Tony Bybell 2001-2011. | |
1 | * Copyright (c) Tony Bybell 2001-2013. | |
2 | 2 | * |
3 | 3 | * This program is free software; you can redistribute it and/or |
4 | 4 | * modify it under the terms of the GNU General Public License |
182 | 182 | |
183 | 183 | #ifdef USE_X86_INLINE_ASM |
184 | 184 | |
185 | inline static unsigned int get_byte(offset) { | |
185 | inline static unsigned int get_byte(off_t offset) { | |
186 | 186 | return ((unsigned int)(*((unsigned char *) GLOBALS->mm_lxt_c_1+offset))); |
187 | 187 | } |
188 | 188 |
0 | 0 | /* |
1 | * Copyright (c) Tony Bybell 1999-2012. | |
1 | * Copyright (c) Tony Bybell 1999-2013. | |
2 | 2 | * |
3 | 3 | * This program is free software; you can redistribute it and/or |
4 | 4 | * modify it under the terms of the GNU General Public License |
369 | 369 | } |
370 | 370 | #endif |
371 | 371 | } |
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); | |
373 | 373 | gtk_main(); |
374 | 374 | |
375 | 375 | return(GLOBALS->ftext_main_main_c_1); |
5425 | 5425 | static void |
5426 | 5426 | menu_open_hierarchy_2a(gpointer null_data, guint callback_action, GtkWidget *widget, int typ) |
5427 | 5427 | { |
5428 | Trptr t; | |
5429 | int fix=0; | |
5430 | 5428 | if(GLOBALS->helpbox_is_active) |
5431 | 5429 | { |
5432 | 5430 | if((typ == FST_MT_SOURCESTEM) || (typ == FST_MT_SOURCEISTEM)) |
0 | 0 | /* |
1 | * Copyright (c) Tony Bybell 1999-2012. | |
1 | * Copyright (c) Tony Bybell 1999-2013. | |
2 | 2 | * |
3 | 3 | * This program is free software; you can redistribute it and/or |
4 | 4 | * modify it under the terms of the GNU General Public License |
412 | 412 | */ |
413 | 413 | static gint keypress_local(GtkWidget *widget, GdkEventKey *event, gpointer data) |
414 | 414 | { |
415 | GtkAdjustment *wadj, *hadj; | |
415 | GtkAdjustment *wadj; | |
416 | 416 | int num_traces_displayable; |
417 | 417 | int target; |
418 | 418 | int which; |
526 | 526 | case GDK_Left: |
527 | 527 | case GDK_KP_Left: |
528 | 528 | |
529 | service_left_edge(NULL, 0); | |
530 | /* | |
529 | 531 | hadj=GTK_ADJUSTMENT(GLOBALS->signal_hslider); |
530 | 532 | |
531 | 533 | if(hadj->value < hadj->page_increment) |
537 | 539 | hadj->value = hadj->value - hadj->page_increment; |
538 | 540 | } |
539 | 541 | |
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"); | |
542 | 544 | signalarea_configure_event(GLOBALS->signalarea, NULL); |
545 | */ | |
543 | 546 | |
544 | 547 | rc = TRUE; |
545 | 548 | break; |
547 | 550 | case GDK_Right: |
548 | 551 | case GDK_KP_Right: |
549 | 552 | |
550 | /* fill in left/right hscroll here */ | |
553 | service_right_edge(NULL, 0); | |
554 | /* | |
551 | 555 | hadj=GTK_ADJUSTMENT(GLOBALS->signal_hslider); |
552 | 556 | |
553 | 557 | if( ((int) hadj->value + hadj->page_increment) >= hadj->upper) |
559 | 563 | hadj->value = hadj->value + hadj->page_increment; |
560 | 564 | } |
561 | 565 | |
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"); | |
564 | 568 | signalarea_configure_event(GLOBALS->signalarea, NULL); |
569 | */ | |
565 | 570 | |
566 | 571 | rc = TRUE; |
567 | 572 | break; |
714 | 719 | GdkEventMotion event[1]; |
715 | 720 | event[0].deviceid = GDK_CORE_POINTER; |
716 | 721 | #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 | } | |
717 | 782 | |
718 | 783 | if(in_main_iteration()) return(TRUE); |
719 | 784 |
0 | 0 | /* |
1 | * Copyright (c) Tony Bybell 1999-2011. | |
1 | * Copyright (c) Tony Bybell 1999-2013. | |
2 | 2 | * |
3 | 3 | * This program is free software; you can redistribute it and/or |
4 | 4 | * modify it under the terms of the GNU General Public License |
38 | 38 | |
39 | 39 | static struct item_mark_string item_mark_start_strings[]= |
40 | 40 | { |
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 } | |
68 | 68 | }; |
69 | 69 | |
70 | 70 | static struct item_mark_string item_mark_end_strings[]= |
71 | 71 | { |
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 } | |
99 | 99 | }; |
100 | 100 | |
101 | 101 |
2477 | 2477 | bts->nodes[i]->harray = NULL; |
2478 | 2478 | } |
2479 | 2479 | } |
2480 | else | |
2481 | { | |
2482 | t->interactive_vector_needs_regeneration = 1; | |
2483 | } | |
2480 | 2484 | } |
2481 | 2485 | } |
2482 | 2486 | |
2650 | 2654 | gtkwave_main_iteration(); |
2651 | 2655 | } |
2652 | 2656 | |
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 | ||
2653 | 2675 | void vcd_partial_mark_and_sweep(int mandclear) |
2654 | 2676 | { |
2655 | 2677 | Trptr t; |
2678 | ||
2679 | ||
2656 | 2680 | |
2657 | 2681 | /* node */ |
2658 | 2682 | t = GLOBALS->traces.first; while(t) { if(!t->vector) regen_trace_mark(t, mandclear); t = t->t_next; } |
2661 | 2685 | t = GLOBALS->traces.first; while(t) { if(!t->vector) regen_trace_sweep(t); t = t->t_next; } |
2662 | 2686 | t = GLOBALS->traces.buffer; while(t) { if(!t->vector) regen_trace_sweep(t); t = t->t_next; } |
2663 | 2687 | |
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 | ||
2664 | 2692 | /* vector */ |
2665 | 2693 | t = GLOBALS->traces.first; while(t) { if(t->vector) regen_trace_mark(t, mandclear); t = t->t_next; } |
2666 | 2694 | t = GLOBALS->traces.buffer; while(t) { if(t->vector) regen_trace_mark(t, mandclear); t = t->t_next; } |
1468 | 1468 | else |
1469 | 1469 | if(event->button==2) |
1470 | 1470 | { |
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 | } | |
1472 | 1476 | } |
1473 | 1477 | |
1474 | 1478 | return(TRUE); |