├── .buildkite ├── pipeline.yml ├── runtest.sh └── runtest_distro.sh ├── .github └── CODEOWNERS ├── .gitignore ├── .gitmodules ├── CHANGES ├── Dockerfile ├── Dockerfile.alpine ├── Dockerfile.centos7 ├── LICENSE.txt ├── Makefile ├── NOTICE.txt ├── README.md ├── bpf_probes.c ├── bpf_queue.c ├── btf.c ├── btfhub.c ├── catalog-info.yaml ├── compat.c ├── compat.h ├── display_man.c ├── docs ├── index.html ├── mandoc.css ├── quark-btf.8.html ├── quark-mon.8.html ├── quark-test.8.html ├── quark.7.html ├── quark_event_dump.3.html ├── quark_process_iter.3.html ├── quark_process_lookup.3.html ├── quark_queue_block.3.html ├── quark_queue_close.3.html ├── quark_queue_default_attr.3.html ├── quark_queue_get_epollfd.3.html ├── quark_queue_get_event.3.html ├── quark_queue_get_stats.3.html └── quark_queue_open.3.html ├── elastic-ebpf ├── GPL │ └── Events │ │ ├── EbpfEventProto.h │ │ ├── File │ │ ├── File.h │ │ └── Probe.bpf.c │ │ ├── Helpers.h │ │ ├── Network │ │ ├── Network.h │ │ └── Probe.bpf.c │ │ ├── PathResolver.h │ │ ├── Process │ │ └── Probe.bpf.c │ │ ├── State.h │ │ └── Varlen.h ├── commit ├── contrib │ └── vmlinux │ │ ├── aarch64 │ │ └── vmlinux.h │ │ └── x86_64 │ │ └── vmlinux.h └── sync.sh ├── elftoolchain ├── LICENSE ├── README.quark ├── commit ├── common │ ├── _elftc.h │ ├── elfdefinitions.h │ ├── sys │ │ ├── elfconstants.m4 │ │ └── elfdefinitions.m4 │ ├── utarray.h │ └── uthash.h └── libelf │ ├── GNUmakefile │ ├── _libelf.h │ ├── _libelf_ar.h │ ├── _libelf_config.h │ ├── elf.c │ ├── elf.h │ ├── elf_begin.c │ ├── elf_cntl.c │ ├── elf_data.c │ ├── elf_end.c │ ├── elf_errmsg.c │ ├── elf_errno.c │ ├── elf_fill.c │ ├── elf_flag.c │ ├── elf_getarhdr.c │ ├── elf_getarsym.c │ ├── elf_getbase.c │ ├── elf_getident.c │ ├── elf_getversion.c │ ├── elf_hash.c │ ├── elf_kind.c │ ├── elf_memory.c │ ├── elf_next.c │ ├── elf_open.c │ ├── elf_phnum.c │ ├── elf_rand.c │ ├── elf_rawfile.c │ ├── elf_scn.c │ ├── elf_shnum.c │ ├── elf_shstrndx.c │ ├── elf_strptr.c │ ├── elf_types.m4 │ ├── elf_update.c │ ├── elf_version.c │ ├── gelf.h │ ├── gelf_cap.c │ ├── gelf_checksum.c │ ├── gelf_dyn.c │ ├── gelf_ehdr.c │ ├── gelf_fsize.c │ ├── gelf_getclass.c │ ├── gelf_move.c │ ├── gelf_phdr.c │ ├── gelf_rel.c │ ├── gelf_rela.c │ ├── gelf_shdr.c │ ├── gelf_sym.c │ ├── gelf_syminfo.c │ ├── gelf_symshndx.c │ ├── gelf_xlate.c │ ├── libelf.h │ ├── libelf_align.c │ ├── libelf_allocate.c │ ├── libelf_ar.c │ ├── libelf_ar_util.c │ ├── libelf_checksum.c │ ├── libelf_convert.m4 │ ├── libelf_data.c │ ├── libelf_ehdr.c │ ├── libelf_elfmachine.c │ ├── libelf_extended.c │ ├── libelf_fsize.m4 │ ├── libelf_memory.c │ ├── libelf_msize.m4 │ ├── libelf_open.c │ ├── libelf_phdr.c │ ├── libelf_shdr.c │ └── libelf_xlate.c ├── freebsd_queue.h ├── freebsd_tree.h ├── genbtf.sh ├── init.c ├── kprobe_defs.h ├── kprobe_queue.c ├── krun-fedora.sh ├── krun-rhel.sh ├── krun.sh ├── ktest-all.sh ├── licenses ├── APACHE-LICENSE-2.0.txt ├── BSD-2-CLAUSE-LICENSE.txt ├── BSD-3-CLAUSE-LICENSE.txt ├── ISC-LICENSE.txt └── ZLIB-LICENSE.txt ├── man-embedder.c ├── quark-btf.8 ├── quark-btf.c ├── quark-mon.8 ├── quark-mon.c ├── quark-test.8 ├── quark-test.c ├── quark.7 ├── quark.c ├── quark.h ├── quark_event_dump.3 ├── quark_process_iter.3 ├── quark_process_lookup.3 ├── quark_queue_block.3 ├── quark_queue_close.3 ├── quark_queue_default_attr.3 ├── quark_queue_get_epollfd.3 ├── quark_queue_get_event.3 ├── quark_queue_get_stats.3 ├── quark_queue_open.3 ├── qutil.c └── zlib ├── CMakeLists.txt ├── ChangeLog ├── FAQ ├── INDEX ├── LICENSE ├── Makefile.in ├── README ├── README.quark ├── adler32.c ├── amiga ├── Makefile.pup └── Makefile.sas ├── commit ├── compress.c ├── configure ├── contrib ├── README.contrib ├── ada │ ├── buffer_demo.adb │ ├── mtest.adb │ ├── read.adb │ ├── readme.txt │ ├── test.adb │ ├── zlib-streams.adb │ ├── zlib-streams.ads │ ├── zlib-thin.adb │ ├── zlib-thin.ads │ ├── zlib.adb │ ├── zlib.ads │ └── zlib.gpr ├── blast │ ├── Makefile │ ├── README │ ├── blast.c │ ├── blast.h │ ├── test.pk │ └── test.txt ├── delphi │ ├── ZLib.pas │ ├── ZLibConst.pas │ ├── readme.txt │ └── zlibd32.mak ├── dotzlib │ ├── DotZLib.build │ ├── DotZLib.chm │ ├── DotZLib.sln │ ├── DotZLib │ │ ├── AssemblyInfo.cs │ │ ├── ChecksumImpl.cs │ │ ├── CircularBuffer.cs │ │ ├── CodecBase.cs │ │ ├── Deflater.cs │ │ ├── DotZLib.cs │ │ ├── DotZLib.csproj │ │ ├── GZipStream.cs │ │ ├── Inflater.cs │ │ └── UnitTests.cs │ ├── LICENSE_1_0.txt │ └── readme.txt ├── gcc_gvmat64 │ └── gvmat64.S ├── infback9 │ ├── README │ ├── infback9.c │ ├── infback9.h │ ├── inffix9.h │ ├── inflate9.h │ ├── inftree9.c │ └── inftree9.h ├── iostream │ ├── test.cpp │ ├── zfstream.cpp │ └── zfstream.h ├── iostream2 │ ├── zstream.h │ └── zstream_test.cpp ├── iostream3 │ ├── README │ ├── TODO │ ├── test.cc │ ├── zfstream.cc │ └── zfstream.h ├── minizip │ ├── Makefile │ ├── Makefile.am │ ├── MiniZip64_Changes.txt │ ├── MiniZip64_info.txt │ ├── configure.ac │ ├── crypt.h │ ├── ioapi.c │ ├── ioapi.h │ ├── iowin32.c │ ├── iowin32.h │ ├── make_vms.com │ ├── miniunz.c │ ├── miniunzip.1 │ ├── minizip.1 │ ├── minizip.c │ ├── minizip.pc.in │ ├── mztools.c │ ├── mztools.h │ ├── skipset.h │ ├── unzip.c │ ├── unzip.h │ ├── zip.c │ └── zip.h ├── nuget │ ├── nuget.csproj │ └── nuget.sln ├── pascal │ ├── example.pas │ ├── readme.txt │ ├── zlibd32.mak │ └── zlibpas.pas ├── puff │ ├── Makefile │ ├── README │ ├── puff.c │ ├── puff.h │ ├── pufftest.c │ └── zeros.raw ├── testzlib │ ├── testzlib.c │ └── testzlib.txt ├── untgz │ ├── Makefile │ ├── Makefile.msc │ └── untgz.c └── vstudio │ ├── readme.txt │ ├── vc10 │ ├── miniunz.vcxproj │ ├── miniunz.vcxproj.filters │ ├── minizip.vcxproj │ ├── minizip.vcxproj.filters │ ├── testzlib.vcxproj │ ├── testzlib.vcxproj.filters │ ├── testzlibdll.vcxproj │ ├── testzlibdll.vcxproj.filters │ ├── zlib.rc │ ├── zlibstat.vcxproj │ ├── zlibstat.vcxproj.filters │ ├── zlibvc.def │ ├── zlibvc.sln │ ├── zlibvc.vcxproj │ └── zlibvc.vcxproj.filters │ ├── vc11 │ ├── miniunz.vcxproj │ ├── minizip.vcxproj │ ├── testzlib.vcxproj │ ├── testzlibdll.vcxproj │ ├── zlib.rc │ ├── zlibstat.vcxproj │ ├── zlibvc.def │ ├── zlibvc.sln │ └── zlibvc.vcxproj │ ├── vc12 │ ├── miniunz.vcxproj │ ├── minizip.vcxproj │ ├── testzlib.vcxproj │ ├── testzlibdll.vcxproj │ ├── zlib.rc │ ├── zlibstat.vcxproj │ ├── zlibvc.def │ ├── zlibvc.sln │ └── zlibvc.vcxproj │ ├── vc14 │ ├── miniunz.vcxproj │ ├── minizip.vcxproj │ ├── testzlib.vcxproj │ ├── testzlibdll.vcxproj │ ├── zlib.rc │ ├── zlibstat.vcxproj │ ├── zlibvc.def │ ├── zlibvc.sln │ └── zlibvc.vcxproj │ ├── vc17 │ ├── miniunz.vcxproj │ ├── minizip.vcxproj │ ├── testzlib.vcxproj │ ├── testzlibdll.vcxproj │ ├── zlib.rc │ ├── zlibstat.vcxproj │ ├── zlibvc.def │ ├── zlibvc.sln │ └── zlibvc.vcxproj │ └── vc9 │ ├── miniunz.vcproj │ ├── minizip.vcproj │ ├── testzlib.vcproj │ ├── testzlibdll.vcproj │ ├── zlib.rc │ ├── zlibstat.vcproj │ ├── zlibvc.def │ ├── zlibvc.sln │ └── zlibvc.vcproj ├── crc32.c ├── crc32.h ├── deflate.c ├── deflate.h ├── doc ├── algorithm.txt ├── crc-doc.1.0.pdf ├── rfc1950.txt ├── rfc1951.txt ├── rfc1952.txt └── txtvsbin.txt ├── examples ├── README.examples ├── enough.c ├── fitblk.c ├── gun.c ├── gzappend.c ├── gzjoin.c ├── gzlog.c ├── gzlog.h ├── gznorm.c ├── zlib_how.html ├── zpipe.c ├── zran.c └── zran.h ├── gzclose.c ├── gzguts.h ├── gzlib.c ├── gzread.c ├── gzwrite.c ├── infback.c ├── inffast.c ├── inffast.h ├── inffixed.h ├── inflate.c ├── inflate.h ├── inftrees.c ├── inftrees.h ├── make_vms.com ├── msdos ├── Makefile.bor ├── Makefile.dj2 ├── Makefile.emx ├── Makefile.msc └── Makefile.tc ├── nintendods ├── Makefile └── README ├── old ├── Makefile.emx ├── Makefile.riscos ├── README ├── descrip.mms ├── os2 │ ├── Makefile.os2 │ └── zlib.def └── visual-basic.txt ├── os400 ├── README400 ├── bndsrc ├── make.sh └── zlib.inc ├── qnx └── package.qpg ├── test ├── example.c ├── infcover.c └── minigzip.c ├── treebuild.xml ├── trees.c ├── trees.h ├── uncompr.c ├── watcom ├── watcom_f.mak └── watcom_l.mak ├── win32 ├── DLL_FAQ.txt ├── Makefile.bor ├── Makefile.gcc ├── Makefile.msc ├── README-WIN32.txt ├── VisualC.txt ├── zlib.def └── zlib1.rc ├── zconf.h.cmakein ├── zconf.h.in ├── zlib.3 ├── zlib.3.pdf ├── zlib.h ├── zlib.map ├── zlib.pc ├── zlib.pc.cmakein ├── zlib.pc.in ├── zutil.c └── zutil.h /.buildkite/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | function download { 6 | buildkite-agent artifact download "$1" "$2" 7 | } 8 | 9 | if [ -z "${BUILDKITE}" ]; then 10 | echo "This script doesn't appear to be running in buildkite" 1>&2 11 | echo "refusing to continue" 1>&2 12 | exit 1 13 | fi 14 | 15 | download quark-test . 16 | chmod +x quark-test 17 | 18 | sudo ./quark-test 19 | exit $? 20 | -------------------------------------------------------------------------------- /.buildkite/runtest_distro.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | DISTRO="$1" 6 | DISTROVER="$2" 7 | shift 2 8 | 9 | function download { 10 | buildkite-agent artifact download "$1" "$2" 11 | } 12 | 13 | if [ -z "${BUILDKITE}" ]; then 14 | echo "This script doesn't appear to be running in buildkite" 1>&2 15 | echo "refusing to continue" 1>&2 16 | exit 1 17 | fi 18 | 19 | download initramfs.gz . 20 | 21 | echo updating packages... 22 | sudo apt-get -qq update -y 23 | echo installing packages... 24 | sudo apt-get -qq install -y --no-install-recommends \ 25 | cpio \ 26 | cpu-checker \ 27 | lynx \ 28 | qemu-system-x86 \ 29 | qemu-kvm \ 30 | rpm2cpio \ 31 | > /dev/null 32 | 33 | # Make sure we can run things on KVM 34 | sudo kvm-ok 35 | 36 | case "$DISTRO" in 37 | fedora) sudo ./krun-fedora.sh initramfs.gz "$DISTROVER" quark-test $@;; 38 | rhel) sudo ./krun-rhel.sh initramfs.gz "$DISTROVER" quark-test $@;; 39 | *) echo bad distribution "$DISTROVER" 1>&2;; 40 | esac 41 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These owners will be the default owners for everything in 2 | # the repo. 3 | * @elastic/sec-linux-platform 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dot 2 | *.o 3 | *.png 4 | *.svg 5 | cscope.* 6 | quark-mon 7 | quark-mon-static 8 | quark-btf 9 | quark-btf-static 10 | quark-test 11 | quark-test-static 12 | init 13 | libquark.a 14 | libquark_big.a 15 | bpf_probes_skel.h 16 | # manpages.h is autogenerated 17 | manpages.h 18 | man-embedder 19 | manhtml/*.html 20 | elftoolchain/libelf/libelf_pic.a 21 | initramfs/ 22 | initramfs.gz 23 | # include is where we install libbpf headers 24 | include 25 | # These are autogenerated 26 | elftoolchain/libelf/libelf_convert.c 27 | elftoolchain/libelf/libelf_fsize.c 28 | elftoolchain/libelf/libelf_msize.c 29 | elftoolchain/common/sys/elfdefinitions.h 30 | zlib/Makefile 31 | zlib/zconf.h 32 | zlib/configure.log 33 | zlib/libz.a 34 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libbpf"] 2 | path = libbpf 3 | url = https://github.com/libbpf/libbpf 4 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | Quark Breaking Changes 2 | ~~~~~~~~~~~~~~~~~~~~~~ 3 | This file documents breaking and/or other changes that might require 4 | user interaction. Examples include: a user facing structure change; a 5 | new library call; a change in behaviour. 6 | 7 | Changes from 0.1 to 0.2 8 | ~~~~~~~~~~~~~~~~~~~~~~~ 9 | o quark_queue_stats{} got a "backend" member. 10 | 11 | Changes from 0.2 to 0.3 12 | ~~~~~~~~~~~~~~~~~~~~~~~ 13 | o quark_queue_process{} got {uts,ipc,mnt,net}_inonum members. 14 | o -h on quark-{mon,test,btf} now invokes the manpage instead of usage. 15 | 16 | Changes from 0.3 to 0.4 17 | ~~~~~~~~~~~~~~~~~~~~~~~ 18 | o quark_queue_get_events(3) was removed in favor of quark_queue_get_event(3). 19 | o quark_event{} got a new member socket, 20 | QUARK_EV_SOCK_CONN_{ESTABLISHED,CLOSED}. The probes still have 21 | some issues so it's mostly experimental. 22 | o Initial snapshot of process events is not sent anymore. User is 23 | expected to retrieve them via quark_process_iter(3) if desired. 24 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # aka 24.04 2 | FROM ubuntu:noble 3 | ENV BPFTOOL="/usr/lib/linux-tools-6.8.0-41/bpftool" 4 | RUN apt-get update && apt-get install -y \ 5 | clang \ 6 | cpio \ 7 | gcc \ 8 | gcc-aarch64-linux-gnu \ 9 | linux-tools-6.8.0-41-generic \ 10 | make \ 11 | m4 12 | -------------------------------------------------------------------------------- /Dockerfile.alpine: -------------------------------------------------------------------------------- 1 | FROM alpine:3.21 2 | RUN apk add \ 3 | bash \ 4 | clang \ 5 | bpftool \ 6 | gcc \ 7 | libbsd \ 8 | libbsd-dev \ 9 | make \ 10 | musl-fts \ 11 | musl-fts-dev \ 12 | m4 13 | -------------------------------------------------------------------------------- /Dockerfile.centos7: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/CentOS-*.repo 3 | RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/CentOS-*.repo 4 | RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/CentOS-*.repo 5 | RUN yum install -y gcc make m4 less 6 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Source code in this repository is licensed under the Apache License Version 2.0, 2 | an Apache compatible license. 3 | -------------------------------------------------------------------------------- /bpf_probes.c: -------------------------------------------------------------------------------- 1 | #include "vmlinux.h" 2 | 3 | #include 4 | 5 | char LICENSE[] SEC("license") = "Dual BSD/GPL"; 6 | 7 | struct { 8 | __uint(type, BPF_MAP_TYPE_RINGBUF); 9 | __uint(max_entries, 1 << 22); // 4 MiB 10 | } ringbuf SEC(".maps"); 11 | 12 | #include "Process/Probe.bpf.c" 13 | #include "Network/Probe.bpf.c" 14 | #include "File/Probe.bpf.c" 15 | -------------------------------------------------------------------------------- /catalog-info.yaml: -------------------------------------------------------------------------------- 1 | # Declare your Buildkite pipelines below 2 | --- 3 | # yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json 4 | apiVersion: backstage.io/v1alpha1 5 | kind: Resource 6 | metadata: 7 | name: buildkite-pipeline-quark 8 | description: Buildkite Pipeline for quark 9 | links: 10 | - title: Pipeline 11 | url: https://buildkite.com/elastic/quark 12 | 13 | spec: 14 | type: buildkite-pipeline 15 | owner: group:sec-linux-platform 16 | system: buildkite 17 | implementation: 18 | apiVersion: buildkite.elastic.dev/v1 19 | kind: Pipeline 20 | metadata: 21 | name: quark 22 | description: a linux process telemetry library 23 | spec: 24 | repository: elastic/quark 25 | pipeline_file: ".buildkite/pipeline.yml" 26 | teams: 27 | sec-linux-platform: 28 | access_level: MANAGE_BUILD_AND_READ 29 | everyone: 30 | access_level: READ_ONLY 31 | -------------------------------------------------------------------------------- /compat.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: Apache-2.0 */ 2 | /* Copyright (c) 2024 Elastic NV */ 3 | 4 | #ifndef _COMPAT_H_ 5 | #define _COMPAT_H_ 6 | 7 | /* Linux specific */ 8 | #include 9 | 10 | /* Sys */ 11 | #include 12 | 13 | /* Standard */ 14 | #include 15 | #include 16 | 17 | /* 18 | * General compat 19 | */ 20 | /* uint64_t is historically defined as unsigned long on LONG architectures, not 21 | * unsigned long long, meaning we can't always use %llu for printing on 32 and 22 | * 64bit. We use __u64 which is saner. 23 | */ 24 | typedef __u64 u64; 25 | typedef __s64 s64; 26 | typedef __u32 u32; 27 | typedef __s32 s32; 28 | typedef __u16 u16; 29 | typedef __s16 s16; 30 | typedef __u8 u8; 31 | typedef __s8 s8; 32 | typedef uintptr_t __uintptr_t; /* for freebsd_tree.h */ 33 | 34 | #ifndef __aligned 35 | #define __aligned(x) __attribute__((aligned(x))) 36 | #endif /* __aligned */ 37 | 38 | #ifndef __weak 39 | #define __weak __attribute__((weak)) 40 | #endif /* __weak */ 41 | 42 | #ifndef likely 43 | #define likely(x) __builtin_expect(!!(x), 1) 44 | #endif /* likely */ 45 | 46 | #ifndef unlikely 47 | #define unlikely(x) __builtin_expect(!!(x), 0) 48 | #endif /* unlikely */ 49 | 50 | #ifndef nitems 51 | #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) 52 | #endif /* nitems */ 53 | 54 | #ifndef min 55 | #define min(_a, _b) ((_a) < (_b) ? (_a) : (_b)) 56 | #endif /* min */ 57 | 58 | /* 59 | * BSD compat 60 | */ 61 | #include "freebsd_queue.h" 62 | #include "freebsd_tree.h" 63 | 64 | size_t strlcat(char *, const char *, size_t); 65 | size_t strlcpy(char *, const char *, size_t); 66 | long long strtonum(const char *, long long, long long, const char **); 67 | 68 | /* 69 | * Misc 70 | */ 71 | void sshbuf_dump_data(const void *, size_t, FILE *); 72 | 73 | #endif /* _COMPAT_H */ 74 | -------------------------------------------------------------------------------- /display_man.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code is stashed in the end of manpage.h 3 | */ 4 | static void 5 | display_man(void) 6 | { 7 | int fd, status; 8 | char template[] = "/tmp/quark-man-display.XXXXXX"; 9 | pid_t pid; 10 | 11 | fd = mkstemp(template); 12 | if (fd == -1) 13 | err(1, "mkstemp"); 14 | if (qwrite(fd, manpage_bin, sizeof(manpage_bin)) != 0) 15 | err(1, "qwrite"); 16 | close(fd); 17 | 18 | if ((pid = fork()) == -1) 19 | err(1, "fork"); 20 | 21 | /* child */ 22 | if (pid == 0) 23 | exit(execlp("man", "man", template, NULL)); 24 | /* parent */ 25 | if (waitpid(pid, &status, 0) == -1) 26 | err(1, "waitpid"); 27 | if (unlink(template) != 0) 28 | warn("unlink"); 29 | if (WIFEXITED(status)) 30 | exit(WEXITSTATUS(status)); 31 | 32 | exit(1); 33 | } 34 | -------------------------------------------------------------------------------- /docs/quark_queue_close.3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | QUARK_QUEUE_CLOSE(3) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
QUARK_QUEUE_CLOSE(3)Library Functions ManualQUARK_QUEUE_CLOSE(3)
17 |
18 |
19 |

