initial: nsUnz plugin 1.0.0
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{yml,yaml,json}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{cmd,bat,ps1}]
|
||||
end_of_line = crlf
|
||||
|
||||
[*.{nsi,nsh,sln,vcxproj,filters}]
|
||||
end_of_line = crlf
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
@@ -0,0 +1,52 @@
|
||||
# Normalizzazione line endings
|
||||
* text=auto eol=lf
|
||||
|
||||
# File di codice
|
||||
*.c text eol=lf
|
||||
*.cpp text eol=lf
|
||||
*.h text eol=lf
|
||||
*.hpp text eol=lf
|
||||
*.def text eol=lf
|
||||
*.py text eol=lf
|
||||
*.ps1 text eol=lf
|
||||
*.cmd text eol=crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
# NSIS
|
||||
*.nsi text eol=crlf
|
||||
*.nsh text eol=crlf
|
||||
|
||||
# Markdown / docs / config
|
||||
*.md text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.yaml text eol=lf
|
||||
*.json text eol=lf
|
||||
*.txt text eol=lf
|
||||
*.xml text eol=lf
|
||||
|
||||
# Visual Studio (CRLF richiesto)
|
||||
*.sln text eol=crlf
|
||||
*.vcxproj text eol=crlf merge=union
|
||||
*.filters text eol=crlf merge=union
|
||||
*.rc binary
|
||||
*.rc2 binary
|
||||
|
||||
# Binari
|
||||
*.dll binary
|
||||
*.exe binary
|
||||
*.lib binary
|
||||
*.obj binary
|
||||
*.pdb binary
|
||||
*.zip binary
|
||||
*.7z binary
|
||||
*.png binary
|
||||
*.ico binary
|
||||
*.gif binary
|
||||
*.jpg binary
|
||||
*.jpeg binary
|
||||
*.bmp binary
|
||||
*.pdf binary
|
||||
|
||||
# Linguistic detection (GitHub Linguist / Gitea analogo)
|
||||
*.nsi linguist-language=NSIS
|
||||
*.nsh linguist-language=NSIS
|
||||
@@ -0,0 +1,76 @@
|
||||
name: Bug Report
|
||||
description: Segnala un bug riproducibile
|
||||
title: "[Bug]: "
|
||||
labels: ["bug", "triage"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Grazie per la segnalazione. Compila i campi sotto per aiutarci a riprodurre il problema.
|
||||
|
||||
- type: input
|
||||
id: plugin-version
|
||||
attributes:
|
||||
label: Versione plugin
|
||||
description: Contenuto del file VERSION o tag della release scaricata
|
||||
placeholder: "1.6.0"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: architecture
|
||||
attributes:
|
||||
label: Architettura DLL usata
|
||||
options:
|
||||
- x86-ansi
|
||||
- x86-unicode
|
||||
- amd64-unicode
|
||||
- non so / multiple
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: nsis-version
|
||||
attributes:
|
||||
label: Versione NSIS
|
||||
placeholder: "3.10"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: os
|
||||
attributes:
|
||||
label: Sistema operativo
|
||||
placeholder: "Windows 11 23H2 x64"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: repro
|
||||
attributes:
|
||||
label: Passi per riprodurre
|
||||
description: Script .nsi minimale che riproduce il problema
|
||||
render: nsis
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Comportamento atteso
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: Comportamento osservato
|
||||
description: Includi messaggi di errore esatti, output del log NSIS, screenshot
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: additional
|
||||
attributes:
|
||||
label: Note aggiuntive
|
||||
description: Qualunque altra informazione utile (workaround tentati, ecc.)
|
||||
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Domande generali
|
||||
url: https://gitea.emulab.it/Simone/nsis-plugin-nsunz/issues?type=question
|
||||
about: Per domande di utilizzo che non sono bug, apri una issue con label "question"
|
||||
- name: Security
|
||||
url: https://gitea.emulab.it/Simone/nsis-plugin-nsunz/security/advisories/new
|
||||
about: Segnala vulnerabilità di security in privato (non aprire issue pubbliche)
|
||||
@@ -0,0 +1,32 @@
|
||||
name: Feature Request
|
||||
description: Suggerisci una nuova funzionalità o miglioramento
|
||||
title: "[Feature]: "
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Problema / Caso d'uso
|
||||
description: Quale problema vorresti risolvere? Quale workflow vuoi abilitare?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: proposal
|
||||
attributes:
|
||||
label: Proposta
|
||||
description: Come dovrebbe funzionare? Includi esempio di API/uso negli script NSIS se possibile.
|
||||
render: nsis
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternative considerate
|
||||
description: Altri approcci che hai valutato e perché sono stati scartati
|
||||
|
||||
- type: textarea
|
||||
id: additional
|
||||
attributes:
|
||||
label: Note aggiuntive
|
||||
@@ -0,0 +1,31 @@
|
||||
## Descrizione
|
||||
|
||||
<!-- Descrivi cosa cambia questa PR e perché. Riferisci issue se applicabile (Closes #XXX). -->
|
||||
|
||||
## Tipo di Modifica
|
||||
|
||||
- [ ] Bug fix (modifica non breaking che risolve un problema)
|
||||
- [ ] Feature (modifica non breaking che aggiunge funzionalità)
|
||||
- [ ] Breaking change (fix o feature che rompe la compatibilità)
|
||||
- [ ] Documentazione
|
||||
- [ ] Build / CI
|
||||
|
||||
## Architetture Testate
|
||||
|
||||
- [ ] `x86-ansi`
|
||||
- [ ] `x86-unicode`
|
||||
- [ ] `amd64-unicode`
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] Build completa senza warning: `python build_plugin.py`
|
||||
- [ ] CHANGELOG.md aggiornato (sezione `[Unreleased]`)
|
||||
- [ ] README / docs aggiornati se l'API è cambiata
|
||||
- [ ] Esempi aggiornati se l'API è cambiata
|
||||
- [ ] Conventional Commits rispettato
|
||||
- [ ] Nessun file in `dist/` o `__pycache__/` committato
|
||||
- [ ] Self-review completata
|
||||
|
||||
## Note Aggiuntive
|
||||
|
||||
<!-- Eventuali considerazioni per i reviewer, screenshot, output di test, ecc. -->
|
||||
@@ -0,0 +1,63 @@
|
||||
# Build (GitHub) — pipeline CI primaria
|
||||
#
|
||||
# Strategia hosting:
|
||||
# - Repo primario su Gitea (push iniziale)
|
||||
# - Push mirror automatico Gitea -> GitHub
|
||||
# - GitHub esegue TUTTA la CI (Gitea non esegue Actions)
|
||||
#
|
||||
# Trigger:
|
||||
# - push su main (incluso quello propagato dal mirror Gitea)
|
||||
# - PR aperte su GitHub
|
||||
# - run manuale via UI
|
||||
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
- 'examples/**'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config: [x86-ansi, x86-unicode, x64-unicode]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
|
||||
- name: Read VERSION
|
||||
id: version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$v = (Get-Content VERSION -Raw).Trim()
|
||||
"version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
||||
|
||||
- name: Build ${{ matrix.config }}
|
||||
run: python build_plugin.py --configs ${{ matrix.config }}
|
||||
|
||||
- name: Upload DLL
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ github.event.repository.name }}-${{ steps.version.outputs.version }}-${{ matrix.config }}
|
||||
path: dist/**
|
||||
if-no-files-found: error
|
||||
retention-days: 30
|
||||
@@ -0,0 +1,99 @@
|
||||
# Release (GitHub) — pipeline release primaria
|
||||
#
|
||||
# Triggerata quando un tag v* viene propagato dal mirror Gitea.
|
||||
# Costruisce gli artifact per tutte le architetture e crea la GitHub Release.
|
||||
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag versione (es. v1.7.0)'
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
config: [x86-ansi, x86-unicode, x64-unicode]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- uses: microsoft/setup-msbuild@v2
|
||||
|
||||
- name: Build ${{ matrix.config }}
|
||||
run: python build_plugin.py --configs ${{ matrix.config }}
|
||||
|
||||
- name: Determine version & arch
|
||||
id: meta
|
||||
shell: pwsh
|
||||
run: |
|
||||
$tag = "${{ github.ref_name }}"
|
||||
if ([string]::IsNullOrEmpty($tag) -or $tag -eq "main") { $tag = "${{ inputs.tag }}" }
|
||||
$v = $tag -replace '^v',''
|
||||
$map = @{ 'x86-ansi' = 'x86-ansi'; 'x86-unicode' = 'x86-unicode'; 'x64-unicode' = 'amd64-unicode' }
|
||||
$dir = $map['${{ matrix.config }}']
|
||||
echo "version=$v" >> $env:GITHUB_OUTPUT
|
||||
echo "tag=$tag" >> $env:GITHUB_OUTPUT
|
||||
echo "dir=$dir" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: Package
|
||||
shell: pwsh
|
||||
run: |
|
||||
$name = "${{ github.event.repository.name }}-${{ steps.meta.outputs.version }}-${{ steps.meta.outputs.dir }}"
|
||||
$stage = "stage/$name"
|
||||
New-Item -ItemType Directory -Force -Path $stage | Out-Null
|
||||
Copy-Item "dist/${{ steps.meta.outputs.dir }}/*" $stage -Recurse
|
||||
Copy-Item README.md, LICENSE, VERSION, CHANGELOG.md $stage
|
||||
if (Test-Path "include") { Copy-Item "include" $stage -Recurse }
|
||||
if (Test-Path "examples") { Copy-Item "examples" $stage -Recurse }
|
||||
Compress-Archive -Path "$stage/*" -DestinationPath "$name.zip" -Force
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: pkg-${{ matrix.config }}
|
||||
path: '*.zip'
|
||||
|
||||
publish:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
|
||||
- name: SHA256SUMS
|
||||
run: |
|
||||
cd artifacts
|
||||
sha256sum *.zip > SHA256SUMS.txt
|
||||
cat SHA256SUMS.txt
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
artifacts/*.zip
|
||||
artifacts/SHA256SUMS.txt
|
||||
generate_release_notes: true
|
||||
body: |
|
||||
**Repository primario**: vedi link Gitea nel README.
|
||||
|
||||
Il mirror GitHub è generato automaticamente dal repo Gitea (sorgente di verità).
|
||||
Per issue e PR aprire ticket sul repository primario Gitea.
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
# Build output (src/ subdirs only — dist/ is tracked, contains pre-built DLLs)
|
||||
bin/
|
||||
obj/
|
||||
Build/
|
||||
build/
|
||||
|
||||
# Visual Studio
|
||||
*.user
|
||||
*.suo
|
||||
*.ncb
|
||||
*.sdf
|
||||
.vs/
|
||||
ipch/
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
*.opendb
|
||||
*.aps
|
||||
*.tlog
|
||||
*.idb
|
||||
*.pdb
|
||||
*.ilk
|
||||
*.exp
|
||||
*.lib
|
||||
*.obj
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
.pytest_cache/
|
||||
*.egg-info/
|
||||
.venv/
|
||||
venv/
|
||||
|
||||
# Editor / IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS
|
||||
Thumbs.db
|
||||
desktop.ini
|
||||
.DS_Store
|
||||
|
||||
# NSIS
|
||||
*.nsh.bak
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
.logs/
|
||||
|
||||
# Sensitive
|
||||
.env
|
||||
.env.local
|
||||
*.pem
|
||||
*.key
|
||||
|
||||
# Migration/automation scripts (temporary, contain tokens — never commit)
|
||||
tools/t*.py
|
||||
tools/check_*.py
|
||||
tools/legacy/
|
||||
@@ -0,0 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
Tutte le modifiche rilevanti a questo progetto sono documentate in questo file.
|
||||
|
||||
Il formato segue [Keep a Changelog](https://keepachangelog.com/it/1.0.0/),
|
||||
e il progetto aderisce al [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.0.0] — 2026-04-29
|
||||
|
||||
### Added
|
||||
- Prima release come repository indipendente
|
||||
- Build script unificato (`build_plugin.py`) con CLI canonica
|
||||
- CI/CD via GitHub Actions (mirror automatico Gitea → GitHub)
|
||||
- Documentazione completa (README, CONTRIBUTING, SECURITY)
|
||||
|
||||
[Unreleased]: https://gitea.emulab.it/Simone/nsis-plugin-nsunz/compare/v1.0.0...HEAD
|
||||
[1.0.0]: https://gitea.emulab.it/Simone/nsis-plugin-nsunz/releases/tag/v1.0.0
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
# Contribuire a nsUnz
|
||||
|
||||
Grazie per il tuo interesse a contribuire!
|
||||
|
||||
> Repository primario: [https://gitea.emulab.it/Simone/nsis-plugin-nsunz](https://gitea.emulab.it/Simone/nsis-plugin-nsunz)
|
||||
> Mirror GitHub: [https://github.com/systempal/nsis-plugin-nsunz](https://github.com/systempal/nsis-plugin-nsunz) (read-only — apri PR su Gitea)
|
||||
|
||||
## Prerequisiti
|
||||
|
||||
| Strumento | Versione | Note |
|
||||
|-----------|----------|------|
|
||||
| Visual Studio | 2022 / 2026 | Workload: Desktop development with C++ (toolset v143/v145) |
|
||||
| Python | 3.7+ | Per `build_plugin.py` |
|
||||
| Git | 2.30+ | Con supporto submoduli se applicabile |
|
||||
|
||||
## Quick Start
|
||||
|
||||
```powershell
|
||||
git clone https://gitea.emulab.it/Simone/nsis-plugin-nsunz.git
|
||||
cd nsis-plugin-nsunz
|
||||
python build_plugin.py
|
||||
```
|
||||
|
||||
Output in `dist/{x86-ansi,x86-unicode,amd64-unicode}/`.
|
||||
|
||||
## Workflow Sviluppo
|
||||
|
||||
### 1. Branch
|
||||
|
||||
```powershell
|
||||
git checkout -b feat/nome-feature # nuova feature
|
||||
git checkout -b fix/descrizione-bug # bugfix
|
||||
git checkout -b docs/aggiornamento # solo doc
|
||||
git checkout -b chore/manutenzione # build, dipendenze
|
||||
```
|
||||
|
||||
### 2. Commit
|
||||
|
||||
Segui [Conventional Commits](https://www.conventionalcommits.org/it/v1.0.0/):
|
||||
|
||||
```
|
||||
feat: aggiunge supporto per formato XYZ
|
||||
fix: corregge crash su Windows 11 ARM
|
||||
docs: aggiorna esempio di utilizzo
|
||||
chore: aggiorna toolset MSVC
|
||||
refactor: estrae logica parsing in funzione separata
|
||||
test: aggiunge test per edge case
|
||||
build: aggiorna script di build
|
||||
ci: aggiorna workflow GitHub Actions
|
||||
```
|
||||
|
||||
Breaking changes:
|
||||
|
||||
```
|
||||
feat!: rinomina API Foo() in Bar()
|
||||
|
||||
BREAKING CHANGE: Foo() rinominata in Bar(); aggiornare tutti i chiamanti.
|
||||
```
|
||||
|
||||
### 3. Pull Request
|
||||
|
||||
PR aperte verso il branch `main` su Gitea. Verifica:
|
||||
|
||||
- [ ] Build completa senza warning per tutte le architetture: `python build_plugin.py`
|
||||
- [ ] Esempi aggiornati se cambia l'API
|
||||
- [ ] `CHANGELOG.md` aggiornato (sezione `[Unreleased]`)
|
||||
- [ ] Documentazione aggiornata (README, docs/API.md se esiste)
|
||||
- [ ] Conventional Commits rispettato
|
||||
- [ ] Nessun file in `dist/` o `__pycache__/` committato
|
||||
|
||||
## Build Script
|
||||
|
||||
```
|
||||
python build_plugin.py [opzioni]
|
||||
```
|
||||
|
||||
| Opzione | Default | Descrizione |
|
||||
|---------|---------|-------------|
|
||||
| `--config` | `all` | Architettura: `x86-ansi`, `x86-unicode`, `x64-unicode`, `all` |
|
||||
| `--toolset` | `auto` | Visual Studio: `2022`, `2026`, `auto` (rileva il più recente) |
|
||||
| `--jobs` | numero CPU | Thread paralleli per la build |
|
||||
| `--clean` | false | Pulisce `dist/` prima di compilare |
|
||||
| `--install-dir` | none | Copia DLL anche in `<dir>/{arch}/` (es. NSIS plugin folder) |
|
||||
| `--verbose` | false | Output dettagliato (mostra comandi MSBuild) |
|
||||
|
||||
Exit codes:
|
||||
- `0` — Successo
|
||||
- `1` — Errore di build
|
||||
- `2` — Prerequisiti mancanti
|
||||
- `3` — Argomenti invalidi
|
||||
|
||||
## Release Workflow
|
||||
|
||||
Le release sono automatiche via tag Git:
|
||||
|
||||
```powershell
|
||||
# 1. Aggiorna VERSION e CHANGELOG.md
|
||||
echo "1.7.0" > VERSION
|
||||
# (modifica CHANGELOG.md spostando entry da [Unreleased] a [1.7.0])
|
||||
|
||||
# 2. Commit
|
||||
git add VERSION CHANGELOG.md
|
||||
git commit -m "chore(release): v1.7.0"
|
||||
|
||||
# 3. Tag annotato
|
||||
git tag -a v1.7.0 -m "Release v1.7.0"
|
||||
|
||||
# 4. Push
|
||||
git push origin main
|
||||
git push origin v1.7.0
|
||||
```
|
||||
|
||||
Il workflow `.github/workflows/release.yml` compilerà tutte le architetture
|
||||
e creerà la release su Gitea con gli artifact ZIP allegati. Il mirror GitHub
|
||||
riceverà automaticamente il tag.
|
||||
|
||||
## Code Style
|
||||
|
||||
- C/C++: stile coerente con il file modificato
|
||||
- Python: PEP 8 (4 spazi indent, line length flessibile)
|
||||
- Header file: `#include` ordinati: stdlib → Win32 → progetto
|
||||
- Encoding: UTF-8 senza BOM (eccetto `.rc` che richiede UTF-16 LE)
|
||||
- Line endings: LF in repo (`.gitattributes` normalizza)
|
||||
|
||||
## Reporting Bug
|
||||
|
||||
Apri una [issue](https://gitea.emulab.it/Simone/nsis-plugin-nsunz/issues/new) usando il template "Bug Report".
|
||||
Includi:
|
||||
- Versione plugin e architettura DLL usata
|
||||
- Versione NSIS
|
||||
- Sistema operativo
|
||||
- Script `.nsi` minimale che riproduce il problema
|
||||
- Output / errore esatto
|
||||
|
||||
## Domande
|
||||
|
||||
Per domande generali, apri una [issue](https://gitea.emulab.it/Simone/nsis-plugin-nsunz/issues) con label `question`.
|
||||
@@ -0,0 +1,21 @@
|
||||
zlib License
|
||||
|
||||
Copyright (c) 2026 Simone
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
@@ -0,0 +1,51 @@
|
||||
# nsisunz NSIS Plugin
|
||||
|
||||
NSIS plugin for ZIP file extraction.
|
||||
|
||||
## Versions
|
||||
|
||||
| Folder | zlib version | Notes |
|
||||
|--------|-------------|-------|
|
||||
| `zlib-1.1.3/` | zlib 1.1.3 (1998) | Original version |
|
||||
| `zlib-1.3/` | zlib 1.3.1 (2023) | Updated version |
|
||||
|
||||
## Build Script
|
||||
|
||||
The repo includes a single unified `build_plugin.py` script that replaces the previous per-version scripts.
|
||||
|
||||
## Build
|
||||
|
||||
```powershell
|
||||
# Recommended: zlib 1.3 with auto-detected toolset
|
||||
python build_plugin.py
|
||||
|
||||
# Select zlib version (1.1.3 = legacy, 1.3 = default)
|
||||
python build_plugin.py --zlib-version 1.1.3
|
||||
|
||||
# Specific toolset (2022|2026|auto)
|
||||
python build_plugin.py --toolset 2022
|
||||
|
||||
# Print version and exit
|
||||
python build_plugin.py --version
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Compiled DLLs are copied to `plugins/{platform}/nsisunz.dll`:
|
||||
|
||||
- `plugins/x86-ansi/nsisunz.dll`
|
||||
- `plugins/x86-unicode/nsisunz.dll`
|
||||
- `plugins/amd64-unicode/nsisunz.dll`
|
||||
|
||||
## Documentation
|
||||
|
||||
- **zlib 1.3**: See [zlib-1.3/README.md](zlib-1.3/README.md) and [zlib-1.3/BUILD_INFO.md](zlib-1.3/BUILD_INFO.md)
|
||||
- **zlib 1.1.3**: See [zlib-1.1.3/README.md](zlib-1.1.3/README.md)
|
||||
|
||||
## Credits
|
||||
|
||||
Based on [past-due/nsisunz](https://github.com/past-due/nsisunz)
|
||||
|
||||
---
|
||||
|
||||
*See [README_IT.md](README_IT.md) for the Italian version.*
|
||||
@@ -0,0 +1,47 @@
|
||||
# nsisunz NSIS Plugin
|
||||
|
||||
**Plugin NSIS per estrazione file ZIP**
|
||||
|
||||
## Versioni
|
||||
|
||||
| Cartella | Versione zlib | Note |
|
||||
|----------|---------------|------|
|
||||
| `zlib-1.1.3/` | zlib 1.1.3 (1998) | Versione originale |
|
||||
| `zlib-1.3/` | zlib 1.3.1 (2023) | Versione aggiornata |
|
||||
|
||||
## Script di Build
|
||||
|
||||
Il repo include un unico script unificato `build_plugin.py` che sostituisce i precedenti script per-versione.
|
||||
|
||||
## Compilazione
|
||||
|
||||
```powershell
|
||||
# Raccomandato: zlib 1.3 con toolset rilevato automaticamente
|
||||
python build_plugin.py
|
||||
|
||||
# Seleziona versione zlib (1.1.3 = legacy, 1.3 = default)
|
||||
python build_plugin.py --zlib-version 1.1.3
|
||||
|
||||
# Toolset specifico (2022|2026|auto)
|
||||
python build_plugin.py --toolset 2022
|
||||
|
||||
# Stampa versione ed esce
|
||||
python build_plugin.py --version
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
I DLL compilati vengono copiati in `plugins/{platform}/nsisunz.dll`:
|
||||
|
||||
- `plugins/x86-ansi/nsisunz.dll`
|
||||
- `plugins/x86-unicode/nsisunz.dll`
|
||||
- `plugins/amd64-unicode/nsisunz.dll`
|
||||
|
||||
## Documentazione
|
||||
|
||||
- **zlib 1.3**: Vedi [zlib-1.3/README.md](zlib-1.3/README.md) e [zlib-1.3/BUILD_INFO.md](zlib-1.3/BUILD_INFO.md)
|
||||
- **zlib 1.1.3**: Vedi [zlib-1.1.3/README.md](zlib-1.1.3/README.md)
|
||||
|
||||
## Crediti
|
||||
|
||||
Basato su [past-due/nsisunz](https://github.com/past-due/nsisunz)
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
# Security Policy
|
||||
|
||||
## Versioni Supportate
|
||||
|
||||
Solo l'ultima versione minor riceve fix di security.
|
||||
|
||||
| Versione | Supporto |
|
||||
|----------|----------|
|
||||
| Latest minor (es. 1.0.0) | ✅ |
|
||||
| Versioni precedenti | ❌ |
|
||||
|
||||
## Reporting di una Vulnerabilità
|
||||
|
||||
**Non aprire issue pubbliche per vulnerabilità di security.**
|
||||
|
||||
Per segnalare una vulnerabilità:
|
||||
|
||||
1. **Preferito**: usa la funzione [Security Advisory privato](https://gitea.emulab.it/Simone/nsis-plugin-nsunz/security/advisories/new) di Gitea
|
||||
2. **Alternativa**: invia email a `security@example.com` (sostituire con email reale prima del primo release)
|
||||
|
||||
Includi:
|
||||
- Descrizione della vulnerabilità
|
||||
- Passi per riprodurla
|
||||
- Versione/i affette
|
||||
- Possibile mitigazione (se nota)
|
||||
|
||||
## Tempo di Risposta
|
||||
|
||||
- Acknowledgment iniziale: entro 7 giorni
|
||||
- Valutazione: entro 14 giorni
|
||||
- Patch (se confermata): tempistiche dipendono dalla severità
|
||||
|
||||
## Hardening
|
||||
|
||||
Questo plugin gira con i permessi del processo NSIS chiamante (tipicamente
|
||||
l'utente che esegue l'installer). Non richiede privilegi elevati per la
|
||||
compilazione né per l'esecuzione, salvo dove esplicitamente documentato.
|
||||
|
||||
DLL distribuite tramite Releases sono compilate da CI GitHub Actions con
|
||||
toolchain pinnata. Verificare hash SHA256 pubblicati nelle release.
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build script for nsisunz NSIS plugin.
|
||||
|
||||
Wraps per-version/per-toolset build scripts.
|
||||
Defaults: zlib 1.3, VS2026 (v145 toolset)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, subprocess, sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class Colors:
|
||||
CYAN = "\033[36m"; GREEN = "\033[32m"; YELLOW = "\033[33m"
|
||||
RED = "\033[31m"; GRAY = "\033[90m"; RESET = "\033[0m"
|
||||
BOLD = "\033[1m"; BRIGHT_CYAN = "\033[96m"
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
SCRIPTS = {
|
||||
"1.1.3": {"2022": "tools/legacy/build_plugin_zlib113_vs2022.py",
|
||||
"2026": "tools/legacy/build_plugin_zlib113_vs2026.py"},
|
||||
"1.3": {"2022": "tools/legacy/build_plugin_zlib13_vs2022.py",
|
||||
"2026": "tools/legacy/build_plugin_zlib13_vs2026.py"},
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Build nsisunz NSIS plugin")
|
||||
parser.add_argument("--zlib-version", choices=["1.1.3", "1.3"], default="1.3",
|
||||
help="zlib version to use (default: 1.3)")
|
||||
parser.add_argument("--toolset", choices=["2022", "2026", "auto"], default="auto",
|
||||
help="Visual Studio toolset version (default: auto)")
|
||||
parser.add_argument("--version", action="store_true",
|
||||
help="Print plugin version and exit")
|
||||
known, rest = parser.parse_known_args()
|
||||
|
||||
if known.version:
|
||||
print((ROOT / "VERSION").read_text(encoding="utf-8-sig").strip())
|
||||
return 0
|
||||
|
||||
ver = (ROOT / "VERSION").read_text(encoding="utf-8-sig").strip()
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}=== Building nsUnz v{ver} "
|
||||
f"(zlib {known.zlib_version}) ==={Colors.RESET}")
|
||||
|
||||
toolset = known.toolset
|
||||
if toolset == "auto":
|
||||
toolset = "2026"
|
||||
|
||||
script = ROOT / SCRIPTS[known.zlib_version][toolset]
|
||||
return subprocess.run([sys.executable, str(script)] + rest).returncode
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,361 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>nsisunz</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
|
||||
<style type="text/css">
|
||||
/*<![CDATA[*/
|
||||
|
||||
body
|
||||
{
|
||||
padding: 10px;
|
||||
background-color: #F0F0F0;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
p
|
||||
{
|
||||
font-size: 100%;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
.center
|
||||
{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table
|
||||
{
|
||||
margin: auto;
|
||||
text-align: left;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.maintable
|
||||
{
|
||||
border: 2px solid #376EAB;
|
||||
}
|
||||
|
||||
.parameter
|
||||
{
|
||||
font-weight: bold;
|
||||
color: #6586AC;
|
||||
}
|
||||
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 220%;
|
||||
color: #333333;
|
||||
font-weight: normal;
|
||||
text-align: center;
|
||||
margin: 20px;
|
||||
filter: glow(color="silver", strength="6");
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
h2
|
||||
{
|
||||
font-size: 165%;
|
||||
color: #7A7272;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h3
|
||||
{
|
||||
font-size: 140%;
|
||||
font-weight: bold;
|
||||
color: #303030;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-size: 100%;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
div
|
||||
{
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
a:link, a:visited, a:active
|
||||
{
|
||||
color: #294F75;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover
|
||||
{
|
||||
color: #182634;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.subtable
|
||||
{
|
||||
border: 0px;
|
||||
margin-left: 20px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.lefttable
|
||||
{
|
||||
background-color: #CCCCCC;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.righttable
|
||||
{
|
||||
background-color: #EEEEEE;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.preproc {color: green;}
|
||||
.comment {color: gray;}
|
||||
.keyword {color: blue;}
|
||||
.string {color: teal;}
|
||||
.param {color: orange;}
|
||||
|
||||
/*]]>*/
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="center">
|
||||
<table width="750" class="maintable" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td>
|
||||
<h1>nsisunz</h1>
|
||||
<div>
|
||||
<h2>Introduction</h2>
|
||||
<p><b>nsisunz</b> is a NSIS plugin which allows you to extract files from ZIP
|
||||
archives.</p>
|
||||
<p><b>nsisunz</b> is great when you use another NSIS plug-in named
|
||||
<em>NSISdl</em> to download a ZIP file from the internet.
|
||||
Download a small installer which lets the user choose the components he/she
|
||||
want to install and the installer downloads it (<em>QuickTime Setup</em> does
|
||||
this).</p>
|
||||
<p>Note:
|
||||
<em>nsisunz</em> does not support password protected ZIP archives
|
||||
(encrypted).<br/>
|
||||
To extract only a specific file from the archive use the
|
||||
<a href="#fileopt">"/file"</a> option.
|
||||
</p>
|
||||
<h2>How to use</h2>
|
||||
<h3>Setting it up</h3>
|
||||
<p>To see a great example of how to use the plug-in,
|
||||
check out the included <a href="example.nsi">example script</a>.</p>
|
||||
<p>You use the <em>Unzip</em>, <em>UnzipToLog</em> or the
|
||||
<em><a href="#UnzipToStack">UnzipToStack</a></em> function to extract files
|
||||
from a ZIP archive.</p>
|
||||
<p>In my opinion the best way to describe things is by showing an example,
|
||||
so here is one:</p>
|
||||
<pre>
|
||||
<font class="keyword">InitPluginsDir</font>
|
||||
<font class="comment">; Call plug-in. Push filename to ZIP first, and the dest. folder last.</font>
|
||||
nsisunz::UnzipToLog <font class="string">"$PLUGINSDIR\myzipfile.zip" "$INSTDIR"</font>
|
||||
|
||||
<font class="comment">; Always check result on stack</font>
|
||||
<font class="keyword">Pop</font> $0
|
||||
<font class="keyword">StrCmp</font> $0 <font class="string">"success"</font> ok
|
||||
<font class="keyword">DetailPrint</font> <font class="string">"$0"</font> <font class="comment">;print error message to log</font>
|
||||
ok:
|
||||
|
||||
<font class="comment">; You can also use the "Unzip" function if you don't want to use the log.
|
||||
; It is a lot quicker, and is preferred for large ZIP archives.</font>
|
||||
nsisunz::Unzip <font class="string">"$PLUGINSDIR\myzipfile.zip" "$INSTDIR"</font>
|
||||
</pre>
|
||||
<a name="UnzipToStack"><h3>The UnzipToStack function</h3></a>
|
||||
<p>The <em>UnzipToStack</em> function can be used instead of the <em>UnzipToLog</em> function
|
||||
if you want the extraction to be a lot faster when extracting from very large ZIP archives and still
|
||||
want to see the files extracted. This is how you use it:
|
||||
</p>
|
||||
<pre>
|
||||
nsisunz::UnzipToStack <font class="string">"$PLUGINSDIR\myzipfile.zip" "$INSTDIR"</font>
|
||||
<font class="keyword">Pop</font> $0
|
||||
<font class="keyword">StrCmp</font> $0 <font class="string">"success"</font> ok
|
||||
<font class="keyword">DetailPrint</font> <font class="keyword">"$0"</font> <font class="comment">;print error message to log</font>
|
||||
<font class="keyword">Goto</font> skiplist
|
||||
ok:
|
||||
|
||||
<font class="comment">; Print out list of files extracted to log</font>
|
||||
next:
|
||||
<font class="keyword">Pop</font> $0
|
||||
<font class="keyword">DetailPrint</font> $0
|
||||
<font class="keyword">StrCmp</font> $0 "" 0 next <font class="comment">; pop strings until a blank one arrives</font>
|
||||
|
||||
skiplist:
|
||||
</pre>
|
||||
<a name="fileopt"><h3>Extracting specific files</h3></a>
|
||||
<p>
|
||||
To extract only a specific file use the "/file" option like this:
|
||||
</p>
|
||||
<pre>
|
||||
nsisunz::UnzipToLog /file <font class="string">"AnyPathInsideZIP/AFile.txt" "myzip.zip" "c:\myfiles"</font>
|
||||
</pre>
|
||||
<p>
|
||||
The path is relative to the root of the ZIP archive so you don't have to
|
||||
prepend a slash ("/"). Furthermore the foldernames are extracted with the file so
|
||||
the example above creates a file named "c:\myfiles\AnyPathInsideZIP\AFile.txt".
|
||||
To avoid this use "/noextractpath" like this:
|
||||
</p>
|
||||
<pre>
|
||||
nsisunz::UnzipToLog /noextractpath /file \
|
||||
<font class="string">"AnyPathInsideZIP/AFile.txt" "myzip.zip" "c:\myfiles"</font>
|
||||
</pre>
|
||||
<h3>Using nsisunz with NSISdl</h3>
|
||||
<p>To use <em>NSISdl</em> with <em>nsisunz</em> to download and extract a ZIP archive,
|
||||
do something like this:</p>
|
||||
<pre>
|
||||
<font class="keyword">InitPluginsDir</font>
|
||||
NSISdl::download <font class="string">http://www.domain.com/file "$PLUGINSDIR\localfile.zip"</font>
|
||||
<font class="keyword">Pop</font> $R0 ;Get the return value
|
||||
<font class="keyword">StrCmp</font> $R0 <font class="string">"success"</font> +3
|
||||
<font class="keyword">MessageBox</font> <font class="param">MB_OK</font> <font class="string">"Download failed: $R0"</font>
|
||||
<font class="keyword">Quit</font>
|
||||
|
||||
nsisunz::UnzipToLog <font class="string">"$PLUGINSDIR\localfile.zip" "$INSTDIR"</font>
|
||||
<font class="keyword">Pop</font> $R0
|
||||
<font class="keyword">StrCmp</font> $R0 <font class="string">"success"</font> +2
|
||||
<font class="keyword">DetailPrint</font> <font class="string">"$R0"</font> <font class="comment">;print error message to log</font>
|
||||
|
||||
</pre>
|
||||
<h3>Options</h3>
|
||||
<p>These are the optional parameters you can specify when calling <em>nsisunz</em>.</p>
|
||||
<table class="subtable">
|
||||
<tr>
|
||||
<td class="lefttable">/noextractpath</td>
|
||||
<td class="righttable">This option makes the plug-in extract all files to
|
||||
the destination directory without regard to paths stored in ZIP file.
|
||||
Is often used in conjunction with "/file" to extract a single file
|
||||
from anywhere in an archive to a destination directory.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lefttable">/file</td>
|
||||
<td class="righttable">Extract a specific file. Filename must be specified
|
||||
as next parameter and must match a file in the ZIP including any
|
||||
subdirectories. If the file couldn't be found in the ZIP file,
|
||||
<em>nsisunz</em> pushes the string "File not found in ZIP file" on the
|
||||
stack.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lefttable">/text</td>
|
||||
<td class="righttable">Sets the format of the text used in the log to the
|
||||
next param. <em>"%f"</em> is replaced with the filename, <em>"%c"</em> is
|
||||
replaced with the compressed size and <em>"%u"</em> is replaced with the
|
||||
uncompressed size.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3>Return value</h3>
|
||||
<p>After you have called the DLL, <b>nsisunz</b> adds either "success" or a specific error message
|
||||
on the stack. This is the possible error messages:</p>
|
||||
<ul>
|
||||
<li>Error opening ZIP file</li>
|
||||
<li>Error opening output file(s)</li>
|
||||
<li>Error writing output file(s)</li>
|
||||
<li>Error extracting from ZIP file</li>
|
||||
<li>File not found in ZIP file</li>
|
||||
</ul>
|
||||
<p>Usually, you don't need to check this value, but you still have to remove it from the stack
|
||||
(have a look at the example above).</p>
|
||||
<h2>Reserve files</h2>
|
||||
<p>If you are using BZIP2 (solid) compression, it's important that files which are being extracted
|
||||
in init- or page functions function are located before other files in the data block, because this
|
||||
will make your installer faster.</p>
|
||||
<p>If there are File commands in your sections or functions above the init- or page functions, add
|
||||
ReserveFile commands above your sections and functions:</p>
|
||||
<pre>
|
||||
<font class="keyword">ReserveFile</font> <font class="string">"myzipfile.zip"</font>
|
||||
<font class="keyword">ReserveFile</font> <font class="string">"${NSISDIR}\Plugins\nsisunz.dll"</font>
|
||||
</pre>
|
||||
<h2>Localization</h2>
|
||||
<p>Use the <em>"/text"</em> parameter to localize the text used by nsisunz
|
||||
for the log output.
|
||||
</p>
|
||||
<pre>
|
||||
<font class="comment">; Localized strings for use with nsisunz</font>
|
||||
<font class="comment">; The "%f" in the string is replaced with the filename on run-time.</font>
|
||||
<font class="comment">; "%c" and "%u" is replaced with compressed size and</font>
|
||||
<font class="comment">; uncompressed size respectively. See example script.</font>
|
||||
|
||||
<font class="keyword">LoadLanguageFile</font> <font class="string">"${NSISDIR}\Contrib\Language files\english.nlf"</font>
|
||||
<font class="keyword">LoadLanguageFile</font> <font class="string">"${NSISDIR}\Contrib\Language files\norwegian.nlf"</font>
|
||||
|
||||
<font class="keyword">LangString</font> nsisunz_text ${LANG_ENGLISH} <font class="string">"Extract: %f"</font>
|
||||
<font class="keyword">LangString</font> nsisunz_text ${LANG_NORWEGIAN} <font class="string">"Pakk ut: %f"</font>
|
||||
|
||||
<font class="keyword">Function</font> .onInit
|
||||
nsisunz:: /text <font class="string">"" "$(nsisunz_text)"</font>
|
||||
<font class="keyword">FunctionEnd</font>
|
||||
</pre>
|
||||
<h2>Notes</h2>
|
||||
<p>
|
||||
The plug-in is compressed with UPX to make it smaller.<br />
|
||||
If you make changes to the source, re-compile and use UPX you may get this
|
||||
message:<br />
|
||||
<code>upx: nsisunz.dll: CantPackException: file is possibly packed/protected
|
||||
(try --force)</code><br />
|
||||
I used the "<code>--force</code>" parameter as proposed,
|
||||
and without problems UPX reduced the size of <em>nsisunz.dll</em> from ~71 kb
|
||||
to 31,5 kb<br/>
|
||||
The reason for why you get this message is that the source #include's
|
||||
"AggressiveOptimize.h" which makes the linker merge the code sections of the
|
||||
final executable. This makes UPX think it's already packed (which it kinda is).
|
||||
But by using the "<code>--force</code>" parameter, UPX may shrink it a lot
|
||||
more.<br/>
|
||||
I hope people appreciate my struggles to keep the size of the plug-in small.
|
||||
If someone have any suggestions for making it even smaller I would like if
|
||||
someone sendt me an e-mail.
|
||||
</p>
|
||||
<h2>Contact</h2>
|
||||
<p><em>nsisunz</em> is written by Saivert.<br />
|
||||
Homepage: <a href="http://saivert.inthegray.com/">
|
||||
http://saivert.inthegray.com/</a><br />
|
||||
E-mail: <a href="mailto:saivert@gmail.com?subject=nsisunz&
|
||||
body=Regarding%20nsisunz:%0D%0A%0D%0A">saivert@gmail.com</a>
|
||||
|
||||
</p>
|
||||
<h2>Version history</h2>
|
||||
<ul>
|
||||
<li>DLL version 1.0 (12/4/2004)
|
||||
<ul>
|
||||
<li>First public release!</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<h2>Credits</h2>
|
||||
<p>
|
||||
Based on code in NSIS Zip2Exe<br/>
|
||||
portions Copyright © 1999-2001 Miguel Garrido (mgarrido01@hotmail.com)<br/>
|
||||
Uses ZLIB - Copyright © Mark Adler<br/>
|
||||
ZIP format routines - Copyright © 1998 Gilles Vollant<br/>
|
||||
Thanks to Tim Kosse for the LogMessage function, even though I
|
||||
could figure this out myself.<br/>
|
||||
And thanks to Joost Verburg for the readme HTML page design.</p>
|
||||
<h2>License</h2>
|
||||
<pre>
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute
|
||||
it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented;
|
||||
you must not claim that you wrote the original software.
|
||||
If you use this software in a product, an acknowledgment in the
|
||||
product documentation would be appreciated but is not required.
|
||||
2. Altered versions must be plainly marked as such,
|
||||
and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any distribution.
|
||||
</pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,101 @@
|
||||
#ifndef _EXDLL_H_
|
||||
#define _EXDLL_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define UNUSED
|
||||
#endif
|
||||
|
||||
// only include this file from one place in your DLL.
|
||||
// (it is all static, if you use it in two places it will fail)
|
||||
|
||||
typedef struct _stack_t
|
||||
{
|
||||
struct _stack_t *next;
|
||||
TCHAR text[1]; // this should be the length of string_size
|
||||
} stack_t;
|
||||
|
||||
// Global variables (must be declared where you include this header)
|
||||
static unsigned int g_stringsize;
|
||||
static stack_t **g_stacktop;
|
||||
static TCHAR *g_variables;
|
||||
|
||||
#define EXDLL_INIT() \
|
||||
{ \
|
||||
g_stringsize = string_size; \
|
||||
g_stacktop = stacktop; \
|
||||
g_variables = variables; \
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
INST_0, // $0
|
||||
INST_1, // $1
|
||||
INST_2, // $2
|
||||
INST_3, // $3
|
||||
INST_4, // $4
|
||||
INST_5, // $5
|
||||
INST_6, // $6
|
||||
INST_7, // $7
|
||||
INST_8, // $8
|
||||
INST_9, // $9
|
||||
INST_R0, // $R0
|
||||
INST_R1, // $R1
|
||||
INST_R2, // $R2
|
||||
INST_R3, // $R3
|
||||
INST_R4, // $R4
|
||||
INST_R5, // $R5
|
||||
INST_R6, // $R6
|
||||
INST_R7, // $R7
|
||||
INST_R8, // $R8
|
||||
INST_R9, // $R9
|
||||
INST_CMDLINE, // $CMDLINE
|
||||
INST_INSTDIR, // $INSTDIR
|
||||
INST_OUTDIR, // $OUTDIR
|
||||
INST_EXEDIR, // $EXEDIR
|
||||
INST_LANG, // $LANGUAGE
|
||||
__INST_LAST
|
||||
};
|
||||
|
||||
// utility functions (not required but often useful)
|
||||
static int UNUSED popstring(TCHAR *str)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop || !*g_stacktop)
|
||||
return 1;
|
||||
th = (*g_stacktop);
|
||||
lstrcpyn(str, th->text, (int)g_stringsize);
|
||||
*g_stacktop = th->next;
|
||||
GlobalFree((HGLOBAL)th);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void UNUSED pushstring(const TCHAR *str)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop)
|
||||
return;
|
||||
th = (stack_t *)GlobalAlloc(GPTR, (sizeof(stack_t) + (g_stringsize) * sizeof(TCHAR)));
|
||||
lstrcpyn(th->text, str, (int)g_stringsize);
|
||||
th->next = *g_stacktop;
|
||||
*g_stacktop = th;
|
||||
}
|
||||
|
||||
static TCHAR *UNUSED getuservariable(const int varnum)
|
||||
{
|
||||
if (varnum < 0 || varnum >= __INST_LAST)
|
||||
return NULL;
|
||||
return g_variables + varnum * g_stringsize;
|
||||
}
|
||||
|
||||
static void UNUSED setuservariable(const int varnum, const TCHAR *var)
|
||||
{
|
||||
if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
|
||||
lstrcpy(g_variables + varnum * g_stringsize, var);
|
||||
}
|
||||
|
||||
#endif //_EXDLL_H_
|
||||
@@ -0,0 +1,95 @@
|
||||
; Example script for nsisunz
|
||||
; Written by Saivert
|
||||
; Homepage: http://members.tripod.com/files_saivert/
|
||||
;
|
||||
; Dependencies:
|
||||
; - nsisunz.dll Plug-in
|
||||
; - InstallOptions.dll Plug-in
|
||||
; - zippage.ini (InstallOptions INI file)
|
||||
|
||||
!addplugindir ".\Release"
|
||||
|
||||
OutFile "nsisunz_test.exe"
|
||||
Name "NSIS Unzip plug-in test"
|
||||
Caption "NSIS Unzip plug-in test"
|
||||
ShowInstDetails show
|
||||
XPStyle on
|
||||
CompletedText "Extracted!"
|
||||
SubCaption 3 " - Extracting files"
|
||||
SubCaption 4 " - Extracted"
|
||||
|
||||
LoadLanguageFile "${NSISDIR}\Contrib\Language files\english.nlf"
|
||||
|
||||
; Installer pages
|
||||
Page custom onZipPageShow onZipPageLeave " - Select Zip file"
|
||||
Page instfiles
|
||||
|
||||
; Localized strings for use with nsisunz
|
||||
; The '%f' in the string is replaced with the filename on run-time.
|
||||
; "%c", "%u", "%p" and "%p" is replaced with compressed size,
|
||||
; uncompressed size, percent complete (with "%") and byte complete
|
||||
; respectively.
|
||||
LangString nsisunz_text ${LANG_ENGLISH} "Extract: %f (%c -> %b) [%p]"
|
||||
|
||||
Function .onInit
|
||||
InitPluginsDir
|
||||
File "/oname=$PLUGINSDIR\zippage.ini" "zippage.ini"
|
||||
FunctionEnd
|
||||
|
||||
Function onZipPageShow
|
||||
; Turn Text control into a button (HM NIS Edit v2.0b5 does not support "Button" type).
|
||||
WriteINIStr "$PLUGINSDIR\zippage.ini" "Field 12" "Type" "Button"
|
||||
WriteINIStr "$PLUGINSDIR\zippage.ini" "Field 12" "Flags" "NOTIFY"
|
||||
|
||||
InstallOptions::dialog "$PLUGINSDIR\zippage.ini"
|
||||
FunctionEnd
|
||||
|
||||
Function onZipPageLeave
|
||||
; $R0 = zip filename $R1 = dest. folder
|
||||
|
||||
ReadINIStr $R0 "$PLUGINSDIR\zippage.ini" "Field 4" "State"
|
||||
ReadINIStr $R1 "$PLUGINSDIR\zippage.ini" "Field 6" "State"
|
||||
|
||||
; Remove trailing backslash if any
|
||||
StrCpy $0 $R1 1 -1
|
||||
StrCmp "$0" "\" 0 notneeded
|
||||
StrCpy $R1 $R1 -1
|
||||
notneeded:
|
||||
|
||||
IfFileExists $R0 checkdir
|
||||
MessageBox MB_ICONEXCLAMATION|MB_OK 'The file "$R0" does not exist!'
|
||||
Abort ;return to page
|
||||
checkdir:
|
||||
IfFileExists $R1\*.* unzip
|
||||
MessageBox MB_ICONEXCLAMATION|MB_YESNO 'The folder "$R1" does not exist!$\r$\nDo you wish to create it?' IDNO skipcreate
|
||||
CreateDirectory $R1
|
||||
Goto unzip
|
||||
skipcreate:
|
||||
Abort ;return to page
|
||||
|
||||
unzip:
|
||||
; Just fall of the end, so the sections can be executed
|
||||
FunctionEnd
|
||||
|
||||
Section -pre
|
||||
DetailPrint "ZIP file: $R0"
|
||||
DetailPrint "Dest. folder: $R1"
|
||||
SectionEnd
|
||||
|
||||
Section
|
||||
; Check if the checkbox is checked and if it is, then don't extract paths
|
||||
ReadINIStr $R2 "$PLUGINSDIR\zippage.ini" "Field 7" "State"
|
||||
StrCmp $R2 "1" 0 usepaths
|
||||
nsisunz::UnzipToLog /text "$(nsisunz_text)" /noextractpath $R0 $R1
|
||||
Goto check
|
||||
usepaths:
|
||||
nsisunz::UnzipToLog /text "$(nsisunz_text)" $R0 $R1
|
||||
|
||||
check:
|
||||
; Always check for errors. Everything else than "success" means an error.
|
||||
Pop $0
|
||||
StrCmp $0 "success" ok
|
||||
Abort "$0"
|
||||
ok:
|
||||
SectionEnd
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
; Example script for nsisunz
|
||||
; Written by Saivert
|
||||
; Homepage: http://members.tripod.com/files_saivert/
|
||||
;
|
||||
; Dependencies:
|
||||
; - nsisunz.dll Plug-in
|
||||
; - InstallOptions.dll Plug-in
|
||||
; - zippage.ini (InstallOptions INI file)
|
||||
|
||||
!addplugindir ".\Release"
|
||||
|
||||
!include "MUI.nsh"
|
||||
|
||||
OutFile "nsisunz_testmui.exe"
|
||||
Name "NSIS Unzip plug-in test"
|
||||
Caption "NSIS Unzip plug-in test"
|
||||
ShowInstDetails show
|
||||
CompletedText "Extracted!"
|
||||
|
||||
; Installer pages
|
||||
Page custom onZipPageShow onZipPageLeave " "
|
||||
!define MUI_PAGE_HEADER_TEXT "Extracting"
|
||||
!define MUI_PAGE_HEADER_SUBTEXT "Extracting files"
|
||||
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Extracted"
|
||||
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "Thes files has been extracted"
|
||||
!define MUI_INSTFILESPAGE_ABORTHEADER_TEXT "Extraction aborted"
|
||||
!define MUI_INSTFILESPAGE_ABORTHEADER_SUBTEXT "The extraction process was aborted"
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
|
||||
; Localized strings for use with nsisunz
|
||||
; The '%f' in the string is replaced with the filename on run-time.
|
||||
; "%c" and "%u" is replaced with compressed size and uncompressed size
|
||||
; respectively.
|
||||
LangString nsisunz_text ${LANG_ENGLISH} "Extract: %f (%c -> %u)"
|
||||
|
||||
Function .onInit
|
||||
InitPluginsDir
|
||||
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "zippage.ini"
|
||||
FunctionEnd
|
||||
|
||||
Function onZipPageShow
|
||||
!insertmacro MUI_HEADER_TEXT "Unzip" "Select ZIP file and destination folder"
|
||||
|
||||
; Remove icon (so we get away with one INI file for both scripts)
|
||||
!insertmacro MUI_INSTALLOPTIONS_WRITE "zippage.ini" "Field 1" "Type" ""
|
||||
!insertmacro MUI_INSTALLOPTIONS_WRITE "zippage.ini" "Field 2" "Left" "0"
|
||||
|
||||
|
||||
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "zippage.ini"
|
||||
FunctionEnd
|
||||
|
||||
Function onZipPageLeave
|
||||
; $R0 = zip filename $R1 = dest. folder
|
||||
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "zippage.ini" "Field 4" "State"
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "zippage.ini" "Field 6" "State"
|
||||
|
||||
; Remove trailing backslash if any
|
||||
StrCpy $0 $R1 1 -1
|
||||
StrCmp "$0" "\" 0 notneeded
|
||||
StrCpy $R1 $R1 -1
|
||||
notneeded:
|
||||
|
||||
IfFileExists $R0 checkdir
|
||||
MessageBox MB_ICONEXCLAMATION|MB_OK 'The file "$R0" does not exist!'
|
||||
Abort ;return to page
|
||||
checkdir:
|
||||
IfFileExists $R1\*.* unzip
|
||||
MessageBox MB_ICONEXCLAMATION|MB_YESNO 'The folder "$R1" does not exist!$\r$\nDo you wish to create it?' IDNO skipcreate
|
||||
CreateDirectory $R1
|
||||
Goto unzip
|
||||
skipcreate:
|
||||
Abort ;return to page
|
||||
|
||||
unzip:
|
||||
; Just fall of the end, so the sections can be executed
|
||||
FunctionEnd
|
||||
|
||||
Section -pre
|
||||
DetailPrint "ZIP file: $R0"
|
||||
DetailPrint "Dest. folder: $R1"
|
||||
SectionEnd
|
||||
|
||||
Section
|
||||
; Check if the checkbox is checked and if it is, then don't extract paths
|
||||
ReadINIStr $R2 "$PLUGINSDIR\zippage.ini" "Field 7" "State"
|
||||
StrCmp $R2 "1" 0 usepaths
|
||||
nsisunz::UnzipToLog /text "$(nsisunz_text)" /noextractpath $R0 $R1
|
||||
Goto check
|
||||
usepaths:
|
||||
nsisunz::UnzipToLog /text "$(nsisunz_text)" $R0 $R1
|
||||
|
||||
check:
|
||||
; Always check for errors. Everything else than "success" means an error.
|
||||
Pop $0
|
||||
StrCmp $0 "success" ok
|
||||
Abort "$0"
|
||||
ok:
|
||||
SectionEnd
|
||||
Binary file not shown.
@@ -0,0 +1,106 @@
|
||||
# nsisunz NSIS Plugin
|
||||
|
||||
**Versione personale modificata**
|
||||
|
||||
Basato su [past-due/nsisunz](https://github.com/past-due/nsisunz) - un plugin NSIS per estrarre file da archivi ZIP.
|
||||
|
||||
---
|
||||
|
||||
## Descrizione Originale
|
||||
|
||||
**nsisunz** è un plugin [NSIS](https://en.wikipedia.org/wiki/Nullsoft_Scriptable_Install_System) che permette di estrarre file da archivi ZIP.
|
||||
|
||||
> **nsisunz** è ideale quando si usa un altro plugin NSIS chiamato _NSISdl_ per scaricare un file ZIP da internet. Si può creare un piccolo installer che permette all'utente di scegliere i componenti da installare e l'installer li scarica.
|
||||
|
||||
### Origini e Storia
|
||||
|
||||
- _nsisunz_ è stato originariamente scritto da Saivert (http://saivert.com/)
|
||||
- Supporto NSIS Unicode [aggiunto da Gringoloco023](http://portableapps.com/node/21879), Febbraio 2010
|
||||
- Ulteriori miglioramenti di past-due, 2018+:
|
||||
- Aggiornamento NSIS plugin API a 3.0
|
||||
- Aggiornamento [zlib](https://zlib.net) a [1.2.11](https://zlib.net/ChangeLog.txt)
|
||||
- Aggiornamento Minizip a 1.1-8
|
||||
- Supporto build [CMake](https://cmake.org) (compila sia DLL ANSI che Unicode)
|
||||
|
||||
## Funzioni
|
||||
|
||||
### UnzipToLog
|
||||
|
||||
Estrae i file e mostra il log dettagliato:
|
||||
|
||||
```nsis
|
||||
InitPluginsDir
|
||||
; Chiama il plugin. Prima il file ZIP, poi la cartella di destinazione.
|
||||
nsisunz::UnzipToLog "$PLUGINSDIR\myzipfile.zip" "$INSTDIR"
|
||||
|
||||
; Controlla sempre il risultato sullo stack
|
||||
Pop $0
|
||||
StrCmp $0 "success" ok
|
||||
DetailPrint "$0" ; stampa messaggio di errore nel log
|
||||
ok:
|
||||
```
|
||||
|
||||
### Unzip
|
||||
|
||||
Estrazione veloce senza log (preferita per archivi grandi):
|
||||
|
||||
```nsis
|
||||
nsisunz::Unzip "$PLUGINSDIR\myzipfile.zip" "$INSTDIR"
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
- Basato sul codice di NSIS Zip2Exe - porzioni Copyright © 1999-2001 Miguel Garrido (mgarrido01@hotmail.com)
|
||||
- [ZLIB](https://zlib.net) - Copyright © Mark Adler
|
||||
- MiniZip - Copyright © 1998-2010 - di Gilles Vollant - versione 1.1 64 bits di Mathias Svensson
|
||||
|
||||
## Licenza
|
||||
|
||||
Le condizioni di uso e distribuzione sono le stesse di [zlib](https://en.wikipedia.org/wiki/Zlib_License).
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Differenze nella versione personale
|
||||
|
||||
Questa versione è basata su [past-due/nsisunz](https://github.com/past-due/nsisunz) con le seguenti modifiche:
|
||||
|
||||
### Nuova architettura supportata: x64 (amd64-unicode)
|
||||
|
||||
L'originale supporta:
|
||||
- x86-ansi
|
||||
- x86-unicode
|
||||
|
||||
La versione personale aggiunge il supporto per:
|
||||
- **amd64-unicode** (x64)
|
||||
|
||||
### Progetto Visual Studio
|
||||
|
||||
L'originale usa CMake per la compilazione. La versione personale include progetti Visual Studio:
|
||||
- `Source/nsisunz.vcproj` - Progetto VS2008 (legacy)
|
||||
- `Source/nsisunz.vcxproj` - Progetto VS2022 (x86-ansi, x86-unicode, amd64-unicode)
|
||||
|
||||
### File modificati/semplificati
|
||||
|
||||
La versione personale usa una versione più vecchia e semplificata di zlib:
|
||||
- `Source/zlib/` - Libreria zlib semplificata (solo file essenziali per decompressione)
|
||||
|
||||
Rispetto all'originale GitHub che include:
|
||||
- CMakeLists.txt e configurazione CMake completa
|
||||
- zlib 1.2.11 completa con tutti i contributi (285 file)
|
||||
- Minizip completo
|
||||
- Configurazione CI/CD (.github, appveyor)
|
||||
|
||||
### File aggiunti
|
||||
|
||||
- `build_plugin.py` - Script Python per compilare il plugin per tutte le architetture
|
||||
- `Doc/` - Documentazione (info.rtf, nsisunz_readme.html)
|
||||
- `ExDLL/exdll.h` - Header per l'API NSIS extern DLL
|
||||
|
||||
### Compilazione
|
||||
|
||||
```cmd
|
||||
cd nsUnz
|
||||
python build_plugin.py
|
||||
```
|
||||
|
||||
I DLL vengono copiati in `plugins/{platform}/nsisunz.dll`.
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
//////////////////////////////
|
||||
// Version 1.30
|
||||
// Nov 24th, 2000
|
||||
// Version 1.20
|
||||
// Jun 9th, 2000
|
||||
// Version 1.10
|
||||
// Jan 23rd, 2000
|
||||
// Version 1.00
|
||||
// May 20th, 1999
|
||||
// Todd C. Wilson, Fresh Ground Software
|
||||
// (todd@nopcode.com)
|
||||
// This header file will kick in settings for Visual C++ 5 and 6 that will (usually)
|
||||
// result in smaller exe's.
|
||||
// The "trick" is to tell the compiler to not pad out the function calls; this is done
|
||||
// by not using the /O1 or /O2 option - if you do, you implicitly use /Gy, which pads
|
||||
// out each and every function call. In one single 500k dll, I managed to cut out 120k
|
||||
// by this alone!
|
||||
// The other two "tricks" are telling the Linker to merge all data-type segments together
|
||||
// in the exe file. The relocation, read-only (constants) data, and code section (.text)
|
||||
// sections can almost always be merged. Each section merged can save 4k in exe space,
|
||||
// since each section is padded out to 4k chunks. This is very noticeable with smaller
|
||||
// exes, since you could have only 700 bytes of data, 300 bytes of code, 94 bytes of
|
||||
// strings - padded out, this could be 12k of runtime, for 1094 bytes of stuff! For larger
|
||||
// programs, this is less overall, but can save at least 4k.
|
||||
// Note that if you're using MFC static or some other 3rd party libs, you may get poor
|
||||
// results with merging the readonly (.rdata) section - the exe may grow larger.
|
||||
// To use this feature, define _MERGE_DATA_ in your project or before this header is used.
|
||||
// With Visual C++ 5, the program uses a file alignment of 512 bytes, which results
|
||||
// in a small exe. Under VC6, the program instead uses 4k, which is the same as the
|
||||
// section size. The reason (from what I understand) is that 4k is the chunk size of
|
||||
// the virtual memory manager, and that WinAlign (an end-user tuning tool for Win98)
|
||||
// will re-align the programs on this boundary. The problem with this is that all of
|
||||
// Microsoft's system exes and dlls are *NOT* tuned like this, and using 4k causes serious
|
||||
// exe bloat. Very noticeable for smaller programs.
|
||||
// The "trick" for this is to use the undocumented FILEALIGN linker parm to change the
|
||||
// padding from 4k to 1/2k, which results in a much smaller exe - anywhere from 20%-75%
|
||||
// depending on the size. Note that this is the same as using /OPT:NOWIN98, which *is*
|
||||
// a previously documented switch, but was left out of the docs for some reason in VC6 and
|
||||
// all of the current MSDN's - see KB:Q235956 for more information.
|
||||
// Microsoft does say that using the 4k alignment will "speed up process loading",
|
||||
// but I've been unable to notice a difference, even on my P180, with a very large (4meg) exe.
|
||||
// Please note, however, that this will probably not change the size of the COMPRESSED
|
||||
// file (either in a .zip file or in an install archive), since this 4k is all zeroes and
|
||||
// gets compressed away.
|
||||
// Also, the /ALIGN:4096 switch will "magically" do the same thing, even though this is the
|
||||
// default setting for this switch. Apparently this sets the same values as the above two
|
||||
// switches do. We do not use this in this header, since it smacks of a bug and not a feature.
|
||||
// Thanks to Michael Geary <Mike@Geary.com> for some additional tips!
|
||||
|
||||
#ifdef NDEBUG
|
||||
// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers)
|
||||
#pragma optimize("gsy",on)
|
||||
|
||||
#pragma comment(linker,"/RELEASE")
|
||||
|
||||
// Note that merging the .rdata section will result in LARGER exe's if you using
|
||||
// MFC (esp. static link). If this is desirable, define _MERGE_RDATA_ in your project.
|
||||
#ifdef _MERGE_RDATA_
|
||||
#pragma comment(linker,"/merge:.rdata=.data")
|
||||
#endif // _MERGE_RDATA_
|
||||
|
||||
#pragma comment(linker,"/merge:.text=.data")
|
||||
#pragma comment(linker,"/merge:.reloc=.data")
|
||||
|
||||
// Merging sections with different attributes causes a linker warning, so
|
||||
// turn off the warning. From Michael Geary. Undocumented, as usual!
|
||||
#pragma comment(linker,"/ignore:4078")
|
||||
|
||||
// With Visual C++ 5, you already get the 512-byte alignment, so you will only need
|
||||
// it for VC6, and maybe later.
|
||||
#if _MSC_VER >= 1000
|
||||
|
||||
// Option #1: use /filealign
|
||||
// Totally undocumented! And if you set it lower than 512 bytes, the program crashes.
|
||||
// Either leave at 0x200 or 0x1000
|
||||
//#pragma comment(linker,"/FILEALIGN:0x200")
|
||||
|
||||
// Option #2: use /opt:nowin98
|
||||
// See KB:Q235956 or the READMEVC.htm in your VC directory for info on this one.
|
||||
// This is our currently preferred option, since it is fully documented and unlikely
|
||||
// to break in service packs and updates.
|
||||
#pragma comment(linker,"/opt:nowin98")
|
||||
|
||||
// Option #3: use /align:4096
|
||||
// A side effect of using the default align value is that it turns on the above switch.
|
||||
// May break in future versions!
|
||||
//#pragma comment(linker,"/ALIGN:4096")
|
||||
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#endif // NDEBUG
|
||||
@@ -0,0 +1,593 @@
|
||||
// Unicode NSIS support by Gringoloco023, http://portableapps.com/node/21879, Februari 6 2010
|
||||
/*
|
||||
UnZip Plug-in for NSIS
|
||||
Written by Saivert
|
||||
|
||||
Credits:
|
||||
- Based on code in NSIS Zip2Exe
|
||||
portions Copyright © 1999-2001 Miguel Garrido (mgarrido01@hotmail.com)
|
||||
- Uses ZLIB - Copyright © Mark Adler
|
||||
- ZIP format routines - Copyright (C) 1998 Gilles Vollant
|
||||
|
||||
Even though this project is an NSIS Plug-in, it also
|
||||
exports a function that can be used by any applications.
|
||||
The exported function is "appextract"
|
||||
*/
|
||||
//#include "AggressiveOptimize.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <commctrl.h>
|
||||
#include "..\ExDLL\exdll.h"
|
||||
|
||||
//#include "exdll.h"
|
||||
|
||||
extern "C" {
|
||||
#include "zlib/unzip.h"
|
||||
};
|
||||
|
||||
//Strings used all over the place
|
||||
TCHAR szSuccess[] = {_T('s'),_T('u'),_T('c'),_T('c'),_T('e'),_T('s'),_T('s'),_T('\0')};
|
||||
TCHAR szFile[] = {_T('/'),_T('f'),_T('i'),_T('l'),_T('e'),_T('\0')};
|
||||
TCHAR szNoextractpath[] = {_T('/'),_T('n'),_T('o'),_T('e'),_T('x'),_T('t'),_T('r'),_T('a'),_T('c'),_T('t'),_T('p'),_T('a'),_T('t'),_T('h'),_T('\0')};
|
||||
TCHAR szDefExtractText[] = {_T('E'),_T('x'),_T('t'),_T('r'),_T('a'),_T('c'),_T('t'),_T(':'),_T(' '),_T('%'),_T('f'),_T('\0')};
|
||||
|
||||
TCHAR g_extract_text[1024];
|
||||
|
||||
int g_extracting;
|
||||
HWND g_hwndParent;
|
||||
TCHAR tempzip_path[1024];
|
||||
|
||||
void internal_unzip(int);
|
||||
|
||||
CRITICAL_SECTION cs;
|
||||
|
||||
//Log stuff
|
||||
HWND g_hwndList;
|
||||
HWND g_hwndStatus;
|
||||
void LogMessage(HWND, const TCHAR *, int = 0);
|
||||
|
||||
#ifdef UNICODE
|
||||
char * _T2A(wchar_t *str);
|
||||
wchar_t * _A2T(char *str);
|
||||
#define _tfopen_s _wfopen_s
|
||||
#else
|
||||
#define _T2A(x) (x)
|
||||
#define _A2T(x) (x)
|
||||
#define _tfopen_s fopen_s
|
||||
#endif
|
||||
|
||||
extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
//case DLL_THREAD_ATTACH:
|
||||
case DLL_PROCESS_ATTACH:
|
||||
InitializeCriticalSection(&cs);
|
||||
break;
|
||||
//case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
DeleteCriticalSection(&cs);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void doMKDir(TCHAR *directory)
|
||||
{
|
||||
TCHAR *p, *p2;
|
||||
TCHAR buf[MAX_PATH];
|
||||
if (!*directory) return;
|
||||
lstrcpy(buf,directory);
|
||||
p=buf; while (*p) p++;
|
||||
while (p >= buf && *p != _T('\\')) p--;
|
||||
p2 = buf;
|
||||
if (p2[1] == _T(':')) p2+=4;
|
||||
else if (p2[0] == _T('\\') && p2[1] == _T('\\'))
|
||||
{
|
||||
p2+=2;
|
||||
while (*p2 && *p2 != _T('\\')) p2++;
|
||||
if (*p2) p2++;
|
||||
while (*p2 && *p2 != _T('\\')) p2++;
|
||||
if (*p2) p2++;
|
||||
}
|
||||
if (p >= p2)
|
||||
{
|
||||
*p=0;
|
||||
doMKDir(buf);
|
||||
}
|
||||
CreateDirectory(directory,NULL);
|
||||
}
|
||||
|
||||
//Based on inttosizestr from NSIS exehead project.
|
||||
//Creates a string representing the size of a file,
|
||||
//choosing the unit that's best suited.
|
||||
static TCHAR * FormatDiskSize(TCHAR *str, unsigned long b)
|
||||
{
|
||||
TCHAR scale=_T('k');
|
||||
TCHAR sh=30;
|
||||
TCHAR s=0;
|
||||
|
||||
if (b <= (1024*1024) ) sh=10, scale=_T('k');
|
||||
else if (b <= (1024*1024*1024)) sh=20, scale=_T('M');
|
||||
else if (GetVersion()&0x80000000) s=_T('+'); //only display '+' on GB shown on Win95
|
||||
|
||||
if (b >= 1000) //represent everything above 1000 bytes as 0,xx kB
|
||||
{
|
||||
wsprintf(str, _T("%d.%d%d %cB%c"),
|
||||
b>>sh, ((b*10)>>sh)%10, ((b*20)>>sh)%10, scale, s);
|
||||
if (b < 1024)
|
||||
wsprintf(str+_tcsclen(str), _T(" (%u byte%c)"), b, b == 1?0:_T('s'));
|
||||
}
|
||||
else
|
||||
wsprintf(str, _T("%u byte%c"), b, b == 1?0:_T('s'));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/* A simple format parser
|
||||
* Handles %f, %c and %u
|
||||
* size of out must be twice as large as size of str
|
||||
*/
|
||||
static TCHAR * parse(const TCHAR *str, TCHAR *out, int outlen,
|
||||
TCHAR *filename,
|
||||
unsigned long compressed,
|
||||
unsigned long uncompressed,
|
||||
unsigned int nkb)
|
||||
{
|
||||
TCHAR s[32];
|
||||
const TCHAR *p;
|
||||
UINT i=0;
|
||||
p=str-1;
|
||||
memset(out, 0, outlen);
|
||||
|
||||
while (p++ && (*p != 0))
|
||||
{
|
||||
if (*p == _T('%'))
|
||||
{
|
||||
switch (*(p+1))
|
||||
{
|
||||
case _T('c'):
|
||||
case _T('C'):
|
||||
{
|
||||
FormatDiskSize(s, compressed);
|
||||
lstrcat(out, s);
|
||||
i += lstrlen(s);
|
||||
break;
|
||||
}
|
||||
case _T('u'):
|
||||
case _T('U'):
|
||||
{
|
||||
FormatDiskSize(s, uncompressed);
|
||||
lstrcat(out, s);
|
||||
i += lstrlen(s);
|
||||
break;
|
||||
}
|
||||
case _T('f'):
|
||||
case _T('F'):
|
||||
{
|
||||
lstrcat(out, filename);
|
||||
i += lstrlen(filename);
|
||||
break;
|
||||
}
|
||||
case _T('p'):
|
||||
case _T('P'):
|
||||
{
|
||||
unsigned int j;
|
||||
j = uncompressed;
|
||||
if (!j) j = 1;
|
||||
wsprintf(s, _T("%d%%"), nkb*100/j);
|
||||
lstrcat(out, s);
|
||||
i += lstrlen(s);
|
||||
break;
|
||||
}
|
||||
case _T('b'):
|
||||
case _T('B'):
|
||||
{
|
||||
FormatDiskSize(s, nkb);
|
||||
lstrcat(out, s);
|
||||
i += lstrlen(s);
|
||||
break;
|
||||
}
|
||||
default: out[i++] = *p;
|
||||
}
|
||||
++p;
|
||||
} else {
|
||||
out[i++] = *p;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
void Unzip(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||
{
|
||||
EXDLL_INIT();
|
||||
g_hwndParent = hwndParent;
|
||||
internal_unzip(0);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
void UnzipToLog(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||
{
|
||||
EXDLL_INIT();
|
||||
g_hwndParent = hwndParent;
|
||||
internal_unzip(1);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
void UnzipToStack(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||
{
|
||||
EXDLL_INIT();
|
||||
g_hwndParent = hwndParent;
|
||||
internal_unzip(2);
|
||||
}
|
||||
|
||||
// This function is to be used by rundll32.exe. Call it like this:
|
||||
//
|
||||
// rundll32.exe "c:\a path\nsisunz.dll",extract_RunDLL c:\path\zipfile.zip c:\outdir
|
||||
//
|
||||
// or to extract a single file, use this (concatenate the next two lines):
|
||||
//
|
||||
// rundll32.exe c:\path\nsisunz.dll,extract_RunDLL
|
||||
// /file readme.txt "c:\a path\zipfile.zip" c:\outdir
|
||||
//
|
||||
// "/noextractpath" is implicitly used if "/file" is used.
|
||||
// It mimics NSIS itself by setting up a stack and pushing the
|
||||
// parameters from the function on the stack. I made it like this
|
||||
// so I could directly reuse the code I already had written without modifications.
|
||||
extern "C" __declspec(dllexport)
|
||||
void extract_RunDLL(HINSTANCE hAppInstance, LPVOID unused, TCHAR *params)
|
||||
{
|
||||
TCHAR res[1024];
|
||||
TCHAR temp[256];
|
||||
TCHAR zipfile[MAX_PATH]={0,};
|
||||
TCHAR destdir[MAX_PATH]={0,};
|
||||
TCHAR file[MAX_PATH]={0,};
|
||||
TCHAR *p = params;
|
||||
TCHAR *s;
|
||||
TCHAR q=0;
|
||||
int next=0;
|
||||
#define NEXT_FILE 1
|
||||
#define NEXT_ZIP 2
|
||||
#define NEXT_DEST 3
|
||||
|
||||
stack_t ownstacktop;
|
||||
stack_t *pownstacktop = &ownstacktop;
|
||||
|
||||
ownstacktop.next = NULL;
|
||||
ownstacktop.text[0] = NULL;
|
||||
|
||||
g_stringsize=1024;
|
||||
g_stacktop=&pownstacktop;
|
||||
g_variables=NULL;
|
||||
|
||||
//Parse the parameters
|
||||
//While we do the parsing we use next as a clue to
|
||||
//what comes next. This way I don't have to write a
|
||||
//new function.
|
||||
while (*p)
|
||||
{
|
||||
if (*p==_T('"')) q=_T('"'), p++; else q=_T(' '); //Do we search for a quote or a space?
|
||||
s = temp;
|
||||
while (*p && *p != q) *s++ = *p++; //Copy chars from params to zipfile
|
||||
*s = 0; //Terminate string
|
||||
if (next==NEXT_FILE) lstrcpy(file, temp), next=NEXT_ZIP;
|
||||
else if (next==NEXT_ZIP) lstrcpy(zipfile, temp), next=NEXT_DEST;
|
||||
else if (next==NEXT_DEST) lstrcpy(destdir, temp), next=0;
|
||||
else if (!lstrcmpi(temp, szFile)) next=NEXT_FILE;
|
||||
else lstrcpy(zipfile, temp), next=NEXT_DEST;
|
||||
|
||||
while (*p && *++p == _T(' '));
|
||||
}
|
||||
|
||||
pushstring(destdir);
|
||||
pushstring(zipfile);
|
||||
|
||||
if (file[0])
|
||||
{
|
||||
pushstring(file);
|
||||
pushstring(szFile);
|
||||
pushstring(szNoextractpath);
|
||||
}
|
||||
|
||||
internal_unzip(0);
|
||||
popstring(res);
|
||||
if (lstrcmp(res, szSuccess))
|
||||
MessageBox(0, res, NULL, MB_ICONERROR);
|
||||
}
|
||||
|
||||
void internal_unzip(int uselog)
|
||||
{
|
||||
//All char baby (or should I use int for the non-string stuff??)
|
||||
TCHAR first=0;
|
||||
TCHAR filefound=0;
|
||||
TCHAR usefile=0;
|
||||
TCHAR hastext=0;
|
||||
TCHAR noextractpath=0;
|
||||
TCHAR filetoextract[MAX_PATH+1];
|
||||
TCHAR buf[1024];
|
||||
TCHAR fn[MAX_PATH+1];
|
||||
|
||||
popstring(buf);
|
||||
while (buf[0] == _T('/'))
|
||||
{
|
||||
if (!lstrcmpi(buf+1, _T("text"))) popstring(g_extract_text), hastext++;
|
||||
if (!lstrcmpi(buf+1, _T("noextractpath"))) noextractpath++;
|
||||
if (!lstrcmpi(buf+1, _T("file")))
|
||||
{
|
||||
TCHAR *p;
|
||||
popstring(filetoextract);
|
||||
// Ensure filename uses backslashes
|
||||
p = filetoextract;
|
||||
while (*p)
|
||||
{
|
||||
if (*p == _T('/')) *p=_T('\\');
|
||||
p++;
|
||||
}
|
||||
usefile++;
|
||||
}
|
||||
|
||||
//if stack is empty, bail out
|
||||
if (popstring(buf))
|
||||
*buf = 0;
|
||||
}
|
||||
//check for first required param
|
||||
if (*buf)
|
||||
lstrcpyn(fn, buf, MAX_PATH);
|
||||
else
|
||||
{
|
||||
pushstring(_T("Error reading ZIP filename parameter"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (popstring(tempzip_path))
|
||||
{
|
||||
pushstring(_T("Error reading destination directory parameter"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (uselog==1)
|
||||
{
|
||||
if (!hastext) lstrcpy(g_extract_text, szDefExtractText);
|
||||
}
|
||||
|
||||
unzFile f;
|
||||
f = unzOpen(_T2A(fn));
|
||||
if (!f || unzGoToFirstFile(f) != UNZ_OK)
|
||||
{
|
||||
if (f) unzClose(f);
|
||||
pushstring(_T("Error opening ZIP file"));
|
||||
return;
|
||||
}
|
||||
|
||||
int nf=0, nb=0;
|
||||
unz_file_info fileinfo;
|
||||
g_extracting=1;
|
||||
do {
|
||||
char filenameA[MAX_PATH];
|
||||
TCHAR filename[MAX_PATH];
|
||||
unzGetCurrentFileInfo(f,&fileinfo,filenameA,sizeof(filename),NULL,0,NULL,0);
|
||||
lstrcpyn(filename, _A2T(filenameA), MAX_PATH);
|
||||
|
||||
if (filename[0] &&
|
||||
filename[_tcsclen(filename)-1] != _T('\\') &&
|
||||
filename[_tcsclen(filename)-1] != _T('/'))
|
||||
{
|
||||
TCHAR *pfn=filename;
|
||||
//ensure path uses backslashes
|
||||
while (*pfn)
|
||||
{
|
||||
if (*pfn == _T('/')) *pfn=_T('\\');
|
||||
pfn++;
|
||||
}
|
||||
|
||||
if (usefile)
|
||||
{
|
||||
if (lstrcmpi(filename, filetoextract) != 0) continue;
|
||||
else filefound++;
|
||||
}
|
||||
|
||||
pfn=filename;
|
||||
if (pfn[1] == _T(':') && pfn[2] == _T('\\')) pfn+=3;
|
||||
while (*pfn == _T('\\')) pfn++;
|
||||
|
||||
if (noextractpath)
|
||||
{
|
||||
TCHAR buf[MAX_PATH];
|
||||
lstrcpy(buf,filename);
|
||||
TCHAR *p=buf+_tcsclen(buf);
|
||||
while (p > buf && *p != _T('\\') && *p != _T('/')) p = CharPrev(buf, p);
|
||||
if (p > buf) p++;
|
||||
lstrcpy(filename, p);
|
||||
}
|
||||
|
||||
TCHAR out_filename[1024];
|
||||
lstrcpy(out_filename,tempzip_path);
|
||||
lstrcat(out_filename,_T("\\"));
|
||||
lstrcat(out_filename,pfn);
|
||||
if (_tcsstr(pfn,_T("\\")))
|
||||
{
|
||||
TCHAR buf[1024];
|
||||
lstrcpy(buf,out_filename);
|
||||
TCHAR *p=buf+_tcsclen(buf);
|
||||
while (p > buf && *p != _T('\\')) p--;
|
||||
*p=0;
|
||||
if (buf[0]) doMKDir(buf);
|
||||
}
|
||||
|
||||
if (unzOpenCurrentFile(f) == UNZ_OK)
|
||||
{
|
||||
FILE *fp;
|
||||
int l;
|
||||
fp = _tfopen(out_filename,_T("wb"));
|
||||
if (fp)
|
||||
{
|
||||
if (uselog==1) {
|
||||
TCHAR logtmp[256];
|
||||
parse(g_extract_text, logtmp, sizeof(logtmp),
|
||||
pfn, fileinfo.compressed_size, fileinfo.uncompressed_size, 0);
|
||||
LogMessage(g_hwndParent, logtmp);
|
||||
} else if (uselog == 2) {
|
||||
if (!first)
|
||||
{
|
||||
pushstring(_T("")); //push list terminator (empty string)
|
||||
first++;
|
||||
}
|
||||
pushstring(pfn);
|
||||
}
|
||||
nb=0;
|
||||
do
|
||||
{
|
||||
TCHAR buf[1024];
|
||||
l=unzReadCurrentFile(f,buf,sizeof(buf));
|
||||
if (l > 0)
|
||||
{
|
||||
if (fwrite(buf,1,l,fp) != (unsigned int)l)
|
||||
{
|
||||
unzClose(f);
|
||||
fclose(fp);
|
||||
pushstring(_T("Error writing output file(s)"));
|
||||
g_extracting=0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_extracting)
|
||||
{
|
||||
unzClose(f);
|
||||
fclose(fp);
|
||||
g_extracting=0;
|
||||
pushstring(_T("aborted"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (uselog==1 && (nb % 1024))
|
||||
{
|
||||
TCHAR logtmp[256];
|
||||
parse(g_extract_text, logtmp, sizeof(logtmp),
|
||||
pfn, fileinfo.compressed_size,
|
||||
fileinfo.uncompressed_size, nb);
|
||||
LogMessage(g_hwndParent, logtmp, 1);
|
||||
}
|
||||
nb += l;
|
||||
} while (l > 0);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
unzClose(f);
|
||||
pushstring(_T("Error opening output file(s)"));
|
||||
g_extracting=0;
|
||||
return;
|
||||
}
|
||||
nf++;
|
||||
|
||||
int quit=0;
|
||||
if (g_hwndParent)
|
||||
{
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
|
||||
{
|
||||
if (msg.message == WM_DESTROY && msg.hwnd == g_hwndParent)
|
||||
{
|
||||
quit++;
|
||||
break;
|
||||
}
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
unzCloseCurrentFile(f);
|
||||
if (quit) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
unzClose(f);
|
||||
pushstring(_T("Error extracting from ZIP file"));
|
||||
g_extracting=0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} while (unzGoToNextFile(f) == UNZ_OK);
|
||||
|
||||
g_extracting=0;
|
||||
if (usefile && !filefound) {
|
||||
pushstring(_T("File not found in archive"));
|
||||
} else {
|
||||
pushstring(szSuccess);
|
||||
}
|
||||
unzClose(f);
|
||||
return;
|
||||
}
|
||||
|
||||
// Tim Kosse's LogMessage
|
||||
void LogMessage(HWND hwndParent, const TCHAR *pStr, int changelast) {
|
||||
static HWND hwndList=0;
|
||||
static HWND hwndStatus=0;
|
||||
LVITEM item={0};
|
||||
int nItemCount;
|
||||
if (!hwndParent) return;
|
||||
|
||||
EnterCriticalSection(&cs);
|
||||
|
||||
//Get ListView control on instfiles page (the log)
|
||||
if (!hwndList) hwndList = FindWindowEx(
|
||||
FindWindowEx(hwndParent, NULL, _T("#32770"), NULL),
|
||||
NULL, _T("SysListView32"), NULL);
|
||||
|
||||
//Get status "STATIC" control above progressbar
|
||||
if (!hwndStatus) hwndStatus = GetDlgItem(
|
||||
FindWindowEx(hwndParent, NULL, _T("#32770"), NULL),
|
||||
1006);
|
||||
|
||||
if (!hwndList || !hwndStatus) return;
|
||||
|
||||
SendMessage(hwndStatus, WM_SETTEXT, 0, (LPARAM)pStr);//added by Saivert
|
||||
nItemCount=SendMessage(hwndList, LVM_GETITEMCOUNT, 0, 0);
|
||||
|
||||
item.mask=LVIF_TEXT;
|
||||
item.pszText=(TCHAR *)pStr;
|
||||
item.cchTextMax=0;
|
||||
item.iItem=changelast?nItemCount-1:nItemCount;
|
||||
|
||||
if (changelast) {
|
||||
ListView_SetItem(hwndList, &item);
|
||||
} else {
|
||||
ListView_InsertItem(hwndList, &item);
|
||||
}
|
||||
ListView_EnsureVisible(hwndList, item.iItem, 0);
|
||||
|
||||
LeaveCriticalSection(&cs);
|
||||
}
|
||||
|
||||
// EXPERIMENTAL THREAD BASED EXTRACTION
|
||||
/*
|
||||
extern "C" __declspec(dllexport)
|
||||
UnzipToLogUsingThread(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
||||
{
|
||||
MSG msg;
|
||||
DWORD dwTID;
|
||||
|
||||
CreateThread(NULL, 0, UnzipThread, (LPVOID)1, 0, &dwTID);
|
||||
}
|
||||
|
||||
DWORD WINAPI UnzipThread(LPVOID p)
|
||||
{
|
||||
int uselog = 1;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
#ifdef UNICODE
|
||||
unsigned char staticCnvBuffer[1024*sizeof(TCHAR)]; /* temp buffer, holds ASCII & UNICODE string after conversion */
|
||||
char * _T2A(wchar_t *wideStr)
|
||||
{
|
||||
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, (LPSTR)staticCnvBuffer, sizeof(staticCnvBuffer), NULL, NULL);
|
||||
return (char *)staticCnvBuffer;
|
||||
}
|
||||
wchar_t * _A2T(char *ansiStr)
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, (TCHAR *)staticCnvBuffer, sizeof(staticCnvBuffer)/sizeof(TCHAR));
|
||||
return (wchar_t *)staticCnvBuffer;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
LIBRARY nsisunz
|
||||
EXPORTS
|
||||
Unzip
|
||||
UnzipToLog
|
||||
UnzipToStack
|
||||
@@ -0,0 +1,527 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="nsisunz"
|
||||
ProjectGUID="{8534CD66-1841-45FC-9201-FA3515F5967B}"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/nsisunz.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;UNZIP_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/nsisunz.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1044"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Debug/nsisunz.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/nsisunz.pdb"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary=".\Debug/nsisunz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/nsisunz.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UNZIP_EXPORTS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/nsisunz.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1044"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="pluginapi.lib"
|
||||
OutputFile=".\Release/nsisunz.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
ProgramDatabaseFile=".\Release/nsisunz.pdb"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary=".\Release/nsisunz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath="zlib\ADLER32.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\CRC32.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFBLOCK.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFCODES.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFFAST.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFLATE.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFTREES.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFUTIL.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="nsisunz.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\Unzip.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\Zutil.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath="zlib\INFBLOCK.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFCODES.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFFAST.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFFIXED.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFTREES.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFUTIL.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\UNZIP.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\ZCONF.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\ZLIB.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\ZUTIL.H"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release Unicode|Win32">
|
||||
<Configuration>Release Unicode</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release Unicode|x64">
|
||||
<Configuration>Release Unicode</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}</ProjectGuid>
|
||||
<RootNamespace>nsisunz</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'"
|
||||
Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'"
|
||||
Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
|
||||
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
|
||||
Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>nsisunz</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'">
|
||||
<OutDir>Build\x86-unicode\</OutDir>
|
||||
<IntDir>Build\x86-unicode\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'">
|
||||
<OutDir>Build\x64-unicode\</OutDir>
|
||||
<IntDir>Build\x64-unicode\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>Build\x86-ansi\</OutDir>
|
||||
<IntDir>Build\x86-ansi\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>Build\x64-ansi\</OutDir>
|
||||
<IntDir>Build\x64-ansi\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;UNICODE;_UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;UNICODE;_UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="nsisunz.cpp" />
|
||||
<ClCompile Include="zlib\ADLER32.C" />
|
||||
<ClCompile Include="zlib\CRC32.C" />
|
||||
<ClCompile Include="zlib\INFBLOCK.C" />
|
||||
<ClCompile Include="zlib\INFCODES.C" />
|
||||
<ClCompile Include="zlib\INFFAST.C" />
|
||||
<ClCompile Include="zlib\INFLATE.C" />
|
||||
<ClCompile Include="zlib\INFTREES.C" />
|
||||
<ClCompile Include="zlib\INFUTIL.C" />
|
||||
<ClCompile Include="zlib\Unzip.c" />
|
||||
<ClCompile Include="zlib\Zutil.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\ExDLL\exdll.h" />
|
||||
<ClInclude Include="AggressiveOptimize.h" />
|
||||
<ClInclude Include="zlib\INFBLOCK.H" />
|
||||
<ClInclude Include="zlib\INFCODES.H" />
|
||||
<ClInclude Include="zlib\INFFAST.H" />
|
||||
<ClInclude Include="zlib\INFFIXED.H" />
|
||||
<ClInclude Include="zlib\INFTREES.H" />
|
||||
<ClInclude Include="zlib\INFUTIL.H" />
|
||||
<ClInclude Include="zlib\UNZIP.H" />
|
||||
<ClInclude Include="zlib\ZCONF.H" />
|
||||
<ClInclude Include="zlib\ZLIB.H" />
|
||||
<ClInclude Include="zlib\ZUTIL.H" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="nsisunz.def" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,48 @@
|
||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id: ADLER32.C,v 1.1.1.1 2002/08/02 09:59:32 kichik Exp $ */
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#define BASE 65521L /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
|
||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
unsigned long s1 = adler & 0xffff;
|
||||
unsigned long s2 = (adler >> 16) & 0xffff;
|
||||
int k;
|
||||
|
||||
if (buf == Z_NULL) return 1L;
|
||||
|
||||
while (len > 0) {
|
||||
k = len < NMAX ? len : NMAX;
|
||||
len -= k;
|
||||
while (k >= 16) {
|
||||
DO16(buf);
|
||||
buf += 16;
|
||||
k -= 16;
|
||||
}
|
||||
if (k != 0) do {
|
||||
s1 += *buf++;
|
||||
s2 += s1;
|
||||
} while (--k);
|
||||
s1 %= BASE;
|
||||
s2 %= BASE;
|
||||
}
|
||||
return (s2 << 16) | s1;
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/* crc32.c -- compute the CRC-32 of a data stream
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id: CRC32.C,v 1.1.1.1 2002/08/02 09:59:33 kichik Exp $ */
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#define local static
|
||||
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
|
||||
local int crc_table_empty = 1;
|
||||
local uLongf crc_table[256];
|
||||
local void make_crc_table OF((void));
|
||||
|
||||
/*
|
||||
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
|
||||
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
|
||||
|
||||
Polynomials over GF(2) are represented in binary, one bit per coefficient,
|
||||
with the lowest powers in the most significant bit. Then adding polynomials
|
||||
is just exclusive-or, and multiplying a polynomial by x is a right shift by
|
||||
one. If we call the above polynomial p, and represent a byte as the
|
||||
polynomial q, also with the lowest power in the most significant bit (so the
|
||||
byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
|
||||
where a mod b means the remainder after dividing a by b.
|
||||
|
||||
This calculation is done using the shift-register method of multiplying and
|
||||
taking the remainder. The register is initialized to zero, and for each
|
||||
incoming bit, x^32 is added mod p to the register if the bit is a one (where
|
||||
x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
|
||||
x (which is shifting right by one and adding x^32 mod p if the bit shifted
|
||||
out is a one). We start with the highest power (least significant bit) of
|
||||
q and repeat for all eight bits of q.
|
||||
|
||||
The table is simply the CRC of all possible eight bit values. This is all
|
||||
the information needed to generate CRC's on data a byte at a time for all
|
||||
combinations of CRC register values and incoming bytes.
|
||||
*/
|
||||
local void make_crc_table()
|
||||
{
|
||||
uLong c;
|
||||
int n, k;
|
||||
uLong poly; /* polynomial exclusive-or pattern */
|
||||
/* terms of polynomial defining this crc (except x^32): */
|
||||
static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
||||
|
||||
/* make exclusive-or pattern from polynomial (0xedb88320L) */
|
||||
poly = 0L;
|
||||
for (n = 0; n < sizeof(p)/sizeof(Byte); n++)
|
||||
poly |= 1L << (31 - p[n]);
|
||||
|
||||
for (n = 0; n < 256; n++)
|
||||
{
|
||||
c = (uLong)n;
|
||||
for (k = 0; k < 8; k++)
|
||||
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
||||
crc_table[n] = c;
|
||||
}
|
||||
crc_table_empty = 0;
|
||||
}
|
||||
#else
|
||||
/* ========================================================================
|
||||
* Table of CRC-32's of all single-byte values (made by make_crc_table)
|
||||
*/
|
||||
local const uLongf crc_table[256] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
#endif
|
||||
|
||||
/* =========================================================================
|
||||
* This function can be used by asm versions of crc32()
|
||||
*/
|
||||
const uLongf * ZEXPORT get_crc_table()
|
||||
{
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
if (crc_table_empty) make_crc_table();
|
||||
#endif
|
||||
return (const uLongf *)crc_table;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
|
||||
#define DO2(buf) DO1(buf); DO1(buf);
|
||||
#define DO4(buf) DO2(buf); DO2(buf);
|
||||
#define DO8(buf) DO4(buf); DO4(buf);
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT crc32(crc, buf, len)
|
||||
uLong crc;
|
||||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
if (buf == Z_NULL) return 0L;
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
if (crc_table_empty)
|
||||
make_crc_table();
|
||||
#endif
|
||||
crc = crc ^ 0xffffffffL;
|
||||
while (len >= 8)
|
||||
{
|
||||
DO8(buf);
|
||||
len -= 8;
|
||||
}
|
||||
if (len) do {
|
||||
DO1(buf);
|
||||
} while (--len);
|
||||
return crc ^ 0xffffffffL;
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
/* infblock.c -- interpret and process block types to last block
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "infblock.h"
|
||||
#include "inftrees.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
/* Table for deflate from PKZIP's appnote.txt. */
|
||||
local const uInt border[] = { /* Order of the bit length code lengths */
|
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
||||
|
||||
/*
|
||||
Notes beyond the 1.93a appnote.txt:
|
||||
|
||||
1. Distance pointers never point before the beginning of the output
|
||||
stream.
|
||||
2. Distance pointers can point back across blocks, up to 32k away.
|
||||
3. There is an implied maximum of 7 bits for the bit length table and
|
||||
15 bits for the actual data.
|
||||
4. If only one code exists, then it is encoded using one bit. (Zero
|
||||
would be more efficient, but perhaps a little confusing.) If two
|
||||
codes exist, they are coded using one bit each (0 and 1).
|
||||
5. There is no way of sending zero distance codes--a dummy must be
|
||||
sent if there are none. (History: a pre 2.0 version of PKZIP would
|
||||
store blocks with no distance codes, but this was discovered to be
|
||||
too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
|
||||
zero distance codes, which is sent as one code of zero bits in
|
||||
length.
|
||||
6. There are up to 286 literal/length codes. Code 256 represents the
|
||||
end-of-block. Note however that the static length tree defines
|
||||
288 codes just to fill out the Huffman codes. Codes 286 and 287
|
||||
cannot be used though, since there is no length base or extra bits
|
||||
defined for them. Similarily, there are up to 30 distance codes.
|
||||
However, static trees define 32 codes (all 5 bits) to fill out the
|
||||
Huffman codes, but the last two had better not show up in the data.
|
||||
7. Unzip can check dynamic Huffman blocks for complete code sets.
|
||||
The exception is that a single code would not be complete (see #4).
|
||||
8. The five bits following the block type is really the number of
|
||||
literal codes sent minus 257.
|
||||
9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
|
||||
(1+6+6). Therefore, to output three times the length, you output
|
||||
three codes (1+1+1), whereas to output four times the same length,
|
||||
you only need two codes (1+3). Hmm.
|
||||
10. In the tree reconstruction algorithm, Code = Code + Increment
|
||||
only if BitLength(i) is not zero. (Pretty obvious.)
|
||||
11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
|
||||
12. Note: length code 284 can represent 227-258, but length code 285
|
||||
really is 258. The last length deserves its own, short code
|
||||
since it gets used a lot in very redundant files. The length
|
||||
258 is special since 258 - 3 (the min match length) is 255.
|
||||
13. The literal/length and distance code bit lengths are read as a
|
||||
single stream of lengths. It is possible (and advantageous) for
|
||||
a repeat code (16, 17, or 18) to go across the boundary between
|
||||
the two sets of lengths.
|
||||
*/
|
||||
|
||||
|
||||
void inflate_blocks_reset(s, z, c)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
uLongf *c;
|
||||
{
|
||||
if (c != Z_NULL)
|
||||
*c = s->check;
|
||||
if (s->mode == BTREE || s->mode == DTREE)
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
if (s->mode == CODES)
|
||||
inflate_codes_free(s->sub.decode.codes, z);
|
||||
s->mode = TYPE;
|
||||
s->bitk = 0;
|
||||
s->bitb = 0;
|
||||
s->read = s->write = s->window;
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
|
||||
Tracev((stderr, "inflate: blocks reset\n"));
|
||||
}
|
||||
|
||||
|
||||
inflate_blocks_statef *inflate_blocks_new(z, c, w)
|
||||
z_streamp z;
|
||||
check_func c;
|
||||
uInt w;
|
||||
{
|
||||
inflate_blocks_statef *s;
|
||||
|
||||
if ((s = (inflate_blocks_statef *)ZALLOC
|
||||
(z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
|
||||
return s;
|
||||
if ((s->hufts =
|
||||
(inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, s);
|
||||
return Z_NULL;
|
||||
}
|
||||
if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, s->hufts);
|
||||
ZFREE(z, s);
|
||||
return Z_NULL;
|
||||
}
|
||||
s->end = s->window + w;
|
||||
s->checkfn = c;
|
||||
s->mode = TYPE;
|
||||
Tracev((stderr, "inflate: blocks allocated\n"));
|
||||
inflate_blocks_reset(s, z, Z_NULL);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
int inflate_blocks(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt t; /* temporary storage */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
|
||||
/* copy input/output information to locals (UPDATE macro restores) */
|
||||
LOAD
|
||||
|
||||
/* process input based on current state */
|
||||
while (1) switch (s->mode)
|
||||
{
|
||||
case TYPE:
|
||||
NEEDBITS(3)
|
||||
t = (uInt)b & 7;
|
||||
s->last = t & 1;
|
||||
switch (t >> 1)
|
||||
{
|
||||
case 0: /* stored */
|
||||
Tracev((stderr, "inflate: stored block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
DUMPBITS(3)
|
||||
t = k & 7; /* go to byte boundary */
|
||||
DUMPBITS(t)
|
||||
s->mode = LENS; /* get length of stored block */
|
||||
break;
|
||||
case 1: /* fixed */
|
||||
Tracev((stderr, "inflate: fixed codes block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
{
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl, *td;
|
||||
|
||||
inflate_trees_fixed(&bl, &bd, &tl, &td, z);
|
||||
s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
|
||||
if (s->sub.decode.codes == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
}
|
||||
DUMPBITS(3)
|
||||
s->mode = CODES;
|
||||
break;
|
||||
case 2: /* dynamic */
|
||||
Tracev((stderr, "inflate: dynamic codes block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
DUMPBITS(3)
|
||||
s->mode = TABLE;
|
||||
break;
|
||||
case 3: /* illegal */
|
||||
DUMPBITS(3)
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid block type";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
break;
|
||||
case LENS:
|
||||
NEEDBITS(32)
|
||||
if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
|
||||
{
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid stored block lengths";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
s->sub.left = (uInt)b & 0xffff;
|
||||
b = k = 0; /* dump bits */
|
||||
Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
|
||||
s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
|
||||
break;
|
||||
case STORED:
|
||||
if (n == 0)
|
||||
LEAVE
|
||||
NEEDOUT
|
||||
t = s->sub.left;
|
||||
if (t > n) t = n;
|
||||
if (t > m) t = m;
|
||||
zmemcpy(q, p, t);
|
||||
p += t; n -= t;
|
||||
q += t; m -= t;
|
||||
if ((s->sub.left -= t) != 0)
|
||||
break;
|
||||
Tracev((stderr, "inflate: stored end, %lu total out\n",
|
||||
z->total_out + (q >= s->read ? q - s->read :
|
||||
(s->end - s->read) + (q - s->window))));
|
||||
s->mode = s->last ? DRY : TYPE;
|
||||
break;
|
||||
case TABLE:
|
||||
NEEDBITS(14)
|
||||
s->sub.trees.table = t = (uInt)b & 0x3fff;
|
||||
#ifndef PKZIP_BUG_WORKAROUND
|
||||
if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
|
||||
{
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"too many length or distance symbols";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
#endif
|
||||
t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
|
||||
if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
DUMPBITS(14)
|
||||
s->sub.trees.index = 0;
|
||||
Tracev((stderr, "inflate: table sizes ok\n"));
|
||||
s->mode = BTREE;
|
||||
case BTREE:
|
||||
while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
|
||||
{
|
||||
NEEDBITS(3)
|
||||
s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
|
||||
DUMPBITS(3)
|
||||
}
|
||||
while (s->sub.trees.index < 19)
|
||||
s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
|
||||
s->sub.trees.bb = 7;
|
||||
t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
|
||||
&s->sub.trees.tb, s->hufts, z);
|
||||
if (t != Z_OK)
|
||||
{
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
r = t;
|
||||
if (r == Z_DATA_ERROR)
|
||||
s->mode = BAD;
|
||||
LEAVE
|
||||
}
|
||||
s->sub.trees.index = 0;
|
||||
Tracev((stderr, "inflate: bits tree ok\n"));
|
||||
s->mode = DTREE;
|
||||
case DTREE:
|
||||
while (t = s->sub.trees.table,
|
||||
s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
|
||||
{
|
||||
inflate_huft *h;
|
||||
uInt i, j, c;
|
||||
|
||||
t = s->sub.trees.bb;
|
||||
NEEDBITS(t)
|
||||
h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
|
||||
t = h->bits;
|
||||
c = h->base;
|
||||
if (c < 16)
|
||||
{
|
||||
DUMPBITS(t)
|
||||
s->sub.trees.blens[s->sub.trees.index++] = c;
|
||||
}
|
||||
else /* c == 16..18 */
|
||||
{
|
||||
i = c == 18 ? 7 : c - 14;
|
||||
j = c == 18 ? 11 : 3;
|
||||
NEEDBITS(t + i)
|
||||
DUMPBITS(t)
|
||||
j += (uInt)b & inflate_mask[i];
|
||||
DUMPBITS(i)
|
||||
i = s->sub.trees.index;
|
||||
t = s->sub.trees.table;
|
||||
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
|
||||
(c == 16 && i < 1))
|
||||
{
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid bit length repeat";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
|
||||
do {
|
||||
s->sub.trees.blens[i++] = c;
|
||||
} while (--j);
|
||||
s->sub.trees.index = i;
|
||||
}
|
||||
}
|
||||
s->sub.trees.tb = Z_NULL;
|
||||
{
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl, *td;
|
||||
inflate_codes_statef *c;
|
||||
|
||||
bl = 9; /* must be <= 9 for lookahead assumptions */
|
||||
bd = 6; /* must be <= 9 for lookahead assumptions */
|
||||
t = s->sub.trees.table;
|
||||
t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
|
||||
s->sub.trees.blens, &bl, &bd, &tl, &td,
|
||||
s->hufts, z);
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
if (t != Z_OK)
|
||||
{
|
||||
if (t == (uInt)Z_DATA_ERROR)
|
||||
s->mode = BAD;
|
||||
r = t;
|
||||
LEAVE
|
||||
}
|
||||
Tracev((stderr, "inflate: trees ok\n"));
|
||||
if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
s->sub.decode.codes = c;
|
||||
}
|
||||
s->mode = CODES;
|
||||
case CODES:
|
||||
UPDATE
|
||||
if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
|
||||
return inflate_flush(s, z, r);
|
||||
r = Z_OK;
|
||||
inflate_codes_free(s->sub.decode.codes, z);
|
||||
LOAD
|
||||
Tracev((stderr, "inflate: codes end, %lu total out\n",
|
||||
z->total_out + (q >= s->read ? q - s->read :
|
||||
(s->end - s->read) + (q - s->window))));
|
||||
if (!s->last)
|
||||
{
|
||||
s->mode = TYPE;
|
||||
break;
|
||||
}
|
||||
s->mode = DRY;
|
||||
case DRY:
|
||||
FLUSH
|
||||
if (s->read != s->write)
|
||||
LEAVE
|
||||
s->mode = DONE;
|
||||
case DONE:
|
||||
r = Z_STREAM_END;
|
||||
LEAVE
|
||||
case BAD:
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
default:
|
||||
r = Z_STREAM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int inflate_blocks_free(s, z)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_blocks_reset(s, z, Z_NULL);
|
||||
ZFREE(z, s->window);
|
||||
ZFREE(z, s->hufts);
|
||||
ZFREE(z, s);
|
||||
Tracev((stderr, "inflate: blocks freed\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
void inflate_set_dictionary(s, d, n)
|
||||
inflate_blocks_statef *s;
|
||||
const Bytef *d;
|
||||
uInt n;
|
||||
{
|
||||
zmemcpy(s->window, d, n);
|
||||
s->read = s->write = s->window + n;
|
||||
}
|
||||
|
||||
|
||||
/* Returns true if inflate is currently at the end of a block generated
|
||||
* by Z_SYNC_FLUSH or Z_FULL_FLUSH.
|
||||
* IN assertion: s != Z_NULL
|
||||
*/
|
||||
int inflate_blocks_sync_point(s)
|
||||
inflate_blocks_statef *s;
|
||||
{
|
||||
return s->mode == LENS;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/* infblock.h -- header to use infblock.c
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
struct inflate_blocks_state;
|
||||
typedef struct inflate_blocks_state FAR inflate_blocks_statef;
|
||||
|
||||
extern inflate_blocks_statef * inflate_blocks_new OF((
|
||||
z_streamp z,
|
||||
check_func c, /* check function */
|
||||
uInt w)); /* window size */
|
||||
|
||||
extern int inflate_blocks OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int)); /* initial return code */
|
||||
|
||||
extern void inflate_blocks_reset OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
uLongf *)); /* check value on output */
|
||||
|
||||
extern int inflate_blocks_free OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp));
|
||||
|
||||
extern void inflate_set_dictionary OF((
|
||||
inflate_blocks_statef *s,
|
||||
const Bytef *d, /* dictionary */
|
||||
uInt n)); /* dictionary length */
|
||||
|
||||
extern int inflate_blocks_sync_point OF((
|
||||
inflate_blocks_statef *s));
|
||||
@@ -0,0 +1,257 @@
|
||||
/* infcodes.c -- process literals and length/distance pairs
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
#include "infblock.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
#include "inffast.h"
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
|
||||
START, /* x: set up for LEN */
|
||||
LEN, /* i: get length/literal/eob next */
|
||||
LENEXT, /* i: getting length extra (have base) */
|
||||
DIST, /* i: get distance next */
|
||||
DISTEXT, /* i: getting distance extra */
|
||||
COPY, /* o: copying bytes in window, waiting for space */
|
||||
LIT, /* o: got literal, waiting for output space */
|
||||
WASH, /* o: got eob, possibly still output waiting */
|
||||
END, /* x: got eob and all data flushed */
|
||||
BADCODE} /* x: got error */
|
||||
inflate_codes_mode;
|
||||
|
||||
/* inflate codes private state */
|
||||
struct inflate_codes_state {
|
||||
|
||||
/* mode */
|
||||
inflate_codes_mode mode; /* current inflate_codes mode */
|
||||
|
||||
/* mode dependent information */
|
||||
uInt len;
|
||||
union {
|
||||
struct {
|
||||
inflate_huft *tree; /* pointer into tree */
|
||||
uInt need; /* bits needed */
|
||||
} code; /* if LEN or DIST, where in tree */
|
||||
uInt lit; /* if LIT, literal */
|
||||
struct {
|
||||
uInt get; /* bits to get for extra */
|
||||
uInt dist; /* distance back to copy from */
|
||||
} copy; /* if EXT or COPY, where and how much */
|
||||
} sub; /* submode */
|
||||
|
||||
/* mode independent information */
|
||||
Byte lbits; /* ltree bits decoded per branch */
|
||||
Byte dbits; /* dtree bits decoder per branch */
|
||||
inflate_huft *ltree; /* literal/length/eob tree */
|
||||
inflate_huft *dtree; /* distance tree */
|
||||
|
||||
};
|
||||
|
||||
|
||||
inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl;
|
||||
inflate_huft *td; /* need separate declaration for Borland C++ */
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_codes_statef *c;
|
||||
|
||||
if ((c = (inflate_codes_statef *)
|
||||
ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
|
||||
{
|
||||
c->mode = START;
|
||||
c->lbits = (Byte)bl;
|
||||
c->dbits = (Byte)bd;
|
||||
c->ltree = tl;
|
||||
c->dtree = td;
|
||||
Tracev((stderr, "inflate: codes new\n"));
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
int inflate_codes(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt j; /* temporary storage */
|
||||
inflate_huft *t; /* temporary pointer */
|
||||
uInt e; /* extra bits or operation */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
Bytef *f; /* pointer to copy strings from */
|
||||
inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
|
||||
|
||||
/* copy input/output information to locals (UPDATE macro restores) */
|
||||
LOAD
|
||||
|
||||
/* process input and output based on current state */
|
||||
while (1) switch (c->mode)
|
||||
{ /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
|
||||
case START: /* x: set up for LEN */
|
||||
#ifndef SLOW
|
||||
if (m >= 258 && n >= 10)
|
||||
{
|
||||
UPDATE
|
||||
r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
|
||||
LOAD
|
||||
if (r != Z_OK)
|
||||
{
|
||||
c->mode = r == Z_STREAM_END ? WASH : BADCODE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* !SLOW */
|
||||
c->sub.code.need = c->lbits;
|
||||
c->sub.code.tree = c->ltree;
|
||||
c->mode = LEN;
|
||||
case LEN: /* i: get length/literal/eob next */
|
||||
j = c->sub.code.need;
|
||||
NEEDBITS(j)
|
||||
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
|
||||
DUMPBITS(t->bits)
|
||||
e = (uInt)(t->exop);
|
||||
if (e == 0) /* literal */
|
||||
{
|
||||
c->sub.lit = t->base;
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: literal '%c'\n" :
|
||||
"inflate: literal 0x%02x\n", t->base));
|
||||
c->mode = LIT;
|
||||
break;
|
||||
}
|
||||
if (e & 16) /* length */
|
||||
{
|
||||
c->sub.copy.get = e & 15;
|
||||
c->len = t->base;
|
||||
c->mode = LENEXT;
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0) /* next table */
|
||||
{
|
||||
c->sub.code.need = e;
|
||||
c->sub.code.tree = t + t->base;
|
||||
break;
|
||||
}
|
||||
if (e & 32) /* end of block */
|
||||
{
|
||||
Tracevv((stderr, "inflate: end of block\n"));
|
||||
c->mode = WASH;
|
||||
break;
|
||||
}
|
||||
c->mode = BADCODE; /* invalid code */
|
||||
z->msg = (char*)"invalid literal/length code";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
case LENEXT: /* i: getting length extra (have base) */
|
||||
j = c->sub.copy.get;
|
||||
NEEDBITS(j)
|
||||
c->len += (uInt)b & inflate_mask[j];
|
||||
DUMPBITS(j)
|
||||
c->sub.code.need = c->dbits;
|
||||
c->sub.code.tree = c->dtree;
|
||||
Tracevv((stderr, "inflate: length %u\n", c->len));
|
||||
c->mode = DIST;
|
||||
case DIST: /* i: get distance next */
|
||||
j = c->sub.code.need;
|
||||
NEEDBITS(j)
|
||||
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
|
||||
DUMPBITS(t->bits)
|
||||
e = (uInt)(t->exop);
|
||||
if (e & 16) /* distance */
|
||||
{
|
||||
c->sub.copy.get = e & 15;
|
||||
c->sub.copy.dist = t->base;
|
||||
c->mode = DISTEXT;
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0) /* next table */
|
||||
{
|
||||
c->sub.code.need = e;
|
||||
c->sub.code.tree = t + t->base;
|
||||
break;
|
||||
}
|
||||
c->mode = BADCODE; /* invalid code */
|
||||
z->msg = (char*)"invalid distance code";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
case DISTEXT: /* i: getting distance extra */
|
||||
j = c->sub.copy.get;
|
||||
NEEDBITS(j)
|
||||
c->sub.copy.dist += (uInt)b & inflate_mask[j];
|
||||
DUMPBITS(j)
|
||||
Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
|
||||
c->mode = COPY;
|
||||
case COPY: /* o: copying bytes in window, waiting for space */
|
||||
#ifndef __TURBOC__ /* Turbo C bug for following expression */
|
||||
f = (uInt)(q - s->window) < c->sub.copy.dist ?
|
||||
s->end - (c->sub.copy.dist - (q - s->window)) :
|
||||
q - c->sub.copy.dist;
|
||||
#else
|
||||
f = q - c->sub.copy.dist;
|
||||
if ((uInt)(q - s->window) < c->sub.copy.dist)
|
||||
f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));
|
||||
#endif
|
||||
while (c->len)
|
||||
{
|
||||
NEEDOUT
|
||||
OUTBYTE(*f++)
|
||||
if (f == s->end)
|
||||
f = s->window;
|
||||
c->len--;
|
||||
}
|
||||
c->mode = START;
|
||||
break;
|
||||
case LIT: /* o: got literal, waiting for output space */
|
||||
NEEDOUT
|
||||
OUTBYTE(c->sub.lit)
|
||||
c->mode = START;
|
||||
break;
|
||||
case WASH: /* o: got eob, possibly more output */
|
||||
if (k > 7) /* return unused byte, if any */
|
||||
{
|
||||
Assert(k < 16, "inflate_codes grabbed too many bytes")
|
||||
k -= 8;
|
||||
n++;
|
||||
p--; /* can always return one */
|
||||
}
|
||||
FLUSH
|
||||
if (s->read != s->write)
|
||||
LEAVE
|
||||
c->mode = END;
|
||||
case END:
|
||||
r = Z_STREAM_END;
|
||||
LEAVE
|
||||
case BADCODE: /* x: got error */
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
default:
|
||||
r = Z_STREAM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
#ifdef NEED_DUMMY_RETURN
|
||||
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void inflate_codes_free(c, z)
|
||||
inflate_codes_statef *c;
|
||||
z_streamp z;
|
||||
{
|
||||
ZFREE(z, c);
|
||||
Tracev((stderr, "inflate: codes free\n"));
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/* infcodes.h -- header to use infcodes.c
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
struct inflate_codes_state;
|
||||
typedef struct inflate_codes_state FAR inflate_codes_statef;
|
||||
|
||||
extern inflate_codes_statef *inflate_codes_new OF((
|
||||
uInt, uInt,
|
||||
inflate_huft *, inflate_huft *,
|
||||
z_streamp ));
|
||||
|
||||
extern int inflate_codes OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int));
|
||||
|
||||
extern void inflate_codes_free OF((
|
||||
inflate_codes_statef *,
|
||||
z_streamp ));
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
/* inffast.c -- process literals and length/distance pairs fast
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
#include "infblock.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
#include "inffast.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
/* macros for bit input with no checking and for returning unused bytes */
|
||||
#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
|
||||
#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
|
||||
|
||||
/* Called with number of bytes left to write in window at least 258
|
||||
(the maximum string length) and number of input bytes available
|
||||
at least ten. The ten bytes are six bytes for the longest length/
|
||||
distance pair plus four bytes for overloading the bit buffer. */
|
||||
|
||||
int inflate_fast(bl, bd, tl, td, s, z)
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl;
|
||||
inflate_huft *td; /* need separate declaration for Borland C++ */
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_huft *t; /* temporary pointer */
|
||||
uInt e; /* extra bits or operation */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
uInt ml; /* mask for literal/length tree */
|
||||
uInt md; /* mask for distance tree */
|
||||
uInt c; /* bytes to copy */
|
||||
uInt d; /* distance back to copy from */
|
||||
Bytef *r; /* copy source pointer */
|
||||
|
||||
/* load input, output, bit values */
|
||||
LOAD
|
||||
|
||||
/* initialize masks */
|
||||
ml = inflate_mask[bl];
|
||||
md = inflate_mask[bd];
|
||||
|
||||
/* do until not enough input or output space for fast loop */
|
||||
do { /* assume called with m >= 258 && n >= 10 */
|
||||
/* get literal/length code */
|
||||
GRABBITS(20) /* max bits for literal/length code */
|
||||
if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
|
||||
{
|
||||
DUMPBITS(t->bits)
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: * literal '%c'\n" :
|
||||
"inflate: * literal 0x%02x\n", t->base));
|
||||
*q++ = (Byte)t->base;
|
||||
m--;
|
||||
continue;
|
||||
}
|
||||
do {
|
||||
DUMPBITS(t->bits)
|
||||
if (e & 16)
|
||||
{
|
||||
/* get extra bits for length */
|
||||
e &= 15;
|
||||
c = t->base + ((uInt)b & inflate_mask[e]);
|
||||
DUMPBITS(e)
|
||||
Tracevv((stderr, "inflate: * length %u\n", c));
|
||||
|
||||
/* decode distance base of block to copy */
|
||||
GRABBITS(15); /* max bits for distance code */
|
||||
e = (t = td + ((uInt)b & md))->exop;
|
||||
do {
|
||||
DUMPBITS(t->bits)
|
||||
if (e & 16)
|
||||
{
|
||||
/* get extra bits to add to distance base */
|
||||
e &= 15;
|
||||
GRABBITS(e) /* get extra bits (up to 13) */
|
||||
d = t->base + ((uInt)b & inflate_mask[e]);
|
||||
DUMPBITS(e)
|
||||
Tracevv((stderr, "inflate: * distance %u\n", d));
|
||||
|
||||
/* do the copy */
|
||||
m -= c;
|
||||
if ((uInt)(q - s->window) >= d) /* offset before dest */
|
||||
{ /* just copy */
|
||||
r = q - d;
|
||||
*q++ = *r++; c--; /* minimum count is three, */
|
||||
*q++ = *r++; c--; /* so unroll loop a little */
|
||||
}
|
||||
else /* else offset after destination */
|
||||
{
|
||||
e = d - (uInt)(q - s->window); /* bytes from offset to end */
|
||||
r = s->end - e; /* pointer to offset */
|
||||
if (c > e) /* if source crosses, */
|
||||
{
|
||||
c -= e; /* copy to end of window */
|
||||
do {
|
||||
*q++ = *r++;
|
||||
} while (--e);
|
||||
r = s->window; /* copy rest from start of window */
|
||||
}
|
||||
}
|
||||
do { /* copy all or what's left */
|
||||
*q++ = *r++;
|
||||
} while (--c);
|
||||
break;
|
||||
}
|
||||
else if ((e & 64) == 0)
|
||||
{
|
||||
t += t->base;
|
||||
e = (t += ((uInt)b & inflate_mask[e]))->exop;
|
||||
}
|
||||
else
|
||||
{
|
||||
z->msg = (char*)"invalid distance code";
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
} while (1);
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0)
|
||||
{
|
||||
t += t->base;
|
||||
if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
|
||||
{
|
||||
DUMPBITS(t->bits)
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: * literal '%c'\n" :
|
||||
"inflate: * literal 0x%02x\n", t->base));
|
||||
*q++ = (Byte)t->base;
|
||||
m--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (e & 32)
|
||||
{
|
||||
Tracevv((stderr, "inflate: * end of block\n"));
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_STREAM_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
z->msg = (char*)"invalid literal/length code";
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
} while (1);
|
||||
} while (m >= 258 && n >= 10);
|
||||
|
||||
/* not enough input or output--restore pointers and return */
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_OK;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/* inffast.h -- header to use inffast.c
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
extern int inflate_fast OF((
|
||||
uInt,
|
||||
uInt,
|
||||
inflate_huft *,
|
||||
inflate_huft *,
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ));
|
||||
@@ -0,0 +1,151 @@
|
||||
/* inffixed.h -- table for decoding fixed codes
|
||||
* Generated automatically by the maketree.c program
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
local uInt fixed_bl = 9;
|
||||
local uInt fixed_bd = 5;
|
||||
local inflate_huft fixed_tl[] = {
|
||||
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
|
||||
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
|
||||
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
|
||||
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
|
||||
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
|
||||
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
|
||||
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
|
||||
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
|
||||
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
|
||||
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
|
||||
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
|
||||
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
|
||||
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
|
||||
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
|
||||
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
|
||||
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
|
||||
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
|
||||
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
|
||||
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
|
||||
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
|
||||
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
|
||||
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
|
||||
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
|
||||
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
|
||||
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
|
||||
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
|
||||
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
|
||||
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
|
||||
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
|
||||
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
|
||||
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
|
||||
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
|
||||
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
|
||||
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
|
||||
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
|
||||
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
|
||||
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
|
||||
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
|
||||
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
|
||||
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
|
||||
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
|
||||
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
|
||||
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
|
||||
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
|
||||
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
|
||||
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
|
||||
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
|
||||
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
|
||||
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
|
||||
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
|
||||
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
|
||||
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
|
||||
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
|
||||
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
|
||||
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
|
||||
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
|
||||
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
|
||||
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
|
||||
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
|
||||
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
|
||||
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
|
||||
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
|
||||
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
|
||||
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
|
||||
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
|
||||
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
|
||||
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
|
||||
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
|
||||
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
|
||||
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
|
||||
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
|
||||
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
|
||||
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
|
||||
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
|
||||
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
|
||||
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
|
||||
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
|
||||
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
|
||||
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
|
||||
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
|
||||
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
|
||||
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
|
||||
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
|
||||
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
|
||||
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
|
||||
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
|
||||
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
|
||||
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
|
||||
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
|
||||
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
|
||||
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
|
||||
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
|
||||
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
|
||||
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
|
||||
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
|
||||
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
|
||||
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
|
||||
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
|
||||
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
|
||||
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
|
||||
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
|
||||
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
|
||||
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
|
||||
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
|
||||
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
|
||||
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
|
||||
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
|
||||
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
|
||||
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
|
||||
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
|
||||
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
|
||||
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
|
||||
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
|
||||
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
|
||||
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
|
||||
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
|
||||
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
|
||||
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
|
||||
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
|
||||
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
|
||||
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
|
||||
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
|
||||
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
|
||||
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
|
||||
};
|
||||
local inflate_huft fixed_td[] = {
|
||||
{{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
|
||||
{{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
|
||||
{{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
|
||||
{{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
|
||||
{{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
|
||||
{{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
|
||||
{{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
|
||||
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
|
||||
};
|
||||
@@ -0,0 +1,366 @@
|
||||
/* inflate.c -- zlib interface to inflate modules
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "infblock.h"
|
||||
|
||||
struct inflate_blocks_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
typedef enum {
|
||||
METHOD, /* waiting for method byte */
|
||||
FLAG, /* waiting for flag byte */
|
||||
DICT4, /* four dictionary check bytes to go */
|
||||
DICT3, /* three dictionary check bytes to go */
|
||||
DICT2, /* two dictionary check bytes to go */
|
||||
DICT1, /* one dictionary check byte to go */
|
||||
DICT0, /* waiting for inflateSetDictionary */
|
||||
BLOCKS, /* decompressing blocks */
|
||||
CHECK4, /* four check bytes to go */
|
||||
CHECK3, /* three check bytes to go */
|
||||
CHECK2, /* two check bytes to go */
|
||||
CHECK1, /* one check byte to go */
|
||||
DONE, /* finished check, done */
|
||||
BAD} /* got an error--stay here */
|
||||
inflate_mode;
|
||||
|
||||
/* inflate private state */
|
||||
struct internal_state {
|
||||
|
||||
/* mode */
|
||||
inflate_mode mode; /* current inflate mode */
|
||||
|
||||
/* mode dependent information */
|
||||
union {
|
||||
uInt method; /* if FLAGS, method byte */
|
||||
struct {
|
||||
uLong was; /* computed check value */
|
||||
uLong need; /* stream check value */
|
||||
} check; /* if CHECK, check values to compare */
|
||||
uInt marker; /* if BAD, inflateSync's marker bytes count */
|
||||
} sub; /* submode */
|
||||
|
||||
/* mode independent information */
|
||||
int nowrap; /* flag for no wrapper */
|
||||
uInt wbits; /* log2(window size) (8..15, defaults to 15) */
|
||||
inflate_blocks_statef
|
||||
*blocks; /* current inflate_blocks state */
|
||||
|
||||
};
|
||||
|
||||
|
||||
int ZEXPORT inflateReset(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
z->total_in = z->total_out = 0;
|
||||
z->msg = Z_NULL;
|
||||
z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
|
||||
inflate_blocks_reset(z->state->blocks, z, Z_NULL);
|
||||
Tracev((stderr, "inflate: reset\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateEnd(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (z->state->blocks != Z_NULL)
|
||||
inflate_blocks_free(z->state->blocks, z);
|
||||
ZFREE(z, z->state);
|
||||
z->state = Z_NULL;
|
||||
Tracev((stderr, "inflate: end\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateInit2_(z, w, version, stream_size)
|
||||
z_streamp z;
|
||||
int w;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
||||
stream_size != sizeof(z_stream))
|
||||
return Z_VERSION_ERROR;
|
||||
|
||||
/* initialize state */
|
||||
if (z == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
z->msg = Z_NULL;
|
||||
if (z->zalloc == Z_NULL)
|
||||
{
|
||||
z->zalloc = zcalloc;
|
||||
z->opaque = (voidpf)0;
|
||||
}
|
||||
if (z->zfree == Z_NULL) z->zfree = zcfree;
|
||||
if ((z->state = (struct internal_state FAR *)
|
||||
ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
z->state->blocks = Z_NULL;
|
||||
|
||||
/* handle undocumented nowrap option (no zlib header or check) */
|
||||
z->state->nowrap = 0;
|
||||
if (w < 0)
|
||||
{
|
||||
w = - w;
|
||||
z->state->nowrap = 1;
|
||||
}
|
||||
|
||||
/* set window size */
|
||||
if (w < 8 || w > 15)
|
||||
{
|
||||
inflateEnd(z);
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
z->state->wbits = (uInt)w;
|
||||
|
||||
/* create inflate_blocks state */
|
||||
if ((z->state->blocks =
|
||||
inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
|
||||
== Z_NULL)
|
||||
{
|
||||
inflateEnd(z);
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
Tracev((stderr, "inflate: allocated\n"));
|
||||
|
||||
/* reset state */
|
||||
inflateReset(z);
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateInit_(z, version, stream_size)
|
||||
z_streamp z;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
return inflateInit2_(z, DEF_WBITS, version, stream_size);
|
||||
}
|
||||
|
||||
|
||||
#define NEEDBYTE {if(z->avail_in==0)return r;r=f;}
|
||||
#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
|
||||
|
||||
int ZEXPORT inflate(z, f)
|
||||
z_streamp z;
|
||||
int f;
|
||||
{
|
||||
int r;
|
||||
uInt b;
|
||||
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
|
||||
r = Z_BUF_ERROR;
|
||||
while (1) switch (z->state->mode)
|
||||
{
|
||||
case METHOD:
|
||||
NEEDBYTE
|
||||
if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"unknown compression method";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"invalid window size";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
z->state->mode = FLAG;
|
||||
case FLAG:
|
||||
NEEDBYTE
|
||||
b = NEXTBYTE;
|
||||
if (((z->state->sub.method << 8) + b) % 31)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"incorrect header check";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
Tracev((stderr, "inflate: zlib header ok\n"));
|
||||
if (!(b & PRESET_DICT))
|
||||
{
|
||||
z->state->mode = BLOCKS;
|
||||
break;
|
||||
}
|
||||
z->state->mode = DICT4;
|
||||
case DICT4:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need = (uLong)NEXTBYTE << 24;
|
||||
z->state->mode = DICT3;
|
||||
case DICT3:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 16;
|
||||
z->state->mode = DICT2;
|
||||
case DICT2:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 8;
|
||||
z->state->mode = DICT1;
|
||||
case DICT1:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE;
|
||||
z->adler = z->state->sub.check.need;
|
||||
z->state->mode = DICT0;
|
||||
return Z_NEED_DICT;
|
||||
case DICT0:
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"need dictionary";
|
||||
z->state->sub.marker = 0; /* can try inflateSync */
|
||||
return Z_STREAM_ERROR;
|
||||
case BLOCKS:
|
||||
r = inflate_blocks(z->state->blocks, z, r);
|
||||
if (r == Z_DATA_ERROR)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->state->sub.marker = 0; /* can try inflateSync */
|
||||
break;
|
||||
}
|
||||
if (r == Z_OK)
|
||||
r = f;
|
||||
if (r != Z_STREAM_END)
|
||||
return r;
|
||||
r = f;
|
||||
inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
|
||||
if (z->state->nowrap)
|
||||
{
|
||||
z->state->mode = DONE;
|
||||
break;
|
||||
}
|
||||
z->state->mode = CHECK4;
|
||||
case CHECK4:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need = (uLong)NEXTBYTE << 24;
|
||||
z->state->mode = CHECK3;
|
||||
case CHECK3:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 16;
|
||||
z->state->mode = CHECK2;
|
||||
case CHECK2:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 8;
|
||||
z->state->mode = CHECK1;
|
||||
case CHECK1:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE;
|
||||
|
||||
if (z->state->sub.check.was != z->state->sub.check.need)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"incorrect data check";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
Tracev((stderr, "inflate: zlib check ok\n"));
|
||||
z->state->mode = DONE;
|
||||
case DONE:
|
||||
return Z_STREAM_END;
|
||||
case BAD:
|
||||
return Z_DATA_ERROR;
|
||||
default:
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
#ifdef NEED_DUMMY_RETURN
|
||||
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateSetDictionary(z, dictionary, dictLength)
|
||||
z_streamp z;
|
||||
const Bytef *dictionary;
|
||||
uInt dictLength;
|
||||
{
|
||||
uInt length = dictLength;
|
||||
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
|
||||
z->adler = 1L;
|
||||
|
||||
if (length >= ((uInt)1<<z->state->wbits))
|
||||
{
|
||||
length = (1<<z->state->wbits)-1;
|
||||
dictionary += dictLength - length;
|
||||
}
|
||||
inflate_set_dictionary(z->state->blocks, dictionary, length);
|
||||
z->state->mode = BLOCKS;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateSync(z)
|
||||
z_streamp z;
|
||||
{
|
||||
uInt n; /* number of bytes to look at */
|
||||
Bytef *p; /* pointer to bytes */
|
||||
uInt m; /* number of marker bytes found in a row */
|
||||
uLong r, w; /* temporaries to save total_in and total_out */
|
||||
|
||||
/* set up */
|
||||
if (z == Z_NULL || z->state == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (z->state->mode != BAD)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->state->sub.marker = 0;
|
||||
}
|
||||
if ((n = z->avail_in) == 0)
|
||||
return Z_BUF_ERROR;
|
||||
p = z->next_in;
|
||||
m = z->state->sub.marker;
|
||||
|
||||
/* search */
|
||||
while (n && m < 4)
|
||||
{
|
||||
static const Byte mark[4] = {0, 0, 0xff, 0xff};
|
||||
if (*p == mark[m])
|
||||
m++;
|
||||
else if (*p)
|
||||
m = 0;
|
||||
else
|
||||
m = 4 - m;
|
||||
p++, n--;
|
||||
}
|
||||
|
||||
/* restore */
|
||||
z->total_in += p - z->next_in;
|
||||
z->next_in = p;
|
||||
z->avail_in = n;
|
||||
z->state->sub.marker = m;
|
||||
|
||||
/* return no joy or set up to restart on a new block */
|
||||
if (m != 4)
|
||||
return Z_DATA_ERROR;
|
||||
r = z->total_in; w = z->total_out;
|
||||
inflateReset(z);
|
||||
z->total_in = r; z->total_out = w;
|
||||
z->state->mode = BLOCKS;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Returns true if inflate is currently at the end of a block generated
|
||||
* by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
|
||||
* implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
|
||||
* but removes the length bytes of the resulting empty stored block. When
|
||||
* decompressing, PPP checks that at the end of input packet, inflate is
|
||||
* waiting for these length bytes.
|
||||
*/
|
||||
int ZEXPORT inflateSyncPoint(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
return inflate_blocks_sync_point(z->state->blocks);
|
||||
}
|
||||
@@ -0,0 +1,455 @@
|
||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
|
||||
#if !defined(BUILDFIXED) && !defined(STDC)
|
||||
# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */
|
||||
#endif
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
include such an acknowledgment, I would appreciate that you keep this
|
||||
copyright string in the executable of your product.
|
||||
*/
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
|
||||
local int huft_build OF((
|
||||
uIntf *, /* code lengths in bits */
|
||||
uInt, /* number of codes */
|
||||
uInt, /* number of "simple" codes */
|
||||
const uIntf *, /* list of base values for non-simple codes */
|
||||
const uIntf *, /* list of extra bits for non-simple codes */
|
||||
inflate_huft * FAR*,/* result: starting table */
|
||||
uIntf *, /* maximum lookup bits (returns actual) */
|
||||
inflate_huft *, /* space for trees */
|
||||
uInt *, /* hufts used in space */
|
||||
uIntf * )); /* space for values */
|
||||
|
||||
/* Tables for deflate from PKZIP's appnote.txt. */
|
||||
local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
/* see note #13 above about 258 */
|
||||
local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */
|
||||
local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577};
|
||||
local const uInt cpdext[30] = { /* Extra bits for distance codes */
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 13, 13};
|
||||
|
||||
/*
|
||||
Huffman code decoding is performed using a multi-level table lookup.
|
||||
The fastest way to decode is to simply build a lookup table whose
|
||||
size is determined by the longest code. However, the time it takes
|
||||
to build this table can also be a factor if the data being decoded
|
||||
is not very long. The most common codes are necessarily the
|
||||
shortest codes, so those codes dominate the decoding time, and hence
|
||||
the speed. The idea is you can have a shorter table that decodes the
|
||||
shorter, more probable codes, and then point to subsidiary tables for
|
||||
the longer codes. The time it costs to decode the longer codes is
|
||||
then traded against the time it takes to make longer tables.
|
||||
|
||||
This results of this trade are in the variables lbits and dbits
|
||||
below. lbits is the number of bits the first level table for literal/
|
||||
length codes can decode in one step, and dbits is the same thing for
|
||||
the distance codes. Subsequent tables are also less than or equal to
|
||||
those sizes. These values may be adjusted either when all of the
|
||||
codes are shorter than that, in which case the longest code length in
|
||||
bits is used, or when the shortest code is *longer* than the requested
|
||||
table size, in which case the length of the shortest code in bits is
|
||||
used.
|
||||
|
||||
There are two different values for the two tables, since they code a
|
||||
different number of possibilities each. The literal/length table
|
||||
codes 286 possible values, or in a flat code, a little over eight
|
||||
bits. The distance table codes 30 possible values, or a little less
|
||||
than five bits, flat. The optimum values for speed end up being
|
||||
about one bit more than those, so lbits is 8+1 and dbits is 5+1.
|
||||
The optimum values may differ though from machine to machine, and
|
||||
possibly even between compilers. Your mileage may vary.
|
||||
*/
|
||||
|
||||
|
||||
/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
|
||||
#define BMAX 15 /* maximum bit length of any code */
|
||||
|
||||
local int huft_build(b, n, s, d, e, t, m, hp, hn, v)
|
||||
uIntf *b; /* code lengths in bits (all assumed <= BMAX) */
|
||||
uInt n; /* number of codes (assumed <= 288) */
|
||||
uInt s; /* number of simple-valued codes (0..s-1) */
|
||||
const uIntf *d; /* list of base values for non-simple codes */
|
||||
const uIntf *e; /* list of extra bits for non-simple codes */
|
||||
inflate_huft * FAR *t; /* result: starting table */
|
||||
uIntf *m; /* maximum lookup bits, returns actual */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
uInt *hn; /* hufts used in space */
|
||||
uIntf *v; /* working area: values in order of bit length */
|
||||
/* Given a list of code lengths and a maximum table size, make a set of
|
||||
tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
|
||||
if the given code set is incomplete (the tables are still built in this
|
||||
case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
|
||||
lengths), or Z_MEM_ERROR if not enough memory. */
|
||||
{
|
||||
|
||||
uInt a; /* counter for codes of length k */
|
||||
uInt c[BMAX+1]; /* bit length count table */
|
||||
uInt f; /* i repeats in table every f entries */
|
||||
int g; /* maximum code length */
|
||||
int h; /* table level */
|
||||
register uInt i; /* counter, current code */
|
||||
register uInt j; /* counter */
|
||||
register int k; /* number of bits in current code */
|
||||
int l; /* bits per table (returned in m) */
|
||||
uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
|
||||
register uIntf *p; /* pointer into c[], b[], or v[] */
|
||||
inflate_huft *q; /* points to current table */
|
||||
struct inflate_huft_s r; /* table entry for structure assignment */
|
||||
inflate_huft *u[BMAX]; /* table stack */
|
||||
register int w; /* bits before this table == (l * h) */
|
||||
uInt x[BMAX+1]; /* bit offsets, then code stack */
|
||||
uIntf *xp; /* pointer into x */
|
||||
int y; /* number of dummy codes added */
|
||||
uInt z; /* number of entries in current table */
|
||||
|
||||
|
||||
/* Generate counts for each bit length */
|
||||
p = c;
|
||||
#define C0 *p++ = 0;
|
||||
#define C2 C0 C0 C0 C0
|
||||
#define C4 C2 C2 C2 C2
|
||||
C4 /* clear c[]--assume BMAX+1 is 16 */
|
||||
p = b; i = n;
|
||||
do {
|
||||
c[*p++]++; /* assume all entries <= BMAX */
|
||||
} while (--i);
|
||||
if (c[0] == n) /* null input--all zero length codes */
|
||||
{
|
||||
*t = (inflate_huft *)Z_NULL;
|
||||
*m = 0;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Find minimum and maximum length, bound *m by those */
|
||||
l = *m;
|
||||
for (j = 1; j <= BMAX; j++)
|
||||
if (c[j])
|
||||
break;
|
||||
k = j; /* minimum code length */
|
||||
if ((uInt)l < j)
|
||||
l = j;
|
||||
for (i = BMAX; i; i--)
|
||||
if (c[i])
|
||||
break;
|
||||
g = i; /* maximum code length */
|
||||
if ((uInt)l > i)
|
||||
l = i;
|
||||
*m = l;
|
||||
|
||||
|
||||
/* Adjust last length count to fill out codes, if needed */
|
||||
for (y = 1 << j; j < i; j++, y <<= 1)
|
||||
if ((y -= c[j]) < 0)
|
||||
return Z_DATA_ERROR;
|
||||
if ((y -= c[i]) < 0)
|
||||
return Z_DATA_ERROR;
|
||||
c[i] += y;
|
||||
|
||||
|
||||
/* Generate starting offsets into the value table for each length */
|
||||
x[1] = j = 0;
|
||||
p = c + 1; xp = x + 2;
|
||||
while (--i) { /* note that i == g from above */
|
||||
*xp++ = (j += *p++);
|
||||
}
|
||||
|
||||
|
||||
/* Make a table of values in order of bit lengths */
|
||||
p = b; i = 0;
|
||||
do {
|
||||
if ((j = *p++) != 0)
|
||||
v[x[j]++] = i;
|
||||
} while (++i < n);
|
||||
n = x[g]; /* set n to length of v */
|
||||
|
||||
|
||||
/* Generate the Huffman codes and for each, make the table entries */
|
||||
x[0] = i = 0; /* first Huffman code is zero */
|
||||
p = v; /* grab values in bit order */
|
||||
h = -1; /* no tables yet--level -1 */
|
||||
w = -l; /* bits decoded == (l * h) */
|
||||
u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
|
||||
q = (inflate_huft *)Z_NULL; /* ditto */
|
||||
z = 0; /* ditto */
|
||||
|
||||
/* go through the bit lengths (k already is bits in shortest code) */
|
||||
for (; k <= g; k++)
|
||||
{
|
||||
a = c[k];
|
||||
while (a--)
|
||||
{
|
||||
/* here i is the Huffman code of length k bits for value *p */
|
||||
/* make tables up to required level */
|
||||
while (k > w + l)
|
||||
{
|
||||
h++;
|
||||
w += l; /* previous table always l bits */
|
||||
|
||||
/* compute minimum size table less than or equal to l bits */
|
||||
z = g - w;
|
||||
z = z > (uInt)l ? l : z; /* table size upper limit */
|
||||
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
|
||||
{ /* too few codes for k-w bit table */
|
||||
f -= a + 1; /* deduct codes from patterns left */
|
||||
xp = c + k;
|
||||
if (j < z)
|
||||
while (++j < z) /* try smaller tables up to z bits */
|
||||
{
|
||||
if ((f <<= 1) <= *++xp)
|
||||
break; /* enough codes to use up j bits */
|
||||
f -= *xp; /* else deduct codes from patterns */
|
||||
}
|
||||
}
|
||||
z = 1 << j; /* table entries for j-bit table */
|
||||
|
||||
/* allocate new table */
|
||||
if (*hn + z > MANY) /* (note: doesn't matter for fixed) */
|
||||
return Z_MEM_ERROR; /* not enough memory */
|
||||
u[h] = q = hp + *hn;
|
||||
*hn += z;
|
||||
|
||||
/* connect to last table, if there is one */
|
||||
if (h)
|
||||
{
|
||||
x[h] = i; /* save pattern for backing up */
|
||||
r.bits = (Byte)l; /* bits to dump before this table */
|
||||
r.exop = (Byte)j; /* bits in this table */
|
||||
j = i >> (w - l);
|
||||
r.base = (uInt)(q - u[h-1] - j); /* offset to this table */
|
||||
u[h-1][j] = r; /* connect to last table */
|
||||
}
|
||||
else
|
||||
*t = q; /* first table is returned result */
|
||||
}
|
||||
|
||||
/* set up table entry in r */
|
||||
r.bits = (Byte)(k - w);
|
||||
if (p >= v + n)
|
||||
r.exop = 128 + 64; /* out of values--invalid code */
|
||||
else if (*p < s)
|
||||
{
|
||||
r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
|
||||
r.base = *p++; /* simple code is just the value */
|
||||
}
|
||||
else
|
||||
{
|
||||
r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
|
||||
r.base = d[*p++ - s];
|
||||
}
|
||||
|
||||
/* fill code-like entries with r */
|
||||
f = 1 << (k - w);
|
||||
for (j = i >> w; j < z; j += f)
|
||||
q[j] = r;
|
||||
|
||||
/* backwards increment the k-bit code i */
|
||||
for (j = 1 << (k - 1); i & j; j >>= 1)
|
||||
i ^= j;
|
||||
i ^= j;
|
||||
|
||||
/* backup over finished tables */
|
||||
mask = (1 << w) - 1; /* needed on HP, cc -O bug */
|
||||
while ((i & mask) != x[h])
|
||||
{
|
||||
h--; /* don't need to update q */
|
||||
w -= l;
|
||||
mask = (1 << w) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Return Z_BUF_ERROR if we were given an incomplete table */
|
||||
return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int inflate_trees_bits(c, bb, tb, hp, z)
|
||||
uIntf *c; /* 19 code lengths */
|
||||
uIntf *bb; /* bits tree desired/actual depth */
|
||||
inflate_huft * FAR *tb; /* bits tree result */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
z_streamp z; /* for messages */
|
||||
{
|
||||
int r;
|
||||
uInt hn = 0; /* hufts used in space */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL,
|
||||
tb, bb, hp, &hn, v);
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed dynamic bit lengths tree";
|
||||
else if (r == Z_BUF_ERROR || *bb == 0)
|
||||
{
|
||||
z->msg = (char*)"incomplete dynamic bit lengths tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z)
|
||||
uInt nl; /* number of literal/length codes */
|
||||
uInt nd; /* number of distance codes */
|
||||
uIntf *c; /* that many (total) code lengths */
|
||||
uIntf *bl; /* literal desired/actual bit depth */
|
||||
uIntf *bd; /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *tl; /* literal/length tree result */
|
||||
inflate_huft * FAR *td; /* distance tree result */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
z_streamp z; /* for messages */
|
||||
{
|
||||
int r;
|
||||
uInt hn = 0; /* hufts used in space */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
/* allocate work area */
|
||||
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
|
||||
/* build literal/length tree */
|
||||
r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
|
||||
if (r != Z_OK || *bl == 0)
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed literal/length tree";
|
||||
else if (r != Z_MEM_ERROR)
|
||||
{
|
||||
z->msg = (char*)"incomplete literal/length tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* build distance tree */
|
||||
r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
|
||||
if (r != Z_OK || (*bd == 0 && nl > 257))
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed distance tree";
|
||||
else if (r == Z_BUF_ERROR) {
|
||||
#ifdef PKZIP_BUG_WORKAROUND
|
||||
r = Z_OK;
|
||||
}
|
||||
#else
|
||||
z->msg = (char*)"incomplete distance tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
else if (r != Z_MEM_ERROR)
|
||||
{
|
||||
z->msg = (char*)"empty distance tree with lengths";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* done */
|
||||
ZFREE(z, v);
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* build fixed tables only once--keep them here */
|
||||
#ifdef BUILDFIXED
|
||||
local int fixed_built = 0;
|
||||
#define FIXEDH 544 /* number of hufts used by fixed tables */
|
||||
local inflate_huft fixed_mem[FIXEDH];
|
||||
local uInt fixed_bl;
|
||||
local uInt fixed_bd;
|
||||
local inflate_huft *fixed_tl;
|
||||
local inflate_huft *fixed_td;
|
||||
#else
|
||||
#include "inffixed.h"
|
||||
#endif
|
||||
|
||||
|
||||
int inflate_trees_fixed(bl, bd, tl, td, z)
|
||||
uIntf *bl; /* literal desired/actual bit depth */
|
||||
uIntf *bd; /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *tl; /* literal/length tree result */
|
||||
inflate_huft * FAR *td; /* distance tree result */
|
||||
z_streamp z; /* for memory allocation */
|
||||
{
|
||||
#ifdef BUILDFIXED
|
||||
/* build fixed tables if not already */
|
||||
if (!fixed_built)
|
||||
{
|
||||
int k; /* temporary variable */
|
||||
uInt f = 0; /* number of hufts used in fixed_mem */
|
||||
uIntf *c; /* length list for huft_build */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
/* allocate memory */
|
||||
if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, c);
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
|
||||
/* literal table */
|
||||
for (k = 0; k < 144; k++)
|
||||
c[k] = 8;
|
||||
for (; k < 256; k++)
|
||||
c[k] = 9;
|
||||
for (; k < 280; k++)
|
||||
c[k] = 7;
|
||||
for (; k < 288; k++)
|
||||
c[k] = 8;
|
||||
fixed_bl = 9;
|
||||
huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl,
|
||||
fixed_mem, &f, v);
|
||||
|
||||
/* distance table */
|
||||
for (k = 0; k < 30; k++)
|
||||
c[k] = 5;
|
||||
fixed_bd = 5;
|
||||
huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd,
|
||||
fixed_mem, &f, v);
|
||||
|
||||
/* done */
|
||||
ZFREE(z, v);
|
||||
ZFREE(z, c);
|
||||
fixed_built = 1;
|
||||
}
|
||||
#endif
|
||||
*bl = fixed_bl;
|
||||
*bd = fixed_bd;
|
||||
*tl = fixed_tl;
|
||||
*td = fixed_td;
|
||||
return Z_OK;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/* inftrees.h -- header to use inftrees.c
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* Huffman code lookup table entry--this entry is four bytes for machines
|
||||
that have 16-bit pointers (e.g. PC's in the small or medium model). */
|
||||
|
||||
typedef struct inflate_huft_s FAR inflate_huft;
|
||||
|
||||
struct inflate_huft_s {
|
||||
union {
|
||||
struct {
|
||||
Byte Exop; /* number of extra bits or operation */
|
||||
Byte Bits; /* number of bits in this code or subcode */
|
||||
} what;
|
||||
uInt pad; /* pad structure to a power of 2 (4 bytes for */
|
||||
} word; /* 16-bit, 8 bytes for 32-bit int's) */
|
||||
uInt base; /* literal, length base, distance base,
|
||||
or table offset */
|
||||
};
|
||||
|
||||
/* Maximum size of dynamic tree. The maximum found in a long but non-
|
||||
exhaustive search was 1004 huft structures (850 for length/literals
|
||||
and 154 for distances, the latter actually the result of an
|
||||
exhaustive search). The actual maximum is not known, but the
|
||||
value below is more than safe. */
|
||||
#define MANY 1440
|
||||
|
||||
extern int inflate_trees_bits OF((
|
||||
uIntf *, /* 19 code lengths */
|
||||
uIntf *, /* bits tree desired/actual depth */
|
||||
inflate_huft * FAR *, /* bits tree result */
|
||||
inflate_huft *, /* space for trees */
|
||||
z_streamp)); /* for messages */
|
||||
|
||||
extern int inflate_trees_dynamic OF((
|
||||
uInt, /* number of literal/length codes */
|
||||
uInt, /* number of distance codes */
|
||||
uIntf *, /* that many (total) code lengths */
|
||||
uIntf *, /* literal desired/actual bit depth */
|
||||
uIntf *, /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *, /* literal/length tree result */
|
||||
inflate_huft * FAR *, /* distance tree result */
|
||||
inflate_huft *, /* space for trees */
|
||||
z_streamp)); /* for messages */
|
||||
|
||||
extern int inflate_trees_fixed OF((
|
||||
uIntf *, /* literal desired/actual bit depth */
|
||||
uIntf *, /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *, /* literal/length tree result */
|
||||
inflate_huft * FAR *, /* distance tree result */
|
||||
z_streamp)); /* for memory allocation */
|
||||
@@ -0,0 +1,87 @@
|
||||
/* inflate_util.c -- data and routines common to blocks and codes
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "infblock.h"
|
||||
#include "inftrees.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* And'ing with mask[n] masks the lower n bits */
|
||||
uInt inflate_mask[17] = {
|
||||
0x0000,
|
||||
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
|
||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||
};
|
||||
|
||||
|
||||
/* copy as much as possible from the sliding window to the output area */
|
||||
int inflate_flush(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt n;
|
||||
Bytef *p;
|
||||
Bytef *q;
|
||||
|
||||
/* local copies of source and destination pointers */
|
||||
p = z->next_out;
|
||||
q = s->read;
|
||||
|
||||
/* compute number of bytes to copy as far as end of window */
|
||||
n = (uInt)((q <= s->write ? s->write : s->end) - q);
|
||||
if (n > z->avail_out) n = z->avail_out;
|
||||
if (n && r == Z_BUF_ERROR) r = Z_OK;
|
||||
|
||||
/* update counters */
|
||||
z->avail_out -= n;
|
||||
z->total_out += n;
|
||||
|
||||
/* update check information */
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(s->check, q, n);
|
||||
|
||||
/* copy as far as end of window */
|
||||
zmemcpy(p, q, n);
|
||||
p += n;
|
||||
q += n;
|
||||
|
||||
/* see if more to copy at beginning of window */
|
||||
if (q == s->end)
|
||||
{
|
||||
/* wrap pointers */
|
||||
q = s->window;
|
||||
if (s->write == s->end)
|
||||
s->write = s->window;
|
||||
|
||||
/* compute bytes to copy */
|
||||
n = (uInt)(s->write - q);
|
||||
if (n > z->avail_out) n = z->avail_out;
|
||||
if (n && r == Z_BUF_ERROR) r = Z_OK;
|
||||
|
||||
/* update counters */
|
||||
z->avail_out -= n;
|
||||
z->total_out += n;
|
||||
|
||||
/* update check information */
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(s->check, q, n);
|
||||
|
||||
/* copy */
|
||||
zmemcpy(p, q, n);
|
||||
p += n;
|
||||
q += n;
|
||||
}
|
||||
|
||||
/* update pointers */
|
||||
z->next_out = p;
|
||||
s->read = q;
|
||||
|
||||
/* done */
|
||||
return r;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* infutil.h -- types and macros common to blocks and codes
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
#ifndef _INFUTIL_H
|
||||
#define _INFUTIL_H
|
||||
|
||||
typedef enum {
|
||||
TYPE, /* get type bits (3, including end bit) */
|
||||
LENS, /* get lengths for stored */
|
||||
STORED, /* processing stored block */
|
||||
TABLE, /* get table lengths */
|
||||
BTREE, /* get bit lengths tree for a dynamic block */
|
||||
DTREE, /* get length, distance trees for a dynamic block */
|
||||
CODES, /* processing fixed or dynamic block */
|
||||
DRY, /* output remaining window bytes */
|
||||
DONE, /* finished last block, done */
|
||||
BAD} /* got a data error--stuck here */
|
||||
inflate_block_mode;
|
||||
|
||||
/* inflate blocks semi-private state */
|
||||
struct inflate_blocks_state {
|
||||
|
||||
/* mode */
|
||||
inflate_block_mode mode; /* current inflate_block mode */
|
||||
|
||||
/* mode dependent information */
|
||||
union {
|
||||
uInt left; /* if STORED, bytes left to copy */
|
||||
struct {
|
||||
uInt table; /* table lengths (14 bits) */
|
||||
uInt index; /* index into blens (or border) */
|
||||
uIntf *blens; /* bit lengths of codes */
|
||||
uInt bb; /* bit length tree depth */
|
||||
inflate_huft *tb; /* bit length decoding tree */
|
||||
} trees; /* if DTREE, decoding info for trees */
|
||||
struct {
|
||||
inflate_codes_statef
|
||||
*codes;
|
||||
} decode; /* if CODES, current state */
|
||||
} sub; /* submode */
|
||||
uInt last; /* true if this block is the last block */
|
||||
|
||||
/* mode independent information */
|
||||
uInt bitk; /* bits in bit buffer */
|
||||
uLong bitb; /* bit buffer */
|
||||
inflate_huft *hufts; /* single malloc for tree space */
|
||||
Bytef *window; /* sliding window */
|
||||
Bytef *end; /* one byte after sliding window */
|
||||
Bytef *read; /* window read pointer */
|
||||
Bytef *write; /* window write pointer */
|
||||
check_func checkfn; /* check function */
|
||||
uLong check; /* check on output */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* defines for inflate input/output */
|
||||
/* update pointers and return */
|
||||
#define UPDBITS {s->bitb=b;s->bitk=k;}
|
||||
#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
|
||||
#define UPDOUT {s->write=q;}
|
||||
#define UPDATE {UPDBITS UPDIN UPDOUT}
|
||||
#define LEAVE {UPDATE return inflate_flush(s,z,r);}
|
||||
/* get bytes and bits */
|
||||
#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
|
||||
#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
|
||||
#define NEXTBYTE (n--,*p++)
|
||||
#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
|
||||
#define DUMPBITS(j) {b>>=(j);k-=(j);}
|
||||
/* output bytes */
|
||||
#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
|
||||
#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
|
||||
#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
|
||||
#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
|
||||
#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
|
||||
#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
|
||||
/* load local pointers */
|
||||
#define LOAD {LOADIN LOADOUT}
|
||||
|
||||
/* masks for lower bits (size given to avoid silly warnings with Visual C++) */
|
||||
extern uInt inflate_mask[17];
|
||||
|
||||
/* copy as much as possible from the sliding window to the output area */
|
||||
extern int inflate_flush OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int));
|
||||
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,275 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 0.15 beta, Mar 19th, 1998,
|
||||
|
||||
Copyright (C) 1998 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
|
||||
CAN CHANGE IN FUTURE VERSION !!
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
/* for more info about .ZIP format, see
|
||||
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip */
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
|
||||
"zlib/zlib111.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,279 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-1998 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id: ZCONF.H,v 1.1.1.1 2002/08/02 09:59:42 kichik Exp $ */
|
||||
|
||||
#ifndef _ZCONF_H
|
||||
#define _ZCONF_H
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
*/
|
||||
#ifdef Z_PREFIX
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflate z_deflate
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflate z_inflate
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateParams z_deflateParams
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateReset z_inflateReset
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define uncompress z_uncompress
|
||||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
#endif
|
||||
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||
# define WIN32
|
||||
#endif
|
||||
#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
|
||||
# ifndef __32BIT__
|
||||
# define __32BIT__
|
||||
# endif
|
||||
#endif
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#if defined(MSDOS) && !defined(__32BIT__)
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
|
||||
# define STDC
|
||||
#endif
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Some Mac compilers merge all .h files incorrectly: */
|
||||
#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
|
||||
# define NO_DUMMY_DECL
|
||||
#endif
|
||||
|
||||
/* Old Borland C incorrectly complains about missing returns: */
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
|
||||
# define NEED_DUMMY_RETURN
|
||||
#endif
|
||||
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
#endif
|
||||
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
# ifndef __32BIT__
|
||||
# define SMALL_MEDIUM
|
||||
# define FAR _far
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Compile with -DZLIB_DLL for Windows DLL support */
|
||||
#if defined(ZLIB_DLL)
|
||||
# if defined(_WINDOWS) || defined(WINDOWS)
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR _cdecl _export
|
||||
# endif
|
||||
# endif
|
||||
# if defined (__BORLANDC__)
|
||||
# if (__BORLANDC__ >= 0x0500) && defined (WIN32)
|
||||
# include <windows.h>
|
||||
# define ZEXPORT __declspec(dllexport) WINAPI
|
||||
# define ZEXPORTRVA __declspec(dllexport) WINAPIV
|
||||
# else
|
||||
# if defined (_Windows) && defined (__DLL__)
|
||||
# define ZEXPORT _export
|
||||
# define ZEXPORTVA _export
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# if defined (ZLIB_DLL)
|
||||
# define ZEXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(MACOS) && !defined(TARGET_OS_MAC)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# include <unistd.h> /* for SEEK_* and off_t */
|
||||
# define z_off_t off_t
|
||||
#endif
|
||||
#ifndef SEEK_SET
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
# pragma map(deflateInit_,"DEIN")
|
||||
# pragma map(deflateInit2_,"DEIN2")
|
||||
# pragma map(deflateEnd,"DEEND")
|
||||
# pragma map(inflateInit_,"ININ")
|
||||
# pragma map(inflateInit2_,"ININ2")
|
||||
# pragma map(inflateEnd,"INEND")
|
||||
# pragma map(inflateSync,"INSY")
|
||||
# pragma map(inflateSetDictionary,"INSEDI")
|
||||
# pragma map(inflate_blocks,"INBL")
|
||||
# pragma map(inflate_blocks_new,"INBLNE")
|
||||
# pragma map(inflate_blocks_free,"INBLFR")
|
||||
# pragma map(inflate_blocks_reset,"INBLRE")
|
||||
# pragma map(inflate_codes_free,"INCOFR")
|
||||
# pragma map(inflate_codes,"INCO")
|
||||
# pragma map(inflate_fast,"INFA")
|
||||
# pragma map(inflate_flush,"INFLU")
|
||||
# pragma map(inflate_mask,"INMA")
|
||||
# pragma map(inflate_set_dictionary,"INSEDI2")
|
||||
# pragma map(inflate_copyright,"INCOPY")
|
||||
# pragma map(inflate_trees_bits,"INTRBI")
|
||||
# pragma map(inflate_trees_dynamic,"INTRDY")
|
||||
# pragma map(inflate_trees_fixed,"INTRFI")
|
||||
# pragma map(inflate_trees_free,"INTRFR")
|
||||
#endif
|
||||
|
||||
#endif /* _ZCONF_H */
|
||||
@@ -0,0 +1,893 @@
|
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.1.3, July 9th, 1998
|
||||
|
||||
Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
|
||||
|
||||
The data format used by the zlib library is described by RFCs (Request for
|
||||
Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
|
||||
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
|
||||
*/
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#define _ZLIB_H
|
||||
|
||||
#include "zconf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ZLIB_VERSION "1.1.3"
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
decompression functions, including integrity checks of the uncompressed
|
||||
data. This version of the library supports only one compression method
|
||||
(deflation) but other algorithms will be added later and will have the same
|
||||
stream interface.
|
||||
|
||||
Compression can be done in a single step if the buffers are large
|
||||
enough (for example if an input file is mmap'ed), or can be done by
|
||||
repeated calls of the compression function. In the latter case, the
|
||||
application must provide more input and/or consume the output
|
||||
(providing more output space) before each call.
|
||||
|
||||
The library also supports reading and writing files in gzip (.gz) format
|
||||
with an interface similar to that of stdio.
|
||||
|
||||
The library does not install any signal handler. The decoder checks
|
||||
the consistency of the compressed data, so the library should never
|
||||
crash even in case of corrupted input.
|
||||
*/
|
||||
|
||||
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
|
||||
typedef void (*free_func) OF((voidpf opaque, voidpf address));
|
||||
|
||||
struct internal_state;
|
||||
|
||||
typedef struct z_stream_s {
|
||||
Bytef *next_in; /* next input byte */
|
||||
uInt avail_in; /* number of bytes available at next_in */
|
||||
uLong total_in; /* total nb of input bytes read so far */
|
||||
|
||||
Bytef *next_out; /* next output byte should be put there */
|
||||
uInt avail_out; /* remaining free space at next_out */
|
||||
uLong total_out; /* total nb of bytes output so far */
|
||||
|
||||
char *msg; /* last error message, NULL if no error */
|
||||
struct internal_state FAR *state; /* not visible by applications */
|
||||
|
||||
alloc_func zalloc; /* used to allocate the internal state */
|
||||
free_func zfree; /* used to free the internal state */
|
||||
voidpf opaque; /* private data object passed to zalloc and zfree */
|
||||
|
||||
int data_type; /* best guess about the data type: ascii or binary */
|
||||
uLong adler; /* adler32 value of the uncompressed data */
|
||||
uLong reserved; /* reserved for future use */
|
||||
} z_stream;
|
||||
|
||||
typedef z_stream FAR *z_streamp;
|
||||
|
||||
/*
|
||||
The application must update next_in and avail_in when avail_in has
|
||||
dropped to zero. It must update next_out and avail_out when avail_out
|
||||
has dropped to zero. The application must initialize zalloc, zfree and
|
||||
opaque before calling the init function. All other fields are set by the
|
||||
compression library and must not be updated by the application.
|
||||
|
||||
The opaque value provided by the application will be passed as the first
|
||||
parameter for calls of zalloc and zfree. This can be useful for custom
|
||||
memory management. The compression library attaches no meaning to the
|
||||
opaque value.
|
||||
|
||||
zalloc must return Z_NULL if there is not enough memory for the object.
|
||||
If zlib is used in a multi-threaded application, zalloc and zfree must be
|
||||
thread safe.
|
||||
|
||||
On 16-bit systems, the functions zalloc and zfree must be able to allocate
|
||||
exactly 65536 bytes, but will not be required to allocate more than this
|
||||
if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
|
||||
pointers returned by zalloc for objects of exactly 65536 bytes *must*
|
||||
have their offset normalized to zero. The default allocation function
|
||||
provided by this library ensures this (see zutil.c). To reduce memory
|
||||
requirements and avoid any allocation of 64K objects, at the expense of
|
||||
compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
|
||||
|
||||
The fields total_in and total_out can be used for statistics or
|
||||
progress reports. After compression, total_in holds the total size of
|
||||
the uncompressed data and may be saved for use in the decompressor
|
||||
(particularly if the decompressor wants to decompress everything in
|
||||
a single step).
|
||||
*/
|
||||
|
||||
/* constants */
|
||||
|
||||
#define Z_NO_FLUSH 0
|
||||
#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
|
||||
#define Z_SYNC_FLUSH 2
|
||||
#define Z_FULL_FLUSH 3
|
||||
#define Z_FINISH 4
|
||||
/* Allowed flush values; see deflate() below for details */
|
||||
|
||||
#define Z_OK 0
|
||||
#define Z_STREAM_END 1
|
||||
#define Z_NEED_DICT 2
|
||||
#define Z_ERRNO (-1)
|
||||
#define Z_STREAM_ERROR (-2)
|
||||
#define Z_DATA_ERROR (-3)
|
||||
#define Z_MEM_ERROR (-4)
|
||||
#define Z_BUF_ERROR (-5)
|
||||
#define Z_VERSION_ERROR (-6)
|
||||
/* Return codes for the compression/decompression functions. Negative
|
||||
* values are errors, positive values are used for special but normal events.
|
||||
*/
|
||||
|
||||
#define Z_NO_COMPRESSION 0
|
||||
#define Z_BEST_SPEED 1
|
||||
#define Z_BEST_COMPRESSION 9
|
||||
#define Z_DEFAULT_COMPRESSION (-1)
|
||||
/* compression levels */
|
||||
|
||||
#define Z_FILTERED 1
|
||||
#define Z_HUFFMAN_ONLY 2
|
||||
#define Z_DEFAULT_STRATEGY 0
|
||||
/* compression strategy; see deflateInit2() below for details */
|
||||
|
||||
#define Z_BINARY 0
|
||||
#define Z_ASCII 1
|
||||
#define Z_UNKNOWN 2
|
||||
/* Possible values of the data_type field */
|
||||
|
||||
#define Z_DEFLATED 8
|
||||
/* The deflate compression method (the only one supported in this version) */
|
||||
|
||||
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
|
||||
|
||||
#define zlib_version zlibVersion()
|
||||
/* for compatibility with versions < 1.0.2 */
|
||||
|
||||
/* basic functions */
|
||||
|
||||
ZEXTERN const char * ZEXPORT zlibVersion OF((void));
|
||||
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
|
||||
If the first character differs, the library code actually used is
|
||||
not compatible with the zlib.h header file used by the application.
|
||||
This check is automatically made by deflateInit and inflateInit.
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
|
||||
|
||||
Initializes the internal stream state for compression. The fields
|
||||
zalloc, zfree and opaque must be initialized before by the caller.
|
||||
If zalloc and zfree are set to Z_NULL, deflateInit updates them to
|
||||
use default allocation functions.
|
||||
|
||||
The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
|
||||
1 gives best speed, 9 gives best compression, 0 gives no compression at
|
||||
all (the input data is simply copied a block at a time).
|
||||
Z_DEFAULT_COMPRESSION requests a default compromise between speed and
|
||||
compression (currently equivalent to level 6).
|
||||
|
||||
deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_STREAM_ERROR if level is not a valid compression level,
|
||||
Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
|
||||
with the version assumed by the caller (ZLIB_VERSION).
|
||||
msg is set to null if there is no error message. deflateInit does not
|
||||
perform any compression: this will be done by deflate().
|
||||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
||||
/*
|
||||
deflate compresses as much data as possible, and stops when the input
|
||||
buffer becomes empty or the output buffer becomes full. It may introduce some
|
||||
output latency (reading input without producing any output) except when
|
||||
forced to flush.
|
||||
|
||||
The detailed semantics are as follows. deflate performs one or both of the
|
||||
following actions:
|
||||
|
||||
- Compress more input starting at next_in and update next_in and avail_in
|
||||
accordingly. If not all input can be processed (because there is not
|
||||
enough room in the output buffer), next_in and avail_in are updated and
|
||||
processing will resume at this point for the next call of deflate().
|
||||
|
||||
- Provide more output starting at next_out and update next_out and avail_out
|
||||
accordingly. This action is forced if the parameter flush is non zero.
|
||||
Forcing flush frequently degrades the compression ratio, so this parameter
|
||||
should be set only when necessary (in interactive applications).
|
||||
Some output may be provided even if flush is not set.
|
||||
|
||||
Before the call of deflate(), the application should ensure that at least
|
||||
one of the actions is possible, by providing more input and/or consuming
|
||||
more output, and updating avail_in or avail_out accordingly; avail_out
|
||||
should never be zero before the call. The application can consume the
|
||||
compressed output when it wants, for example when the output buffer is full
|
||||
(avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
|
||||
and with zero avail_out, it must be called again after making room in the
|
||||
output buffer because there might be more output pending.
|
||||
|
||||
If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
|
||||
flushed to the output buffer and the output is aligned on a byte boundary, so
|
||||
that the decompressor can get all input data available so far. (In particular
|
||||
avail_in is zero after the call if enough output space has been provided
|
||||
before the call.) Flushing may degrade compression for some compression
|
||||
algorithms and so it should be used only when necessary.
|
||||
|
||||
If flush is set to Z_FULL_FLUSH, all output is flushed as with
|
||||
Z_SYNC_FLUSH, and the compression state is reset so that decompression can
|
||||
restart from this point if previous compressed data has been damaged or if
|
||||
random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
|
||||
the compression.
|
||||
|
||||
If deflate returns with avail_out == 0, this function must be called again
|
||||
with the same value of the flush parameter and more output space (updated
|
||||
avail_out), until the flush is complete (deflate returns with non-zero
|
||||
avail_out).
|
||||
|
||||
If the parameter flush is set to Z_FINISH, pending input is processed,
|
||||
pending output is flushed and deflate returns with Z_STREAM_END if there
|
||||
was enough output space; if deflate returns with Z_OK, this function must be
|
||||
called again with Z_FINISH and more output space (updated avail_out) but no
|
||||
more input data, until it returns with Z_STREAM_END or an error. After
|
||||
deflate has returned Z_STREAM_END, the only possible operations on the
|
||||
stream are deflateReset or deflateEnd.
|
||||
|
||||
Z_FINISH can be used immediately after deflateInit if all the compression
|
||||
is to be done in a single step. In this case, avail_out must be at least
|
||||
0.1% larger than avail_in plus 12 bytes. If deflate does not return
|
||||
Z_STREAM_END, then it must be called again as described above.
|
||||
|
||||
deflate() sets strm->adler to the adler32 checksum of all input read
|
||||
so far (that is, total_in bytes).
|
||||
|
||||
deflate() may update data_type if it can make a good guess about
|
||||
the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
|
||||
binary. This field is only for information purposes and does not affect
|
||||
the compression algorithm in any manner.
|
||||
|
||||
deflate() returns Z_OK if some progress has been made (more input
|
||||
processed or more output produced), Z_STREAM_END if all input has been
|
||||
consumed and all output has been produced (only when flush is set to
|
||||
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
|
||||
if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
|
||||
(for example avail_in or avail_out was zero).
|
||||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
|
||||
/*
|
||||
All dynamically allocated data structures for this stream are freed.
|
||||
This function discards any unprocessed input and does not flush any
|
||||
pending output.
|
||||
|
||||
deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
|
||||
stream state was inconsistent, Z_DATA_ERROR if the stream was freed
|
||||
prematurely (some input or output was discarded). In the error case,
|
||||
msg may be set but then points to a static string (which must not be
|
||||
deallocated).
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
|
||||
|
||||
Initializes the internal stream state for decompression. The fields
|
||||
next_in, avail_in, zalloc, zfree and opaque must be initialized before by
|
||||
the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
|
||||
value depends on the compression method), inflateInit determines the
|
||||
compression method from the zlib header and allocates all data structures
|
||||
accordingly; otherwise the allocation will be deferred to the first call of
|
||||
inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
|
||||
use default allocation functions.
|
||||
|
||||
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
||||
version assumed by the caller. msg is set to null if there is no error
|
||||
message. inflateInit does not perform any decompression apart from reading
|
||||
the zlib header if present: this will be done by inflate(). (So next_in and
|
||||
avail_in may be modified, but next_out and avail_out are unchanged.)
|
||||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
||||
/*
|
||||
inflate decompresses as much data as possible, and stops when the input
|
||||
buffer becomes empty or the output buffer becomes full. It may some
|
||||
introduce some output latency (reading input without producing any output)
|
||||
except when forced to flush.
|
||||
|
||||
The detailed semantics are as follows. inflate performs one or both of the
|
||||
following actions:
|
||||
|
||||
- Decompress more input starting at next_in and update next_in and avail_in
|
||||
accordingly. If not all input can be processed (because there is not
|
||||
enough room in the output buffer), next_in is updated and processing
|
||||
will resume at this point for the next call of inflate().
|
||||
|
||||
- Provide more output starting at next_out and update next_out and avail_out
|
||||
accordingly. inflate() provides as much output as possible, until there
|
||||
is no more input data or no more space in the output buffer (see below
|
||||
about the flush parameter).
|
||||
|
||||
Before the call of inflate(), the application should ensure that at least
|
||||
one of the actions is possible, by providing more input and/or consuming
|
||||
more output, and updating the next_* and avail_* values accordingly.
|
||||
The application can consume the uncompressed output when it wants, for
|
||||
example when the output buffer is full (avail_out == 0), or after each
|
||||
call of inflate(). If inflate returns Z_OK and with zero avail_out, it
|
||||
must be called again after making room in the output buffer because there
|
||||
might be more output pending.
|
||||
|
||||
If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
|
||||
output as possible to the output buffer. The flushing behavior of inflate is
|
||||
not specified for values of the flush parameter other than Z_SYNC_FLUSH
|
||||
and Z_FINISH, but the current implementation actually flushes as much output
|
||||
as possible anyway.
|
||||
|
||||
inflate() should normally be called until it returns Z_STREAM_END or an
|
||||
error. However if all decompression is to be performed in a single step
|
||||
(a single call of inflate), the parameter flush should be set to
|
||||
Z_FINISH. In this case all pending input is processed and all pending
|
||||
output is flushed; avail_out must be large enough to hold all the
|
||||
uncompressed data. (The size of the uncompressed data may have been saved
|
||||
by the compressor for this purpose.) The next operation on this stream must
|
||||
be inflateEnd to deallocate the decompression state. The use of Z_FINISH
|
||||
is never required, but can be used to inform inflate that a faster routine
|
||||
may be used for the single inflate() call.
|
||||
|
||||
If a preset dictionary is needed at this point (see inflateSetDictionary
|
||||
below), inflate sets strm-adler to the adler32 checksum of the
|
||||
dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
|
||||
it sets strm->adler to the adler32 checksum of all output produced
|
||||
so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
|
||||
an error code as described below. At the end of the stream, inflate()
|
||||
checks that its computed adler32 checksum is equal to that saved by the
|
||||
compressor and returns Z_STREAM_END only if the checksum is correct.
|
||||
|
||||
inflate() returns Z_OK if some progress has been made (more input processed
|
||||
or more output produced), Z_STREAM_END if the end of the compressed data has
|
||||
been reached and all uncompressed output has been produced, Z_NEED_DICT if a
|
||||
preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
|
||||
corrupted (input stream not conforming to the zlib format or incorrect
|
||||
adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
|
||||
(for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if no progress is possible or if there was not
|
||||
enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
|
||||
case, the application may then call inflateSync to look for a good
|
||||
compression block.
|
||||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
|
||||
/*
|
||||
All dynamically allocated data structures for this stream are freed.
|
||||
This function discards any unprocessed input and does not flush any
|
||||
pending output.
|
||||
|
||||
inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
|
||||
was inconsistent. In the error case, msg may be set but then points to a
|
||||
static string (which must not be deallocated).
|
||||
*/
|
||||
|
||||
/* Advanced functions */
|
||||
|
||||
/*
|
||||
The following functions are needed only in some special applications.
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
||||
int level,
|
||||
int method,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy));
|
||||
|
||||
This is another version of deflateInit with more compression options. The
|
||||
fields next_in, zalloc, zfree and opaque must be initialized before by
|
||||
the caller.
|
||||
|
||||
The method parameter is the compression method. It must be Z_DEFLATED in
|
||||
this version of the library.
|
||||
|
||||
The windowBits parameter is the base two logarithm of the window size
|
||||
(the size of the history buffer). It should be in the range 8..15 for this
|
||||
version of the library. Larger values of this parameter result in better
|
||||
compression at the expense of memory usage. The default value is 15 if
|
||||
deflateInit is used instead.
|
||||
|
||||
The memLevel parameter specifies how much memory should be allocated
|
||||
for the internal compression state. memLevel=1 uses minimum memory but
|
||||
is slow and reduces compression ratio; memLevel=9 uses maximum memory
|
||||
for optimal speed. The default value is 8. See zconf.h for total memory
|
||||
usage as a function of windowBits and memLevel.
|
||||
|
||||
The strategy parameter is used to tune the compression algorithm. Use the
|
||||
value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
|
||||
filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
|
||||
string match). Filtered data consists mostly of small values with a
|
||||
somewhat random distribution. In this case, the compression algorithm is
|
||||
tuned to compress them better. The effect of Z_FILTERED is to force more
|
||||
Huffman coding and less string matching; it is somewhat intermediate
|
||||
between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
|
||||
the compression ratio but not the correctness of the compressed output even
|
||||
if it is not set appropriately.
|
||||
|
||||
deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
|
||||
method). msg is set to null if there is no error message. deflateInit2 does
|
||||
not perform any compression: this will be done by deflate().
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength));
|
||||
/*
|
||||
Initializes the compression dictionary from the given byte sequence
|
||||
without producing any compressed output. This function must be called
|
||||
immediately after deflateInit, deflateInit2 or deflateReset, before any
|
||||
call of deflate. The compressor and decompressor must use exactly the same
|
||||
dictionary (see inflateSetDictionary).
|
||||
|
||||
The dictionary should consist of strings (byte sequences) that are likely
|
||||
to be encountered later in the data to be compressed, with the most commonly
|
||||
used strings preferably put towards the end of the dictionary. Using a
|
||||
dictionary is most useful when the data to be compressed is short and can be
|
||||
predicted with good accuracy; the data can then be compressed better than
|
||||
with the default empty dictionary.
|
||||
|
||||
Depending on the size of the compression data structures selected by
|
||||
deflateInit or deflateInit2, a part of the dictionary may in effect be
|
||||
discarded, for example if the dictionary is larger than the window size in
|
||||
deflate or deflate2. Thus the strings most likely to be useful should be
|
||||
put at the end of the dictionary, not at the front.
|
||||
|
||||
Upon return of this function, strm->adler is set to the Adler32 value
|
||||
of the dictionary; the decompressor may later use this value to determine
|
||||
which dictionary has been used by the compressor. (The Adler32 value
|
||||
applies to the whole dictionary even if only a subset of the dictionary is
|
||||
actually used by the compressor.)
|
||||
|
||||
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
|
||||
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||
inconsistent (for example if deflate has already been called for this stream
|
||||
or if the compression method is bsort). deflateSetDictionary does not
|
||||
perform any compression: this will be done by deflate().
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
|
||||
z_streamp source));
|
||||
/*
|
||||
Sets the destination stream as a complete copy of the source stream.
|
||||
|
||||
This function can be useful when several compression strategies will be
|
||||
tried, for example when there are several ways of pre-processing the input
|
||||
data with a filter. The streams that will be discarded should then be freed
|
||||
by calling deflateEnd. Note that deflateCopy duplicates the internal
|
||||
compression state which can be quite large, so this strategy is slow and
|
||||
can consume lots of memory.
|
||||
|
||||
deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
|
||||
(such as zalloc being NULL). msg is left unchanged in both source and
|
||||
destination.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
|
||||
/*
|
||||
This function is equivalent to deflateEnd followed by deflateInit,
|
||||
but does not free and reallocate all the internal compression state.
|
||||
The stream will keep the same compression level and any other attributes
|
||||
that may have been set by deflateInit2.
|
||||
|
||||
deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent (such as zalloc or state being NULL).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
|
||||
int level,
|
||||
int strategy));
|
||||
/*
|
||||
Dynamically update the compression level and compression strategy. The
|
||||
interpretation of level and strategy is as in deflateInit2. This can be
|
||||
used to switch between compression and straight copy of the input data, or
|
||||
to switch to a different kind of input data requiring a different
|
||||
strategy. If the compression level is changed, the input available so far
|
||||
is compressed with the old level (and may be flushed); the new level will
|
||||
take effect only at the next call of deflate().
|
||||
|
||||
Before the call of deflateParams, the stream state must be set as for
|
||||
a call of deflate(), since the currently available input may have to
|
||||
be compressed and flushed. In particular, strm->avail_out must be non-zero.
|
||||
|
||||
deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
|
||||
if strm->avail_out was zero.
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
||||
int windowBits));
|
||||
|
||||
This is another version of inflateInit with an extra parameter. The
|
||||
fields next_in, avail_in, zalloc, zfree and opaque must be initialized
|
||||
before by the caller.
|
||||
|
||||
The windowBits parameter is the base two logarithm of the maximum window
|
||||
size (the size of the history buffer). It should be in the range 8..15 for
|
||||
this version of the library. The default value is 15 if inflateInit is used
|
||||
instead. If a compressed stream with a larger window size is given as
|
||||
input, inflate() will return with the error code Z_DATA_ERROR instead of
|
||||
trying to allocate a larger window.
|
||||
|
||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
||||
memLevel). msg is set to null if there is no error message. inflateInit2
|
||||
does not perform any decompression apart from reading the zlib header if
|
||||
present: this will be done by inflate(). (So next_in and avail_in may be
|
||||
modified, but next_out and avail_out are unchanged.)
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength));
|
||||
/*
|
||||
Initializes the decompression dictionary from the given uncompressed byte
|
||||
sequence. This function must be called immediately after a call of inflate
|
||||
if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
|
||||
can be determined from the Adler32 value returned by this call of
|
||||
inflate. The compressor and decompressor must use exactly the same
|
||||
dictionary (see deflateSetDictionary).
|
||||
|
||||
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
|
||||
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||
inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
|
||||
expected one (incorrect Adler32 value). inflateSetDictionary does not
|
||||
perform any decompression: this will be done by subsequent calls of
|
||||
inflate().
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
||||
/*
|
||||
Skips invalid compressed data until a full flush point (see above the
|
||||
description of deflate with Z_FULL_FLUSH) can be found, or until all
|
||||
available input is skipped. No output is provided.
|
||||
|
||||
inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
|
||||
if no more input was provided, Z_DATA_ERROR if no flush point has been found,
|
||||
or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
|
||||
case, the application may save the current current value of total_in which
|
||||
indicates where valid compressed data was found. In the error case, the
|
||||
application may repeatedly call inflateSync, providing more input each time,
|
||||
until success or end of the input data.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
|
||||
/*
|
||||
This function is equivalent to inflateEnd followed by inflateInit,
|
||||
but does not free and reallocate all the internal decompression state.
|
||||
The stream will keep attributes that may have been set by inflateInit2.
|
||||
|
||||
inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent (such as zalloc or state being NULL).
|
||||
*/
|
||||
|
||||
|
||||
/* utility functions */
|
||||
|
||||
/*
|
||||
The following utility functions are implemented on top of the
|
||||
basic stream-oriented functions. To simplify the interface, some
|
||||
default options are assumed (compression level and memory usage,
|
||||
standard memory allocation functions). The source code of these
|
||||
utility functions can easily be modified if you need special options.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen));
|
||||
/*
|
||||
Compresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
size of the destination buffer, which must be at least 0.1% larger than
|
||||
sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
|
||||
compressed buffer.
|
||||
This function can be used to compress a whole file at once if the
|
||||
input file is mmap'ed.
|
||||
compress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen,
|
||||
int level));
|
||||
/*
|
||||
Compresses the source buffer into the destination buffer. The level
|
||||
parameter has the same meaning as in deflateInit. sourceLen is the byte
|
||||
length of the source buffer. Upon entry, destLen is the total size of the
|
||||
destination buffer, which must be at least 0.1% larger than sourceLen plus
|
||||
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
||||
|
||||
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen));
|
||||
/*
|
||||
Decompresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
size of the destination buffer, which must be large enough to hold the
|
||||
entire uncompressed data. (The size of the uncompressed data must have
|
||||
been saved previously by the compressor and transmitted to the decompressor
|
||||
by some mechanism outside the scope of this compression library.)
|
||||
Upon exit, destLen is the actual size of the compressed buffer.
|
||||
This function can be used to decompress a whole file at once if the
|
||||
input file is mmap'ed.
|
||||
|
||||
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||
*/
|
||||
|
||||
|
||||
typedef voidp gzFile;
|
||||
|
||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||
/*
|
||||
Opens a gzip (.gz) file for reading or writing. The mode parameter
|
||||
is as in fopen ("rb" or "wb") but can also include a compression level
|
||||
("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
|
||||
Huffman only compression as in "wb1h". (See the description
|
||||
of deflateInit2 for more information about the strategy parameter.)
|
||||
|
||||
gzopen can be used to read a file which is not in gzip format; in this
|
||||
case gzread will directly read from the file without decompression.
|
||||
|
||||
gzopen returns NULL if the file could not be opened or if there was
|
||||
insufficient memory to allocate the (de)compression state; errno
|
||||
can be checked to distinguish the two cases (if errno is zero, the
|
||||
zlib error is Z_MEM_ERROR). */
|
||||
|
||||
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||
/*
|
||||
gzdopen() associates a gzFile with the file descriptor fd. File
|
||||
descriptors are obtained from calls like open, dup, creat, pipe or
|
||||
fileno (in the file has been previously opened with fopen).
|
||||
The mode parameter is as in gzopen.
|
||||
The next call of gzclose on the returned gzFile will also close the
|
||||
file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
|
||||
descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
|
||||
gzdopen returns NULL if there was insufficient memory to allocate
|
||||
the (de)compression state.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
||||
/*
|
||||
Dynamically update the compression level or strategy. See the description
|
||||
of deflateInit2 for the meaning of these parameters.
|
||||
gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
|
||||
opened for writing.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||
/*
|
||||
Reads the given number of uncompressed bytes from the compressed file.
|
||||
If the input file was not in gzip format, gzread copies the given number
|
||||
of bytes into the buffer.
|
||||
gzread returns the number of uncompressed bytes actually read (0 for
|
||||
end of file, -1 for error). */
|
||||
|
||||
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
|
||||
const voidp buf, unsigned len));
|
||||
/*
|
||||
Writes the given number of uncompressed bytes into the compressed file.
|
||||
gzwrite returns the number of uncompressed bytes actually written
|
||||
(0 in case of error).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
|
||||
/*
|
||||
Converts, formats, and writes the args to the compressed file under
|
||||
control of the format string, as in fprintf. gzprintf returns the number of
|
||||
uncompressed bytes actually written (0 in case of error).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||
/*
|
||||
Writes the given null-terminated string to the compressed file, excluding
|
||||
the terminating null character.
|
||||
gzputs returns the number of characters written, or -1 in case of error.
|
||||
*/
|
||||
|
||||
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||
/*
|
||||
Reads bytes from the compressed file until len-1 characters are read, or
|
||||
a newline character is read and transferred to buf, or an end-of-file
|
||||
condition is encountered. The string is then terminated with a null
|
||||
character.
|
||||
gzgets returns buf, or Z_NULL in case of error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
||||
/*
|
||||
Writes c, converted to an unsigned char, into the compressed file.
|
||||
gzputc returns the value that was written, or -1 in case of error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||
/*
|
||||
Reads one byte from the compressed file. gzgetc returns this byte
|
||||
or -1 in case of end of file or error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
||||
/*
|
||||
Flushes all pending output into the compressed file. The parameter
|
||||
flush is as in the deflate() function. The return value is the zlib
|
||||
error number (see function gzerror below). gzflush returns Z_OK if
|
||||
the flush parameter is Z_FINISH and all output could be flushed.
|
||||
gzflush should be called only when strictly necessary because it can
|
||||
degrade compression.
|
||||
*/
|
||||
|
||||
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||
z_off_t offset, int whence));
|
||||
/*
|
||||
Sets the starting position for the next gzread or gzwrite on the
|
||||
given compressed file. The offset represents a number of bytes in the
|
||||
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
||||
the value SEEK_END is not supported.
|
||||
If the file is opened for reading, this function is emulated but can be
|
||||
extremely slow. If the file is opened for writing, only forward seeks are
|
||||
supported; gzseek then compresses a sequence of zeroes up to the new
|
||||
starting position.
|
||||
|
||||
gzseek returns the resulting offset location as measured in bytes from
|
||||
the beginning of the uncompressed stream, or -1 in case of error, in
|
||||
particular if the file is opened for writing and the new starting position
|
||||
would be before the current position.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
||||
/*
|
||||
Rewinds the given file. This function is supported only for reading.
|
||||
|
||||
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
||||
*/
|
||||
|
||||
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||
/*
|
||||
Returns the starting position for the next gzread or gzwrite on the
|
||||
given compressed file. This position represents a number of bytes in the
|
||||
uncompressed data stream.
|
||||
|
||||
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
||||
/*
|
||||
Returns 1 when EOF has previously been detected reading the given
|
||||
input stream, otherwise zero.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||
/*
|
||||
Flushes all pending output if necessary, closes the compressed file
|
||||
and deallocates all the (de)compression state. The return value is the zlib
|
||||
error number (see function gzerror below).
|
||||
*/
|
||||
|
||||
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||
/*
|
||||
Returns the error message for the last error which occurred on the
|
||||
given compressed file. errnum is set to zlib error number. If an
|
||||
error occurred in the file system and not in the compression library,
|
||||
errnum is set to Z_ERRNO and the application may consult errno
|
||||
to get the exact error code.
|
||||
*/
|
||||
|
||||
/* checksum functions */
|
||||
|
||||
/*
|
||||
These functions are not related to compression but are exported
|
||||
anyway because they might be useful in applications using the
|
||||
compression library.
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||
|
||||
/*
|
||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||
return the updated checksum. If buf is NULL, this function returns
|
||||
the required initial value for the checksum.
|
||||
An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
|
||||
much faster. Usage example:
|
||||
|
||||
uLong adler = adler32(0L, Z_NULL, 0);
|
||||
|
||||
while (read_buffer(buffer, length) != EOF) {
|
||||
adler = adler32(adler, buffer, length);
|
||||
}
|
||||
if (adler != original_adler) error();
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||
/*
|
||||
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||
crc. If buf is NULL, this function returns the required initial value
|
||||
for the crc. Pre- and post-conditioning (one's complement) is performed
|
||||
within this function so it shouldn't be done by the application.
|
||||
Usage example:
|
||||
|
||||
uLong crc = crc32(0L, Z_NULL, 0);
|
||||
|
||||
while (read_buffer(buffer, length) != EOF) {
|
||||
crc = crc32(crc, buffer, length);
|
||||
}
|
||||
if (crc != original_crc) error();
|
||||
*/
|
||||
|
||||
|
||||
/* various hacks, don't look :) */
|
||||
|
||||
/* deflateInit and inflateInit are macros to allow checking the zlib version
|
||||
* and the compiler's view of z_stream:
|
||||
*/
|
||||
ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
|
||||
const char *version, int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
|
||||
const char *version, int stream_size));
|
||||
ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel,
|
||||
int strategy, const char *version,
|
||||
int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
|
||||
const char *version, int stream_size));
|
||||
#define deflateInit(strm, level) \
|
||||
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define inflateInit(strm) \
|
||||
inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
|
||||
deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
|
||||
(strategy), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define inflateInit2(strm, windowBits) \
|
||||
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
|
||||
|
||||
|
||||
#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
|
||||
struct internal_state {int dummy;}; /* hack for buggy compilers */
|
||||
#endif
|
||||
|
||||
ZEXTERN const char * ZEXPORT zError OF((int err));
|
||||
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
|
||||
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ZLIB_H */
|
||||
@@ -0,0 +1,220 @@
|
||||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-1998 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id: ZUTIL.H,v 1.1.1.1 2002/08/02 09:59:47 kichik Exp $ */
|
||||
|
||||
#ifndef _Z_UTIL_H
|
||||
#define _Z_UTIL_H
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#ifdef STDC
|
||||
# include <stddef.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef NO_ERRNO_H
|
||||
extern int errno;
|
||||
#else
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||
|
||||
typedef unsigned char uch;
|
||||
typedef uch FAR uchf;
|
||||
typedef unsigned short ush;
|
||||
typedef ush FAR ushf;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
/* (size given to avoid silly warnings with Visual C++) */
|
||||
|
||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||
|
||||
#define ERR_RETURN(strm,err) \
|
||||
return (strm->msg = (char*)ERR_MSG(err), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
|
||||
/* common constants */
|
||||
|
||||
#ifndef DEF_WBITS
|
||||
# define DEF_WBITS MAX_WBITS
|
||||
#endif
|
||||
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
||||
|
||||
#if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
#else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
#define STORED_BLOCK 0
|
||||
#define STATIC_TREES 1
|
||||
#define DYN_TREES 2
|
||||
/* The three kinds of block type */
|
||||
|
||||
#define MIN_MATCH 3
|
||||
#define MAX_MATCH 258
|
||||
/* The minimum and maximum match lengths */
|
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||
|
||||
/* target dependencies */
|
||||
|
||||
#ifdef MSDOS
|
||||
# define OS_CODE 0x00
|
||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||
/* Allow compilation with ANSI keywords only enabled */
|
||||
void _Cdecl farfree( void *block );
|
||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||
# else
|
||||
# include <alloc.h>
|
||||
# endif
|
||||
# else /* MSC or DJGPP */
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef OS2
|
||||
# define OS_CODE 0x06
|
||||
#endif
|
||||
|
||||
#ifdef WIN32 /* Window 95 & Windows NT */
|
||||
# define OS_CODE 0x0b
|
||||
#endif
|
||||
|
||||
#if defined(VAXC) || defined(VMS)
|
||||
# define OS_CODE 0x02
|
||||
# define F_OPEN(name, mode) \
|
||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||
#endif
|
||||
|
||||
#ifdef AMIGA
|
||||
# define OS_CODE 0x01
|
||||
#endif
|
||||
|
||||
#if defined(ATARI) || defined(atarist)
|
||||
# define OS_CODE 0x05
|
||||
#endif
|
||||
|
||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
# define OS_CODE 0x07
|
||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||
# include <unix.h> /* for fdopen */
|
||||
# else
|
||||
# ifndef fdopen
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __50SERIES /* Prime/PRIMOS */
|
||||
# define OS_CODE 0x0F
|
||||
#endif
|
||||
|
||||
#ifdef TOPS20
|
||||
# define OS_CODE 0x0a
|
||||
#endif
|
||||
|
||||
#if defined(_BEOS_) || defined(RISCOS)
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER > 600))
|
||||
# define fdopen(fd,type) _fdopen(fd,type)
|
||||
#endif
|
||||
|
||||
|
||||
/* Common defaults */
|
||||
|
||||
#ifndef OS_CODE
|
||||
# define OS_CODE 0x03 /* assume Unix */
|
||||
#endif
|
||||
|
||||
#ifndef F_OPEN
|
||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||
#endif
|
||||
|
||||
/* functions */
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
extern char *strerror OF((int));
|
||||
# define zstrerror(errnum) strerror(errnum)
|
||||
#else
|
||||
# define zstrerror(errnum) ""
|
||||
#endif
|
||||
|
||||
#if defined(pyr)
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||
/* Use our own functions for small and medium model with MSC <= 5.0.
|
||||
* You may have to use the same strategy for Borland C (untested).
|
||||
* The __SC__ check is for Symantec.
|
||||
*/
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
||||
# define HAVE_MEMCPY
|
||||
#endif
|
||||
#ifdef HAVE_MEMCPY
|
||||
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
||||
# define zmemcpy _fmemcpy
|
||||
# define zmemcmp _fmemcmp
|
||||
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
||||
# else
|
||||
# define zmemcpy memcpy
|
||||
# define zmemcmp memcmp
|
||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||
# endif
|
||||
#else
|
||||
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
||||
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
||||
extern void zmemzero OF((Bytef* dest, uInt len));
|
||||
#endif
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef DEBUG
|
||||
# include <stdio.h>
|
||||
extern int z_verbose;
|
||||
extern void z_error OF((char *m));
|
||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
||||
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
||||
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
||||
#else
|
||||
# define Assert(cond,msg)
|
||||
# define Trace(x)
|
||||
# define Tracev(x)
|
||||
# define Tracevv(x)
|
||||
# define Tracec(c,x)
|
||||
# define Tracecv(c,x)
|
||||
#endif
|
||||
|
||||
|
||||
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
|
||||
uInt len));
|
||||
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
|
||||
void zcfree OF((voidpf opaque, voidpf ptr));
|
||||
|
||||
#define ZALLOC(strm, items, size) \
|
||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
|
||||
#endif /* _Z_UTIL_H */
|
||||
@@ -0,0 +1,226 @@
|
||||
/* zutil.c -- target dependent utility functions for the compression library
|
||||
* Copyright (C) 1995-1998 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id: Zutil.c,v 1.1.1.1 2002/08/02 09:59:46 kichik Exp $ */
|
||||
#include <windows.h>
|
||||
|
||||
#include "zutil.h"
|
||||
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
#ifndef STDC
|
||||
extern void exit OF((int));
|
||||
#endif
|
||||
|
||||
const char *z_errmsg[10] = {
|
||||
"need dictionary", /* Z_NEED_DICT 2 */
|
||||
"stream end", /* Z_STREAM_END 1 */
|
||||
"", /* Z_OK 0 */
|
||||
"file error", /* Z_ERRNO (-1) */
|
||||
"stream error", /* Z_STREAM_ERROR (-2) */
|
||||
"data error", /* Z_DATA_ERROR (-3) */
|
||||
"insufficient memory", /* Z_MEM_ERROR (-4) */
|
||||
"buffer error", /* Z_BUF_ERROR (-5) */
|
||||
"incompatible version",/* Z_VERSION_ERROR (-6) */
|
||||
""};
|
||||
|
||||
|
||||
const char * ZEXPORT zlibVersion()
|
||||
{
|
||||
return ZLIB_VERSION;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
# ifndef verbose
|
||||
# define verbose 0
|
||||
# endif
|
||||
int z_verbose = verbose;
|
||||
|
||||
void z_error (m)
|
||||
char *m;
|
||||
{
|
||||
fprintf(stderr, "%s\n", m);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* exported to allow conversion of error code to string for compress() and
|
||||
* uncompress()
|
||||
*/
|
||||
const char * ZEXPORT zError(err)
|
||||
int err;
|
||||
{
|
||||
return ERR_MSG(err);
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_MEMCPY
|
||||
|
||||
void zmemcpy(dest, source, len)
|
||||
Bytef* dest;
|
||||
const Bytef* source;
|
||||
uInt len;
|
||||
{
|
||||
if (len == 0) return;
|
||||
do {
|
||||
*dest++ = *source++; /* ??? to be unrolled */
|
||||
} while (--len != 0);
|
||||
}
|
||||
|
||||
int zmemcmp(s1, s2, len)
|
||||
const Bytef* s1;
|
||||
const Bytef* s2;
|
||||
uInt len;
|
||||
{
|
||||
uInt j;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void zmemzero(dest, len)
|
||||
Bytef* dest;
|
||||
uInt len;
|
||||
{
|
||||
if (len == 0) return;
|
||||
do {
|
||||
*dest++ = 0; /* ??? to be unrolled */
|
||||
} while (--len != 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__)
|
||||
/* Small and medium model in Turbo C are for now limited to near allocation
|
||||
* with reduced MAX_WBITS and MAX_MEM_LEVEL
|
||||
*/
|
||||
# define MY_ZCALLOC
|
||||
|
||||
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
|
||||
* and farmalloc(64K) returns a pointer with an offset of 8, so we
|
||||
* must fix the pointer. Warning: the pointer must be put back to its
|
||||
* original form in order to free it, use zcfree().
|
||||
*/
|
||||
|
||||
#define MAX_PTR 10
|
||||
/* 10*64K = 640K */
|
||||
|
||||
local int next_ptr = 0;
|
||||
|
||||
typedef struct ptr_table_s {
|
||||
voidpf org_ptr;
|
||||
voidpf new_ptr;
|
||||
} ptr_table;
|
||||
|
||||
local ptr_table table[MAX_PTR];
|
||||
/* This table is used to remember the original form of pointers
|
||||
* to large buffers (64K). Such pointers are normalized with a zero offset.
|
||||
* Since MSDOS is not a preemptive multitasking OS, this table is not
|
||||
* protected from concurrent access. This hack doesn't work anyway on
|
||||
* a protected system like OS/2. Use Microsoft C instead.
|
||||
*/
|
||||
|
||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||
{
|
||||
voidpf buf = opaque; /* just to make some compilers happy */
|
||||
ulg bsize = (ulg)items*size;
|
||||
|
||||
/* If we allocate less than 65520 bytes, we assume that farmalloc
|
||||
* will return a usable pointer which doesn't have to be normalized.
|
||||
*/
|
||||
if (bsize < 65520L) {
|
||||
buf = farmalloc(bsize);
|
||||
if (*(ush*)&buf != 0) return buf;
|
||||
} else {
|
||||
buf = farmalloc(bsize + 16L);
|
||||
}
|
||||
if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
|
||||
table[next_ptr].org_ptr = buf;
|
||||
|
||||
/* Normalize the pointer to seg:0 */
|
||||
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
|
||||
*(ush*)&buf = 0;
|
||||
table[next_ptr++].new_ptr = buf;
|
||||
return buf;
|
||||
}
|
||||
|
||||
void zcfree (voidpf opaque, voidpf ptr)
|
||||
{
|
||||
int n;
|
||||
if (*(ush*)&ptr != 0) { /* object < 64K */
|
||||
farfree(ptr);
|
||||
return;
|
||||
}
|
||||
/* Find the original pointer */
|
||||
for (n = 0; n < next_ptr; n++) {
|
||||
if (ptr != table[n].new_ptr) continue;
|
||||
|
||||
farfree(table[n].org_ptr);
|
||||
while (++n < next_ptr) {
|
||||
table[n-1] = table[n];
|
||||
}
|
||||
next_ptr--;
|
||||
return;
|
||||
}
|
||||
ptr = opaque; /* just to make some compilers happy */
|
||||
Assert(0, "zcfree: ptr not found");
|
||||
}
|
||||
#endif
|
||||
#endif /* __TURBOC__ */
|
||||
|
||||
|
||||
#if defined(M_I86) && !defined(__32BIT__)
|
||||
/* Microsoft C in 16-bit mode */
|
||||
|
||||
# define MY_ZCALLOC
|
||||
|
||||
#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
|
||||
# define _halloc halloc
|
||||
# define _hfree hfree
|
||||
#endif
|
||||
|
||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||
{
|
||||
if (opaque) opaque = 0; /* to make compiler happy */
|
||||
return _halloc((long)items, size);
|
||||
}
|
||||
|
||||
void zcfree (voidpf opaque, voidpf ptr)
|
||||
{
|
||||
if (opaque) opaque = 0; /* to make compiler happy */
|
||||
_hfree(ptr);
|
||||
}
|
||||
|
||||
#endif /* MSC */
|
||||
|
||||
|
||||
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
||||
|
||||
#ifndef STDC
|
||||
extern voidp calloc OF((uInt items, uInt size));
|
||||
extern void free OF((voidpf ptr));
|
||||
#endif
|
||||
|
||||
voidpf zcalloc (opaque, items, size)
|
||||
voidpf opaque;
|
||||
unsigned items;
|
||||
unsigned size;
|
||||
{
|
||||
if (opaque) items += size - size; /* make compiler happy */
|
||||
return (voidpf)GlobalAlloc(GPTR,items*size);
|
||||
}
|
||||
|
||||
void zcfree (opaque, ptr)
|
||||
voidpf opaque;
|
||||
voidpf ptr;
|
||||
{
|
||||
if (ptr) GlobalFree(ptr);
|
||||
if (opaque) return; /* make compiler happy */
|
||||
}
|
||||
|
||||
#endif /* MY_ZCALLOC */
|
||||
@@ -0,0 +1,205 @@
|
||||
# nsisunz - Informazioni di Build
|
||||
|
||||
## ⚠️ Nota importante
|
||||
|
||||
**Visual Studio 2026 Build Tools - Toolset v145**
|
||||
|
||||
Visual Studio 2026 Build Tools (versione 18.x) utilizza il **Platform Toolset v145**.
|
||||
|
||||
### Percorsi di installazione
|
||||
|
||||
VS2026 Build Tools installato con Chocolatey si trova in:
|
||||
- `C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools`
|
||||
|
||||
### Toolset
|
||||
|
||||
- **VS2022**: v143
|
||||
- **VS2026**: v145
|
||||
|
||||
---
|
||||
|
||||
## File di progetto disponibili
|
||||
|
||||
Questo plugin supporta due versioni di Visual Studio:
|
||||
|
||||
### Visual Studio 2022 (v143)
|
||||
- **File progetto**: `Source/nsisunz.vcxproj`
|
||||
- **Script build**: `build_plugin.py`
|
||||
- **Platform Toolset**: v143
|
||||
- **Percorso VS**: `C:\Program Files\Microsoft Visual Studio\2022\`
|
||||
|
||||
### Visual Studio 2026 (v145)
|
||||
- **File progetto**: `Source/nsisunz_vs2026.vcxproj`
|
||||
- **Script build**: `build_plugin_vs2026.py`
|
||||
- **Platform Toolset**: v145
|
||||
- **Percorso VS**: `C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools`
|
||||
|
||||
## Compilazione
|
||||
|
||||
### Con Visual Studio 2022
|
||||
|
||||
#### Metodo 1: Script Python
|
||||
```cmd
|
||||
cd nsUnz-zlib1.3
|
||||
python build_plugin.py
|
||||
```
|
||||
|
||||
#### Metodo 2: Visual Studio IDE
|
||||
1. Apri `Source\nsisunz.vcxproj` in Visual Studio 2022
|
||||
2. Seleziona la configurazione (Release, Release Unicode)
|
||||
3. Seleziona la piattaforma (Win32, x64)
|
||||
4. Build → Rebuild Solution
|
||||
|
||||
#### Metodo 3: MSBuild diretto
|
||||
```cmd
|
||||
cd nsUnz-zlib1.3\Source
|
||||
msbuild nsisunz.vcxproj /p:Configuration="Release Unicode" /p:Platform=Win32
|
||||
msbuild nsisunz.vcxproj /p:Configuration="Release Unicode" /p:Platform=x64
|
||||
msbuild nsisunz.vcxproj /p:Configuration=Release /p:Platform=Win32
|
||||
```
|
||||
|
||||
### Visual Studio 2026 (FUNZIONANTE)
|
||||
|
||||
#### Metodo 1: Script Python
|
||||
```cmd
|
||||
cd nsUnz-zlib1.3
|
||||
python build_plugin_vs2026.py
|
||||
```
|
||||
|
||||
#### Metodo 2: Visual Studio IDE
|
||||
1. Apri `Source\nsisunz_vs2026.vcxproj` in Visual Studio 2026
|
||||
2. Seleziona la configurazione (Release, Release Unicode)
|
||||
3. Seleziona la piattaforma (Win32, x64)
|
||||
4. Build → Rebuild Solution
|
||||
|
||||
#### Metodo 3: MSBuild diretto
|
||||
```cmd
|
||||
cd nsUnz-zlib1.3\Source
|
||||
msbuild nsisunz_vs2026.vcxproj /p:Configuration="Release Unicode" /p:Platform=Win32
|
||||
msbuild nsisunz_vs2026.vcxproj /p:Configuration="Release Unicode" /p:Platform=x64
|
||||
msbuild nsisunz_vs2026.vcxproj /p:Configuration=Release /p:Platform=Win32
|
||||
```
|
||||
|
||||
## Configurazioni Build
|
||||
|
||||
Entrambi i progetti supportano le stesse configurazioni:
|
||||
|
||||
| Nome Config | Configurazione VS | Piattaforma | Output | Destinazione Plugin |
|
||||
|-------------|-------------------|-------------|--------|---------------------|
|
||||
| x86-ansi | Release | Win32 | nsisunz.dll | plugins/x86-ansi/ |
|
||||
| x86-unicode | Release Unicode | Win32 | nsisunz.dll | plugins/x86-unicode/ |
|
||||
| x64-unicode | Release Unicode | x64 | nsisunz.dll | plugins/amd64-unicode/ |
|
||||
|
||||
## Opzioni Script Python
|
||||
|
||||
Entrambi gli script supportano le stesse opzioni:
|
||||
|
||||
```cmd
|
||||
# Compila tutte le configurazioni
|
||||
python build_plugin.py
|
||||
|
||||
# Compila solo configurazioni specifiche
|
||||
python build_plugin.py --configs x86-unicode x64-unicode
|
||||
|
||||
# Build incrementale (no rebuild)
|
||||
python build_plugin.py --no-rebuild
|
||||
|
||||
# Build single-thread (no parallel)
|
||||
python build_plugin.py --no-parallel
|
||||
|
||||
# Aumenta verbosità
|
||||
python build_plugin.py --verbosity minimal
|
||||
|
||||
# Non pulire file intermedi
|
||||
python build_plugin.py --no-clean
|
||||
|
||||
# Lista configurazioni disponibili
|
||||
python build_plugin.py --list
|
||||
|
||||
# Pausa alla fine
|
||||
python build_plugin.py --pause
|
||||
|
||||
# Benchmark prestazioni
|
||||
python build_plugin.py --benchmark --configs x86-unicode
|
||||
```
|
||||
|
||||
## Differenze tra VS2022 e VS2026
|
||||
|
||||
### Platform Toolset
|
||||
- **VS2022**: v143
|
||||
- **VS2026**: v145 (versione 18.x Build Tools)
|
||||
|
||||
### Percorso installazione
|
||||
- **VS2022**: `C:\Program Files\Microsoft Visual Studio\2022\`
|
||||
- **VS2026 Build Tools**: `C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools`
|
||||
|
||||
### Compatibilità
|
||||
Entrambe le versioni producono DLL binari compatibili con NSIS. La differenza principale è nel compilatore e nell'ottimizzatore utilizzato.
|
||||
|
||||
### Quando usare quale versione?
|
||||
|
||||
**Usa VS2022** se:
|
||||
- È la tua versione corrente di Visual Studio
|
||||
- Vuoi stabilità e compatibilità provata
|
||||
- Stai lavorando in un ambiente di produzione
|
||||
|
||||
**Usa VS2026** se:
|
||||
- Hai installato VS2026 Build Tools (choco install visualstudio2026buildtools)
|
||||
- Vuoi utilizzare il toolset v145
|
||||
- Vuoi testare il compilatore più recente
|
||||
|
||||
## Output
|
||||
|
||||
Dopo la compilazione, i DLL vengono copiati in:
|
||||
```
|
||||
Launchers/plugins/
|
||||
├── x86-ansi/nsisunz.dll
|
||||
├── x86-unicode/nsisunz.dll
|
||||
└── amd64-unicode/nsisunz.dll
|
||||
```
|
||||
|
||||
## Preprocessor Defines
|
||||
|
||||
Entrambi i progetti utilizzano:
|
||||
- `NOCRYPT` - Disabilita supporto ZIP criptati
|
||||
- `Z_SOLO` - Disabilita funzioni gzip (riduce dipendenze)
|
||||
|
||||
## Requisiti
|
||||
|
||||
### Per Visual Studio 2022
|
||||
- Visual Studio 2022 (Community/Professional/Enterprise)
|
||||
- Windows SDK 10.0
|
||||
- Desktop development with C++ workload
|
||||
- Python 3.6+ (opzionale, per script build)
|
||||
|
||||
### Per Visual Studio 2026
|
||||
- Visual Studio 2026 Build Tools (Community/Professional/Enterprise)
|
||||
```cmd
|
||||
choco install visualstudio2026buildtools
|
||||
```
|
||||
- Windows SDK 10.0
|
||||
- Desktop development with C++ workload
|
||||
- Python 3.6+ (opzionale, per script build)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### MSBuild non trovato
|
||||
Assicurati che Visual Studio sia installato con il workload "Desktop development with C++".
|
||||
|
||||
### Errore Platform Toolset
|
||||
Se vedi errori sul toolset, verifica che la versione corretta di Visual Studio sia installata:
|
||||
- v143 richiede VS2022
|
||||
- v145 richiede VS2026 Build Tools (versione 18.x)
|
||||
|
||||
### Errore Z_SOLO / gzguts.h
|
||||
Questo è già risolto nei progetti. Se vedi questo errore, assicurati che `Z_SOLO` sia definito nei preprocessor defines.
|
||||
|
||||
## Note
|
||||
|
||||
- Visual Studio 2026 Build Tools (versione 18.x) usa il toolset **v145**
|
||||
- Installabile con Chocolatey: `choco install visualstudio2026buildtools`
|
||||
- Il percorso di installazione è `C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools`
|
||||
- Entrambi gli script (VS2022 e VS2026) sono completamente funzionanti
|
||||
|
||||
---
|
||||
Aggiornato: Dicembre 2025
|
||||
@@ -0,0 +1,118 @@
|
||||
# Modifiche rispetto a nsUnz originale
|
||||
|
||||
## Aggiornamento zlib 1.1.3 → 1.3.1
|
||||
|
||||
Questa versione di nsisunz è stata aggiornata per utilizzare **zlib 1.3.1** (ultima versione stabile, Agosto 2023) invece della vecchia versione 1.1.3 del 1998.
|
||||
|
||||
### Motivazioni dell'aggiornamento
|
||||
|
||||
1. **Sicurezza**: 25 anni di correzioni di sicurezza
|
||||
2. **Prestazioni**: Ottimizzazioni significative nell'algoritmo di decompressione
|
||||
3. **Compatibilità**: Migliore supporto per ZIP64 e archivi moderni
|
||||
4. **Stabilità**: Bug fix accumulati nel corso degli anni
|
||||
5. **Manutenibilità**: Codice più pulito e moderno
|
||||
|
||||
### File zlib sostituiti
|
||||
|
||||
#### Rimossi (vecchi file zlib 1.1.3):
|
||||
- `INFBLOCK.C/H` - Gestione blocchi inflate (obsoleto)
|
||||
- `INFCODES.C/H` - Decodifica codici inflate (obsoleto)
|
||||
- `INFUTIL.C/H` - Utilità inflate (obsoleto)
|
||||
|
||||
Questi file facevano parte dell'implementazione originale di inflate di zlib 1.1.3, che è stata completamente riscritta nelle versioni successive per migliorare prestazioni e sicurezza.
|
||||
|
||||
#### Aggiunti (nuovi file zlib 1.3.1):
|
||||
|
||||
**Core decompressione (aggiornati):**
|
||||
- `inflate.c/h` - Implementazione inflate moderna e ottimizzata
|
||||
- `inftrees.c/h` - Gestione alberi Huffman (aggiornato)
|
||||
- `inffast.c/h` - Decompressione veloce (aggiornato)
|
||||
- `inffixed.h` - Tabelle Huffman fisse (aggiornato)
|
||||
|
||||
**Checksum (aggiornati):**
|
||||
- `adler32.c` - Checksum Adler-32 ottimizzato
|
||||
- `crc32.c/h` - CRC32 con tabelle ottimizzate
|
||||
|
||||
**Utilities:**
|
||||
- `zutil.c/h` - Utilità zlib (aggiornato)
|
||||
- `zconf.h` - Configurazione zlib (aggiornato)
|
||||
- `zlib.h` - Header principale (v1.3.1)
|
||||
|
||||
**Minizip (aggiornato da contrib/minizip di zlib 1.3.1):**
|
||||
- `unzip.c/h` - Gestione archivi ZIP (aggiornato con supporto ZIP64)
|
||||
- `ioapi.c/h` - API I/O astratta (nuovo)
|
||||
- `iowin32.c/h` - Implementazione I/O Windows (nuovo)
|
||||
- `crypt.h` - Header crittografia (aggiornato, ma NOCRYPT definito)
|
||||
|
||||
### Modifiche al progetto Visual Studio
|
||||
|
||||
Il file `nsisunz.vcxproj` è stato aggiornato per:
|
||||
|
||||
1. **Rimuovere** i vecchi file zlib 1.1.3:
|
||||
- INFBLOCK.C/H
|
||||
- INFCODES.C/H
|
||||
- INFUTIL.C/H
|
||||
|
||||
2. **Aggiungere** i nuovi file zlib 1.3.1:
|
||||
- ioapi.c/h
|
||||
- iowin32.c/h
|
||||
- crc32.h
|
||||
- crypt.h
|
||||
|
||||
3. **Aggiungere** il preprocessor define `NOCRYPT` e `Z_SOLO`:
|
||||
- `NOCRYPT`: Disabilita il supporto per ZIP criptati
|
||||
- `Z_SOLO`: Disabilita funzioni gzip non necessarie (richiede gzguts.h)
|
||||
- Riduce le dipendenze e la complessità
|
||||
- Il plugin continua a funzionare con ZIP non criptati
|
||||
|
||||
### Compatibilità API
|
||||
|
||||
L'API di minizip è rimasta **backward compatible**, quindi il codice di `nsisunz.cpp` **non richiede modifiche**. Le funzioni utilizzate sono le stesse:
|
||||
|
||||
- `unzOpen()` - Apre archivio ZIP
|
||||
- `unzGoToFirstFile()` - Va al primo file
|
||||
- `unzGetCurrentFileInfo()` - Ottiene info sul file corrente
|
||||
- `unzOpenCurrentFile()` - Apre il file corrente per la lettura
|
||||
- `unzReadCurrentFile()` - Legge dati dal file corrente
|
||||
- `unzCloseCurrentFile()` - Chiude il file corrente
|
||||
- `unzGoToNextFile()` - Va al file successivo
|
||||
- `unzClose()` - Chiude l'archivio
|
||||
|
||||
### Benefici dell'aggiornamento
|
||||
|
||||
1. **Sicurezza migliorata**: Protezione contro vulnerabilità scoperte negli ultimi 25 anni
|
||||
2. **Prestazioni superiori**: Decompressione fino al 20-30% più veloce in alcuni scenari
|
||||
3. **Memoria ottimizzata**: Utilizzo più efficiente della memoria
|
||||
4. **ZIP64**: Supporto migliorato per archivi > 4GB
|
||||
5. **Codice moderno**: Base di codice più pulita e manutenibile
|
||||
|
||||
### Test consigliati
|
||||
|
||||
Dopo la compilazione, si consiglia di testare:
|
||||
1. Estrazione di archivi ZIP standard
|
||||
2. Estrazione di file singoli con `/file`
|
||||
3. Estrazione con `/noextractpath`
|
||||
4. Archivi con nomi di file Unicode
|
||||
5. Archivi ZIP grandi (se possibile, ZIP64)
|
||||
|
||||
### Compilazione
|
||||
|
||||
```cmd
|
||||
cd nsUnz-zlib1.3\Source
|
||||
```
|
||||
|
||||
Quindi aprire `nsisunz.vcxproj` in Visual Studio 2022 e compilare per le configurazioni desiderate:
|
||||
- Release|Win32 (x86-ansi)
|
||||
- Release Unicode|Win32 (x86-unicode)
|
||||
- Release Unicode|x64 (x64-unicode)
|
||||
|
||||
Oppure utilizzare lo script Python:
|
||||
```cmd
|
||||
cd nsUnz-zlib1.3
|
||||
python build_plugin.py # VS2022
|
||||
python build_plugin_vs2026.py # VS2026
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
*Per dettagli completi sulla compilazione, vedi [BUILD_INFO.md](BUILD_INFO.md)*
|
||||
Binary file not shown.
@@ -0,0 +1,361 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>nsisunz</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
|
||||
<style type="text/css">
|
||||
/*<![CDATA[*/
|
||||
|
||||
body
|
||||
{
|
||||
padding: 10px;
|
||||
background-color: #F0F0F0;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
p
|
||||
{
|
||||
font-size: 100%;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
.center
|
||||
{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table
|
||||
{
|
||||
margin: auto;
|
||||
text-align: left;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.maintable
|
||||
{
|
||||
border: 2px solid #376EAB;
|
||||
}
|
||||
|
||||
.parameter
|
||||
{
|
||||
font-weight: bold;
|
||||
color: #6586AC;
|
||||
}
|
||||
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 220%;
|
||||
color: #333333;
|
||||
font-weight: normal;
|
||||
text-align: center;
|
||||
margin: 20px;
|
||||
filter: glow(color="silver", strength="6");
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
h2
|
||||
{
|
||||
font-size: 165%;
|
||||
color: #7A7272;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h3
|
||||
{
|
||||
font-size: 140%;
|
||||
font-weight: bold;
|
||||
color: #303030;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-size: 100%;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
div
|
||||
{
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
a:link, a:visited, a:active
|
||||
{
|
||||
color: #294F75;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover
|
||||
{
|
||||
color: #182634;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.subtable
|
||||
{
|
||||
border: 0px;
|
||||
margin-left: 20px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.lefttable
|
||||
{
|
||||
background-color: #CCCCCC;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.righttable
|
||||
{
|
||||
background-color: #EEEEEE;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.preproc {color: green;}
|
||||
.comment {color: gray;}
|
||||
.keyword {color: blue;}
|
||||
.string {color: teal;}
|
||||
.param {color: orange;}
|
||||
|
||||
/*]]>*/
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="center">
|
||||
<table width="750" class="maintable" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td>
|
||||
<h1>nsisunz</h1>
|
||||
<div>
|
||||
<h2>Introduction</h2>
|
||||
<p><b>nsisunz</b> is a NSIS plugin which allows you to extract files from ZIP
|
||||
archives.</p>
|
||||
<p><b>nsisunz</b> is great when you use another NSIS plug-in named
|
||||
<em>NSISdl</em> to download a ZIP file from the internet.
|
||||
Download a small installer which lets the user choose the components he/she
|
||||
want to install and the installer downloads it (<em>QuickTime Setup</em> does
|
||||
this).</p>
|
||||
<p>Note:
|
||||
<em>nsisunz</em> does not support password protected ZIP archives
|
||||
(encrypted).<br/>
|
||||
To extract only a specific file from the archive use the
|
||||
<a href="#fileopt">"/file"</a> option.
|
||||
</p>
|
||||
<h2>How to use</h2>
|
||||
<h3>Setting it up</h3>
|
||||
<p>To see a great example of how to use the plug-in,
|
||||
check out the included <a href="example.nsi">example script</a>.</p>
|
||||
<p>You use the <em>Unzip</em>, <em>UnzipToLog</em> or the
|
||||
<em><a href="#UnzipToStack">UnzipToStack</a></em> function to extract files
|
||||
from a ZIP archive.</p>
|
||||
<p>In my opinion the best way to describe things is by showing an example,
|
||||
so here is one:</p>
|
||||
<pre>
|
||||
<font class="keyword">InitPluginsDir</font>
|
||||
<font class="comment">; Call plug-in. Push filename to ZIP first, and the dest. folder last.</font>
|
||||
nsisunz::UnzipToLog <font class="string">"$PLUGINSDIR\myzipfile.zip" "$INSTDIR"</font>
|
||||
|
||||
<font class="comment">; Always check result on stack</font>
|
||||
<font class="keyword">Pop</font> $0
|
||||
<font class="keyword">StrCmp</font> $0 <font class="string">"success"</font> ok
|
||||
<font class="keyword">DetailPrint</font> <font class="string">"$0"</font> <font class="comment">;print error message to log</font>
|
||||
ok:
|
||||
|
||||
<font class="comment">; You can also use the "Unzip" function if you don't want to use the log.
|
||||
; It is a lot quicker, and is preferred for large ZIP archives.</font>
|
||||
nsisunz::Unzip <font class="string">"$PLUGINSDIR\myzipfile.zip" "$INSTDIR"</font>
|
||||
</pre>
|
||||
<a name="UnzipToStack"><h3>The UnzipToStack function</h3></a>
|
||||
<p>The <em>UnzipToStack</em> function can be used instead of the <em>UnzipToLog</em> function
|
||||
if you want the extraction to be a lot faster when extracting from very large ZIP archives and still
|
||||
want to see the files extracted. This is how you use it:
|
||||
</p>
|
||||
<pre>
|
||||
nsisunz::UnzipToStack <font class="string">"$PLUGINSDIR\myzipfile.zip" "$INSTDIR"</font>
|
||||
<font class="keyword">Pop</font> $0
|
||||
<font class="keyword">StrCmp</font> $0 <font class="string">"success"</font> ok
|
||||
<font class="keyword">DetailPrint</font> <font class="keyword">"$0"</font> <font class="comment">;print error message to log</font>
|
||||
<font class="keyword">Goto</font> skiplist
|
||||
ok:
|
||||
|
||||
<font class="comment">; Print out list of files extracted to log</font>
|
||||
next:
|
||||
<font class="keyword">Pop</font> $0
|
||||
<font class="keyword">DetailPrint</font> $0
|
||||
<font class="keyword">StrCmp</font> $0 "" 0 next <font class="comment">; pop strings until a blank one arrives</font>
|
||||
|
||||
skiplist:
|
||||
</pre>
|
||||
<a name="fileopt"><h3>Extracting specific files</h3></a>
|
||||
<p>
|
||||
To extract only a specific file use the "/file" option like this:
|
||||
</p>
|
||||
<pre>
|
||||
nsisunz::UnzipToLog /file <font class="string">"AnyPathInsideZIP/AFile.txt" "myzip.zip" "c:\myfiles"</font>
|
||||
</pre>
|
||||
<p>
|
||||
The path is relative to the root of the ZIP archive so you don't have to
|
||||
prepend a slash ("/"). Furthermore the foldernames are extracted with the file so
|
||||
the example above creates a file named "c:\myfiles\AnyPathInsideZIP\AFile.txt".
|
||||
To avoid this use "/noextractpath" like this:
|
||||
</p>
|
||||
<pre>
|
||||
nsisunz::UnzipToLog /noextractpath /file \
|
||||
<font class="string">"AnyPathInsideZIP/AFile.txt" "myzip.zip" "c:\myfiles"</font>
|
||||
</pre>
|
||||
<h3>Using nsisunz with NSISdl</h3>
|
||||
<p>To use <em>NSISdl</em> with <em>nsisunz</em> to download and extract a ZIP archive,
|
||||
do something like this:</p>
|
||||
<pre>
|
||||
<font class="keyword">InitPluginsDir</font>
|
||||
NSISdl::download <font class="string">http://www.domain.com/file "$PLUGINSDIR\localfile.zip"</font>
|
||||
<font class="keyword">Pop</font> $R0 ;Get the return value
|
||||
<font class="keyword">StrCmp</font> $R0 <font class="string">"success"</font> +3
|
||||
<font class="keyword">MessageBox</font> <font class="param">MB_OK</font> <font class="string">"Download failed: $R0"</font>
|
||||
<font class="keyword">Quit</font>
|
||||
|
||||
nsisunz::UnzipToLog <font class="string">"$PLUGINSDIR\localfile.zip" "$INSTDIR"</font>
|
||||
<font class="keyword">Pop</font> $R0
|
||||
<font class="keyword">StrCmp</font> $R0 <font class="string">"success"</font> +2
|
||||
<font class="keyword">DetailPrint</font> <font class="string">"$R0"</font> <font class="comment">;print error message to log</font>
|
||||
|
||||
</pre>
|
||||
<h3>Options</h3>
|
||||
<p>These are the optional parameters you can specify when calling <em>nsisunz</em>.</p>
|
||||
<table class="subtable">
|
||||
<tr>
|
||||
<td class="lefttable">/noextractpath</td>
|
||||
<td class="righttable">This option makes the plug-in extract all files to
|
||||
the destination directory without regard to paths stored in ZIP file.
|
||||
Is often used in conjunction with "/file" to extract a single file
|
||||
from anywhere in an archive to a destination directory.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lefttable">/file</td>
|
||||
<td class="righttable">Extract a specific file. Filename must be specified
|
||||
as next parameter and must match a file in the ZIP including any
|
||||
subdirectories. If the file couldn't be found in the ZIP file,
|
||||
<em>nsisunz</em> pushes the string "File not found in ZIP file" on the
|
||||
stack.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lefttable">/text</td>
|
||||
<td class="righttable">Sets the format of the text used in the log to the
|
||||
next param. <em>"%f"</em> is replaced with the filename, <em>"%c"</em> is
|
||||
replaced with the compressed size and <em>"%u"</em> is replaced with the
|
||||
uncompressed size.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3>Return value</h3>
|
||||
<p>After you have called the DLL, <b>nsisunz</b> adds either "success" or a specific error message
|
||||
on the stack. This is the possible error messages:</p>
|
||||
<ul>
|
||||
<li>Error opening ZIP file</li>
|
||||
<li>Error opening output file(s)</li>
|
||||
<li>Error writing output file(s)</li>
|
||||
<li>Error extracting from ZIP file</li>
|
||||
<li>File not found in ZIP file</li>
|
||||
</ul>
|
||||
<p>Usually, you don't need to check this value, but you still have to remove it from the stack
|
||||
(have a look at the example above).</p>
|
||||
<h2>Reserve files</h2>
|
||||
<p>If you are using BZIP2 (solid) compression, it's important that files which are being extracted
|
||||
in init- or page functions function are located before other files in the data block, because this
|
||||
will make your installer faster.</p>
|
||||
<p>If there are File commands in your sections or functions above the init- or page functions, add
|
||||
ReserveFile commands above your sections and functions:</p>
|
||||
<pre>
|
||||
<font class="keyword">ReserveFile</font> <font class="string">"myzipfile.zip"</font>
|
||||
<font class="keyword">ReserveFile</font> <font class="string">"${NSISDIR}\Plugins\nsisunz.dll"</font>
|
||||
</pre>
|
||||
<h2>Localization</h2>
|
||||
<p>Use the <em>"/text"</em> parameter to localize the text used by nsisunz
|
||||
for the log output.
|
||||
</p>
|
||||
<pre>
|
||||
<font class="comment">; Localized strings for use with nsisunz</font>
|
||||
<font class="comment">; The "%f" in the string is replaced with the filename on run-time.</font>
|
||||
<font class="comment">; "%c" and "%u" is replaced with compressed size and</font>
|
||||
<font class="comment">; uncompressed size respectively. See example script.</font>
|
||||
|
||||
<font class="keyword">LoadLanguageFile</font> <font class="string">"${NSISDIR}\Contrib\Language files\english.nlf"</font>
|
||||
<font class="keyword">LoadLanguageFile</font> <font class="string">"${NSISDIR}\Contrib\Language files\norwegian.nlf"</font>
|
||||
|
||||
<font class="keyword">LangString</font> nsisunz_text ${LANG_ENGLISH} <font class="string">"Extract: %f"</font>
|
||||
<font class="keyword">LangString</font> nsisunz_text ${LANG_NORWEGIAN} <font class="string">"Pakk ut: %f"</font>
|
||||
|
||||
<font class="keyword">Function</font> .onInit
|
||||
nsisunz:: /text <font class="string">"" "$(nsisunz_text)"</font>
|
||||
<font class="keyword">FunctionEnd</font>
|
||||
</pre>
|
||||
<h2>Notes</h2>
|
||||
<p>
|
||||
The plug-in is compressed with UPX to make it smaller.<br />
|
||||
If you make changes to the source, re-compile and use UPX you may get this
|
||||
message:<br />
|
||||
<code>upx: nsisunz.dll: CantPackException: file is possibly packed/protected
|
||||
(try --force)</code><br />
|
||||
I used the "<code>--force</code>" parameter as proposed,
|
||||
and without problems UPX reduced the size of <em>nsisunz.dll</em> from ~71 kb
|
||||
to 31,5 kb<br/>
|
||||
The reason for why you get this message is that the source #include's
|
||||
"AggressiveOptimize.h" which makes the linker merge the code sections of the
|
||||
final executable. This makes UPX think it's already packed (which it kinda is).
|
||||
But by using the "<code>--force</code>" parameter, UPX may shrink it a lot
|
||||
more.<br/>
|
||||
I hope people appreciate my struggles to keep the size of the plug-in small.
|
||||
If someone have any suggestions for making it even smaller I would like if
|
||||
someone sendt me an e-mail.
|
||||
</p>
|
||||
<h2>Contact</h2>
|
||||
<p><em>nsisunz</em> is written by Saivert.<br />
|
||||
Homepage: <a href="http://saivert.inthegray.com/">
|
||||
http://saivert.inthegray.com/</a><br />
|
||||
E-mail: <a href="mailto:saivert@gmail.com?subject=nsisunz&
|
||||
body=Regarding%20nsisunz:%0D%0A%0D%0A">saivert@gmail.com</a>
|
||||
|
||||
</p>
|
||||
<h2>Version history</h2>
|
||||
<ul>
|
||||
<li>DLL version 1.0 (12/4/2004)
|
||||
<ul>
|
||||
<li>First public release!</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<h2>Credits</h2>
|
||||
<p>
|
||||
Based on code in NSIS Zip2Exe<br/>
|
||||
portions Copyright © 1999-2001 Miguel Garrido (mgarrido01@hotmail.com)<br/>
|
||||
Uses ZLIB - Copyright © Mark Adler<br/>
|
||||
ZIP format routines - Copyright © 1998 Gilles Vollant<br/>
|
||||
Thanks to Tim Kosse for the LogMessage function, even though I
|
||||
could figure this out myself.<br/>
|
||||
And thanks to Joost Verburg for the readme HTML page design.</p>
|
||||
<h2>License</h2>
|
||||
<pre>
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute
|
||||
it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented;
|
||||
you must not claim that you wrote the original software.
|
||||
If you use this software in a product, an acknowledgment in the
|
||||
product documentation would be appreciated but is not required.
|
||||
2. Altered versions must be plainly marked as such,
|
||||
and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any distribution.
|
||||
</pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,101 @@
|
||||
#ifndef _EXDLL_H_
|
||||
#define _EXDLL_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define UNUSED
|
||||
#endif
|
||||
|
||||
// only include this file from one place in your DLL.
|
||||
// (it is all static, if you use it in two places it will fail)
|
||||
|
||||
typedef struct _stack_t
|
||||
{
|
||||
struct _stack_t *next;
|
||||
TCHAR text[1]; // this should be the length of string_size
|
||||
} stack_t;
|
||||
|
||||
// Global variables (must be declared where you include this header)
|
||||
static unsigned int g_stringsize;
|
||||
static stack_t **g_stacktop;
|
||||
static TCHAR *g_variables;
|
||||
|
||||
#define EXDLL_INIT() \
|
||||
{ \
|
||||
g_stringsize = string_size; \
|
||||
g_stacktop = stacktop; \
|
||||
g_variables = variables; \
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
INST_0, // $0
|
||||
INST_1, // $1
|
||||
INST_2, // $2
|
||||
INST_3, // $3
|
||||
INST_4, // $4
|
||||
INST_5, // $5
|
||||
INST_6, // $6
|
||||
INST_7, // $7
|
||||
INST_8, // $8
|
||||
INST_9, // $9
|
||||
INST_R0, // $R0
|
||||
INST_R1, // $R1
|
||||
INST_R2, // $R2
|
||||
INST_R3, // $R3
|
||||
INST_R4, // $R4
|
||||
INST_R5, // $R5
|
||||
INST_R6, // $R6
|
||||
INST_R7, // $R7
|
||||
INST_R8, // $R8
|
||||
INST_R9, // $R9
|
||||
INST_CMDLINE, // $CMDLINE
|
||||
INST_INSTDIR, // $INSTDIR
|
||||
INST_OUTDIR, // $OUTDIR
|
||||
INST_EXEDIR, // $EXEDIR
|
||||
INST_LANG, // $LANGUAGE
|
||||
__INST_LAST
|
||||
};
|
||||
|
||||
// utility functions (not required but often useful)
|
||||
static int UNUSED popstring(TCHAR *str)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop || !*g_stacktop)
|
||||
return 1;
|
||||
th = (*g_stacktop);
|
||||
lstrcpyn(str, th->text, (int)g_stringsize);
|
||||
*g_stacktop = th->next;
|
||||
GlobalFree((HGLOBAL)th);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void UNUSED pushstring(const TCHAR *str)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop)
|
||||
return;
|
||||
th = (stack_t *)GlobalAlloc(GPTR, (sizeof(stack_t) + (g_stringsize) * sizeof(TCHAR)));
|
||||
lstrcpyn(th->text, str, (int)g_stringsize);
|
||||
th->next = *g_stacktop;
|
||||
*g_stacktop = th;
|
||||
}
|
||||
|
||||
static TCHAR *UNUSED getuservariable(const int varnum)
|
||||
{
|
||||
if (varnum < 0 || varnum >= __INST_LAST)
|
||||
return NULL;
|
||||
return g_variables + varnum * g_stringsize;
|
||||
}
|
||||
|
||||
static void UNUSED setuservariable(const int varnum, const TCHAR *var)
|
||||
{
|
||||
if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
|
||||
lstrcpy(g_variables + varnum * g_stringsize, var);
|
||||
}
|
||||
|
||||
#endif //_EXDLL_H_
|
||||
@@ -0,0 +1,95 @@
|
||||
; Example script for nsisunz
|
||||
; Written by Saivert
|
||||
; Homepage: http://members.tripod.com/files_saivert/
|
||||
;
|
||||
; Dependencies:
|
||||
; - nsisunz.dll Plug-in
|
||||
; - InstallOptions.dll Plug-in
|
||||
; - zippage.ini (InstallOptions INI file)
|
||||
|
||||
!addplugindir ".\Release"
|
||||
|
||||
OutFile "nsisunz_test.exe"
|
||||
Name "NSIS Unzip plug-in test"
|
||||
Caption "NSIS Unzip plug-in test"
|
||||
ShowInstDetails show
|
||||
XPStyle on
|
||||
CompletedText "Extracted!"
|
||||
SubCaption 3 " - Extracting files"
|
||||
SubCaption 4 " - Extracted"
|
||||
|
||||
LoadLanguageFile "${NSISDIR}\Contrib\Language files\english.nlf"
|
||||
|
||||
; Installer pages
|
||||
Page custom onZipPageShow onZipPageLeave " - Select Zip file"
|
||||
Page instfiles
|
||||
|
||||
; Localized strings for use with nsisunz
|
||||
; The '%f' in the string is replaced with the filename on run-time.
|
||||
; "%c", "%u", "%p" and "%p" is replaced with compressed size,
|
||||
; uncompressed size, percent complete (with "%") and byte complete
|
||||
; respectively.
|
||||
LangString nsisunz_text ${LANG_ENGLISH} "Extract: %f (%c -> %b) [%p]"
|
||||
|
||||
Function .onInit
|
||||
InitPluginsDir
|
||||
File "/oname=$PLUGINSDIR\zippage.ini" "zippage.ini"
|
||||
FunctionEnd
|
||||
|
||||
Function onZipPageShow
|
||||
; Turn Text control into a button (HM NIS Edit v2.0b5 does not support "Button" type).
|
||||
WriteINIStr "$PLUGINSDIR\zippage.ini" "Field 12" "Type" "Button"
|
||||
WriteINIStr "$PLUGINSDIR\zippage.ini" "Field 12" "Flags" "NOTIFY"
|
||||
|
||||
InstallOptions::dialog "$PLUGINSDIR\zippage.ini"
|
||||
FunctionEnd
|
||||
|
||||
Function onZipPageLeave
|
||||
; $R0 = zip filename $R1 = dest. folder
|
||||
|
||||
ReadINIStr $R0 "$PLUGINSDIR\zippage.ini" "Field 4" "State"
|
||||
ReadINIStr $R1 "$PLUGINSDIR\zippage.ini" "Field 6" "State"
|
||||
|
||||
; Remove trailing backslash if any
|
||||
StrCpy $0 $R1 1 -1
|
||||
StrCmp "$0" "\" 0 notneeded
|
||||
StrCpy $R1 $R1 -1
|
||||
notneeded:
|
||||
|
||||
IfFileExists $R0 checkdir
|
||||
MessageBox MB_ICONEXCLAMATION|MB_OK 'The file "$R0" does not exist!'
|
||||
Abort ;return to page
|
||||
checkdir:
|
||||
IfFileExists $R1\*.* unzip
|
||||
MessageBox MB_ICONEXCLAMATION|MB_YESNO 'The folder "$R1" does not exist!$\r$\nDo you wish to create it?' IDNO skipcreate
|
||||
CreateDirectory $R1
|
||||
Goto unzip
|
||||
skipcreate:
|
||||
Abort ;return to page
|
||||
|
||||
unzip:
|
||||
; Just fall of the end, so the sections can be executed
|
||||
FunctionEnd
|
||||
|
||||
Section -pre
|
||||
DetailPrint "ZIP file: $R0"
|
||||
DetailPrint "Dest. folder: $R1"
|
||||
SectionEnd
|
||||
|
||||
Section
|
||||
; Check if the checkbox is checked and if it is, then don't extract paths
|
||||
ReadINIStr $R2 "$PLUGINSDIR\zippage.ini" "Field 7" "State"
|
||||
StrCmp $R2 "1" 0 usepaths
|
||||
nsisunz::UnzipToLog /text "$(nsisunz_text)" /noextractpath $R0 $R1
|
||||
Goto check
|
||||
usepaths:
|
||||
nsisunz::UnzipToLog /text "$(nsisunz_text)" $R0 $R1
|
||||
|
||||
check:
|
||||
; Always check for errors. Everything else than "success" means an error.
|
||||
Pop $0
|
||||
StrCmp $0 "success" ok
|
||||
Abort "$0"
|
||||
ok:
|
||||
SectionEnd
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
; Example script for nsisunz
|
||||
; Written by Saivert
|
||||
; Homepage: http://members.tripod.com/files_saivert/
|
||||
;
|
||||
; Dependencies:
|
||||
; - nsisunz.dll Plug-in
|
||||
; - InstallOptions.dll Plug-in
|
||||
; - zippage.ini (InstallOptions INI file)
|
||||
|
||||
!addplugindir ".\Release"
|
||||
|
||||
!include "MUI.nsh"
|
||||
|
||||
OutFile "nsisunz_testmui.exe"
|
||||
Name "NSIS Unzip plug-in test"
|
||||
Caption "NSIS Unzip plug-in test"
|
||||
ShowInstDetails show
|
||||
CompletedText "Extracted!"
|
||||
|
||||
; Installer pages
|
||||
Page custom onZipPageShow onZipPageLeave " "
|
||||
!define MUI_PAGE_HEADER_TEXT "Extracting"
|
||||
!define MUI_PAGE_HEADER_SUBTEXT "Extracting files"
|
||||
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Extracted"
|
||||
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "Thes files has been extracted"
|
||||
!define MUI_INSTFILESPAGE_ABORTHEADER_TEXT "Extraction aborted"
|
||||
!define MUI_INSTFILESPAGE_ABORTHEADER_SUBTEXT "The extraction process was aborted"
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
|
||||
; Localized strings for use with nsisunz
|
||||
; The '%f' in the string is replaced with the filename on run-time.
|
||||
; "%c" and "%u" is replaced with compressed size and uncompressed size
|
||||
; respectively.
|
||||
LangString nsisunz_text ${LANG_ENGLISH} "Extract: %f (%c -> %u)"
|
||||
|
||||
Function .onInit
|
||||
InitPluginsDir
|
||||
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "zippage.ini"
|
||||
FunctionEnd
|
||||
|
||||
Function onZipPageShow
|
||||
!insertmacro MUI_HEADER_TEXT "Unzip" "Select ZIP file and destination folder"
|
||||
|
||||
; Remove icon (so we get away with one INI file for both scripts)
|
||||
!insertmacro MUI_INSTALLOPTIONS_WRITE "zippage.ini" "Field 1" "Type" ""
|
||||
!insertmacro MUI_INSTALLOPTIONS_WRITE "zippage.ini" "Field 2" "Left" "0"
|
||||
|
||||
|
||||
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "zippage.ini"
|
||||
FunctionEnd
|
||||
|
||||
Function onZipPageLeave
|
||||
; $R0 = zip filename $R1 = dest. folder
|
||||
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "zippage.ini" "Field 4" "State"
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "zippage.ini" "Field 6" "State"
|
||||
|
||||
; Remove trailing backslash if any
|
||||
StrCpy $0 $R1 1 -1
|
||||
StrCmp "$0" "\" 0 notneeded
|
||||
StrCpy $R1 $R1 -1
|
||||
notneeded:
|
||||
|
||||
IfFileExists $R0 checkdir
|
||||
MessageBox MB_ICONEXCLAMATION|MB_OK 'The file "$R0" does not exist!'
|
||||
Abort ;return to page
|
||||
checkdir:
|
||||
IfFileExists $R1\*.* unzip
|
||||
MessageBox MB_ICONEXCLAMATION|MB_YESNO 'The folder "$R1" does not exist!$\r$\nDo you wish to create it?' IDNO skipcreate
|
||||
CreateDirectory $R1
|
||||
Goto unzip
|
||||
skipcreate:
|
||||
Abort ;return to page
|
||||
|
||||
unzip:
|
||||
; Just fall of the end, so the sections can be executed
|
||||
FunctionEnd
|
||||
|
||||
Section -pre
|
||||
DetailPrint "ZIP file: $R0"
|
||||
DetailPrint "Dest. folder: $R1"
|
||||
SectionEnd
|
||||
|
||||
Section
|
||||
; Check if the checkbox is checked and if it is, then don't extract paths
|
||||
ReadINIStr $R2 "$PLUGINSDIR\zippage.ini" "Field 7" "State"
|
||||
StrCmp $R2 "1" 0 usepaths
|
||||
nsisunz::UnzipToLog /text "$(nsisunz_text)" /noextractpath $R0 $R1
|
||||
Goto check
|
||||
usepaths:
|
||||
nsisunz::UnzipToLog /text "$(nsisunz_text)" $R0 $R1
|
||||
|
||||
check:
|
||||
; Always check for errors. Everything else than "success" means an error.
|
||||
Pop $0
|
||||
StrCmp $0 "success" ok
|
||||
Abort "$0"
|
||||
ok:
|
||||
SectionEnd
|
||||
Binary file not shown.
@@ -0,0 +1,146 @@
|
||||
# nsisunz NSIS Plugin - zlib 1.3.1
|
||||
|
||||
**Plugin NSIS per estrazione file ZIP con zlib 1.3.1**
|
||||
|
||||
Basato su [past-due/nsisunz](https://github.com/past-due/nsisunz) - Aggiornato da zlib 1.1.3 (1998) a zlib 1.3.1 (2023).
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Compilazione
|
||||
|
||||
**Visual Studio 2022:**
|
||||
```cmd
|
||||
cd nsUnz
|
||||
python build_plugin_zlib13_vs2022.py
|
||||
```
|
||||
|
||||
**Visual Studio 2026:**
|
||||
```cmd
|
||||
cd nsUnz
|
||||
python build_plugin_zlib13_vs2026.py
|
||||
```
|
||||
|
||||
I DLL compilati vengono copiati in `plugins/{platform}/nsisunz.dll`.
|
||||
|
||||
**Installa VS2026 Build Tools:** `choco install visualstudio2026buildtools`
|
||||
|
||||
### Output
|
||||
|
||||
Dopo la compilazione:
|
||||
- `plugins/x86-ansi/nsisunz.dll` (~124 KB)
|
||||
- `plugins/x86-unicode/nsisunz.dll` (~127-129 KB)
|
||||
- `plugins/amd64-unicode/nsisunz.dll` (~150-153 KB)
|
||||
|
||||
**Documentazione completa:** Vedi [BUILD_INFO.md](BUILD_INFO.md) per dettagli su VS2022/VS2026.
|
||||
|
||||
---
|
||||
|
||||
## Uso in NSIS
|
||||
|
||||
### UnzipToLog
|
||||
|
||||
Estrae i file e mostra il log dettagliato:
|
||||
|
||||
```nsis
|
||||
InitPluginsDir
|
||||
; Chiama il plugin. Prima il file ZIP, poi la cartella di destinazione.
|
||||
nsisunz::UnzipToLog "$PLUGINSDIR\myzipfile.zip" "$INSTDIR"
|
||||
|
||||
; Controlla sempre il risultato sullo stack
|
||||
Pop $0
|
||||
StrCmp $0 "success" ok
|
||||
DetailPrint "$0" ; stampa messaggio di errore nel log
|
||||
ok:
|
||||
```
|
||||
|
||||
### Unzip
|
||||
|
||||
Estrazione veloce senza log (preferita per archivi grandi):
|
||||
|
||||
```nsis
|
||||
nsisunz::Unzip "$PLUGINSDIR\myzipfile.zip" "$INSTDIR"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Caratteristiche Versione zlib 1.3.1
|
||||
|
||||
### Aggiornamenti principali
|
||||
|
||||
**zlib 1.1.3 (1998) → zlib 1.3.1 (2023):**
|
||||
- 25 anni di correzioni di sicurezza
|
||||
- Prestazioni decompressione migliorate del 20-30%
|
||||
- Supporto ZIP64 completo per archivi > 4GB
|
||||
- Minizip aggiornato dalla versione contrib/minizip di zlib 1.3.1
|
||||
|
||||
### File zlib inclusi
|
||||
|
||||
**Core decompressione:**
|
||||
- inflate.c/h, inftrees.c/h, inffast.c/h, inffixed.h
|
||||
|
||||
**Checksum:**
|
||||
- adler32.c, crc32.c/h
|
||||
|
||||
**Utilities:**
|
||||
- zutil.c/h, zconf.h, zlib.h
|
||||
|
||||
**Minizip:**
|
||||
- unzip.c/h, ioapi.c/h, iowin32.c/h, crypt.h
|
||||
|
||||
### Preprocessor Defines
|
||||
|
||||
- `NOCRYPT` - Disabilita supporto ZIP criptati
|
||||
- `Z_SOLO` - Disabilita funzioni gzip (riduce dipendenze)
|
||||
|
||||
---
|
||||
|
||||
## Progetti Visual Studio
|
||||
|
||||
### Visual Studio 2022 (v143)
|
||||
- File: `Source/nsisunz.vcxproj`
|
||||
- Script: `build_plugin.py`
|
||||
- Toolset: v143
|
||||
- Percorso: `C:\Program Files\Microsoft Visual Studio\2022\`
|
||||
|
||||
### Visual Studio 2026 (v145)
|
||||
- File: `Source/nsisunz_vs2026.vcxproj`
|
||||
- Script: `build_plugin_vs2026.py`
|
||||
- Toolset: v145
|
||||
- Percorso: `C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools`
|
||||
|
||||
### Configurazioni supportate
|
||||
|
||||
| Config | Configurazione VS | Piattaforma | Output |
|
||||
|--------|-------------------|-------------|--------|
|
||||
| x86-ansi | Release | Win32 | nsisunz.dll |
|
||||
| x86-unicode | Release Unicode | Win32 | nsisunz.dll |
|
||||
| x64-unicode | Release Unicode | x64 | nsisunz.dll |
|
||||
|
||||
---
|
||||
|
||||
## Credits e Licenza
|
||||
|
||||
**Credits:**
|
||||
- Originale: Saivert (http://saivert.com/)
|
||||
- Unicode support: Gringoloco023, 2010
|
||||
- Miglioramenti: past-due, 2018+
|
||||
- zlib 1.3.1 update: 2025
|
||||
|
||||
**Basato su:**
|
||||
- NSIS Zip2Exe - Copyright © 1999-2001 Miguel Garrido
|
||||
- [ZLIB](https://zlib.net) - Copyright © Mark Adler
|
||||
- MiniZip - Copyright © 1998-2010 Gilles Vollant
|
||||
|
||||
**Licenza:** [zlib License](https://en.wikipedia.org/wiki/Zlib_License)
|
||||
|
||||
---
|
||||
|
||||
## Documentazione
|
||||
|
||||
- **[BUILD_INFO.md](BUILD_INFO.md)** - Guida completa compilazione VS2022/VS2026
|
||||
- **[CHANGES.md](CHANGES.md)** - Changelog dettagliato zlib 1.1.3 → 1.3.1
|
||||
- **[COMPARISON_nsUnz_vs_nsUnz-zlib1.3.md](../COMPARISON_nsUnz_vs_nsUnz-zlib1.3.md)** - Confronto con versione originale
|
||||
|
||||
---
|
||||
|
||||
*Aggiornato: Dicembre 2025*
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
//////////////////////////////
|
||||
// Version 1.30
|
||||
// Nov 24th, 2000
|
||||
// Version 1.20
|
||||
// Jun 9th, 2000
|
||||
// Version 1.10
|
||||
// Jan 23rd, 2000
|
||||
// Version 1.00
|
||||
// May 20th, 1999
|
||||
// Todd C. Wilson, Fresh Ground Software
|
||||
// (todd@nopcode.com)
|
||||
// This header file will kick in settings for Visual C++ 5 and 6 that will (usually)
|
||||
// result in smaller exe's.
|
||||
// The "trick" is to tell the compiler to not pad out the function calls; this is done
|
||||
// by not using the /O1 or /O2 option - if you do, you implicitly use /Gy, which pads
|
||||
// out each and every function call. In one single 500k dll, I managed to cut out 120k
|
||||
// by this alone!
|
||||
// The other two "tricks" are telling the Linker to merge all data-type segments together
|
||||
// in the exe file. The relocation, read-only (constants) data, and code section (.text)
|
||||
// sections can almost always be merged. Each section merged can save 4k in exe space,
|
||||
// since each section is padded out to 4k chunks. This is very noticeable with smaller
|
||||
// exes, since you could have only 700 bytes of data, 300 bytes of code, 94 bytes of
|
||||
// strings - padded out, this could be 12k of runtime, for 1094 bytes of stuff! For larger
|
||||
// programs, this is less overall, but can save at least 4k.
|
||||
// Note that if you're using MFC static or some other 3rd party libs, you may get poor
|
||||
// results with merging the readonly (.rdata) section - the exe may grow larger.
|
||||
// To use this feature, define _MERGE_DATA_ in your project or before this header is used.
|
||||
// With Visual C++ 5, the program uses a file alignment of 512 bytes, which results
|
||||
// in a small exe. Under VC6, the program instead uses 4k, which is the same as the
|
||||
// section size. The reason (from what I understand) is that 4k is the chunk size of
|
||||
// the virtual memory manager, and that WinAlign (an end-user tuning tool for Win98)
|
||||
// will re-align the programs on this boundary. The problem with this is that all of
|
||||
// Microsoft's system exes and dlls are *NOT* tuned like this, and using 4k causes serious
|
||||
// exe bloat. Very noticeable for smaller programs.
|
||||
// The "trick" for this is to use the undocumented FILEALIGN linker parm to change the
|
||||
// padding from 4k to 1/2k, which results in a much smaller exe - anywhere from 20%-75%
|
||||
// depending on the size. Note that this is the same as using /OPT:NOWIN98, which *is*
|
||||
// a previously documented switch, but was left out of the docs for some reason in VC6 and
|
||||
// all of the current MSDN's - see KB:Q235956 for more information.
|
||||
// Microsoft does say that using the 4k alignment will "speed up process loading",
|
||||
// but I've been unable to notice a difference, even on my P180, with a very large (4meg) exe.
|
||||
// Please note, however, that this will probably not change the size of the COMPRESSED
|
||||
// file (either in a .zip file or in an install archive), since this 4k is all zeroes and
|
||||
// gets compressed away.
|
||||
// Also, the /ALIGN:4096 switch will "magically" do the same thing, even though this is the
|
||||
// default setting for this switch. Apparently this sets the same values as the above two
|
||||
// switches do. We do not use this in this header, since it smacks of a bug and not a feature.
|
||||
// Thanks to Michael Geary <Mike@Geary.com> for some additional tips!
|
||||
|
||||
#ifdef NDEBUG
|
||||
// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers)
|
||||
#pragma optimize("gsy",on)
|
||||
|
||||
#pragma comment(linker,"/RELEASE")
|
||||
|
||||
// Note that merging the .rdata section will result in LARGER exe's if you using
|
||||
// MFC (esp. static link). If this is desirable, define _MERGE_RDATA_ in your project.
|
||||
#ifdef _MERGE_RDATA_
|
||||
#pragma comment(linker,"/merge:.rdata=.data")
|
||||
#endif // _MERGE_RDATA_
|
||||
|
||||
#pragma comment(linker,"/merge:.text=.data")
|
||||
#pragma comment(linker,"/merge:.reloc=.data")
|
||||
|
||||
// Merging sections with different attributes causes a linker warning, so
|
||||
// turn off the warning. From Michael Geary. Undocumented, as usual!
|
||||
#pragma comment(linker,"/ignore:4078")
|
||||
|
||||
// With Visual C++ 5, you already get the 512-byte alignment, so you will only need
|
||||
// it for VC6, and maybe later.
|
||||
#if _MSC_VER >= 1000
|
||||
|
||||
// Option #1: use /filealign
|
||||
// Totally undocumented! And if you set it lower than 512 bytes, the program crashes.
|
||||
// Either leave at 0x200 or 0x1000
|
||||
//#pragma comment(linker,"/FILEALIGN:0x200")
|
||||
|
||||
// Option #2: use /opt:nowin98
|
||||
// See KB:Q235956 or the READMEVC.htm in your VC directory for info on this one.
|
||||
// This is our currently preferred option, since it is fully documented and unlikely
|
||||
// to break in service packs and updates.
|
||||
#pragma comment(linker,"/opt:nowin98")
|
||||
|
||||
// Option #3: use /align:4096
|
||||
// A side effect of using the default align value is that it turns on the above switch.
|
||||
// May break in future versions!
|
||||
//#pragma comment(linker,"/ALIGN:4096")
|
||||
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#endif // NDEBUG
|
||||
@@ -0,0 +1,593 @@
|
||||
// Unicode NSIS support by Gringoloco023, http://portableapps.com/node/21879, Februari 6 2010
|
||||
/*
|
||||
UnZip Plug-in for NSIS
|
||||
Written by Saivert
|
||||
|
||||
Credits:
|
||||
- Based on code in NSIS Zip2Exe
|
||||
portions Copyright © 1999-2001 Miguel Garrido (mgarrido01@hotmail.com)
|
||||
- Uses ZLIB - Copyright © Mark Adler
|
||||
- ZIP format routines - Copyright (C) 1998 Gilles Vollant
|
||||
|
||||
Even though this project is an NSIS Plug-in, it also
|
||||
exports a function that can be used by any applications.
|
||||
The exported function is "appextract"
|
||||
*/
|
||||
//#include "AggressiveOptimize.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <commctrl.h>
|
||||
#include "..\ExDLL\exdll.h"
|
||||
|
||||
//#include "exdll.h"
|
||||
|
||||
extern "C" {
|
||||
#include "zlib/unzip.h"
|
||||
};
|
||||
|
||||
//Strings used all over the place
|
||||
TCHAR szSuccess[] = {_T('s'),_T('u'),_T('c'),_T('c'),_T('e'),_T('s'),_T('s'),_T('\0')};
|
||||
TCHAR szFile[] = {_T('/'),_T('f'),_T('i'),_T('l'),_T('e'),_T('\0')};
|
||||
TCHAR szNoextractpath[] = {_T('/'),_T('n'),_T('o'),_T('e'),_T('x'),_T('t'),_T('r'),_T('a'),_T('c'),_T('t'),_T('p'),_T('a'),_T('t'),_T('h'),_T('\0')};
|
||||
TCHAR szDefExtractText[] = {_T('E'),_T('x'),_T('t'),_T('r'),_T('a'),_T('c'),_T('t'),_T(':'),_T(' '),_T('%'),_T('f'),_T('\0')};
|
||||
|
||||
TCHAR g_extract_text[1024];
|
||||
|
||||
int g_extracting;
|
||||
HWND g_hwndParent;
|
||||
TCHAR tempzip_path[1024];
|
||||
|
||||
void internal_unzip(int);
|
||||
|
||||
CRITICAL_SECTION cs;
|
||||
|
||||
//Log stuff
|
||||
HWND g_hwndList;
|
||||
HWND g_hwndStatus;
|
||||
void LogMessage(HWND, const TCHAR *, int = 0);
|
||||
|
||||
#ifdef UNICODE
|
||||
char * _T2A(wchar_t *str);
|
||||
wchar_t * _A2T(char *str);
|
||||
#define _tfopen_s _wfopen_s
|
||||
#else
|
||||
#define _T2A(x) (x)
|
||||
#define _A2T(x) (x)
|
||||
#define _tfopen_s fopen_s
|
||||
#endif
|
||||
|
||||
extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
//case DLL_THREAD_ATTACH:
|
||||
case DLL_PROCESS_ATTACH:
|
||||
InitializeCriticalSection(&cs);
|
||||
break;
|
||||
//case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
DeleteCriticalSection(&cs);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void doMKDir(TCHAR *directory)
|
||||
{
|
||||
TCHAR *p, *p2;
|
||||
TCHAR buf[MAX_PATH];
|
||||
if (!*directory) return;
|
||||
lstrcpy(buf,directory);
|
||||
p=buf; while (*p) p++;
|
||||
while (p >= buf && *p != _T('\\')) p--;
|
||||
p2 = buf;
|
||||
if (p2[1] == _T(':')) p2+=4;
|
||||
else if (p2[0] == _T('\\') && p2[1] == _T('\\'))
|
||||
{
|
||||
p2+=2;
|
||||
while (*p2 && *p2 != _T('\\')) p2++;
|
||||
if (*p2) p2++;
|
||||
while (*p2 && *p2 != _T('\\')) p2++;
|
||||
if (*p2) p2++;
|
||||
}
|
||||
if (p >= p2)
|
||||
{
|
||||
*p=0;
|
||||
doMKDir(buf);
|
||||
}
|
||||
CreateDirectory(directory,NULL);
|
||||
}
|
||||
|
||||
//Based on inttosizestr from NSIS exehead project.
|
||||
//Creates a string representing the size of a file,
|
||||
//choosing the unit that's best suited.
|
||||
static TCHAR * FormatDiskSize(TCHAR *str, unsigned long b)
|
||||
{
|
||||
TCHAR scale=_T('k');
|
||||
TCHAR sh=30;
|
||||
TCHAR s=0;
|
||||
|
||||
if (b <= (1024*1024) ) sh=10, scale=_T('k');
|
||||
else if (b <= (1024*1024*1024)) sh=20, scale=_T('M');
|
||||
else if (GetVersion()&0x80000000) s=_T('+'); //only display '+' on GB shown on Win95
|
||||
|
||||
if (b >= 1000) //represent everything above 1000 bytes as 0,xx kB
|
||||
{
|
||||
wsprintf(str, _T("%d.%d%d %cB%c"),
|
||||
b>>sh, ((b*10)>>sh)%10, ((b*20)>>sh)%10, scale, s);
|
||||
if (b < 1024)
|
||||
wsprintf(str+_tcsclen(str), _T(" (%u byte%c)"), b, b == 1?0:_T('s'));
|
||||
}
|
||||
else
|
||||
wsprintf(str, _T("%u byte%c"), b, b == 1?0:_T('s'));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/* A simple format parser
|
||||
* Handles %f, %c and %u
|
||||
* size of out must be twice as large as size of str
|
||||
*/
|
||||
static TCHAR * parse(const TCHAR *str, TCHAR *out, int outlen,
|
||||
TCHAR *filename,
|
||||
unsigned long compressed,
|
||||
unsigned long uncompressed,
|
||||
unsigned int nkb)
|
||||
{
|
||||
TCHAR s[32];
|
||||
const TCHAR *p;
|
||||
UINT i=0;
|
||||
p=str-1;
|
||||
memset(out, 0, outlen);
|
||||
|
||||
while (p++ && (*p != 0))
|
||||
{
|
||||
if (*p == _T('%'))
|
||||
{
|
||||
switch (*(p+1))
|
||||
{
|
||||
case _T('c'):
|
||||
case _T('C'):
|
||||
{
|
||||
FormatDiskSize(s, compressed);
|
||||
lstrcat(out, s);
|
||||
i += lstrlen(s);
|
||||
break;
|
||||
}
|
||||
case _T('u'):
|
||||
case _T('U'):
|
||||
{
|
||||
FormatDiskSize(s, uncompressed);
|
||||
lstrcat(out, s);
|
||||
i += lstrlen(s);
|
||||
break;
|
||||
}
|
||||
case _T('f'):
|
||||
case _T('F'):
|
||||
{
|
||||
lstrcat(out, filename);
|
||||
i += lstrlen(filename);
|
||||
break;
|
||||
}
|
||||
case _T('p'):
|
||||
case _T('P'):
|
||||
{
|
||||
unsigned int j;
|
||||
j = uncompressed;
|
||||
if (!j) j = 1;
|
||||
wsprintf(s, _T("%d%%"), nkb*100/j);
|
||||
lstrcat(out, s);
|
||||
i += lstrlen(s);
|
||||
break;
|
||||
}
|
||||
case _T('b'):
|
||||
case _T('B'):
|
||||
{
|
||||
FormatDiskSize(s, nkb);
|
||||
lstrcat(out, s);
|
||||
i += lstrlen(s);
|
||||
break;
|
||||
}
|
||||
default: out[i++] = *p;
|
||||
}
|
||||
++p;
|
||||
} else {
|
||||
out[i++] = *p;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
void Unzip(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||
{
|
||||
EXDLL_INIT();
|
||||
g_hwndParent = hwndParent;
|
||||
internal_unzip(0);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
void UnzipToLog(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||
{
|
||||
EXDLL_INIT();
|
||||
g_hwndParent = hwndParent;
|
||||
internal_unzip(1);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
void UnzipToStack(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||
{
|
||||
EXDLL_INIT();
|
||||
g_hwndParent = hwndParent;
|
||||
internal_unzip(2);
|
||||
}
|
||||
|
||||
// This function is to be used by rundll32.exe. Call it like this:
|
||||
//
|
||||
// rundll32.exe "c:\a path\nsisunz.dll",extract_RunDLL c:\path\zipfile.zip c:\outdir
|
||||
//
|
||||
// or to extract a single file, use this (concatenate the next two lines):
|
||||
//
|
||||
// rundll32.exe c:\path\nsisunz.dll,extract_RunDLL
|
||||
// /file readme.txt "c:\a path\zipfile.zip" c:\outdir
|
||||
//
|
||||
// "/noextractpath" is implicitly used if "/file" is used.
|
||||
// It mimics NSIS itself by setting up a stack and pushing the
|
||||
// parameters from the function on the stack. I made it like this
|
||||
// so I could directly reuse the code I already had written without modifications.
|
||||
extern "C" __declspec(dllexport)
|
||||
void extract_RunDLL(HINSTANCE hAppInstance, LPVOID unused, TCHAR *params)
|
||||
{
|
||||
TCHAR res[1024];
|
||||
TCHAR temp[256];
|
||||
TCHAR zipfile[MAX_PATH]={0,};
|
||||
TCHAR destdir[MAX_PATH]={0,};
|
||||
TCHAR file[MAX_PATH]={0,};
|
||||
TCHAR *p = params;
|
||||
TCHAR *s;
|
||||
TCHAR q=0;
|
||||
int next=0;
|
||||
#define NEXT_FILE 1
|
||||
#define NEXT_ZIP 2
|
||||
#define NEXT_DEST 3
|
||||
|
||||
stack_t ownstacktop;
|
||||
stack_t *pownstacktop = &ownstacktop;
|
||||
|
||||
ownstacktop.next = NULL;
|
||||
ownstacktop.text[0] = NULL;
|
||||
|
||||
g_stringsize=1024;
|
||||
g_stacktop=&pownstacktop;
|
||||
g_variables=NULL;
|
||||
|
||||
//Parse the parameters
|
||||
//While we do the parsing we use next as a clue to
|
||||
//what comes next. This way I don't have to write a
|
||||
//new function.
|
||||
while (*p)
|
||||
{
|
||||
if (*p==_T('"')) q=_T('"'), p++; else q=_T(' '); //Do we search for a quote or a space?
|
||||
s = temp;
|
||||
while (*p && *p != q) *s++ = *p++; //Copy chars from params to zipfile
|
||||
*s = 0; //Terminate string
|
||||
if (next==NEXT_FILE) lstrcpy(file, temp), next=NEXT_ZIP;
|
||||
else if (next==NEXT_ZIP) lstrcpy(zipfile, temp), next=NEXT_DEST;
|
||||
else if (next==NEXT_DEST) lstrcpy(destdir, temp), next=0;
|
||||
else if (!lstrcmpi(temp, szFile)) next=NEXT_FILE;
|
||||
else lstrcpy(zipfile, temp), next=NEXT_DEST;
|
||||
|
||||
while (*p && *++p == _T(' '));
|
||||
}
|
||||
|
||||
pushstring(destdir);
|
||||
pushstring(zipfile);
|
||||
|
||||
if (file[0])
|
||||
{
|
||||
pushstring(file);
|
||||
pushstring(szFile);
|
||||
pushstring(szNoextractpath);
|
||||
}
|
||||
|
||||
internal_unzip(0);
|
||||
popstring(res);
|
||||
if (lstrcmp(res, szSuccess))
|
||||
MessageBox(0, res, NULL, MB_ICONERROR);
|
||||
}
|
||||
|
||||
void internal_unzip(int uselog)
|
||||
{
|
||||
//All char baby (or should I use int for the non-string stuff??)
|
||||
TCHAR first=0;
|
||||
TCHAR filefound=0;
|
||||
TCHAR usefile=0;
|
||||
TCHAR hastext=0;
|
||||
TCHAR noextractpath=0;
|
||||
TCHAR filetoextract[MAX_PATH+1];
|
||||
TCHAR buf[1024];
|
||||
TCHAR fn[MAX_PATH+1];
|
||||
|
||||
popstring(buf);
|
||||
while (buf[0] == _T('/'))
|
||||
{
|
||||
if (!lstrcmpi(buf+1, _T("text"))) popstring(g_extract_text), hastext++;
|
||||
if (!lstrcmpi(buf+1, _T("noextractpath"))) noextractpath++;
|
||||
if (!lstrcmpi(buf+1, _T("file")))
|
||||
{
|
||||
TCHAR *p;
|
||||
popstring(filetoextract);
|
||||
// Ensure filename uses backslashes
|
||||
p = filetoextract;
|
||||
while (*p)
|
||||
{
|
||||
if (*p == _T('/')) *p=_T('\\');
|
||||
p++;
|
||||
}
|
||||
usefile++;
|
||||
}
|
||||
|
||||
//if stack is empty, bail out
|
||||
if (popstring(buf))
|
||||
*buf = 0;
|
||||
}
|
||||
//check for first required param
|
||||
if (*buf)
|
||||
lstrcpyn(fn, buf, MAX_PATH);
|
||||
else
|
||||
{
|
||||
pushstring(_T("Error reading ZIP filename parameter"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (popstring(tempzip_path))
|
||||
{
|
||||
pushstring(_T("Error reading destination directory parameter"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (uselog==1)
|
||||
{
|
||||
if (!hastext) lstrcpy(g_extract_text, szDefExtractText);
|
||||
}
|
||||
|
||||
unzFile f;
|
||||
f = unzOpen(_T2A(fn));
|
||||
if (!f || unzGoToFirstFile(f) != UNZ_OK)
|
||||
{
|
||||
if (f) unzClose(f);
|
||||
pushstring(_T("Error opening ZIP file"));
|
||||
return;
|
||||
}
|
||||
|
||||
int nf=0, nb=0;
|
||||
unz_file_info fileinfo;
|
||||
g_extracting=1;
|
||||
do {
|
||||
char filenameA[MAX_PATH];
|
||||
TCHAR filename[MAX_PATH];
|
||||
unzGetCurrentFileInfo(f,&fileinfo,filenameA,sizeof(filename),NULL,0,NULL,0);
|
||||
lstrcpyn(filename, _A2T(filenameA), MAX_PATH);
|
||||
|
||||
if (filename[0] &&
|
||||
filename[_tcsclen(filename)-1] != _T('\\') &&
|
||||
filename[_tcsclen(filename)-1] != _T('/'))
|
||||
{
|
||||
TCHAR *pfn=filename;
|
||||
//ensure path uses backslashes
|
||||
while (*pfn)
|
||||
{
|
||||
if (*pfn == _T('/')) *pfn=_T('\\');
|
||||
pfn++;
|
||||
}
|
||||
|
||||
if (usefile)
|
||||
{
|
||||
if (lstrcmpi(filename, filetoextract) != 0) continue;
|
||||
else filefound++;
|
||||
}
|
||||
|
||||
pfn=filename;
|
||||
if (pfn[1] == _T(':') && pfn[2] == _T('\\')) pfn+=3;
|
||||
while (*pfn == _T('\\')) pfn++;
|
||||
|
||||
if (noextractpath)
|
||||
{
|
||||
TCHAR buf[MAX_PATH];
|
||||
lstrcpy(buf,filename);
|
||||
TCHAR *p=buf+_tcsclen(buf);
|
||||
while (p > buf && *p != _T('\\') && *p != _T('/')) p = CharPrev(buf, p);
|
||||
if (p > buf) p++;
|
||||
lstrcpy(filename, p);
|
||||
}
|
||||
|
||||
TCHAR out_filename[1024];
|
||||
lstrcpy(out_filename,tempzip_path);
|
||||
lstrcat(out_filename,_T("\\"));
|
||||
lstrcat(out_filename,pfn);
|
||||
if (_tcsstr(pfn,_T("\\")))
|
||||
{
|
||||
TCHAR buf[1024];
|
||||
lstrcpy(buf,out_filename);
|
||||
TCHAR *p=buf+_tcsclen(buf);
|
||||
while (p > buf && *p != _T('\\')) p--;
|
||||
*p=0;
|
||||
if (buf[0]) doMKDir(buf);
|
||||
}
|
||||
|
||||
if (unzOpenCurrentFile(f) == UNZ_OK)
|
||||
{
|
||||
FILE *fp;
|
||||
int l;
|
||||
fp = _tfopen(out_filename,_T("wb"));
|
||||
if (fp)
|
||||
{
|
||||
if (uselog==1) {
|
||||
TCHAR logtmp[256];
|
||||
parse(g_extract_text, logtmp, sizeof(logtmp),
|
||||
pfn, fileinfo.compressed_size, fileinfo.uncompressed_size, 0);
|
||||
LogMessage(g_hwndParent, logtmp);
|
||||
} else if (uselog == 2) {
|
||||
if (!first)
|
||||
{
|
||||
pushstring(_T("")); //push list terminator (empty string)
|
||||
first++;
|
||||
}
|
||||
pushstring(pfn);
|
||||
}
|
||||
nb=0;
|
||||
do
|
||||
{
|
||||
TCHAR buf[1024];
|
||||
l=unzReadCurrentFile(f,buf,sizeof(buf));
|
||||
if (l > 0)
|
||||
{
|
||||
if (fwrite(buf,1,l,fp) != (unsigned int)l)
|
||||
{
|
||||
unzClose(f);
|
||||
fclose(fp);
|
||||
pushstring(_T("Error writing output file(s)"));
|
||||
g_extracting=0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_extracting)
|
||||
{
|
||||
unzClose(f);
|
||||
fclose(fp);
|
||||
g_extracting=0;
|
||||
pushstring(_T("aborted"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (uselog==1 && (nb % 1024))
|
||||
{
|
||||
TCHAR logtmp[256];
|
||||
parse(g_extract_text, logtmp, sizeof(logtmp),
|
||||
pfn, fileinfo.compressed_size,
|
||||
fileinfo.uncompressed_size, nb);
|
||||
LogMessage(g_hwndParent, logtmp, 1);
|
||||
}
|
||||
nb += l;
|
||||
} while (l > 0);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
unzClose(f);
|
||||
pushstring(_T("Error opening output file(s)"));
|
||||
g_extracting=0;
|
||||
return;
|
||||
}
|
||||
nf++;
|
||||
|
||||
int quit=0;
|
||||
if (g_hwndParent)
|
||||
{
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
|
||||
{
|
||||
if (msg.message == WM_DESTROY && msg.hwnd == g_hwndParent)
|
||||
{
|
||||
quit++;
|
||||
break;
|
||||
}
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
unzCloseCurrentFile(f);
|
||||
if (quit) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
unzClose(f);
|
||||
pushstring(_T("Error extracting from ZIP file"));
|
||||
g_extracting=0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} while (unzGoToNextFile(f) == UNZ_OK);
|
||||
|
||||
g_extracting=0;
|
||||
if (usefile && !filefound) {
|
||||
pushstring(_T("File not found in archive"));
|
||||
} else {
|
||||
pushstring(szSuccess);
|
||||
}
|
||||
unzClose(f);
|
||||
return;
|
||||
}
|
||||
|
||||
// Tim Kosse's LogMessage
|
||||
void LogMessage(HWND hwndParent, const TCHAR *pStr, int changelast) {
|
||||
static HWND hwndList=0;
|
||||
static HWND hwndStatus=0;
|
||||
LVITEM item={0};
|
||||
int nItemCount;
|
||||
if (!hwndParent) return;
|
||||
|
||||
EnterCriticalSection(&cs);
|
||||
|
||||
//Get ListView control on instfiles page (the log)
|
||||
if (!hwndList) hwndList = FindWindowEx(
|
||||
FindWindowEx(hwndParent, NULL, _T("#32770"), NULL),
|
||||
NULL, _T("SysListView32"), NULL);
|
||||
|
||||
//Get status "STATIC" control above progressbar
|
||||
if (!hwndStatus) hwndStatus = GetDlgItem(
|
||||
FindWindowEx(hwndParent, NULL, _T("#32770"), NULL),
|
||||
1006);
|
||||
|
||||
if (!hwndList || !hwndStatus) return;
|
||||
|
||||
SendMessage(hwndStatus, WM_SETTEXT, 0, (LPARAM)pStr);//added by Saivert
|
||||
nItemCount=SendMessage(hwndList, LVM_GETITEMCOUNT, 0, 0);
|
||||
|
||||
item.mask=LVIF_TEXT;
|
||||
item.pszText=(TCHAR *)pStr;
|
||||
item.cchTextMax=0;
|
||||
item.iItem=changelast?nItemCount-1:nItemCount;
|
||||
|
||||
if (changelast) {
|
||||
ListView_SetItem(hwndList, &item);
|
||||
} else {
|
||||
ListView_InsertItem(hwndList, &item);
|
||||
}
|
||||
ListView_EnsureVisible(hwndList, item.iItem, 0);
|
||||
|
||||
LeaveCriticalSection(&cs);
|
||||
}
|
||||
|
||||
// EXPERIMENTAL THREAD BASED EXTRACTION
|
||||
/*
|
||||
extern "C" __declspec(dllexport)
|
||||
UnzipToLogUsingThread(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
||||
{
|
||||
MSG msg;
|
||||
DWORD dwTID;
|
||||
|
||||
CreateThread(NULL, 0, UnzipThread, (LPVOID)1, 0, &dwTID);
|
||||
}
|
||||
|
||||
DWORD WINAPI UnzipThread(LPVOID p)
|
||||
{
|
||||
int uselog = 1;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
#ifdef UNICODE
|
||||
unsigned char staticCnvBuffer[1024*sizeof(TCHAR)]; /* temp buffer, holds ASCII & UNICODE string after conversion */
|
||||
char * _T2A(wchar_t *wideStr)
|
||||
{
|
||||
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, (LPSTR)staticCnvBuffer, sizeof(staticCnvBuffer), NULL, NULL);
|
||||
return (char *)staticCnvBuffer;
|
||||
}
|
||||
wchar_t * _A2T(char *ansiStr)
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, (TCHAR *)staticCnvBuffer, sizeof(staticCnvBuffer)/sizeof(TCHAR));
|
||||
return (wchar_t *)staticCnvBuffer;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
LIBRARY nsisunz
|
||||
EXPORTS
|
||||
Unzip
|
||||
UnzipToLog
|
||||
UnzipToStack
|
||||
@@ -0,0 +1,527 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="nsisunz"
|
||||
ProjectGUID="{8534CD66-1841-45FC-9201-FA3515F5967B}"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/nsisunz.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;UNZIP_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/nsisunz.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1044"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Debug/nsisunz.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/nsisunz.pdb"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary=".\Debug/nsisunz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/nsisunz.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UNZIP_EXPORTS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/nsisunz.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1044"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="pluginapi.lib"
|
||||
OutputFile=".\Release/nsisunz.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
ProgramDatabaseFile=".\Release/nsisunz.pdb"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary=".\Release/nsisunz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath="zlib\ADLER32.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\CRC32.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFBLOCK.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFCODES.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFFAST.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFLATE.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFTREES.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFUTIL.C"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="nsisunz.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\Unzip.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\Zutil.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UNZIP_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath="zlib\INFBLOCK.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFCODES.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFFAST.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFFIXED.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFTREES.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\INFUTIL.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\UNZIP.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\ZCONF.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\ZLIB.H"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="zlib\ZUTIL.H"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,220 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release Unicode|Win32">
|
||||
<Configuration>Release Unicode</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release Unicode|x64">
|
||||
<Configuration>Release Unicode</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}</ProjectGuid>
|
||||
<RootNamespace>nsisunz</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'"
|
||||
Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'"
|
||||
Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
|
||||
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
|
||||
Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>nsisunz</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'">
|
||||
<OutDir>Build\x86-unicode\</OutDir>
|
||||
<IntDir>Build\x86-unicode\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'">
|
||||
<OutDir>Build\x64-unicode\</OutDir>
|
||||
<IntDir>Build\x64-unicode\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>Build\x86-ansi\</OutDir>
|
||||
<IntDir>Build\x86-ansi\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>Build\x64-ansi\</OutDir>
|
||||
<IntDir>Build\x64-ansi\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;UNICODE;_UNICODE;NOCRYPT;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;UNICODE;_UNICODE;NOCRYPT;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;NOCRYPT;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;NOCRYPT;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="nsisunz.cpp" />
|
||||
<ClCompile Include="zlib\adler32.c" />
|
||||
<ClCompile Include="zlib\crc32.c" />
|
||||
<ClCompile Include="zlib\inffast.c" />
|
||||
<ClCompile Include="zlib\inflate.c" />
|
||||
<ClCompile Include="zlib\inftrees.c" />
|
||||
<ClCompile Include="zlib\ioapi.c" />
|
||||
<ClCompile Include="zlib\iowin32.c" />
|
||||
<ClCompile Include="zlib\unzip.c" />
|
||||
<ClCompile Include="zlib\zutil.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\ExDLL\exdll.h" />
|
||||
<ClInclude Include="AggressiveOptimize.h" />
|
||||
<ClInclude Include="zlib\crc32.h" />
|
||||
<ClInclude Include="zlib\crypt.h" />
|
||||
<ClInclude Include="zlib\inffast.h" />
|
||||
<ClInclude Include="zlib\inffixed.h" />
|
||||
<ClInclude Include="zlib\inflate.h" />
|
||||
<ClInclude Include="zlib\inftrees.h" />
|
||||
<ClInclude Include="zlib\ioapi.h" />
|
||||
<ClInclude Include="zlib\iowin32.h" />
|
||||
<ClInclude Include="zlib\unzip.h" />
|
||||
<ClInclude Include="zlib\zconf.h" />
|
||||
<ClInclude Include="zlib\zlib.h" />
|
||||
<ClInclude Include="zlib\zutil.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="nsisunz.def" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,220 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release Unicode|Win32">
|
||||
<Configuration>Release Unicode</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release Unicode|x64">
|
||||
<Configuration>Release Unicode</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}</ProjectGuid>
|
||||
<RootNamespace>nsisunz</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'"
|
||||
Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'"
|
||||
Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
|
||||
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
|
||||
Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>nsisunz</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'">
|
||||
<OutDir>Build\x86-unicode\</OutDir>
|
||||
<IntDir>Build\x86-unicode\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'">
|
||||
<OutDir>Build\x64-unicode\</OutDir>
|
||||
<IntDir>Build\x64-unicode\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>Build\x86-ansi\</OutDir>
|
||||
<IntDir>Build\x86-ansi\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>Build\x64-ansi\</OutDir>
|
||||
<IntDir>Build\x64-ansi\obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;UNICODE;_UNICODE;NOCRYPT;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;UNICODE;_UNICODE;NOCRYPT;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;NOCRYPT;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>
|
||||
WIN32;NDEBUG;_WINDOWS;_USRDLL;NSISUNZ_EXPORTS;NOCRYPT;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DisableSpecificWarnings>4996;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>..\.ExDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>false</DataExecutionPrevention>
|
||||
<ModuleDefinitionFile>nsisunz.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="nsisunz.cpp" />
|
||||
<ClCompile Include="zlib\adler32.c" />
|
||||
<ClCompile Include="zlib\crc32.c" />
|
||||
<ClCompile Include="zlib\inffast.c" />
|
||||
<ClCompile Include="zlib\inflate.c" />
|
||||
<ClCompile Include="zlib\inftrees.c" />
|
||||
<ClCompile Include="zlib\ioapi.c" />
|
||||
<ClCompile Include="zlib\iowin32.c" />
|
||||
<ClCompile Include="zlib\unzip.c" />
|
||||
<ClCompile Include="zlib\zutil.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\ExDLL\exdll.h" />
|
||||
<ClInclude Include="AggressiveOptimize.h" />
|
||||
<ClInclude Include="zlib\crc32.h" />
|
||||
<ClInclude Include="zlib\crypt.h" />
|
||||
<ClInclude Include="zlib\inffast.h" />
|
||||
<ClInclude Include="zlib\inffixed.h" />
|
||||
<ClInclude Include="zlib\inflate.h" />
|
||||
<ClInclude Include="zlib\inftrees.h" />
|
||||
<ClInclude Include="zlib\ioapi.h" />
|
||||
<ClInclude Include="zlib\iowin32.h" />
|
||||
<ClInclude Include="zlib\unzip.h" />
|
||||
<ClInclude Include="zlib\zconf.h" />
|
||||
<ClInclude Include="zlib\zlib.h" />
|
||||
<ClInclude Include="zlib\zutil.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="nsisunz.def" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,164 @@
|
||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||
* Copyright (C) 1995-2011, 2016 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#include "zutil.h"
|
||||
|
||||
#define BASE 65521U /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||
|
||||
/* use NO_DIVIDE if your processor does not do division in hardware --
|
||||
try it both ways to see which is faster */
|
||||
#ifdef NO_DIVIDE
|
||||
/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
|
||||
(thank you to John Reiser for pointing this out) */
|
||||
# define CHOP(a) \
|
||||
do { \
|
||||
unsigned long tmp = a >> 16; \
|
||||
a &= 0xffffUL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
} while (0)
|
||||
# define MOD28(a) \
|
||||
do { \
|
||||
CHOP(a); \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
# define MOD(a) \
|
||||
do { \
|
||||
CHOP(a); \
|
||||
MOD28(a); \
|
||||
} while (0)
|
||||
# define MOD63(a) \
|
||||
do { /* this assumes a is not negative */ \
|
||||
z_off64_t tmp = a >> 32; \
|
||||
a &= 0xffffffffL; \
|
||||
a += (tmp << 8) - (tmp << 5) + tmp; \
|
||||
tmp = a >> 16; \
|
||||
a &= 0xffffL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
tmp = a >> 16; \
|
||||
a &= 0xffffL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
#else
|
||||
# define MOD(a) a %= BASE
|
||||
# define MOD28(a) a %= BASE
|
||||
# define MOD63(a) a %= BASE
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
|
||||
unsigned long sum2;
|
||||
unsigned n;
|
||||
|
||||
/* split Adler-32 into component sums */
|
||||
sum2 = (adler >> 16) & 0xffff;
|
||||
adler &= 0xffff;
|
||||
|
||||
/* in case user likes doing a byte at a time, keep it fast */
|
||||
if (len == 1) {
|
||||
adler += buf[0];
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
sum2 += adler;
|
||||
if (sum2 >= BASE)
|
||||
sum2 -= BASE;
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
||||
if (buf == Z_NULL)
|
||||
return 1L;
|
||||
|
||||
/* in case short lengths are provided, keep it somewhat fast */
|
||||
if (len < 16) {
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
MOD28(sum2); /* only added so many BASE's */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* do length NMAX blocks -- requires just one modulo operation */
|
||||
while (len >= NMAX) {
|
||||
len -= NMAX;
|
||||
n = NMAX / 16; /* NMAX is divisible by 16 */
|
||||
do {
|
||||
DO16(buf); /* 16 sums unrolled */
|
||||
buf += 16;
|
||||
} while (--n);
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* do remaining bytes (less than NMAX, still just one modulo) */
|
||||
if (len) { /* avoid modulos if none remaining */
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
DO16(buf);
|
||||
buf += 16;
|
||||
}
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* return recombined sums */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
|
||||
return adler32_z(adler, buf, len);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||
unsigned long sum1;
|
||||
unsigned long sum2;
|
||||
unsigned rem;
|
||||
|
||||
/* for negative len, return invalid adler32 as a clue for debugging */
|
||||
if (len2 < 0)
|
||||
return 0xffffffffUL;
|
||||
|
||||
/* the derivation of this formula is left as an exercise for the reader */
|
||||
MOD63(len2); /* assumes len2 >= 0 */
|
||||
rem = (unsigned)len2;
|
||||
sum1 = adler1 & 0xffff;
|
||||
sum2 = rem * sum1;
|
||||
MOD(sum2);
|
||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
||||
if (sum1 >= BASE) sum1 -= BASE;
|
||||
if (sum1 >= BASE) sum1 -= BASE;
|
||||
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
|
||||
if (sum2 >= BASE) sum2 -= BASE;
|
||||
return sum1 | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
|
||||
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,128 @@
|
||||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
The encryption/decryption parts of this source code (as opposed to the
|
||||
non-echoing password parts) were originally written in Europe. The
|
||||
whole source package can be freely distributed, including from the USA.
|
||||
(Prior to January 2000, re-export from the US was a violation of US law.)
|
||||
|
||||
This encryption code is a direct transcription of the algorithm from
|
||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||
file (appnote.txt) is distributed with the PKZIP program (even in the
|
||||
version without encryption capabilities).
|
||||
|
||||
If you don't need crypting in your application, just define symbols
|
||||
NOCRYPT and NOUNCRYPT.
|
||||
|
||||
This code support the "Traditional PKWARE Encryption".
|
||||
|
||||
The new AES encryption added on Zip format by Winzip (see the page
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
* with any known compiler so far, though */
|
||||
|
||||
(void)pcrc_32_tab;
|
||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
|
||||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
||||
{
|
||||
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
||||
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
|
||||
*(pkeys+0) = 305419896L;
|
||||
*(pkeys+1) = 591751049L;
|
||||
*(pkeys+2) = 878082192L;
|
||||
while (*passwd != '\0') {
|
||||
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
|
||||
passwd++;
|
||||
}
|
||||
}
|
||||
|
||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||
|
||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))
|
||||
|
||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||
|
||||
#define RAND_HEAD_LEN 12
|
||||
/* "last resort" source for second part of crypt seed pattern */
|
||||
# ifndef ZCR_SEED2
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# endif
|
||||
|
||||
static unsigned crypthead(const char* passwd, /* password string */
|
||||
unsigned char* buf, /* where to write header */
|
||||
int bufSize,
|
||||
unsigned long* pkeys,
|
||||
const z_crc_t* pcrc_32_tab,
|
||||
unsigned long crcForCrypting) {
|
||||
unsigned n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
int c; /* random byte */
|
||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||
static unsigned calls = 0; /* ensure different random header each time */
|
||||
|
||||
if (bufSize<RAND_HEAD_LEN)
|
||||
return 0;
|
||||
|
||||
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
||||
* output of rand() to get less predictability, since rand() is
|
||||
* often poorly implemented.
|
||||
*/
|
||||
if (++calls == 1)
|
||||
{
|
||||
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
||||
}
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
c = (rand() >> 7) & 0xff;
|
||||
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
||||
}
|
||||
/* Encrypt random header (last two bytes is high word of crc) */
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
||||
}
|
||||
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,320 @@
|
||||
/* inffast.c -- fast decoding
|
||||
* Copyright (C) 1995-2017 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
#include "inflate.h"
|
||||
#include "inffast.h"
|
||||
|
||||
#ifdef ASMINF
|
||||
# pragma message("Assembler code may have bugs -- use at your own risk")
|
||||
#else
|
||||
|
||||
/*
|
||||
Decode literal, length, and distance codes and write out the resulting
|
||||
literal and match bytes until either not enough input or output is
|
||||
available, an end-of-block is encountered, or a data error is encountered.
|
||||
When large enough input and output buffers are supplied to inflate(), for
|
||||
example, a 16K input buffer and a 64K output buffer, more than 95% of the
|
||||
inflate execution time is spent in this routine.
|
||||
|
||||
Entry assumptions:
|
||||
|
||||
state->mode == LEN
|
||||
strm->avail_in >= 6
|
||||
strm->avail_out >= 258
|
||||
start >= strm->avail_out
|
||||
state->bits < 8
|
||||
|
||||
On return, state->mode is one of:
|
||||
|
||||
LEN -- ran out of enough output space or enough available input
|
||||
TYPE -- reached end of block code, inflate() to interpret next block
|
||||
BAD -- error in block data
|
||||
|
||||
Notes:
|
||||
|
||||
- The maximum input bits used by a length/distance pair is 15 bits for the
|
||||
length code, 5 bits for the length extra, 15 bits for the distance code,
|
||||
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
|
||||
Therefore if strm->avail_in >= 6, then there is enough input to avoid
|
||||
checking for available input while decoding.
|
||||
|
||||
- The maximum bytes that a single length/distance pair can output is 258
|
||||
bytes, which is the maximum length that can be coded. inflate_fast()
|
||||
requires strm->avail_out >= 258 for each loop to avoid checking for
|
||||
output space.
|
||||
*/
|
||||
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
|
||||
struct inflate_state FAR *state;
|
||||
z_const unsigned char FAR *in; /* local strm->next_in */
|
||||
z_const unsigned char FAR *last; /* have enough input while in < last */
|
||||
unsigned char FAR *out; /* local strm->next_out */
|
||||
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
|
||||
unsigned char FAR *end; /* while out < end, enough space available */
|
||||
#ifdef INFLATE_STRICT
|
||||
unsigned dmax; /* maximum distance from zlib header */
|
||||
#endif
|
||||
unsigned wsize; /* window size or zero if not using window */
|
||||
unsigned whave; /* valid bytes in the window */
|
||||
unsigned wnext; /* window write index */
|
||||
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
|
||||
unsigned long hold; /* local strm->hold */
|
||||
unsigned bits; /* local strm->bits */
|
||||
code const FAR *lcode; /* local strm->lencode */
|
||||
code const FAR *dcode; /* local strm->distcode */
|
||||
unsigned lmask; /* mask for first level of length codes */
|
||||
unsigned dmask; /* mask for first level of distance codes */
|
||||
code const *here; /* retrieved table entry */
|
||||
unsigned op; /* code bits, operation, extra bits, or */
|
||||
/* window position, window bytes to copy */
|
||||
unsigned len; /* match length, unused bytes */
|
||||
unsigned dist; /* match distance */
|
||||
unsigned char FAR *from; /* where to copy match from */
|
||||
|
||||
/* copy state to local variables */
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
in = strm->next_in;
|
||||
last = in + (strm->avail_in - 5);
|
||||
out = strm->next_out;
|
||||
beg = out - (start - strm->avail_out);
|
||||
end = out + (strm->avail_out - 257);
|
||||
#ifdef INFLATE_STRICT
|
||||
dmax = state->dmax;
|
||||
#endif
|
||||
wsize = state->wsize;
|
||||
whave = state->whave;
|
||||
wnext = state->wnext;
|
||||
window = state->window;
|
||||
hold = state->hold;
|
||||
bits = state->bits;
|
||||
lcode = state->lencode;
|
||||
dcode = state->distcode;
|
||||
lmask = (1U << state->lenbits) - 1;
|
||||
dmask = (1U << state->distbits) - 1;
|
||||
|
||||
/* decode literals and length/distances until end-of-block or not enough
|
||||
input data or output space */
|
||||
do {
|
||||
if (bits < 15) {
|
||||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
}
|
||||
here = lcode + (hold & lmask);
|
||||
dolen:
|
||||
op = (unsigned)(here->bits);
|
||||
hold >>= op;
|
||||
bits -= op;
|
||||
op = (unsigned)(here->op);
|
||||
if (op == 0) { /* literal */
|
||||
Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
|
||||
"inflate: literal '%c'\n" :
|
||||
"inflate: literal 0x%02x\n", here->val));
|
||||
*out++ = (unsigned char)(here->val);
|
||||
}
|
||||
else if (op & 16) { /* length base */
|
||||
len = (unsigned)(here->val);
|
||||
op &= 15; /* number of extra bits */
|
||||
if (op) {
|
||||
if (bits < op) {
|
||||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
}
|
||||
len += (unsigned)hold & ((1U << op) - 1);
|
||||
hold >>= op;
|
||||
bits -= op;
|
||||
}
|
||||
Tracevv((stderr, "inflate: length %u\n", len));
|
||||
if (bits < 15) {
|
||||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
}
|
||||
here = dcode + (hold & dmask);
|
||||
dodist:
|
||||
op = (unsigned)(here->bits);
|
||||
hold >>= op;
|
||||
bits -= op;
|
||||
op = (unsigned)(here->op);
|
||||
if (op & 16) { /* distance base */
|
||||
dist = (unsigned)(here->val);
|
||||
op &= 15; /* number of extra bits */
|
||||
if (bits < op) {
|
||||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
if (bits < op) {
|
||||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
}
|
||||
}
|
||||
dist += (unsigned)hold & ((1U << op) - 1);
|
||||
#ifdef INFLATE_STRICT
|
||||
if (dist > dmax) {
|
||||
strm->msg = (char *)"invalid distance too far back";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
hold >>= op;
|
||||
bits -= op;
|
||||
Tracevv((stderr, "inflate: distance %u\n", dist));
|
||||
op = (unsigned)(out - beg); /* max distance in output */
|
||||
if (dist > op) { /* see if copy from window */
|
||||
op = dist - op; /* distance back in window */
|
||||
if (op > whave) {
|
||||
if (state->sane) {
|
||||
strm->msg =
|
||||
(char *)"invalid distance too far back";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||
if (len <= op - whave) {
|
||||
do {
|
||||
*out++ = 0;
|
||||
} while (--len);
|
||||
continue;
|
||||
}
|
||||
len -= op - whave;
|
||||
do {
|
||||
*out++ = 0;
|
||||
} while (--op > whave);
|
||||
if (op == 0) {
|
||||
from = out - dist;
|
||||
do {
|
||||
*out++ = *from++;
|
||||
} while (--len);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
from = window;
|
||||
if (wnext == 0) { /* very common case */
|
||||
from += wsize - op;
|
||||
if (op < len) { /* some from window */
|
||||
len -= op;
|
||||
do {
|
||||
*out++ = *from++;
|
||||
} while (--op);
|
||||
from = out - dist; /* rest from output */
|
||||
}
|
||||
}
|
||||
else if (wnext < op) { /* wrap around window */
|
||||
from += wsize + wnext - op;
|
||||
op -= wnext;
|
||||
if (op < len) { /* some from end of window */
|
||||
len -= op;
|
||||
do {
|
||||
*out++ = *from++;
|
||||
} while (--op);
|
||||
from = window;
|
||||
if (wnext < len) { /* some from start of window */
|
||||
op = wnext;
|
||||
len -= op;
|
||||
do {
|
||||
*out++ = *from++;
|
||||
} while (--op);
|
||||
from = out - dist; /* rest from output */
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* contiguous in window */
|
||||
from += wnext - op;
|
||||
if (op < len) { /* some from window */
|
||||
len -= op;
|
||||
do {
|
||||
*out++ = *from++;
|
||||
} while (--op);
|
||||
from = out - dist; /* rest from output */
|
||||
}
|
||||
}
|
||||
while (len > 2) {
|
||||
*out++ = *from++;
|
||||
*out++ = *from++;
|
||||
*out++ = *from++;
|
||||
len -= 3;
|
||||
}
|
||||
if (len) {
|
||||
*out++ = *from++;
|
||||
if (len > 1)
|
||||
*out++ = *from++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
from = out - dist; /* copy direct from output */
|
||||
do { /* minimum length is three */
|
||||
*out++ = *from++;
|
||||
*out++ = *from++;
|
||||
*out++ = *from++;
|
||||
len -= 3;
|
||||
} while (len > 2);
|
||||
if (len) {
|
||||
*out++ = *from++;
|
||||
if (len > 1)
|
||||
*out++ = *from++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((op & 64) == 0) { /* 2nd level distance code */
|
||||
here = dcode + here->val + (hold & ((1U << op) - 1));
|
||||
goto dodist;
|
||||
}
|
||||
else {
|
||||
strm->msg = (char *)"invalid distance code";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((op & 64) == 0) { /* 2nd level length code */
|
||||
here = lcode + here->val + (hold & ((1U << op) - 1));
|
||||
goto dolen;
|
||||
}
|
||||
else if (op & 32) { /* end-of-block */
|
||||
Tracevv((stderr, "inflate: end of block\n"));
|
||||
state->mode = TYPE;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
strm->msg = (char *)"invalid literal/length code";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
} while (in < last && out < end);
|
||||
|
||||
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
|
||||
len = bits >> 3;
|
||||
in -= len;
|
||||
bits -= len << 3;
|
||||
hold &= (1U << bits) - 1;
|
||||
|
||||
/* update state and return */
|
||||
strm->next_in = in;
|
||||
strm->next_out = out;
|
||||
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
|
||||
strm->avail_out = (unsigned)(out < end ?
|
||||
257 + (end - out) : 257 - (out - end));
|
||||
state->hold = hold;
|
||||
state->bits = bits;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
|
||||
- Using bit fields for code structure
|
||||
- Different op definition to avoid & for extra bits (do & for table bits)
|
||||
- Three separate decoding do-loops for direct, window, and wnext == 0
|
||||
- Special case for distance > 1 copies to do overlapped load and store copy
|
||||
- Explicit branch predictions (based on measured branch probabilities)
|
||||
- Deferring match copy and interspersed it with decoding subsequent codes
|
||||
- Swapping literal/length else
|
||||
- Swapping window/direct else
|
||||
- Larger unrolled copy loops (three is about right)
|
||||
- Moving len -= 3 statement into middle of loop
|
||||
*/
|
||||
|
||||
#endif /* !ASMINF */
|
||||
@@ -0,0 +1,11 @@
|
||||
/* inffast.h -- header to use inffast.c
|
||||
* Copyright (C) 1995-2003, 2010 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
|
||||
@@ -0,0 +1,94 @@
|
||||
/* inffixed.h -- table for decoding fixed codes
|
||||
* Generated automatically by makefixed().
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications.
|
||||
It is part of the implementation of this library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
static const code lenfix[512] = {
|
||||
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
|
||||
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
|
||||
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
|
||||
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
|
||||
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
|
||||
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
|
||||
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
|
||||
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
|
||||
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
|
||||
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
|
||||
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
|
||||
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
|
||||
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
|
||||
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
|
||||
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
|
||||
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
|
||||
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
|
||||
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
|
||||
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
|
||||
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
|
||||
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
|
||||
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
|
||||
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
|
||||
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
|
||||
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
|
||||
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
|
||||
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
|
||||
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
|
||||
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
|
||||
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
|
||||
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
|
||||
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
|
||||
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
|
||||
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
|
||||
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
|
||||
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
|
||||
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
|
||||
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
|
||||
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
|
||||
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
|
||||
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
|
||||
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
|
||||
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
|
||||
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
|
||||
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
|
||||
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
|
||||
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
|
||||
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
|
||||
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
|
||||
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
|
||||
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
|
||||
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
|
||||
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
|
||||
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
|
||||
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
|
||||
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
|
||||
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
|
||||
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
|
||||
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
|
||||
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
|
||||
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
|
||||
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
|
||||
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
|
||||
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
|
||||
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
|
||||
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
|
||||
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
|
||||
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
|
||||
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
|
||||
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
|
||||
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
|
||||
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
|
||||
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
|
||||
{0,9,255}
|
||||
};
|
||||
|
||||
static const code distfix[32] = {
|
||||
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
|
||||
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
|
||||
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
|
||||
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
|
||||
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
|
||||
{22,5,193},{64,5,0}
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,126 @@
|
||||
/* inflate.h -- internal inflate state definition
|
||||
* Copyright (C) 1995-2019 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* define NO_GZIP when compiling if you want to disable gzip header and
|
||||
trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
|
||||
the crc code when it is not needed. For shared libraries, gzip decoding
|
||||
should be left enabled. */
|
||||
#ifndef NO_GZIP
|
||||
# define GUNZIP
|
||||
#endif
|
||||
|
||||
/* Possible inflate modes between inflate() calls */
|
||||
typedef enum {
|
||||
HEAD = 16180, /* i: waiting for magic header */
|
||||
FLAGS, /* i: waiting for method and flags (gzip) */
|
||||
TIME, /* i: waiting for modification time (gzip) */
|
||||
OS, /* i: waiting for extra flags and operating system (gzip) */
|
||||
EXLEN, /* i: waiting for extra length (gzip) */
|
||||
EXTRA, /* i: waiting for extra bytes (gzip) */
|
||||
NAME, /* i: waiting for end of file name (gzip) */
|
||||
COMMENT, /* i: waiting for end of comment (gzip) */
|
||||
HCRC, /* i: waiting for header crc (gzip) */
|
||||
DICTID, /* i: waiting for dictionary check value */
|
||||
DICT, /* waiting for inflateSetDictionary() call */
|
||||
TYPE, /* i: waiting for type bits, including last-flag bit */
|
||||
TYPEDO, /* i: same, but skip check to exit inflate on new block */
|
||||
STORED, /* i: waiting for stored size (length and complement) */
|
||||
COPY_, /* i/o: same as COPY below, but only first time in */
|
||||
COPY, /* i/o: waiting for input or output to copy stored block */
|
||||
TABLE, /* i: waiting for dynamic block table lengths */
|
||||
LENLENS, /* i: waiting for code length code lengths */
|
||||
CODELENS, /* i: waiting for length/lit and distance code lengths */
|
||||
LEN_, /* i: same as LEN below, but only first time in */
|
||||
LEN, /* i: waiting for length/lit/eob code */
|
||||
LENEXT, /* i: waiting for length extra bits */
|
||||
DIST, /* i: waiting for distance code */
|
||||
DISTEXT, /* i: waiting for distance extra bits */
|
||||
MATCH, /* o: waiting for output space to copy string */
|
||||
LIT, /* o: waiting for output space to write literal */
|
||||
CHECK, /* i: waiting for 32-bit check value */
|
||||
LENGTH, /* i: waiting for 32-bit length (gzip) */
|
||||
DONE, /* finished check, done -- remain here until reset */
|
||||
BAD, /* got a data error -- remain here until reset */
|
||||
MEM, /* got an inflate() memory error -- remain here until reset */
|
||||
SYNC /* looking for synchronization bytes to restart inflate() */
|
||||
} inflate_mode;
|
||||
|
||||
/*
|
||||
State transitions between above modes -
|
||||
|
||||
(most modes can go to BAD or MEM on error -- not shown for clarity)
|
||||
|
||||
Process header:
|
||||
HEAD -> (gzip) or (zlib) or (raw)
|
||||
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
|
||||
HCRC -> TYPE
|
||||
(zlib) -> DICTID or TYPE
|
||||
DICTID -> DICT -> TYPE
|
||||
(raw) -> TYPEDO
|
||||
Read deflate blocks:
|
||||
TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
|
||||
STORED -> COPY_ -> COPY -> TYPE
|
||||
TABLE -> LENLENS -> CODELENS -> LEN_
|
||||
LEN_ -> LEN
|
||||
Read deflate codes in fixed or dynamic block:
|
||||
LEN -> LENEXT or LIT or TYPE
|
||||
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
|
||||
LIT -> LEN
|
||||
Process trailer:
|
||||
CHECK -> LENGTH -> DONE
|
||||
*/
|
||||
|
||||
/* State maintained between inflate() calls -- approximately 7K bytes, not
|
||||
including the allocated sliding window, which is up to 32K bytes. */
|
||||
struct inflate_state {
|
||||
z_streamp strm; /* pointer back to this zlib stream */
|
||||
inflate_mode mode; /* current inflate mode */
|
||||
int last; /* true if processing last block */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
|
||||
bit 2 true to validate check value */
|
||||
int havedict; /* true if dictionary provided */
|
||||
int flags; /* gzip header method and flags, 0 if zlib, or
|
||||
-1 if raw or no header yet */
|
||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
||||
unsigned long check; /* protected copy of check value */
|
||||
unsigned long total; /* protected copy of output count */
|
||||
gz_headerp head; /* where to save gzip header information */
|
||||
/* sliding window */
|
||||
unsigned wbits; /* log base 2 of requested window size */
|
||||
unsigned wsize; /* window size or zero if not using window */
|
||||
unsigned whave; /* valid bytes in the window */
|
||||
unsigned wnext; /* window write index */
|
||||
unsigned char FAR *window; /* allocated sliding window, if needed */
|
||||
/* bit accumulator */
|
||||
unsigned long hold; /* input bit accumulator */
|
||||
unsigned bits; /* number of bits in "in" */
|
||||
/* for string and stored block copying */
|
||||
unsigned length; /* literal or length of data to copy */
|
||||
unsigned offset; /* distance back to copy string from */
|
||||
/* for table and code decoding */
|
||||
unsigned extra; /* extra bits needed */
|
||||
/* fixed and dynamic code tables */
|
||||
code const FAR *lencode; /* starting table for length/literal codes */
|
||||
code const FAR *distcode; /* starting table for distance codes */
|
||||
unsigned lenbits; /* index bits for lencode */
|
||||
unsigned distbits; /* index bits for distcode */
|
||||
/* dynamic table building */
|
||||
unsigned ncode; /* number of code length code lengths */
|
||||
unsigned nlen; /* number of length code lengths */
|
||||
unsigned ndist; /* number of distance code lengths */
|
||||
unsigned have; /* number of code lengths in lens[] */
|
||||
code FAR *next; /* next available space in codes[] */
|
||||
unsigned short lens[320]; /* temporary storage for code lengths */
|
||||
unsigned short work[288]; /* work area for code table building */
|
||||
code codes[ENOUGH]; /* space for code tables */
|
||||
int sane; /* if false, allow invalid distance too far */
|
||||
int back; /* bits back of last unprocessed length/lit */
|
||||
unsigned was; /* initial length of match */
|
||||
};
|
||||
@@ -0,0 +1,299 @@
|
||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||
* Copyright (C) 1995-2024 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
|
||||
#define MAXBITS 15
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
include such an acknowledgment, I would appreciate that you keep this
|
||||
copyright string in the executable of your product.
|
||||
*/
|
||||
|
||||
/*
|
||||
Build a set of tables to decode the provided canonical Huffman code.
|
||||
The code lengths are lens[0..codes-1]. The result starts at *table,
|
||||
whose indices are 0..2^bits-1. work is a writable array of at least
|
||||
lens shorts, which is used as a work area. type is the type of code
|
||||
to be generated, CODES, LENS, or DISTS. On return, zero is success,
|
||||
-1 is an invalid code, and +1 means that ENOUGH isn't enough. table
|
||||
on return points to the next available entry's address. bits is the
|
||||
requested root table index bits, and on return it is the actual root
|
||||
table index bits. It will differ if the request is greater than the
|
||||
longest code or if it is less than the shortest code.
|
||||
*/
|
||||
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work) {
|
||||
unsigned len; /* a code's length in bits */
|
||||
unsigned sym; /* index of code symbols */
|
||||
unsigned min, max; /* minimum and maximum code lengths */
|
||||
unsigned root; /* number of index bits for root table */
|
||||
unsigned curr; /* number of index bits for current table */
|
||||
unsigned drop; /* code bits to drop for sub-table */
|
||||
int left; /* number of prefix codes available */
|
||||
unsigned used; /* code entries in table used */
|
||||
unsigned huff; /* Huffman code */
|
||||
unsigned incr; /* for incrementing code, index */
|
||||
unsigned fill; /* index for replicating entries */
|
||||
unsigned low; /* low bits for current root entry */
|
||||
unsigned mask; /* mask for low root bits */
|
||||
code here; /* table entry for duplication */
|
||||
code FAR *next; /* next available space in table */
|
||||
const unsigned short FAR *base; /* base value table to use */
|
||||
const unsigned short FAR *extra; /* extra bits table to use */
|
||||
unsigned match; /* use base and extra for symbol >= match */
|
||||
unsigned short count[MAXBITS+1]; /* number of codes of each length */
|
||||
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
|
||||
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
|
||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577, 0, 0};
|
||||
static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
|
||||
16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
|
||||
23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
|
||||
28, 28, 29, 29, 64, 64};
|
||||
|
||||
/*
|
||||
Process a set of code lengths to create a canonical Huffman code. The
|
||||
code lengths are lens[0..codes-1]. Each length corresponds to the
|
||||
symbols 0..codes-1. The Huffman code is generated by first sorting the
|
||||
symbols by length from short to long, and retaining the symbol order
|
||||
for codes with equal lengths. Then the code starts with all zero bits
|
||||
for the first code of the shortest length, and the codes are integer
|
||||
increments for the same length, and zeros are appended as the length
|
||||
increases. For the deflate format, these bits are stored backwards
|
||||
from their more natural integer increment ordering, and so when the
|
||||
decoding tables are built in the large loop below, the integer codes
|
||||
are incremented backwards.
|
||||
|
||||
This routine assumes, but does not check, that all of the entries in
|
||||
lens[] are in the range 0..MAXBITS. The caller must assure this.
|
||||
1..MAXBITS is interpreted as that code length. zero means that that
|
||||
symbol does not occur in this code.
|
||||
|
||||
The codes are sorted by computing a count of codes for each length,
|
||||
creating from that a table of starting indices for each length in the
|
||||
sorted table, and then entering the symbols in order in the sorted
|
||||
table. The sorted table is work[], with that space being provided by
|
||||
the caller.
|
||||
|
||||
The length counts are used for other purposes as well, i.e. finding
|
||||
the minimum and maximum length codes, determining if there are any
|
||||
codes at all, checking for a valid set of lengths, and looking ahead
|
||||
at length counts to determine sub-table sizes when building the
|
||||
decoding tables.
|
||||
*/
|
||||
|
||||
/* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
|
||||
for (len = 0; len <= MAXBITS; len++)
|
||||
count[len] = 0;
|
||||
for (sym = 0; sym < codes; sym++)
|
||||
count[lens[sym]]++;
|
||||
|
||||
/* bound code lengths, force root to be within code lengths */
|
||||
root = *bits;
|
||||
for (max = MAXBITS; max >= 1; max--)
|
||||
if (count[max] != 0) break;
|
||||
if (root > max) root = max;
|
||||
if (max == 0) { /* no symbols to code at all */
|
||||
here.op = (unsigned char)64; /* invalid code marker */
|
||||
here.bits = (unsigned char)1;
|
||||
here.val = (unsigned short)0;
|
||||
*(*table)++ = here; /* make a table to force an error */
|
||||
*(*table)++ = here;
|
||||
*bits = 1;
|
||||
return 0; /* no symbols, but wait for decoding to report error */
|
||||
}
|
||||
for (min = 1; min < max; min++)
|
||||
if (count[min] != 0) break;
|
||||
if (root < min) root = min;
|
||||
|
||||
/* check for an over-subscribed or incomplete set of lengths */
|
||||
left = 1;
|
||||
for (len = 1; len <= MAXBITS; len++) {
|
||||
left <<= 1;
|
||||
left -= count[len];
|
||||
if (left < 0) return -1; /* over-subscribed */
|
||||
}
|
||||
if (left > 0 && (type == CODES || max != 1))
|
||||
return -1; /* incomplete set */
|
||||
|
||||
/* generate offsets into symbol table for each length for sorting */
|
||||
offs[1] = 0;
|
||||
for (len = 1; len < MAXBITS; len++)
|
||||
offs[len + 1] = offs[len] + count[len];
|
||||
|
||||
/* sort symbols by length, by symbol order within each length */
|
||||
for (sym = 0; sym < codes; sym++)
|
||||
if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
|
||||
|
||||
/*
|
||||
Create and fill in decoding tables. In this loop, the table being
|
||||
filled is at next and has curr index bits. The code being used is huff
|
||||
with length len. That code is converted to an index by dropping drop
|
||||
bits off of the bottom. For codes where len is less than drop + curr,
|
||||
those top drop + curr - len bits are incremented through all values to
|
||||
fill the table with replicated entries.
|
||||
|
||||
root is the number of index bits for the root table. When len exceeds
|
||||
root, sub-tables are created pointed to by the root entry with an index
|
||||
of the low root bits of huff. This is saved in low to check for when a
|
||||
new sub-table should be started. drop is zero when the root table is
|
||||
being filled, and drop is root when sub-tables are being filled.
|
||||
|
||||
When a new sub-table is needed, it is necessary to look ahead in the
|
||||
code lengths to determine what size sub-table is needed. The length
|
||||
counts are used for this, and so count[] is decremented as codes are
|
||||
entered in the tables.
|
||||
|
||||
used keeps track of how many table entries have been allocated from the
|
||||
provided *table space. It is checked for LENS and DIST tables against
|
||||
the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
|
||||
the initial root table size constants. See the comments in inftrees.h
|
||||
for more information.
|
||||
|
||||
sym increments through all symbols, and the loop terminates when
|
||||
all codes of length max, i.e. all codes, have been processed. This
|
||||
routine permits incomplete codes, so another loop after this one fills
|
||||
in the rest of the decoding tables with invalid code markers.
|
||||
*/
|
||||
|
||||
/* set up for code type */
|
||||
switch (type) {
|
||||
case CODES:
|
||||
base = extra = work; /* dummy value--not used */
|
||||
match = 20;
|
||||
break;
|
||||
case LENS:
|
||||
base = lbase;
|
||||
extra = lext;
|
||||
match = 257;
|
||||
break;
|
||||
default: /* DISTS */
|
||||
base = dbase;
|
||||
extra = dext;
|
||||
match = 0;
|
||||
}
|
||||
|
||||
/* initialize state for loop */
|
||||
huff = 0; /* starting code */
|
||||
sym = 0; /* starting code symbol */
|
||||
len = min; /* starting code length */
|
||||
next = *table; /* current table to fill in */
|
||||
curr = root; /* current table index bits */
|
||||
drop = 0; /* current bits to drop from code for index */
|
||||
low = (unsigned)(-1); /* trigger new sub-table when len > root */
|
||||
used = 1U << root; /* use root table entries */
|
||||
mask = used - 1; /* mask for comparing low */
|
||||
|
||||
/* check available table space */
|
||||
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||
(type == DISTS && used > ENOUGH_DISTS))
|
||||
return 1;
|
||||
|
||||
/* process all codes and make table entries */
|
||||
for (;;) {
|
||||
/* create table entry */
|
||||
here.bits = (unsigned char)(len - drop);
|
||||
if (work[sym] + 1U < match) {
|
||||
here.op = (unsigned char)0;
|
||||
here.val = work[sym];
|
||||
}
|
||||
else if (work[sym] >= match) {
|
||||
here.op = (unsigned char)(extra[work[sym] - match]);
|
||||
here.val = base[work[sym] - match];
|
||||
}
|
||||
else {
|
||||
here.op = (unsigned char)(32 + 64); /* end of block */
|
||||
here.val = 0;
|
||||
}
|
||||
|
||||
/* replicate for those indices with low len bits equal to huff */
|
||||
incr = 1U << (len - drop);
|
||||
fill = 1U << curr;
|
||||
min = fill; /* save offset to next table */
|
||||
do {
|
||||
fill -= incr;
|
||||
next[(huff >> drop) + fill] = here;
|
||||
} while (fill != 0);
|
||||
|
||||
/* backwards increment the len-bit code huff */
|
||||
incr = 1U << (len - 1);
|
||||
while (huff & incr)
|
||||
incr >>= 1;
|
||||
if (incr != 0) {
|
||||
huff &= incr - 1;
|
||||
huff += incr;
|
||||
}
|
||||
else
|
||||
huff = 0;
|
||||
|
||||
/* go to next symbol, update count, len */
|
||||
sym++;
|
||||
if (--(count[len]) == 0) {
|
||||
if (len == max) break;
|
||||
len = lens[work[sym]];
|
||||
}
|
||||
|
||||
/* create new sub-table if needed */
|
||||
if (len > root && (huff & mask) != low) {
|
||||
/* if first time, transition to sub-tables */
|
||||
if (drop == 0)
|
||||
drop = root;
|
||||
|
||||
/* increment past last table */
|
||||
next += min; /* here min is 1 << curr */
|
||||
|
||||
/* determine length of next table */
|
||||
curr = len - drop;
|
||||
left = (int)(1 << curr);
|
||||
while (curr + drop < max) {
|
||||
left -= count[curr + drop];
|
||||
if (left <= 0) break;
|
||||
curr++;
|
||||
left <<= 1;
|
||||
}
|
||||
|
||||
/* check for enough space */
|
||||
used += 1U << curr;
|
||||
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||
(type == DISTS && used > ENOUGH_DISTS))
|
||||
return 1;
|
||||
|
||||
/* point entry in root table to sub-table */
|
||||
low = huff & mask;
|
||||
(*table)[low].op = (unsigned char)curr;
|
||||
(*table)[low].bits = (unsigned char)root;
|
||||
(*table)[low].val = (unsigned short)(next - *table);
|
||||
}
|
||||
}
|
||||
|
||||
/* fill in remaining table entry if code is incomplete (guaranteed to have
|
||||
at most one remaining entry, since if the code is incomplete, the
|
||||
maximum code length that was allowed to get this far is one bit) */
|
||||
if (huff != 0) {
|
||||
here.op = (unsigned char)64; /* invalid code marker */
|
||||
here.bits = (unsigned char)(len - drop);
|
||||
here.val = (unsigned short)0;
|
||||
next[huff] = here;
|
||||
}
|
||||
|
||||
/* set return parameters */
|
||||
*table += used;
|
||||
*bits = root;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/* inftrees.h -- header to use inftrees.c
|
||||
* Copyright (C) 1995-2005, 2010 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* Structure for decoding tables. Each entry provides either the
|
||||
information needed to do the operation requested by the code that
|
||||
indexed that table entry, or it provides a pointer to another
|
||||
table that indexes more bits of the code. op indicates whether
|
||||
the entry is a pointer to another table, a literal, a length or
|
||||
distance, an end-of-block, or an invalid code. For a table
|
||||
pointer, the low four bits of op is the number of index bits of
|
||||
that table. For a length or distance, the low four bits of op
|
||||
is the number of extra bits to get after the code. bits is
|
||||
the number of bits in this code or part of the code to drop off
|
||||
of the bit buffer. val is the actual byte to output in the case
|
||||
of a literal, the base length or distance, or the offset from
|
||||
the current table to the next table. Each entry is four bytes. */
|
||||
typedef struct {
|
||||
unsigned char op; /* operation, extra bits, table bits */
|
||||
unsigned char bits; /* bits in this part of the code */
|
||||
unsigned short val; /* offset in table or code value */
|
||||
} code;
|
||||
|
||||
/* op values as set by inflate_table():
|
||||
00000000 - literal
|
||||
0000tttt - table link, tttt != 0 is the number of table index bits
|
||||
0001eeee - length or distance, eeee is the number of extra bits
|
||||
01100000 - end of block
|
||||
01000000 - invalid code
|
||||
*/
|
||||
|
||||
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
||||
codes. These values were found by exhaustive searches using the program
|
||||
examples/enough.c found in the zlib distribution. The arguments to that
|
||||
program are the number of symbols, the initial root table size, and the
|
||||
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||
returns 852, and "enough 30 6 15" for distance codes returns 592. The
|
||||
initial root table size (9 or 6) is found in the fifth argument of the
|
||||
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
||||
changed, then these maximum sizes would be need to be recalculated and
|
||||
updated. */
|
||||
#define ENOUGH_LENS 852
|
||||
#define ENOUGH_DISTS 592
|
||||
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
|
||||
|
||||
/* Type of code to build for inflate_table() */
|
||||
typedef enum {
|
||||
CODES,
|
||||
LENS,
|
||||
DISTS
|
||||
} codetype;
|
||||
|
||||
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work);
|
||||
@@ -0,0 +1,231 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS)))
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
|
||||
#else
|
||||
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello64(stream)
|
||||
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
|
||||
#endif
|
||||
|
||||
|
||||
#include "ioapi.h"
|
||||
|
||||
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) {
|
||||
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
|
||||
else
|
||||
{
|
||||
return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
|
||||
}
|
||||
}
|
||||
|
||||
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) {
|
||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
|
||||
else
|
||||
{
|
||||
uLong offsetTruncated = (uLong)offset;
|
||||
if (offsetTruncated != offset)
|
||||
return -1;
|
||||
else
|
||||
return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
|
||||
}
|
||||
}
|
||||
|
||||
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) {
|
||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
||||
else
|
||||
{
|
||||
uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||
if ((tell_uLong) == MAXU32)
|
||||
return (ZPOS64_T)-1;
|
||||
else
|
||||
return tell_uLong;
|
||||
}
|
||||
}
|
||||
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) {
|
||||
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
|
||||
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
|
||||
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
||||
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
||||
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
|
||||
p_filefunc64_32->zfile_func64.zseek64_file = NULL;
|
||||
p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
|
||||
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||
p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
|
||||
p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
|
||||
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) {
|
||||
FILE* file = NULL;
|
||||
const char* mode_fopen = NULL;
|
||||
(void)opaque;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
mode_fopen = "r+b";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
mode_fopen = "wb";
|
||||
|
||||
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||
file = fopen(filename, mode_fopen);
|
||||
return file;
|
||||
}
|
||||
|
||||
static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) {
|
||||
FILE* file = NULL;
|
||||
const char* mode_fopen = NULL;
|
||||
(void)opaque;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
mode_fopen = "r+b";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
mode_fopen = "wb";
|
||||
|
||||
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||
file = FOPEN_FUNC((const char*)filename, mode_fopen);
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) {
|
||||
uLong ret;
|
||||
(void)opaque;
|
||||
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
|
||||
uLong ret;
|
||||
(void)opaque;
|
||||
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) {
|
||||
long ret;
|
||||
(void)opaque;
|
||||
ret = ftell((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) {
|
||||
ZPOS64_T ret;
|
||||
(void)opaque;
|
||||
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
|
||||
int fseek_origin=0;
|
||||
long ret;
|
||||
(void)opaque;
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
fseek_origin = SEEK_CUR;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_END :
|
||||
fseek_origin = SEEK_END;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_SET :
|
||||
fseek_origin = SEEK_SET;
|
||||
break;
|
||||
default: return -1;
|
||||
}
|
||||
ret = 0;
|
||||
if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0)
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
|
||||
int fseek_origin=0;
|
||||
long ret;
|
||||
(void)opaque;
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
fseek_origin = SEEK_CUR;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_END :
|
||||
fseek_origin = SEEK_END;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_SET :
|
||||
fseek_origin = SEEK_SET;
|
||||
break;
|
||||
default: return -1;
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0)
|
||||
ret = -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret;
|
||||
(void)opaque;
|
||||
ret = fclose((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret;
|
||||
(void)opaque;
|
||||
ret = ferror((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
pzlib_filefunc_def->ztell_file = ftell_file_func;
|
||||
pzlib_filefunc_def->zseek_file = fseek_file_func;
|
||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = ftell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = fseek64_file_func;
|
||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
Changes
|
||||
|
||||
Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
|
||||
Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
|
||||
More if/def section may be needed to support other platforms
|
||||
Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
|
||||
(but you should use iowin32.c for windows instead)
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI64_H
|
||||
#define _ZLIBIOAPI64_H
|
||||
|
||||
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
|
||||
|
||||
// Linux needs this to support file operation on files larger then 4+GB
|
||||
// But might need better if/def to select just the platforms that needs them.
|
||||
|
||||
#ifndef __USE_FILE_OFFSET64
|
||||
#define __USE_FILE_OFFSET64
|
||||
#endif
|
||||
#ifndef __USE_LARGEFILE64
|
||||
#define __USE_LARGEFILE64
|
||||
#endif
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
#ifndef _FILE_OFFSET_BIT
|
||||
#define _FILE_OFFSET_BIT 64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "zlib.h"
|
||||
|
||||
#if defined(USE_FILE32API)
|
||||
#define fopen64 fopen
|
||||
#define ftello64 ftell
|
||||
#define fseeko64 fseek
|
||||
#else
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
|
||||
#define fopen64 fopen
|
||||
#define ftello64 ftello
|
||||
#define fseeko64 fseeko
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#define fopen64 fopen
|
||||
#if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
|
||||
#define ftello64 _ftelli64
|
||||
#define fseeko64 _fseeki64
|
||||
#else // old MSC
|
||||
#define ftello64 ftell
|
||||
#define fseeko64 fseek
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifndef ZPOS64_T
|
||||
#ifdef _WIN32
|
||||
#define ZPOS64_T fpos_t
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#define ZPOS64_T uint64_t
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifdef HAVE_MINIZIP64_CONF_H
|
||||
#include "mz64conf.h"
|
||||
#endif
|
||||
|
||||
/* a type chosen by DEFINE */
|
||||
#ifdef HAVE_64BIT_INT_CUSTOM
|
||||
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||
#else
|
||||
#ifdef HAS_STDINT_H
|
||||
#include "stdint.h"
|
||||
typedef uint64_t ZPOS64_T;
|
||||
#else
|
||||
|
||||
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ZPOS64_T;
|
||||
#else
|
||||
typedef unsigned long long int ZPOS64_T;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||
#ifndef MAXU32
|
||||
#define MAXU32 (0xffffffff)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||
|
||||
|
||||
#ifndef ZCALLBACK
|
||||
#if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
|
||||
typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
|
||||
typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
|
||||
typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
|
||||
typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
|
||||
|
||||
typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
|
||||
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
|
||||
|
||||
|
||||
/* here is the "old" 32 bits structure */
|
||||
typedef struct zlib_filefunc_def_s
|
||||
{
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
voidpf opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
|
||||
typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
|
||||
typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode);
|
||||
|
||||
typedef struct zlib_filefunc64_def_s
|
||||
{
|
||||
open64_file_func zopen64_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell64_file_func ztell64_file;
|
||||
seek64_file_func zseek64_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
voidpf opaque;
|
||||
} zlib_filefunc64_def;
|
||||
|
||||
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
|
||||
|
||||
/* now internal definition, only for zip.c and unzip.h */
|
||||
typedef struct zlib_filefunc64_32_def_s
|
||||
{
|
||||
zlib_filefunc64_def zfile_func64;
|
||||
open_file_func zopen32_file;
|
||||
tell_file_func ztell32_file;
|
||||
seek_file_func zseek32_file;
|
||||
} zlib_filefunc64_32_def;
|
||||
|
||||
|
||||
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||
//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
|
||||
//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||
|
||||
voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
|
||||
long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
|
||||
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
|
||||
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
|
||||
|
||||
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
|
||||
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
|
||||
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,440 @@
|
||||
/* iowin32.c -- IO base function header for compress/uncompress .zip
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zlib.h"
|
||||
#include "ioapi.h"
|
||||
#include "iowin32.h"
|
||||
|
||||
#ifndef INVALID_HANDLE_VALUE
|
||||
#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
|
||||
#endif
|
||||
|
||||
#ifndef INVALID_SET_FILE_POINTER
|
||||
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
|
||||
#endif
|
||||
|
||||
|
||||
// see Include/shared/winapifamily.h in the Windows Kit
|
||||
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
|
||||
|
||||
#if !defined(WINAPI_FAMILY_ONE_PARTITION)
|
||||
#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)
|
||||
#endif
|
||||
|
||||
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
|
||||
#define IOWIN32_USING_WINRT_API 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HANDLE hf;
|
||||
int error;
|
||||
} WIN32FILE_IOWIN;
|
||||
|
||||
|
||||
static void win32_translate_open_mode(int mode,
|
||||
DWORD* lpdwDesiredAccess,
|
||||
DWORD* lpdwCreationDisposition,
|
||||
DWORD* lpdwShareMode,
|
||||
DWORD* lpdwFlagsAndAttributes) {
|
||||
*lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
|
||||
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
{
|
||||
*lpdwDesiredAccess = GENERIC_READ;
|
||||
*lpdwCreationDisposition = OPEN_EXISTING;
|
||||
*lpdwShareMode = FILE_SHARE_READ;
|
||||
}
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
{
|
||||
*lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
|
||||
*lpdwCreationDisposition = OPEN_EXISTING;
|
||||
}
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
{
|
||||
*lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
|
||||
*lpdwCreationDisposition = CREATE_ALWAYS;
|
||||
}
|
||||
}
|
||||
|
||||
static voidpf win32_build_iowin(HANDLE hFile) {
|
||||
voidpf ret=NULL;
|
||||
|
||||
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
|
||||
{
|
||||
WIN32FILE_IOWIN w32fiow;
|
||||
w32fiow.hf = hFile;
|
||||
w32fiow.error = 0;
|
||||
ret = malloc(sizeof(WIN32FILE_IOWIN));
|
||||
|
||||
if (ret==NULL)
|
||||
CloseHandle(hFile);
|
||||
else
|
||||
*((WIN32FILE_IOWIN*)ret) = w32fiow;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
||||
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
#ifdef UNICODE
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
{
|
||||
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
||||
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
||||
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
#endif
|
||||
|
||||
return win32_build_iowin(hFile);
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
||||
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
{
|
||||
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
||||
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
||||
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
}
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
#endif
|
||||
|
||||
return win32_build_iowin(hFile);
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
||||
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL);
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
#endif
|
||||
|
||||
return win32_build_iowin(hFile);
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
||||
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
#ifdef UNICODE
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
{
|
||||
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
||||
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
||||
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
#endif
|
||||
|
||||
return win32_build_iowin(hFile);
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
|
||||
uLong ret=0;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
||||
|
||||
if (hFile != NULL)
|
||||
{
|
||||
if (!ReadFile(hFile, buf, size, &ret, NULL))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
if (dwErr == ERROR_HANDLE_EOF)
|
||||
dwErr = 0;
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
|
||||
uLong ret=0;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
||||
|
||||
if (hFile != NULL)
|
||||
{
|
||||
if (!WriteFile(hFile, buf, size, &ret, NULL))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
if (dwErr == ERROR_HANDLE_EOF)
|
||||
dwErr = 0;
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) {
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
|
||||
#else
|
||||
LONG lHigh = pos.HighPart;
|
||||
DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod);
|
||||
BOOL fOk = TRUE;
|
||||
if (dwNewPos == 0xFFFFFFFF)
|
||||
if (GetLastError() != NO_ERROR)
|
||||
fOk = FALSE;
|
||||
if ((newPos != NULL) && (fOk))
|
||||
{
|
||||
newPos->LowPart = dwNewPos;
|
||||
newPos->HighPart = lHigh;
|
||||
}
|
||||
return fOk;
|
||||
#endif
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
|
||||
long ret=-1;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
||||
if (hFile != NULL)
|
||||
{
|
||||
LARGE_INTEGER pos;
|
||||
pos.QuadPart = 0;
|
||||
|
||||
if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
ret=(long)pos.LowPart;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
|
||||
ZPOS64_T ret= (ZPOS64_T)-1;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
|
||||
|
||||
if (hFile)
|
||||
{
|
||||
LARGE_INTEGER pos;
|
||||
pos.QuadPart = 0;
|
||||
|
||||
if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
ret = (ZPOS64_T)-1;
|
||||
}
|
||||
else
|
||||
ret=pos.QuadPart;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
long ret=-1;
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
dwMoveMethod = FILE_CURRENT;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_END :
|
||||
dwMoveMethod = FILE_END;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_SET :
|
||||
dwMoveMethod = FILE_BEGIN;
|
||||
break;
|
||||
default: return -1;
|
||||
}
|
||||
|
||||
if (hFile != NULL)
|
||||
{
|
||||
LARGE_INTEGER pos;
|
||||
pos.QuadPart = offset;
|
||||
if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
ret=0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
long ret=-1;
|
||||
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
|
||||
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
dwMoveMethod = FILE_CURRENT;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_END :
|
||||
dwMoveMethod = FILE_END;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_SET :
|
||||
dwMoveMethod = FILE_BEGIN;
|
||||
break;
|
||||
default: return -1;
|
||||
}
|
||||
|
||||
if (hFile)
|
||||
{
|
||||
LARGE_INTEGER pos;
|
||||
pos.QuadPart = offset;
|
||||
if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
ret=0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret=-1;
|
||||
|
||||
if (stream!=NULL)
|
||||
{
|
||||
HANDLE hFile;
|
||||
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
||||
if (hFile != NULL)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
ret=0;
|
||||
}
|
||||
free(stream);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret=-1;
|
||||
if (stream!=NULL)
|
||||
{
|
||||
ret = ((WIN32FILE_IOWIN*)stream) -> error;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen_file = win32_open_file_func;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
pzlib_filefunc_def->ztell_file = win32_tell_file_func;
|
||||
pzlib_filefunc_def->zseek_file = win32_seek_file_func;
|
||||
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
||||
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
||||
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
||||
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
|
||||
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
||||
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
||||
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
|
||||
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
||||
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
||||
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/* iowin32.h -- IO base function header for compress/uncompress .zip
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
|
||||
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,437 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Modifications of Unzip for Zip64
|
||||
Copyright (C) 2007-2008 Even Rouault
|
||||
|
||||
Modifications for Zip64 support on both zip and unzip
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
Changes
|
||||
|
||||
See header of unzip64.c
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _unz64_H
|
||||
#define _unz64_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BZIP2
|
||||
#include "bzlib.h"
|
||||
#endif
|
||||
|
||||
#define Z_BZIP2ED 12
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
int tm_sec; /* seconds after the minute - [0,59] */
|
||||
int tm_min; /* minutes after the hour - [0,59] */
|
||||
int tm_hour; /* hours since midnight - [0,23] */
|
||||
int tm_mday; /* day of the month - [1,31] */
|
||||
int tm_mon; /* months since January - [0,11] */
|
||||
int tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info64_s
|
||||
{
|
||||
ZPOS64_T number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info64;
|
||||
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info64_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
ZPOS64_T compressed_size; /* compressed size 8 bytes */
|
||||
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info64;
|
||||
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare(const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity);
|
||||
/*
|
||||
Compare two filenames (fileName1,fileName2).
|
||||
If iCaseSensitivity = 1, comparison is case sensitive (like strcmp)
|
||||
If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSensitivity = 0, case sensitivity is default of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen(const char *path);
|
||||
extern unzFile ZEXPORT unzOpen64(const void *path);
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||
"zlib/zlib113.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
the "64" function take a const void* pointer, because the path is just the
|
||||
value passed to the open64_file_func callback.
|
||||
Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
|
||||
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
|
||||
does not describe the reality
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2(const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def);
|
||||
/*
|
||||
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2_64(const void *path,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
/*
|
||||
Open a Zip file, like unz64Open, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose(unzFile file);
|
||||
/*
|
||||
Close a ZipFile opened with unzOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzCloseCurrentFile before call unzClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo(unzFile file,
|
||||
unz_global_info *pglobal_info);
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo64(unzFile file,
|
||||
unz_global_info64 *pglobal_info);
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment(unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf);
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile(unzFile file);
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile(unzFile file);
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile(unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity);
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
/* ****************************************** */
|
||||
/* Ryan supplied functions */
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_pos_s
|
||||
{
|
||||
uLong pos_in_zip_directory; /* offset in zip file directory */
|
||||
uLong num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
typedef struct unz64_file_pos_s
|
||||
{
|
||||
ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
|
||||
ZPOS64_T num_of_file; /* # of file */
|
||||
} unz64_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos64(
|
||||
unzFile file,
|
||||
unz64_file_pos* file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos64(
|
||||
unzFile file,
|
||||
const unz64_file_pos* file_pos);
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file,
|
||||
unz_file_info64 *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize);
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize);
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain some info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filename string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
|
||||
/** Addition for GDAL : START */
|
||||
|
||||
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file);
|
||||
|
||||
/** Addition for GDAL : END */
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile(unzFile file);
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file,
|
||||
const char* password);
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
password is a crypting password
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2(unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw);
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3(unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password);
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile(unzFile file);
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile(unzFile file,
|
||||
voidp buf,
|
||||
unsigned len);
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if some bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell(unzFile file);
|
||||
|
||||
extern ZPOS64_T ZEXPORT unztell64(unzFile file);
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof(unzFile file);
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield(unzFile file,
|
||||
voidp buf,
|
||||
unsigned len);
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
|
||||
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
|
||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz64_H */
|
||||
@@ -0,0 +1,543 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||
* this permanently in zconf.h using "./configure --zprefix".
|
||||
*/
|
||||
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||
# define Z_PREFIX_SET
|
||||
|
||||
/* all linked symbols and init macros */
|
||||
# define _dist_code z__dist_code
|
||||
# define _length_code z__length_code
|
||||
# define _tr_align z__tr_align
|
||||
# define _tr_flush_bits z__tr_flush_bits
|
||||
# define _tr_flush_block z__tr_flush_block
|
||||
# define _tr_init z__tr_init
|
||||
# define _tr_stored_block z__tr_stored_block
|
||||
# define _tr_tally z__tr_tally
|
||||
# define adler32 z_adler32
|
||||
# define adler32_combine z_adler32_combine
|
||||
# define adler32_combine64 z_adler32_combine64
|
||||
# define adler32_z z_adler32_z
|
||||
# ifndef Z_SOLO
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# endif
|
||||
# define crc32 z_crc32
|
||||
# define crc32_combine z_crc32_combine
|
||||
# define crc32_combine64 z_crc32_combine64
|
||||
# define crc32_combine_gen z_crc32_combine_gen
|
||||
# define crc32_combine_gen64 z_crc32_combine_gen64
|
||||
# define crc32_combine_op z_crc32_combine_op
|
||||
# define crc32_z z_crc32_z
|
||||
# define deflate z_deflate
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define deflateGetDictionary z_deflateGetDictionary
|
||||
# define deflateInit z_deflateInit
|
||||
# define deflateInit2 z_deflateInit2
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflatePending z_deflatePending
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateResetKeep z_deflateResetKeep
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateSetHeader z_deflateSetHeader
|
||||
# define deflateTune z_deflateTune
|
||||
# define deflate_copyright z_deflate_copyright
|
||||
# define get_crc_table z_get_crc_table
|
||||
# ifndef Z_SOLO
|
||||
# define gz_error z_gz_error
|
||||
# define gz_intmax z_gz_intmax
|
||||
# define gz_strwinerror z_gz_strwinerror
|
||||
# define gzbuffer z_gzbuffer
|
||||
# define gzclearerr z_gzclearerr
|
||||
# define gzclose z_gzclose
|
||||
# define gzclose_r z_gzclose_r
|
||||
# define gzclose_w z_gzclose_w
|
||||
# define gzdirect z_gzdirect
|
||||
# define gzdopen z_gzdopen
|
||||
# define gzeof z_gzeof
|
||||
# define gzerror z_gzerror
|
||||
# define gzflush z_gzflush
|
||||
# define gzfread z_gzfread
|
||||
# define gzfwrite z_gzfwrite
|
||||
# define gzgetc z_gzgetc
|
||||
# define gzgetc_ z_gzgetc_
|
||||
# define gzgets z_gzgets
|
||||
# define gzoffset z_gzoffset
|
||||
# define gzoffset64 z_gzoffset64
|
||||
# define gzopen z_gzopen
|
||||
# define gzopen64 z_gzopen64
|
||||
# ifdef _WIN32
|
||||
# define gzopen_w z_gzopen_w
|
||||
# endif
|
||||
# define gzprintf z_gzprintf
|
||||
# define gzputc z_gzputc
|
||||
# define gzputs z_gzputs
|
||||
# define gzread z_gzread
|
||||
# define gzrewind z_gzrewind
|
||||
# define gzseek z_gzseek
|
||||
# define gzseek64 z_gzseek64
|
||||
# define gzsetparams z_gzsetparams
|
||||
# define gztell z_gztell
|
||||
# define gztell64 z_gztell64
|
||||
# define gzungetc z_gzungetc
|
||||
# define gzvprintf z_gzvprintf
|
||||
# define gzwrite z_gzwrite
|
||||
# endif
|
||||
# define inflate z_inflate
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define inflateBackInit z_inflateBackInit
|
||||
# define inflateBackInit_ z_inflateBackInit_
|
||||
# define inflateCodesUsed z_inflateCodesUsed
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define inflateGetDictionary z_inflateGetDictionary
|
||||
# define inflateGetHeader z_inflateGetHeader
|
||||
# define inflateInit z_inflateInit
|
||||
# define inflateInit2 z_inflateInit2
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflateMark z_inflateMark
|
||||
# define inflatePrime z_inflatePrime
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateReset2 z_inflateReset2
|
||||
# define inflateResetKeep z_inflateResetKeep
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateUndermine z_inflateUndermine
|
||||
# define inflateValidate z_inflateValidate
|
||||
# define inflate_copyright z_inflate_copyright
|
||||
# define inflate_fast z_inflate_fast
|
||||
# define inflate_table z_inflate_table
|
||||
# ifndef Z_SOLO
|
||||
# define uncompress z_uncompress
|
||||
# define uncompress2 z_uncompress2
|
||||
# endif
|
||||
# define zError z_zError
|
||||
# ifndef Z_SOLO
|
||||
# define zcalloc z_zcalloc
|
||||
# define zcfree z_zcfree
|
||||
# endif
|
||||
# define zlibCompileFlags z_zlibCompileFlags
|
||||
# define zlibVersion z_zlibVersion
|
||||
|
||||
/* all zlib typedefs in zlib.h and zconf.h */
|
||||
# define Byte z_Byte
|
||||
# define Bytef z_Bytef
|
||||
# define alloc_func z_alloc_func
|
||||
# define charf z_charf
|
||||
# define free_func z_free_func
|
||||
# ifndef Z_SOLO
|
||||
# define gzFile z_gzFile
|
||||
# endif
|
||||
# define gz_header z_gz_header
|
||||
# define gz_headerp z_gz_headerp
|
||||
# define in_func z_in_func
|
||||
# define intf z_intf
|
||||
# define out_func z_out_func
|
||||
# define uInt z_uInt
|
||||
# define uIntf z_uIntf
|
||||
# define uLong z_uLong
|
||||
# define uLongf z_uLongf
|
||||
# define voidp z_voidp
|
||||
# define voidpc z_voidpc
|
||||
# define voidpf z_voidpf
|
||||
|
||||
/* all zlib structs in zlib.h and zconf.h */
|
||||
# define gz_header_s z_gz_header_s
|
||||
# define internal_state z_internal_state
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||
# define OS2
|
||||
#endif
|
||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||
# ifndef SYS16BIT
|
||||
# define SYS16BIT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#ifdef __STDC_VERSION__
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# ifndef STDC99
|
||||
# define STDC99
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const /* note: need a more gentle solution here */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
# define z_const const
|
||||
#else
|
||||
# define z_const
|
||||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
# ifdef _WIN64
|
||||
typedef unsigned long long z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
#else
|
||||
# define z_longlong long long
|
||||
# if defined(NO_SIZE_T)
|
||||
typedef unsigned NO_SIZE_T z_size_t;
|
||||
# elif defined(STDC)
|
||||
# include <stddef.h>
|
||||
typedef size_t z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
# undef z_longlong
|
||||
#endif
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# if defined(M_I86SM) || defined(M_I86MM)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
/* Turbo C small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef __BORLANDC__
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(WIN32)
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
# ifdef ZLIB_DLL
|
||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif /* ZLIB_DLL */
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
# ifdef ZLIB_WINAPI
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR CDECL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# ifdef ZLIB_DLL
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXPORT __declspec(dllexport)
|
||||
# define ZEXPORTVA __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXPORT __declspec(dllimport)
|
||||
# define ZEXPORTVA __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||
# include <limits.h>
|
||||
# if (UINT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned
|
||||
# elif (ULONG_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned long
|
||||
# elif (USHRT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned short
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Z_U4
|
||||
typedef Z_U4 z_crc_t;
|
||||
#else
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_STDARG_H
|
||||
#endif
|
||||
|
||||
#ifdef STDC
|
||||
# ifndef Z_SOLO
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# ifndef Z_SOLO
|
||||
# include <stdarg.h> /* for va_list */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef Z_SOLO
|
||||
# include <stddef.h> /* for wchar_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||
* though the former does not conform to the LFS document), but considering
|
||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||
* equivalently requesting no 64-bit operations
|
||||
*/
|
||||
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#ifndef Z_HAVE_UNISTD_H
|
||||
# ifdef __WATCOMC__
|
||||
# define Z_HAVE_UNISTD_H
|
||||
# endif
|
||||
#endif
|
||||
#ifndef Z_HAVE_UNISTD_H
|
||||
# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
|
||||
# define Z_HAVE_UNISTD_H
|
||||
# endif
|
||||
#endif
|
||||
#ifndef Z_SOLO
|
||||
# if defined(Z_HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# ifndef z_off_t
|
||||
# define z_off_t off_t
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
# define Z_LARGE64
|
||||
#endif
|
||||
|
||||
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||
# define Z_WANT64
|
||||
#endif
|
||||
|
||||
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#else
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
#pragma map(deflateInit2_,"DEIN2")
|
||||
#pragma map(deflateEnd,"DEEND")
|
||||
#pragma map(deflateBound,"DEBND")
|
||||
#pragma map(inflateInit_,"ININ")
|
||||
#pragma map(inflateInit2_,"ININ2")
|
||||
#pragma map(inflateEnd,"INEND")
|
||||
#pragma map(inflateSync,"INSY")
|
||||
#pragma map(inflateSetDictionary,"INSEDI")
|
||||
#pragma map(compressBound,"CMBND")
|
||||
#pragma map(inflate_table,"INTABL")
|
||||
#pragma map(inflate_fast,"INFA")
|
||||
#pragma map(inflate_copyright,"INCOPY")
|
||||
#endif
|
||||
|
||||
#endif /* ZCONF_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,299 @@
|
||||
/* zutil.c -- target dependent utility functions for the compression library
|
||||
* Copyright (C) 1995-2017 Jean-loup Gailly
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#include "zutil.h"
|
||||
#ifndef Z_SOLO
|
||||
# include "gzguts.h"
|
||||
#endif
|
||||
|
||||
z_const char * const z_errmsg[10] = {
|
||||
(z_const char *)"need dictionary", /* Z_NEED_DICT 2 */
|
||||
(z_const char *)"stream end", /* Z_STREAM_END 1 */
|
||||
(z_const char *)"", /* Z_OK 0 */
|
||||
(z_const char *)"file error", /* Z_ERRNO (-1) */
|
||||
(z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */
|
||||
(z_const char *)"data error", /* Z_DATA_ERROR (-3) */
|
||||
(z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */
|
||||
(z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */
|
||||
(z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
|
||||
(z_const char *)""
|
||||
};
|
||||
|
||||
|
||||
const char * ZEXPORT zlibVersion(void) {
|
||||
return ZLIB_VERSION;
|
||||
}
|
||||
|
||||
uLong ZEXPORT zlibCompileFlags(void) {
|
||||
uLong flags;
|
||||
|
||||
flags = 0;
|
||||
switch ((int)(sizeof(uInt))) {
|
||||
case 2: break;
|
||||
case 4: flags += 1; break;
|
||||
case 8: flags += 2; break;
|
||||
default: flags += 3;
|
||||
}
|
||||
switch ((int)(sizeof(uLong))) {
|
||||
case 2: break;
|
||||
case 4: flags += 1 << 2; break;
|
||||
case 8: flags += 2 << 2; break;
|
||||
default: flags += 3 << 2;
|
||||
}
|
||||
switch ((int)(sizeof(voidpf))) {
|
||||
case 2: break;
|
||||
case 4: flags += 1 << 4; break;
|
||||
case 8: flags += 2 << 4; break;
|
||||
default: flags += 3 << 4;
|
||||
}
|
||||
switch ((int)(sizeof(z_off_t))) {
|
||||
case 2: break;
|
||||
case 4: flags += 1 << 6; break;
|
||||
case 8: flags += 2 << 6; break;
|
||||
default: flags += 3 << 6;
|
||||
}
|
||||
#ifdef ZLIB_DEBUG
|
||||
flags += 1 << 8;
|
||||
#endif
|
||||
/*
|
||||
#if defined(ASMV) || defined(ASMINF)
|
||||
flags += 1 << 9;
|
||||
#endif
|
||||
*/
|
||||
#ifdef ZLIB_WINAPI
|
||||
flags += 1 << 10;
|
||||
#endif
|
||||
#ifdef BUILDFIXED
|
||||
flags += 1 << 12;
|
||||
#endif
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
flags += 1 << 13;
|
||||
#endif
|
||||
#ifdef NO_GZCOMPRESS
|
||||
flags += 1L << 16;
|
||||
#endif
|
||||
#ifdef NO_GZIP
|
||||
flags += 1L << 17;
|
||||
#endif
|
||||
#ifdef PKZIP_BUG_WORKAROUND
|
||||
flags += 1L << 20;
|
||||
#endif
|
||||
#ifdef FASTEST
|
||||
flags += 1L << 21;
|
||||
#endif
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# ifdef NO_vsnprintf
|
||||
flags += 1L << 25;
|
||||
# ifdef HAS_vsprintf_void
|
||||
flags += 1L << 26;
|
||||
# endif
|
||||
# else
|
||||
# ifdef HAS_vsnprintf_void
|
||||
flags += 1L << 26;
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
flags += 1L << 24;
|
||||
# ifdef NO_snprintf
|
||||
flags += 1L << 25;
|
||||
# ifdef HAS_sprintf_void
|
||||
flags += 1L << 26;
|
||||
# endif
|
||||
# else
|
||||
# ifdef HAS_snprintf_void
|
||||
flags += 1L << 26;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
return flags;
|
||||
}
|
||||
|
||||
#ifdef ZLIB_DEBUG
|
||||
#include <stdlib.h>
|
||||
# ifndef verbose
|
||||
# define verbose 0
|
||||
# endif
|
||||
int ZLIB_INTERNAL z_verbose = verbose;
|
||||
|
||||
void ZLIB_INTERNAL z_error(char *m) {
|
||||
fprintf(stderr, "%s\n", m);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* exported to allow conversion of error code to string for compress() and
|
||||
* uncompress()
|
||||
*/
|
||||
const char * ZEXPORT zError(int err) {
|
||||
return ERR_MSG(err);
|
||||
}
|
||||
|
||||
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
|
||||
/* The older Microsoft C Run-Time Library for Windows CE doesn't have
|
||||
* errno. We define it as a global variable to simplify porting.
|
||||
* Its value is always 0 and should not be used.
|
||||
*/
|
||||
int errno = 0;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MEMCPY
|
||||
|
||||
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) {
|
||||
if (len == 0) return;
|
||||
do {
|
||||
*dest++ = *source++; /* ??? to be unrolled */
|
||||
} while (--len != 0);
|
||||
}
|
||||
|
||||
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) {
|
||||
uInt j;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
|
||||
if (len == 0) return;
|
||||
do {
|
||||
*dest++ = 0; /* ??? to be unrolled */
|
||||
} while (--len != 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef Z_SOLO
|
||||
|
||||
#ifdef SYS16BIT
|
||||
|
||||
#ifdef __TURBOC__
|
||||
/* Turbo C in 16-bit mode */
|
||||
|
||||
# define MY_ZCALLOC
|
||||
|
||||
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
|
||||
* and farmalloc(64K) returns a pointer with an offset of 8, so we
|
||||
* must fix the pointer. Warning: the pointer must be put back to its
|
||||
* original form in order to free it, use zcfree().
|
||||
*/
|
||||
|
||||
#define MAX_PTR 10
|
||||
/* 10*64K = 640K */
|
||||
|
||||
local int next_ptr = 0;
|
||||
|
||||
typedef struct ptr_table_s {
|
||||
voidpf org_ptr;
|
||||
voidpf new_ptr;
|
||||
} ptr_table;
|
||||
|
||||
local ptr_table table[MAX_PTR];
|
||||
/* This table is used to remember the original form of pointers
|
||||
* to large buffers (64K). Such pointers are normalized with a zero offset.
|
||||
* Since MSDOS is not a preemptive multitasking OS, this table is not
|
||||
* protected from concurrent access. This hack doesn't work anyway on
|
||||
* a protected system like OS/2. Use Microsoft C instead.
|
||||
*/
|
||||
|
||||
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
||||
voidpf buf;
|
||||
ulg bsize = (ulg)items*size;
|
||||
|
||||
(void)opaque;
|
||||
|
||||
/* If we allocate less than 65520 bytes, we assume that farmalloc
|
||||
* will return a usable pointer which doesn't have to be normalized.
|
||||
*/
|
||||
if (bsize < 65520L) {
|
||||
buf = farmalloc(bsize);
|
||||
if (*(ush*)&buf != 0) return buf;
|
||||
} else {
|
||||
buf = farmalloc(bsize + 16L);
|
||||
}
|
||||
if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
|
||||
table[next_ptr].org_ptr = buf;
|
||||
|
||||
/* Normalize the pointer to seg:0 */
|
||||
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
|
||||
*(ush*)&buf = 0;
|
||||
table[next_ptr++].new_ptr = buf;
|
||||
return buf;
|
||||
}
|
||||
|
||||
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||
int n;
|
||||
|
||||
(void)opaque;
|
||||
|
||||
if (*(ush*)&ptr != 0) { /* object < 64K */
|
||||
farfree(ptr);
|
||||
return;
|
||||
}
|
||||
/* Find the original pointer */
|
||||
for (n = 0; n < next_ptr; n++) {
|
||||
if (ptr != table[n].new_ptr) continue;
|
||||
|
||||
farfree(table[n].org_ptr);
|
||||
while (++n < next_ptr) {
|
||||
table[n-1] = table[n];
|
||||
}
|
||||
next_ptr--;
|
||||
return;
|
||||
}
|
||||
Assert(0, "zcfree: ptr not found");
|
||||
}
|
||||
|
||||
#endif /* __TURBOC__ */
|
||||
|
||||
|
||||
#ifdef M_I86
|
||||
/* Microsoft C in 16-bit mode */
|
||||
|
||||
# define MY_ZCALLOC
|
||||
|
||||
#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
|
||||
# define _halloc halloc
|
||||
# define _hfree hfree
|
||||
#endif
|
||||
|
||||
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) {
|
||||
(void)opaque;
|
||||
return _halloc((long)items, size);
|
||||
}
|
||||
|
||||
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||
(void)opaque;
|
||||
_hfree(ptr);
|
||||
}
|
||||
|
||||
#endif /* M_I86 */
|
||||
|
||||
#endif /* SYS16BIT */
|
||||
|
||||
|
||||
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
||||
|
||||
#ifndef STDC
|
||||
extern voidp malloc(uInt size);
|
||||
extern voidp calloc(uInt items, uInt size);
|
||||
extern void free(voidpf ptr);
|
||||
#endif
|
||||
|
||||
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
||||
(void)opaque;
|
||||
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
||||
(voidpf)calloc(items, size);
|
||||
}
|
||||
|
||||
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||
(void)opaque;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#endif /* MY_ZCALLOC */
|
||||
|
||||
#endif /* !Z_SOLO */
|
||||
@@ -0,0 +1,254 @@
|
||||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZUTIL_H
|
||||
#define ZUTIL_H
|
||||
|
||||
#ifdef HAVE_HIDDEN
|
||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#else
|
||||
# define ZLIB_INTERNAL
|
||||
#endif
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#if defined(STDC) && !defined(Z_SOLO)
|
||||
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* since "static" is used to mean two completely different things in C, we
|
||||
define "local" for the non-static meaning of "static", for readability
|
||||
(compile with -Dlocal if your debugger can't find static symbols) */
|
||||
|
||||
typedef unsigned char uch;
|
||||
typedef uch FAR uchf;
|
||||
typedef unsigned short ush;
|
||||
typedef ush FAR ushf;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
|
||||
# include <limits.h>
|
||||
# if (ULONG_MAX == 0xffffffffffffffff)
|
||||
# define Z_U8 unsigned long
|
||||
# elif (ULLONG_MAX == 0xffffffffffffffff)
|
||||
# define Z_U8 unsigned long long
|
||||
# elif (UINT_MAX == 0xffffffffffffffff)
|
||||
# define Z_U8 unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
/* (size given to avoid silly warnings with Visual C++) */
|
||||
|
||||
#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
|
||||
|
||||
#define ERR_RETURN(strm,err) \
|
||||
return (strm->msg = ERR_MSG(err), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
|
||||
/* common constants */
|
||||
|
||||
#ifndef DEF_WBITS
|
||||
# define DEF_WBITS MAX_WBITS
|
||||
#endif
|
||||
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
||||
|
||||
#if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
#else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
#define STORED_BLOCK 0
|
||||
#define STATIC_TREES 1
|
||||
#define DYN_TREES 2
|
||||
/* The three kinds of block type */
|
||||
|
||||
#define MIN_MATCH 3
|
||||
#define MAX_MATCH 258
|
||||
/* The minimum and maximum match lengths */
|
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||
|
||||
/* target dependencies */
|
||||
|
||||
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
||||
# define OS_CODE 0x00
|
||||
# ifndef Z_SOLO
|
||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||
/* Allow compilation with ANSI keywords only enabled */
|
||||
void _Cdecl farfree( void *block );
|
||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||
# else
|
||||
# include <alloc.h>
|
||||
# endif
|
||||
# else /* MSC or DJGPP */
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef AMIGA
|
||||
# define OS_CODE 1
|
||||
#endif
|
||||
|
||||
#if defined(VAXC) || defined(VMS)
|
||||
# define OS_CODE 2
|
||||
# define F_OPEN(name, mode) \
|
||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||
#endif
|
||||
|
||||
#ifdef __370__
|
||||
# if __TARGET_LIB__ < 0x20000000
|
||||
# define OS_CODE 4
|
||||
# elif __TARGET_LIB__ < 0x40000000
|
||||
# define OS_CODE 11
|
||||
# else
|
||||
# define OS_CODE 8
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ATARI) || defined(atarist)
|
||||
# define OS_CODE 5
|
||||
#endif
|
||||
|
||||
#ifdef OS2
|
||||
# define OS_CODE 6
|
||||
# if defined(M_I86) && !defined(Z_SOLO)
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MACOS)
|
||||
# define OS_CODE 7
|
||||
#endif
|
||||
|
||||
#ifdef __acorn
|
||||
# define OS_CODE 13
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define OS_CODE 10
|
||||
#endif
|
||||
|
||||
#ifdef _BEOS_
|
||||
# define OS_CODE 16
|
||||
#endif
|
||||
|
||||
#ifdef __TOS_OS400__
|
||||
# define OS_CODE 18
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define OS_CODE 19
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||
#pragma warn -8004
|
||||
#pragma warn -8008
|
||||
#pragma warn -8066
|
||||
#endif
|
||||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
#if !defined(_WIN32) && \
|
||||
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
|
||||
#endif
|
||||
|
||||
/* common defaults */
|
||||
|
||||
#ifndef OS_CODE
|
||||
# define OS_CODE 3 /* assume Unix */
|
||||
#endif
|
||||
|
||||
#ifndef F_OPEN
|
||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||
#endif
|
||||
|
||||
/* functions */
|
||||
|
||||
#if defined(pyr) || defined(Z_SOLO)
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||
/* Use our own functions for small and medium model with MSC <= 5.0.
|
||||
* You may have to use the same strategy for Borland C (untested).
|
||||
* The __SC__ check is for Symantec.
|
||||
*/
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
||||
# define HAVE_MEMCPY
|
||||
#endif
|
||||
#ifdef HAVE_MEMCPY
|
||||
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
||||
# define zmemcpy _fmemcpy
|
||||
# define zmemcmp _fmemcmp
|
||||
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
||||
# else
|
||||
# define zmemcpy memcpy
|
||||
# define zmemcmp memcmp
|
||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||
# endif
|
||||
#else
|
||||
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len);
|
||||
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
|
||||
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len);
|
||||
#endif
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef ZLIB_DEBUG
|
||||
# include <stdio.h>
|
||||
extern int ZLIB_INTERNAL z_verbose;
|
||||
extern void ZLIB_INTERNAL z_error(char *m);
|
||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
||||
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
||||
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
||||
#else
|
||||
# define Assert(cond,msg)
|
||||
# define Trace(x)
|
||||
# define Tracev(x)
|
||||
# define Tracevv(x)
|
||||
# define Tracec(c,x)
|
||||
# define Tracecv(c,x)
|
||||
#endif
|
||||
|
||||
#ifndef Z_SOLO
|
||||
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items,
|
||||
unsigned size);
|
||||
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr);
|
||||
#endif
|
||||
|
||||
#define ZALLOC(strm, items, size) \
|
||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
|
||||
/* Reverse the bytes in a 32-bit value */
|
||||
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
||||
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||
|
||||
#endif /* ZUTIL_H */
|
||||
Reference in New Issue
Block a user