-redo-ifchange cert.pem tofuproxy.cmd fifos/ensure cmd/unzstd/unzstd
+redo-ifchange cert.pem tofuproxy.cmd fifos/ensure cmd/zstd/unzstd
mkdir -p certs ccerts
+++ /dev/null
-compile_flags.txt
+++ /dev/null
-enzstd creates Zstandard compressed stream of frames, where each frame
-holds exactly single WARC record. It also explicitly adds checksum.
-Utility takes records from stdin, where each record has 64-bit
-big-endian length prefix.
+++ /dev/null
-../unzstd/compile_flags.txt.do
\ No newline at end of file
+++ /dev/null
-src=enzstd.c
-redo-ifchange $src
-${CC:-cc} ${CFLAGS} -o $3 $src $LDFLAGS -lzstd
+++ /dev/null
-printf "%s" "$CFLAGS $LDFLAGS" | tr " " "\n" | grep -v "^$" | sort | uniq
+++ /dev/null
-src=unzstd.c
-redo-ifchange $src
-${CC:-cc} ${CFLAGS} -o $3 $src $LDFLAGS -lzstd
--- /dev/null
+/compile_flags.txt
+/enzstd
+/unzstd
--- /dev/null
+enzstd creates Zstandard compressed stream of frames, where each frame
+holds exactly single WARC record. It also explicitly adds checksum.
+Utility takes records from stdin, where each record has 64-bit
+big-endian length prefix.
+
+unzstd decompressed Zstandard frames stream from stdin to stdout. If
+stream starts with the dictionary (either compressed, or uncompressed)
+it is loaded first. If 3rd file descriptor is opened, then each frame's
+offset (its size) with decompressed data size is printed in
+tab-separated format. If the stream contains dictionary, then first
+frame's data size equals to zero.
--- /dev/null
+redo-ifchange enzstd unzstd
--- /dev/null
+redo-ifchange $src conf/zstd.cflags.rc conf/zstd.libs.rc
+read ZSTD_CFLAGS < conf/zstd.cflags.rc
+read ZSTD_LIBS < conf/zstd.libs.rc
+printf "%s" "$CFLAGS $ZSTD_CFLAGS $LDFLAGS $ZSTD_LIBS" |
+ tr " " "\n" | grep -v "^$" | sort | uniq
--- /dev/null
+echo ${PKGCONF:-`command -v pkgconf || command -v pkg-config`}
--- /dev/null
+redo-ifchange pkgconf.rc
+read PKGCONF < pkgconf.rc
+$PKGCONF --cflags libzstd
--- /dev/null
+redo-ifchange pkgconf.rc
+read PKGCONF < pkgconf.rc
+$PKGCONF --libs libzstd
--- /dev/null
+src=$1.c
+redo-ifchange $src conf/zstd.cflags.rc conf/zstd.libs.rc
+read ZSTD_CFLAGS < conf/zstd.cflags.rc
+read ZSTD_LIBS < conf/zstd.libs.rc
+${CC:-cc} $CFLAGS $ZSTD_CFLAGS -o $3 $src $ZSTD_LIBS
rounds/*.go \
tls/*.go \
warc/*.go
-GO_LDFLAGS="${GO_LDFLAGS:--ldflags=-s}"
-${GO:-go} build -o $3 $GO_LDFLAGS ./cmd/${1%.cmd}
+UNZSTD_PATH="`pwd`/cmd/zstd/unzstd"
+GO_LDFLAGS="${GO_LDFLAGS:--s}"
+GO_LDFLAGS="$GO_LDFLAGS -X go.stargrave.org/tofuproxy/warc.UnZSTDPath=$UNZSTD_PATH"
+${GO:-go} build -o $3 -ldflags="$GO_LDFLAGS" ./cmd/${1%.cmd}
Multi-frame format is properly indexed. Dictionary at the beginning
is also supported.
-It is processed with with @command{unzstd} (@file{cmd/unzstd/unzstd})
+It is processed with with @command{unzstd} (@file{cmd/zstd/unzstd})
utility. It eats compressed stream from @code{stdin}, outputs
decompressed data to @code{stdout}, and prints each frame size with
corresponding decompressed data size to 3rd file descriptor (if it is
-opened). You can adjust path to it with
-@code{-X go.stargrave.org/tofuproxy/warc.UnZSTDPath} command line option
-during building.
+opened).
@end table
"path"
)
-var UnZSTDPath = "/home/stargrave/work/tofuproxy/cmd/unzstd/unzstd"
+var UnZSTDPath = "/home/stargrave/work/tofuproxy/cmd/zstd/unzstd"
type Offset struct {
Z int64 // Compressed frame size