20 |

quark_queue_close — 21 | closes a quark_queue

22 |
23 |
24 |

25 |

#include 26 | <quark.h>

27 |

int 28 |
29 | quark_queue_close(struct 30 | quark_queue *qq);

31 |
32 |

33 | quark_queue_close closes the 34 | quark_queue pointed to by qq, 35 | which must have been previously opened with 36 | quark_queue_open(3). 37 |
38 |

40 |

Zero on success, -1 otherwise and errno is 41 | set.

42 |
43 |
44 |

46 |

quark_event_dump(3), 47 | quark_process_lookup(3), 48 | quark_queue_block(3), 49 | quark_queue_default_attr(3), 50 | quark_queue_get_epollfd(3), 51 | quark_queue_get_event(3), 52 | quark_queue_get_stats(3), 53 | quark_queue_open(3), 54 | quark(7), 55 | quark-btf(8), 56 | quark-mon(8), 57 | quark-test(8)

58 |
59 |
60 | 61 | 62 | 63 | 64 | 65 |
December 1, 2024Linux
66 | 67 | 68 | -------------------------------------------------------------------------------- /docs/quark_queue_default_attr.3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | QUARK_QUEUE_DEFAULT_ATTR(3) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
QUARK_QUEUE_DEFAULT_ATTR(3)Library Functions ManualQUARK_QUEUE_DEFAULT_ATTR(3)
17 |
18 |
19 |

20 |

quark_queue_default_attr — 21 | fetch default attributes for 22 | quark_queue_open(3)

23 |
24 |
25 |

26 |

#include 27 | <quark.h>

28 |

void 29 |
30 | quark_queue_default_attr(struct 31 | quark_queue_attr *attr);

32 |
33 |

34 | quark_queue_default_attr copies out default attributes 35 | for opening a quark_queue. 36 |

Refer to 37 | quark_queue_open(3) for an 38 | in depth explanation of each member.

39 |
40 |

42 |

quark_event_dump(3), 43 | quark_process_lookup(3), 44 | quark_queue_block(3), 45 | quark_queue_close(3), 46 | quark_queue_get_event(3), 47 | quark_queue_open(3), 48 | quark(7), 49 | quark-btf(8), 50 | quark-mon(8), 51 | quark-test(8)

52 |
53 |
54 | 55 | 56 | 57 | 58 | 59 |
December 1, 2024Linux
60 | 61 | 62 | -------------------------------------------------------------------------------- /elastic-ebpf/commit: -------------------------------------------------------------------------------- 1 | 8126a19945eaed63791115350baef23e4e2d387c 2 | -------------------------------------------------------------------------------- /elastic-ebpf/sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # SPDX-License-Identifier: Apache-2.0 4 | # Copyright (c) 2024 Elastic NV 5 | 6 | Script=$(basename $0) 7 | 8 | function usage 9 | { 10 | echo "usage: $Script elastic-ebpf-source-path" 11 | exit 1 12 | } 13 | 14 | if [ $# -ne 1 ]; then 15 | usage 16 | fi 17 | 18 | Src="$1" 19 | Commit=$(cd "$Src" && git rev-parse HEAD) 20 | if [ -z $Commit ]; then 21 | exit 1 22 | fi 23 | 24 | cd $(dirname $0) 25 | for x in $(find . -type f); do 26 | if [ $x = "./$Script" -o $x = "./commit" ]; then 27 | continue 28 | fi 29 | dst=$(realpath "$x") 30 | src=$(realpath "$Src/$x") 31 | # set -x 32 | if ! cp "$src" "$dst"; then 33 | exit 1 34 | fi 35 | done 36 | 37 | echo $Commit > commit 38 | -------------------------------------------------------------------------------- /elftoolchain/LICENSE: -------------------------------------------------------------------------------- 1 | Unless otherwise specified, the Elftoolchain 2 | project's sources are distributed under a 3 | 2-clause BSD license. 4 | 5 | SPDX short identifier: BSD-2-Clause 6 | 7 | <<<--->>> 8 | Copyright (c) 2006-2021, Elftoolchain Project Contributors. 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions 13 | are met: 14 | 15 | 1. Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | 2. Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 22 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | <<<--->>> 33 | -------------------------------------------------------------------------------- /elftoolchain/README.quark: -------------------------------------------------------------------------------- 1 | Elftoolchain@Quark 2 | ~~~~~~~~~~~~~~~~~~ 3 | Elftoolchain has been imported in quark to get rid of the GPLed libelf present 4 | on most linux systems. 5 | 6 | In order to make Elftoolchain fit the project and also work with a recent 7 | libbpf we had to make a few changes. This file documents those changes. 8 | 9 | 10 | Changes to the build system 11 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 | o All Makefiles were removed. 13 | o Dependency on bmake(1) is removed in favor of GNUmake. 14 | o Only libelf/ and common/ are imported. 15 | o The sole Makefile now is libelf/GNUMakefile, running make there will generate 16 | libelf_pic.a. Other artifacts like shared objects were also removed. 17 | o Documentation, manpages, tools, tests also removed. 18 | 19 | 20 | Changes to please libbpf 21 | ~~~~~~~~~~~~~~~~~~~~~~~~ 22 | o All the following changes are guarded under ifdef QUARK. 23 | o Define empty stubs for a bunch of gelf_* functions. They return NULL/zero, 24 | and since it's not used by quark@libbpf, this is fine. 25 | o Declared missing types in gelf.h. 26 | o Renamed elf_{openmemory, open} to elftoolchain_{openmemory, open}, these 27 | names clash with an exported symbol from libbpf. 28 | o Created a missing elf.h in sys/. 29 | -------------------------------------------------------------------------------- /elftoolchain/commit: -------------------------------------------------------------------------------- 1 | f7e9afc6f9ad0d84ea73b4659c5d6d13275d2306 2 | -------------------------------------------------------------------------------- /elftoolchain/common/elfdefinitions.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2010,2021 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $Id$ 27 | */ 28 | 29 | #ifndef _ELFDEFINITIONS_H_ 30 | #define _ELFDEFINITIONS_H_ 31 | 32 | #include 33 | 34 | #endif /* _ELFDEFINITIONS_H_ */ 35 | -------------------------------------------------------------------------------- /elftoolchain/libelf/_libelf_ar.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2010 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $Id$ 27 | */ 28 | 29 | #ifndef __LIBELF_AR_H_ 30 | #define __LIBELF_AR_H_ 31 | 32 | /* 33 | * Prototypes and declarations needed by libelf's ar(1) archive 34 | * handling code. 35 | */ 36 | 37 | #include 38 | 39 | #define LIBELF_AR_BSD_EXTENDED_NAME_PREFIX "#1/" 40 | #define LIBELF_AR_BSD_SYMTAB_NAME "__.SYMDEF" 41 | #define LIBELF_AR_BSD_EXTENDED_NAME_PREFIX_SIZE \ 42 | (sizeof(LIBELF_AR_BSD_EXTENDED_NAME_PREFIX) - 1) 43 | 44 | #define IS_EXTENDED_BSD_NAME(NAME) \ 45 | (strncmp((const char *) (NAME), \ 46 | LIBELF_AR_BSD_EXTENDED_NAME_PREFIX, \ 47 | LIBELF_AR_BSD_EXTENDED_NAME_PREFIX_SIZE) == 0) 48 | 49 | 50 | unsigned char *_libelf_ar_get_string(const char *_buf, size_t _sz, 51 | unsigned int _rawname, int _svr4names); 52 | char *_libelf_ar_get_raw_name(const struct ar_hdr *_arh); 53 | char *_libelf_ar_get_translated_name(const struct ar_hdr *_arh, Elf *_ar); 54 | int _libelf_ar_get_number(const char *_buf, size_t _sz, 55 | unsigned int _base, size_t *_ret); 56 | 57 | #endif /* __LIBELF_AR_H_ */ 58 | -------------------------------------------------------------------------------- /elftoolchain/libelf/_libelf_config.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008-2011 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $Id$ 27 | */ 28 | 29 | #if defined(__NetBSD__) 30 | 31 | #include 32 | 33 | #if !defined(ARCH_ELFSIZE) 34 | #error ARCH_ELFSIZE is not defined. 35 | #endif 36 | 37 | #if ARCH_ELFSIZE == 32 38 | #define Elf_Note Elf32_Nhdr 39 | #else 40 | #define Elf_Note Elf64_Nhdr 41 | #endif 42 | 43 | #endif 44 | 45 | /* 46 | * Downstream projects can replace the following marker with a custom 47 | * definition of LIBELF_BYTEORDER. 48 | */ 49 | /* @LIBELF-BYTEORDER-MARKER@ */ 50 | 51 | #if !defined(LIBELF_BYTEORDER) 52 | 53 | /* 54 | * Use the __BYTE_ORDER__ and __ORDER_{LITTLE|BIG}_ENDIAN__ macros to 55 | * determine the host's byte order. These macros are predefined by the 56 | * GNU and CLANG C compilers. 57 | */ 58 | #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) 59 | 60 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 61 | #define LIBELF_BYTEORDER ELFDATA2LSB 62 | #else 63 | #define LIBELF_BYTEORDER ELFDATA2MSB 64 | #endif 65 | 66 | #else 67 | 68 | #error unknown host byte order 69 | 70 | #endif /* defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) */ 71 | #endif /* !defined(LIBELF_BYTEORDER) */ 72 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008,2011 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | struct _libelf_globals _libelf = { 40 | .libelf_byteorder = LIBELF_BYTEORDER, 41 | .libelf_error = 0, 42 | .libelf_fillchar = 0, 43 | .libelf_version = EV_NONE 44 | }; 45 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_H_ 2 | #define _ELF_H_ 3 | 4 | /*- 5 | * Copyright (c) 2024 Christiano Haesbaert 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $Id$ 30 | */ 31 | 32 | #ifdef QUARK 33 | #include 34 | #endif /* QUARK */ 35 | 36 | #endif /* _ELF_H */ 37 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_begin.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008-2011 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | Elf * 40 | elf_begin(int fd, Elf_Cmd c, Elf *a) 41 | { 42 | Elf *e; 43 | 44 | e = NULL; 45 | 46 | if (LIBELF_PRIVATE(version) == EV_NONE) { 47 | LIBELF_SET_ERROR(SEQUENCE, 0); 48 | return (NULL); 49 | } 50 | 51 | switch (c) { 52 | case ELF_C_NULL: 53 | return (NULL); 54 | 55 | case ELF_C_WRITE: 56 | /* 57 | * The ELF_C_WRITE command is required to ignore the 58 | * descriptor passed in. 59 | */ 60 | a = NULL; 61 | break; 62 | 63 | case ELF_C_RDWR: 64 | if (a != NULL) { /* not allowed for ar(1) archives. */ 65 | LIBELF_SET_ERROR(ARGUMENT, 0); 66 | return (NULL); 67 | } 68 | /*FALLTHROUGH*/ 69 | case ELF_C_READ: 70 | /* 71 | * Descriptor `a' could be for a regular ELF file, or 72 | * for an ar(1) archive. If descriptor `a' was opened 73 | * using a valid file descriptor, we need to check if 74 | * the passed in `fd' value matches the original one. 75 | */ 76 | if (a && 77 | ((a->e_fd != -1 && a->e_fd != fd) || c != a->e_cmd)) { 78 | LIBELF_SET_ERROR(ARGUMENT, 0); 79 | return (NULL); 80 | } 81 | break; 82 | 83 | default: 84 | LIBELF_SET_ERROR(ARGUMENT, 0); 85 | return (NULL); 86 | 87 | } 88 | 89 | if (a == NULL) 90 | e = _libelf_open_object(fd, c, 1); 91 | else if (a->e_kind == ELF_K_AR) 92 | e = _libelf_ar_open_member(a->e_fd, c, a); 93 | else 94 | (e = a)->e_activations++; 95 | 96 | return (e); 97 | } 98 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_cntl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | int 40 | elf_cntl(Elf *e, Elf_Cmd c) 41 | { 42 | if (e == NULL || 43 | (c != ELF_C_FDDONE && c != ELF_C_FDREAD)) { 44 | LIBELF_SET_ERROR(ARGUMENT, 0); 45 | return (-1); 46 | } 47 | 48 | if (e->e_parent) { 49 | LIBELF_SET_ERROR(ARCHIVE, 0); 50 | return (-1); 51 | } 52 | 53 | if (c == ELF_C_FDREAD) { 54 | if (e->e_cmd == ELF_C_WRITE) { 55 | LIBELF_SET_ERROR(MODE, 0); 56 | return (-1); 57 | } 58 | else 59 | return (0); 60 | } 61 | 62 | e->e_fd = -1; 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_errno.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008,2011 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | int 40 | elf_errno(void) 41 | { 42 | int old; 43 | 44 | old = LIBELF_PRIVATE(error); 45 | LIBELF_PRIVATE(error) = 0; 46 | return (old & LIBELF_ELF_ERROR_MASK); 47 | } 48 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_fill.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | void 40 | elf_fill(int fill) 41 | { 42 | LIBELF_PRIVATE(fillchar) = fill; 43 | } 44 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_getarhdr.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008,2010 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | Elf_Arhdr * 40 | elf_getarhdr(Elf *e) 41 | { 42 | if (e == NULL) { 43 | LIBELF_SET_ERROR(ARGUMENT, 0); 44 | return (NULL); 45 | } 46 | 47 | if (e->e_flags & LIBELF_F_AR_HEADER) 48 | return (e->e_hdr.e_arhdr); 49 | 50 | return (_libelf_ar_gethdr(e)); 51 | } 52 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_getarsym.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | Elf_Arsym * 40 | elf_getarsym(Elf *ar, size_t *ptr) 41 | { 42 | size_t n; 43 | Elf_Arsym *symtab; 44 | 45 | n = 0; 46 | symtab = NULL; 47 | 48 | if (ar == NULL || ar->e_kind != ELF_K_AR) 49 | LIBELF_SET_ERROR(ARGUMENT, 0); 50 | else if ((symtab = ar->e_u.e_ar.e_symtab) != NULL) 51 | n = ar->e_u.e_ar.e_symtabsz; 52 | else if (ar->e_u.e_ar.e_rawsymtab) 53 | symtab = (ar->e_flags & LIBELF_F_AR_VARIANT_SVR4) ? 54 | _libelf_ar_process_svr4_symtab(ar, &n) : 55 | _libelf_ar_process_bsd_symtab(ar, &n); 56 | else 57 | LIBELF_SET_ERROR(ARCHIVE, 0); 58 | 59 | if (ptr) 60 | *ptr = n; 61 | return (symtab); 62 | } 63 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_getbase.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | off_t 40 | elf_getbase(Elf *e) 41 | { 42 | if (e == NULL) { 43 | LIBELF_SET_ERROR(ARGUMENT, 0); 44 | return ((off_t) -1); 45 | } 46 | 47 | if (e->e_parent == NULL) 48 | return ((off_t) 0); 49 | 50 | return ((off_t) ((uintptr_t) e->e_rawfile - 51 | (uintptr_t) e->e_parent->e_rawfile)); 52 | } 53 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_getident.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "_libelf.h" 36 | 37 | ELFTC_VCSID("$Id$"); 38 | 39 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 40 | 41 | char * 42 | elf_getident(Elf *e, size_t *sz) 43 | { 44 | 45 | if (e == NULL) { 46 | LIBELF_SET_ERROR(ARGUMENT, 0); 47 | goto error; 48 | } 49 | 50 | if (e->e_cmd == ELF_C_WRITE && e->e_rawfile == NULL) { 51 | LIBELF_SET_ERROR(SEQUENCE, 0); 52 | goto error; 53 | } 54 | 55 | assert(e->e_kind != ELF_K_AR || e->e_cmd == ELF_C_READ); 56 | 57 | if (sz) { 58 | if (e->e_kind == ELF_K_AR) 59 | *sz = SARMAG; 60 | else if (e->e_kind == ELF_K_ELF) 61 | *sz = EI_NIDENT; 62 | else 63 | *sz = (size_t) e->e_rawsize; 64 | } 65 | 66 | return ((char *) e->e_rawfile); 67 | 68 | error: 69 | if (sz) 70 | *sz = 0; 71 | return (NULL); 72 | } 73 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_getversion.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2021 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 18 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 19 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 24 | * THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | unsigned int 40 | elf_getversion(Elf *e) 41 | { 42 | if (e == NULL || e->e_kind != ELF_K_ELF) { 43 | LIBELF_SET_ERROR(ARGUMENT, 0); 44 | return (EV_NONE); 45 | } 46 | 47 | return (e->e_version); 48 | } 49 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_hash.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | /* 40 | * This elf_hash function is defined by the System V ABI. 41 | */ 42 | 43 | unsigned long 44 | elf_hash(const char *name) 45 | { 46 | unsigned long h, t; 47 | const unsigned char *s; 48 | 49 | s = (const unsigned char *) name; 50 | h = t = 0; 51 | 52 | for (; *s != '\0'; h = h & ~t) { 53 | h = (h << 4) + *s++; 54 | t = h & 0xF0000000UL; 55 | if (t) 56 | h ^= t >> 24; 57 | } 58 | 59 | return (h); 60 | } 61 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_kind.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | Elf_Kind 40 | elf_kind(Elf *e) 41 | { 42 | if (e == NULL) 43 | return (ELF_K_NONE); 44 | if (e->e_kind == ELF_K_AR || 45 | e->e_kind == ELF_K_ELF) 46 | return (e->e_kind); 47 | return (ELF_K_NONE); 48 | } 49 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_memory.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | Elf * 40 | elf_memory(char *image, size_t sz) 41 | { 42 | if (LIBELF_PRIVATE(version) == EV_NONE) { 43 | LIBELF_SET_ERROR(SEQUENCE, 0); 44 | return (NULL); 45 | } 46 | 47 | if (image == NULL || sz == 0) { 48 | LIBELF_SET_ERROR(ARGUMENT, 0); 49 | return (NULL); 50 | } 51 | 52 | return (_libelf_memory((unsigned char *) image, sz, 1)); 53 | } 54 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_next.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "_libelf.h" 36 | 37 | ELFTC_VCSID("$Id$"); 38 | 39 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 40 | 41 | Elf_Cmd 42 | elf_next(Elf *e) 43 | { 44 | off_t next; 45 | Elf *parent; 46 | 47 | if (e == NULL) 48 | return (ELF_C_NULL); 49 | 50 | if ((parent = e->e_parent) == NULL) { 51 | LIBELF_SET_ERROR(ARGUMENT, 0); 52 | return (ELF_C_NULL); 53 | } 54 | 55 | assert(parent->e_kind == ELF_K_AR); 56 | assert(parent->e_cmd == ELF_C_READ); 57 | assert(e->e_rawfile > parent->e_rawfile); 58 | 59 | next = e->e_rawfile - parent->e_rawfile + (off_t) e->e_rawsize; 60 | next = (next + 1) & ~1; /* round up to an even boundary */ 61 | 62 | /* 63 | * Setup the 'e_next' field of the archive descriptor for the 64 | * next call to 'elf_begin()'. 65 | */ 66 | parent->e_u.e_ar.e_next = (next >= (off_t) parent->e_rawsize) ? 67 | (off_t) 0 : next; 68 | 69 | /* 70 | * Return an error if the 'e_next' field falls outside the current 71 | * file. 72 | * 73 | * This check is performed after updating the parent descriptor's 74 | * 'e_next' field so that the next call to elf_begin(3) will terminate 75 | * traversal of a too-small archive even if client code forgets to 76 | * check the return value from elf_next(3). 77 | */ 78 | if (next > (off_t) parent->e_rawsize) { 79 | LIBELF_SET_ERROR(ARGUMENT, 0); 80 | return (ELF_C_NULL); 81 | } 82 | 83 | return (ELF_C_READ); 84 | } 85 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_open.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2011 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | #ifdef QUARK 40 | /* 41 | * Extension API: open a file for reading, ignoring parse errors. 42 | */ 43 | 44 | Elf * 45 | elftoolchain_elf_open(int fd) 46 | { 47 | if (LIBELF_PRIVATE(version) == EV_NONE) { 48 | LIBELF_SET_ERROR(SEQUENCE, 0); 49 | return (NULL); 50 | } 51 | 52 | return (_libelf_open_object(fd, ELF_C_READ, 0)); 53 | } 54 | 55 | /* 56 | * Extension API: create an ELF descriptor for an in-memory object, 57 | * ignoring parse errors. 58 | */ 59 | 60 | Elf * 61 | elftoolchain_elf_openmemory(char *image, size_t sz) 62 | { 63 | if (LIBELF_PRIVATE(version) == EV_NONE) { 64 | LIBELF_SET_ERROR(SEQUENCE, 0); 65 | return (NULL); 66 | } 67 | 68 | if (image == NULL || sz == 0) { 69 | LIBELF_SET_ERROR(ARGUMENT, 0); 70 | return (NULL); 71 | } 72 | 73 | return (_libelf_memory((unsigned char *) image, sz, 0)); 74 | } 75 | 76 | #endif /* QUARK */ 77 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_phnum.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "_libelf.h" 35 | 36 | ELFTC_VCSID("$Id$"); 37 | 38 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 39 | 40 | static int 41 | _libelf_getphdrnum(Elf *e, size_t *phnum) 42 | { 43 | void *eh; 44 | int ec; 45 | 46 | if (e == NULL || e->e_kind != ELF_K_ELF || 47 | ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) { 48 | LIBELF_SET_ERROR(ARGUMENT, 0); 49 | return (-1); 50 | } 51 | 52 | if ((eh = _libelf_ehdr(e, ec, 0)) == NULL) 53 | return (-1); 54 | 55 | *phnum = e->e_u.e_elf.e_nphdr; 56 | 57 | return (0); 58 | } 59 | 60 | int 61 | elf_getphdrnum(Elf *e, size_t *phnum) 62 | { 63 | return (_libelf_getphdrnum(e, phnum)); 64 | } 65 | 66 | /* Deprecated API */ 67 | int 68 | elf_getphnum(Elf *e, size_t *phnum) 69 | { 70 | return (_libelf_getphdrnum(e, phnum) >= 0); 71 | } 72 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_rand.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "_libelf.h" 35 | 36 | ELFTC_VCSID("$Id$"); 37 | 38 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 39 | 40 | off_t 41 | elf_rand(Elf *ar, off_t offset) 42 | { 43 | struct ar_hdr *arh; 44 | off_t offset_of_member; 45 | 46 | if (ar == NULL || ar->e_kind != ELF_K_AR || 47 | (offset & 1) || offset < SARMAG || 48 | offset >= ar->e_rawsize) { 49 | LIBELF_SET_ERROR(ARGUMENT, 0); 50 | return 0; 51 | } 52 | 53 | offset_of_member = offset + (off_t) sizeof(struct ar_hdr); 54 | 55 | if (offset_of_member <= 0 || /* Numeric overflow. */ 56 | offset_of_member >= ar->e_rawsize) { 57 | LIBELF_SET_ERROR(ARGUMENT, 0); 58 | return 0; 59 | } 60 | 61 | arh = (struct ar_hdr *) (ar->e_rawfile + offset); 62 | 63 | /* a too simple sanity check */ 64 | if (arh->ar_fmag[0] != '`' || arh->ar_fmag[1] != '\n') { 65 | LIBELF_SET_ERROR(ARCHIVE, 0); 66 | return 0; 67 | } 68 | 69 | ar->e_u.e_ar.e_next = offset; 70 | 71 | return (offset); 72 | } 73 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_rawfile.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | char * 40 | elf_rawfile(Elf *e, size_t *sz) 41 | { 42 | unsigned char *ptr; 43 | 44 | ptr = NULL; 45 | 46 | if (e == NULL) 47 | LIBELF_SET_ERROR(ARGUMENT, 0); 48 | else if ((ptr = e->e_rawfile) == NULL && e->e_cmd == ELF_C_WRITE) 49 | LIBELF_SET_ERROR(SEQUENCE, 0); 50 | 51 | if (sz) 52 | *sz = e ? (size_t) e->e_rawsize : 0; 53 | 54 | return ((char *) ptr); 55 | } 56 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_shnum.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "_libelf.h" 35 | 36 | ELFTC_VCSID("$Id$"); 37 | 38 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 39 | 40 | static int 41 | _libelf_getshdrnum(Elf *e, size_t *shnum) 42 | { 43 | void *eh; 44 | int ec; 45 | 46 | if (e == NULL || e->e_kind != ELF_K_ELF || 47 | ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) { 48 | LIBELF_SET_ERROR(ARGUMENT, 0); 49 | return (-1); 50 | } 51 | 52 | if ((eh = _libelf_ehdr(e, ec, 0)) == NULL) 53 | return (-1); 54 | 55 | *shnum = e->e_u.e_elf.e_nscn; 56 | 57 | return (0); 58 | } 59 | 60 | int 61 | elf_getshdrnum(Elf *e, size_t *shnum) 62 | { 63 | return (_libelf_getshdrnum(e, shnum)); 64 | } 65 | 66 | /* Deprecated API. */ 67 | int 68 | elf_getshnum(Elf *e, size_t *shnum) 69 | { 70 | return (_libelf_getshdrnum(e, shnum) >= 0); 71 | } 72 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_shstrndx.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "_libelf.h" 35 | 36 | ELFTC_VCSID("$Id$"); 37 | 38 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 39 | 40 | static int 41 | _libelf_getshdrstrndx(Elf *e, size_t *strndx) 42 | { 43 | void *eh; 44 | int ec; 45 | 46 | if (e == NULL || e->e_kind != ELF_K_ELF || 47 | ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) { 48 | LIBELF_SET_ERROR(ARGUMENT, 0); 49 | return (-1); 50 | } 51 | 52 | if ((eh = _libelf_ehdr(e, ec, 0)) == NULL) 53 | return (-1); 54 | 55 | *strndx = e->e_u.e_elf.e_strndx; 56 | 57 | return (0); 58 | } 59 | 60 | int 61 | elf_getshdrstrndx(Elf *e, size_t *strndx) 62 | { 63 | return (_libelf_getshdrstrndx(e, strndx)); 64 | } 65 | 66 | int 67 | elf_getshstrndx(Elf *e, size_t *strndx) /* Deprecated API. */ 68 | { 69 | return (_libelf_getshdrstrndx(e, strndx) >= 0); 70 | } 71 | 72 | int 73 | elf_setshstrndx(Elf *e, size_t strndx) 74 | { 75 | void *eh; 76 | int ec; 77 | 78 | if (e == NULL || e->e_kind != ELF_K_ELF || 79 | ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64) || 80 | ((eh = _libelf_ehdr(e, ec, 0)) == NULL)) { 81 | LIBELF_SET_ERROR(ARGUMENT, 0); 82 | return (0); 83 | } 84 | 85 | return (_libelf_setshstrndx(e, eh, ec, strndx)); 86 | } 87 | -------------------------------------------------------------------------------- /elftoolchain/libelf/elf_version.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | unsigned int 40 | elf_version(unsigned int v) 41 | { 42 | unsigned int old; 43 | 44 | if ((old = LIBELF_PRIVATE(version)) == EV_NONE) 45 | old = EV_CURRENT; 46 | 47 | if (v == EV_NONE) 48 | return old; 49 | if (v > EV_CURRENT) { 50 | LIBELF_SET_ERROR(VERSION, 0); 51 | return EV_NONE; 52 | } 53 | 54 | LIBELF_PRIVATE(version) = v; 55 | return (old); 56 | } 57 | -------------------------------------------------------------------------------- /elftoolchain/libelf/gelf_checksum.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "_libelf.h" 35 | 36 | ELFTC_VCSID("$Id$"); 37 | 38 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 39 | 40 | long 41 | elf32_checksum(Elf *e) 42 | { 43 | return (_libelf_checksum(e, ELFCLASS32)); 44 | } 45 | 46 | long 47 | elf64_checksum(Elf *e) 48 | { 49 | return (_libelf_checksum(e, ELFCLASS64)); 50 | } 51 | 52 | long 53 | gelf_checksum(Elf *e) 54 | { 55 | int ec; 56 | if (e == NULL || 57 | ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) { 58 | LIBELF_SET_ERROR(ARGUMENT, 0); 59 | return (0L); 60 | } 61 | return (_libelf_checksum(e, ec)); 62 | } 63 | -------------------------------------------------------------------------------- /elftoolchain/libelf/gelf_fsize.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "_libelf.h" 35 | 36 | ELFTC_VCSID("$Id$"); 37 | 38 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 39 | 40 | size_t 41 | elf32_fsize(Elf_Type t, size_t c, unsigned int v) 42 | { 43 | return (_libelf_fsize(t, ELFCLASS32, v, c)); 44 | } 45 | 46 | size_t 47 | elf64_fsize(Elf_Type t, size_t c, unsigned int v) 48 | { 49 | return (_libelf_fsize(t, ELFCLASS64, v, c)); 50 | } 51 | 52 | size_t 53 | gelf_fsize(Elf *e, Elf_Type t, size_t c, unsigned int v) 54 | { 55 | 56 | if (e == NULL) { 57 | LIBELF_SET_ERROR(ARGUMENT, 0); 58 | return (0); 59 | } 60 | 61 | if (e->e_class == ELFCLASS32 || e->e_class == ELFCLASS64) 62 | return (_libelf_fsize(t, e->e_class, v, c)); 63 | 64 | LIBELF_SET_ERROR(ARGUMENT, 0); 65 | return (0); 66 | } 67 | -------------------------------------------------------------------------------- /elftoolchain/libelf/gelf_getclass.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | 33 | #include "_libelf.h" 34 | 35 | ELFTC_VCSID("$Id$"); 36 | 37 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 38 | 39 | int 40 | gelf_getclass(Elf *e) 41 | { 42 | return (e != NULL ? e->e_class : ELFCLASSNONE); 43 | } 44 | -------------------------------------------------------------------------------- /elftoolchain/libelf/libelf_elfmachine.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2018 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "_libelf.h" 35 | 36 | ELFTC_VCSID("$Id$"); 37 | 38 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 39 | 40 | /* 41 | * A convenience helper that returns the ELF machine architecture for 42 | * a ELF descriptor. 43 | */ 44 | int 45 | _libelf_elfmachine(Elf *e) 46 | { 47 | Elf32_Ehdr *eh32; 48 | Elf64_Ehdr *eh64; 49 | 50 | if (!e) 51 | return EM_NONE; 52 | 53 | assert(e->e_kind == ELF_K_ELF); 54 | assert(e->e_class != ELFCLASSNONE); 55 | 56 | eh32 = NULL; 57 | eh64 = NULL; 58 | 59 | switch (e->e_class) { 60 | case ELFCLASS32: 61 | eh32 = e->e_u.e_elf.e_ehdr.e_ehdr32; 62 | return eh32 ? eh32->e_machine : EM_NONE; 63 | case ELFCLASS64: 64 | eh64 = e->e_u.e_elf.e_ehdr.e_ehdr64; 65 | return eh64 ? eh64->e_machine : EM_NONE; 66 | } 67 | 68 | return (EM_NONE); 69 | } 70 | -------------------------------------------------------------------------------- /elftoolchain/libelf/libelf_shdr.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006,2008 Joseph Koshy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef QUARK 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "_libelf.h" 35 | 36 | ELFTC_VCSID("$Id$"); 37 | 38 | /*@ELFTC-DOWNSTREAM-VCSID@*/ 39 | 40 | void * 41 | _libelf_getshdr(Elf_Scn *s, int ec) 42 | { 43 | Elf *e; 44 | 45 | if (s == NULL || (e = s->s_elf) == NULL || 46 | e->e_kind != ELF_K_ELF) { 47 | LIBELF_SET_ERROR(ARGUMENT, 0); 48 | return (NULL); 49 | } 50 | 51 | if (ec == ELFCLASSNONE) 52 | ec = e->e_class; 53 | 54 | if (ec != e->e_class) { 55 | LIBELF_SET_ERROR(CLASS, 0); 56 | return (NULL); 57 | } 58 | 59 | return ((void *) &s->s_shdr); 60 | } 61 | -------------------------------------------------------------------------------- /krun-fedora.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | SCRIPT=${0##*/} 6 | 7 | function usage 8 | { 9 | echo "usage: $SCRIPT initramfs.gz FEDORAVERSION command" 1>&2 10 | exit 1 11 | } 12 | 13 | if [ $# -lt 3 ]; then 14 | usage 15 | fi 16 | 17 | INITRAMFS="$1" 18 | FEDORAVER="$2" 19 | shift 2 20 | 21 | case $FEDORAVER in 22 | 2?|3?) URL="https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/$FEDORAVER/Everything/x86_64/Packages/k";; 23 | 43|rawhide) URL="https://ftp.fau.de/fedora/linux/development/$FEDORAVER/Everything/x86_64/os/Packages/k";; 24 | 4?) URL="https://ftp.fau.de/fedora/linux/updates/$FEDORAVER/Everything/x86_64/Packages/k";; 25 | *) echo bad version "$FEDORAVER" 1>&2;; 26 | esac 27 | 28 | TMPDIR=$(mktemp -d "/tmp/$SCRIPT.XXXXXXXXXX") 29 | trap 'rm -rf "$TMPDIR"' EXIT 30 | 31 | RPMURL=$(lynx -dump -listonly "$URL"|grep kernel-core) 32 | RPMURL=${RPMURL##* } 33 | RPM=$(basename "$RPMURL") 34 | VMLINUZ=${RPM##kernel-core-} 35 | VMLINUZ=${VMLINUZ%%.rpm} 36 | VMLINUZ=$TMPDIR/lib/modules/$VMLINUZ/vmlinuz 37 | 38 | # echo URL $URL 39 | # echo RPMURL $RPMURL 40 | # echo RPM $RPM 41 | # echo VMLINUZ $VMLINUZ 42 | 43 | cd "$TMPDIR" 44 | curl -s "$RPMURL" | rpm2cpio - | cpio -idm 45 | cd - 46 | 47 | ./krun.sh "$INITRAMFS" "$VMLINUZ" "$@" 48 | -------------------------------------------------------------------------------- /krun-rhel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | SCRIPT=${0##*/} 6 | 7 | function usage 8 | { 9 | echo "usage: $SCRIPT initramfs.gz RHELVER command" 1>&2 10 | exit 1 11 | } 12 | 13 | if [ $# -lt 3 ]; then 14 | usage 15 | fi 16 | 17 | INITRAMFS="$1" 18 | RHELVER="$2" 19 | shift 2 20 | 21 | case $RHELVER in 22 | 8|9) URL="https://ftp.fau.de/rockylinux/$RHELVER/BaseOS/x86_64/os/Packages/k";; 23 | 8.[34]) URL="https://dl.rockylinux.org/vault/rocky/$RHELVER/BaseOS/x86_64/os/Packages";; 24 | 8.?|9.?) URL="https://dl.rockylinux.org/vault/rocky/$RHELVER/BaseOS/x86_64/os/Packages/k";; 25 | *) echo bad version "$RHELVER" 1>&2;; 26 | esac 27 | 28 | TMPDIR=$(mktemp -d "/tmp/$SCRIPT.XXXXXXXXXX") 29 | trap 'rm -rf "$TMPDIR"' EXIT 30 | 31 | RPMURL=$(lynx -dump -listonly "$URL"|grep kernel-core) 32 | RPMURL=${RPMURL##* } 33 | RPM=$(basename "$RPMURL") 34 | VMLINUZ=${RPM##kernel-core-} 35 | VMLINUZ=${VMLINUZ%%.rpm} 36 | VMLINUZ=$TMPDIR/lib/modules/$VMLINUZ/vmlinuz 37 | 38 | # echo URL $URL 39 | # echo RPMURL $RPMURL 40 | # echo RPM $RPM 41 | # echo VMLINUZ $VMLINUZ 42 | 43 | cd "$TMPDIR" 44 | curl -s "$RPMURL" | rpm2cpio - | cpio -idm 45 | cd - 46 | 47 | ./krun.sh "$INITRAMFS" "$VMLINUZ" "$@" 48 | -------------------------------------------------------------------------------- /krun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Script=${0##*/} 4 | 5 | function usage 6 | { 7 | echo "usage: $Script initramfs_path kernel_path cmd_line" 1>&2 8 | exit 1 9 | } 10 | 11 | if [ $# -lt 3 ]; then 12 | usage 13 | fi 14 | 15 | initramfs="$1" 16 | kernel="$2" 17 | shift 2 18 | bin="$1" 19 | cmdline="$*" 20 | 21 | function qemu { 22 | case "$(file -b "$kernel" | awk '{print $3}')" in 23 | x86) 24 | kvm="" 25 | if grep -qw vmx /proc/cpuinfo && [ -e /dev/kvm ]; then 26 | kvm="-enable-kvm" 27 | fi 28 | qemu-system-x86_64 \ 29 | -m 256M \ 30 | -initrd "$initramfs" \ 31 | -kernel "$kernel" \ 32 | -nographic \ 33 | --append "console=ttyS0 quiet TERM=dumb $cmdline" \ 34 | $kvm 35 | ;; 36 | ARM64) 37 | qemu-system-aarch64 \ 38 | -m 256M \ 39 | -machine virt \ 40 | -cpu cortex-a57 \ 41 | -initrd "$initramfs" \ 42 | -kernel "$kernel" \ 43 | -nographic \ 44 | --append "console=ttyAMA0 quiet TERM=dumb $cmdline" 45 | ;; 46 | *) 47 | echo unknown kernel image arch 1>&2; exit 1;; 48 | esac 49 | } 50 | 51 | exitcode=1 52 | while read -r line 53 | do 54 | line="$(tr -d '\r' <<< "$line")" 55 | echo "$line" 56 | if grep -q "^$bin exited with " <<< "$line"; then 57 | exitcode="$(awk '{print $4}' <<< "$line")" 58 | fi 59 | done < <(qemu) 60 | 61 | echo exited with "$exitcode" 62 | 63 | exit $((exitcode)) 64 | -------------------------------------------------------------------------------- /ktest-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | kprobe_only=(linux-3.10.0-123.el7.x86_64) 6 | result="" 7 | error_run="" 8 | declare -i failures=0 9 | all_kernels="$(find kernel-images/{amd64,arm64} -type f)" 10 | 11 | function maybe_kflag 12 | { 13 | for k in "${kprobe_only[@]}"; do 14 | if [ "$1" = "$k" ]; then 15 | return 0 16 | fi 17 | done 18 | 19 | return 1 20 | } 21 | 22 | for k in $all_kernels 23 | do 24 | kname="$(basename "$k")" 25 | cmdline="./krun.sh initramfs.gz $k quark-test" 26 | if maybe_kflag "$kname"; then 27 | cmdline+=" -k" 28 | fi 29 | if eval "$cmdline"; then 30 | r="$(printf "%s: ok" "$kname")" 31 | else 32 | r="$(printf "%s: fail" "$kname")" 33 | error_run+="${cmdline}"$'\n' 34 | failures=$((failures+1)) 35 | fi 36 | result+="${r}"$'\n' 37 | done 38 | 39 | echo -n "$result" 40 | echo failures $failures 41 | if test -n "$error_run"; then 42 | echo to reproduce failed cases, run: 43 | echo -n "$error_run" 44 | fi 45 | 46 | exit $failures 47 | -------------------------------------------------------------------------------- /licenses/BSD-2-CLAUSE-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Valid-License-Identifier: BSD-2-Clause 2 | SPDX-URL: https://spdx.org/licenses/BSD-2-Clause.html 3 | Usage-Guide: 4 | To use the BSD 2-clause "Simplified" License put the following SPDX 5 | tag/value pair into a comment according to the placement guidelines in 6 | the licensing rules documentation: 7 | SPDX-License-Identifier: BSD-2-Clause 8 | License-Text: 9 | 10 | Copyright (c) . All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | 1. Redistributions of source code must retain the above copyright notice, 16 | this list of conditions and the following disclaimer. 17 | 18 | 2. Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /licenses/BSD-3-CLAUSE-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) . 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this 6 | list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the above copyright notice, 8 | this list of conditions and the following disclaimer in the documentation and/or 9 | other materials provided with the distribution. 10 | 3. Neither the name of the copyright holder nor the names of its contributors 11 | may be used to endorse or promote products derived from this software without 12 | specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /licenses/ISC-LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Permission to use, copy, modify, and /or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above copyright 5 | notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 11 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 12 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 13 | THIS SOFTWARE. 14 | 15 | -------------------------------------------------------------------------------- /licenses/ZLIB-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /man-embedder.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | /* Copyright (c) 2024 Elastic NV */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | static void 13 | usage(void) 14 | { 15 | fprintf(stderr, "usage: %s input_file ifdef_name\n", 16 | program_invocation_short_name); 17 | 18 | exit(1); 19 | } 20 | 21 | static int 22 | embed(const char *input_path, const char *ifdef_name) 23 | { 24 | FILE *input; 25 | int ch, line_wrap; 26 | 27 | if ((input = fopen(input_path, "r")) == NULL) 28 | err(1, "fopen"); 29 | 30 | if (ifdef_name != NULL) 31 | printf("#ifdef %s\n", ifdef_name); 32 | printf("const char manpage_bin[] = {\n"); 33 | 34 | line_wrap = 0; 35 | while ((ch = fgetc(input)) != EOF) { 36 | if (line_wrap == 0) 37 | putchar('\t'); 38 | printf("0x%02x, ", ch); 39 | if (++line_wrap == 10) { 40 | putchar('\n'); 41 | line_wrap = 0; 42 | } 43 | } 44 | if (ferror(input)) 45 | errx(1, "input error"); 46 | fclose(input); 47 | 48 | printf("\n};\n"); 49 | if (ifdef_name != NULL) 50 | printf("#endif /* %s */", ifdef_name); 51 | putchar('\n'); 52 | 53 | return (0); 54 | } 55 | 56 | int 57 | main(int argc, char *argv[]) 58 | { 59 | if (argc != 3) 60 | usage(); 61 | 62 | return (embed(argv[1], argv[2])); 63 | } 64 | -------------------------------------------------------------------------------- /quark-test.8: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK-TEST 8 3 | .Os 4 | .Sh NAME 5 | .Nm quark-test 6 | .Nd quark's test utility 7 | .Sh SYNOPSIS 8 | .Nm quark-test 9 | .Op Fl 1bkv 10 | .Op Fl x Ar test 11 | .Op Ar tests ... 12 | .Nm quark-test 13 | .Fl h 14 | .Nm quark-test Fl l 15 | .Nm quark-test Fl N 16 | .Nm quark-test Fl V 17 | .Sh DESCRIPTION 18 | The 19 | .Nm 20 | program runs tests for 21 | .Xr quark 7 . 22 | It is designed as one big fat binary so that you can easily run it with quark's 23 | custom 24 | .Pa initramfs.gz . 25 | Without any arguments, 26 | .Nm 27 | will run all tests in both KPROBE and EBPF as backend. 28 | .Pp 29 | Each test runs a separate sub-process in order to avoid address space 30 | contaminaton between two tests. 31 | The number of failed tests is the return value of 32 | .Nm . 33 | .Pp 34 | The options are as follows: 35 | .Bl -tag -width Dtb 36 | .It Fl 1 37 | Don't run tests in a child process, useful for debugging with gdb, strace and 38 | whatnot. 39 | .It Fl b 40 | Run only EBPF tests. 41 | .It Fl h 42 | Display this manpage. 43 | .It Fl k 44 | Run only KPROBE tests. 45 | .It Fl l 46 | Prints all available tests on stdout. 47 | .It Fl N 48 | This is a nop flag, literally, 49 | .Nm 50 | will just exit with 0. Some tests must fork and exec things in order to collect 51 | events, this keeps the binary self contained by forking and execing itself as we 52 | don't have access to system utilities in 53 | .Pa initramfs.gz . 54 | .It Fl v 55 | Increase 56 | .Em quark_verbose , 57 | can be issued multiple times. 58 | .It Fl V 59 | Print version and exit. 60 | .It Fl x Ar test 61 | Exclude 62 | .Ar test 63 | from the run, can be specified multiple times. 64 | .El 65 | .Sh EXIT STATUS 66 | .Nm 67 | exits with the number of failed tests, or non-zero if 68 | .Nm 69 | itself fails. 70 | .Sh EXAMPLES 71 | .Bd -literal 72 | $ quark-test -k 73 | 74 | t_probe @ kprobe: ok 75 | t_fork_exec_exit @ kprobe: ok 76 | failed tests 0 77 | 78 | $ quark-test t_fork_exec_exit 79 | 80 | t_fork_exec_exit @ ebpf: ok 81 | t_fork_exec_exit @ kprobe: ok 82 | failed tests 0 83 | .Ed 84 | .Sh SEE ALSO 85 | .Xr quark_event_dump 3 , 86 | .Xr quark_process_lookup 3 , 87 | .Xr quark_queue_block 3 , 88 | .Xr quark_queue_close 3 , 89 | .Xr quark_queue_get_epollfd 3 , 90 | .Xr quark_queue_get_event 3 , 91 | .Xr quark_queue_get_stats 3 , 92 | .Xr quark_queue_open 3 , 93 | .Xr quark-btf 8 , 94 | .Xr quark-mon 8 95 | -------------------------------------------------------------------------------- /quark_event_dump.3: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK_EVENT_DUMP 3 3 | .Os 4 | .Sh NAME 5 | .Nm quark_event_dump 6 | .Nd dump a 7 | .Vt quark_event 8 | to a 9 | .Vt FILE 10 | .Sh SYNOPSIS 11 | .In quark.h 12 | .Ft int 13 | .Fn quark_event_dump "struct quark_event *qev" "FILE *file" 14 | .Sh DESCRIPTION 15 | .Nm 16 | dumps a human readable format of the event pointed to by 17 | .Fa qev 18 | to the file specified in 19 | .Fa file . 20 | .Sh OUTPUT EXAMPLE 21 | .Bd -literal 22 | ->818621 (FORK+EXEC+EXIT) 23 | COMM comm=git 24 | CMDL cmdline=[ /usr/bin/git, --no-pager, ls-tree, --name-only, -z, HEAD, --, quark_event_dump.3 ] 25 | PROC ppid=5082 26 | PROC uid=1000 gid=1000 suid=1000 sgid=1000 euid=1000 egid=1000 27 | PROC cap_inheritable=0x0 cap_permitted=0x0 cap_effective=0x0 28 | PROC cap_bset=0x1ffffffffff cap_ambient=0x0 29 | PROC time_boot=1712219191035753014 30 | CWD cwd=/home/haesbaert 31 | FILE filename=/usr/bin/git 32 | EXIT exit_code=0 exit_time=72031260061483 33 | .Ed 34 | .Sh FORMAT 35 | The number 36 | .Sy 818621 37 | after the 38 | .Sy -> 39 | is the pid of the originating process. 40 | The string 41 | .Sy (FORK+EXEC+EXIT) 42 | describes what is aggregated in 43 | .Sy this 44 | specific event. 45 | The following fields contain all the data we know about pid 46 | .Sy 818621 , 47 | which originates both from this event, and whatever has been learned before and 48 | is cached. 49 | .Pp 50 | The first column of the subsequent lines is a description of the 51 | .Vt flag 52 | from where the fields in the second column originates from. 53 | For example 54 | .Sy PROC 55 | is 56 | .Dv QUARK_F_PROC 57 | and produces the fields 58 | .Sy ppid , 59 | .Sy uid , 60 | .Sy gid , 61 | .Sy suid ... 62 | .Sh RETURN VALUES 63 | Zero on success, -1 in error from 64 | .Xr fwrite 3 . 65 | .Sh SEE ALSO 66 | .Xr quark_process_lookup 3 , 67 | .Xr quark_queue_block 3 , 68 | .Xr quark_queue_close 3 , 69 | .Xr quark_queue_default_attr 3 , 70 | .Xr quark_queue_get_epollfd 3 , 71 | .Xr quark_queue_get_event 3 , 72 | .Xr quark_queue_get_stats 3 , 73 | .Xr quark_queue_open 3 , 74 | .Xr quark 7 , 75 | .Xr quark-btf 8 , 76 | .Xr quark-mon 8 77 | -------------------------------------------------------------------------------- /quark_process_iter.3: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK_PROCESS_ITER 3 3 | .Os 4 | .Sh NAME 5 | .Nm quark_process_iter_init , 6 | .Nm quark_process_iter_next 7 | .Nd string process iteration operations 8 | .Sh SYNOPSIS 9 | .In quark.h 10 | .Ft void 11 | .Fn quark_process_iter_init "struct quark_process_iter *" "struct quark_queue *qq" 12 | .Ft const quark_process * 13 | .Fn quark_process_iter_next "struct quark_process_iter *" 14 | .Sh DESCRIPTION 15 | Initialize and iterate over the internal cache of processes, it can be used on 16 | boot up to get a list of all learned processes, or else. 17 | .Sh EXAMPLES 18 | .Bd -literal 19 | 20 | struct quark_process_iter qi; 21 | struct quark_process *qp; 22 | 23 | quark_process_iter_init(&qi, qq); 24 | while ((qp = quark_process_next(&qi)) != NULL) 25 | printf("process %d\n", qp->pid); 26 | .Ed 27 | .Sh RETURNS 28 | The returned process points to internal memory and must not be modified, the 29 | pointer is invalidated on any subsequent call of 30 | .Xr quark_queue_get_event 3 . 31 | .Sh SEE ALSO 32 | .Xr quark_process_lookup 3 , 33 | .Xr quark_queue_block 3 , 34 | .Xr quark_queue_close 3 , 35 | .Xr quark_queue_default_attr 3 , 36 | .Xr quark_queue_get_epollfd 3 , 37 | .Xr quark_queue_get_event 3 , 38 | .Xr quark_queue_get_stats 3 , 39 | .Xr quark_queue_open 3 , 40 | .Xr quark 7 , 41 | .Xr quark-btf 8 , 42 | .Xr quark-mon 8 43 | -------------------------------------------------------------------------------- /quark_process_lookup.3: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK_PROCESS_LOOKUP 3 3 | .Os 4 | .Sh NAME 5 | .Nm quark_process_lookup 6 | .Nd lookup a 7 | .Vt quark_process 8 | in quark's cache 9 | .Sh SYNOPSIS 10 | .In quark.h 11 | .Ft const struct quark_process * 12 | .Fn quark_process_lookup "struct quark_queue *qq" "int pid" 13 | .Sh DESCRIPTION 14 | .Nm 15 | looks for the cached process referenced by 16 | .Fa pid . 17 | .Pp 18 | Quark's internal cache keeps processes that exited for a grace time, meaning 19 | you can still lookup them for a little while before they're garbage 20 | collected. 21 | At the time of this writing, this is hardcoded to 4 seconds. 22 | .Sh RETURN VALUES 23 | Returns a pointer to the internal process if found. 24 | The pointer points to the internal process used by quark, therefore, its 25 | contents must 26 | .Em NOT 27 | be modified, or accessed while 28 | .Xr quark_queue_get_event 3 29 | is taking place, as this might free the pointed memory. 30 | .Sh SEE ALSO 31 | .Xr quark_event_dump 3 , 32 | .Xr quark_queue_block 3 , 33 | .Xr quark_queue_close 3 , 34 | .Xr quark_queue_default_attr 3 , 35 | .Xr quark_queue_get_epollfd 3 , 36 | .Xr quark_queue_get_event 3 , 37 | .Xr quark_queue_get_stats 3 , 38 | .Xr quark_queue_open 3 , 39 | .Xr quark-btf 8 , 40 | .Xr quark-mon 8 , 41 | .Xr quark-test 8 42 | -------------------------------------------------------------------------------- /quark_queue_block.3: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK_QUEUE_BLOCK 3 3 | .Os 4 | .Sh NAME 5 | .Nm quark_queue_block 6 | .Nd block waiting for quark events 7 | .Sh SYNOPSIS 8 | .In quark.h 9 | .Ft int 10 | .Fn quark_queue_block "struct quark_queue *qq" 11 | .Sh DESCRIPTION 12 | .Nm 13 | blocks the calling process until there would be events to be read with 14 | .Xr quark_queue_get_event 3 . 15 | .Pp 16 | Internally this will call 17 | .Xr epoll_wait 2 18 | on the descriptor returned by 19 | .Xr quark_queue_get_epollfd 3 , 20 | the call is also arranged with a reasonable timeout, this is needed because 21 | perf-ring file descriptors only become readable once a certain amount of data 22 | surpasses a threshold. 23 | On the return from 24 | .Nm , 25 | the caller should call 26 | .Xr quark_queue_get_event 3 27 | until it returns zero, signifying there are no more events to be read. 28 | See 29 | .Xr quark 7 30 | for an example. 31 | .Sh RETURN VALUES 32 | Zero on success, -1 otherwise and 33 | .Va errno 34 | is set. 35 | .Sh SEE ALSO 36 | .Xr quark_event_dump 3 , 37 | .Xr quark_process_lookup 3 , 38 | .Xr quark_queue_close 3 , 39 | .Xr quark_queue_default_attr 3 , 40 | .Xr quark_queue_get_epollfd 3 , 41 | .Xr quark_queue_get_event 3 , 42 | .Xr quark_queue_get_stats 3 , 43 | .Xr quark_queue_open 3 , 44 | .Xr quark 7 , 45 | .Xr quark-btf 8 , 46 | .Xr quark-mon 8 , 47 | .Xr quark-test 8 48 | -------------------------------------------------------------------------------- /quark_queue_close.3: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK_QUEUE_CLOSE 3 3 | .Os 4 | .Sh NAME 5 | .Nm quark_queue_close 6 | .Nd closes a 7 | .Vt quark_queue 8 | .Sh SYNOPSIS 9 | .In quark.h 10 | .Ft int 11 | .Fn quark_queue_close "struct quark_queue *qq" 12 | .Sh DESCRIPTION 13 | .Nm 14 | closes the 15 | .Vt quark_queue 16 | pointed to by 17 | .Fa qq , 18 | which must have been previously opened with 19 | .Xr quark_queue_open 3 . 20 | .Sh RETURN VALUES 21 | Zero on success, -1 otherwise and 22 | .Va errno 23 | is set. 24 | .Sh SEE ALSO 25 | .Xr quark_event_dump 3 , 26 | .Xr quark_process_lookup 3 , 27 | .Xr quark_queue_block 3 , 28 | .Xr quark_queue_default_attr 3 , 29 | .Xr quark_queue_get_epollfd 3 , 30 | .Xr quark_queue_get_event 3 , 31 | .Xr quark_queue_get_stats 3 , 32 | .Xr quark_queue_open 3 , 33 | .Xr quark 7 , 34 | .Xr quark-btf 8 , 35 | .Xr quark-mon 8 , 36 | .Xr quark-test 8 37 | -------------------------------------------------------------------------------- /quark_queue_default_attr.3: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK_QUEUE_DEFAULT_ATTR 3 3 | .Os 4 | .Sh NAME 5 | .Nm quark_queue_default_attr 6 | .Nd fetch default attributes for 7 | .Xr quark_queue_open 3 8 | .Sh SYNOPSIS 9 | .In quark.h 10 | .Ft void 11 | .Fn quark_queue_default_attr "struct quark_queue_attr *attr" 12 | .Sh DESCRIPTION 13 | .Nm 14 | copies out default attributes for opening a quark_queue. 15 | .Pp 16 | Refer to 17 | .Xr quark_queue_open 3 18 | for an in depth explanation of each member. 19 | .Sh SEE ALSO 20 | .Xr quark_event_dump 3 , 21 | .Xr quark_process_lookup 3 , 22 | .Xr quark_queue_block 3 , 23 | .Xr quark_queue_close 3 , 24 | .Xr quark_queue_get_event 3 , 25 | .Xr quark_queue_open 3 , 26 | .Xr quark 7 , 27 | .Xr quark-btf 8 , 28 | .Xr quark-mon 8 , 29 | .Xr quark-test 8 30 | -------------------------------------------------------------------------------- /quark_queue_get_epollfd.3: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK_QUEUE_GET_EPOLLFD 3 3 | .Os 4 | .Sh NAME 5 | .Nm quark_queue_get_epollfd 6 | .Nd fetch a file descriptor suitable for blocking with 7 | .Xr epoll_wait 2 8 | .Sh SYNOPSIS 9 | .In quark.h 10 | .Ft int 11 | .Fn quark_queue_get_epollfd "struct quark_queue *qq" 12 | .Sh DESCRIPTION 13 | .Nm 14 | retrieves a epoll file descriptor with all the backend related descriptors 15 | already registered to it. 16 | This is to be used for integrating quark into an existing main-loop, as in, not 17 | calling 18 | .Xr quark_queue_block 3 19 | at all. 20 | .Pp 21 | It is 22 | .Em VERY IMPORTANT 23 | to establish a reasonable timeout when you call 24 | .Xr epoll_wait 2 25 | on it. 26 | Some backends will only make the file descriptor readable once a certain 27 | watermark of bytes have been read, so without the timeout you might get very 28 | late events. 29 | 100ms is a safe value, the user should then call 30 | .Xr quark_queue_get_event 3 31 | to fetch the expired event. 32 | .Sh RETURN VALUES 33 | Returns the epoll file descriptor or -1 if deemed invalid, as trying to get the 34 | descriptor of a closed queue. 35 | .Va errno 36 | is set. 37 | .Sh EXAMPLES 38 | .Bd -literal -offset indent 39 | #include 40 | 41 | #include 42 | 43 | static int 44 | my_own_blocking(struct quark_queue *qq) 45 | { 46 | int epollfd; 47 | 48 | epollfd = quark_queue_get_epollfd(qq); 49 | if (epollfd == -1) 50 | return (-1); 51 | if (epoll_wait(qq->epollfd, &ev, 1, 100) == -1) 52 | return (-1); 53 | 54 | return (0); 55 | } 56 | .Ed 57 | .Sh SEE ALSO 58 | .Xr quark_event_dump 3 , 59 | .Xr quark_process_lookup 3 , 60 | .Xr quark_queue_block 3 , 61 | .Xr quark_queue_close 3 , 62 | .Xr quark_queue_default_attr 3 , 63 | .Xr quark_queue_get_event 3 , 64 | .Xr quark_queue_get_stats 3 , 65 | .Xr quark_queue_open 3 , 66 | .Xr quark 7 , 67 | .Xr quark-btf 8 , 68 | .Xr quark-mon 8 , 69 | .Xr quark-test 8 70 | -------------------------------------------------------------------------------- /quark_queue_get_stats.3: -------------------------------------------------------------------------------- 1 | .Dd $Mdocdate$ 2 | .Dt QUARK_QUEUE_GET_STATS 3 3 | .Os 4 | .Sh NAME 5 | .Nm quark_queue_get_stats 6 | .Nd fetch queue statistics 7 | .Sh SYNOPSIS 8 | .In quark.h 9 | .Ft void 10 | .Fn quark_queue_get_stats "struct quark_queue *qq" "struct quark_queue_stats *qs" 11 | .Sh DESCRIPTION 12 | .Nm 13 | copies out all internal statistics from 14 | .Fa qq 15 | into 16 | .Fa qs . 17 | .Vt quark_queue_stats 18 | is defined as: 19 | .Bd -literal -offset indent 20 | struct quark_queue_stats { 21 | u64 insertions; 22 | u64 removals; 23 | u64 aggregations; 24 | u64 non_aggregations; 25 | u64 lost; 26 | int backend; 27 | }; 28 | .Ed 29 | .Bl -tag -width "non_aggregations" 30 | .It Em insertions 31 | A counter of all events that were inserted into the queue 32 | sorting/buffering structures, this is roughly 1:1 with the actual events we read 33 | from the backend. 34 | .It Em removals 35 | A counter of removals of the above, you can count alive items by 36 | counting the difference. 37 | .It Em aggregations 38 | A counter of how many events were aggregated, this is an absolute 39 | counter, meaning a FORK+EXEC+EXIT counts as 1 aggregation, which consumes 3 40 | events. 41 | .It Em non_aggregations 42 | The opposite of 43 | .Em aggregations . 44 | It is increased by one when we didn't aggregate. 45 | .It Em lost 46 | A a counter of missed backend events. 47 | This can happen if the user didn't call 48 | .Xr quark_queue_get_event 3 49 | fast enough or if 50 | .Em quark 51 | simply can't handle the load, the former is way more likely. 52 | It is a state counter representing total loss, the user should compare to an old 53 | reading to know if it increased. 54 | .It Em backend 55 | Active queue backend, either 56 | .Dv QQ_EBPF 57 | or 58 | .Dv QQ_KPROBE . 59 | .El 60 | .Sh SEE ALSO 61 | .Xr quark_event_dump 3 , 62 | .Xr quark_process_lookup 3 , 63 | .Xr quark_queue_block 3 , 64 | .Xr quark_queue_close 3 , 65 | .Xr quark_queue_default_attr 3 , 66 | .Xr quark_queue_get_event 3 , 67 | .Xr quark_queue_open 3 , 68 | .Xr quark 7 , 69 | .Xr quark-btf 8 , 70 | .Xr quark-mon 8 , 71 | .Xr quark-test 8 72 | -------------------------------------------------------------------------------- /zlib/INDEX: -------------------------------------------------------------------------------- 1 | CMakeLists.txt cmake build file 2 | ChangeLog history of changes 3 | FAQ Frequently Asked Questions about zlib 4 | INDEX this file 5 | Makefile dummy Makefile that tells you to ./configure 6 | Makefile.in template for Unix Makefile 7 | README guess what 8 | configure configure script for Unix 9 | make_vms.com makefile for VMS 10 | test/example.c zlib usages examples for build testing 11 | test/minigzip.c minimal gzip-like functionality for build testing 12 | test/infcover.c inf*.c code coverage for build coverage testing 13 | treebuild.xml XML description of source file dependencies 14 | zconf.h.cmakein zconf.h template for cmake 15 | zconf.h.in zconf.h template for configure 16 | zlib.3 Man page for zlib 17 | zlib.3.pdf Man page in PDF format 18 | zlib.map Linux symbol information 19 | zlib.pc.in Template for pkg-config descriptor 20 | zlib.pc.cmakein zlib.pc template for cmake 21 | zlib2ansi perl script to convert source files for C++ compilation 22 | 23 | amiga/ makefiles for Amiga SAS C 24 | as400/ makefiles for AS/400 25 | doc/ documentation for formats and algorithms 26 | msdos/ makefiles for MSDOS 27 | nintendods/ makefile for Nintendo DS 28 | old/ makefiles for various architectures and zlib documentation 29 | files that have not yet been updated for zlib 1.2.x 30 | qnx/ makefiles for QNX 31 | watcom/ makefiles for OpenWatcom 32 | win32/ makefiles for Windows 33 | 34 | zlib public header files (required for library use): 35 | zconf.h 36 | zlib.h 37 | 38 | private source files used to build the zlib library: 39 | adler32.c 40 | compress.c 41 | crc32.c 42 | crc32.h 43 | deflate.c 44 | deflate.h 45 | gzclose.c 46 | gzguts.h 47 | gzlib.c 48 | gzread.c 49 | gzwrite.c 50 | infback.c 51 | inffast.c 52 | inffast.h 53 | inffixed.h 54 | inflate.c 55 | inflate.h 56 | inftrees.c 57 | inftrees.h 58 | trees.c 59 | trees.h 60 | uncompr.c 61 | zutil.c 62 | zutil.h 63 | 64 | source files for sample programs 65 | See examples/README.examples 66 | 67 | unsupported contributions by third parties 68 | See contrib/README.contrib 69 | -------------------------------------------------------------------------------- /zlib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright notice: 2 | 3 | (C) 1995-2024 Jean-loup Gailly and Mark Adler 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | Jean-loup Gailly Mark Adler 22 | jloup@gzip.org madler@alumni.caltech.edu 23 | -------------------------------------------------------------------------------- /zlib/README.quark: -------------------------------------------------------------------------------- 1 | Zlib@Quark 2 | ~~~~~~~~~~~~~~~~~~ 3 | No changes to source code, only makefile tweaks to the printed output. 4 | Only libz.a is build and it's included since we can't expect users of the 5 | static library to build their own. 6 | -------------------------------------------------------------------------------- /zlib/amiga/Makefile.pup: -------------------------------------------------------------------------------- 1 | # Amiga powerUP (TM) Makefile 2 | # makefile for libpng and SAS C V6.58/7.00 PPC compiler 3 | # Copyright (C) 1998 by Andreas R. Kleinert 4 | 5 | LIBNAME = libzip.a 6 | 7 | CC = scppc 8 | CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL \ 9 | OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 NOVER 10 | AR = ppc-amigaos-ar cr 11 | RANLIB = ppc-amigaos-ranlib 12 | LD = ppc-amigaos-ld -r 13 | LDFLAGS = -o 14 | LDLIBS = LIB:scppc.a LIB:end.o 15 | RM = delete quiet 16 | 17 | OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ 18 | uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o 19 | 20 | TEST_OBJS = example.o minigzip.o 21 | 22 | all: example minigzip 23 | 24 | check: test 25 | test: all 26 | example 27 | echo hello world | minigzip | minigzip -d 28 | 29 | $(LIBNAME): $(OBJS) 30 | $(AR) $@ $(OBJS) 31 | -$(RANLIB) $@ 32 | 33 | example: example.o $(LIBNAME) 34 | $(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS) 35 | 36 | minigzip: minigzip.o $(LIBNAME) 37 | $(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS) 38 | 39 | mostlyclean: clean 40 | clean: 41 | $(RM) *.o example minigzip $(LIBNAME) foo.gz 42 | 43 | zip: 44 | zip -ul9 zlib README ChangeLog Makefile Make????.??? Makefile.?? \ 45 | descrip.mms *.[ch] 46 | 47 | tgz: 48 | cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \ 49 | zlib/Make????.??? zlib/Makefile.?? zlib/descrip.mms zlib/*.[ch] 50 | 51 | # DO NOT DELETE THIS LINE -- make depend depends on it. 52 | 53 | adler32.o: zlib.h zconf.h 54 | compress.o: zlib.h zconf.h 55 | crc32.o: crc32.h zlib.h zconf.h 56 | deflate.o: deflate.h zutil.h zlib.h zconf.h 57 | example.o: zlib.h zconf.h 58 | gzclose.o: zlib.h zconf.h gzguts.h 59 | gzlib.o: zlib.h zconf.h gzguts.h 60 | gzread.o: zlib.h zconf.h gzguts.h 61 | gzwrite.o: zlib.h zconf.h gzguts.h 62 | inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 63 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 64 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 65 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h 66 | minigzip.o: zlib.h zconf.h 67 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h 68 | uncompr.o: zlib.h zconf.h 69 | zutil.o: zutil.h zlib.h zconf.h 70 | -------------------------------------------------------------------------------- /zlib/amiga/Makefile.sas: -------------------------------------------------------------------------------- 1 | # SMakefile for zlib 2 | # Modified from the standard UNIX Makefile Copyright Jean-loup Gailly 3 | # Osma Ahvenlampi 4 | # Amiga, SAS/C 6.56 & Smake 5 | 6 | CC=sc 7 | CFLAGS=OPT 8 | #CFLAGS=OPT CPU=68030 9 | #CFLAGS=DEBUG=LINE 10 | LDFLAGS=LIB z.lib 11 | 12 | SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \ 13 | NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX \ 14 | DEF=POSTINC 15 | 16 | OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ 17 | uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o 18 | 19 | TEST_OBJS = example.o minigzip.o 20 | 21 | all: SCOPTIONS example minigzip 22 | 23 | check: test 24 | test: all 25 | example 26 | echo hello world | minigzip | minigzip -d 27 | 28 | install: z.lib 29 | copy clone zlib.h zconf.h INCLUDE: 30 | copy clone z.lib LIB: 31 | 32 | z.lib: $(OBJS) 33 | oml z.lib r $(OBJS) 34 | 35 | example: example.o z.lib 36 | $(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS) 37 | 38 | minigzip: minigzip.o z.lib 39 | $(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS) 40 | 41 | mostlyclean: clean 42 | clean: 43 | -delete force quiet example minigzip *.o z.lib foo.gz *.lnk SCOPTIONS 44 | 45 | SCOPTIONS: Makefile.sas 46 | copy to $@ (uLong)max ? max : (uInt)left; 47 | left -= stream.avail_out; 48 | } 49 | if (stream.avail_in == 0) { 50 | stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; 51 | sourceLen -= stream.avail_in; 52 | } 53 | err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); 54 | } while (err == Z_OK); 55 | 56 | *destLen = stream.total_out; 57 | deflateEnd(&stream); 58 | return err == Z_STREAM_END ? Z_OK : err; 59 | } 60 | 61 | /* =========================================================================== 62 | */ 63 | int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, 64 | uLong sourceLen) { 65 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 66 | } 67 | 68 | /* =========================================================================== 69 | If the default memLevel or windowBits for deflateInit() is changed, then 70 | this function needs to be updated. 71 | */ 72 | uLong ZEXPORT compressBound(uLong sourceLen) { 73 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 74 | (sourceLen >> 25) + 13; 75 | } 76 | -------------------------------------------------------------------------------- /zlib/contrib/README.contrib: -------------------------------------------------------------------------------- 1 | All files under this contrib directory are UNSUPPORTED. They were 2 | provided by users of zlib and were not tested by the authors of zlib. 3 | Use at your own risk. Please contact the authors of the contributions 4 | for help about these, not the zlib authors. Thanks. 5 | 6 | 7 | ada/ by Dmitriy Anisimkov 8 | Support for Ada 9 | See http://zlib-ada.sourceforge.net/ 10 | 11 | blast/ by Mark Adler 12 | Decompressor for output of PKWare Data Compression Library (DCL) 13 | 14 | delphi/ by Cosmin Truta 15 | Support for Delphi and C++ Builder 16 | 17 | dotzlib/ by Henrik Ravn 18 | Support for Microsoft .Net and Visual C++ .Net 19 | 20 | gcc_gvmat64/by Gilles Vollant 21 | GCC Version of x86 64-bit (AMD64 and Intel EM64t) code for x64 22 | assembler to replace longest_match() and inflate_fast() 23 | 24 | infback9/ by Mark Adler 25 | Unsupported diffs to infback to decode the deflate64 format 26 | 27 | iostream/ by Kevin Ruland 28 | A C++ I/O streams interface to the zlib gz* functions 29 | 30 | iostream2/ by Tyge Løvset 31 | Another C++ I/O streams interface 32 | 33 | iostream3/ by Ludwig Schwardt 34 | and Kevin Ruland 35 | Yet another C++ I/O streams interface 36 | 37 | minizip/ by Gilles Vollant 38 | Mini zip and unzip based on zlib 39 | Includes Zip64 support by Mathias Svensson 40 | See http://www.winimage.com/zLibDll/minizip.html 41 | 42 | pascal/ by Bob Dellaca et al. 43 | Support for Pascal 44 | 45 | puff/ by Mark Adler 46 | Small, low memory usage inflate. Also serves to provide an 47 | unambiguous description of the deflate format. 48 | 49 | testzlib/ by Gilles Vollant 50 | Example of the use of zlib 51 | 52 | untgz/ by Pedro A. Aranda Gutierrez 53 | A very simple tar.gz file extractor using zlib 54 | 55 | vstudio/ by Gilles Vollant 56 | Building a minizip-enhanced zlib with Microsoft Visual Studio 57 | Includes vc11 from kreuzerkrieg and vc12 from davispuh 58 | -------------------------------------------------------------------------------- /zlib/contrib/ada/readme.txt: -------------------------------------------------------------------------------- 1 | ZLib for Ada thick binding (ZLib.Ada) 2 | Release 1.3 3 | 4 | ZLib.Ada is a thick binding interface to the popular ZLib data 5 | compression library, available at https://zlib.net/. 6 | It provides Ada-style access to the ZLib C library. 7 | 8 | 9 | Here are the main changes since ZLib.Ada 1.2: 10 | 11 | - Attention: ZLib.Read generic routine have a initialization requirement 12 | for Read_Last parameter now. It is a bit incompatible with previous version, 13 | but extends functionality, we could use new parameters Allow_Read_Some and 14 | Flush now. 15 | 16 | - Added Is_Open routines to ZLib and ZLib.Streams packages. 17 | 18 | - Add pragma Assert to check Stream_Element is 8 bit. 19 | 20 | - Fix extraction to buffer with exact known decompressed size. Error reported by 21 | Steve Sangwine. 22 | 23 | - Fix definition of ULong (changed to unsigned_long), fix regression on 64 bits 24 | computers. Patch provided by Pascal Obry. 25 | 26 | - Add Status_Error exception definition. 27 | 28 | - Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit. 29 | 30 | 31 | How to build ZLib.Ada under GNAT 32 | 33 | You should have the ZLib library already build on your computer, before 34 | building ZLib.Ada. Make the directory of ZLib.Ada sources current and 35 | issue the command: 36 | 37 | gnatmake test -largs -L -lz 38 | 39 | Or use the GNAT project file build for GNAT 3.15 or later: 40 | 41 | gnatmake -Pzlib.gpr -L 42 | 43 | 44 | How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2 45 | 46 | 1. Make a project with all *.ads and *.adb files from the distribution. 47 | 2. Build the libz.a library from the ZLib C sources. 48 | 3. Rename libz.a to z.lib. 49 | 4. Add the library z.lib to the project. 50 | 5. Add the libc.lib library from the ObjectAda distribution to the project. 51 | 6. Build the executable using test.adb as a main procedure. 52 | 53 | 54 | How to use ZLib.Ada 55 | 56 | The source files test.adb and read.adb are small demo programs that show 57 | the main functionality of ZLib.Ada. 58 | 59 | The routines from the package specifications are commented. 60 | 61 | 62 | Homepage: http://zlib-ada.sourceforge.net/ 63 | Author: Dmitriy Anisimkov 64 | 65 | Contributors: Pascal Obry , Steve Sangwine 66 | -------------------------------------------------------------------------------- /zlib/contrib/ada/zlib.gpr: -------------------------------------------------------------------------------- 1 | project Zlib is 2 | 3 | for Languages use ("Ada"); 4 | for Source_Dirs use ("."); 5 | for Object_Dir use "."; 6 | for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo"); 7 | 8 | package Compiler is 9 | for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst"); 10 | end Compiler; 11 | 12 | package Linker is 13 | for Default_Switches ("ada") use ("-lz"); 14 | end Linker; 15 | 16 | package Builder is 17 | for Default_Switches ("ada") use ("-s", "-gnatQ"); 18 | end Builder; 19 | 20 | end Zlib; 21 | -------------------------------------------------------------------------------- /zlib/contrib/blast/Makefile: -------------------------------------------------------------------------------- 1 | blast: blast.c blast.h 2 | cc -DTEST -o blast blast.c 3 | 4 | test: blast 5 | blast < test.pk | cmp - test.txt 6 | 7 | clean: 8 | rm -f blast blast.o 9 | -------------------------------------------------------------------------------- /zlib/contrib/blast/README: -------------------------------------------------------------------------------- 1 | Read blast.h for purpose and usage. 2 | 3 | Mark Adler 4 | madler@alumni.caltech.edu 5 | -------------------------------------------------------------------------------- /zlib/contrib/blast/test.pk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/blast/test.pk -------------------------------------------------------------------------------- /zlib/contrib/blast/test.txt: -------------------------------------------------------------------------------- 1 | AIAIAIAIAIAIA -------------------------------------------------------------------------------- /zlib/contrib/delphi/ZLibConst.pas: -------------------------------------------------------------------------------- 1 | unit ZLibConst; 2 | 3 | interface 4 | 5 | resourcestring 6 | sTargetBufferTooSmall = 'ZLib error: target buffer may be too small'; 7 | sInvalidStreamOp = 'Invalid stream operation'; 8 | 9 | implementation 10 | 11 | end. 12 | -------------------------------------------------------------------------------- /zlib/contrib/delphi/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Overview 3 | ======== 4 | 5 | This directory contains an update to the ZLib interface unit, 6 | distributed by Borland as a Delphi supplemental component. 7 | 8 | The original ZLib unit is Copyright (c) 1997,99 Borland Corp., 9 | and is based on zlib version 1.0.4. There are a series of bugs 10 | and security problems associated with that old zlib version, and 11 | we recommend the users to update their ZLib unit. 12 | 13 | 14 | Summary of modifications 15 | ======================== 16 | 17 | - Improved makefile, adapted to zlib version 1.2.1. 18 | 19 | - Some field types from TZStreamRec are changed from Integer to 20 | Longint, for consistency with the zlib.h header, and for 64-bit 21 | readiness. 22 | 23 | - The zlib_version constant is updated. 24 | 25 | - The new Z_RLE strategy has its corresponding symbolic constant. 26 | 27 | - The allocation and deallocation functions and function types 28 | (TAlloc, TFree, zlibAllocMem and zlibFreeMem) are now cdecl, 29 | and _malloc and _free are added as C RTL stubs. As a result, 30 | the original C sources of zlib can be compiled out of the box, 31 | and linked to the ZLib unit. 32 | 33 | 34 | Suggestions for improvements 35 | ============================ 36 | 37 | Currently, the ZLib unit provides only a limited wrapper around 38 | the zlib library, and much of the original zlib functionality is 39 | missing. Handling compressed file formats like ZIP/GZIP or PNG 40 | cannot be implemented without having this functionality. 41 | Applications that handle these formats are either using their own, 42 | duplicated code, or not using the ZLib unit at all. 43 | 44 | Here are a few suggestions: 45 | 46 | - Checksum class wrappers around adler32() and crc32(), similar 47 | to the Java classes that implement the java.util.zip.Checksum 48 | interface. 49 | 50 | - The ability to read and write raw deflate streams, without the 51 | zlib stream header and trailer. Raw deflate streams are used 52 | in the ZIP file format. 53 | 54 | - The ability to read and write gzip streams, used in the GZIP 55 | file format, and normally produced by the gzip program. 56 | 57 | - The ability to select a different compression strategy, useful 58 | to PNG and MNG image compression, and to multimedia compression 59 | in general. Besides the compression level 60 | 61 | TCompressionLevel = (clNone, clFastest, clDefault, clMax); 62 | 63 | which, in fact, could have used the 'z' prefix and avoided 64 | TColor-like symbols 65 | 66 | TCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax); 67 | 68 | there could be a compression strategy 69 | 70 | TCompressionStrategy = (zsDefault, zsFiltered, zsHuffmanOnly, zsRle); 71 | 72 | - ZIP and GZIP stream handling via TStreams. 73 | 74 | 75 | -- 76 | Cosmin Truta 77 | -------------------------------------------------------------------------------- /zlib/contrib/delphi/zlibd32.mak: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # For use with Delphi and C++ Builder under Win32 3 | # Updated for zlib 1.2.x by Cosmin Truta 4 | 5 | # ------------ Borland C++ ------------ 6 | 7 | # This project uses the Delphi (fastcall/register) calling convention: 8 | LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl 9 | 10 | CC = bcc32 11 | LD = bcc32 12 | AR = tlib 13 | # do not use "-pr" in CFLAGS 14 | CFLAGS = -a -d -k- -O2 $(LOC) 15 | LDFLAGS = 16 | 17 | 18 | # variables 19 | ZLIB_LIB = zlib.lib 20 | 21 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj 22 | OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj 23 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj 24 | OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj 25 | 26 | 27 | # targets 28 | all: $(ZLIB_LIB) example.exe minigzip.exe 29 | 30 | .c.obj: 31 | $(CC) -c $(CFLAGS) $*.c 32 | 33 | adler32.obj: adler32.c zlib.h zconf.h 34 | 35 | compress.obj: compress.c zlib.h zconf.h 36 | 37 | crc32.obj: crc32.c zlib.h zconf.h crc32.h 38 | 39 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h 40 | 41 | gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h 42 | 43 | gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h 44 | 45 | gzread.obj: gzread.c zlib.h zconf.h gzguts.h 46 | 47 | gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h 48 | 49 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 50 | inffast.h inffixed.h 51 | 52 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 53 | inffast.h 54 | 55 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 56 | inffast.h inffixed.h 57 | 58 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h 59 | 60 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h 61 | 62 | uncompr.obj: uncompr.c zlib.h zconf.h 63 | 64 | zutil.obj: zutil.c zutil.h zlib.h zconf.h 65 | 66 | example.obj: test/example.c zlib.h zconf.h 67 | 68 | minigzip.obj: test/minigzip.c zlib.h zconf.h 69 | 70 | 71 | # For the sake of the old Borland make, 72 | # the command line is cut to fit in the MS-DOS 128 byte limit: 73 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) 74 | -del $(ZLIB_LIB) 75 | $(AR) $(ZLIB_LIB) $(OBJP1) 76 | $(AR) $(ZLIB_LIB) $(OBJP2) 77 | 78 | 79 | # testing 80 | test: example.exe minigzip.exe 81 | example 82 | echo hello world | minigzip | minigzip -d 83 | 84 | example.exe: example.obj $(ZLIB_LIB) 85 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) 86 | 87 | minigzip.exe: minigzip.obj $(ZLIB_LIB) 88 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) 89 | 90 | 91 | # cleanup 92 | clean: 93 | -del *.obj 94 | -del *.exe 95 | -del *.lib 96 | -del *.tds 97 | -del zlib.bak 98 | -del foo.gz 99 | 100 | -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib.build: -------------------------------------------------------------------------------- 1 |  2 | 3 | A .Net wrapper library around ZLib1.dll 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/dotzlib/DotZLib.chm -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotZLib", "DotZLib\DotZLib.csproj", "{BB1EE0B1-1808-46CB-B786-949D91117FC5}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfiguration) = preSolution 8 | Debug = Debug 9 | Release = Release 10 | EndGlobalSection 11 | GlobalSection(ProjectConfiguration) = postSolution 12 | {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.ActiveCfg = Debug|.NET 13 | {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.Build.0 = Debug|.NET 14 | {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.ActiveCfg = Release|.NET 15 | {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.Build.0 = Release|.NET 16 | EndGlobalSection 17 | GlobalSection(ExtensibilityGlobals) = postSolution 18 | EndGlobalSection 19 | GlobalSection(ExtensibilityAddIns) = postSolution 20 | EndGlobalSection 21 | EndGlobal 22 | -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | // 9 | [assembly: AssemblyTitle("DotZLib")] 10 | [assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("Henrik Ravn")] 13 | [assembly: AssemblyProduct("")] 14 | [assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Revision and Build Numbers 27 | // by using the '*' as shown below: 28 | 29 | [assembly: AssemblyVersion("1.0.*")] 30 | 31 | // 32 | // In order to sign your assembly you must specify a key to use. Refer to the 33 | // Microsoft .NET Framework documentation for more information on assembly signing. 34 | // 35 | // Use the attributes below to control which key is used for signing. 36 | // 37 | // Notes: 38 | // (*) If no key is specified, the assembly is not signed. 39 | // (*) KeyName refers to a key that has been installed in the Crypto Service 40 | // Provider (CSP) on your machine. KeyFile refers to a file which contains 41 | // a key. 42 | // (*) If the KeyFile and the KeyName values are both specified, the 43 | // following processing occurs: 44 | // (1) If the KeyName can be found in the CSP, that key is used. 45 | // (2) If the KeyName does not exist and the KeyFile does exist, the key 46 | // in the KeyFile is installed into the CSP and used. 47 | // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. 48 | // When specifying the KeyFile, the location of the KeyFile should be 49 | // relative to the project output directory which is 50 | // %Project Directory%\obj\. For example, if your KeyFile is 51 | // located in the project directory, you would specify the AssemblyKeyFile 52 | // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] 53 | // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework 54 | // documentation for more information on this. 55 | // 56 | [assembly: AssemblyDelaySign(false)] 57 | [assembly: AssemblyKeyFile("")] 58 | [assembly: AssemblyKeyName("")] 59 | -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib/CodecBase.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/dotzlib/DotZLib/CodecBase.cs -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib/Deflater.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/dotzlib/DotZLib/Deflater.cs -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib/DotZLib.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/dotzlib/DotZLib/DotZLib.cs -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib/GZipStream.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/dotzlib/DotZLib/GZipStream.cs -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/DotZLib/Inflater.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/dotzlib/DotZLib/Inflater.cs -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /zlib/contrib/dotzlib/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains a .Net wrapper class library for the ZLib1.dll 2 | 3 | The wrapper includes support for inflating/deflating memory buffers, 4 | .Net streaming wrappers for the gz streams part of zlib, and wrappers 5 | for the checksum parts of zlib. See DotZLib/UnitTests.cs for examples. 6 | 7 | Directory structure: 8 | -------------------- 9 | 10 | LICENSE_1_0.txt - License file. 11 | readme.txt - This file. 12 | DotZLib.chm - Class library documentation 13 | DotZLib.build - NAnt build file 14 | DotZLib.sln - Microsoft Visual Studio 2003 solution file 15 | 16 | DotZLib\*.cs - Source files for the class library 17 | 18 | Unit tests: 19 | ----------- 20 | The file DotZLib/UnitTests.cs contains unit tests for use with NUnit 2.1 or higher. 21 | To include unit tests in the build, define nunit before building. 22 | 23 | 24 | Build instructions: 25 | ------------------- 26 | 27 | 1. Using Visual Studio.Net 2003: 28 | Open DotZLib.sln in VS.Net and build from there. Output file (DotZLib.dll) 29 | will be found ./DotZLib/bin/release or ./DotZLib/bin/debug, depending on 30 | you are building the release or debug version of the library. Check 31 | DotZLib/UnitTests.cs for instructions on how to include unit tests in the 32 | build. 33 | 34 | 2. Using NAnt: 35 | Open a command prompt with access to the build environment and run nant 36 | in the same directory as the DotZLib.build file. 37 | You can define 2 properties on the nant command-line to control the build: 38 | debug={true|false} to toggle between release/debug builds (default=true). 39 | nunit={true|false} to include or exclude unit tests (default=true). 40 | Also the target clean will remove binaries. 41 | Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release 42 | or ./DotZLib/bin/debug, depending on whether you are building the release 43 | or debug version of the library. 44 | 45 | Examples: 46 | nant -D:debug=false -D:nunit=false 47 | will build a release mode version of the library without unit tests. 48 | nant 49 | will build a debug version of the library with unit tests 50 | nant clean 51 | will remove all previously built files. 52 | 53 | 54 | --------------------------------- 55 | Copyright (c) Henrik Ravn 2004 56 | 57 | Use, modification and distribution are subject to the Boost Software License, Version 1.0. 58 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 59 | -------------------------------------------------------------------------------- /zlib/contrib/infback9/README: -------------------------------------------------------------------------------- 1 | See infback9.h for what this is and how to use it. 2 | -------------------------------------------------------------------------------- /zlib/contrib/infback9/infback9.h: -------------------------------------------------------------------------------- 1 | /* infback9.h -- header for using inflateBack9 functions 2 | * Copyright (C) 2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* 7 | * This header file and associated patches provide a decoder for PKWare's 8 | * undocumented deflate64 compression method (method 9). Use with infback9.c, 9 | * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported. 10 | * This should be compiled with zlib, since it uses zutil.h and zutil.o. 11 | * This code has not yet been tested on 16-bit architectures. See the 12 | * comments in zlib.h for inflateBack() usage. These functions are used 13 | * identically, except that there is no windowBits parameter, and a 64K 14 | * window must be provided. Also if int's are 16 bits, then a zero for 15 | * the third parameter of the "out" function actually means 65536UL. 16 | * zlib.h must be included before this header file. 17 | */ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | ZEXTERN int ZEXPORT inflateBack9(z_stream FAR *strm, 24 | in_func in, void FAR *in_desc, 25 | out_func out, void FAR *out_desc); 26 | ZEXTERN int ZEXPORT inflateBack9End(z_stream FAR *strm); 27 | ZEXTERN int ZEXPORT inflateBack9Init_(z_stream FAR *strm, 28 | unsigned char FAR *window, 29 | const char *version, 30 | int stream_size); 31 | #define inflateBack9Init(strm, window) \ 32 | inflateBack9Init_((strm), (window), \ 33 | ZLIB_VERSION, sizeof(z_stream)) 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /zlib/contrib/infback9/inflate9.h: -------------------------------------------------------------------------------- 1 | /* inflate9.h -- internal inflate state definition 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Possible inflate modes between inflate() calls */ 12 | typedef enum { 13 | TYPE, /* i: waiting for type bits, including last-flag bit */ 14 | STORED, /* i: waiting for stored size (length and complement) */ 15 | TABLE, /* i: waiting for dynamic block table lengths */ 16 | LEN, /* i: waiting for length/lit code */ 17 | DONE, /* finished check, done -- remain here until reset */ 18 | BAD /* got a data error -- remain here until reset */ 19 | } inflate_mode; 20 | 21 | /* 22 | State transitions between above modes - 23 | 24 | (most modes can go to the BAD mode -- not shown for clarity) 25 | 26 | Read deflate blocks: 27 | TYPE -> STORED or TABLE or LEN or DONE 28 | STORED -> TYPE 29 | TABLE -> LENLENS -> CODELENS -> LEN 30 | Read deflate codes: 31 | LEN -> LEN or TYPE 32 | */ 33 | 34 | /* state maintained between inflate() calls. Approximately 7K bytes. */ 35 | struct inflate_state { 36 | /* sliding window */ 37 | unsigned char FAR *window; /* allocated sliding window, if needed */ 38 | /* dynamic table building */ 39 | unsigned ncode; /* number of code length code lengths */ 40 | unsigned nlen; /* number of length code lengths */ 41 | unsigned ndist; /* number of distance code lengths */ 42 | unsigned have; /* number of code lengths in lens[] */ 43 | code FAR *next; /* next available space in codes[] */ 44 | unsigned short lens[320]; /* temporary storage for code lengths */ 45 | unsigned short work[288]; /* work area for code table building */ 46 | code codes[ENOUGH]; /* space for code tables */ 47 | }; 48 | -------------------------------------------------------------------------------- /zlib/contrib/iostream/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "zfstream.h" 3 | 4 | int main() { 5 | 6 | // Construct a stream object with this filebuffer. Anything sent 7 | // to this stream will go to standard out. 8 | gzofstream os( 1, ios::out ); 9 | 10 | // This text is getting compressed and sent to stdout. 11 | // To prove this, run 'test | zcat'. 12 | os << "Hello, Mommy" << endl; 13 | 14 | os << setcompressionlevel( Z_NO_COMPRESSION ); 15 | os << "hello, hello, hi, ho!" << endl; 16 | 17 | setcompressionlevel( os, Z_DEFAULT_COMPRESSION ) 18 | << "I'm compressing again" << endl; 19 | 20 | os.close(); 21 | 22 | return 0; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /zlib/contrib/iostream2/zstream_test.cpp: -------------------------------------------------------------------------------- 1 | #include "zstream.h" 2 | #include 3 | #include 4 | #include 5 | 6 | void main() { 7 | char h[256] = "Hello"; 8 | char* g = "Goodbye"; 9 | ozstream out("temp.gz"); 10 | out < "This works well" < h < g; 11 | out.close(); 12 | 13 | izstream in("temp.gz"); // read it back 14 | char *x = read_string(in), *y = new char[256], z[256]; 15 | in > y > z; 16 | in.close(); 17 | cout << x << endl << y << endl << z << endl; 18 | 19 | out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results 20 | out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl; 21 | out << z << endl << y << endl << x << endl; 22 | out << 1.1234567890123456789 << endl; 23 | 24 | delete[] x; delete[] y; 25 | } 26 | -------------------------------------------------------------------------------- /zlib/contrib/iostream3/README: -------------------------------------------------------------------------------- 1 | These classes provide a C++ stream interface to the zlib library. It allows you 2 | to do things like: 3 | 4 | gzofstream outf("blah.gz"); 5 | outf << "These go into the gzip file " << 123 << endl; 6 | 7 | It does this by deriving a specialized stream buffer for gzipped files, which is 8 | the way Stroustrup would have done it. :-> 9 | 10 | The gzifstream and gzofstream classes were originally written by Kevin Ruland 11 | and made available in the zlib contrib/iostream directory. The older version still 12 | compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of 13 | this version. 14 | 15 | The new classes are as standard-compliant as possible, closely following the 16 | approach of the standard library's fstream classes. It compiles under gcc versions 17 | 3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard 18 | library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs 19 | from the previous one in the following respects: 20 | - added showmanyc 21 | - added setbuf, with support for unbuffered output via setbuf(0,0) 22 | - a few bug fixes of stream behavior 23 | - gzipped output file opened with default compression level instead of maximum level 24 | - setcompressionlevel()/strategy() members replaced by single setcompression() 25 | 26 | The code is provided "as is", with the permission to use, copy, modify, distribute 27 | and sell it for any purpose without fee. 28 | 29 | Ludwig Schwardt 30 | 31 | 32 | DSP Lab 33 | Electrical & Electronic Engineering Department 34 | University of Stellenbosch 35 | South Africa 36 | -------------------------------------------------------------------------------- /zlib/contrib/iostream3/TODO: -------------------------------------------------------------------------------- 1 | Possible upgrades to gzfilebuf: 2 | 3 | - The ability to do putback (e.g. putbackfail) 4 | 5 | - The ability to seek (zlib supports this, but could be slow/tricky) 6 | 7 | - Simultaneous read/write access (does it make sense?) 8 | 9 | - Support for ios_base::ate open mode 10 | 11 | - Locale support? 12 | 13 | - Check public interface to see which calls give problems 14 | (due to dependence on library internals) 15 | 16 | - Override operator<<(ostream&, gzfilebuf*) to allow direct copying 17 | of stream buffer to stream ( i.e. os << is.rdbuf(); ) 18 | -------------------------------------------------------------------------------- /zlib/contrib/iostream3/test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Test program for gzifstream and gzofstream 3 | * 4 | * by Ludwig Schwardt 5 | * original version by Kevin Ruland 6 | */ 7 | 8 | #include "zfstream.h" 9 | #include // for cout 10 | 11 | int main() { 12 | 13 | gzofstream outf; 14 | gzifstream inf; 15 | char buf[80]; 16 | 17 | outf.open("test1.txt.gz"); 18 | outf << "The quick brown fox sidestepped the lazy canine\n" 19 | << 1.3 << "\nPlan " << 9 << std::endl; 20 | outf.close(); 21 | std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n" 22 | << "The quick brown fox sidestepped the lazy canine\n" 23 | << 1.3 << "\nPlan " << 9 << std::endl; 24 | 25 | std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n"; 26 | inf.open("test1.txt.gz"); 27 | while (inf.getline(buf,80,'\n')) { 28 | std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; 29 | } 30 | inf.close(); 31 | 32 | outf.rdbuf()->pubsetbuf(0,0); 33 | outf.open("test2.txt.gz"); 34 | outf << setcompression(Z_NO_COMPRESSION) 35 | << "The quick brown fox sidestepped the lazy canine\n" 36 | << 1.3 << "\nPlan " << 9 << std::endl; 37 | outf.close(); 38 | std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form"; 39 | 40 | std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n"; 41 | inf.rdbuf()->pubsetbuf(0,0); 42 | inf.open("test2.txt.gz"); 43 | while (inf.getline(buf,80,'\n')) { 44 | std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; 45 | } 46 | inf.close(); 47 | 48 | return 0; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/Makefile: -------------------------------------------------------------------------------- 1 | CC?=cc 2 | CFLAGS := -O $(CFLAGS) -I../.. 3 | 4 | UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a 5 | ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a 6 | 7 | .c.o: 8 | $(CC) -c $(CFLAGS) $*.c 9 | 10 | all: miniunz minizip 11 | 12 | miniunz: $(UNZ_OBJS) 13 | $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) 14 | 15 | minizip: $(ZIP_OBJS) 16 | $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) 17 | 18 | test: miniunz minizip 19 | @rm -f test.* 20 | @echo hello hello hello > test.txt 21 | ./minizip test test.txt 22 | ./miniunz -l test.zip 23 | @mv test.txt test.old 24 | ./miniunz test.zip 25 | @cmp test.txt test.old 26 | @rm -f test.* 27 | 28 | clean: 29 | /bin/rm -f *.o *~ minizip miniunz test.* 30 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libminizip.la 2 | 3 | if COND_DEMOS 4 | bin_PROGRAMS = miniunzip minizip 5 | endif 6 | 7 | zlib_top_srcdir = $(top_srcdir)/../.. 8 | zlib_top_builddir = $(top_builddir)/../.. 9 | 10 | AM_CPPFLAGS = -I$(zlib_top_srcdir) 11 | AM_LDFLAGS = -L$(zlib_top_builddir) 12 | 13 | if WIN32 14 | iowin32_src = iowin32.c 15 | iowin32_h = iowin32.h 16 | endif 17 | 18 | libminizip_la_SOURCES = \ 19 | ioapi.c \ 20 | mztools.c \ 21 | unzip.c \ 22 | zip.c \ 23 | ${iowin32_src} 24 | 25 | libminizip_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 -lz 26 | 27 | minizip_includedir = $(includedir)/minizip 28 | minizip_include_HEADERS = \ 29 | crypt.h \ 30 | ioapi.h \ 31 | mztools.h \ 32 | unzip.h \ 33 | zip.h \ 34 | ${iowin32_h} 35 | 36 | pkgconfigdir = $(libdir)/pkgconfig 37 | pkgconfig_DATA = minizip.pc 38 | 39 | EXTRA_PROGRAMS = miniunzip minizip 40 | 41 | miniunzip_SOURCES = miniunz.c 42 | miniunzip_LDADD = libminizip.la 43 | 44 | minizip_SOURCES = minizip.c 45 | minizip_LDADD = libminizip.la -lz 46 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/MiniZip64_Changes.txt: -------------------------------------------------------------------------------- 1 | 2 | MiniZip 1.1 was derived from MiniZip at version 1.01f 3 | 4 | Change in 1.0 (Okt 2009) 5 | - **TODO - Add history** 6 | 7 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_INIT([minizip], [1.3.1.1], [bugzilla.redhat.com]) 5 | AC_CONFIG_SRCDIR([minizip.c]) 6 | AM_INIT_AUTOMAKE([foreign]) 7 | LT_INIT 8 | 9 | AC_MSG_CHECKING([whether to build example programs]) 10 | AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs])) 11 | AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes]) 12 | if test "$enable_demos" = yes 13 | then 14 | AC_MSG_RESULT([yes]) 15 | else 16 | AC_MSG_RESULT([no]) 17 | fi 18 | 19 | case "${host}" in 20 | *-mingw* | mingw*) 21 | WIN32="yes" 22 | ;; 23 | *) 24 | ;; 25 | esac 26 | AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) 27 | 28 | 29 | AC_SUBST([HAVE_UNISTD_H], [0]) 30 | AC_CHECK_HEADER([unistd.h], [HAVE_UNISTD_H=1], []) 31 | AC_CONFIG_FILES([Makefile minizip.pc]) 32 | AC_OUTPUT 33 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/iowin32.h: -------------------------------------------------------------------------------- 1 | /* iowin32.h -- IO base function header for compress/uncompress .zip 2 | Version 1.1, February 14h, 2010 3 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 4 | 5 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 6 | 7 | Modifications for Zip64 support 8 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 9 | 10 | For more info read MiniZip_info.txt 11 | 12 | */ 13 | 14 | #include 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def); 22 | void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def); 23 | void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def); 24 | void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/make_vms.com: -------------------------------------------------------------------------------- 1 | $ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig 2 | $ open/write zdef vmsdefs.h 3 | $ copy sys$input: zdef 4 | $ deck 5 | #define __unix__ 6 | #define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from 7 | #define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator 8 | #define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord 9 | #define Write_EndOfCentralDirectoryRecord Write_EoDRecord 10 | $ eod 11 | $ close zdef 12 | $ copy vmsdefs.h,ioapi.h_orig ioapi.h 13 | $ cc/include=[--]/prefix=all ioapi.c 14 | $ cc/include=[--]/prefix=all miniunz.c 15 | $ cc/include=[--]/prefix=all unzip.c 16 | $ cc/include=[--]/prefix=all minizip.c 17 | $ cc/include=[--]/prefix=all zip.c 18 | $ link miniunz,unzip,ioapi,[--]libz.olb/lib 19 | $ link minizip,zip,ioapi,[--]libz.olb/lib 20 | $ mcr []minizip test minizip_info.txt 21 | $ mcr []miniunz -l test.zip 22 | $ rename minizip_info.txt; minizip_info.txt_old 23 | $ mcr []miniunz test.zip 24 | $ delete test.zip;* 25 | $exit 26 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/miniunzip.1: -------------------------------------------------------------------------------- 1 | .\" Hey, EMACS: -*- nroff -*- 2 | .TH miniunzip 1 "Nov 7, 2001" 3 | .\" Please adjust this date whenever revising the manpage. 4 | .\" 5 | .\" Some roff macros, for reference: 6 | .\" .nh disable hyphenation 7 | .\" .hy enable hyphenation 8 | .\" .ad l left justify 9 | .\" .ad b justify to both left and right margins 10 | .\" .nf disable filling 11 | .\" .fi enable filling 12 | .\" .br insert line break 13 | .\" .sp insert n+1 empty lines 14 | .\" for manpage-specific macros, see man(7) 15 | .SH NAME 16 | miniunzip - uncompress and examine ZIP archives 17 | .SH SYNOPSIS 18 | .B miniunzip 19 | .RI [ -exvlo ] 20 | zipfile [ files_to_extract ] [-d tempdir] 21 | .SH DESCRIPTION 22 | .B minizip 23 | is a simple tool which allows the extraction of compressed file 24 | archives in the ZIP format used by the MS-DOS utility PKZIP. It was 25 | written as a demonstration of the 26 | .IR zlib (3) 27 | library and therefore lack many of the features of the 28 | .IR unzip (1) 29 | program. 30 | .SH OPTIONS 31 | A number of options are supported. With the exception of 32 | .BI \-d\ tempdir 33 | these must be supplied before any 34 | other arguments and are: 35 | .TP 36 | .BI \-l\ ,\ \-\-v 37 | List the files in the archive without extracting them. 38 | .TP 39 | .B \-o 40 | Overwrite files without prompting for confirmation. 41 | .TP 42 | .B \-x 43 | Extract files (default). 44 | .PP 45 | The 46 | .I zipfile 47 | argument is the name of the archive to process. The next argument can be used 48 | to specify a single file to extract from the archive. 49 | 50 | Lastly, the following option can be specified at the end of the command-line: 51 | .TP 52 | .BI \-d\ tempdir 53 | Extract the archive in the directory 54 | .I tempdir 55 | rather than the current directory. 56 | .SH SEE ALSO 57 | .BR minizip (1), 58 | .BR zlib (3), 59 | .BR unzip (1). 60 | .SH AUTHOR 61 | This program was written by Gilles Vollant. This manual page was 62 | written by Mark Brown . The -d tempdir option 63 | was added by Dirk Eddelbuettel . 64 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/minizip.1: -------------------------------------------------------------------------------- 1 | .\" Hey, EMACS: -*- nroff -*- 2 | .TH minizip 1 "May 2, 2001" 3 | .\" Please adjust this date whenever revising the manpage. 4 | .\" 5 | .\" Some roff macros, for reference: 6 | .\" .nh disable hyphenation 7 | .\" .hy enable hyphenation 8 | .\" .ad l left justify 9 | .\" .ad b justify to both left and right margins 10 | .\" .nf disable filling 11 | .\" .fi enable filling 12 | .\" .br insert line break 13 | .\" .sp insert n+1 empty lines 14 | .\" for manpage-specific macros, see man(7) 15 | .SH NAME 16 | minizip - create ZIP archives 17 | .SH SYNOPSIS 18 | .B minizip 19 | .RI [ -o ] 20 | zipfile [ " files" ... ] 21 | .SH DESCRIPTION 22 | .B minizip 23 | is a simple tool which allows the creation of compressed file archives 24 | in the ZIP format used by the MS-DOS utility PKZIP. It was written as 25 | a demonstration of the 26 | .IR zlib (3) 27 | library and therefore lack many of the features of the 28 | .IR zip (1) 29 | program. 30 | .SH OPTIONS 31 | The first argument supplied is the name of the ZIP archive to create or 32 | .RI -o 33 | in which case it is ignored and the second argument treated as the 34 | name of the ZIP file. If the ZIP file already exists it will be 35 | overwritten. 36 | .PP 37 | Subsequent arguments specify a list of files to place in the ZIP 38 | archive. If none are specified then an empty archive will be created. 39 | .SH SEE ALSO 40 | .BR miniunzip (1), 41 | .BR zlib (3), 42 | .BR zip (1). 43 | .SH AUTHOR 44 | This program was written by Gilles Vollant. This manual page was 45 | written by Mark Brown . 46 | 47 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/minizip.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@/minizip 5 | 6 | Name: minizip 7 | Description: Minizip zip file manipulation library 8 | Requires: 9 | Version: @PACKAGE_VERSION@ 10 | Libs: -L${libdir} -lminizip 11 | Libs.private: -lz 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /zlib/contrib/minizip/mztools.h: -------------------------------------------------------------------------------- 1 | /* 2 | Additional tools for Minizip 3 | Code: Xavier Roche '2004 4 | License: Same as ZLIB (www.gzip.org) 5 | */ 6 | 7 | #ifndef _zip_tools_H 8 | #define _zip_tools_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef _ZLIB_H 15 | #include "zlib.h" 16 | #endif 17 | 18 | #include "unzip.h" 19 | 20 | /* Repair a ZIP file (missing central directory) 21 | file: file to recover 22 | fileOut: output file after recovery 23 | fileOutTmp: temporary file name used for recovery 24 | */ 25 | extern int ZEXPORT unzRepair(const char* file, 26 | const char* fileOut, 27 | const char* fileOutTmp, 28 | uLong* nRecovered, 29 | uLong* bytesRecovered); 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /zlib/contrib/nuget/nuget.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31903.59 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nuget", "nuget.csproj", "{B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(SolutionProperties) = preSolution 14 | HideSolutionNode = FALSE 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 | {B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 | {B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 | {B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Release|Any CPU.Build.0 = Release|Any CPU 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /zlib/contrib/pascal/zlibd32.mak: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # For use with Delphi and C++ Builder under Win32 3 | # Updated for zlib 1.2.x by Cosmin Truta 4 | 5 | # ------------ Borland C++ ------------ 6 | 7 | # This project uses the Delphi (fastcall/register) calling convention: 8 | LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl 9 | 10 | CC = bcc32 11 | LD = bcc32 12 | AR = tlib 13 | # do not use "-pr" in CFLAGS 14 | CFLAGS = -a -d -k- -O2 $(LOC) 15 | LDFLAGS = 16 | 17 | 18 | # variables 19 | ZLIB_LIB = zlib.lib 20 | 21 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj 22 | OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj 23 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj 24 | OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj 25 | 26 | 27 | # targets 28 | all: $(ZLIB_LIB) example.exe minigzip.exe 29 | 30 | .c.obj: 31 | $(CC) -c $(CFLAGS) $*.c 32 | 33 | adler32.obj: adler32.c zlib.h zconf.h 34 | 35 | compress.obj: compress.c zlib.h zconf.h 36 | 37 | crc32.obj: crc32.c zlib.h zconf.h crc32.h 38 | 39 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h 40 | 41 | gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h 42 | 43 | gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h 44 | 45 | gzread.obj: gzread.c zlib.h zconf.h gzguts.h 46 | 47 | gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h 48 | 49 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 50 | inffast.h inffixed.h 51 | 52 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 53 | inffast.h 54 | 55 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 56 | inffast.h inffixed.h 57 | 58 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h 59 | 60 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h 61 | 62 | uncompr.obj: uncompr.c zlib.h zconf.h 63 | 64 | zutil.obj: zutil.c zutil.h zlib.h zconf.h 65 | 66 | example.obj: test/example.c zlib.h zconf.h 67 | 68 | minigzip.obj: test/minigzip.c zlib.h zconf.h 69 | 70 | 71 | # For the sake of the old Borland make, 72 | # the command line is cut to fit in the MS-DOS 128 byte limit: 73 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) 74 | -del $(ZLIB_LIB) 75 | $(AR) $(ZLIB_LIB) $(OBJP1) 76 | $(AR) $(ZLIB_LIB) $(OBJP2) 77 | 78 | 79 | # testing 80 | test: example.exe minigzip.exe 81 | example 82 | echo hello world | minigzip | minigzip -d 83 | 84 | example.exe: example.obj $(ZLIB_LIB) 85 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) 86 | 87 | minigzip.exe: minigzip.obj $(ZLIB_LIB) 88 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) 89 | 90 | 91 | # cleanup 92 | clean: 93 | -del *.obj 94 | -del *.exe 95 | -del *.lib 96 | -del *.tds 97 | -del zlib.bak 98 | -del foo.gz 99 | 100 | -------------------------------------------------------------------------------- /zlib/contrib/puff/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-O 2 | 3 | puff: puff.o pufftest.o 4 | 5 | puff.o: puff.h 6 | 7 | pufftest.o: puff.h 8 | 9 | test: puff 10 | puff zeros.raw 11 | 12 | puft: puff.c puff.h pufftest.o 13 | cc -fprofile-arcs -ftest-coverage -o puft puff.c pufftest.o 14 | 15 | # puff full coverage test (should say 100%) 16 | cov: puft 17 | @rm -f *.gcov *.gcda 18 | @puft -w zeros.raw 2>&1 | cat > /dev/null 19 | @echo '04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 20 | @echo '00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 21 | @echo '00 00 00 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 254 22 | @echo '00 01 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 23 | @echo '01 01 00 fe ff 0a' | xxd -r -p | puft -f 2>&1 | cat > /dev/null 24 | @echo '02 7e ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 25 | @echo '02' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 26 | @echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 27 | @echo '04 80 49 92 24 49 92 24 71 ff ff 93 11 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 249 28 | @echo '04 c0 81 08 00 00 00 00 20 7f eb 0b 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 29 | @echo '0b 00 00' | xxd -r -p | puft -f 2>&1 | cat > /dev/null 30 | @echo '1a 07' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 31 | @echo '0c c0 81 00 00 00 00 00 90 ff 6b 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 245 32 | @puft -f zeros.raw 2>&1 | cat > /dev/null 33 | @echo 'fc 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 253 34 | @echo '04 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 252 35 | @echo '04 00 24 49' | xxd -r -p | puft 2> /dev/null || test $$? -eq 251 36 | @echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 84' | xxd -r -p | puft 2> /dev/null || test $$? -eq 248 37 | @echo '04 00 24 e9 ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 250 38 | @echo '04 00 24 e9 ff 6d' | xxd -r -p | puft 2> /dev/null || test $$? -eq 247 39 | @gcov -n puff.c 40 | 41 | clean: 42 | rm -f puff puft *.o *.gc* 43 | -------------------------------------------------------------------------------- /zlib/contrib/puff/puff.h: -------------------------------------------------------------------------------- 1 | /* puff.h 2 | Copyright (C) 2002-2013 Mark Adler, all rights reserved 3 | version 2.3, 21 Jan 2013 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the author be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | Mark Adler madler@alumni.caltech.edu 22 | */ 23 | 24 | 25 | /* 26 | * See puff.c for purpose and usage. 27 | */ 28 | #ifndef NIL 29 | # define NIL ((unsigned char *)0) /* for no output option */ 30 | #endif 31 | 32 | int puff(unsigned char *dest, /* pointer to destination pointer */ 33 | unsigned long *destlen, /* amount of output space */ 34 | const unsigned char *source, /* pointer to source data pointer */ 35 | unsigned long *sourcelen); /* amount of input available */ 36 | -------------------------------------------------------------------------------- /zlib/contrib/puff/zeros.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/contrib/puff/zeros.raw -------------------------------------------------------------------------------- /zlib/contrib/testzlib/testzlib.txt: -------------------------------------------------------------------------------- 1 | To build testzLib with Visual Studio 2005: 2 | 3 | copy to a directory file from : 4 | - root of zLib tree 5 | - contrib/testzlib 6 | - contrib/masmx86 7 | - contrib/masmx64 8 | - contrib/vstudio/vc7 9 | 10 | and open testzlib8.sln -------------------------------------------------------------------------------- /zlib/contrib/untgz/Makefile: -------------------------------------------------------------------------------- 1 | CC=cc 2 | CFLAGS=-g 3 | 4 | untgz: untgz.o ../../libz.a 5 | $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz 6 | 7 | untgz.o: untgz.c ../../zlib.h 8 | $(CC) $(CFLAGS) -c -I../.. untgz.c 9 | 10 | ../../libz.a: 11 | cd ../..; ./configure; make 12 | 13 | clean: 14 | rm -f untgz untgz.o *~ 15 | -------------------------------------------------------------------------------- /zlib/contrib/untgz/Makefile.msc: -------------------------------------------------------------------------------- 1 | CC=cl 2 | CFLAGS=-MD 3 | 4 | untgz.exe: untgz.obj ..\..\zlib.lib 5 | $(CC) $(CFLAGS) untgz.obj ..\..\zlib.lib 6 | 7 | untgz.obj: untgz.c ..\..\zlib.h 8 | $(CC) $(CFLAGS) -c -I..\.. untgz.c 9 | 10 | ..\..\zlib.lib: 11 | cd ..\.. 12 | $(MAKE) -f win32\makefile.msc 13 | cd contrib\untgz 14 | 15 | clean: 16 | -del untgz.obj 17 | -del untgz.exe 18 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {048af943-022b-4db6-beeb-a54c34774ee2} 6 | cpp;c;cxx;def;odl;idl;hpj;bat 7 | 8 | 9 | {c1d600d2-888f-4aea-b73e-8b0dd9befa0c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {0844199a-966b-4f19-81db-1e0125e141b9} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc10/minizip.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {c0419b40-bf50-40da-b153-ff74215b79de} 6 | cpp;c;cxx;def;odl;idl;hpj;bat 7 | 8 | 9 | {bb87b070-735b-478e-92ce-7383abb2f36c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {f46ab6a6-548f-43cb-ae96-681abb5bd5db} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {c1f6a2e3-5da5-4955-8653-310d3efe05a9} 6 | cpp;c;cxx;def;odl;idl;hpj;bat 7 | 8 | 9 | {c2aaffdc-2c95-4d6f-8466-4bec5890af2c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {c274fe07-05f2-461c-964b-f6341e4e7eb5} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {fa61a89f-93fc-4c89-b29e-36224b7592f4} 6 | cpp;c;cxx;def;odl;idl;hpj;bat 7 | 8 | 9 | {d4b85da0-2ba2-4934-b57f-e2584e3848ee} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {e573e075-00bd-4a7d-bd67-a8cc9bfc5aca} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc10/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 3, 1, 1 6 | PRODUCTVERSION 1, 3, 1, 1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.3.1.1\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {174213f6-7f66-4ae8-a3a8-a1e0a1e6ffdd} 6 | 7 | 8 | 9 | 10 | Source Files 11 | 12 | 13 | Source Files 14 | 15 | 16 | Source Files 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | 65 | 66 | Source Files 67 | 68 | 69 | 70 | 71 | Source Files 72 | 73 | 74 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc11/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 3, 1, 1 6 | PRODUCTVERSION 1, 3, 1, 1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.3.1.1\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc12/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 3, 1, 1 6 | PRODUCTVERSION 1, 3, 1, 1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.3.1.1\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc14/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 3, 1, 1 6 | PRODUCTVERSION 1, 3, 1, 1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.3.1.1\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc17/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 3, 1, 1 6 | PRODUCTVERSION 1, 3, 1, 1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.3.1.1\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /zlib/contrib/vstudio/vc9/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 3, 1, 1 6 | PRODUCTVERSION 1, 3, 1, 1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.3.1.1\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /zlib/doc/crc-doc.1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/doc/crc-doc.1.0.pdf -------------------------------------------------------------------------------- /zlib/examples/README.examples: -------------------------------------------------------------------------------- 1 | This directory contains examples of the use of zlib and other relevant 2 | programs and documentation. 3 | 4 | enough.c 5 | calculation and justification of ENOUGH parameter in inftrees.h 6 | - calculates the maximum table space used in inflate tree 7 | construction over all possible Huffman codes 8 | 9 | fitblk.c 10 | compress just enough input to nearly fill a requested output size 11 | - zlib isn't designed to do this, but fitblk does it anyway 12 | 13 | gun.c 14 | uncompress a gzip file 15 | - illustrates the use of inflateBack() for high speed file-to-file 16 | decompression using call-back functions 17 | - is approximately twice as fast as gzip -d 18 | - also provides Unix uncompress functionality, again twice as fast 19 | 20 | gzappend.c 21 | append to a gzip file 22 | - illustrates the use of the Z_BLOCK flush parameter for inflate() 23 | - illustrates the use of deflatePrime() to start at any bit 24 | 25 | gzjoin.c 26 | join gzip files without recalculating the crc or recompressing 27 | - illustrates the use of the Z_BLOCK flush parameter for inflate() 28 | - illustrates the use of crc32_combine() 29 | 30 | gzlog.c 31 | gzlog.h 32 | efficiently and robustly maintain a message log file in gzip format 33 | - illustrates use of raw deflate, Z_PARTIAL_FLUSH, deflatePrime(), 34 | and deflateSetDictionary() 35 | - illustrates use of a gzip header extra field 36 | 37 | gznorm.c 38 | normalize a gzip file by combining members into a single member 39 | - demonstrates how to concatenate deflate streams using Z_BLOCK 40 | 41 | zlib_how.html 42 | painfully comprehensive description of zpipe.c (see below) 43 | - describes in excruciating detail the use of deflate() and inflate() 44 | 45 | zpipe.c 46 | reads and writes zlib streams from stdin to stdout 47 | - illustrates the proper use of deflate() and inflate() 48 | - deeply commented in zlib_how.html (see above) 49 | 50 | zran.c 51 | zran.h 52 | index a zlib or gzip stream and randomly access it 53 | - illustrates the use of Z_BLOCK, inflatePrime(), and 54 | inflateSetDictionary() to provide random access 55 | -------------------------------------------------------------------------------- /zlib/examples/zran.h: -------------------------------------------------------------------------------- 1 | /* zran.h -- example of deflated stream indexing and random access 2 | * Copyright (C) 2005, 2012, 2018, 2023, 2024 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | * Version 1.5 4 Feb 2024 Mark Adler */ 5 | 6 | #include 7 | #include "zlib.h" 8 | 9 | // Access point. 10 | typedef struct point { 11 | off_t out; // offset in uncompressed data 12 | off_t in; // offset in compressed file of first full byte 13 | int bits; // 0, or number of bits (1-7) from byte at in-1 14 | unsigned dict; // number of bytes in window to use as a dictionary 15 | unsigned char *window; // preceding 32K (or less) of uncompressed data 16 | } point_t; 17 | 18 | // Access point list. 19 | struct deflate_index { 20 | int have; // number of access points in list 21 | int mode; // -15 for raw, 15 for zlib, or 31 for gzip 22 | off_t length; // total length of uncompressed data 23 | point_t *list; // allocated list of access points 24 | z_stream strm; // re-usable inflate engine for extraction 25 | }; 26 | 27 | // Make one pass through a zlib, gzip, or raw deflate compressed stream and 28 | // build an index, with access points about every span bytes of uncompressed 29 | // output. gzip files with multiple members are fully indexed. span should be 30 | // chosen to balance the speed of random access against the memory requirements 31 | // of the list, which is about 32K bytes per access point. The return value is 32 | // the number of access points on success (>= 1), Z_MEM_ERROR for out of 33 | // memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format 34 | // or verification error in the input file, or Z_ERRNO for a file read error. 35 | // On success, *built points to the resulting index, otherwise it's NULL. 36 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built); 37 | 38 | // Use the index to read len bytes from offset into buf. Return the number of 39 | // bytes read or a negative error code. If data is requested past the end of 40 | // the uncompressed data, then deflate_index_extract() will return a value less 41 | // than len, indicating how much was actually read into buf. If given a valid 42 | // index, this function should not return an error unless the file was modified 43 | // somehow since the index was generated, given that deflate_index_build() had 44 | // validated all of the input. If nevertheless there is a failure, Z_BUF_ERROR 45 | // is returned if the compressed data ends prematurely, Z_DATA_ERROR if the 46 | // deflate compressed data is not valid, Z_MEM_ERROR if out of memory, 47 | // Z_STREAM_ERROR if the index is not valid, or Z_ERRNO if there is an error 48 | // reading or seeking on the input file. 49 | ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index, 50 | off_t offset, unsigned char *buf, size_t len); 51 | 52 | // Deallocate an index built by deflate_index_build(). 53 | void deflate_index_free(struct deflate_index *index); 54 | -------------------------------------------------------------------------------- /zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(gzFile file) { 12 | #ifndef NO_GZCOMPRESS 13 | gz_statep state; 14 | 15 | if (file == NULL) 16 | return Z_STREAM_ERROR; 17 | state = (gz_statep)file; 18 | 19 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 20 | #else 21 | return gzclose_r(file); 22 | #endif 23 | } 24 | -------------------------------------------------------------------------------- /zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); 12 | -------------------------------------------------------------------------------- /zlib/msdos/Makefile.emx: -------------------------------------------------------------------------------- 1 | # Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. 3 | # For conditions of distribution and use, see copyright notice in zlib.h 4 | 5 | # To compile, or to compile and test, type: 6 | # 7 | # make -fmakefile.emx; make test -fmakefile.emx 8 | # 9 | 10 | CC=gcc 11 | 12 | #CFLAGS=-MMD -O 13 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 14 | #CFLAGS=-MMD -g -DZLIB_DEBUG 15 | CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ 16 | -Wstrict-prototypes -Wmissing-prototypes 17 | 18 | # If cp.exe is available, replace "copy /Y" with "cp -fp" . 19 | CP=copy /Y 20 | # If gnu install.exe is available, replace $(CP) with ginstall. 21 | INSTALL=$(CP) 22 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: 23 | RM=del 24 | LDLIBS=-L. -lzlib 25 | LD=$(CC) -s -o 26 | LDSHARED=$(CC) 27 | 28 | INCL=zlib.h zconf.h 29 | LIBS=zlib.a 30 | 31 | AR=ar rcs 32 | 33 | prefix=/usr/local 34 | exec_prefix = $(prefix) 35 | 36 | OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ 37 | uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o 38 | 39 | TEST_OBJS = example.o minigzip.o 40 | 41 | all: example.exe minigzip.exe 42 | 43 | test: all 44 | ./example 45 | echo hello world | .\minigzip | .\minigzip -d 46 | 47 | %.o : %.c 48 | $(CC) $(CFLAGS) -c $< -o $@ 49 | 50 | zlib.a: $(OBJS) 51 | $(AR) $@ $(OBJS) 52 | 53 | %.exe : %.o $(LIBS) 54 | $(LD) $@ $< $(LDLIBS) 55 | 56 | 57 | .PHONY : clean 58 | 59 | clean: 60 | $(RM) *.d 61 | $(RM) *.o 62 | $(RM) *.exe 63 | $(RM) zlib.a 64 | $(RM) foo.gz 65 | 66 | DEPS := $(wildcard *.d) 67 | ifneq ($(DEPS),) 68 | include $(DEPS) 69 | endif 70 | -------------------------------------------------------------------------------- /zlib/nintendods/README: -------------------------------------------------------------------------------- 1 | This Makefile requires devkitARM (http://www.devkitpro.org/category/devkitarm/) and works inside "contrib/nds". It is based on a devkitARM template. 2 | 3 | Eduardo Costa 4 | January 3, 2009 5 | 6 | -------------------------------------------------------------------------------- /zlib/old/Makefile.emx: -------------------------------------------------------------------------------- 1 | # Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. 3 | # For conditions of distribution and use, see copyright notice in zlib.h 4 | 5 | # To compile, or to compile and test, type: 6 | # 7 | # make -fmakefile.emx; make test -fmakefile.emx 8 | # 9 | 10 | CC=gcc -Zwin32 11 | 12 | #CFLAGS=-MMD -O 13 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 14 | #CFLAGS=-MMD -g -DZLIB_DEBUG 15 | CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ 16 | -Wstrict-prototypes -Wmissing-prototypes 17 | 18 | # If cp.exe is available, replace "copy /Y" with "cp -fp" . 19 | CP=copy /Y 20 | # If gnu install.exe is available, replace $(CP) with ginstall. 21 | INSTALL=$(CP) 22 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: 23 | RM=del 24 | LDLIBS=-L. -lzlib 25 | LD=$(CC) -s -o 26 | LDSHARED=$(CC) 27 | 28 | INCL=zlib.h zconf.h 29 | LIBS=zlib.a 30 | 31 | AR=ar rcs 32 | 33 | prefix=/usr/local 34 | exec_prefix = $(prefix) 35 | 36 | OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ 37 | gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o 38 | 39 | TEST_OBJS = example.o minigzip.o 40 | 41 | all: example.exe minigzip.exe 42 | 43 | test: all 44 | ./example 45 | echo hello world | .\minigzip | .\minigzip -d 46 | 47 | %.o : %.c 48 | $(CC) $(CFLAGS) -c $< -o $@ 49 | 50 | zlib.a: $(OBJS) 51 | $(AR) $@ $(OBJS) 52 | 53 | %.exe : %.o $(LIBS) 54 | $(LD) $@ $< $(LDLIBS) 55 | 56 | 57 | .PHONY : clean 58 | 59 | clean: 60 | $(RM) *.d 61 | $(RM) *.o 62 | $(RM) *.exe 63 | $(RM) zlib.a 64 | $(RM) foo.gz 65 | 66 | DEPS := $(wildcard *.d) 67 | ifneq ($(DEPS),) 68 | include $(DEPS) 69 | endif 70 | -------------------------------------------------------------------------------- /zlib/old/README: -------------------------------------------------------------------------------- 1 | This directory contains files that have not been updated for zlib 1.2.x 2 | 3 | (Volunteers are encouraged to help clean this up. Thanks.) 4 | -------------------------------------------------------------------------------- /zlib/old/descrip.mms: -------------------------------------------------------------------------------- 1 | # descrip.mms: MMS description file for building zlib on VMS 2 | # written by Martin P.J. Zinser 3 | 4 | cc_defs = 5 | c_deb = 6 | 7 | .ifdef __DECC__ 8 | pref = /prefix=all 9 | .endif 10 | 11 | OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\ 12 | deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\ 13 | inftrees.obj, infcodes.obj, infutil.obj, inffast.obj 14 | 15 | CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) 16 | 17 | all : example.exe minigzip.exe 18 | @ write sys$output " Example applications available" 19 | libz.olb : libz.olb($(OBJS)) 20 | @ write sys$output " libz available" 21 | 22 | example.exe : example.obj libz.olb 23 | link example,libz.olb/lib 24 | 25 | minigzip.exe : minigzip.obj libz.olb 26 | link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib 27 | 28 | clean : 29 | delete *.obj;*,libz.olb;* 30 | 31 | 32 | # Other dependencies. 33 | adler32.obj : zutil.h zlib.h zconf.h 34 | compress.obj : zlib.h zconf.h 35 | crc32.obj : zutil.h zlib.h zconf.h 36 | deflate.obj : deflate.h zutil.h zlib.h zconf.h 37 | example.obj : zlib.h zconf.h 38 | gzio.obj : zutil.h zlib.h zconf.h 39 | infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h 40 | infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h 41 | inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h 42 | inflate.obj : zutil.h zlib.h zconf.h infblock.h 43 | inftrees.obj : zutil.h zlib.h zconf.h inftrees.h 44 | infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h 45 | minigzip.obj : zlib.h zconf.h 46 | trees.obj : deflate.h zutil.h zlib.h zconf.h 47 | uncompr.obj : zlib.h zconf.h 48 | zutil.obj : zutil.h zlib.h zconf.h 49 | -------------------------------------------------------------------------------- /zlib/old/os2/zlib.def: -------------------------------------------------------------------------------- 1 | ; 2 | ; Slightly modified version of ../nt/zlib.dnt :-) 3 | ; 4 | 5 | LIBRARY Z 6 | DESCRIPTION "Zlib compression library for OS/2" 7 | CODE PRELOAD MOVEABLE DISCARDABLE 8 | DATA PRELOAD MOVEABLE MULTIPLE 9 | 10 | EXPORTS 11 | adler32 12 | compress 13 | crc32 14 | deflate 15 | deflateCopy 16 | deflateEnd 17 | deflateInit2_ 18 | deflateInit_ 19 | deflateParams 20 | deflateReset 21 | deflateSetDictionary 22 | gzclose 23 | gzdopen 24 | gzerror 25 | gzflush 26 | gzopen 27 | gzread 28 | gzwrite 29 | inflate 30 | inflateEnd 31 | inflateInit2_ 32 | inflateInit_ 33 | inflateReset 34 | inflateSetDictionary 35 | inflateSync 36 | uncompress 37 | zlibVersion 38 | gzprintf 39 | gzputc 40 | gzgetc 41 | gzseek 42 | gzrewind 43 | gztell 44 | gzeof 45 | gzsetparams 46 | zError 47 | inflateSyncPoint 48 | get_crc_table 49 | compress2 50 | gzputs 51 | gzgets 52 | -------------------------------------------------------------------------------- /zlib/os400/README400: -------------------------------------------------------------------------------- 1 | ZLIB version 1.3.1.1 for OS/400 installation instructions 2 | 3 | 1) Download and unpack the zlib tarball to some IFS directory. 4 | (i.e.: /path/to/the/zlib/ifs/source/directory) 5 | 6 | If the installed IFS command supports gzip format, this is straightforward, 7 | else you have to unpack first to some directory on a system supporting it, 8 | then move the whole directory to the IFS via the network (via SMB or FTP). 9 | 10 | 2) Edit the configuration parameters in the compilation script. 11 | 12 | EDTF STMF('/path/to/the/zlib/ifs/source/directory/os400/make.sh') 13 | 14 | Tune the parameters according to your needs if not matching the defaults. 15 | Save the file and exit after edition. 16 | 17 | 3) Enter qshell, then work in the zlib OS/400 specific directory. 18 | 19 | QSH 20 | cd /path/to/the/zlib/ifs/source/directory/os400 21 | 22 | 4) Compile and install 23 | 24 | sh make.sh 25 | 26 | The script will: 27 | - create the libraries, objects and IFS directories for the zlib environment, 28 | - compile all modules, 29 | - create a service program, 30 | - create a static and a dynamic binding directory, 31 | - install header files for C/C++ and for ILE/RPG, both for compilation in 32 | DB2 and IFS environments. 33 | 34 | That's all. 35 | 36 | 37 | Notes: For OS/400 ILE RPG programmers, a /copy member defining the ZLIB 38 | API prototypes for ILE RPG can be found in ZLIB/H(ZLIB.INC). 39 | In the ILE environment, the same definitions are available from 40 | file zlib.inc located in the same IFS include directory as the 41 | C/C++ header files. 42 | Please read comments in this member for more information. 43 | 44 | Remember that most foreign textual data are ASCII coded: this 45 | implementation does not handle conversion from/to ASCII, so 46 | text data code conversions must be done explicitly. 47 | 48 | Mainly for the reason above, always open zipped files in binary mode. 49 | -------------------------------------------------------------------------------- /zlib/watcom/watcom_f.mak: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # OpenWatcom flat model 3 | # Last updated: 28-Dec-2005 4 | 5 | # To use, do "wmake -f watcom_f.mak" 6 | 7 | C_SOURCE = adler32.c compress.c crc32.c deflate.c & 8 | gzclose.c gzlib.c gzread.c gzwrite.c & 9 | infback.c inffast.c inflate.c inftrees.c & 10 | trees.c uncompr.c zutil.c 11 | 12 | OBJS = adler32.obj compress.obj crc32.obj deflate.obj & 13 | gzclose.obj gzlib.obj gzread.obj gzwrite.obj & 14 | infback.obj inffast.obj inflate.obj inftrees.obj & 15 | trees.obj uncompr.obj zutil.obj 16 | 17 | CC = wcc386 18 | LINKER = wcl386 19 | CFLAGS = -zq -mf -3r -fp3 -s -bt=dos -oilrtfm -fr=nul -wx 20 | ZLIB_LIB = zlib_f.lib 21 | 22 | .C.OBJ: 23 | $(CC) $(CFLAGS) $[@ 24 | 25 | all: $(ZLIB_LIB) example.exe minigzip.exe 26 | 27 | $(ZLIB_LIB): $(OBJS) 28 | wlib -b -c $(ZLIB_LIB) -+adler32.obj -+compress.obj -+crc32.obj 29 | wlib -b -c $(ZLIB_LIB) -+gzclose.obj -+gzlib.obj -+gzread.obj -+gzwrite.obj 30 | wlib -b -c $(ZLIB_LIB) -+deflate.obj -+infback.obj 31 | wlib -b -c $(ZLIB_LIB) -+inffast.obj -+inflate.obj -+inftrees.obj 32 | wlib -b -c $(ZLIB_LIB) -+trees.obj -+uncompr.obj -+zutil.obj 33 | 34 | example.exe: $(ZLIB_LIB) example.obj 35 | $(LINKER) -ldos32a -fe=example.exe example.obj $(ZLIB_LIB) 36 | 37 | minigzip.exe: $(ZLIB_LIB) minigzip.obj 38 | $(LINKER) -ldos32a -fe=minigzip.exe minigzip.obj $(ZLIB_LIB) 39 | 40 | clean: .SYMBOLIC 41 | del *.obj 42 | del $(ZLIB_LIB) 43 | @echo Cleaning done 44 | -------------------------------------------------------------------------------- /zlib/watcom/watcom_l.mak: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # OpenWatcom large model 3 | # Last updated: 28-Dec-2005 4 | 5 | # To use, do "wmake -f watcom_l.mak" 6 | 7 | C_SOURCE = adler32.c compress.c crc32.c deflate.c & 8 | gzclose.c gzlib.c gzread.c gzwrite.c & 9 | infback.c inffast.c inflate.c inftrees.c & 10 | trees.c uncompr.c zutil.c 11 | 12 | OBJS = adler32.obj compress.obj crc32.obj deflate.obj & 13 | gzclose.obj gzlib.obj gzread.obj gzwrite.obj & 14 | infback.obj inffast.obj inflate.obj inftrees.obj & 15 | trees.obj uncompr.obj zutil.obj 16 | 17 | CC = wcc 18 | LINKER = wcl 19 | CFLAGS = -zq -ml -s -bt=dos -oilrtfm -fr=nul -wx 20 | ZLIB_LIB = zlib_l.lib 21 | 22 | .C.OBJ: 23 | $(CC) $(CFLAGS) $[@ 24 | 25 | all: $(ZLIB_LIB) example.exe minigzip.exe 26 | 27 | $(ZLIB_LIB): $(OBJS) 28 | wlib -b -c $(ZLIB_LIB) -+adler32.obj -+compress.obj -+crc32.obj 29 | wlib -b -c $(ZLIB_LIB) -+gzclose.obj -+gzlib.obj -+gzread.obj -+gzwrite.obj 30 | wlib -b -c $(ZLIB_LIB) -+deflate.obj -+infback.obj 31 | wlib -b -c $(ZLIB_LIB) -+inffast.obj -+inflate.obj -+inftrees.obj 32 | wlib -b -c $(ZLIB_LIB) -+trees.obj -+uncompr.obj -+zutil.obj 33 | 34 | example.exe: $(ZLIB_LIB) example.obj 35 | $(LINKER) -fe=example.exe example.obj $(ZLIB_LIB) 36 | 37 | minigzip.exe: $(ZLIB_LIB) minigzip.obj 38 | $(LINKER) -fe=minigzip.exe minigzip.obj $(ZLIB_LIB) 39 | 40 | clean: .SYMBOLIC 41 | del *.obj 42 | del $(ZLIB_LIB) 43 | @echo Cleaning done 44 | -------------------------------------------------------------------------------- /zlib/win32/Makefile.bor: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # Borland C++ for Win32 3 | # 4 | # Usage: 5 | # make -f win32/Makefile.bor 6 | 7 | # ------------ Borland C++ ------------ 8 | 9 | # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) 10 | # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or 11 | # added to the declaration of LOC here: 12 | LOC = $(LOCAL_ZLIB) 13 | 14 | CC = bcc32 15 | AS = bcc32 16 | LD = bcc32 17 | AR = tlib 18 | CFLAGS = -a -d -k- -O2 $(LOC) 19 | ASFLAGS = $(LOC) 20 | LDFLAGS = $(LOC) 21 | 22 | 23 | # variables 24 | ZLIB_LIB = zlib.lib 25 | 26 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj 27 | OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj 28 | #OBJA = 29 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj 30 | OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj 31 | #OBJPA= 32 | 33 | 34 | # targets 35 | all: $(ZLIB_LIB) example.exe minigzip.exe 36 | 37 | .c.obj: 38 | $(CC) -c $(CFLAGS) $< 39 | 40 | .asm.obj: 41 | $(AS) -c $(ASFLAGS) $< 42 | 43 | adler32.obj: adler32.c zlib.h zconf.h 44 | 45 | compress.obj: compress.c zlib.h zconf.h 46 | 47 | crc32.obj: crc32.c zlib.h zconf.h crc32.h 48 | 49 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h 50 | 51 | gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h 52 | 53 | gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h 54 | 55 | gzread.obj: gzread.c zlib.h zconf.h gzguts.h 56 | 57 | gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h 58 | 59 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 60 | inffast.h inffixed.h 61 | 62 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 63 | inffast.h 64 | 65 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 66 | inffast.h inffixed.h 67 | 68 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h 69 | 70 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h 71 | 72 | uncompr.obj: uncompr.c zlib.h zconf.h 73 | 74 | zutil.obj: zutil.c zutil.h zlib.h zconf.h 75 | 76 | example.obj: test/example.c zlib.h zconf.h 77 | 78 | minigzip.obj: test/minigzip.c zlib.h zconf.h 79 | 80 | 81 | # For the sake of the old Borland make, 82 | # the command line is cut to fit in the MS-DOS 128 byte limit: 83 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) $(OBJA) 84 | -del $(ZLIB_LIB) 85 | $(AR) $(ZLIB_LIB) $(OBJP1) 86 | $(AR) $(ZLIB_LIB) $(OBJP2) 87 | $(AR) $(ZLIB_LIB) $(OBJPA) 88 | 89 | 90 | # testing 91 | test: example.exe minigzip.exe 92 | example 93 | echo hello world | minigzip | minigzip -d 94 | 95 | example.exe: example.obj $(ZLIB_LIB) 96 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) 97 | 98 | minigzip.exe: minigzip.obj $(ZLIB_LIB) 99 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) 100 | 101 | 102 | # cleanup 103 | clean: 104 | -del $(ZLIB_LIB) 105 | -del *.obj 106 | -del *.exe 107 | -del *.tds 108 | -del zlib.bak 109 | -del foo.gz 110 | -------------------------------------------------------------------------------- /zlib/win32/VisualC.txt: -------------------------------------------------------------------------------- 1 | 2 | To build zlib using the Microsoft Visual C++ environment, 3 | use the appropriate project from the contrib/vstudio/ directory. 4 | -------------------------------------------------------------------------------- /zlib/win32/zlib.def: -------------------------------------------------------------------------------- 1 | ; zlib data compression library 2 | EXPORTS 3 | ; basic functions 4 | zlibVersion 5 | deflate 6 | deflateEnd 7 | inflate 8 | inflateEnd 9 | ; advanced functions 10 | deflateSetDictionary 11 | deflateGetDictionary 12 | deflateCopy 13 | deflateReset 14 | deflateParams 15 | deflateTune 16 | deflateBound 17 | deflatePending 18 | deflatePrime 19 | deflateSetHeader 20 | inflateSetDictionary 21 | inflateGetDictionary 22 | inflateSync 23 | inflateCopy 24 | inflateReset 25 | inflateReset2 26 | inflatePrime 27 | inflateMark 28 | inflateGetHeader 29 | inflateBack 30 | inflateBackEnd 31 | zlibCompileFlags 32 | ; utility functions 33 | compress 34 | compress2 35 | compressBound 36 | uncompress 37 | uncompress2 38 | gzopen 39 | gzdopen 40 | gzbuffer 41 | gzsetparams 42 | gzread 43 | gzfread 44 | gzwrite 45 | gzfwrite 46 | gzprintf 47 | gzvprintf 48 | gzputs 49 | gzgets 50 | gzputc 51 | gzgetc 52 | gzungetc 53 | gzflush 54 | gzseek 55 | gzrewind 56 | gztell 57 | gzoffset 58 | gzeof 59 | gzdirect 60 | gzclose 61 | gzclose_r 62 | gzclose_w 63 | gzerror 64 | gzclearerr 65 | ; large file functions 66 | gzopen64 67 | gzseek64 68 | gztell64 69 | gzoffset64 70 | adler32_combine64 71 | crc32_combine64 72 | crc32_combine_gen64 73 | ; checksum functions 74 | adler32 75 | adler32_z 76 | crc32 77 | crc32_z 78 | adler32_combine 79 | crc32_combine 80 | crc32_combine_gen 81 | crc32_combine_op 82 | ; various hacks, don't look :) 83 | deflateInit_ 84 | deflateInit2_ 85 | inflateInit_ 86 | inflateInit2_ 87 | inflateBackInit_ 88 | gzgetc_ 89 | zError 90 | inflateSyncPoint 91 | get_crc_table 92 | inflateUndermine 93 | inflateValidate 94 | inflateCodesUsed 95 | inflateResetKeep 96 | deflateResetKeep 97 | gzopen_w 98 | -------------------------------------------------------------------------------- /zlib/win32/zlib1.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../zlib.h" 3 | 4 | #ifdef GCC_WINDRES 5 | VS_VERSION_INFO VERSIONINFO 6 | #else 7 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 8 | #endif 9 | FILEVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 10 | PRODUCTVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 11 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 12 | #ifdef _DEBUG 13 | FILEFLAGS 1 14 | #else 15 | FILEFLAGS 0 16 | #endif 17 | FILEOS VOS__WINDOWS32 18 | FILETYPE VFT_DLL 19 | FILESUBTYPE 0 // not used 20 | BEGIN 21 | BLOCK "StringFileInfo" 22 | BEGIN 23 | BLOCK "040904E4" 24 | //language ID = U.S. English, char set = Windows, Multilingual 25 | BEGIN 26 | VALUE "FileDescription", "zlib data compression library\0" 27 | VALUE "FileVersion", ZLIB_VERSION "\0" 28 | VALUE "InternalName", "zlib1.dll\0" 29 | VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" 30 | VALUE "OriginalFilename", "zlib1.dll\0" 31 | VALUE "ProductName", "zlib\0" 32 | VALUE "ProductVersion", ZLIB_VERSION "\0" 33 | VALUE "Comments", "For more information visit http://www.zlib.net/\0" 34 | END 35 | END 36 | BLOCK "VarFileInfo" 37 | BEGIN 38 | VALUE "Translation", 0x0409, 1252 39 | END 40 | END 41 | -------------------------------------------------------------------------------- /zlib/zlib.3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/quark/dbff15aa5fb0174b65d1e42ed5a2ecf51c182dd1/zlib/zlib.3.pdf -------------------------------------------------------------------------------- /zlib/zlib.map: -------------------------------------------------------------------------------- 1 | ZLIB_1.2.0 { 2 | global: 3 | compressBound; 4 | deflateBound; 5 | inflateBack; 6 | inflateBackEnd; 7 | inflateBackInit_; 8 | inflateCopy; 9 | local: 10 | deflate_copyright; 11 | inflate_copyright; 12 | inflate_fast; 13 | inflate_table; 14 | zcalloc; 15 | zcfree; 16 | z_errmsg; 17 | gz_error; 18 | gz_intmax; 19 | _*; 20 | }; 21 | 22 | ZLIB_1.2.0.2 { 23 | gzclearerr; 24 | gzungetc; 25 | zlibCompileFlags; 26 | } ZLIB_1.2.0; 27 | 28 | ZLIB_1.2.0.8 { 29 | deflatePrime; 30 | } ZLIB_1.2.0.2; 31 | 32 | ZLIB_1.2.2 { 33 | adler32_combine; 34 | crc32_combine; 35 | deflateSetHeader; 36 | inflateGetHeader; 37 | } ZLIB_1.2.0.8; 38 | 39 | ZLIB_1.2.2.3 { 40 | deflateTune; 41 | gzdirect; 42 | } ZLIB_1.2.2; 43 | 44 | ZLIB_1.2.2.4 { 45 | inflatePrime; 46 | } ZLIB_1.2.2.3; 47 | 48 | ZLIB_1.2.3.3 { 49 | adler32_combine64; 50 | crc32_combine64; 51 | gzopen64; 52 | gzseek64; 53 | gztell64; 54 | inflateUndermine; 55 | } ZLIB_1.2.2.4; 56 | 57 | ZLIB_1.2.3.4 { 58 | inflateReset2; 59 | inflateMark; 60 | } ZLIB_1.2.3.3; 61 | 62 | ZLIB_1.2.3.5 { 63 | gzbuffer; 64 | gzoffset; 65 | gzoffset64; 66 | gzclose_r; 67 | gzclose_w; 68 | } ZLIB_1.2.3.4; 69 | 70 | ZLIB_1.2.5.1 { 71 | deflatePending; 72 | } ZLIB_1.2.3.5; 73 | 74 | ZLIB_1.2.5.2 { 75 | deflateResetKeep; 76 | gzgetc_; 77 | inflateResetKeep; 78 | } ZLIB_1.2.5.1; 79 | 80 | ZLIB_1.2.7.1 { 81 | inflateGetDictionary; 82 | gzvprintf; 83 | } ZLIB_1.2.5.2; 84 | 85 | ZLIB_1.2.9 { 86 | inflateCodesUsed; 87 | inflateValidate; 88 | uncompress2; 89 | gzfread; 90 | gzfwrite; 91 | deflateGetDictionary; 92 | adler32_z; 93 | crc32_z; 94 | } ZLIB_1.2.7.1; 95 | 96 | ZLIB_1.2.12 { 97 | crc32_combine_gen; 98 | crc32_combine_gen64; 99 | crc32_combine_op; 100 | } ZLIB_1.2.9; 101 | -------------------------------------------------------------------------------- /zlib/zlib.pc: -------------------------------------------------------------------------------- 1 | prefix=/usr/local 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | sharedlibdir=${libdir} 5 | includedir=${prefix}/include 6 | 7 | Name: zlib 8 | Description: zlib compression library 9 | Version: 1.3.1.1-motley 10 | 11 | Requires: 12 | Libs: -L${libdir} -L${sharedlibdir} -lz 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /zlib/zlib.pc.cmakein: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=@INSTALL_LIB_DIR@ 4 | sharedlibdir=@INSTALL_LIB_DIR@ 5 | includedir=@INSTALL_INC_DIR@ 6 | 7 | Name: zlib 8 | Description: zlib compression library 9 | Version: @VERSION@ 10 | 11 | Requires: 12 | Libs: -L${libdir} -L${sharedlibdir} -lz 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /zlib/zlib.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | sharedlibdir=@sharedlibdir@ 5 | includedir=@includedir@ 6 | 7 | Name: zlib 8 | Description: zlib compression library 9 | Version: @VERSION@ 10 | 11 | Requires: 12 | Libs: -L${libdir} -L${sharedlibdir} -lz 13 | Cflags: -I${includedir} 14 | --------------------------------------------------------------------------------