Compare commits
3 Commits
2abad7f2fa
...
27bfc069aa
Author | SHA1 | Date |
---|---|---|
Fanatic-64 | 27bfc069aa | |
Daniel Nylander | 4521389404 | |
Fanatic-64 | fb1b8c07ec |
|
@ -3,63 +3,69 @@
|
|||
*********************************************************************************/
|
||||
//About DLL
|
||||
#1 # "Svenska" // LANGUAGE ID
|
||||
#2 # "Arnalion (arnalion@hotmail.com)" // Author
|
||||
#3 # "1.0" // Version
|
||||
#4 # "September, 2005" // Date
|
||||
//#2 # "Arnalion (arnalion@hotmail.com)" // Original Author
|
||||
#2 # "Daniel Nylander (github@danielnylander.se)" // Reviewed and massive changes
|
||||
#3 # "3.0" // Version
|
||||
#4 # "January, 2025" // Date
|
||||
|
||||
//About DLL Dialog
|
||||
#5 # "Nuvarande Språk"
|
||||
#5 # "Aktuellt språk"
|
||||
#6 # "Översättare"
|
||||
#7 # "Version"
|
||||
#8 # "Datum"
|
||||
#9 # "Besök Hemsidan"
|
||||
#10 # "ROM Databas (.RDB)"
|
||||
#11 # "Fusk fil (.CHT)"
|
||||
#12 # "ROM Information (.RDX)"
|
||||
#9 # "Besök webbsidan"
|
||||
#10 # "ROM-databas (.RDB)"
|
||||
#11 # "Fuskfil (.CHT)"
|
||||
#12 # "ROM-information (.RDX)"
|
||||
|
||||
//About INI title
|
||||
#20 # "Om INI filer"
|
||||
#20 # "Om INI-filer"
|
||||
|
||||
/*********************************************************************************
|
||||
* Menu *
|
||||
*********************************************************************************/
|
||||
//File Menu
|
||||
#100# "&Fil"
|
||||
#101# "&Öppna N64 Fil"
|
||||
#102# "N64 Fil &Information...."
|
||||
#103# "Starta Emulering"
|
||||
#104# "&Avbryt Emulering"
|
||||
#105# "Välj Fil Katalog..."
|
||||
#106# "Uppdatera listan"
|
||||
#107# "Nuvarande N64 Fil"
|
||||
#108# "Nuvarande Fil Kataloger"
|
||||
#100# "&Arkiv"
|
||||
#101# "&Öppna ROM"
|
||||
#102# "ROM-&information...."
|
||||
#103# "Starta emulering"
|
||||
#104# "A&vsluta emulering"
|
||||
#105# "Välj ROM-katalog..."
|
||||
#106# "Uppdatera ROM-listan"
|
||||
#107# "Tidigare ROM"
|
||||
#108# "Tidigare ROM-kataloger"
|
||||
#109# "A&vsluta"
|
||||
#110# "Öppna &kombination"
|
||||
|
||||
//System Menu
|
||||
#120# "&System"
|
||||
#121# "&Starta om"
|
||||
#122# "&Pausa"
|
||||
#123# "Generera Bitmap"
|
||||
#124# "Begränsa FPS"
|
||||
#125# "&Spara"
|
||||
#126# "Spara Som..."
|
||||
#127# "&Återställ"
|
||||
#128# "Ladda..."
|
||||
#129# "Nuvarande Sparnings S&lot"
|
||||
#130# "Fusk..."
|
||||
#131# "GS Knapp"
|
||||
#132# "Fortsätt"
|
||||
#123# "Fånga skärmbild"
|
||||
#124# "Begränsa bildfrekvens"
|
||||
#125# "&Spara tillstånd"
|
||||
#126# "Spara som..."
|
||||
#127# "&Läs in tillstånd"
|
||||
#128# "Läs in..."
|
||||
#129# "Aktuellt sparat &tillstånd"
|
||||
#130# "&Fusk..."
|
||||
#131# "GS-knapp"
|
||||
#132# "Återup&pta"
|
||||
#133# "&Mjuk omstart"
|
||||
#134# "&Hård omstart"
|
||||
#135# "Byt &disk"
|
||||
#136# "&Förbättringar..."
|
||||
|
||||
//Options Menu
|
||||
#140# "&Alternativ"
|
||||
#141# "&Helskärm"
|
||||
#142# "&Alltid &Överst"
|
||||
#143# "Konfigurera Grafik Pluginen..."
|
||||
#144# "Konfigurera Ljud Pluginen..."
|
||||
#145# "Konfigurera Kontroll Pluginen..."
|
||||
#146# "Konfigurera RSP Pluginen..."
|
||||
#147# "Visa CPU Användning %"
|
||||
#148# "&Inställningar..."
|
||||
#142# "Alltid ö&verst"
|
||||
#143# "&Grafikinställningar"
|
||||
#144# "&Ljudinställningar"
|
||||
#145# "&Inmatningsinställningar"
|
||||
#146# "&RSP-inställningar"
|
||||
#147# "Visa CPU-&statistik"
|
||||
#148# "&Konfiguration"
|
||||
|
||||
//Debugger Menu
|
||||
#160# "&Debugger"
|
||||
|
@ -69,193 +75,262 @@
|
|||
|
||||
//Help Menu
|
||||
#180# "&Hjälp"
|
||||
#181# "Om &INI Filer"
|
||||
#182# "&Om Project 64"
|
||||
#183# "Support &Forum"
|
||||
#184# "&Hemsida"
|
||||
#182# "&Om Project64"
|
||||
#184# "&Webbsida"
|
||||
#185# "&Stöd Project64"
|
||||
#186# "&Discord"
|
||||
|
||||
//Current Save Slot menu
|
||||
#190# "Standard"
|
||||
#191# "Slot 1"
|
||||
#192# "Slot 2"
|
||||
#193# "Slot 3"
|
||||
#194# "Slot 4"
|
||||
#195# "Slot 5"
|
||||
#196# "Slot 6"
|
||||
#197# "Slot 7"
|
||||
#198# "Slot 8"
|
||||
#199# "Slot 9"
|
||||
#200# "Slot 10"
|
||||
#191# "Plats 1"
|
||||
#192# "Plats 2"
|
||||
#193# "Plats 3"
|
||||
#194# "Plats 4"
|
||||
#195# "Plats 5"
|
||||
#196# "Plats 6"
|
||||
#197# "Plats 7"
|
||||
#198# "Plats 8"
|
||||
#199# "Plats 9"
|
||||
#200# "Plats 10"
|
||||
#201# "Sparad plats (%ws) vald"
|
||||
|
||||
//Pop up Menu
|
||||
#210# "Starta Spel"
|
||||
#211# "N64 Fil Information"
|
||||
#212# "Ändra Spel Inställningar"
|
||||
#213# "Ändra Fusk"
|
||||
#210# "Starta spel"
|
||||
#211# "ROM-information"
|
||||
#212# "Redigera spelinställningar"
|
||||
#213# "Redigera fusk..."
|
||||
#214# "Grafikinsticksmodul"
|
||||
#215# "Spela spel med disk"
|
||||
#216# "Välj förbättringar..."
|
||||
|
||||
// Alternate name to save slot
|
||||
#220# "Sparad plats - Standard"
|
||||
#221# "Sparad plats - 1"
|
||||
#222# "Sparad plats - 2"
|
||||
#223# "Sparad plats - 3"
|
||||
#224# "Sparad plats - 4"
|
||||
#225# "Sparad plats - 5"
|
||||
#226# "Sparad plats - 6"
|
||||
#227# "Sparad plats - 7"
|
||||
#228# "Sparad plats - 8"
|
||||
#229# "Sparad plats - 9"
|
||||
#230# "Sparad plats - 10"
|
||||
|
||||
// Menu Descriptions
|
||||
#250# "Öppna en N64 fil"
|
||||
#251# "Visa information om den laddade N64 filen"
|
||||
#252# "Starta Emulering av den laddade N64 filen"
|
||||
#253# "Avbryt Emulering av den laddade N64 filen"
|
||||
#254# "Välj Fil Katalog"
|
||||
#255# "Uppdatera nuvarande lista av N64 filer i filhanteraren"
|
||||
#256# "Avsluta detta programmet"
|
||||
#257# "Starta om den nuvarande N64 filen"
|
||||
#258# "Pausa/Fortsätt emulering av den nuvarande spelet"
|
||||
#259# "Generera en Bitmap bild av den nuvarande skärmen"
|
||||
#260# "Begränsa FPS till N64 orginal hastigheten"
|
||||
#261# ""
|
||||
#262# ""
|
||||
#263# "Ladda snabb sparning"
|
||||
#264# ""
|
||||
#265# "Använd/Använd Inte Game shark fusk"
|
||||
#266# "Game shark knappen används för specefika fusk"
|
||||
#267# "Förstorar upp till helskärm"
|
||||
#268# "Gör att fönstret överlappar alla andra"
|
||||
#269# "Ändra inställningar i Grafik Pluginen"
|
||||
#270# "Ändra inställningar i Ljud Pluginen"
|
||||
#271# "Ändra inställningar i Kontroll Pluginen (ändra knappar)"
|
||||
#272# "Ändra inställningar i RSP Pluginen"
|
||||
#273# "Visar processor användning"
|
||||
#274# "Visa/Ändra inställningar för detta programmet"
|
||||
#275# "VIsa Manual för detta programmet"
|
||||
#276# "Visa FAQ för programmet"
|
||||
#278# "Om programmet och skaparna"
|
||||
#277# "Om skaparna av support filerna"
|
||||
#279# "Öppna den förra N64 filen"
|
||||
#280# "Välj den här katalogen för N64 filerna"
|
||||
#281# "Ändra programmet till detta språket"
|
||||
#282# "Välj snabbsparnings slot"
|
||||
#283# "Starta den valda N64 filen"
|
||||
#284# "Information om den valda N64 filen"
|
||||
#285# "Ändra Inställningar för den valda N64 filen"
|
||||
#286# "Ändra fusk för valda N64 filen"
|
||||
#250# "Öppna en N64 ROM-avbildning"
|
||||
#251# "Visa information om inläst avbildning"
|
||||
#252# "Starta emulering av inlästa ROM-avbildningen"
|
||||
#253# "Stoppa emulering av inlästa ROM-avbildningen"
|
||||
#254# "Välj ROM-katalog"
|
||||
#255# "Uppdatera aktuell lista över ROMar i ROM-bläddraren"
|
||||
#256# "Avsluta detta program"
|
||||
#257# "Starta om aktuella ROM-avbildningen (läs om alla inställningsändringar)"
|
||||
#258# "Pausa/återuppta emulering av aktuellt körande ROM"
|
||||
#259# "Generera en bitmap-bild av aktuell skärm"
|
||||
#260# "Begränsa bildfrekvens till korrekt hastighet för N64"
|
||||
#261# "Spara aktuellt systemtillstånd"
|
||||
#262# "Spara aktuellt systemtillstånd i en vald filplats"
|
||||
#263# "Läs in sparat systemtillstånd"
|
||||
#264# "Välj en sparad systemtillståndfil att läsa in"
|
||||
#265# "Aktivera/inaktivera GameShark-fusk"
|
||||
#266# "GameShark-knapp används med specifika fusk."
|
||||
#267# "Ändra emulering från fönster till helskärmsläge."
|
||||
#268# "Gör att fönstret ligger kvar över alla andra fönster"
|
||||
#269# "Ändra inställningar inne i grafikinsticksmodulen"
|
||||
#270# "Ändra inställningar inne i ljudinsticksmodulen"
|
||||
#271# "Ändra inställningar inne i insticksmodulen för handkontroller (t.ex ställ in knappar)"
|
||||
#272# "Ändra inställningar inne i RSP-insticksmodulen"
|
||||
#273# "Visa CPU-användning för emulerator uppdelat på olika resurser"
|
||||
#274# "Visa/ändra inställningar för detta program"
|
||||
#275# "Visa handboken för programmet"
|
||||
#276# "Visa frågor och svar för programmet"
|
||||
#278# "Om programmet och upphovspersonerna"
|
||||
#277# "Om upphovspersonerna för supportfilerna"
|
||||
#279# "Öppna denna tidigare öppnade ROM-avbildning"
|
||||
#280# "Välj denna katalog som din ROM-katalog"
|
||||
#281# "Byt till detta språk för programmet"
|
||||
#282# "Välj denna plats för att spara tillstånd till"
|
||||
#283# "Spela markerat spel"
|
||||
#284# "Information om markerat spel"
|
||||
#285# "Redigera inställningar för markerat spel"
|
||||
#286# "Redigera fusk för markerat spel"
|
||||
|
||||
|
||||
/*********************************************************************************
|
||||
* ROM Browser *
|
||||
*********************************************************************************/
|
||||
//ROM Browser Fields
|
||||
#300# "Fil Namn"
|
||||
#301# "Orginal Namn"
|
||||
#302# "Version Namn"
|
||||
#300# "Filnamn"
|
||||
#301# "Internt namn"
|
||||
#302# "Versionsnamn"
|
||||
#303# "Status"
|
||||
#304# "Fil Storlek"
|
||||
#304# "ROM-storlek"
|
||||
#305# "Anteckningar (kärna)"
|
||||
#306# "Anteckningar (standard plugins)"
|
||||
#306# "Anteckningar (standardinsticksmoduler)"
|
||||
#307# "Anteckningar (användare)"
|
||||
#308# "Förpacknings ID"
|
||||
#308# "Cartridge-id"
|
||||
#309# "Mediatyp"
|
||||
#310# "Land"
|
||||
#311# "Utvecklare"
|
||||
#312# "CRC1"
|
||||
#313# "CRC2"
|
||||
#314# "CIC Chip"
|
||||
#315# "Släppnings Datum"
|
||||
#316# "Kategori"
|
||||
#315# "Utgivningsdatum"
|
||||
#316# "Genre"
|
||||
#317# "Spelare"
|
||||
#318# "Tvinga Respons"
|
||||
#318# "Force Feedback"
|
||||
#319# "Filformat"
|
||||
#321# "Namn"
|
||||
|
||||
|
||||
//Select ROM
|
||||
#320# "Välj nuvarande fil katalog"
|
||||
#320# "Välj aktuell ROM-katalog"
|
||||
|
||||
//Messages
|
||||
#340# "Dålig N64 fil? Använd GoodN64 & leta efter uppdaterad RDB"
|
||||
#340# "Dålig ROM? Använd GoodN64 och leta efter uppdaterad RDB"
|
||||
|
||||
/*********************************************************************************
|
||||
* Options *
|
||||
*********************************************************************************/
|
||||
//Options Title
|
||||
#400# "Inställningar"
|
||||
#400# "Konfiguration"
|
||||
|
||||
//Tabs
|
||||
#401# "Plugins"
|
||||
#401# "Insticksmoduler"
|
||||
#402# "Kataloger"
|
||||
#403# "Alternativ"
|
||||
#404# "Val av N64 fil"
|
||||
#403# "Allmänna inställningar"
|
||||
#404# "ROM-bläddrare"
|
||||
#405# "Avancerat"
|
||||
#406# "N64 Fil Inställningar"
|
||||
#407# "Skal Integrering"
|
||||
#408# "N64 Fil Anteckningar"
|
||||
#406# "ROM-inställningar"
|
||||
#408# "Anteckningar"
|
||||
#409# "Snabbtangenter"
|
||||
#410# "Status"
|
||||
#411# "Omkompilerare"
|
||||
#412# "Standardvärden"
|
||||
#413# "64DD"
|
||||
#414# "64DD"
|
||||
|
||||
|
||||
//Plugin Dialog
|
||||
#420# "Om"
|
||||
#421# " Reality Signal Processor plugin: "
|
||||
#422# " Video (grafik) plugin: "
|
||||
#423# " Audio (ljud) plugin: "
|
||||
#424# " Kontroll (kontroll) plugin: "
|
||||
#421# " RSP-insticksmodul (Reality Signal Processor): "
|
||||
#422# " Videoinsticksmodul (grafik): "
|
||||
#423# " Ljudinsticksmodul (ljud): "
|
||||
#424# " Inmatningsinsticksmodul (handkontroller): "
|
||||
#425# "Grafik-HLE"
|
||||
#426# "Ljud-HLE"
|
||||
#427# "** Använd systeminsticksmodul **"
|
||||
|
||||
|
||||
//Directory Dialog
|
||||
#440# " Plugin Katalog:: "
|
||||
#441# " Fil Katalog: "
|
||||
#442# " N64 Auto sparning: "
|
||||
#443# " Direkt sparning: "
|
||||
#444# " Screen Shots: "
|
||||
#445# "Senaste Katalogen N64 filen var öppnad från."
|
||||
#446# "Välj Plugin Katalog"
|
||||
#447# "Välj Fil Katalog"
|
||||
#448# "Välj Automatisk sparnings Katalog"
|
||||
#449# "Välj Direkt sparnings Katalog"
|
||||
#450# "Välj snap shot Katalog"
|
||||
#440# " Insticksmodulskatalog: "
|
||||
#441# " ROM-katalog: "
|
||||
#442# " Sparkatalog för N64: "
|
||||
#443# " Katalog för sparade tillstånd: "
|
||||
#444# " Katalog för skärmbilder: "
|
||||
#445# "Senaste katalog som en ROM öppnades från"
|
||||
#446# "Välj insticksmodulskatalog"
|
||||
#447# "Välj ROM-katalog"
|
||||
#448# "Välj sparkatalog för N64"
|
||||
#449# "Välj katalog för sparade tillstånd"
|
||||
#450# "Välj katalog för skärmbilder"
|
||||
#451# " Katalog för texturpaket: "
|
||||
#452# "Välj katalog för texturpaket"
|
||||
|
||||
//Options Dialog
|
||||
#460# "Pausa emulering när fönstret är inaktivt?"
|
||||
#461# "När N64 filen laddas gå till helskärm"
|
||||
#462# "Göm Avancerade Inställningar"
|
||||
// Options (general) tab
|
||||
#460# "Pausa emulatorn när fönstret inte är aktivt"
|
||||
#461# "Gå in i helskärmsläget när en ROM läses in"
|
||||
#462# "Dölj avancerade inställningar"
|
||||
#463# "Kom ihåg valda fusk"
|
||||
#464# "Inaktivera skärmsläckare när en ROM körs"
|
||||
#465# "Visningshastighet"
|
||||
#466# "Hastighetsvisning:"
|
||||
#467# "Kontrollera om Project64 redan körs"
|
||||
#468# "Lagra spelsparningar i separata mappar"
|
||||
#469# "Sökväg för 64DD IPL ROM för japansk retail:"
|
||||
#470# "Sökväg för 64DD IPL ROM för amerikansk retail:"
|
||||
#471# "Sökväg för 64DD IPL ROM för utveckling:"
|
||||
#472# "Typ för disksparning:"
|
||||
#473# "Aktivera förbättringar"
|
||||
#474# "Visa statusrad"
|
||||
#475# "Avsluta helskärm när fokus flyttas"
|
||||
#476# "Aktivera Discord Rich Presence"
|
||||
|
||||
|
||||
//ROM Browser Tab
|
||||
#480# "Max # av filer ihågkomna (Max 10):"
|
||||
#481# "roms"
|
||||
#482# "Max # av fil kataloger ihågkomna (Max 10):"
|
||||
#483# "Kataloger"
|
||||
#484# "Använd Filhanteraren"
|
||||
#485# "Använd Katalog standard"
|
||||
#486# "Lediga Fält:"
|
||||
#487# "Visa Fält i denna ordning:"
|
||||
#480# "Max # ROMar som minns (0-10):"
|
||||
#481# "ROMar"
|
||||
#482# "Max # ROM-kataloger som minns (0-10):"
|
||||
#483# "kataloger"
|
||||
#484# "Använd ROM-bläddrare"
|
||||
#485# "Använd rekursiva kataloger"
|
||||
#486# "Tillgängliga fält:"
|
||||
#487# "Ordning för fälten:"
|
||||
#488# "Lägg till ->"
|
||||
#489# "<- Ta bort"
|
||||
#490# "Upp"
|
||||
#491# "Ner"
|
||||
#492# "Uppdatera automatiskt bläddraren"
|
||||
|
||||
|
||||
//Advanced Options
|
||||
#500# "Dom flesta av dom här ändringarna kommer inte att användas förren en ny N64 fil öppnas eller att den nuvarande N64 filen startas om."
|
||||
#501# "Kärna Standard"
|
||||
#502# "CPU Kärnans Typ:"
|
||||
#503# "Kod Metod:"
|
||||
#504# "Standard Minnes Storlek:"
|
||||
#505# "Avancerad Blockering:"
|
||||
#506# "Starta Emulering när N64 filen är öppnad?"
|
||||
#507# "Skriv alltid över standard inställningarna från INI filen?"
|
||||
#508# "Komprimera automatiskt direkt sparning"
|
||||
#500# "De flesta av dessa ändringarna kommer att användas när en ny ROM öppnas eller den aktuella ROMen startas om."
|
||||
#501# "Standardvärden för kärna"
|
||||
#502# "Typ av CPU-kärna:"
|
||||
#503# "Metoder för självmoddar:"
|
||||
#504# "Standardstorlek för minne:"
|
||||
#505# "Avancerad blocklänkning:"
|
||||
#506# "Starta emulering när ROM öppnas"
|
||||
#507# "Åsidosätt alltid standardinställningarna med de från RDB"
|
||||
#508# "Komprimera automatiskt sparade tillstånd"
|
||||
#509# "Aktivera felsökare"
|
||||
#510# "Cache"
|
||||
#511# "PI DMA"
|
||||
#512# "Starta ändrad"
|
||||
#513# "Skydda minnet"
|
||||
#514# "TLB unmapping"
|
||||
#515# "Använd alltid tolkningskärna"
|
||||
|
||||
//ROM Options
|
||||
#520# "CPU Kärnans Typ:"
|
||||
#521# "Kod Metod:"
|
||||
#522# "Minnes Storlek:"
|
||||
#523# "Avancerad Blockering:"
|
||||
#524# "Standard Sparnings typ:"
|
||||
#525# "Räkneverk:"
|
||||
#526# "Större Kompilerings Buffert"
|
||||
// ROM options
|
||||
#520# "Typ av CPU-kärna:"
|
||||
#521# "VI uppdateringsfrekvens:"
|
||||
#522# "Minnesstorlek:"
|
||||
#523# "Avancerad blocklänkning"
|
||||
#524# "Standardtyp för sparning:"
|
||||
#525# "Faktor för räknare:"
|
||||
#526# "Större kompileringsbuffert"
|
||||
#527# "Använd TLB"
|
||||
#528# "Registrera caching"
|
||||
#529# "Vänta Med SI Avbrytandet"
|
||||
#530# "SP Hack"
|
||||
#528# "Registrera cachning"
|
||||
#529# "Fördröj SI-avbrott"
|
||||
#530# "Snabb SP"
|
||||
#531# "Standard"
|
||||
#532# "RSP Ljud Signal"
|
||||
#532# "RSP-ljudsignal"
|
||||
#533# "Fast ljudtid"
|
||||
#534# "Metod för funktionsuppslag:"
|
||||
#535# "Metod för anpassade självmoddar"
|
||||
#536# "Synkronisera med ljud"
|
||||
#537# "AI-antal per byte:"
|
||||
#538# "32-bitars motor"
|
||||
#539# "Fördröj DP-avbrott"
|
||||
|
||||
//Core Styles
|
||||
#540# "Interpreter"
|
||||
#541# "Recompiler"
|
||||
#542# "Synkronisera Kärnorna"
|
||||
#540# "Tolk"
|
||||
#541# "Omkompilerare"
|
||||
#542# "Synkronisera kärnorna"
|
||||
|
||||
//Self Mod Methods
|
||||
#560# "Ingen"
|
||||
#561# "Cache"
|
||||
#562# "Skydda Minne"
|
||||
#563# "Kolla Minne & Cache"
|
||||
#564# "Ändra Minne & Cache"
|
||||
#565# "Kolla Avancerat Minne"
|
||||
#562# "Skydda minnet"
|
||||
#563# "Kontrollera minne och cache"
|
||||
#564# "Ändra minne och cache"
|
||||
#565# "Kontrollera memory advance"
|
||||
#566# "Töm kod vid cache"
|
||||
|
||||
// Function lookup method
|
||||
#570# "Fysisk uppslagstabell"
|
||||
#571# "Virtuell uppslagstabell"
|
||||
#572# "Ändra minnet"
|
||||
|
||||
//RDRAM Size
|
||||
#580# "4 MB"
|
||||
|
@ -266,161 +341,252 @@
|
|||
#601# "Av"
|
||||
|
||||
//Save Type
|
||||
#620# "Använd Första sparnings typ"
|
||||
#620# "Använd första använda sparningstyp"
|
||||
#621# "4-kbit EEPROM"
|
||||
#622# "16-kbit EEPROM"
|
||||
#623# "SRAM"
|
||||
#624# "Flash RAM"
|
||||
|
||||
//Shell Integration Tab
|
||||
#640# "Fil typ association:"
|
||||
// ROM notes
|
||||
#660# "ROM-status:"
|
||||
#661# "Kärnanteckning:"
|
||||
#662# "Insticksanteckning:"
|
||||
|
||||
//ROM Notes
|
||||
#660# "N64 Filens Status:"
|
||||
#661# "Kärna Anteckning:"
|
||||
#662# "Plugin Anteckning:"
|
||||
// Accelerator selector
|
||||
#680# "CPU-tillstånd:"
|
||||
#681# "Menypost:"
|
||||
#682# "Aktuella tangenter:"
|
||||
#683# "Välj ny genvägstangent:"
|
||||
#684# "För närvarande tilldelad till:"
|
||||
#685# "Tilldela"
|
||||
#686# "Ta bort"
|
||||
#687# "Nollställ alla"
|
||||
#688# "Spelet inte igång"
|
||||
#689# "Spelet är igång"
|
||||
#690# "Spelet är igång (fönsterläge)"
|
||||
#691# "Spelet är igång (helskärmsläge)"
|
||||
#692# "Upptäck tangenter"
|
||||
|
||||
/*********************************************************************************
|
||||
* ROM Information *
|
||||
*********************************************************************************/
|
||||
//ROM Info Title
|
||||
#800# "ROM Information"
|
||||
// Framerate option
|
||||
#700# "Vertikala avbrott per sekund"
|
||||
#701# "Visa listor per sekund"
|
||||
#702# "Procenttal av full hastighet"
|
||||
|
||||
//ROM Info Text
|
||||
#801# "N64 Filens Namn:"
|
||||
#802# "Fil typ Namn:"
|
||||
// Increase speed
|
||||
#710# "Öka spelhastigheten"
|
||||
#711# "Sänk spelhastigheten"
|
||||
|
||||
// Bottom page buttons
|
||||
#720# "Nollställ sida"
|
||||
#721# "Nollställ allt"
|
||||
#722# "Tillämpa"
|
||||
#723# "Stäng"
|
||||
|
||||
// Disk save type
|
||||
#730# "Fullständig diskkopia"
|
||||
#731# "Spara endast område"
|
||||
|
||||
/*** ROM information ***/
|
||||
#800# "ROM-information"
|
||||
|
||||
// ROM info text
|
||||
#801# "ROM-namn:"
|
||||
#802# "Filnamn:"
|
||||
#803# "Plats:"
|
||||
#804# "Fil Storlek:"
|
||||
#805# "Förpacknings ID"
|
||||
#804# "ROM-storlek:"
|
||||
#805# "Cartridge-id:"
|
||||
#806# "Mediatyp:"
|
||||
#807# "Land:"
|
||||
#808# "CRC1:"
|
||||
#809# "CRC2:"
|
||||
#810# "CIC Chip:"
|
||||
#811# "MD5:"
|
||||
|
||||
/*********************************************************************************
|
||||
* Cheats *
|
||||
*********************************************************************************/
|
||||
//Cheat List
|
||||
/*** Cheats ***/
|
||||
|
||||
// Cheat list
|
||||
#1000# "Fusk"
|
||||
#1001# "Fusk:"
|
||||
#1002# " Anteckning: "
|
||||
#1003# "Markera Alla"
|
||||
#1004# "Omakera Alla"
|
||||
#1002# " Anteckningar: "
|
||||
#1003# "Markera allt"
|
||||
#1004# "Avmarkera allt"
|
||||
|
||||
//Add Cheat
|
||||
#1005# "Lägg till Fusk"
|
||||
// Add cheat
|
||||
#1005# "Lägg till fusk"
|
||||
#1006# "Namn:"
|
||||
#1007# "Kod:"
|
||||
#1008# "Sätt in"
|
||||
#1009# "Rensa"
|
||||
#1010# " Fusk Anteckning: "
|
||||
#1011# "Lägg till i DB"
|
||||
#1022# "Lägg till Fusk"
|
||||
#1023# "Nya Fusk"
|
||||
#1024# "<address> <värde>"
|
||||
#1025# "Alternativ:"
|
||||
#1026# "<värde> <lager>"
|
||||
#1008# "Infoga"
|
||||
#1009# "Töm"
|
||||
#1010# " Fuskanteckningar: "
|
||||
#1011# "Lägg till i databas"
|
||||
|
||||
//Code extension
|
||||
#1012# "Kod typ"
|
||||
#1013# "Var vänlig att välja värde:"
|
||||
// Code extension
|
||||
#1012# "Kodtillägg"
|
||||
#1013# "Välj ett värde att användas för:"
|
||||
#1014# "OK"
|
||||
#1015# "Avbryt"
|
||||
|
||||
//Digital Value
|
||||
#1016# "Kvantitet Digit"
|
||||
#1017# "Var vänlig välj värde för:"
|
||||
// Digital value
|
||||
#1016# "Kvantitetssiffra"
|
||||
#1017# "Välj ett värde för:"
|
||||
#1018# "&Värde"
|
||||
#1019# "från"
|
||||
#1020# "till"
|
||||
#1021# "&Anteckning:"
|
||||
#1021# "A&nteckningar:"
|
||||
#1022# "Lägg till fusk"
|
||||
#1023# "Nytt fusk"
|
||||
#1024# "<adress> <värde>:<gammalt>"
|
||||
#1025# "Alternativ:"
|
||||
#1026# "<värde> <etikett>"
|
||||
|
||||
//Edit Cheat
|
||||
#1027# "Andra Fusk"
|
||||
#1028# "Uppdatera Fusk"
|
||||
// Edit cheat
|
||||
#1027# "Redigera fusk"
|
||||
#1028# "Uppdatera fusk"
|
||||
#1029# "Fusket har ändrats.\n\nVill du uppdatera?"
|
||||
#1030# "Fusket uppdaterades"
|
||||
|
||||
//Cheat Popup Menu
|
||||
// Cheat pop-up menu
|
||||
#1040# "Lägg till nytt fusk..."
|
||||
#1041# "Ändra"
|
||||
#1041# "Redigera"
|
||||
#1042# "Ta bort"
|
||||
|
||||
/*********************************************************************************
|
||||
* Messages *
|
||||
*********************************************************************************/
|
||||
#2000# "*** CPU PAUSED ***"
|
||||
#2001# "CPU Fortsatt"
|
||||
#2002# "I en permanent loop som inte kan avbrytas.
|
||||
Emulering kommer nu att avbrytas.
|
||||
// Shortcut editor
|
||||
#1100# "Nollställ genvägar"
|
||||
#1101# "Är du säker på att du vill nollställa genvägarna?\n\nDenna åtgärd går inte att ångra."
|
||||
#1102# "Filmeny"
|
||||
#1103# "Systemmeny"
|
||||
#1104# "Alternativ"
|
||||
#1105# "Sparningsplatser"
|
||||
|
||||
Verifiera fil och fil inställningar."
|
||||
#2003# "Misslyckades att hitta minne"
|
||||
#2004# "Standard pluginen eller nuvarande vald grafik plugin är saknad eller korrupt.
|
||||
/*** Support window ***/
|
||||
|
||||
Kolla så att du åtminstånde har en kompatible plugin i din plugin katalog."
|
||||
#2005# "Standard pluginen eller nuvarande vald ljud plugin är saknad eller korrupt.
|
||||
#1200# "Stöd Project64"
|
||||
#1201# "Project64 är en fri Nintendo 64-emulator byggd på öppen källkod.\n\nDen låter dig spela riktiga N64-program på samma sätt som det skulle vara i den ursprunliga konsollen.\n\nJag är ledsen för att visa denna ruta men behöver be dig vänta några sekunder för att njuta av resultatet av hundratals timmars arbete.\n\nOm du kan och vill ge ditt stöd till Project64 eller att du har fått nytta av det så ge gärna ditt stöd till Project64 antingen som ett tack eller din önskan att ta bort denna ruta.\n\nOm du har gett ditt stöd till Project64:"
|
||||
#1202# "Ange/begärd notifieringskod"
|
||||
#1203# "Stöd Project64"
|
||||
#1204# "Fortsätt"
|
||||
#1205# "Ange supportkoden"
|
||||
#1206# "Misslyckades med att validera koden\n\nFörsäkra dig om att koden i e-postmeddelandet matchar baserat på din maskin"
|
||||
#1207# "Tack"
|
||||
#1208# "Ange din supportkod"
|
||||
#1209# "Ange koden som du fick i din e-post.\n\nE-postmeddelandet kommer att skickas till e-postadress som du använde för Project64.\n\nNotera att koden endast fungerar för en unik maskin. ID för denna dator är:"
|
||||
#1210# "OK"
|
||||
#1211# "Avbryt"
|
||||
#1212# "Begär kod"
|
||||
#1213# "Koden har skickats till dig via e-post"
|
||||
#1214# "Misslyckades med att skicka koden. Försäkra dig om att din e-post är korrekt"
|
||||
|
||||
Kolla så att du åtminstånde har en kompatible plugin i din plugin katalog."
|
||||
#2006# "Standard pluginen eller nuvarande vald RSP plugin är saknad eller korrupt.
|
||||
/*** Enhancements ***/
|
||||
|
||||
Kolla så att du har Project64 korrekt installerad med en korrekt plugin katalog."
|
||||
#2007# "Standard pluginen eller nuvarande vald kontroll plugin är saknad eller korrupt.
|
||||
#1300# "Förbättringar"
|
||||
|
||||
Kolla så att du åtminstånde har en kompatible plugin i din plugin katalog."
|
||||
#2008# "Misslyckades med att ladda plugin:"
|
||||
#2009# "Misslyckade till att word
|
||||
/*** Messages ***/
|
||||
|
||||
Verify ROM and ROM Settings."
|
||||
#2010# "Misslyckade öppna den sparade filen"
|
||||
#2011# "Misslyckade öppna EEPROM"
|
||||
#2012# "Misslyckade öppna flash RAM"
|
||||
#2013# "Misslyckade öppna mempak"
|
||||
#2014# "Försök att öppna zip filen misslyckades.
|
||||
Saknad eller korrupt zip fil - kolla katalog och fil.
|
||||
|
||||
Du kanske måste starta om programmet."
|
||||
#2015# "Försök att öppna fil misslyckades."
|
||||
#2016# "Fel uppstod av öppnande av zip fil."
|
||||
#2017# "Den öppnade filen verkar inte va en korrekt N64 fil.
|
||||
|
||||
Verifiera dina N64 filer with GoodN64."
|
||||
#2000# "*** CPU PAUSAD ***"
|
||||
#2001# "CPU återupptagen"
|
||||
#2002# "I en permanent loop som inte kan avslutas.\nEmuleringen kommer nu att stoppas.\n\nVerifiera ROM och dess inställningar."
|
||||
#2003# "Misslyckades att allokera minne"
|
||||
#2004# "The default or selected video plugin is missing or invalid.\n\nYou need to go into Settings and select a video (graphics) plugin.\nCheck that you have at least one compatible plugin file in your plugin folder."
|
||||
#2005# "The default or selected audio plugin is missing or invalid.\n\nYou need to go into Settings and select a audio (sound) plugin.\nCheck that you have at least one compatible plugin file in your plugin folder."
|
||||
#2006# "The default or selected RSP plugin is missing or invalid.\n\nYou need to go into Settings and select a RSP (Reality Signal Processor) plugin.\nCheck that you have at least one compatible plugin file in your plugin folder."
|
||||
#2007# "The default or selected input plugin is missing or invalid.\n\nYou need to go into Settings and select an input (controller) plugin.\nCheck that you have at least one compatible plugin file in your plugin folder."
|
||||
#2008# "Failed to load plugin:"
|
||||
#2009# "Failed to load word.\n\nVerify ROM and its settings."
|
||||
#2010# "Failed to open save file"
|
||||
#2011# "Failed to open EEPROM"
|
||||
#2012# "Failed to open flash RAM"
|
||||
#2013# "Failed to open mempak"
|
||||
#2014# "Attempt to open zip file failed.\n\nProbably a corrupt zip file - try unzipping ROM manually."
|
||||
#2015# "Attempt to open file failed."
|
||||
#2016# "Error occurred when trying to open zip file."
|
||||
#2017# "File loaded does not appear to be a valid N64 ROM.\n\nVerify your ROMs with GoodN64."
|
||||
#2018# "Okänt land"
|
||||
#2019# "Okänt CIC chip"
|
||||
#2020# "Okänt fil format"
|
||||
#2021# "Okänt minnes aktion
|
||||
|
||||
Emulering är nu avbryten"
|
||||
#2022# "Ohanterlig R4300i OpCode på"
|
||||
#2023# "Stänger ner från ej kartlagt område.
|
||||
|
||||
Verifiera fil och fil inställingar."
|
||||
#2024# "Sparningen verkar inte matcha den nuvarande filen.
|
||||
|
||||
Sparningar måste vara sparade & loddade mellan 100% identiska filer,
|
||||
Regionen och versionen måste stämma överens med sparningen.
|
||||
Att ladda denna slotten kommer antagligen och/eller att få emulatorn att krasha.
|
||||
|
||||
Är du säker på att du vill fortsätta ladda filen?"
|
||||
#2019# "Unknown CIC chip"
|
||||
#2020# "Unknown file format"
|
||||
#2021# "Unknown memory action\n\nEmulation stopped"
|
||||
#2022# "Unhandled R4300i opcode at"
|
||||
#2023# "Executing from non-mapped space.\n\nVerify ROM and its settings."
|
||||
#2024# "This saved state does not appear to match the running ROM.\n\nStates must be saved & loaded between 100% identical ROMs.\nIn particular, the REGION and VERSION need to be the same.\nLoading this state is likely to cause the game and/or emulator to crash.\n\nAre you sure you want to continue loading?"
|
||||
#2025# "Fel"
|
||||
#2026# "Kopierings sekvensen inte funnen i LUT. Spelet kommer nu längre inte att fungera."
|
||||
#2027# "Kopierings skydds fel"
|
||||
#2028# "Att byta plugin kommer att få Project64 att starta om det starta spelet.
|
||||
Om du inte vill förlora spelet, välj nej och spara först.
|
||||
#2026# "Copyright sequence not found in LUT. Game will no longer function."
|
||||
#2027# "Copy Protection Failure"
|
||||
#2028# "Changing a plugin requires Project64 to reset a running ROM.\nIf you don't want to lose your place, answer No and save the current state first.\n\nChange plugins and reset ROM now?"
|
||||
#2029# "Change Plugins"
|
||||
#2030# "Emulation ended"
|
||||
#2031# "Emulation started"
|
||||
#2032# "Kunde inte läsa in tillstånd"
|
||||
#2033# "Läste in tillstånd"
|
||||
#2034# "Saved current state to"
|
||||
#2035# "State slot"
|
||||
#2036# "Byte-swapping image"
|
||||
#2037# "Väljer N64-avbildning"
|
||||
#2038# "Läste in"
|
||||
#2039# "Läser in avbildning"
|
||||
#2040# "Cannot open a ROM because plugins have not successfully initialized."
|
||||
#2041# "Är du säker på att du vill ta bort denna?"
|
||||
#2042# "Ta bort fusk"
|
||||
#2043# "Fusknamnet används redan."
|
||||
#2044# "You have reached the maximum amount of cheats for this ROM."
|
||||
#2045# "Plugin initializing"
|
||||
#2046# "You have not selected a virtual key to assign to the menu item."
|
||||
#2047# "You need to select a menu item to assign this key to."
|
||||
#2048# "Short-cut has already been assigned to another menu item."
|
||||
#2049# "No shortcut has been selected to be removed."
|
||||
#2050# "ROM loaded. Waiting for emulation to start."
|
||||
#2051# "Project64 beta versions are for members only.\n\nIf you have an account at www.pj64-emu.com, you should not be seeing this error!!\nPlease contact us on the site."
|
||||
#2052# "Programfel"
|
||||
#2053# "Failed to find filename in 7z file"
|
||||
#2054# "Graphics Low-Level Emulation"
|
||||
#2055# "Graphics LLE is not for general use!!!\nIt is advisable that you only use this for testing and not for playing games.\n\nChange to graphics LLE?"
|
||||
#2056# "Audio High-Level Emulation"
|
||||
#2057# "Audio HLE requires a third-party plugin!!!\nIf you do not use a third-party audio plugin that supports HLE, you will hear no sound.\n\nChange to audio HLE?"
|
||||
#2058# "File loaded does not appear to be a valid 64DD IPL ROM.\n\nVerify your ROMs with GoodN64."
|
||||
#2059# "Nintendo 64DD Japanese Retail IPL ROM not found.\nIt is required to play japanese region 64DD disk images.\n\nPlease select the required ROM in the Settings."
|
||||
#2061# "Nintendo 64DD American Retail IPL ROM not found.\nIt is required to play american region 64DD disk images.\n\nPlease select the required ROM in the Settings."
|
||||
#2062# "Nintendo 64DD Development IPL ROM not found.\nIt is required to play development 64DD disk images.\n\nPlease select the required ROM in the Settings."
|
||||
#2063# "Failed to update cheat, it is invalid"
|
||||
#2064# "Ogiltig fusk"
|
||||
|
||||
Byta plugin och starta om nu?"
|
||||
#2029# "Byta plugin"
|
||||
#2030# "Emulering avbryten"
|
||||
#2031# "Emulering startad"
|
||||
#2032# "Oförmögen att ladda sparning"
|
||||
#2033# "Laddad sparnings slot"
|
||||
#2034# "Spara nuvarande läge till"
|
||||
#2035# "sparnings slot"
|
||||
#2036# "Byte uppdaterande fil"
|
||||
#2037# "Val av N64 fil"
|
||||
#2038# "Laddad"
|
||||
#2039# "Laddar fil"
|
||||
#2040# "Kan inte öppna filen på grund av att grafik pluginen inte är helt OK"
|
||||
#2041# "Är du säker på att du vill ta bort det?"
|
||||
#2042# "Borttagna fusk"
|
||||
#2043# "Fuskets namn används redan"
|
||||
#2044# "Du har nåt max antalet av fusk för detta spelet"
|
||||
/*** Android ***/
|
||||
|
||||
#3000# "Inställningar"
|
||||
#3001# "Hjälp/Forum"
|
||||
#3002# "Rapportera fel"
|
||||
#3003# "Om"
|
||||
#3004# "Tidigare spelade"
|
||||
#3005# "Spel"
|
||||
#3006# "Spelkatalog"
|
||||
#3007# "Välj en mapp att söka igenom"
|
||||
#3008# "Inkludera underkataloger"
|
||||
#3009# "Föräldramapp"
|
||||
#3010# "Kataloger"
|
||||
#3011# "Internt minne"
|
||||
#3012# "Söker igenom..."
|
||||
#3013# "OK"
|
||||
#3014# "Avbryt"
|
||||
#3015# "Information"
|
||||
#3016# "Project64 för Android"
|
||||
#3017# "Licens"
|
||||
#3018# "Revision"
|
||||
#3019# "Project64 för Android\u2122 är en portering av Windows-versionen av Project64. Android\u2122-versionen kan spela de flesta N64-spel."
|
||||
#3020# "Upphovspersoner för Project64."
|
||||
#3021# "Discord"
|
||||
|
||||
// In-game menu
|
||||
#3100# "Inställningar"
|
||||
#3101# "Spara tillstånd"
|
||||
#3102# "Läs in tillstånd"
|
||||
#3103# "Avsluta emulering"
|
||||
#3104# "Pausa"
|
||||
#3105# "Återuppta"
|
||||
#3106# "Spelhastighet"
|
||||
#3107# "Aktuellt sparat tillstånd..."
|
||||
#3108# "Auto"
|
||||
#3109# "Plats"
|
||||
#3110# "Starta om"
|
||||
#3111# "Felsökningsalternativ"
|
||||
#3112# "Nollställ funktionstider"
|
||||
#3113# "Dumpa funktionstider"
|
||||
|
||||
// Video plugin
|
||||
#3200# "Inbyggd"
|
||||
|
|
|
@ -1,6 +1,109 @@
|
|||
|
||||
ChangeLog file for zlib
|
||||
|
||||
Changes in 1.3.1 (22 Jan 2024)
|
||||
- Reject overflows of zip header fields in minizip
|
||||
- Fix bug in inflateSync() for data held in bit buffer
|
||||
- Add LIT_MEM define to use more memory for a small deflate speedup
|
||||
- Fix decision on the emission of Zip64 end records in minizip
|
||||
- Add bounds checking to ERR_MSG() macro, used by zError()
|
||||
- Neutralize zip file traversal attacks in miniunz
|
||||
- Fix a bug in ZLIB_DEBUG compiles in check_match()
|
||||
- Various portability and appearance improvements
|
||||
|
||||
Changes in 1.3 (18 Aug 2023)
|
||||
- Remove K&R function definitions and zlib2ansi
|
||||
- Fix bug in deflateBound() for level 0 and memLevel 9
|
||||
- Fix bug when gzungetc() is used immediately after gzopen()
|
||||
- Fix bug when using gzflush() with a very small buffer
|
||||
- Fix crash when gzsetparams() attempted for transparent write
|
||||
- Fix test/example.c to work with FORCE_STORED
|
||||
- Rewrite of zran in examples (see zran.c version history)
|
||||
- Fix minizip to allow it to open an empty zip file
|
||||
- Fix reading disk number start on zip64 files in minizip
|
||||
- Fix logic error in minizip argument processing
|
||||
- Add minizip testing to Makefile
|
||||
- Read multiple bytes instead of byte-by-byte in minizip unzip.c
|
||||
- Add memory sanitizer to configure (--memory)
|
||||
- Various portability improvements
|
||||
- Various documentation improvements
|
||||
- Various spelling and typo corrections
|
||||
|
||||
Changes in 1.2.13 (13 Oct 2022)
|
||||
- Fix configure issue that discarded provided CC definition
|
||||
- Correct incorrect inputs provided to the CRC functions
|
||||
- Repair prototypes and exporting of new CRC functions
|
||||
- Fix inflateBack to detect invalid input with distances too far
|
||||
- Have infback() deliver all of the available output up to any error
|
||||
- Fix a bug when getting a gzip header extra field with inflate()
|
||||
- Fix bug in block type selection when Z_FIXED used
|
||||
- Tighten deflateBound bounds
|
||||
- Remove deleted assembler code references
|
||||
- Various portability and appearance improvements
|
||||
|
||||
Changes in 1.2.12 (27 Mar 2022)
|
||||
- Cygwin does not have _wopen(), so do not create gzopen_w() there
|
||||
- Permit a deflateParams() parameter change as soon as possible
|
||||
- Limit hash table inserts after switch from stored deflate
|
||||
- Fix bug when window full in deflate_stored()
|
||||
- Fix CLEAR_HASH macro to be usable as a single statement
|
||||
- Avoid a conversion error in gzseek when off_t type too small
|
||||
- Have Makefile return non-zero error code on test failure
|
||||
- Avoid some conversion warnings in gzread.c and gzwrite.c
|
||||
- Update use of errno for newer Windows CE versions
|
||||
- Small speedup to inflate [psumbera]
|
||||
- Return an error if the gzputs string length can't fit in an int
|
||||
- Add address checking in clang to -w option of configure
|
||||
- Don't compute check value for raw inflate if asked to validate
|
||||
- Handle case where inflateSync used when header never processed
|
||||
- Avoid the use of ptrdiff_t
|
||||
- Avoid an undefined behavior of memcpy() in gzappend()
|
||||
- Avoid undefined behaviors of memcpy() in gz*printf()
|
||||
- Avoid an undefined behavior of memcpy() in _tr_stored_block()
|
||||
- Make the names in functions declarations identical to definitions
|
||||
- Remove old assembler code in which bugs have manifested
|
||||
- Fix deflateEnd() to not report an error at start of raw deflate
|
||||
- Add legal disclaimer to README
|
||||
- Emphasize the need to continue decompressing gzip members
|
||||
- Correct the initialization requirements for deflateInit2()
|
||||
- Fix a bug that can crash deflate on some input when using Z_FIXED
|
||||
- Assure that the number of bits for deflatePrime() is valid
|
||||
- Use a structure to make globals in enough.c evident
|
||||
- Use a macro for the printf format of big_t in enough.c
|
||||
- Clean up code style in enough.c, update version
|
||||
- Use inline function instead of macro for index in enough.c
|
||||
- Clarify that prefix codes are counted in enough.c
|
||||
- Show all the codes for the maximum tables size in enough.c
|
||||
- Add gznorm.c example, which normalizes gzip files
|
||||
- Fix the zran.c example to work on a multiple-member gzip file
|
||||
- Add tables for crc32_combine(), to speed it up by a factor of 200
|
||||
- Add crc32_combine_gen() and crc32_combine_op() for fast combines
|
||||
- Speed up software CRC-32 computation by a factor of 1.5 to 3
|
||||
- Use atomic test and set, if available, for dynamic CRC tables
|
||||
- Don't bother computing check value after successful inflateSync()
|
||||
- Correct comment in crc32.c
|
||||
- Add use of the ARMv8 crc32 instructions when requested
|
||||
- Use ARM crc32 instructions if the ARM architecture has them
|
||||
- Explicitly note that the 32-bit check values are 32 bits
|
||||
- Avoid adding empty gzip member after gzflush with Z_FINISH
|
||||
- Fix memory leak on error in gzlog.c
|
||||
- Fix error in comment on the polynomial representation of a byte
|
||||
- Clarify gz* function interfaces, referring to parameter names
|
||||
- Change macro name in inflate.c to avoid collision in VxWorks
|
||||
- Correct typo in blast.c
|
||||
- Improve portability of contrib/minizip
|
||||
- Fix indentation in minizip's zip.c
|
||||
- Replace black/white with allow/block. (theresa-m)
|
||||
- minizip warning fix if MAXU32 already defined. (gvollant)
|
||||
- Fix unztell64() in minizip to work past 4GB. (Daniël Hörchner)
|
||||
- Clean up minizip to reduce warnings for testing
|
||||
- Add fallthrough comments for gcc
|
||||
- Eliminate use of ULL constants
|
||||
- Separate out address sanitizing from warnings in configure
|
||||
- Remove destructive aspects of make distclean
|
||||
- Check for cc masquerading as gcc or clang in configure
|
||||
- Fix crc32.c to compile local functions only if used
|
||||
|
||||
Changes in 1.2.11 (15 Jan 2017)
|
||||
- Fix deflate stored bug when pulling last block from window
|
||||
- Permit immediate deflateParams changes before any deflate input
|
||||
|
@ -96,7 +199,7 @@ Changes in 1.2.7.1 (24 Mar 2013)
|
|||
- Fix types in contrib/minizip to match result of get_crc_table()
|
||||
- Simplify contrib/vstudio/vc10 with 'd' suffix
|
||||
- Add TOP support to win32/Makefile.msc
|
||||
- Suport i686 and amd64 assembler builds in CMakeLists.txt
|
||||
- Support i686 and amd64 assembler builds in CMakeLists.txt
|
||||
- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h
|
||||
- Add vc11 and vc12 build files to contrib/vstudio
|
||||
- Add gzvprintf() as an undocumented function in zlib
|
||||
|
@ -296,14 +399,14 @@ Changes in 1.2.5.1 (10 Sep 2011)
|
|||
- Use u4 type for crc_table to avoid conversion warnings
|
||||
- Apply casts in zlib.h to avoid conversion warnings
|
||||
- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller]
|
||||
- Improve inflateSync() documentation to note indeterminancy
|
||||
- Improve inflateSync() documentation to note indeterminacy
|
||||
- Add deflatePending() function to return the amount of pending output
|
||||
- Correct the spelling of "specification" in FAQ [Randers-Pehrson]
|
||||
- Add a check in configure for stdarg.h, use for gzprintf()
|
||||
- Check that pointers fit in ints when gzprint() compiled old style
|
||||
- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler]
|
||||
- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt]
|
||||
- Add debug records in assmebler code [Londer]
|
||||
- Add debug records in assembler code [Londer]
|
||||
- Update RFC references to use http://tools.ietf.org/html/... [Li]
|
||||
- Add --archs option, use of libtool to configure for Mac OS X [Borstel]
|
||||
|
||||
|
@ -511,7 +614,7 @@ Changes in 1.2.3.5 (8 Jan 2010)
|
|||
- Don't use _vsnprintf on later versions of MSVC [Lowman]
|
||||
- Add CMake build script and input file [Lowman]
|
||||
- Update contrib/minizip to 1.1 [Svensson, Vollant]
|
||||
- Moved nintendods directory from contrib to .
|
||||
- Moved nintendods directory from contrib to root
|
||||
- Replace gzio.c with a new set of routines with the same functionality
|
||||
- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above
|
||||
- Update contrib/minizip to 1.1b
|
||||
|
@ -685,7 +788,7 @@ Changes in 1.2.2.4 (11 July 2005)
|
|||
- Be more strict on incomplete code sets in inflate_table() and increase
|
||||
ENOUGH and MAXD -- this repairs a possible security vulnerability for
|
||||
invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for
|
||||
discovering the vulnerability and providing test cases.
|
||||
discovering the vulnerability and providing test cases
|
||||
- Add ia64 support to configure for HP-UX [Smith]
|
||||
- Add error return to gzread() for format or i/o error [Levin]
|
||||
- Use malloc.h for OS/2 [Necasek]
|
||||
|
@ -721,7 +824,7 @@ Changes in 1.2.2.2 (30 December 2004)
|
|||
- Add Z_FIXED strategy option to deflateInit2() to force fixed trees
|
||||
- Add updated make_vms.com [Coghlan], update README
|
||||
- Create a new "examples" directory, move gzappend.c there, add zpipe.c,
|
||||
fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html.
|
||||
fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html
|
||||
- Add FAQ entry and comments in deflate.c on uninitialized memory access
|
||||
- Add Solaris 9 make options in configure [Gilbert]
|
||||
- Allow strerror() usage in gzio.c for STDC
|
||||
|
@ -792,7 +895,7 @@ Changes in 1.2.1.1 (9 January 2004)
|
|||
- Fix a big fat bug in inftrees.c that prevented decoding valid
|
||||
dynamic blocks with only literals and no distance codes --
|
||||
Thanks to "Hot Emu" for the bug report and sample file
|
||||
- Add a note to puff.c on no distance codes case.
|
||||
- Add a note to puff.c on no distance codes case
|
||||
|
||||
Changes in 1.2.1 (17 November 2003)
|
||||
- Remove a tab in contrib/gzappend/gzappend.c
|
||||
|
@ -970,7 +1073,7 @@ Changes in 1.2.0.1 (17 March 2003)
|
|||
- Include additional header file on VMS for off_t typedef
|
||||
- Try to use _vsnprintf where it supplants vsprintf [Vollant]
|
||||
- Add some casts in inffast.c
|
||||
- Enchance comments in zlib.h on what happens if gzprintf() tries to
|
||||
- Enhance comments in zlib.h on what happens if gzprintf() tries to
|
||||
write more than 4095 bytes before compression
|
||||
- Remove unused state from inflateBackEnd()
|
||||
- Remove exit(0) from minigzip.c, example.c
|
||||
|
@ -1036,14 +1139,14 @@ Changes in 1.2.0 (9 March 2003)
|
|||
- Add contrib/puff/ simple inflate for deflate format description
|
||||
|
||||
Changes in 1.1.4 (11 March 2002)
|
||||
- ZFREE was repeated on same allocation on some error conditions.
|
||||
- ZFREE was repeated on same allocation on some error conditions
|
||||
This creates a security problem described in
|
||||
http://www.zlib.org/advisory-2002-03-11.txt
|
||||
- Returned incorrect error (Z_MEM_ERROR) on some invalid data
|
||||
- Avoid accesses before window for invalid distances with inflate window
|
||||
less than 32K.
|
||||
less than 32K
|
||||
- force windowBits > 8 to avoid a bug in the encoder for a window size
|
||||
of 256 bytes. (A complete fix will be available in 1.1.5).
|
||||
of 256 bytes. (A complete fix will be available in 1.1.5)
|
||||
|
||||
Changes in 1.1.3 (9 July 1998)
|
||||
- fix "an inflate input buffer bug that shows up on rare but persistent
|
||||
|
@ -1117,7 +1220,7 @@ Changes in 1.1.1 (27 Feb 98)
|
|||
- remove block truncation heuristic which had very marginal effect for zlib
|
||||
(smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
|
||||
compression ratio on some files. This also allows inlining _tr_tally for
|
||||
matches in deflate_slow.
|
||||
matches in deflate_slow
|
||||
- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
|
||||
|
||||
Changes in 1.1.0 (24 Feb 98)
|
||||
|
@ -1148,7 +1251,7 @@ Changes in 1.0.9 (17 Feb 1998)
|
|||
- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8
|
||||
- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)
|
||||
- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with
|
||||
the declaration of FAR (Gilles VOllant)
|
||||
the declaration of FAR (Gilles Vollant)
|
||||
- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)
|
||||
- read_buf buf parameter of type Bytef* instead of charf*
|
||||
- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)
|
||||
|
@ -1162,7 +1265,7 @@ Changes in 1.0.8 (27 Jan 1998)
|
|||
- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
|
||||
- use constant arrays for the static trees in trees.c instead of computing
|
||||
them at run time (thanks to Ken Raeburn for this suggestion). To create
|
||||
trees.h, compile with GEN_TREES_H and run "make test".
|
||||
trees.h, compile with GEN_TREES_H and run "make test"
|
||||
- check return code of example in "make test" and display result
|
||||
- pass minigzip command line options to file_compress
|
||||
- simplifying code of inflateSync to avoid gcc 2.8 bug
|
||||
|
@ -1201,12 +1304,12 @@ Changes in 1.0.6 (19 Jan 1998)
|
|||
- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
|
||||
gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
|
||||
- Fix a deflate bug occurring only with compression level 0 (thanks to
|
||||
Andy Buckler for finding this one).
|
||||
- In minigzip, pass transparently also the first byte for .Z files.
|
||||
Andy Buckler for finding this one)
|
||||
- In minigzip, pass transparently also the first byte for .Z files
|
||||
- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
|
||||
- check Z_FINISH in inflate (thanks to Marc Schluper)
|
||||
- Implement deflateCopy (thanks to Adam Costello)
|
||||
- make static libraries by default in configure, add --shared option.
|
||||
- make static libraries by default in configure, add --shared option
|
||||
- move MSDOS or Windows specific files to directory msdos
|
||||
- suppress the notion of partial flush to simplify the interface
|
||||
(but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)
|
||||
|
@ -1218,7 +1321,7 @@ Changes in 1.0.6 (19 Jan 1998)
|
|||
- added Makefile.nt (thanks to Stephen Williams)
|
||||
- added the unsupported "contrib" directory:
|
||||
contrib/asm386/ by Gilles Vollant <info@winimage.com>
|
||||
386 asm code replacing longest_match().
|
||||
386 asm code replacing longest_match()
|
||||
contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
|
||||
A C++ I/O streams interface to the zlib gz* functions
|
||||
contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
|
||||
|
@ -1226,7 +1329,7 @@ Changes in 1.0.6 (19 Jan 1998)
|
|||
contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
|
||||
A very simple tar.gz file extractor using zlib
|
||||
contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
|
||||
How to use compress(), uncompress() and the gz* functions from VB.
|
||||
How to use compress(), uncompress() and the gz* functions from VB
|
||||
- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression
|
||||
level) in minigzip (thanks to Tom Lane)
|
||||
|
||||
|
@ -1235,8 +1338,8 @@ Changes in 1.0.6 (19 Jan 1998)
|
|||
- add undocumented function inflateSyncPoint() (hack for Paul Mackerras)
|
||||
- add undocumented function zError to convert error code to string
|
||||
(for Tim Smithers)
|
||||
- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code.
|
||||
- Use default memcpy for Symantec MSDOS compiler.
|
||||
- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code
|
||||
- Use default memcpy for Symantec MSDOS compiler
|
||||
- Add EXPORT keyword for check_func (needed for Windows DLL)
|
||||
- add current directory to LD_LIBRARY_PATH for "make test"
|
||||
- create also a link for libz.so.1
|
||||
|
@ -1249,7 +1352,7 @@ Changes in 1.0.6 (19 Jan 1998)
|
|||
- allow compilation with ANSI keywords only enabled for TurboC in large model
|
||||
- avoid "versionString"[0] (Borland bug)
|
||||
- add NEED_DUMMY_RETURN for Borland
|
||||
- use variable z_verbose for tracing in debug mode (L. Peter Deutsch).
|
||||
- use variable z_verbose for tracing in debug mode (L. Peter Deutsch)
|
||||
- allow compilation with CC
|
||||
- defined STDC for OS/2 (David Charlap)
|
||||
- limit external names to 8 chars for MVS (Thomas Lund)
|
||||
|
@ -1259,7 +1362,7 @@ Changes in 1.0.6 (19 Jan 1998)
|
|||
- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)
|
||||
- added makelcc.bat for lcc-win32 (Tom St Denis)
|
||||
- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
|
||||
- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion.
|
||||
- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion
|
||||
- check for unistd.h in configure (for off_t)
|
||||
- remove useless check parameter in inflate_blocks_free
|
||||
- avoid useless assignment of s->check to itself in inflate_blocks_new
|
||||
|
@ -1280,7 +1383,7 @@ Changes in 1.0.5 (3 Jan 98)
|
|||
Changes in 1.0.4 (24 Jul 96)
|
||||
- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
|
||||
bit, so the decompressor could decompress all the correct data but went
|
||||
on to attempt decompressing extra garbage data. This affected minigzip too.
|
||||
on to attempt decompressing extra garbage data. This affected minigzip too
|
||||
- zlibVersion and gzerror return const char* (needed for DLL)
|
||||
- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
|
||||
- use z_error only for DEBUG (avoid problem with DLLs)
|
||||
|
@ -1310,7 +1413,7 @@ Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
|
|||
- fix array overlay in deflate.c which sometimes caused bad compressed data
|
||||
- fix inflate bug with empty stored block
|
||||
- fix MSDOS medium model which was broken in 0.99
|
||||
- fix deflateParams() which could generate bad compressed data.
|
||||
- fix deflateParams() which could generate bad compressed data
|
||||
- Bytef is define'd instead of typedef'ed (work around Borland bug)
|
||||
- added an INDEX file
|
||||
- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
|
||||
|
@ -1331,7 +1434,7 @@ Changes in 0.99 (27 Jan 96)
|
|||
- allow preset dictionary shared between compressor and decompressor
|
||||
- allow compression level 0 (no compression)
|
||||
- add deflateParams in zlib.h: allow dynamic change of compression level
|
||||
and compression strategy.
|
||||
and compression strategy
|
||||
- test large buffers and deflateParams in example.c
|
||||
- add optional "configure" to build zlib as a shared library
|
||||
- suppress Makefile.qnx, use configure instead
|
||||
|
@ -1370,33 +1473,33 @@ Changes in 0.99 (27 Jan 96)
|
|||
- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
|
||||
- in fcalloc, normalize pointer if size > 65520 bytes
|
||||
- don't use special fcalloc for 32 bit Borland C++
|
||||
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
|
||||
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc.
|
||||
- use Z_BINARY instead of BINARY
|
||||
- document that gzclose after gzdopen will close the file
|
||||
- allow "a" as mode in gzopen.
|
||||
- allow "a" as mode in gzopen
|
||||
- fix error checking in gzread
|
||||
- allow skipping .gz extra-field on pipes
|
||||
- added reference to Perl interface in README
|
||||
- put the crc table in FAR data (I dislike more and more the medium model :)
|
||||
- added get_crc_table
|
||||
- added a dimension to all arrays (Borland C can't count).
|
||||
- added a dimension to all arrays (Borland C can't count)
|
||||
- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast
|
||||
- guard against multiple inclusion of *.h (for precompiled header on Mac)
|
||||
- Watcom C pretends to be Microsoft C small model even in 32 bit mode.
|
||||
- Watcom C pretends to be Microsoft C small model even in 32 bit mode
|
||||
- don't use unsized arrays to avoid silly warnings by Visual C++:
|
||||
warning C4746: 'inflate_mask' : unsized array treated as '__far'
|
||||
(what's wrong with far data in far model?).
|
||||
(what's wrong with far data in far model?)
|
||||
- define enum out of inflate_blocks_state to allow compilation with C++
|
||||
|
||||
Changes in 0.95 (16 Aug 95)
|
||||
- fix MSDOS small and medium model (now easier to adapt to any compiler)
|
||||
- inlined send_bits
|
||||
- fix the final (:-) bug for deflate with flush (output was correct but
|
||||
not completely flushed in rare occasions).
|
||||
not completely flushed in rare occasions)
|
||||
- default window size is same for compression and decompression
|
||||
(it's now sufficient to set MAX_WBITS in zconf.h).
|
||||
(it's now sufficient to set MAX_WBITS in zconf.h)
|
||||
- voidp -> voidpf and voidnp -> voidp (for consistency with other
|
||||
typedefs and because voidnp was not near in large model).
|
||||
typedefs and because voidnp was not near in large model)
|
||||
|
||||
Changes in 0.94 (13 Aug 95)
|
||||
- support MSDOS medium model
|
||||
|
@ -1405,12 +1508,12 @@ Changes in 0.94 (13 Aug 95)
|
|||
- added support for VMS
|
||||
- allow a compression level in gzopen()
|
||||
- gzflush now calls fflush
|
||||
- For deflate with flush, flush even if no more input is provided.
|
||||
- For deflate with flush, flush even if no more input is provided
|
||||
- rename libgz.a as libz.a
|
||||
- avoid complex expression in infcodes.c triggering Turbo C bug
|
||||
- work around a problem with gcc on Alpha (in INSERT_STRING)
|
||||
- don't use inline functions (problem with some gcc versions)
|
||||
- allow renaming of Byte, uInt, etc... with #define.
|
||||
- allow renaming of Byte, uInt, etc... with #define
|
||||
- avoid warning about (unused) pointer before start of array in deflate.c
|
||||
- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c
|
||||
- avoid reserved word 'new' in trees.c
|
||||
|
@ -1429,7 +1532,7 @@ Changes in 0.92 (3 May 95)
|
|||
- no memcpy on Pyramid
|
||||
- suppressed inftest.c
|
||||
- optimized fill_window, put longest_match inline for gcc
|
||||
- optimized inflate on stored blocks.
|
||||
- optimized inflate on stored blocks
|
||||
- untabify all sources to simplify patches
|
||||
|
||||
Changes in 0.91 (2 May 95)
|
||||
|
@ -1447,7 +1550,7 @@ Changes in 0.9 (1 May 95)
|
|||
- let again gzread copy uncompressed data unchanged (was working in 0.71)
|
||||
- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
|
||||
- added a test of inflateSync in example.c
|
||||
- moved MAX_WBITS to zconf.h because users might want to change that.
|
||||
- moved MAX_WBITS to zconf.h because users might want to change that
|
||||
- document explicitly that zalloc(64K) on MSDOS must return a normalized
|
||||
pointer (zero offset)
|
||||
- added Makefiles for Microsoft C, Turbo C, Borland C++
|
||||
|
@ -1456,7 +1559,7 @@ Changes in 0.9 (1 May 95)
|
|||
Changes in 0.8 (29 April 95)
|
||||
- added fast inflate (inffast.c)
|
||||
- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this
|
||||
is incompatible with previous versions of zlib which returned Z_OK.
|
||||
is incompatible with previous versions of zlib which returned Z_OK
|
||||
- work around a TurboC compiler bug (bad code for b << 0, see infutil.h)
|
||||
(actually that was not a compiler bug, see 0.81 above)
|
||||
- gzread no longer reads one extra byte in certain cases
|
||||
|
@ -1466,50 +1569,50 @@ Changes in 0.8 (29 April 95)
|
|||
|
||||
Changes in 0.71 (14 April 95)
|
||||
- Fixed more MSDOS compilation problems :( There is still a bug with
|
||||
TurboC large model.
|
||||
TurboC large model
|
||||
|
||||
Changes in 0.7 (14 April 95)
|
||||
- Added full inflate support.
|
||||
- Added full inflate support
|
||||
- Simplified the crc32() interface. The pre- and post-conditioning
|
||||
(one's complement) is now done inside crc32(). WARNING: this is
|
||||
incompatible with previous versions; see zlib.h for the new usage.
|
||||
incompatible with previous versions; see zlib.h for the new usage
|
||||
|
||||
Changes in 0.61 (12 April 95)
|
||||
- workaround for a bug in TurboC. example and minigzip now work on MSDOS.
|
||||
- workaround for a bug in TurboC. example and minigzip now work on MSDOS
|
||||
|
||||
Changes in 0.6 (11 April 95)
|
||||
- added minigzip.c
|
||||
- added gzdopen to reopen a file descriptor as gzFile
|
||||
- added transparent reading of non-gziped files in gzread.
|
||||
- added transparent reading of non-gziped files in gzread
|
||||
- fixed bug in gzread (don't read crc as data)
|
||||
- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose).
|
||||
- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose)
|
||||
- don't allocate big arrays in the stack (for MSDOS)
|
||||
- fix some MSDOS compilation problems
|
||||
|
||||
Changes in 0.5:
|
||||
- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but
|
||||
not yet Z_FULL_FLUSH.
|
||||
not yet Z_FULL_FLUSH
|
||||
- support decompression but only in a single step (forced Z_FINISH)
|
||||
- added opaque object for zalloc and zfree.
|
||||
- added opaque object for zalloc and zfree
|
||||
- added deflateReset and inflateReset
|
||||
- added a variable zlib_version for consistency checking.
|
||||
- renamed the 'filter' parameter of deflateInit2 as 'strategy'.
|
||||
Added Z_FILTERED and Z_HUFFMAN_ONLY constants.
|
||||
- added a variable zlib_version for consistency checking
|
||||
- renamed the 'filter' parameter of deflateInit2 as 'strategy'
|
||||
Added Z_FILTERED and Z_HUFFMAN_ONLY constants
|
||||
|
||||
Changes in 0.4:
|
||||
- avoid "zip" everywhere, use zlib instead of ziplib.
|
||||
- avoid "zip" everywhere, use zlib instead of ziplib
|
||||
- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush
|
||||
if compression method == 8.
|
||||
if compression method == 8
|
||||
- added adler32 and crc32
|
||||
- renamed deflateOptions as deflateInit2, call one or the other but not both
|
||||
- added the method parameter for deflateInit2.
|
||||
- added the method parameter for deflateInit2
|
||||
- added inflateInit2
|
||||
- simplied considerably deflateInit and inflateInit by not supporting
|
||||
- simplified considerably deflateInit and inflateInit by not supporting
|
||||
user-provided history buffer. This is supported only in deflateInit2
|
||||
and inflateInit2.
|
||||
and inflateInit2
|
||||
|
||||
Changes in 0.3:
|
||||
- prefix all macro names with Z_
|
||||
- use Z_FINISH instead of deflateEnd to finish compression.
|
||||
- use Z_FINISH instead of deflateEnd to finish compression
|
||||
- added Z_HUFFMAN_ONLY
|
||||
- added gzerror()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
ZLIB DATA COMPRESSION LIBRARY
|
||||
|
||||
zlib 1.2.11 is a general purpose data compression library. All the code is
|
||||
zlib 1.3.1 is a general purpose data compression library. All the code is
|
||||
thread safe. The data format used by the zlib library is described by RFCs
|
||||
(Request for Comments) 1950 to 1952 in the files
|
||||
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
|
||||
|
@ -29,18 +29,17 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
|
|||
|
||||
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available at
|
||||
http://marknelson.us/1997/01/01/zlib-engine/ .
|
||||
https://marknelson.us/posts/1997/01/01/zlib-engine.html .
|
||||
|
||||
The changes made in version 1.2.11 are documented in the file ChangeLog.
|
||||
The changes made in version 1.3.1 are documented in the file ChangeLog.
|
||||
|
||||
Unsupported third party contributions are provided in directory contrib/ .
|
||||
|
||||
zlib is available in Java using the java.util.zip package, documented at
|
||||
http://java.sun.com/developer/technicalArticles/Programming/compression/ .
|
||||
zlib is available in Java using the java.util.zip package. Follow the API
|
||||
Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
|
||||
at CPAN (Comprehensive Perl Archive Network) sites, including
|
||||
http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
|
||||
A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org>
|
||||
can be found at https://github.com/pmqs/IO-Compress .
|
||||
|
||||
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
|
||||
available in Python 1.5 and later versions, see
|
||||
|
@ -64,7 +63,7 @@ Notes for some targets:
|
|||
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
|
||||
when compiled with cc.
|
||||
|
||||
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
|
||||
- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
|
||||
necessary to get gzprintf working correctly. This is done by configure.
|
||||
|
||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
|
||||
|
@ -84,7 +83,7 @@ Acknowledgments:
|
|||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2017 Jean-loup Gailly and Mark Adler
|
||||
(C) 1995-2024 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
|
||||
|
@ -108,7 +107,10 @@ Copyright notice:
|
|||
If you use the zlib library in a product, we would appreciate *not* receiving
|
||||
lengthy legal documents to sign. The sources are provided for free but without
|
||||
warranty of any kind. The library has been entirely written by Jean-loup
|
||||
Gailly and Mark Adler; it does not include third-party code.
|
||||
Gailly and Mark Adler; it does not include third-party code. We make all
|
||||
contributions to and distributions of this project solely in our personal
|
||||
capacity, and are not conveying any rights to any intellectual property of
|
||||
any third parties.
|
||||
|
||||
If you redistribute modified sources, we would appreciate that you include in
|
||||
the file ChangeLog history information documenting your changes. Please read
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
#include "zutil.h"
|
||||
|
||||
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
|
||||
|
||||
#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 */
|
||||
|
@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
|
|||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_z(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
z_size_t len;
|
||||
{
|
||||
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
|
||||
unsigned long sum2;
|
||||
unsigned n;
|
||||
|
||||
|
@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
|
||||
return adler32_z(adler, buf, len);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
local uLong adler32_combine_(adler1, adler2, len2)
|
||||
uLong adler1;
|
||||
uLong adler2;
|
||||
z_off64_t len2;
|
||||
{
|
||||
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||
unsigned long sum1;
|
||||
unsigned long sum2;
|
||||
unsigned rem;
|
||||
|
@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
||||
uLong adler1;
|
||||
uLong adler2;
|
||||
z_off_t len2;
|
||||
{
|
||||
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
|
||||
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
|
||||
uLong adler1;
|
||||
uLong adler2;
|
||||
z_off64_t len2;
|
||||
{
|
||||
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
|
|
|
@ -19,13 +19,8 @@
|
|||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
int level;
|
||||
{
|
||||
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
uLong sourceLen, int level) {
|
||||
z_stream stream;
|
||||
int err;
|
||||
const uInt max = (uInt)-1;
|
||||
|
@ -65,12 +60,8 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
|||
|
||||
/* ===========================================================================
|
||||
*/
|
||||
int ZEXPORT compress (dest, destLen, source, sourceLen)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
{
|
||||
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
uLong sourceLen) {
|
||||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||
}
|
||||
|
||||
|
@ -78,9 +69,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
|
|||
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||
this function needs to be updated.
|
||||
*/
|
||||
uLong ZEXPORT compressBound (sourceLen)
|
||||
uLong sourceLen;
|
||||
{
|
||||
uLong ZEXPORT compressBound(uLong sourceLen) {
|
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||
(sourceLen >> 25) + 13;
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@
|
|||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -45,8 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
|||
/***********************************************************************
|
||||
* 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)
|
||||
{
|
||||
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;
|
||||
|
@ -62,8 +61,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int 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)
|
||||
{
|
||||
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;
|
||||
|
@ -77,24 +75,23 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr
|
|||
(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), t^(c))
|
||||
(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 */
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# endif
|
||||
|
||||
static int 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)
|
||||
{
|
||||
int n; /* index in random header */
|
||||
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 */
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
||||
#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)
|
||||
|
@ -28,8 +28,7 @@
|
|||
|
||||
#include "ioapi.h"
|
||||
|
||||
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
|
||||
{
|
||||
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
|
||||
|
@ -38,8 +37,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename
|
|||
}
|
||||
}
|
||||
|
||||
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
|
||||
{
|
||||
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
|
||||
|
@ -52,13 +50,12 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
|
|||
}
|
||||
}
|
||||
|
||||
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
|
||||
{
|
||||
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 = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||
uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||
if ((tell_uLong) == MAXU32)
|
||||
return (ZPOS64_T)-1;
|
||||
else
|
||||
|
@ -66,11 +63,9 @@ 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)
|
||||
{
|
||||
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.zerror_file = p_filefunc32->zerror_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;
|
||||
|
@ -84,18 +79,10 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
|
|||
|
||||
|
||||
|
||||
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
|
||||
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
|
||||
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
|
||||
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
|
||||
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
||||
|
||||
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
||||
{
|
||||
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
|
||||
|
@ -110,10 +97,10 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
|
|||
return file;
|
||||
}
|
||||
|
||||
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
||||
{
|
||||
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
|
||||
|
@ -129,39 +116,39 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
|
|||
}
|
||||
|
||||
|
||||
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) {
|
||||
ZPOS64_T ret;
|
||||
ret = FTELLO_FUNC((FILE *)stream);
|
||||
(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)
|
||||
{
|
||||
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 :
|
||||
|
@ -176,15 +163,15 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
|
|||
default: return -1;
|
||||
}
|
||||
ret = 0;
|
||||
if (fseek((FILE *)stream, offset, fseek_origin) != 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)
|
||||
{
|
||||
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 :
|
||||
|
@ -200,30 +187,28 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
|
|||
}
|
||||
ret = 0;
|
||||
|
||||
if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret;
|
||||
(void)opaque;
|
||||
ret = ferror((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fill_fopen_filefunc (pzlib_filefunc_def)
|
||||
zlib_filefunc_def* pzlib_filefunc_def;
|
||||
{
|
||||
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;
|
||||
|
@ -234,8 +219,7 @@ void fill_fopen_filefunc (pzlib_filefunc_def)
|
|||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#define ftello64 ftell
|
||||
#define fseeko64 fseek
|
||||
#else
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
|
||||
#define fopen64 fopen
|
||||
#define ftello64 ftello
|
||||
#define fseeko64 fseeko
|
||||
|
@ -82,7 +82,7 @@
|
|||
#include "mz64conf.h"
|
||||
#endif
|
||||
|
||||
/* a type choosen by DEFINE */
|
||||
/* a type chosen by DEFINE */
|
||||
#ifdef HAVE_64BIT_INT_CUSTOM
|
||||
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||
#else
|
||||
|
@ -91,8 +91,7 @@ typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
|||
typedef uint64_t ZPOS64_T;
|
||||
#else
|
||||
|
||||
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||
#define MAXU32 0xffffffff
|
||||
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ZPOS64_T;
|
||||
|
@ -102,7 +101,10 @@ typedef unsigned long long int ZPOS64_T;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||
#ifndef MAXU32
|
||||
#define MAXU32 (0xffffffff)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -132,17 +134,17 @@ extern "C" {
|
|||
|
||||
|
||||
|
||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
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) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||
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 structure */
|
||||
/* here is the "old" 32 bits structure */
|
||||
typedef struct zlib_filefunc_def_s
|
||||
{
|
||||
open_file_func zopen_file;
|
||||
|
@ -155,9 +157,9 @@ typedef struct zlib_filefunc_def_s
|
|||
voidpf opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
|
||||
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
|
||||
{
|
||||
|
@ -171,8 +173,8 @@ typedef struct zlib_filefunc64_def_s
|
|||
voidpf opaque;
|
||||
} zlib_filefunc64_def;
|
||||
|
||||
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_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
|
||||
|
@ -191,11 +193,11 @@ typedef struct zlib_filefunc64_32_def_s
|
|||
#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 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
|
||||
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
|
||||
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf 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);
|
||||
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)))
|
||||
|
|
|
@ -28,19 +28,16 @@
|
|||
|
||||
// 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
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
|
||||
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream));
|
||||
long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
|
||||
int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HANDLE hf;
|
||||
|
@ -52,8 +49,7 @@ static void win32_translate_open_mode(int mode,
|
|||
DWORD* lpdwDesiredAccess,
|
||||
DWORD* lpdwCreationDisposition,
|
||||
DWORD* lpdwShareMode,
|
||||
DWORD* lpdwFlagsAndAttributes)
|
||||
{
|
||||
DWORD* lpdwFlagsAndAttributes) {
|
||||
*lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
|
||||
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
|
@ -74,8 +70,7 @@ static void win32_translate_open_mode(int mode,
|
|||
}
|
||||
}
|
||||
|
||||
static voidpf win32_build_iowin(HANDLE hFile)
|
||||
{
|
||||
static voidpf win32_build_iowin(HANDLE hFile) {
|
||||
voidpf ret=NULL;
|
||||
|
||||
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
|
||||
|
@ -93,8 +88,7 @@ static voidpf win32_build_iowin(HANDLE hFile)
|
|||
return ret;
|
||||
}
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
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;
|
||||
|
@ -122,8 +116,7 @@ voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int
|
|||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
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;
|
||||
|
@ -146,8 +139,7 @@ voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int
|
|||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
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;
|
||||
|
@ -166,8 +158,7 @@ voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int
|
|||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
|
||||
{
|
||||
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;
|
||||
|
@ -195,8 +186,7 @@ voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mo
|
|||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
|
||||
{
|
||||
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
|
||||
uLong ret=0;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
|
@ -217,8 +207,7 @@ uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uL
|
|||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
|
||||
{
|
||||
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
|
||||
uLong ret=0;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
|
@ -238,8 +227,7 @@ uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* b
|
|||
return ret;
|
||||
}
|
||||
|
||||
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
|
||||
{
|
||||
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
|
||||
|
@ -258,8 +246,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
|
|||
#endif
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
|
||||
{
|
||||
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
|
||||
long ret=-1;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
|
@ -281,8 +268,7 @@ long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
|
||||
ZPOS64_T ret= (ZPOS64_T)-1;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
|
@ -306,8 +292,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
|
|||
}
|
||||
|
||||
|
||||
long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
|
||||
{
|
||||
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
|
@ -344,8 +329,7 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in
|
|||
return ret;
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
|
||||
{
|
||||
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
long ret=-1;
|
||||
|
@ -383,8 +367,7 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret=-1;
|
||||
|
||||
if (stream!=NULL)
|
||||
|
@ -401,8 +384,7 @@ int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
|
||||
{
|
||||
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret=-1;
|
||||
if (stream!=NULL)
|
||||
{
|
||||
|
@ -411,8 +393,7 @@ int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
{
|
||||
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;
|
||||
|
@ -423,8 +404,7 @@ void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
|||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
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;
|
||||
|
@ -436,8 +416,7 @@ void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
|
|||
}
|
||||
|
||||
|
||||
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
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;
|
||||
|
@ -449,8 +428,7 @@ void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
|
|||
}
|
||||
|
||||
|
||||
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
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
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || 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)
|
||||
|
@ -45,6 +45,7 @@
|
|||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <direct.h>
|
||||
|
@ -78,13 +79,9 @@
|
|||
|
||||
/* change_file_date : change the date/time of a file
|
||||
filename : the filename of the file where date/time must be modified
|
||||
dosdate : the new date at the MSDos format (4 bytes)
|
||||
dosdate : the new date at the MSDOS format (4 bytes)
|
||||
tmu_date : the SAME new date at the tm_unz format */
|
||||
void change_file_date(filename,dosdate,tmu_date)
|
||||
const char *filename;
|
||||
uLong dosdate;
|
||||
tm_unz tmu_date;
|
||||
{
|
||||
static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
|
||||
#ifdef _WIN32
|
||||
HANDLE hFile;
|
||||
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
|
||||
|
@ -97,7 +94,8 @@ void change_file_date(filename,dosdate,tmu_date)
|
|||
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
|
||||
CloseHandle(hFile);
|
||||
#else
|
||||
#ifdef unix || __APPLE__
|
||||
#if defined(unix) || defined(__APPLE__)
|
||||
(void)dosdate;
|
||||
struct utimbuf ut;
|
||||
struct tm newdate;
|
||||
newdate.tm_sec = tmu_date.tm_sec;
|
||||
|
@ -113,6 +111,10 @@ void change_file_date(filename,dosdate,tmu_date)
|
|||
|
||||
ut.actime=ut.modtime=mktime(&newdate);
|
||||
utime(filename,&ut);
|
||||
#else
|
||||
(void)filename;
|
||||
(void)dosdate;
|
||||
(void)tmu_date;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -121,9 +123,7 @@ void change_file_date(filename,dosdate,tmu_date)
|
|||
/* mymkdir and change_file_date are not 100 % portable
|
||||
As I don't know well Unix, I wait feedback for the unix portion */
|
||||
|
||||
int mymkdir(dirname)
|
||||
const char* dirname;
|
||||
{
|
||||
static int mymkdir(const char* dirname) {
|
||||
int ret=0;
|
||||
#ifdef _WIN32
|
||||
ret = _mkdir(dirname);
|
||||
|
@ -131,18 +131,18 @@ int mymkdir(dirname)
|
|||
ret = mkdir (dirname,0775);
|
||||
#elif __APPLE__
|
||||
ret = mkdir (dirname,0775);
|
||||
#else
|
||||
(void)dirname;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int makedir (newdir)
|
||||
char *newdir;
|
||||
{
|
||||
static int makedir(const char *newdir) {
|
||||
char *buffer ;
|
||||
char *p;
|
||||
int len = (int)strlen(newdir);
|
||||
size_t len = strlen(newdir);
|
||||
|
||||
if (len <= 0)
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
buffer = (char*)malloc(len+1);
|
||||
|
@ -185,14 +185,12 @@ int makedir (newdir)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void do_banner()
|
||||
{
|
||||
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
|
||||
static void do_banner(void) {
|
||||
printf("MiniUnz 1.1, demo of zLib + Unz package written by Gilles Vollant\n");
|
||||
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
|
||||
}
|
||||
|
||||
void do_help()
|
||||
{
|
||||
static void do_help(void) {
|
||||
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
|
||||
" -e Extract without pathname (junk paths)\n" \
|
||||
" -x Extract with pathname\n" \
|
||||
|
@ -200,11 +198,10 @@ void do_help()
|
|||
" -l list files\n" \
|
||||
" -d directory to extract into\n" \
|
||||
" -o overwrite files without prompting\n" \
|
||||
" -p extract crypted file using password\n\n");
|
||||
" -p extract encrypted file using password\n\n");
|
||||
}
|
||||
|
||||
void Display64BitsSize(ZPOS64_T n, int size_char)
|
||||
{
|
||||
static void Display64BitsSize(ZPOS64_T n, int size_char) {
|
||||
/* to avoid compatibility problem , we do here the conversion */
|
||||
char number[21];
|
||||
int offset=19;
|
||||
|
@ -231,9 +228,7 @@ void Display64BitsSize(ZPOS64_T n, int size_char)
|
|||
printf("%s",&number[pos_string]);
|
||||
}
|
||||
|
||||
int do_list(uf)
|
||||
unzFile uf;
|
||||
{
|
||||
static int do_list(unzFile uf) {
|
||||
uLong i;
|
||||
unz_global_info64 gi;
|
||||
int err;
|
||||
|
@ -248,7 +243,7 @@ int do_list(uf)
|
|||
char filename_inzip[256];
|
||||
unz_file_info64 file_info;
|
||||
uLong ratio=0;
|
||||
const char *string_method;
|
||||
const char *string_method = "";
|
||||
char charCrypt=' ';
|
||||
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
||||
if (err!=UNZ_OK)
|
||||
|
@ -259,7 +254,7 @@ int do_list(uf)
|
|||
if (file_info.uncompressed_size>0)
|
||||
ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size);
|
||||
|
||||
/* display a '*' if the file is crypted */
|
||||
/* display a '*' if the file is encrypted */
|
||||
if ((file_info.flag & 1) != 0)
|
||||
charCrypt='*';
|
||||
|
||||
|
@ -309,12 +304,7 @@ int do_list(uf)
|
|||
}
|
||||
|
||||
|
||||
int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||
unzFile uf;
|
||||
const int* popt_extract_without_path;
|
||||
int* popt_overwrite;
|
||||
const char* password;
|
||||
{
|
||||
static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
|
||||
char filename_inzip[256];
|
||||
char* filename_withoutpath;
|
||||
char* p;
|
||||
|
@ -324,7 +314,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
|||
uInt size_buf;
|
||||
|
||||
unz_file_info64 file_info;
|
||||
uLong ratio=0;
|
||||
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
||||
|
||||
if (err!=UNZ_OK)
|
||||
|
@ -367,6 +356,20 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
|||
else
|
||||
write_filename = filename_withoutpath;
|
||||
|
||||
if (write_filename[0]!='\0')
|
||||
{
|
||||
const char* relative_check = write_filename;
|
||||
while (relative_check[1]!='\0')
|
||||
{
|
||||
if (relative_check[0]=='.' && relative_check[1]=='.')
|
||||
write_filename = relative_check;
|
||||
relative_check++;
|
||||
}
|
||||
}
|
||||
|
||||
while (write_filename[0]=='/' || write_filename[0]=='.')
|
||||
write_filename++;
|
||||
|
||||
err = unzOpenCurrentFilePassword(uf,password);
|
||||
if (err!=UNZ_OK)
|
||||
{
|
||||
|
@ -439,7 +442,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
|||
break;
|
||||
}
|
||||
if (err>0)
|
||||
if (fwrite(buf,err,1,fout)!=1)
|
||||
if (fwrite(buf,(unsigned)err,1,fout)!=1)
|
||||
{
|
||||
printf("error in writing extracted file\n");
|
||||
err=UNZ_ERRNO;
|
||||
|
@ -472,16 +475,10 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
|||
}
|
||||
|
||||
|
||||
int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
||||
unzFile uf;
|
||||
int opt_extract_without_path;
|
||||
int opt_overwrite;
|
||||
const char* password;
|
||||
{
|
||||
static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
|
||||
uLong i;
|
||||
unz_global_info64 gi;
|
||||
int err;
|
||||
FILE* fout=NULL;
|
||||
|
||||
err = unzGetGlobalInfo64(uf,&gi);
|
||||
if (err!=UNZ_OK)
|
||||
|
@ -508,14 +505,7 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
|
||||
unzFile uf;
|
||||
const char* filename;
|
||||
int opt_extract_without_path;
|
||||
int opt_overwrite;
|
||||
const char* password;
|
||||
{
|
||||
int err = UNZ_OK;
|
||||
static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
|
||||
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
|
||||
{
|
||||
printf("file %s not found in the zipfile\n",filename);
|
||||
|
@ -531,10 +521,7 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,passwo
|
|||
}
|
||||
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
const char *zipfilename=NULL;
|
||||
const char *filename_to_extract=NULL;
|
||||
const char *password=NULL;
|
||||
|
@ -565,7 +552,7 @@ int main(argc,argv)
|
|||
|
||||
while ((*p)!='\0')
|
||||
{
|
||||
char c=*(p++);;
|
||||
char c=*(p++);
|
||||
if ((c=='l') || (c=='L'))
|
||||
opt_do_list = 1;
|
||||
if ((c=='v') || (c=='V'))
|
||||
|
@ -607,7 +594,7 @@ int main(argc,argv)
|
|||
# endif
|
||||
|
||||
strncpy(filename_try, zipfilename,MAXFILENAME-1);
|
||||
/* strncpy doesnt append the trailing NULL, of the string is too long. */
|
||||
/* strncpy doesn't append the trailing NULL, of the string is too long. */
|
||||
filename_try[ MAXFILENAME ] = '\0';
|
||||
|
||||
# ifdef USEWIN32IOAPI
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || 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)
|
||||
|
@ -71,11 +71,9 @@
|
|||
#define MAXFILENAME (256)
|
||||
|
||||
#ifdef _WIN32
|
||||
uLong filetime(f, tmzip, dt)
|
||||
char *f; /* name of file to get info on */
|
||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||
uLong *dt; /* dostime */
|
||||
{
|
||||
/* f: name of file to get info on, tmzip: return value: access,
|
||||
modification and creation times, dt: dostime */
|
||||
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
|
||||
int ret = 0;
|
||||
{
|
||||
FILETIME ftLocal;
|
||||
|
@ -94,12 +92,11 @@ uLong filetime(f, tmzip, dt)
|
|||
return ret;
|
||||
}
|
||||
#else
|
||||
#ifdef unix || __APPLE__
|
||||
uLong filetime(f, tmzip, dt)
|
||||
char *f; /* name of file to get info on */
|
||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||
uLong *dt; /* dostime */
|
||||
{
|
||||
#if defined(unix) || defined(__APPLE__)
|
||||
/* f: name of file to get info on, tmzip: return value: access,
|
||||
modification and creation times, dt: dostime */
|
||||
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
|
||||
(void)dt;
|
||||
int ret=0;
|
||||
struct stat s; /* results of stat() */
|
||||
struct tm* filedate;
|
||||
|
@ -108,12 +105,12 @@ uLong filetime(f, tmzip, dt)
|
|||
if (strcmp(f,"-")!=0)
|
||||
{
|
||||
char name[MAXFILENAME+1];
|
||||
int len = strlen(f);
|
||||
size_t len = strlen(f);
|
||||
if (len > MAXFILENAME)
|
||||
len = MAXFILENAME;
|
||||
|
||||
strncpy(name, f,MAXFILENAME-1);
|
||||
/* strncpy doesnt append the trailing NULL, of the string is too long. */
|
||||
/* strncpy doesn't append the trailing NULL, of the string is too long. */
|
||||
name[ MAXFILENAME ] = '\0';
|
||||
|
||||
if (name[len - 1] == '/')
|
||||
|
@ -137,11 +134,12 @@ uLong filetime(f, tmzip, dt)
|
|||
return ret;
|
||||
}
|
||||
#else
|
||||
uLong filetime(f, tmzip, dt)
|
||||
char *f; /* name of file to get info on */
|
||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||
uLong *dt; /* dostime */
|
||||
{
|
||||
/* f: name of file to get info on, tmzip: return value: access,
|
||||
modification and creation times, dt: dostime */
|
||||
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
|
||||
(void)f;
|
||||
(void)tmzip;
|
||||
(void)dt;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -150,9 +148,7 @@ uLong filetime(f, tmzip, dt)
|
|||
|
||||
|
||||
|
||||
int check_exist_file(filename)
|
||||
const char* filename;
|
||||
{
|
||||
static int check_exist_file(const char* filename) {
|
||||
FILE* ftestexist;
|
||||
int ret = 1;
|
||||
ftestexist = FOPEN_FUNC(filename,"rb");
|
||||
|
@ -163,14 +159,12 @@ int check_exist_file(filename)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void do_banner()
|
||||
{
|
||||
static void do_banner(void) {
|
||||
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
|
||||
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
|
||||
}
|
||||
|
||||
void do_help()
|
||||
{
|
||||
static void do_help(void) {
|
||||
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
|
||||
" -o Overwrite existing file.zip\n" \
|
||||
" -a Append to existing file.zip\n" \
|
||||
|
@ -182,14 +176,13 @@ void do_help()
|
|||
|
||||
/* calculate the CRC32 of a file,
|
||||
because to encrypt a file, we need known the CRC32 of the file before */
|
||||
int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
|
||||
{
|
||||
static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) {
|
||||
unsigned long calculate_crc=0;
|
||||
int err=ZIP_OK;
|
||||
FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
|
||||
|
||||
unsigned long size_read = 0;
|
||||
unsigned long total_read = 0;
|
||||
/* unsigned long total_read = 0; */
|
||||
if (fin==NULL)
|
||||
{
|
||||
err = ZIP_ERRNO;
|
||||
|
@ -199,7 +192,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
|||
do
|
||||
{
|
||||
err = ZIP_OK;
|
||||
size_read = (int)fread(buf,1,size_buf,fin);
|
||||
size_read = fread(buf,1,size_buf,fin);
|
||||
if (size_read < size_buf)
|
||||
if (feof(fin)==0)
|
||||
{
|
||||
|
@ -208,8 +201,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
|||
}
|
||||
|
||||
if (size_read>0)
|
||||
calculate_crc = crc32(calculate_crc,buf,size_read);
|
||||
total_read += size_read;
|
||||
calculate_crc = crc32_z(calculate_crc,buf,size_read);
|
||||
/* total_read += size_read; */
|
||||
|
||||
} while ((err == ZIP_OK) && (size_read>0));
|
||||
|
||||
|
@ -221,18 +214,17 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
|||
return err;
|
||||
}
|
||||
|
||||
int isLargeFile(const char* filename)
|
||||
{
|
||||
static int isLargeFile(const char* filename) {
|
||||
int largeFile = 0;
|
||||
ZPOS64_T pos = 0;
|
||||
FILE* pFile = FOPEN_FUNC(filename, "rb");
|
||||
|
||||
if(pFile != NULL)
|
||||
{
|
||||
int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
|
||||
pos = FTELLO_FUNC(pFile);
|
||||
FSEEKO_FUNC(pFile, 0, SEEK_END);
|
||||
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
|
||||
|
||||
printf("File : %s is %lld bytes\n", filename, pos);
|
||||
printf("File : %s is %llu bytes\n", filename, pos);
|
||||
|
||||
if(pos >= 0xffffffff)
|
||||
largeFile = 1;
|
||||
|
@ -243,10 +235,7 @@ int isLargeFile(const char* filename)
|
|||
return largeFile;
|
||||
}
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
int opt_overwrite=0;
|
||||
int opt_compress_level=Z_DEFAULT_COMPRESSION;
|
||||
|
@ -255,7 +244,7 @@ int main(argc,argv)
|
|||
char filename_try[MAXFILENAME+16];
|
||||
int zipok;
|
||||
int err=0;
|
||||
int size_buf=0;
|
||||
size_t size_buf=0;
|
||||
void* buf=NULL;
|
||||
const char* password=NULL;
|
||||
|
||||
|
@ -276,7 +265,7 @@ int main(argc,argv)
|
|||
|
||||
while ((*p)!='\0')
|
||||
{
|
||||
char c=*(p++);;
|
||||
char c=*(p++);
|
||||
if ((c=='o') || (c=='O'))
|
||||
opt_overwrite = 1;
|
||||
if ((c=='a') || (c=='A'))
|
||||
|
@ -322,7 +311,7 @@ int main(argc,argv)
|
|||
|
||||
zipok = 1 ;
|
||||
strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
|
||||
/* strncpy doesnt append the trailing NULL, of the string is too long. */
|
||||
/* strncpy doesn't append the trailing NULL, of the string is too long. */
|
||||
filename_try[ MAXFILENAME ] = '\0';
|
||||
|
||||
len=(int)strlen(filename_try);
|
||||
|
@ -392,11 +381,11 @@ int main(argc,argv)
|
|||
((argv[i][1]=='o') || (argv[i][1]=='O') ||
|
||||
(argv[i][1]=='a') || (argv[i][1]=='A') ||
|
||||
(argv[i][1]=='p') || (argv[i][1]=='P') ||
|
||||
((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
|
||||
((argv[i][1]>='0') && (argv[i][1]<='9'))) &&
|
||||
(strlen(argv[i]) == 2)))
|
||||
{
|
||||
FILE * fin;
|
||||
int size_read;
|
||||
FILE * fin = NULL;
|
||||
size_t size_read;
|
||||
const char* filenameinzip = argv[i];
|
||||
const char *savefilenameinzip;
|
||||
zip_fileinfo zi;
|
||||
|
@ -472,7 +461,7 @@ int main(argc,argv)
|
|||
do
|
||||
{
|
||||
err = ZIP_OK;
|
||||
size_read = (int)fread(buf,1,size_buf,fin);
|
||||
size_read = fread(buf,1,size_buf,fin);
|
||||
if (size_read < size_buf)
|
||||
if (feof(fin)==0)
|
||||
{
|
||||
|
@ -482,7 +471,7 @@ int main(argc,argv)
|
|||
|
||||
if (size_read>0)
|
||||
{
|
||||
err = zipWriteInFileInZip (zf,buf,size_read);
|
||||
err = zipWriteInFileInZip (zf,buf,(unsigned)size_read);
|
||||
if (err<0)
|
||||
{
|
||||
printf("error in writing %s in the zipfile\n",
|
||||
|
|
|
@ -27,13 +27,7 @@
|
|||
WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
|
||||
} while(0)
|
||||
|
||||
extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
|
||||
const char* file;
|
||||
const char* fileOut;
|
||||
const char* fileOutTmp;
|
||||
uLong* nRecovered;
|
||||
uLong* bytesRecovered;
|
||||
{
|
||||
extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) {
|
||||
int err = Z_OK;
|
||||
FILE* fpZip = fopen(file, "rb");
|
||||
FILE* fpOut = fopen(fileOut, "wb");
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -83,12 +83,12 @@ typedef voidp unzFile;
|
|||
/* 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] */
|
||||
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
|
||||
|
@ -150,21 +150,21 @@ typedef struct unz_file_info_s
|
|||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
extern int ZEXPORT unzStringFileNameCompare(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
|
||||
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 iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
If iCaseSensitivity = 0, case sensitivity is default of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
|
||||
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
|
||||
|
@ -181,41 +181,41 @@ extern unzFile ZEXPORT unzOpen64 OF((const void *path));
|
|||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
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 OF((const void *path,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
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 OF((unzFile file));
|
||||
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 OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
extern int ZEXPORT unzGetGlobalInfo(unzFile file,
|
||||
unz_global_info *pglobal_info);
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
|
||||
unz_global_info64 *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 OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
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.
|
||||
|
@ -226,22 +226,22 @@ extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
|||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
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 OF((unzFile file));
|
||||
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 OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
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
|
||||
|
@ -285,28 +285,28 @@ extern int ZEXPORT unzGoToFilePos64(
|
|||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
|
||||
unz_file_info64 *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
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 OF((unzFile file,
|
||||
unz_file_info *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 somes info about
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain some info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
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).
|
||||
|
@ -318,7 +318,7 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
|||
|
||||
/** Addition for GDAL : START */
|
||||
|
||||
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
|
||||
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file);
|
||||
|
||||
/** Addition for GDAL : END */
|
||||
|
||||
|
@ -328,24 +328,24 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
|
|||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile 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 OF((unzFile file,
|
||||
const char* password));
|
||||
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 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw));
|
||||
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
|
||||
|
@ -355,11 +355,11 @@ extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
|||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password));
|
||||
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
|
||||
|
@ -370,41 +370,41 @@ extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
|||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
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 OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
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 somes bytes are copied
|
||||
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 OF((unzFile file));
|
||||
extern z_off_t ZEXPORT unztell(unzFile file);
|
||||
|
||||
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
|
||||
extern ZPOS64_T ZEXPORT unztell64(unzFile file);
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
extern int ZEXPORT unzeof(unzFile file);
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
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
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives
|
||||
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions.
|
||||
Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data
|
||||
It is used when recreting zip archive with RAW when deleting items from a zip.
|
||||
It is used when recreating zip archive with RAW when deleting items from a zip.
|
||||
ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed.
|
||||
Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required)
|
||||
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
|
||||
|
@ -25,14 +25,13 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include "../../zlib.h"
|
||||
#include "zip.h"
|
||||
|
||||
#ifdef STDC
|
||||
# include <stddef.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef NO_ERRNO_H
|
||||
extern int errno;
|
||||
|
@ -47,7 +46,7 @@
|
|||
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||
|
||||
#ifndef VERSIONMADEBY
|
||||
# define VERSIONMADEBY (0x0) /* platform depedent */
|
||||
# define VERSIONMADEBY (0x0) /* platform dependent */
|
||||
#endif
|
||||
|
||||
#ifndef Z_BUFSIZE
|
||||
|
@ -61,9 +60,6 @@
|
|||
#ifndef ALLOC
|
||||
# define ALLOC(size) (malloc(size))
|
||||
#endif
|
||||
#ifndef TRYFREE
|
||||
# define TRYFREE(p) {if (p) free(p);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
#define SIZECENTRALDIRITEM (0x2e)
|
||||
|
@ -138,37 +134,37 @@ typedef struct
|
|||
uInt pos_in_buffered_data; /* last written byte in buffered_data */
|
||||
|
||||
ZPOS64_T pos_local_header; /* offset of the local header of the file
|
||||
currenty writing */
|
||||
currently writing */
|
||||
char* central_header; /* central header data for the current file */
|
||||
uLong size_centralExtra;
|
||||
uLong size_centralheader; /* size of the central header for cur file */
|
||||
uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */
|
||||
uLong flag; /* flag of the file currently writing */
|
||||
|
||||
int method; /* compression method of file currenty wr.*/
|
||||
int method; /* compression method of file currently wr.*/
|
||||
int raw; /* 1 for directly writing raw data */
|
||||
Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
|
||||
uLong dosDate;
|
||||
uLong crc32;
|
||||
int encrypt;
|
||||
int zip64; /* Add ZIP64 extened information in the extra field */
|
||||
int zip64; /* Add ZIP64 extended information in the extra field */
|
||||
ZPOS64_T pos_zip64extrainfo;
|
||||
ZPOS64_T totalCompressedData;
|
||||
ZPOS64_T totalUncompressedData;
|
||||
#ifndef NOCRYPT
|
||||
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
|
||||
const z_crc_t* pcrc_32_tab;
|
||||
int crypt_header_size;
|
||||
unsigned crypt_header_size;
|
||||
#endif
|
||||
} curfile64_info;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
zlib_filefunc64_32_def z_filefunc;
|
||||
voidpf filestream; /* io structore of the zipfile */
|
||||
voidpf filestream; /* io structure of the zipfile */
|
||||
linkedlist_data central_dir;/* datablock with central dir in construction*/
|
||||
int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/
|
||||
curfile64_info ci; /* info on the file curretly writing */
|
||||
curfile64_info ci; /* info on the file currently writing */
|
||||
|
||||
ZPOS64_T begin_pos; /* position of the beginning of the zipfile */
|
||||
ZPOS64_T add_position_when_writing_offset;
|
||||
|
@ -186,8 +182,7 @@ typedef struct
|
|||
#include "crypt.h"
|
||||
#endif
|
||||
|
||||
local linkedlist_datablock_internal* allocate_new_datablock()
|
||||
{
|
||||
local linkedlist_datablock_internal* allocate_new_datablock(void) {
|
||||
linkedlist_datablock_internal* ldi;
|
||||
ldi = (linkedlist_datablock_internal*)
|
||||
ALLOC(sizeof(linkedlist_datablock_internal));
|
||||
|
@ -200,30 +195,26 @@ local linkedlist_datablock_internal* allocate_new_datablock()
|
|||
return ldi;
|
||||
}
|
||||
|
||||
local void free_datablock(linkedlist_datablock_internal* ldi)
|
||||
{
|
||||
local void free_datablock(linkedlist_datablock_internal* ldi) {
|
||||
while (ldi!=NULL)
|
||||
{
|
||||
linkedlist_datablock_internal* ldinext = ldi->next_datablock;
|
||||
TRYFREE(ldi);
|
||||
free(ldi);
|
||||
ldi = ldinext;
|
||||
}
|
||||
}
|
||||
|
||||
local void init_linkedlist(linkedlist_data* ll)
|
||||
{
|
||||
local void init_linkedlist(linkedlist_data* ll) {
|
||||
ll->first_block = ll->last_block = NULL;
|
||||
}
|
||||
|
||||
local void free_linkedlist(linkedlist_data* ll)
|
||||
{
|
||||
local void free_linkedlist(linkedlist_data* ll) {
|
||||
free_datablock(ll->first_block);
|
||||
ll->first_block = ll->last_block = NULL;
|
||||
}
|
||||
|
||||
|
||||
local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
|
||||
{
|
||||
local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) {
|
||||
linkedlist_datablock_internal* ldi;
|
||||
const unsigned char* from_copy;
|
||||
|
||||
|
@ -238,7 +229,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
|
|||
}
|
||||
|
||||
ldi = ll->last_block;
|
||||
from_copy = (unsigned char*)buf;
|
||||
from_copy = (const unsigned char*)buf;
|
||||
|
||||
while (len>0)
|
||||
{
|
||||
|
@ -283,9 +274,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
|
|||
nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T)
|
||||
*/
|
||||
|
||||
local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte));
|
||||
local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
|
||||
{
|
||||
local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) {
|
||||
unsigned char buf[8];
|
||||
int n;
|
||||
for (n = 0; n < nbByte; n++)
|
||||
|
@ -301,15 +290,13 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def,
|
|||
}
|
||||
}
|
||||
|
||||
if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
|
||||
if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,(uLong)nbByte)!=(uLong)nbByte)
|
||||
return ZIP_ERRNO;
|
||||
else
|
||||
return ZIP_OK;
|
||||
}
|
||||
|
||||
local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte));
|
||||
local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
|
||||
{
|
||||
local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) {
|
||||
unsigned char* buf=(unsigned char*)dest;
|
||||
int n;
|
||||
for (n = 0; n < nbByte; n++) {
|
||||
|
@ -329,25 +316,21 @@ local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
|
|||
/****************************************************************************/
|
||||
|
||||
|
||||
local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)
|
||||
{
|
||||
local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) {
|
||||
uLong year = (uLong)ptm->tm_year;
|
||||
if (year>=1980)
|
||||
year-=1980;
|
||||
else if (year>=80)
|
||||
year-=80;
|
||||
return
|
||||
(uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
|
||||
((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
|
||||
(uLong) (((uLong)(ptm->tm_mday) + (32 * (uLong)(ptm->tm_mon+1)) + (512 * year)) << 16) |
|
||||
(((uLong)ptm->tm_sec/2) + (32 * (uLong)ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi));
|
||||
|
||||
local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi)
|
||||
{
|
||||
local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int* pi) {
|
||||
unsigned char c;
|
||||
int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
|
||||
if (err==1)
|
||||
|
@ -368,10 +351,7 @@ local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,vo
|
|||
/* ===========================================================================
|
||||
Reads a long in LSB order from the given gz_stream. Sets
|
||||
*/
|
||||
local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));
|
||||
|
||||
local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
|
||||
{
|
||||
local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) {
|
||||
uLong x ;
|
||||
int i = 0;
|
||||
int err;
|
||||
|
@ -390,10 +370,7 @@ local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
|
|||
return err;
|
||||
}
|
||||
|
||||
local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));
|
||||
|
||||
local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
|
||||
{
|
||||
local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) {
|
||||
uLong x ;
|
||||
int i = 0;
|
||||
int err;
|
||||
|
@ -420,11 +397,8 @@ local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
|
|||
return err;
|
||||
}
|
||||
|
||||
local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX));
|
||||
|
||||
|
||||
local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
|
||||
{
|
||||
local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) {
|
||||
ZPOS64_T x;
|
||||
int i = 0;
|
||||
int err;
|
||||
|
@ -475,10 +449,7 @@ local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def
|
|||
Locate the Central directory of a zipfile (at the end, just before
|
||||
the global comment)
|
||||
*/
|
||||
local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
|
||||
|
||||
local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
|
||||
{
|
||||
local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
|
||||
unsigned char* buf;
|
||||
ZPOS64_T uSizeFile;
|
||||
ZPOS64_T uBackRead;
|
||||
|
@ -522,14 +493,14 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
|
|||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||
{
|
||||
uPosFound = uReadPos+i;
|
||||
uPosFound = uReadPos+(unsigned)i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (uPosFound!=0)
|
||||
break;
|
||||
if (uPosFound!=0)
|
||||
break;
|
||||
}
|
||||
TRYFREE(buf);
|
||||
free(buf);
|
||||
return uPosFound;
|
||||
}
|
||||
|
||||
|
@ -537,10 +508,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
|
|||
Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before
|
||||
the global comment)
|
||||
*/
|
||||
local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
|
||||
|
||||
local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
|
||||
{
|
||||
local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
|
||||
unsigned char* buf;
|
||||
ZPOS64_T uSizeFile;
|
||||
ZPOS64_T uBackRead;
|
||||
|
@ -586,7 +554,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
|||
// Signature "0x07064b50" Zip64 end of central directory locater
|
||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
||||
{
|
||||
uPosFound = uReadPos+i;
|
||||
uPosFound = uReadPos+(unsigned)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -595,7 +563,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
|||
break;
|
||||
}
|
||||
|
||||
TRYFREE(buf);
|
||||
free(buf);
|
||||
if (uPosFound == 0)
|
||||
return 0;
|
||||
|
||||
|
@ -607,7 +575,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
|||
if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
|
||||
return 0;
|
||||
|
||||
/* number of the disk with the start of the zip64 end of central directory */
|
||||
/* number of the disk with the start of the zip64 end of central directory */
|
||||
if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
|
||||
return 0;
|
||||
if (uL != 0)
|
||||
|
@ -637,8 +605,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
|||
return relativeOffset;
|
||||
}
|
||||
|
||||
int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||
{
|
||||
local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
|
||||
int err=ZIP_OK;
|
||||
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
||||
|
||||
|
@ -647,10 +614,10 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
|||
ZPOS64_T central_pos;
|
||||
uLong uL;
|
||||
|
||||
uLong number_disk; /* number of the current dist, used for
|
||||
spaning ZIP, unsupported, always 0*/
|
||||
uLong number_disk_with_CD; /* number the the disk with central dir, used
|
||||
for spaning ZIP, unsupported, always 0*/
|
||||
uLong number_disk; /* number of the current disk, used for
|
||||
spanning ZIP, unsupported, always 0*/
|
||||
uLong number_disk_with_CD; /* number of the disk with central dir, used
|
||||
for spanning ZIP, unsupported, always 0*/
|
||||
ZPOS64_T number_entry;
|
||||
ZPOS64_T number_entry_CD; /* total number of entries in
|
||||
the central dir
|
||||
|
@ -830,7 +797,7 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
|||
|
||||
size_central_dir_to_read-=read_this;
|
||||
}
|
||||
TRYFREE(buf_read);
|
||||
free(buf_read);
|
||||
}
|
||||
pziinit->begin_pos = byte_before_the_zipfile;
|
||||
pziinit->number_entry = number_entry_CD;
|
||||
|
@ -846,8 +813,7 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
|||
|
||||
|
||||
/************************************************************/
|
||||
extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def)
|
||||
{
|
||||
extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) {
|
||||
zip64_internal ziinit;
|
||||
zip64_internal* zi;
|
||||
int err=ZIP_OK;
|
||||
|
@ -905,9 +871,9 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
|
|||
if (err != ZIP_OK)
|
||||
{
|
||||
# ifndef NO_ADDFILEINEXISTINGZIP
|
||||
TRYFREE(ziinit.globalcomment);
|
||||
free(ziinit.globalcomment);
|
||||
# endif /* !NO_ADDFILEINEXISTINGZIP*/
|
||||
TRYFREE(zi);
|
||||
free(zi);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
|
@ -917,8 +883,7 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
|
|||
}
|
||||
}
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def)
|
||||
{
|
||||
extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) {
|
||||
if (pzlib_filefunc32_def != NULL)
|
||||
{
|
||||
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
|
||||
|
@ -929,8 +894,7 @@ extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* gl
|
|||
return zipOpen3(pathname, append, globalcomment, NULL);
|
||||
}
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
if (pzlib_filefunc_def != NULL)
|
||||
{
|
||||
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
|
||||
|
@ -945,18 +909,15 @@ extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc*
|
|||
|
||||
|
||||
|
||||
extern zipFile ZEXPORT zipOpen (const char* pathname, int append)
|
||||
{
|
||||
extern zipFile ZEXPORT zipOpen(const char* pathname, int append) {
|
||||
return zipOpen3((const void*)pathname,append,NULL,NULL);
|
||||
}
|
||||
|
||||
extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append)
|
||||
{
|
||||
extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) {
|
||||
return zipOpen3(pathname,append,NULL,NULL);
|
||||
}
|
||||
|
||||
int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
|
||||
{
|
||||
local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) {
|
||||
/* write the local header */
|
||||
int err;
|
||||
uInt size_filename = (uInt)strlen(filename);
|
||||
|
@ -1034,8 +995,8 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
|
|||
// Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
|
||||
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
|
||||
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2);
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2);
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2);
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2);
|
||||
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
|
||||
|
@ -1052,14 +1013,13 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
|
|||
It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize
|
||||
unnecessary allocations.
|
||||
*/
|
||||
extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting,
|
||||
uLong versionMadeBy, uLong flagBase, int zip64)
|
||||
{
|
||||
extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting,
|
||||
uLong versionMadeBy, uLong flagBase, int zip64) {
|
||||
zip64_internal* zi;
|
||||
uInt size_filename;
|
||||
uInt size_comment;
|
||||
|
@ -1083,6 +1043,17 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
|
|||
return ZIP_PARAMERROR;
|
||||
#endif
|
||||
|
||||
// The filename and comment length must fit in 16 bits.
|
||||
if ((filename!=NULL) && (strlen(filename)>0xffff))
|
||||
return ZIP_PARAMERROR;
|
||||
if ((comment!=NULL) && (strlen(comment)>0xffff))
|
||||
return ZIP_PARAMERROR;
|
||||
// The extra field length must fit in 16 bits. If the member also requires
|
||||
// a Zip64 extra block, that will also need to fit within that 16-bit
|
||||
// length, but that will be checked for later.
|
||||
if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
|
||||
return ZIP_PARAMERROR;
|
||||
|
||||
zi = (zip64_internal*)file;
|
||||
|
||||
if (zi->in_opened_file_inzip == 1)
|
||||
|
@ -1262,35 +1233,33 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
|
|||
return err;
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting,
|
||||
uLong versionMadeBy, uLong flagBase)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, versionMadeBy, flagBase, 0);
|
||||
extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting,
|
||||
uLong versionMadeBy, uLong flagBase) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, versionMadeBy, flagBase, 0);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0, 0);
|
||||
extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0, 0);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
|
@ -1298,70 +1267,64 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, c
|
|||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting, int zip64)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0, zip64);
|
||||
const char* password, uLong crcForCrypting, int zip64) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0, zip64);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, 0);
|
||||
const char* comment, int method, int level, int raw) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, 0);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw, int zip64)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, zip64);
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw, int zip64) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, zip64);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void*extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int zip64)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, zip64);
|
||||
extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void*extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int zip64) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, zip64);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void*extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, 0);
|
||||
extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void*extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, 0);
|
||||
}
|
||||
|
||||
local int zip64FlushWriteBuffer(zip64_internal* zi)
|
||||
{
|
||||
local int zip64FlushWriteBuffer(zip64_internal* zi) {
|
||||
int err=ZIP_OK;
|
||||
|
||||
if (zi->ci.encrypt != 0)
|
||||
|
@ -1399,8 +1362,7 @@ local int zip64FlushWriteBuffer(zip64_internal* zi)
|
|||
return err;
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len)
|
||||
{
|
||||
extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) {
|
||||
zip64_internal* zi;
|
||||
int err=ZIP_OK;
|
||||
|
||||
|
@ -1450,7 +1412,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
|||
else
|
||||
#endif
|
||||
{
|
||||
zi->ci.stream.next_in = (Bytef*)buf;
|
||||
zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf;
|
||||
zi->ci.stream.avail_in = len;
|
||||
|
||||
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
|
||||
|
@ -1471,11 +1433,6 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
|||
{
|
||||
uLong uTotalOutBefore = zi->ci.stream.total_out;
|
||||
err=deflate(&zi->ci.stream, Z_NO_FLUSH);
|
||||
if(uTotalOutBefore > zi->ci.stream.total_out)
|
||||
{
|
||||
int bBreak = 0;
|
||||
bBreak++;
|
||||
}
|
||||
|
||||
zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
|
||||
}
|
||||
|
@ -1506,17 +1463,15 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
|||
return err;
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32)
|
||||
{
|
||||
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) {
|
||||
return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32)
|
||||
{
|
||||
extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32) {
|
||||
zip64_internal* zi;
|
||||
ZPOS64_T compressed_size;
|
||||
uLong invalidValue = 0xffffffff;
|
||||
short datasize = 0;
|
||||
unsigned datasize = 0;
|
||||
int err=ZIP_OK;
|
||||
|
||||
if (file == NULL)
|
||||
|
@ -1653,7 +1608,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
|
|||
|
||||
if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)
|
||||
{
|
||||
// we can not write more data to the buffer that we have room for.
|
||||
// we cannot write more data to the buffer that we have room for.
|
||||
return ZIP_BADZIPFILE;
|
||||
}
|
||||
|
||||
|
@ -1747,13 +1702,11 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
|
|||
return err;
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip (zipFile file)
|
||||
{
|
||||
extern int ZEXPORT zipCloseFileInZip(zipFile file) {
|
||||
return zipCloseFileInZipRaw (file,0,0);
|
||||
}
|
||||
|
||||
int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
|
||||
{
|
||||
local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) {
|
||||
int err = ZIP_OK;
|
||||
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
|
||||
|
||||
|
@ -1774,8 +1727,7 @@ int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo
|
|||
return err;
|
||||
}
|
||||
|
||||
int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||
{
|
||||
local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
|
||||
int err = ZIP_OK;
|
||||
|
||||
uLong Zip64DataSize = 44;
|
||||
|
@ -1813,8 +1765,8 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra
|
|||
}
|
||||
return err;
|
||||
}
|
||||
int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||
{
|
||||
|
||||
local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
|
||||
int err = ZIP_OK;
|
||||
|
||||
/*signature*/
|
||||
|
@ -1861,8 +1813,7 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir,
|
|||
return err;
|
||||
}
|
||||
|
||||
int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
||||
{
|
||||
local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) {
|
||||
int err = ZIP_OK;
|
||||
uInt size_global_comment = 0;
|
||||
|
||||
|
@ -1879,8 +1830,7 @@ int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
|||
return err;
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
|
||||
{
|
||||
extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
|
||||
zip64_internal* zi;
|
||||
int err = 0;
|
||||
uLong size_centraldir = 0;
|
||||
|
@ -1922,7 +1872,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
|
|||
free_linkedlist(&(zi->central_dir));
|
||||
|
||||
pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
|
||||
if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
|
||||
if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF)
|
||||
{
|
||||
ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
|
||||
Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
|
||||
|
@ -1941,15 +1891,14 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
|
|||
err = ZIP_ERRNO;
|
||||
|
||||
#ifndef NO_ADDFILEINEXISTINGZIP
|
||||
TRYFREE(zi->globalcomment);
|
||||
free(zi->globalcomment);
|
||||
#endif
|
||||
TRYFREE(zi);
|
||||
free(zi);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader)
|
||||
{
|
||||
extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader) {
|
||||
char* p = pData;
|
||||
int size = 0;
|
||||
char* pNewHeader;
|
||||
|
@ -1959,10 +1908,10 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
|
|||
|
||||
int retVal = ZIP_OK;
|
||||
|
||||
if(pData == NULL || *dataLen < 4)
|
||||
if(pData == NULL || dataLen == NULL || *dataLen < 4)
|
||||
return ZIP_PARAMERROR;
|
||||
|
||||
pNewHeader = (char*)ALLOC(*dataLen);
|
||||
pNewHeader = (char*)ALLOC((unsigned)*dataLen);
|
||||
pTmp = pNewHeader;
|
||||
|
||||
while(p < (pData + *dataLen))
|
||||
|
@ -2001,7 +1950,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
|
|||
else
|
||||
retVal = ZIP_ERRNO;
|
||||
|
||||
TRYFREE(pNewHeader);
|
||||
free(pNewHeader);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -88,12 +88,12 @@ typedef voidp zipFile;
|
|||
/* tm_zip contain date/time info */
|
||||
typedef struct tm_zip_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] */
|
||||
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_zip;
|
||||
|
||||
typedef struct
|
||||
|
@ -113,8 +113,8 @@ typedef const char* zipcharpc;
|
|||
#define APPEND_STATUS_CREATEAFTER (1)
|
||||
#define APPEND_STATUS_ADDINZIP (2)
|
||||
|
||||
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
|
||||
extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
|
||||
extern zipFile ZEXPORT zipOpen(const char *pathname, int append);
|
||||
extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
|
||||
/*
|
||||
Create a zipfile.
|
||||
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
|
||||
|
@ -131,50 +131,55 @@ extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
|
|||
|
||||
/* Note : there is no delete function into a zipfile.
|
||||
If you want delete file into a zipfile, you must open a zipfile, and create another
|
||||
Of couse, you can use RAW reading and writing to copy the file you did not want delte
|
||||
Of course, you can use RAW reading and writing to copy the file you did not want delete
|
||||
*/
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
|
||||
extern zipFile ZEXPORT zipOpen2(const char *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc_def* pzlib_filefunc_def);
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2_64(const void *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
extern zipFile ZEXPORT zipOpen3(const void *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc64_32_def* pzlib_filefunc64_32_def);
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level));
|
||||
extern int ZEXPORT zipOpenNewFileInZip(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level);
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int zip64));
|
||||
extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int zip64);
|
||||
|
||||
/*
|
||||
Open a file in the ZIP for writing.
|
||||
filename : the filename in zip (if NULL, '-' without quote will be used
|
||||
*zipfi contain supplemental information
|
||||
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
|
||||
contains the extrafield data the the local header
|
||||
contains the extrafield data for the local header
|
||||
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
|
||||
contains the extrafield data the the local header
|
||||
contains the extrafield data for the global header
|
||||
if comment != NULL, comment contain the comment string
|
||||
method contain the compression method (0 for store, Z_DEFLATED for deflate)
|
||||
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
|
||||
|
@ -184,70 +189,69 @@ extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
|
|||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw));
|
||||
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw);
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int zip64));
|
||||
extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int zip64);
|
||||
/*
|
||||
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting));
|
||||
extern int ZEXPORT zipOpenNewFileInZip3(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting);
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
int zip64
|
||||
));
|
||||
extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
int zip64);
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip2, except
|
||||
|
@ -256,47 +260,45 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
|
|||
crcForCrypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase
|
||||
));
|
||||
extern int ZEXPORT zipOpenNewFileInZip4(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase);
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase,
|
||||
int zip64
|
||||
));
|
||||
extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase,
|
||||
int zip64);
|
||||
/*
|
||||
Same than zipOpenNewFileInZip4, except
|
||||
versionMadeBy : value for Version made by field
|
||||
|
@ -304,25 +306,25 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
|
|||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
const void* buf,
|
||||
unsigned len));
|
||||
extern int ZEXPORT zipWriteInFileInZip(zipFile file,
|
||||
const void* buf,
|
||||
unsigned len);
|
||||
/*
|
||||
Write data in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
extern int ZEXPORT zipCloseFileInZip(zipFile file);
|
||||
/*
|
||||
Close the current file in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32));
|
||||
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32);
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
|
||||
ZPOS64_T uncompressed_size,
|
||||
uLong crc32));
|
||||
extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
|
||||
ZPOS64_T uncompressed_size,
|
||||
uLong crc32);
|
||||
|
||||
/*
|
||||
Close the current file in the zipfile, for file opened with
|
||||
|
@ -330,14 +332,14 @@ extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
|
|||
uncompressed_size and crc32 are value for the uncompressed size
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipClose OF((zipFile file,
|
||||
const char* global_comment));
|
||||
extern int ZEXPORT zipClose(zipFile file,
|
||||
const char* global_comment);
|
||||
/*
|
||||
Close the zipfile
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
|
||||
extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader);
|
||||
/*
|
||||
zipRemoveExtraInfoBlock - Added by Mathias Svensson
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
/* deflate.h -- internal compression state
|
||||
* Copyright (C) 1995-2016 Jean-loup Gailly
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -23,6 +23,10 @@
|
|||
# define GZIP
|
||||
#endif
|
||||
|
||||
/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
|
||||
the cost of a larger memory footprint */
|
||||
/* #define LIT_MEM */
|
||||
|
||||
/* ===========================================================================
|
||||
* Internal compression state.
|
||||
*/
|
||||
|
@ -217,7 +221,14 @@ typedef struct internal_state {
|
|||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||
*/
|
||||
|
||||
uchf *l_buf; /* buffer for literals or lengths */
|
||||
#ifdef LIT_MEM
|
||||
# define LIT_BUFS 5
|
||||
ushf *d_buf; /* buffer for distances */
|
||||
uchf *l_buf; /* buffer for literals/lengths */
|
||||
#else
|
||||
# define LIT_BUFS 4
|
||||
uchf *sym_buf; /* buffer for distances and literals/lengths */
|
||||
#endif
|
||||
|
||||
uInt lit_bufsize;
|
||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||
|
@ -239,13 +250,8 @@ typedef struct internal_state {
|
|||
* - I can't count above 4
|
||||
*/
|
||||
|
||||
uInt last_lit; /* running index in l_buf */
|
||||
|
||||
ushf *d_buf;
|
||||
/* Buffer for distances. To simplify the code, d_buf and l_buf have
|
||||
* the same number of elements. To use different lengths, an extra flag
|
||||
* array would be necessary.
|
||||
*/
|
||||
uInt sym_next; /* running index in symbol buffer */
|
||||
uInt sym_end; /* symbol table full when sym_next reaches this */
|
||||
|
||||
ulg opt_len; /* bit length of current block with optimal trees */
|
||||
ulg static_len; /* bit length of current block with static trees */
|
||||
|
@ -296,14 +302,14 @@ typedef struct internal_state {
|
|||
memory checker errors from longest match routines */
|
||||
|
||||
/* in trees.c */
|
||||
void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
|
||||
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
||||
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last));
|
||||
void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
|
||||
void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
|
||||
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last));
|
||||
void ZLIB_INTERNAL _tr_init(deflate_state *s);
|
||||
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
|
||||
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last);
|
||||
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
|
||||
void ZLIB_INTERNAL _tr_align(deflate_state *s);
|
||||
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last);
|
||||
|
||||
#define d_code(dist) \
|
||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||
|
@ -323,24 +329,46 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
|||
extern const uch ZLIB_INTERNAL _dist_code[];
|
||||
#endif
|
||||
|
||||
#ifdef LIT_MEM
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->d_buf[s->last_lit] = 0; \
|
||||
s->l_buf[s->last_lit++] = cc; \
|
||||
s->d_buf[s->sym_next] = 0; \
|
||||
s->l_buf[s->sym_next++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (uch)(length); \
|
||||
ush dist = (ush)(distance); \
|
||||
s->d_buf[s->last_lit] = dist; \
|
||||
s->l_buf[s->last_lit++] = len; \
|
||||
s->d_buf[s->sym_next] = dist; \
|
||||
s->l_buf[s->sym_next++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->sym_buf[s->sym_next++] = 0; \
|
||||
s->sym_buf[s->sym_next++] = 0; \
|
||||
s->sym_buf[s->sym_next++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (uch)(length); \
|
||||
ush dist = (ush)(distance); \
|
||||
s->sym_buf[s->sym_next++] = (uch)dist; \
|
||||
s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \
|
||||
s->sym_buf[s->sym_next++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
flush = _tr_tally(s, distance, length)
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
/* gzclose() is in a separate file so that it is linked in only if it is used.
|
||||
That way the other gzclose functions can be used instead to avoid linking in
|
||||
unneeded compression or decompression routines. */
|
||||
int ZEXPORT gzclose(file)
|
||||
gzFile file;
|
||||
{
|
||||
int ZEXPORT gzclose(gzFile file) {
|
||||
#ifndef NO_GZCOMPRESS
|
||||
gz_statep state;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
|
||||
* Copyright (C) 2004-2024 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -7,9 +7,8 @@
|
|||
# ifndef _LARGEFILE_SOURCE
|
||||
# define _LARGEFILE_SOURCE 1
|
||||
# endif
|
||||
# ifdef _FILE_OFFSET_BITS
|
||||
# undef _FILE_OFFSET_BITS
|
||||
# endif
|
||||
# undef _FILE_OFFSET_BITS
|
||||
# undef _TIME_BITS
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HIDDEN
|
||||
|
@ -39,7 +38,7 @@
|
|||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#if defined(_WIN32)
|
||||
# define WIDECHAR
|
||||
#endif
|
||||
|
||||
|
@ -119,8 +118,8 @@
|
|||
|
||||
/* gz* functions always use library allocation functions */
|
||||
#ifndef STDC
|
||||
extern voidp malloc OF((uInt size));
|
||||
extern void free OF((voidpf ptr));
|
||||
extern voidp malloc(uInt size);
|
||||
extern void free(voidpf ptr);
|
||||
#endif
|
||||
|
||||
/* get errno and strerror definition */
|
||||
|
@ -138,10 +137,10 @@
|
|||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
||||
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
||||
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
|
||||
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
|
||||
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
|
||||
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
|
||||
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
|
||||
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
|
||||
#endif
|
||||
|
||||
/* default memLevel */
|
||||
|
@ -190,6 +189,7 @@ typedef struct {
|
|||
/* just for writing */
|
||||
int level; /* compression level */
|
||||
int strategy; /* compression strategy */
|
||||
int reset; /* true if a reset is pending after a Z_FINISH */
|
||||
/* seek request */
|
||||
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
||||
int seek; /* true if seek request pending */
|
||||
|
@ -202,17 +202,13 @@ typedef struct {
|
|||
typedef gz_state FAR *gz_statep;
|
||||
|
||||
/* shared functions */
|
||||
void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
|
||||
void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
|
||||
#if defined UNDER_CE
|
||||
char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
|
||||
char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
|
||||
#endif
|
||||
|
||||
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
|
||||
value -- needed when comparing unsigned to z_off64_t, which is signed
|
||||
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
||||
#ifdef INT_MAX
|
||||
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
|
||||
#else
|
||||
unsigned ZLIB_INTERNAL gz_intmax OF((void));
|
||||
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
||||
#endif
|
||||
unsigned ZLIB_INTERNAL gz_intmax(void);
|
||||
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* gzlib.c -- zlib functions common to reading and writing gzip files
|
||||
* Copyright (C) 2004-2017 Mark Adler
|
||||
* Copyright (C) 2004-2024 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "gzguts.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
|
||||
#if defined(_WIN32) && !defined(__BORLANDC__)
|
||||
# define LSEEK _lseeki64
|
||||
#else
|
||||
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
||||
|
@ -15,10 +15,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* Local functions */
|
||||
local void gz_reset OF((gz_statep));
|
||||
local gzFile gz_open OF((const void *, int, const char *));
|
||||
|
||||
#if defined UNDER_CE
|
||||
|
||||
/* Map the Windows error number in ERROR to a locale-dependent error message
|
||||
|
@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *));
|
|||
|
||||
The gz_strwinerror function does not change the current setting of
|
||||
GetLastError. */
|
||||
char ZLIB_INTERNAL *gz_strwinerror (error)
|
||||
DWORD error;
|
||||
{
|
||||
char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
|
||||
static char buf[1024];
|
||||
|
||||
wchar_t *msgbuf;
|
||||
|
@ -72,15 +66,15 @@ char ZLIB_INTERNAL *gz_strwinerror (error)
|
|||
#endif /* UNDER_CE */
|
||||
|
||||
/* Reset gzip file state */
|
||||
local void gz_reset(state)
|
||||
gz_statep state;
|
||||
{
|
||||
local void gz_reset(gz_statep state) {
|
||||
state->x.have = 0; /* no output data available */
|
||||
if (state->mode == GZ_READ) { /* for reading ... */
|
||||
state->eof = 0; /* not at end of file */
|
||||
state->past = 0; /* have not read past end yet */
|
||||
state->how = LOOK; /* look for gzip header */
|
||||
}
|
||||
else /* for writing ... */
|
||||
state->reset = 0; /* no deflateReset pending */
|
||||
state->seek = 0; /* no seek request pending */
|
||||
gz_error(state, Z_OK, NULL); /* clear error */
|
||||
state->x.pos = 0; /* no uncompressed data yet */
|
||||
|
@ -88,11 +82,7 @@ local void gz_reset(state)
|
|||
}
|
||||
|
||||
/* Open a gzip file either by name or file descriptor. */
|
||||
local gzFile gz_open(path, fd, mode)
|
||||
const void *path;
|
||||
int fd;
|
||||
const char *mode;
|
||||
{
|
||||
local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
gz_statep state;
|
||||
z_size_t len;
|
||||
int oflag;
|
||||
|
@ -267,26 +257,17 @@ local gzFile gz_open(path, fd, mode)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile ZEXPORT gzopen(path, mode)
|
||||
const char *path;
|
||||
const char *mode;
|
||||
{
|
||||
gzFile ZEXPORT gzopen(const char *path, const char *mode) {
|
||||
return gz_open(path, -1, mode);
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile ZEXPORT gzopen64(path, mode)
|
||||
const char *path;
|
||||
const char *mode;
|
||||
{
|
||||
gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
|
||||
return gz_open(path, -1, mode);
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile ZEXPORT gzdopen(fd, mode)
|
||||
int fd;
|
||||
const char *mode;
|
||||
{
|
||||
gzFile ZEXPORT gzdopen(int fd, const char *mode) {
|
||||
char *path; /* identifier for error messages */
|
||||
gzFile gz;
|
||||
|
||||
|
@ -304,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
|
|||
|
||||
/* -- see zlib.h -- */
|
||||
#ifdef WIDECHAR
|
||||
gzFile ZEXPORT gzopen_w(path, mode)
|
||||
const wchar_t *path;
|
||||
const char *mode;
|
||||
{
|
||||
gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
|
||||
return gz_open(path, -2, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzbuffer(file, size)
|
||||
gzFile file;
|
||||
unsigned size;
|
||||
{
|
||||
int ZEXPORT gzbuffer(gzFile file, unsigned size) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
|
@ -333,16 +308,14 @@ int ZEXPORT gzbuffer(file, size)
|
|||
/* check and set requested size */
|
||||
if ((size << 1) < size)
|
||||
return -1; /* need to be able to double it */
|
||||
if (size < 2)
|
||||
size = 2; /* need two bytes to check magic header */
|
||||
if (size < 8)
|
||||
size = 8; /* needed to behave well with flushing */
|
||||
state->want = size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzrewind(file)
|
||||
gzFile file;
|
||||
{
|
||||
int ZEXPORT gzrewind(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
|
@ -363,11 +336,7 @@ int ZEXPORT gzrewind(file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t ZEXPORT gzseek64(file, offset, whence)
|
||||
gzFile file;
|
||||
z_off64_t offset;
|
||||
int whence;
|
||||
{
|
||||
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
|
||||
unsigned n;
|
||||
z_off64_t ret;
|
||||
gz_statep state;
|
||||
|
@ -397,7 +366,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
|
|||
/* if within raw area while reading, just go there */
|
||||
if (state->mode == GZ_READ && state->how == COPY &&
|
||||
state->x.pos + offset >= 0) {
|
||||
ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
|
||||
ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
state->x.have = 0;
|
||||
|
@ -440,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off_t ZEXPORT gzseek(file, offset, whence)
|
||||
gzFile file;
|
||||
z_off_t offset;
|
||||
int whence;
|
||||
{
|
||||
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
|
||||
z_off64_t ret;
|
||||
|
||||
ret = gzseek64(file, (z_off64_t)offset, whence);
|
||||
|
@ -452,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t ZEXPORT gztell64(file)
|
||||
gzFile file;
|
||||
{
|
||||
z_off64_t ZEXPORT gztell64(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
|
@ -469,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off_t ZEXPORT gztell(file)
|
||||
gzFile file;
|
||||
{
|
||||
z_off_t ZEXPORT gztell(gzFile file) {
|
||||
z_off64_t ret;
|
||||
|
||||
ret = gztell64(file);
|
||||
|
@ -479,9 +440,7 @@ z_off_t ZEXPORT gztell(file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t ZEXPORT gzoffset64(file)
|
||||
gzFile file;
|
||||
{
|
||||
z_off64_t ZEXPORT gzoffset64(gzFile file) {
|
||||
z_off64_t offset;
|
||||
gz_statep state;
|
||||
|
||||
|
@ -502,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off_t ZEXPORT gzoffset(file)
|
||||
gzFile file;
|
||||
{
|
||||
z_off_t ZEXPORT gzoffset(gzFile file) {
|
||||
z_off64_t ret;
|
||||
|
||||
ret = gzoffset64(file);
|
||||
|
@ -512,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzeof(file)
|
||||
gzFile file;
|
||||
{
|
||||
int ZEXPORT gzeof(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
|
@ -529,10 +484,7 @@ int ZEXPORT gzeof(file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
const char * ZEXPORT gzerror(file, errnum)
|
||||
gzFile file;
|
||||
int *errnum;
|
||||
{
|
||||
const char * ZEXPORT gzerror(gzFile file, int *errnum) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
|
@ -550,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
void ZEXPORT gzclearerr(file)
|
||||
gzFile file;
|
||||
{
|
||||
void ZEXPORT gzclearerr(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
|
@ -576,11 +526,7 @@ void ZEXPORT gzclearerr(file)
|
|||
memory). Simply save the error message as a static string. If there is an
|
||||
allocation failure constructing the error message, then convert the error to
|
||||
out of memory. */
|
||||
void ZLIB_INTERNAL gz_error(state, err, msg)
|
||||
gz_statep state;
|
||||
int err;
|
||||
const char *msg;
|
||||
{
|
||||
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
|
||||
/* free previously allocated message and clear */
|
||||
if (state->msg != NULL) {
|
||||
if (state->err != Z_MEM_ERROR)
|
||||
|
@ -617,21 +563,20 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef INT_MAX
|
||||
/* portably return maximum value for an int (when limits.h presumed not
|
||||
available) -- we need to do this to cover cases where 2's complement not
|
||||
used, since C standard permits 1's complement and sign-bit representations,
|
||||
otherwise we could just use ((unsigned)-1) >> 1 */
|
||||
unsigned ZLIB_INTERNAL gz_intmax()
|
||||
{
|
||||
unsigned p, q;
|
||||
|
||||
p = 1;
|
||||
unsigned ZLIB_INTERNAL gz_intmax(void) {
|
||||
#ifdef INT_MAX
|
||||
return INT_MAX;
|
||||
#else
|
||||
unsigned p = 1, q;
|
||||
do {
|
||||
q = p;
|
||||
p <<= 1;
|
||||
p++;
|
||||
} while (p > q);
|
||||
return q >> 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,29 +1,16 @@
|
|||
/* gzread.c -- zlib functions for reading gzip files
|
||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
|
||||
* Copyright (C) 2004-2017 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "gzguts.h"
|
||||
|
||||
/* Local functions */
|
||||
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
|
||||
local int gz_avail OF((gz_statep));
|
||||
local int gz_look OF((gz_statep));
|
||||
local int gz_decomp OF((gz_statep));
|
||||
local int gz_fetch OF((gz_statep));
|
||||
local int gz_skip OF((gz_statep, z_off64_t));
|
||||
local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
|
||||
|
||||
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
|
||||
state->fd, and update state->eof, state->err, and state->msg as appropriate.
|
||||
This function needs to loop on read(), since read() is not guaranteed to
|
||||
read the number of bytes requested, depending on the type of descriptor. */
|
||||
local int gz_load(state, buf, len, have)
|
||||
gz_statep state;
|
||||
unsigned char *buf;
|
||||
unsigned len;
|
||||
unsigned *have;
|
||||
{
|
||||
local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
|
||||
unsigned *have) {
|
||||
int ret;
|
||||
unsigned get, max = ((unsigned)-1 >> 2) + 1;
|
||||
|
||||
|
@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have)
|
|||
If strm->avail_in != 0, then the current data is moved to the beginning of
|
||||
the input buffer, and then the remainder of the buffer is loaded with the
|
||||
available data from the input file. */
|
||||
local int gz_avail(state)
|
||||
gz_statep state;
|
||||
{
|
||||
local int gz_avail(gz_statep state) {
|
||||
unsigned got;
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
|
@ -88,9 +73,7 @@ local int gz_avail(state)
|
|||
case, all further file reads will be directly to either the output buffer or
|
||||
a user buffer. If decompressing, the inflate state will be initialized.
|
||||
gz_look() will return 0 on success or -1 on failure. */
|
||||
local int gz_look(state)
|
||||
gz_statep state;
|
||||
{
|
||||
local int gz_look(gz_statep state) {
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
/* allocate read buffers and inflate memory */
|
||||
|
@ -157,11 +140,9 @@ local int gz_look(state)
|
|||
the output buffer is larger than the input buffer, which also assures
|
||||
space for gzungetc() */
|
||||
state->x.next = state->out;
|
||||
if (strm->avail_in) {
|
||||
memcpy(state->x.next, strm->next_in, strm->avail_in);
|
||||
state->x.have = strm->avail_in;
|
||||
strm->avail_in = 0;
|
||||
}
|
||||
memcpy(state->x.next, strm->next_in, strm->avail_in);
|
||||
state->x.have = strm->avail_in;
|
||||
strm->avail_in = 0;
|
||||
state->how = COPY;
|
||||
state->direct = 1;
|
||||
return 0;
|
||||
|
@ -172,9 +153,7 @@ local int gz_look(state)
|
|||
data. If the gzip stream completes, state->how is reset to LOOK to look for
|
||||
the next gzip stream or raw data, once state->x.have is depleted. Returns 0
|
||||
on success, -1 on failure. */
|
||||
local int gz_decomp(state)
|
||||
gz_statep state;
|
||||
{
|
||||
local int gz_decomp(gz_statep state) {
|
||||
int ret = Z_OK;
|
||||
unsigned had;
|
||||
z_streamp strm = &(state->strm);
|
||||
|
@ -226,9 +205,7 @@ local int gz_decomp(state)
|
|||
looked for to determine whether to copy or decompress. Returns -1 on error,
|
||||
otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
|
||||
end of the input file has been reached and all data has been processed. */
|
||||
local int gz_fetch(state)
|
||||
gz_statep state;
|
||||
{
|
||||
local int gz_fetch(gz_statep state) {
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
do {
|
||||
|
@ -256,10 +233,7 @@ local int gz_fetch(state)
|
|||
}
|
||||
|
||||
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
|
||||
local int gz_skip(state, len)
|
||||
gz_statep state;
|
||||
z_off64_t len;
|
||||
{
|
||||
local int gz_skip(gz_statep state, z_off64_t len) {
|
||||
unsigned n;
|
||||
|
||||
/* skip over len bytes or reach end-of-file, whichever comes first */
|
||||
|
@ -291,11 +265,7 @@ local int gz_skip(state, len)
|
|||
input. Return the number of bytes read. If zero is returned, either the
|
||||
end of file was reached, or there was an error. state->err must be
|
||||
consulted in that case to determine which. */
|
||||
local z_size_t gz_read(state, buf, len)
|
||||
gz_statep state;
|
||||
voidp buf;
|
||||
z_size_t len;
|
||||
{
|
||||
local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
|
||||
z_size_t got;
|
||||
unsigned n;
|
||||
|
||||
|
@ -314,9 +284,9 @@ local z_size_t gz_read(state, buf, len)
|
|||
got = 0;
|
||||
do {
|
||||
/* set n to the maximum amount of len that fits in an unsigned int */
|
||||
n = -1;
|
||||
n = (unsigned)-1;
|
||||
if (n > len)
|
||||
n = len;
|
||||
n = (unsigned)len;
|
||||
|
||||
/* first just try copying data from the output buffer */
|
||||
if (state->x.have) {
|
||||
|
@ -372,11 +342,7 @@ local z_size_t gz_read(state, buf, len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzread(file, buf, len)
|
||||
gzFile file;
|
||||
voidp buf;
|
||||
unsigned len;
|
||||
{
|
||||
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
|
@ -397,7 +363,7 @@ int ZEXPORT gzread(file, buf, len)
|
|||
}
|
||||
|
||||
/* read len or fewer bytes to buf */
|
||||
len = gz_read(state, buf, len);
|
||||
len = (unsigned)gz_read(state, buf, len);
|
||||
|
||||
/* check for an error */
|
||||
if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
|
||||
|
@ -408,12 +374,7 @@ int ZEXPORT gzread(file, buf, len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_size_t ZEXPORT gzfread(buf, size, nitems, file)
|
||||
voidp buf;
|
||||
z_size_t size;
|
||||
z_size_t nitems;
|
||||
gzFile file;
|
||||
{
|
||||
z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) {
|
||||
z_size_t len;
|
||||
gz_statep state;
|
||||
|
||||
|
@ -444,10 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
|
|||
#else
|
||||
# undef gzgetc
|
||||
#endif
|
||||
int ZEXPORT gzgetc(file)
|
||||
gzFile file;
|
||||
{
|
||||
int ret;
|
||||
int ZEXPORT gzgetc(gzFile file) {
|
||||
unsigned char buf[1];
|
||||
gz_statep state;
|
||||
|
||||
|
@ -469,21 +427,15 @@ int ZEXPORT gzgetc(file)
|
|||
}
|
||||
|
||||
/* nothing there -- try gz_read() */
|
||||
ret = gz_read(state, buf, 1);
|
||||
return ret < 1 ? -1 : buf[0];
|
||||
return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
|
||||
}
|
||||
|
||||
int ZEXPORT gzgetc_(file)
|
||||
gzFile file;
|
||||
{
|
||||
int ZEXPORT gzgetc_(gzFile file) {
|
||||
return gzgetc(file);
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzungetc(c, file)
|
||||
int c;
|
||||
gzFile file;
|
||||
{
|
||||
int ZEXPORT gzungetc(int c, gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
|
@ -491,6 +443,10 @@ int ZEXPORT gzungetc(c, file)
|
|||
return -1;
|
||||
state = (gz_statep)file;
|
||||
|
||||
/* in case this was just opened, set up the input buffer */
|
||||
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
|
||||
(void)gz_look(state);
|
||||
|
||||
/* check that we're reading and that there's no (serious) error */
|
||||
if (state->mode != GZ_READ ||
|
||||
(state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||
|
@ -540,11 +496,7 @@ int ZEXPORT gzungetc(c, file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
char * ZEXPORT gzgets(file, buf, len)
|
||||
gzFile file;
|
||||
char *buf;
|
||||
int len;
|
||||
{
|
||||
char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
|
||||
unsigned left, n;
|
||||
char *str;
|
||||
unsigned char *eol;
|
||||
|
@ -604,9 +556,7 @@ char * ZEXPORT gzgets(file, buf, len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzdirect(file)
|
||||
gzFile file;
|
||||
{
|
||||
int ZEXPORT gzdirect(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
|
@ -624,9 +574,7 @@ int ZEXPORT gzdirect(file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzclose_r(file)
|
||||
gzFile file;
|
||||
{
|
||||
int ZEXPORT gzclose_r(gzFile file) {
|
||||
int ret, err;
|
||||
gz_statep state;
|
||||
|
||||
|
|
|
@ -1,22 +1,14 @@
|
|||
/* gzwrite.c -- zlib functions for writing gzip files
|
||||
* Copyright (C) 2004-2017 Mark Adler
|
||||
* Copyright (C) 2004-2019 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "gzguts.h"
|
||||
|
||||
/* Local functions */
|
||||
local int gz_init OF((gz_statep));
|
||||
local int gz_comp OF((gz_statep, int));
|
||||
local int gz_zero OF((gz_statep, z_off64_t));
|
||||
local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
|
||||
|
||||
/* Initialize state for writing a gzip file. Mark initialization by setting
|
||||
state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
|
||||
success. */
|
||||
local int gz_init(state)
|
||||
gz_statep state;
|
||||
{
|
||||
local int gz_init(gz_statep state) {
|
||||
int ret;
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
|
@ -70,10 +62,7 @@ local int gz_init(state)
|
|||
deflate() flush value. If flush is Z_FINISH, then the deflate() state is
|
||||
reset to start a new gzip stream. If gz->direct is true, then simply write
|
||||
to the output file without compressing, and ignore flush. */
|
||||
local int gz_comp(state, flush)
|
||||
gz_statep state;
|
||||
int flush;
|
||||
{
|
||||
local int gz_comp(gz_statep state, int flush) {
|
||||
int ret, writ;
|
||||
unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
|
||||
z_streamp strm = &(state->strm);
|
||||
|
@ -97,6 +86,15 @@ local int gz_comp(state, flush)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* check for a pending reset */
|
||||
if (state->reset) {
|
||||
/* don't start a new gzip member unless there is data to write */
|
||||
if (strm->avail_in == 0)
|
||||
return 0;
|
||||
deflateReset(strm);
|
||||
state->reset = 0;
|
||||
}
|
||||
|
||||
/* run deflate() on provided input until it produces no more output */
|
||||
ret = Z_OK;
|
||||
do {
|
||||
|
@ -134,7 +132,7 @@ local int gz_comp(state, flush)
|
|||
|
||||
/* if that completed a deflate stream, allow another to start */
|
||||
if (flush == Z_FINISH)
|
||||
deflateReset(strm);
|
||||
state->reset = 1;
|
||||
|
||||
/* all done, no errors */
|
||||
return 0;
|
||||
|
@ -142,10 +140,7 @@ local int gz_comp(state, flush)
|
|||
|
||||
/* Compress len zeros to output. Return -1 on a write error or memory
|
||||
allocation failure by gz_comp(), or 0 on success. */
|
||||
local int gz_zero(state, len)
|
||||
gz_statep state;
|
||||
z_off64_t len;
|
||||
{
|
||||
local int gz_zero(gz_statep state, z_off64_t len) {
|
||||
int first;
|
||||
unsigned n;
|
||||
z_streamp strm = &(state->strm);
|
||||
|
@ -175,11 +170,7 @@ local int gz_zero(state, len)
|
|||
|
||||
/* Write len bytes from buf to file. Return the number of bytes written. If
|
||||
the returned value is less than len, then there was an error. */
|
||||
local z_size_t gz_write(state, buf, len)
|
||||
gz_statep state;
|
||||
voidpc buf;
|
||||
z_size_t len;
|
||||
{
|
||||
local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
|
||||
z_size_t put = len;
|
||||
|
||||
/* if len is zero, avoid unnecessary operations */
|
||||
|
@ -209,7 +200,7 @@ local z_size_t gz_write(state, buf, len)
|
|||
state->in);
|
||||
copy = state->size - have;
|
||||
if (copy > len)
|
||||
copy = len;
|
||||
copy = (unsigned)len;
|
||||
memcpy(state->in + have, buf, copy);
|
||||
state->strm.avail_in += copy;
|
||||
state->x.pos += copy;
|
||||
|
@ -229,7 +220,7 @@ local z_size_t gz_write(state, buf, len)
|
|||
do {
|
||||
unsigned n = (unsigned)-1;
|
||||
if (n > len)
|
||||
n = len;
|
||||
n = (unsigned)len;
|
||||
state->strm.avail_in = n;
|
||||
state->x.pos += n;
|
||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||
|
@ -243,11 +234,7 @@ local z_size_t gz_write(state, buf, len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzwrite(file, buf, len)
|
||||
gzFile file;
|
||||
voidpc buf;
|
||||
unsigned len;
|
||||
{
|
||||
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
|
@ -271,12 +258,8 @@ int ZEXPORT gzwrite(file, buf, len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
|
||||
voidpc buf;
|
||||
z_size_t size;
|
||||
z_size_t nitems;
|
||||
gzFile file;
|
||||
{
|
||||
z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
|
||||
gzFile file) {
|
||||
z_size_t len;
|
||||
gz_statep state;
|
||||
|
||||
|
@ -301,10 +284,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzputc(file, c)
|
||||
gzFile file;
|
||||
int c;
|
||||
{
|
||||
int ZEXPORT gzputc(gzFile file, int c) {
|
||||
unsigned have;
|
||||
unsigned char buf[1];
|
||||
gz_statep state;
|
||||
|
@ -349,12 +329,8 @@ int ZEXPORT gzputc(file, c)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzputs(file, str)
|
||||
gzFile file;
|
||||
const char *str;
|
||||
{
|
||||
int ret;
|
||||
z_size_t len;
|
||||
int ZEXPORT gzputs(gzFile file, const char *s) {
|
||||
z_size_t len, put;
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
|
@ -367,17 +343,20 @@ int ZEXPORT gzputs(file, str)
|
|||
return -1;
|
||||
|
||||
/* write string */
|
||||
len = strlen(str);
|
||||
ret = gz_write(state, str, len);
|
||||
return ret == 0 && len != 0 ? -1 : ret;
|
||||
len = strlen(s);
|
||||
if ((int)len < 0 || (unsigned)len != len) {
|
||||
gz_error(state, Z_STREAM_ERROR, "string length does not fit in int");
|
||||
return -1;
|
||||
}
|
||||
put = gz_write(state, s, len);
|
||||
return put < len ? -1 : (int)len;
|
||||
}
|
||||
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
#include <stdarg.h>
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
||||
{
|
||||
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
|
||||
int len;
|
||||
unsigned left;
|
||||
char *next;
|
||||
|
@ -441,15 +420,14 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
|||
strm->avail_in = state->size;
|
||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||
return state->err;
|
||||
memcpy(state->in, state->in + state->size, left);
|
||||
memmove(state->in, state->in + state->size, left);
|
||||
strm->next_in = state->in;
|
||||
strm->avail_in = left;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
||||
{
|
||||
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
|
||||
va_list va;
|
||||
int ret;
|
||||
|
||||
|
@ -462,13 +440,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
|||
#else /* !STDC && !Z_HAVE_STDARG_H */
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
|
||||
gzFile file;
|
||||
const char *format;
|
||||
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
|
||||
{
|
||||
int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
|
||||
int a4, int a5, int a6, int a7, int a8, int a9, int a10,
|
||||
int a11, int a12, int a13, int a14, int a15, int a16,
|
||||
int a17, int a18, int a19, int a20) {
|
||||
unsigned len, left;
|
||||
char *next;
|
||||
gz_statep state;
|
||||
|
@ -540,7 +515,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
|||
strm->avail_in = state->size;
|
||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||
return state->err;
|
||||
memcpy(state->in, state->in + state->size, left);
|
||||
memmove(state->in, state->in + state->size, left);
|
||||
strm->next_in = state->in;
|
||||
strm->avail_in = left;
|
||||
}
|
||||
|
@ -550,10 +525,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
|||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzflush(file, flush)
|
||||
gzFile file;
|
||||
int flush;
|
||||
{
|
||||
int ZEXPORT gzflush(gzFile file, int flush) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
|
@ -582,11 +554,7 @@ int ZEXPORT gzflush(file, flush)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzsetparams(file, level, strategy)
|
||||
gzFile file;
|
||||
int level;
|
||||
int strategy;
|
||||
{
|
||||
int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
|
||||
gz_statep state;
|
||||
z_streamp strm;
|
||||
|
||||
|
@ -597,7 +565,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
|
|||
strm = &(state->strm);
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
if (state->mode != GZ_WRITE || state->err != Z_OK)
|
||||
if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
/* if no change is requested, then do nothing */
|
||||
|
@ -624,9 +592,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzclose_w(file)
|
||||
gzFile file;
|
||||
{
|
||||
int ZEXPORT gzclose_w(gzFile file) {
|
||||
int ret = Z_OK;
|
||||
gz_statep state;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* infback.c -- inflate using a call-back interface
|
||||
* Copyright (C) 1995-2016 Mark Adler
|
||||
* Copyright (C) 1995-2022 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -15,9 +15,6 @@
|
|||
#include "inflate.h"
|
||||
#include "inffast.h"
|
||||
|
||||
/* function prototypes */
|
||||
local void fixedtables OF((struct inflate_state FAR *state));
|
||||
|
||||
/*
|
||||
strm provides memory allocation functions in zalloc and zfree, or
|
||||
Z_NULL to use the library memory allocation functions.
|
||||
|
@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state));
|
|||
windowBits is in the range 8..15, and window is a user-supplied
|
||||
window and output buffer that is 2**windowBits bytes.
|
||||
*/
|
||||
int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
|
||||
z_streamp strm;
|
||||
int windowBits;
|
||||
unsigned char FAR *window;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
|
||||
unsigned char FAR *window, const char *version,
|
||||
int stream_size) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
||||
|
@ -66,6 +59,7 @@ int stream_size;
|
|||
state->window = window;
|
||||
state->wnext = 0;
|
||||
state->whave = 0;
|
||||
state->sane = 1;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
@ -79,9 +73,7 @@ int stream_size;
|
|||
used for threaded applications, since the rewriting of the tables and virgin
|
||||
may not be thread-safe.
|
||||
*/
|
||||
local void fixedtables(state)
|
||||
struct inflate_state FAR *state;
|
||||
{
|
||||
local void fixedtables(struct inflate_state FAR *state) {
|
||||
#ifdef BUILDFIXED
|
||||
static int virgin = 1;
|
||||
static code *lenfix, *distfix;
|
||||
|
@ -247,13 +239,8 @@ struct inflate_state FAR *state;
|
|||
inflateBack() can also return Z_STREAM_ERROR if the input parameters
|
||||
are not correct, i.e. strm is Z_NULL or the state was not initialized.
|
||||
*/
|
||||
int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
|
||||
z_streamp strm;
|
||||
in_func in;
|
||||
void FAR *in_desc;
|
||||
out_func out;
|
||||
void FAR *out_desc;
|
||||
{
|
||||
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
|
||||
out_func out, void FAR *out_desc) {
|
||||
struct inflate_state FAR *state;
|
||||
z_const unsigned char FAR *next; /* next input */
|
||||
unsigned char FAR *put; /* next output */
|
||||
|
@ -477,6 +464,7 @@ void FAR *out_desc;
|
|||
}
|
||||
Tracev((stderr, "inflate: codes ok\n"));
|
||||
state->mode = LEN;
|
||||
/* fallthrough */
|
||||
|
||||
case LEN:
|
||||
/* use inflate_fast() if we have enough input and output */
|
||||
|
@ -604,33 +592,33 @@ void FAR *out_desc;
|
|||
break;
|
||||
|
||||
case DONE:
|
||||
/* inflate stream terminated properly -- write leftover output */
|
||||
/* inflate stream terminated properly */
|
||||
ret = Z_STREAM_END;
|
||||
if (left < state->wsize) {
|
||||
if (out(out_desc, state->window, state->wsize - left))
|
||||
ret = Z_BUF_ERROR;
|
||||
}
|
||||
goto inf_leave;
|
||||
|
||||
case BAD:
|
||||
ret = Z_DATA_ERROR;
|
||||
goto inf_leave;
|
||||
|
||||
default: /* can't happen, but makes compilers happy */
|
||||
default:
|
||||
/* can't happen, but makes compilers happy */
|
||||
ret = Z_STREAM_ERROR;
|
||||
goto inf_leave;
|
||||
}
|
||||
|
||||
/* Return unused input */
|
||||
/* Write leftover output and return unused input */
|
||||
inf_leave:
|
||||
if (left < state->wsize) {
|
||||
if (out(out_desc, state->window, state->wsize - left) &&
|
||||
ret == Z_STREAM_END)
|
||||
ret = Z_BUF_ERROR;
|
||||
}
|
||||
strm->next_in = next;
|
||||
strm->avail_in = have;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateBackEnd(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
int ZEXPORT inflateBackEnd(z_streamp strm) {
|
||||
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
||||
return Z_STREAM_ERROR;
|
||||
ZFREE(strm, strm->state);
|
||||
|
|
|
@ -47,10 +47,7 @@
|
|||
requires strm->avail_out >= 258 for each loop to avoid checking for
|
||||
output space.
|
||||
*/
|
||||
void ZLIB_INTERNAL inflate_fast(strm, start)
|
||||
z_streamp strm;
|
||||
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||
{
|
||||
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 */
|
||||
|
@ -70,7 +67,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||
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 here; /* retrieved table entry */
|
||||
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 */
|
||||
|
@ -107,20 +104,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
}
|
||||
here = lcode[hold & lmask];
|
||||
here = lcode + (hold & lmask);
|
||||
dolen:
|
||||
op = (unsigned)(here.bits);
|
||||
op = (unsigned)(here->bits);
|
||||
hold >>= op;
|
||||
bits -= op;
|
||||
op = (unsigned)(here.op);
|
||||
op = (unsigned)(here->op);
|
||||
if (op == 0) { /* literal */
|
||||
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||
Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
|
||||
"inflate: literal '%c'\n" :
|
||||
"inflate: literal 0x%02x\n", here.val));
|
||||
*out++ = (unsigned char)(here.val);
|
||||
"inflate: literal 0x%02x\n", here->val));
|
||||
*out++ = (unsigned char)(here->val);
|
||||
}
|
||||
else if (op & 16) { /* length base */
|
||||
len = (unsigned)(here.val);
|
||||
len = (unsigned)(here->val);
|
||||
op &= 15; /* number of extra bits */
|
||||
if (op) {
|
||||
if (bits < op) {
|
||||
|
@ -138,14 +135,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||
hold += (unsigned long)(*in++) << bits;
|
||||
bits += 8;
|
||||
}
|
||||
here = dcode[hold & dmask];
|
||||
here = dcode + (hold & dmask);
|
||||
dodist:
|
||||
op = (unsigned)(here.bits);
|
||||
op = (unsigned)(here->bits);
|
||||
hold >>= op;
|
||||
bits -= op;
|
||||
op = (unsigned)(here.op);
|
||||
op = (unsigned)(here->op);
|
||||
if (op & 16) { /* distance base */
|
||||
dist = (unsigned)(here.val);
|
||||
dist = (unsigned)(here->val);
|
||||
op &= 15; /* number of extra bits */
|
||||
if (bits < op) {
|
||||
hold += (unsigned long)(*in++) << bits;
|
||||
|
@ -264,7 +261,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||
}
|
||||
}
|
||||
else if ((op & 64) == 0) { /* 2nd level distance code */
|
||||
here = dcode[here.val + (hold & ((1U << op) - 1))];
|
||||
here = dcode + here->val + (hold & ((1U << op) - 1));
|
||||
goto dodist;
|
||||
}
|
||||
else {
|
||||
|
@ -274,7 +271,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||
}
|
||||
}
|
||||
else if ((op & 64) == 0) { /* 2nd level length code */
|
||||
here = lcode[here.val + (hold & ((1U << op) - 1))];
|
||||
here = lcode + here->val + (hold & ((1U << op) - 1));
|
||||
goto dolen;
|
||||
}
|
||||
else if (op & 32) { /* end-of-block */
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
|
||||
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* inflate.c -- zlib decompression
|
||||
* Copyright (C) 1995-2016 Mark Adler
|
||||
* Copyright (C) 1995-2022 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -91,20 +91,7 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* function prototypes */
|
||||
local int inflateStateCheck OF((z_streamp strm));
|
||||
local void fixedtables OF((struct inflate_state FAR *state));
|
||||
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
|
||||
unsigned copy));
|
||||
#ifdef BUILDFIXED
|
||||
void makefixed OF((void));
|
||||
#endif
|
||||
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
|
||||
unsigned len));
|
||||
|
||||
local int inflateStateCheck(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
local int inflateStateCheck(z_streamp strm) {
|
||||
struct inflate_state FAR *state;
|
||||
if (strm == Z_NULL ||
|
||||
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
|
||||
|
@ -116,9 +103,7 @@ z_streamp strm;
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateResetKeep(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
int ZEXPORT inflateResetKeep(z_streamp strm) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
|
@ -130,6 +115,7 @@ z_streamp strm;
|
|||
state->mode = HEAD;
|
||||
state->last = 0;
|
||||
state->havedict = 0;
|
||||
state->flags = -1;
|
||||
state->dmax = 32768U;
|
||||
state->head = Z_NULL;
|
||||
state->hold = 0;
|
||||
|
@ -141,9 +127,7 @@ z_streamp strm;
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateReset(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
int ZEXPORT inflateReset(z_streamp strm) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
|
@ -154,10 +138,7 @@ z_streamp strm;
|
|||
return inflateResetKeep(strm);
|
||||
}
|
||||
|
||||
int ZEXPORT inflateReset2(strm, windowBits)
|
||||
z_streamp strm;
|
||||
int windowBits;
|
||||
{
|
||||
int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
|
||||
int wrap;
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -167,6 +148,8 @@ int windowBits;
|
|||
|
||||
/* extract wrap request from windowBits parameter */
|
||||
if (windowBits < 0) {
|
||||
if (windowBits < -15)
|
||||
return Z_STREAM_ERROR;
|
||||
wrap = 0;
|
||||
windowBits = -windowBits;
|
||||
}
|
||||
|
@ -192,12 +175,8 @@ int windowBits;
|
|||
return inflateReset(strm);
|
||||
}
|
||||
|
||||
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
|
||||
z_streamp strm;
|
||||
int windowBits;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
|
||||
const char *version, int stream_size) {
|
||||
int ret;
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -236,22 +215,17 @@ int stream_size;
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateInit_(strm, version, stream_size)
|
||||
z_streamp strm;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
int ZEXPORT inflateInit_(z_streamp strm, const char *version,
|
||||
int stream_size) {
|
||||
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
|
||||
}
|
||||
|
||||
int ZEXPORT inflatePrime(strm, bits, value)
|
||||
z_streamp strm;
|
||||
int bits;
|
||||
int value;
|
||||
{
|
||||
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
if (bits == 0)
|
||||
return Z_OK;
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
if (bits < 0) {
|
||||
state->hold = 0;
|
||||
|
@ -275,9 +249,7 @@ int value;
|
|||
used for threaded applications, since the rewriting of the tables and virgin
|
||||
may not be thread-safe.
|
||||
*/
|
||||
local void fixedtables(state)
|
||||
struct inflate_state FAR *state;
|
||||
{
|
||||
local void fixedtables(struct inflate_state FAR *state) {
|
||||
#ifdef BUILDFIXED
|
||||
static int virgin = 1;
|
||||
static code *lenfix, *distfix;
|
||||
|
@ -339,7 +311,7 @@ struct inflate_state FAR *state;
|
|||
|
||||
a.out > inffixed.h
|
||||
*/
|
||||
void makefixed()
|
||||
void makefixed(void)
|
||||
{
|
||||
unsigned low, size;
|
||||
struct inflate_state state;
|
||||
|
@ -393,11 +365,7 @@ void makefixed()
|
|||
output will fall in the output data, making match copies simpler and faster.
|
||||
The advantage may be dependent on the size of the processor's data caches.
|
||||
*/
|
||||
local int updatewindow(strm, end, copy)
|
||||
z_streamp strm;
|
||||
const Bytef *end;
|
||||
unsigned copy;
|
||||
{
|
||||
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
|
||||
struct inflate_state FAR *state;
|
||||
unsigned dist;
|
||||
|
||||
|
@ -447,10 +415,10 @@ unsigned copy;
|
|||
|
||||
/* check function to use adler32() for zlib or crc32() for gzip */
|
||||
#ifdef GUNZIP
|
||||
# define UPDATE(check, buf, len) \
|
||||
# define UPDATE_CHECK(check, buf, len) \
|
||||
(state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
|
||||
#else
|
||||
# define UPDATE(check, buf, len) adler32(check, buf, len)
|
||||
# define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
|
||||
#endif
|
||||
|
||||
/* check macros for header crc */
|
||||
|
@ -619,10 +587,7 @@ unsigned copy;
|
|||
will return Z_BUF_ERROR if it has not reached the end of the stream.
|
||||
*/
|
||||
|
||||
int ZEXPORT inflate(strm, flush)
|
||||
z_streamp strm;
|
||||
int flush;
|
||||
{
|
||||
int ZEXPORT inflate(z_streamp strm, int flush) {
|
||||
struct inflate_state FAR *state;
|
||||
z_const unsigned char FAR *next; /* next input */
|
||||
unsigned char FAR *put; /* next output */
|
||||
|
@ -670,7 +635,6 @@ int flush;
|
|||
state->mode = FLAGS;
|
||||
break;
|
||||
}
|
||||
state->flags = 0; /* expect zlib header */
|
||||
if (state->head != Z_NULL)
|
||||
state->head->done = -1;
|
||||
if (!(state->wrap & 1) || /* check if zlib header allowed */
|
||||
|
@ -697,6 +661,7 @@ int flush;
|
|||
break;
|
||||
}
|
||||
state->dmax = 1U << len;
|
||||
state->flags = 0; /* indicate zlib header */
|
||||
Tracev((stderr, "inflate: zlib header ok\n"));
|
||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||
state->mode = hold & 0x200 ? DICTID : TYPE;
|
||||
|
@ -722,6 +687,7 @@ int flush;
|
|||
CRC2(state->check, hold);
|
||||
INITBITS();
|
||||
state->mode = TIME;
|
||||
/* fallthrough */
|
||||
case TIME:
|
||||
NEEDBITS(32);
|
||||
if (state->head != Z_NULL)
|
||||
|
@ -730,6 +696,7 @@ int flush;
|
|||
CRC4(state->check, hold);
|
||||
INITBITS();
|
||||
state->mode = OS;
|
||||
/* fallthrough */
|
||||
case OS:
|
||||
NEEDBITS(16);
|
||||
if (state->head != Z_NULL) {
|
||||
|
@ -740,6 +707,7 @@ int flush;
|
|||
CRC2(state->check, hold);
|
||||
INITBITS();
|
||||
state->mode = EXLEN;
|
||||
/* fallthrough */
|
||||
case EXLEN:
|
||||
if (state->flags & 0x0400) {
|
||||
NEEDBITS(16);
|
||||
|
@ -753,14 +721,16 @@ int flush;
|
|||
else if (state->head != Z_NULL)
|
||||
state->head->extra = Z_NULL;
|
||||
state->mode = EXTRA;
|
||||
/* fallthrough */
|
||||
case EXTRA:
|
||||
if (state->flags & 0x0400) {
|
||||
copy = state->length;
|
||||
if (copy > have) copy = have;
|
||||
if (copy) {
|
||||
if (state->head != Z_NULL &&
|
||||
state->head->extra != Z_NULL) {
|
||||
len = state->head->extra_len - state->length;
|
||||
state->head->extra != Z_NULL &&
|
||||
(len = state->head->extra_len - state->length) <
|
||||
state->head->extra_max) {
|
||||
zmemcpy(state->head->extra + len, next,
|
||||
len + copy > state->head->extra_max ?
|
||||
state->head->extra_max - len : copy);
|
||||
|
@ -775,6 +745,7 @@ int flush;
|
|||
}
|
||||
state->length = 0;
|
||||
state->mode = NAME;
|
||||
/* fallthrough */
|
||||
case NAME:
|
||||
if (state->flags & 0x0800) {
|
||||
if (have == 0) goto inf_leave;
|
||||
|
@ -796,6 +767,7 @@ int flush;
|
|||
state->head->name = Z_NULL;
|
||||
state->length = 0;
|
||||
state->mode = COMMENT;
|
||||
/* fallthrough */
|
||||
case COMMENT:
|
||||
if (state->flags & 0x1000) {
|
||||
if (have == 0) goto inf_leave;
|
||||
|
@ -816,6 +788,7 @@ int flush;
|
|||
else if (state->head != Z_NULL)
|
||||
state->head->comment = Z_NULL;
|
||||
state->mode = HCRC;
|
||||
/* fallthrough */
|
||||
case HCRC:
|
||||
if (state->flags & 0x0200) {
|
||||
NEEDBITS(16);
|
||||
|
@ -839,6 +812,7 @@ int flush;
|
|||
strm->adler = state->check = ZSWAP32(hold);
|
||||
INITBITS();
|
||||
state->mode = DICT;
|
||||
/* fallthrough */
|
||||
case DICT:
|
||||
if (state->havedict == 0) {
|
||||
RESTORE();
|
||||
|
@ -846,8 +820,10 @@ int flush;
|
|||
}
|
||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||
state->mode = TYPE;
|
||||
/* fallthrough */
|
||||
case TYPE:
|
||||
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
|
||||
/* fallthrough */
|
||||
case TYPEDO:
|
||||
if (state->last) {
|
||||
BYTEBITS();
|
||||
|
@ -898,8 +874,10 @@ int flush;
|
|||
INITBITS();
|
||||
state->mode = COPY_;
|
||||
if (flush == Z_TREES) goto inf_leave;
|
||||
/* fallthrough */
|
||||
case COPY_:
|
||||
state->mode = COPY;
|
||||
/* fallthrough */
|
||||
case COPY:
|
||||
copy = state->length;
|
||||
if (copy) {
|
||||
|
@ -935,6 +913,7 @@ int flush;
|
|||
Tracev((stderr, "inflate: table sizes ok\n"));
|
||||
state->have = 0;
|
||||
state->mode = LENLENS;
|
||||
/* fallthrough */
|
||||
case LENLENS:
|
||||
while (state->have < state->ncode) {
|
||||
NEEDBITS(3);
|
||||
|
@ -956,6 +935,7 @@ int flush;
|
|||
Tracev((stderr, "inflate: code lengths ok\n"));
|
||||
state->have = 0;
|
||||
state->mode = CODELENS;
|
||||
/* fallthrough */
|
||||
case CODELENS:
|
||||
while (state->have < state->nlen + state->ndist) {
|
||||
for (;;) {
|
||||
|
@ -1039,8 +1019,10 @@ int flush;
|
|||
Tracev((stderr, "inflate: codes ok\n"));
|
||||
state->mode = LEN_;
|
||||
if (flush == Z_TREES) goto inf_leave;
|
||||
/* fallthrough */
|
||||
case LEN_:
|
||||
state->mode = LEN;
|
||||
/* fallthrough */
|
||||
case LEN:
|
||||
if (have >= 6 && left >= 258) {
|
||||
RESTORE();
|
||||
|
@ -1090,6 +1072,7 @@ int flush;
|
|||
}
|
||||
state->extra = (unsigned)(here.op) & 15;
|
||||
state->mode = LENEXT;
|
||||
/* fallthrough */
|
||||
case LENEXT:
|
||||
if (state->extra) {
|
||||
NEEDBITS(state->extra);
|
||||
|
@ -1100,6 +1083,7 @@ int flush;
|
|||
Tracevv((stderr, "inflate: length %u\n", state->length));
|
||||
state->was = state->length;
|
||||
state->mode = DIST;
|
||||
/* fallthrough */
|
||||
case DIST:
|
||||
for (;;) {
|
||||
here = state->distcode[BITS(state->distbits)];
|
||||
|
@ -1127,6 +1111,7 @@ int flush;
|
|||
state->offset = (unsigned)here.val;
|
||||
state->extra = (unsigned)(here.op) & 15;
|
||||
state->mode = DISTEXT;
|
||||
/* fallthrough */
|
||||
case DISTEXT:
|
||||
if (state->extra) {
|
||||
NEEDBITS(state->extra);
|
||||
|
@ -1143,6 +1128,7 @@ int flush;
|
|||
#endif
|
||||
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
||||
state->mode = MATCH;
|
||||
/* fallthrough */
|
||||
case MATCH:
|
||||
if (left == 0) goto inf_leave;
|
||||
copy = out - left;
|
||||
|
@ -1202,7 +1188,7 @@ int flush;
|
|||
state->total += out;
|
||||
if ((state->wrap & 4) && out)
|
||||
strm->adler = state->check =
|
||||
UPDATE(state->check, put - out, out);
|
||||
UPDATE_CHECK(state->check, put - out, out);
|
||||
out = left;
|
||||
if ((state->wrap & 4) && (
|
||||
#ifdef GUNZIP
|
||||
|
@ -1218,10 +1204,11 @@ int flush;
|
|||
}
|
||||
#ifdef GUNZIP
|
||||
state->mode = LENGTH;
|
||||
/* fallthrough */
|
||||
case LENGTH:
|
||||
if (state->wrap && state->flags) {
|
||||
NEEDBITS(32);
|
||||
if (hold != (state->total & 0xffffffffUL)) {
|
||||
if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
|
||||
strm->msg = (char *)"incorrect length check";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
|
@ -1231,6 +1218,7 @@ int flush;
|
|||
}
|
||||
#endif
|
||||
state->mode = DONE;
|
||||
/* fallthrough */
|
||||
case DONE:
|
||||
ret = Z_STREAM_END;
|
||||
goto inf_leave;
|
||||
|
@ -1240,6 +1228,7 @@ int flush;
|
|||
case MEM:
|
||||
return Z_MEM_ERROR;
|
||||
case SYNC:
|
||||
/* fallthrough */
|
||||
default:
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
|
@ -1265,7 +1254,7 @@ int flush;
|
|||
state->total += out;
|
||||
if ((state->wrap & 4) && out)
|
||||
strm->adler = state->check =
|
||||
UPDATE(state->check, strm->next_out - out, out);
|
||||
UPDATE_CHECK(state->check, strm->next_out - out, out);
|
||||
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
|
||||
(state->mode == TYPE ? 128 : 0) +
|
||||
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
||||
|
@ -1274,9 +1263,7 @@ int flush;
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateEnd(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
int ZEXPORT inflateEnd(z_streamp strm) {
|
||||
struct inflate_state FAR *state;
|
||||
if (inflateStateCheck(strm))
|
||||
return Z_STREAM_ERROR;
|
||||
|
@ -1288,11 +1275,8 @@ z_streamp strm;
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
|
||||
z_streamp strm;
|
||||
Bytef *dictionary;
|
||||
uInt *dictLength;
|
||||
{
|
||||
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
|
||||
uInt *dictLength) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
/* check state */
|
||||
|
@ -1311,11 +1295,8 @@ uInt *dictLength;
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
||||
z_streamp strm;
|
||||
const Bytef *dictionary;
|
||||
uInt dictLength;
|
||||
{
|
||||
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
||||
uInt dictLength) {
|
||||
struct inflate_state FAR *state;
|
||||
unsigned long dictid;
|
||||
int ret;
|
||||
|
@ -1346,10 +1327,7 @@ uInt dictLength;
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateGetHeader(strm, head)
|
||||
z_streamp strm;
|
||||
gz_headerp head;
|
||||
{
|
||||
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
/* check state */
|
||||
|
@ -1374,11 +1352,8 @@ gz_headerp head;
|
|||
called again with more data and the *have state. *have is initialized to
|
||||
zero for the first call.
|
||||
*/
|
||||
local unsigned syncsearch(have, buf, len)
|
||||
unsigned FAR *have;
|
||||
const unsigned char FAR *buf;
|
||||
unsigned len;
|
||||
{
|
||||
local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf,
|
||||
unsigned len) {
|
||||
unsigned got;
|
||||
unsigned next;
|
||||
|
||||
|
@ -1397,10 +1372,9 @@ unsigned len;
|
|||
return next;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateSync(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
int ZEXPORT inflateSync(z_streamp strm) {
|
||||
unsigned len; /* number of bytes to look at or looked at */
|
||||
int flags; /* temporary to save header status */
|
||||
unsigned long in, out; /* temporary to save total_in and total_out */
|
||||
unsigned char buf[4]; /* to restore bit buffer to byte string */
|
||||
struct inflate_state FAR *state;
|
||||
|
@ -1413,7 +1387,7 @@ z_streamp strm;
|
|||
/* if first time, start search in bit buffer */
|
||||
if (state->mode != SYNC) {
|
||||
state->mode = SYNC;
|
||||
state->hold <<= state->bits & 7;
|
||||
state->hold >>= state->bits & 7;
|
||||
state->bits -= state->bits & 7;
|
||||
len = 0;
|
||||
while (state->bits >= 8) {
|
||||
|
@ -1433,9 +1407,15 @@ z_streamp strm;
|
|||
|
||||
/* return no joy or set up to restart inflate() on a new block */
|
||||
if (state->have != 4) return Z_DATA_ERROR;
|
||||
if (state->flags == -1)
|
||||
state->wrap = 0; /* if no header yet, treat as raw */
|
||||
else
|
||||
state->wrap &= ~4; /* no point in computing a check value now */
|
||||
flags = state->flags;
|
||||
in = strm->total_in; out = strm->total_out;
|
||||
inflateReset(strm);
|
||||
strm->total_in = in; strm->total_out = out;
|
||||
state->flags = flags;
|
||||
state->mode = TYPE;
|
||||
return Z_OK;
|
||||
}
|
||||
|
@ -1448,9 +1428,7 @@ z_streamp strm;
|
|||
block. When decompressing, PPP checks that at the end of input packet,
|
||||
inflate is waiting for these length bytes.
|
||||
*/
|
||||
int ZEXPORT inflateSyncPoint(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
int ZEXPORT inflateSyncPoint(z_streamp strm) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
|
@ -1458,10 +1436,7 @@ z_streamp strm;
|
|||
return state->mode == STORED && state->bits == 0;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateCopy(dest, source)
|
||||
z_streamp dest;
|
||||
z_streamp source;
|
||||
{
|
||||
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
|
||||
struct inflate_state FAR *state;
|
||||
struct inflate_state FAR *copy;
|
||||
unsigned char FAR *window;
|
||||
|
@ -1505,10 +1480,7 @@ z_streamp source;
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateUndermine(strm, subvert)
|
||||
z_streamp strm;
|
||||
int subvert;
|
||||
{
|
||||
int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
|
@ -1523,24 +1495,19 @@ int subvert;
|
|||
#endif
|
||||
}
|
||||
|
||||
int ZEXPORT inflateValidate(strm, check)
|
||||
z_streamp strm;
|
||||
int check;
|
||||
{
|
||||
int ZEXPORT inflateValidate(z_streamp strm, int check) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
if (check)
|
||||
if (check && state->wrap)
|
||||
state->wrap |= 4;
|
||||
else
|
||||
state->wrap &= ~4;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
long ZEXPORT inflateMark(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
long ZEXPORT inflateMark(z_streamp strm) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (inflateStateCheck(strm))
|
||||
|
@ -1551,9 +1518,7 @@ z_streamp strm;
|
|||
(state->mode == MATCH ? state->was - state->length : 0));
|
||||
}
|
||||
|
||||
unsigned long ZEXPORT inflateCodesUsed(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) {
|
||||
struct inflate_state FAR *state;
|
||||
if (inflateStateCheck(strm)) return (unsigned long)-1;
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* inflate.h -- internal inflate state definition
|
||||
* Copyright (C) 1995-2016 Mark Adler
|
||||
* Copyright (C) 1995-2019 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -86,7 +86,8 @@ struct inflate_state {
|
|||
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) */
|
||||
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 */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||
* Copyright (C) 1995-2017 Mark Adler
|
||||
* Copyright (C) 1995-2024 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define MAXBITS 15
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
|
||||
" 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
|
||||
|
@ -29,14 +29,9 @@ const char inflate_copyright[] =
|
|||
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(type, lens, codes, table, bits, work)
|
||||
codetype type;
|
||||
unsigned short FAR *lens;
|
||||
unsigned codes;
|
||||
code FAR * FAR *table;
|
||||
unsigned FAR *bits;
|
||||
unsigned short FAR *work;
|
||||
{
|
||||
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 */
|
||||
|
@ -62,7 +57,7 @@ unsigned short FAR *work;
|
|||
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, 77, 202};
|
||||
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,
|
||||
|
|
|
@ -38,11 +38,11 @@ typedef struct {
|
|||
/* 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 distribtution. The arguments to that
|
||||
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 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
|
||||
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. */
|
||||
|
@ -57,6 +57,6 @@ typedef enum {
|
|||
DISTS
|
||||
} codetype;
|
||||
|
||||
int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work));
|
||||
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* trees.c -- output deflated data using Huffman coding
|
||||
* Copyright (C) 1995-2017 Jean-loup Gailly
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly
|
||||
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
@ -122,39 +122,116 @@ struct static_tree_desc_s {
|
|||
int max_length; /* max bit length for the codes */
|
||||
};
|
||||
|
||||
local const static_tree_desc static_l_desc =
|
||||
#ifdef NO_INIT_GLOBAL_POINTERS
|
||||
# define TCONST
|
||||
#else
|
||||
# define TCONST const
|
||||
#endif
|
||||
|
||||
local TCONST static_tree_desc static_l_desc =
|
||||
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
|
||||
|
||||
local const static_tree_desc static_d_desc =
|
||||
local TCONST static_tree_desc static_d_desc =
|
||||
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
|
||||
|
||||
local const static_tree_desc static_bl_desc =
|
||||
local TCONST static_tree_desc static_bl_desc =
|
||||
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
|
||||
|
||||
/* ===========================================================================
|
||||
* Local (static) routines in this file.
|
||||
* Output a short LSB first on the stream.
|
||||
* IN assertion: there is enough room in pendingBuf.
|
||||
*/
|
||||
#define put_short(s, w) { \
|
||||
put_byte(s, (uch)((w) & 0xff)); \
|
||||
put_byte(s, (uch)((ush)(w) >> 8)); \
|
||||
}
|
||||
|
||||
local void tr_static_init OF((void));
|
||||
local void init_block OF((deflate_state *s));
|
||||
local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
|
||||
local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
|
||||
local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
|
||||
local void build_tree OF((deflate_state *s, tree_desc *desc));
|
||||
local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
||||
local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
||||
local int build_bl_tree OF((deflate_state *s));
|
||||
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
||||
int blcodes));
|
||||
local void compress_block OF((deflate_state *s, const ct_data *ltree,
|
||||
const ct_data *dtree));
|
||||
local int detect_data_type OF((deflate_state *s));
|
||||
local unsigned bi_reverse OF((unsigned value, int length));
|
||||
local void bi_windup OF((deflate_state *s));
|
||||
local void bi_flush OF((deflate_state *s));
|
||||
/* ===========================================================================
|
||||
* Reverse the first len bits of a code, using straightforward code (a faster
|
||||
* method would use a table)
|
||||
* IN assertion: 1 <= len <= 15
|
||||
*/
|
||||
local unsigned bi_reverse(unsigned code, int len) {
|
||||
register unsigned res = 0;
|
||||
do {
|
||||
res |= code & 1;
|
||||
code >>= 1, res <<= 1;
|
||||
} while (--len > 0);
|
||||
return res >> 1;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Flush the bit buffer, keeping at most 7 bits in it.
|
||||
*/
|
||||
local void bi_flush(deflate_state *s) {
|
||||
if (s->bi_valid == 16) {
|
||||
put_short(s, s->bi_buf);
|
||||
s->bi_buf = 0;
|
||||
s->bi_valid = 0;
|
||||
} else if (s->bi_valid >= 8) {
|
||||
put_byte(s, (Byte)s->bi_buf);
|
||||
s->bi_buf >>= 8;
|
||||
s->bi_valid -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Flush the bit buffer and align the output on a byte boundary
|
||||
*/
|
||||
local void bi_windup(deflate_state *s) {
|
||||
if (s->bi_valid > 8) {
|
||||
put_short(s, s->bi_buf);
|
||||
} else if (s->bi_valid > 0) {
|
||||
put_byte(s, (Byte)s->bi_buf);
|
||||
}
|
||||
s->bi_buf = 0;
|
||||
s->bi_valid = 0;
|
||||
#ifdef ZLIB_DEBUG
|
||||
s->bits_sent = (s->bits_sent + 7) & ~7;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Generate the codes for a given tree and bit counts (which need not be
|
||||
* optimal).
|
||||
* IN assertion: the array bl_count contains the bit length statistics for
|
||||
* the given tree and the field len is set for all tree elements.
|
||||
* OUT assertion: the field code is set for all tree elements of non
|
||||
* zero code length.
|
||||
*/
|
||||
local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) {
|
||||
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
||||
unsigned code = 0; /* running code value */
|
||||
int bits; /* bit index */
|
||||
int n; /* code index */
|
||||
|
||||
/* The distribution counts are first used to generate the code values
|
||||
* without bit reversal.
|
||||
*/
|
||||
for (bits = 1; bits <= MAX_BITS; bits++) {
|
||||
code = (code + bl_count[bits - 1]) << 1;
|
||||
next_code[bits] = (ush)code;
|
||||
}
|
||||
/* Check that the bit counts in bl_count are consistent. The last code
|
||||
* must be all ones.
|
||||
*/
|
||||
Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
|
||||
"inconsistent bit counts");
|
||||
Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
||||
|
||||
for (n = 0; n <= max_code; n++) {
|
||||
int len = tree[n].Len;
|
||||
if (len == 0) continue;
|
||||
/* Now reverse the bits */
|
||||
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
||||
|
||||
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
||||
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GEN_TREES_H
|
||||
local void gen_trees_header OF((void));
|
||||
local void gen_trees_header(void);
|
||||
#endif
|
||||
|
||||
#ifndef ZLIB_DEBUG
|
||||
|
@ -167,33 +244,18 @@ local void gen_trees_header OF((void));
|
|||
send_bits(s, tree[c].Code, tree[c].Len); }
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* Output a short LSB first on the stream.
|
||||
* IN assertion: there is enough room in pendingBuf.
|
||||
*/
|
||||
#define put_short(s, w) { \
|
||||
put_byte(s, (uch)((w) & 0xff)); \
|
||||
put_byte(s, (uch)((ush)(w) >> 8)); \
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Send a value on a given number of bits.
|
||||
* IN assertion: length <= 16 and value fits in length bits.
|
||||
*/
|
||||
#ifdef ZLIB_DEBUG
|
||||
local void send_bits OF((deflate_state *s, int value, int length));
|
||||
|
||||
local void send_bits(s, value, length)
|
||||
deflate_state *s;
|
||||
int value; /* value to send */
|
||||
int length; /* number of bits */
|
||||
{
|
||||
local void send_bits(deflate_state *s, int value, int length) {
|
||||
Tracevv((stderr," l %2d v %4x ", length, value));
|
||||
Assert(length > 0 && length <= 15, "invalid length");
|
||||
s->bits_sent += (ulg)length;
|
||||
|
||||
/* If not enough room in bi_buf, use (valid) bits from bi_buf and
|
||||
* (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
|
||||
* (16 - bi_valid) bits from value, leaving (width - (16 - bi_valid))
|
||||
* unused bits in value.
|
||||
*/
|
||||
if (s->bi_valid > (int)Buf_size - length) {
|
||||
|
@ -229,8 +291,7 @@ local void send_bits(s, value, length)
|
|||
/* ===========================================================================
|
||||
* Initialize the various 'constant' tables.
|
||||
*/
|
||||
local void tr_static_init()
|
||||
{
|
||||
local void tr_static_init(void) {
|
||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||
static int static_init_done = 0;
|
||||
int n; /* iterates over tree elements */
|
||||
|
@ -256,7 +317,7 @@ local void tr_static_init()
|
|||
length = 0;
|
||||
for (code = 0; code < LENGTH_CODES-1; code++) {
|
||||
base_length[code] = length;
|
||||
for (n = 0; n < (1<<extra_lbits[code]); n++) {
|
||||
for (n = 0; n < (1 << extra_lbits[code]); n++) {
|
||||
_length_code[length++] = (uch)code;
|
||||
}
|
||||
}
|
||||
|
@ -265,13 +326,13 @@ local void tr_static_init()
|
|||
* in two different ways: code 284 + 5 bits or code 285, so we
|
||||
* overwrite length_code[255] to use the best encoding:
|
||||
*/
|
||||
_length_code[length-1] = (uch)code;
|
||||
_length_code[length - 1] = (uch)code;
|
||||
|
||||
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */
|
||||
dist = 0;
|
||||
for (code = 0 ; code < 16; code++) {
|
||||
base_dist[code] = dist;
|
||||
for (n = 0; n < (1<<extra_dbits[code]); n++) {
|
||||
for (n = 0; n < (1 << extra_dbits[code]); n++) {
|
||||
_dist_code[dist++] = (uch)code;
|
||||
}
|
||||
}
|
||||
|
@ -279,11 +340,11 @@ local void tr_static_init()
|
|||
dist >>= 7; /* from now on, all distances are divided by 128 */
|
||||
for ( ; code < D_CODES; code++) {
|
||||
base_dist[code] = dist << 7;
|
||||
for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
|
||||
for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {
|
||||
_dist_code[256 + dist++] = (uch)code;
|
||||
}
|
||||
}
|
||||
Assert (dist == 256, "tr_static_init: 256+dist != 512");
|
||||
Assert (dist == 256, "tr_static_init: 256 + dist != 512");
|
||||
|
||||
/* Construct the codes of the static literal tree */
|
||||
for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
|
||||
|
@ -312,7 +373,7 @@ local void tr_static_init()
|
|||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Genererate the file trees.h describing the static trees.
|
||||
* Generate the file trees.h describing the static trees.
|
||||
*/
|
||||
#ifdef GEN_TREES_H
|
||||
# ifndef ZLIB_DEBUG
|
||||
|
@ -321,10 +382,9 @@ local void tr_static_init()
|
|||
|
||||
# define SEPARATOR(i, last, width) \
|
||||
((i) == (last)? "\n};\n\n" : \
|
||||
((i) % (width) == (width)-1 ? ",\n" : ", "))
|
||||
((i) % (width) == (width) - 1 ? ",\n" : ", "))
|
||||
|
||||
void gen_trees_header()
|
||||
{
|
||||
void gen_trees_header(void) {
|
||||
FILE *header = fopen("trees.h", "w");
|
||||
int i;
|
||||
|
||||
|
@ -373,12 +433,26 @@ void gen_trees_header()
|
|||
}
|
||||
#endif /* GEN_TREES_H */
|
||||
|
||||
/* ===========================================================================
|
||||
* Initialize a new block.
|
||||
*/
|
||||
local void init_block(deflate_state *s) {
|
||||
int n; /* iterates over tree elements */
|
||||
|
||||
/* Initialize the trees. */
|
||||
for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
|
||||
for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
|
||||
for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
|
||||
|
||||
s->dyn_ltree[END_BLOCK].Freq = 1;
|
||||
s->opt_len = s->static_len = 0L;
|
||||
s->sym_next = s->matches = 0;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Initialize the tree data structures for a new zlib stream.
|
||||
*/
|
||||
void ZLIB_INTERNAL _tr_init(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
void ZLIB_INTERNAL _tr_init(deflate_state *s) {
|
||||
tr_static_init();
|
||||
|
||||
s->l_desc.dyn_tree = s->dyn_ltree;
|
||||
|
@ -401,24 +475,6 @@ void ZLIB_INTERNAL _tr_init(s)
|
|||
init_block(s);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Initialize a new block.
|
||||
*/
|
||||
local void init_block(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
int n; /* iterates over tree elements */
|
||||
|
||||
/* Initialize the trees. */
|
||||
for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
|
||||
for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
|
||||
for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
|
||||
|
||||
s->dyn_ltree[END_BLOCK].Freq = 1;
|
||||
s->opt_len = s->static_len = 0L;
|
||||
s->last_lit = s->matches = 0;
|
||||
}
|
||||
|
||||
#define SMALLEST 1
|
||||
/* Index within the heap array of least frequent node in the Huffman tree */
|
||||
|
||||
|
@ -448,17 +504,13 @@ local void init_block(s)
|
|||
* when the heap property is re-established (each father smaller than its
|
||||
* two sons).
|
||||
*/
|
||||
local void pqdownheap(s, tree, k)
|
||||
deflate_state *s;
|
||||
ct_data *tree; /* the tree to restore */
|
||||
int k; /* node to move down */
|
||||
{
|
||||
local void pqdownheap(deflate_state *s, ct_data *tree, int k) {
|
||||
int v = s->heap[k];
|
||||
int j = k << 1; /* left son of k */
|
||||
while (j <= s->heap_len) {
|
||||
/* Set j to the smallest of the two sons: */
|
||||
if (j < s->heap_len &&
|
||||
smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
|
||||
smaller(tree, s->heap[j + 1], s->heap[j], s->depth)) {
|
||||
j++;
|
||||
}
|
||||
/* Exit if v is smaller than both sons */
|
||||
|
@ -483,10 +535,7 @@ local void pqdownheap(s, tree, k)
|
|||
* The length opt_len is updated; static_len is also updated if stree is
|
||||
* not null.
|
||||
*/
|
||||
local void gen_bitlen(s, desc)
|
||||
deflate_state *s;
|
||||
tree_desc *desc; /* the tree descriptor */
|
||||
{
|
||||
local void gen_bitlen(deflate_state *s, tree_desc *desc) {
|
||||
ct_data *tree = desc->dyn_tree;
|
||||
int max_code = desc->max_code;
|
||||
const ct_data *stree = desc->stat_desc->static_tree;
|
||||
|
@ -507,7 +556,7 @@ local void gen_bitlen(s, desc)
|
|||
*/
|
||||
tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
|
||||
|
||||
for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
|
||||
for (h = s->heap_max + 1; h < HEAP_SIZE; h++) {
|
||||
n = s->heap[h];
|
||||
bits = tree[tree[n].Dad].Len + 1;
|
||||
if (bits > max_length) bits = max_length, overflow++;
|
||||
|
@ -518,7 +567,7 @@ local void gen_bitlen(s, desc)
|
|||
|
||||
s->bl_count[bits]++;
|
||||
xbits = 0;
|
||||
if (n >= base) xbits = extra[n-base];
|
||||
if (n >= base) xbits = extra[n - base];
|
||||
f = tree[n].Freq;
|
||||
s->opt_len += (ulg)f * (unsigned)(bits + xbits);
|
||||
if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);
|
||||
|
@ -530,10 +579,10 @@ local void gen_bitlen(s, desc)
|
|||
|
||||
/* Find the first bit length which could increase: */
|
||||
do {
|
||||
bits = max_length-1;
|
||||
bits = max_length - 1;
|
||||
while (s->bl_count[bits] == 0) bits--;
|
||||
s->bl_count[bits]--; /* move one leaf down the tree */
|
||||
s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
|
||||
s->bl_count[bits]--; /* move one leaf down the tree */
|
||||
s->bl_count[bits + 1] += 2; /* move one overflow item as its brother */
|
||||
s->bl_count[max_length]--;
|
||||
/* The brother of the overflow item also moves one step up,
|
||||
* but this does not affect bl_count[max_length]
|
||||
|
@ -561,48 +610,9 @@ local void gen_bitlen(s, desc)
|
|||
}
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Generate the codes for a given tree and bit counts (which need not be
|
||||
* optimal).
|
||||
* IN assertion: the array bl_count contains the bit length statistics for
|
||||
* the given tree and the field len is set for all tree elements.
|
||||
* OUT assertion: the field code is set for all tree elements of non
|
||||
* zero code length.
|
||||
*/
|
||||
local void gen_codes (tree, max_code, bl_count)
|
||||
ct_data *tree; /* the tree to decorate */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
ushf *bl_count; /* number of codes at each bit length */
|
||||
{
|
||||
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
||||
unsigned code = 0; /* running code value */
|
||||
int bits; /* bit index */
|
||||
int n; /* code index */
|
||||
|
||||
/* The distribution counts are first used to generate the code values
|
||||
* without bit reversal.
|
||||
*/
|
||||
for (bits = 1; bits <= MAX_BITS; bits++) {
|
||||
code = (code + bl_count[bits-1]) << 1;
|
||||
next_code[bits] = (ush)code;
|
||||
}
|
||||
/* Check that the bit counts in bl_count are consistent. The last code
|
||||
* must be all ones.
|
||||
*/
|
||||
Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
|
||||
"inconsistent bit counts");
|
||||
Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
||||
|
||||
for (n = 0; n <= max_code; n++) {
|
||||
int len = tree[n].Len;
|
||||
if (len == 0) continue;
|
||||
/* Now reverse the bits */
|
||||
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
||||
|
||||
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
||||
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
|
||||
}
|
||||
}
|
||||
#ifdef DUMP_BL_TREE
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* Construct one Huffman tree and assigns the code bit strings and lengths.
|
||||
|
@ -612,10 +622,7 @@ local void gen_codes (tree, max_code, bl_count)
|
|||
* and corresponding code. The length opt_len is updated; static_len is
|
||||
* also updated if stree is not null. The field max_code is set.
|
||||
*/
|
||||
local void build_tree(s, desc)
|
||||
deflate_state *s;
|
||||
tree_desc *desc; /* the tree descriptor */
|
||||
{
|
||||
local void build_tree(deflate_state *s, tree_desc *desc) {
|
||||
ct_data *tree = desc->dyn_tree;
|
||||
const ct_data *stree = desc->stat_desc->static_tree;
|
||||
int elems = desc->stat_desc->elems;
|
||||
|
@ -624,7 +631,7 @@ local void build_tree(s, desc)
|
|||
int node; /* new node being created */
|
||||
|
||||
/* Construct the initial heap, with least frequent element in
|
||||
* heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
|
||||
* heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n + 1].
|
||||
* heap[0] is not used.
|
||||
*/
|
||||
s->heap_len = 0, s->heap_max = HEAP_SIZE;
|
||||
|
@ -652,7 +659,7 @@ local void build_tree(s, desc)
|
|||
}
|
||||
desc->max_code = max_code;
|
||||
|
||||
/* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
|
||||
/* The elements heap[heap_len/2 + 1 .. heap_len] are leaves of the tree,
|
||||
* establish sub-heaps of increasing lengths:
|
||||
*/
|
||||
for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
|
||||
|
@ -700,11 +707,7 @@ local void build_tree(s, desc)
|
|||
* Scan a literal or distance tree to determine the frequencies of the codes
|
||||
* in the bit length tree.
|
||||
*/
|
||||
local void scan_tree (s, tree, max_code)
|
||||
deflate_state *s;
|
||||
ct_data *tree; /* the tree to be scanned */
|
||||
int max_code; /* and its largest code of non zero frequency */
|
||||
{
|
||||
local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
|
||||
int n; /* iterates over all tree elements */
|
||||
int prevlen = -1; /* last emitted length */
|
||||
int curlen; /* length of current code */
|
||||
|
@ -714,10 +717,10 @@ local void scan_tree (s, tree, max_code)
|
|||
int min_count = 4; /* min repeat count */
|
||||
|
||||
if (nextlen == 0) max_count = 138, min_count = 3;
|
||||
tree[max_code+1].Len = (ush)0xffff; /* guard */
|
||||
tree[max_code + 1].Len = (ush)0xffff; /* guard */
|
||||
|
||||
for (n = 0; n <= max_code; n++) {
|
||||
curlen = nextlen; nextlen = tree[n+1].Len;
|
||||
curlen = nextlen; nextlen = tree[n + 1].Len;
|
||||
if (++count < max_count && curlen == nextlen) {
|
||||
continue;
|
||||
} else if (count < min_count) {
|
||||
|
@ -745,11 +748,7 @@ local void scan_tree (s, tree, max_code)
|
|||
* Send a literal or distance tree in compressed form, using the codes in
|
||||
* bl_tree.
|
||||
*/
|
||||
local void send_tree (s, tree, max_code)
|
||||
deflate_state *s;
|
||||
ct_data *tree; /* the tree to be scanned */
|
||||
int max_code; /* and its largest code of non zero frequency */
|
||||
{
|
||||
local void send_tree(deflate_state *s, ct_data *tree, int max_code) {
|
||||
int n; /* iterates over all tree elements */
|
||||
int prevlen = -1; /* last emitted length */
|
||||
int curlen; /* length of current code */
|
||||
|
@ -758,11 +757,11 @@ local void send_tree (s, tree, max_code)
|
|||
int max_count = 7; /* max repeat count */
|
||||
int min_count = 4; /* min repeat count */
|
||||
|
||||
/* tree[max_code+1].Len = -1; */ /* guard already set */
|
||||
/* tree[max_code + 1].Len = -1; */ /* guard already set */
|
||||
if (nextlen == 0) max_count = 138, min_count = 3;
|
||||
|
||||
for (n = 0; n <= max_code; n++) {
|
||||
curlen = nextlen; nextlen = tree[n+1].Len;
|
||||
curlen = nextlen; nextlen = tree[n + 1].Len;
|
||||
if (++count < max_count && curlen == nextlen) {
|
||||
continue;
|
||||
} else if (count < min_count) {
|
||||
|
@ -773,13 +772,13 @@ local void send_tree (s, tree, max_code)
|
|||
send_code(s, curlen, s->bl_tree); count--;
|
||||
}
|
||||
Assert(count >= 3 && count <= 6, " 3_6?");
|
||||
send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
|
||||
send_code(s, REP_3_6, s->bl_tree); send_bits(s, count - 3, 2);
|
||||
|
||||
} else if (count <= 10) {
|
||||
send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
|
||||
send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count - 3, 3);
|
||||
|
||||
} else {
|
||||
send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
|
||||
send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count - 11, 7);
|
||||
}
|
||||
count = 0; prevlen = curlen;
|
||||
if (nextlen == 0) {
|
||||
|
@ -796,9 +795,7 @@ local void send_tree (s, tree, max_code)
|
|||
* Construct the Huffman tree for the bit lengths and return the index in
|
||||
* bl_order of the last bit length code to send.
|
||||
*/
|
||||
local int build_bl_tree(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
local int build_bl_tree(deflate_state *s) {
|
||||
int max_blindex; /* index of last bit length code of non zero freq */
|
||||
|
||||
/* Determine the bit length frequencies for literal and distance trees */
|
||||
|
@ -807,8 +804,8 @@ local int build_bl_tree(s)
|
|||
|
||||
/* Build the bit length tree: */
|
||||
build_tree(s, (tree_desc *)(&(s->bl_desc)));
|
||||
/* opt_len now includes the length of the tree representations, except
|
||||
* the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
|
||||
/* opt_len now includes the length of the tree representations, except the
|
||||
* lengths of the bit lengths codes and the 5 + 5 + 4 bits for the counts.
|
||||
*/
|
||||
|
||||
/* Determine the number of bit length codes to send. The pkzip format
|
||||
|
@ -819,7 +816,7 @@ local int build_bl_tree(s)
|
|||
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
|
||||
}
|
||||
/* Update opt_len to include the bit length tree and counts */
|
||||
s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4;
|
||||
s->opt_len += 3*((ulg)max_blindex + 1) + 5 + 5 + 4;
|
||||
Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
|
||||
s->opt_len, s->static_len));
|
||||
|
||||
|
@ -831,61 +828,54 @@ local int build_bl_tree(s)
|
|||
* lengths of the bit length codes, the literal tree and the distance tree.
|
||||
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
|
||||
*/
|
||||
local void send_all_trees(s, lcodes, dcodes, blcodes)
|
||||
deflate_state *s;
|
||||
int lcodes, dcodes, blcodes; /* number of codes for each tree */
|
||||
{
|
||||
local void send_all_trees(deflate_state *s, int lcodes, int dcodes,
|
||||
int blcodes) {
|
||||
int rank; /* index in bl_order */
|
||||
|
||||
Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
|
||||
Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
|
||||
"too many codes");
|
||||
Tracev((stderr, "\nbl counts: "));
|
||||
send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
|
||||
send_bits(s, dcodes-1, 5);
|
||||
send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
|
||||
send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */
|
||||
send_bits(s, dcodes - 1, 5);
|
||||
send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */
|
||||
for (rank = 0; rank < blcodes; rank++) {
|
||||
Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
|
||||
send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
|
||||
}
|
||||
Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
|
||||
|
||||
send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
|
||||
send_tree(s, (ct_data *)s->dyn_ltree, lcodes - 1); /* literal tree */
|
||||
Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
|
||||
|
||||
send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
|
||||
send_tree(s, (ct_data *)s->dyn_dtree, dcodes - 1); /* distance tree */
|
||||
Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Send a stored block
|
||||
*/
|
||||
void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
|
||||
deflate_state *s;
|
||||
charf *buf; /* input block */
|
||||
ulg stored_len; /* length of input block */
|
||||
int last; /* one if this is the last block for a file */
|
||||
{
|
||||
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
|
||||
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last) {
|
||||
send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */
|
||||
bi_windup(s); /* align on byte boundary */
|
||||
put_short(s, (ush)stored_len);
|
||||
put_short(s, (ush)~stored_len);
|
||||
zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
|
||||
if (stored_len)
|
||||
zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
|
||||
s->pending += stored_len;
|
||||
#ifdef ZLIB_DEBUG
|
||||
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
|
||||
s->compressed_len += (stored_len + 4) << 3;
|
||||
s->bits_sent += 2*16;
|
||||
s->bits_sent += stored_len<<3;
|
||||
s->bits_sent += stored_len << 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
|
||||
*/
|
||||
void ZLIB_INTERNAL _tr_flush_bits(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) {
|
||||
bi_flush(s);
|
||||
}
|
||||
|
||||
|
@ -893,9 +883,7 @@ void ZLIB_INTERNAL _tr_flush_bits(s)
|
|||
* Send one empty static block to give enough lookahead for inflate.
|
||||
* This takes 10 bits, of which 7 may remain in the bit buffer.
|
||||
*/
|
||||
void ZLIB_INTERNAL _tr_align(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
void ZLIB_INTERNAL _tr_align(deflate_state *s) {
|
||||
send_bits(s, STATIC_TREES<<1, 3);
|
||||
send_code(s, END_BLOCK, static_ltree);
|
||||
#ifdef ZLIB_DEBUG
|
||||
|
@ -904,16 +892,108 @@ void ZLIB_INTERNAL _tr_align(s)
|
|||
bi_flush(s);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Send the block data compressed using the given Huffman trees
|
||||
*/
|
||||
local void compress_block(deflate_state *s, const ct_data *ltree,
|
||||
const ct_data *dtree) {
|
||||
unsigned dist; /* distance of matched string */
|
||||
int lc; /* match length or unmatched char (if dist == 0) */
|
||||
unsigned sx = 0; /* running index in symbol buffers */
|
||||
unsigned code; /* the code to send */
|
||||
int extra; /* number of extra bits to send */
|
||||
|
||||
if (s->sym_next != 0) do {
|
||||
#ifdef LIT_MEM
|
||||
dist = s->d_buf[sx];
|
||||
lc = s->l_buf[sx++];
|
||||
#else
|
||||
dist = s->sym_buf[sx++] & 0xff;
|
||||
dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
|
||||
lc = s->sym_buf[sx++];
|
||||
#endif
|
||||
if (dist == 0) {
|
||||
send_code(s, lc, ltree); /* send a literal byte */
|
||||
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
||||
} else {
|
||||
/* Here, lc is the match length - MIN_MATCH */
|
||||
code = _length_code[lc];
|
||||
send_code(s, code + LITERALS + 1, ltree); /* send length code */
|
||||
extra = extra_lbits[code];
|
||||
if (extra != 0) {
|
||||
lc -= base_length[code];
|
||||
send_bits(s, lc, extra); /* send the extra length bits */
|
||||
}
|
||||
dist--; /* dist is now the match distance - 1 */
|
||||
code = d_code(dist);
|
||||
Assert (code < D_CODES, "bad d_code");
|
||||
|
||||
send_code(s, code, dtree); /* send the distance code */
|
||||
extra = extra_dbits[code];
|
||||
if (extra != 0) {
|
||||
dist -= (unsigned)base_dist[code];
|
||||
send_bits(s, dist, extra); /* send the extra distance bits */
|
||||
}
|
||||
} /* literal or match pair ? */
|
||||
|
||||
/* Check for no overlay of pending_buf on needed symbols */
|
||||
#ifdef LIT_MEM
|
||||
Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow");
|
||||
#else
|
||||
Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
|
||||
#endif
|
||||
|
||||
} while (sx < s->sym_next);
|
||||
|
||||
send_code(s, END_BLOCK, ltree);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
||||
* - TEXT if the two conditions below are satisfied:
|
||||
* a) There are no non-portable control characters belonging to the
|
||||
* "block list" (0..6, 14..25, 28..31).
|
||||
* b) There is at least one printable character belonging to the
|
||||
* "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
||||
* - BINARY otherwise.
|
||||
* - The following partially-portable control characters form a
|
||||
* "gray list" that is ignored in this detection algorithm:
|
||||
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
|
||||
* IN assertion: the fields Freq of dyn_ltree are set.
|
||||
*/
|
||||
local int detect_data_type(deflate_state *s) {
|
||||
/* block_mask is the bit mask of block-listed bytes
|
||||
* set bits 0..6, 14..25, and 28..31
|
||||
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
||||
*/
|
||||
unsigned long block_mask = 0xf3ffc07fUL;
|
||||
int n;
|
||||
|
||||
/* Check for non-textual ("block-listed") bytes. */
|
||||
for (n = 0; n <= 31; n++, block_mask >>= 1)
|
||||
if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
|
||||
return Z_BINARY;
|
||||
|
||||
/* Check for textual ("allow-listed") bytes. */
|
||||
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|
||||
|| s->dyn_ltree[13].Freq != 0)
|
||||
return Z_TEXT;
|
||||
for (n = 32; n < LITERALS; n++)
|
||||
if (s->dyn_ltree[n].Freq != 0)
|
||||
return Z_TEXT;
|
||||
|
||||
/* There are no "block-listed" or "allow-listed" bytes:
|
||||
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
||||
*/
|
||||
return Z_BINARY;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Determine the best encoding for the current block: dynamic trees, static
|
||||
* trees or store, and write out the encoded block.
|
||||
*/
|
||||
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||
deflate_state *s;
|
||||
charf *buf; /* input block, or NULL if too old */
|
||||
ulg stored_len; /* length of input block */
|
||||
int last; /* one if this is the last block for a file */
|
||||
{
|
||||
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last) {
|
||||
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
||||
int max_blindex = 0; /* index of last bit length code of non zero freq */
|
||||
|
||||
|
@ -942,14 +1022,17 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|||
max_blindex = build_bl_tree(s);
|
||||
|
||||
/* Determine the best encoding. Compute the block lengths in bytes. */
|
||||
opt_lenb = (s->opt_len+3+7)>>3;
|
||||
static_lenb = (s->static_len+3+7)>>3;
|
||||
opt_lenb = (s->opt_len + 3 + 7) >> 3;
|
||||
static_lenb = (s->static_len + 3 + 7) >> 3;
|
||||
|
||||
Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
|
||||
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
||||
s->last_lit));
|
||||
s->sym_next / 3));
|
||||
|
||||
if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
|
||||
#ifndef FORCE_STATIC
|
||||
if (static_lenb <= opt_lenb || s->strategy == Z_FIXED)
|
||||
#endif
|
||||
opt_lenb = static_lenb;
|
||||
|
||||
} else {
|
||||
Assert(buf != (char*)0, "lost buf");
|
||||
|
@ -959,7 +1042,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|||
#ifdef FORCE_STORED
|
||||
if (buf != (char*)0) { /* force stored block */
|
||||
#else
|
||||
if (stored_len+4 <= opt_lenb && buf != (char*)0) {
|
||||
if (stored_len + 4 <= opt_lenb && buf != (char*)0) {
|
||||
/* 4: two words for the lengths */
|
||||
#endif
|
||||
/* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
|
||||
|
@ -970,21 +1053,17 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|||
*/
|
||||
_tr_stored_block(s, buf, stored_len, last);
|
||||
|
||||
#ifdef FORCE_STATIC
|
||||
} else if (static_lenb >= 0) { /* force static trees */
|
||||
#else
|
||||
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
||||
#endif
|
||||
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
||||
} else if (static_lenb == opt_lenb) {
|
||||
send_bits(s, (STATIC_TREES<<1) + last, 3);
|
||||
compress_block(s, (const ct_data *)static_ltree,
|
||||
(const ct_data *)static_dtree);
|
||||
#ifdef ZLIB_DEBUG
|
||||
s->compressed_len += 3 + s->static_len;
|
||||
#endif
|
||||
} else {
|
||||
send_bits(s, (DYN_TREES<<1)+last, 3);
|
||||
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
|
||||
max_blindex+1);
|
||||
send_bits(s, (DYN_TREES<<1) + last, 3);
|
||||
send_all_trees(s, s->l_desc.max_code + 1, s->d_desc.max_code + 1,
|
||||
max_blindex + 1);
|
||||
compress_block(s, (const ct_data *)s->dyn_ltree,
|
||||
(const ct_data *)s->dyn_dtree);
|
||||
#ifdef ZLIB_DEBUG
|
||||
|
@ -1003,21 +1082,23 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|||
s->compressed_len += 7; /* align on byte boundary */
|
||||
#endif
|
||||
}
|
||||
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
|
||||
s->compressed_len-7*last));
|
||||
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len >> 3,
|
||||
s->compressed_len - 7*last));
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Save the match info and tally the frequency counts. Return true if
|
||||
* the current block must be flushed.
|
||||
*/
|
||||
int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
||||
deflate_state *s;
|
||||
unsigned dist; /* distance of matched string */
|
||||
unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
||||
{
|
||||
s->d_buf[s->last_lit] = (ush)dist;
|
||||
s->l_buf[s->last_lit++] = (uch)lc;
|
||||
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
|
||||
#ifdef LIT_MEM
|
||||
s->d_buf[s->sym_next] = (ush)dist;
|
||||
s->l_buf[s->sym_next++] = (uch)lc;
|
||||
#else
|
||||
s->sym_buf[s->sym_next++] = (uch)dist;
|
||||
s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
|
||||
s->sym_buf[s->sym_next++] = (uch)lc;
|
||||
#endif
|
||||
if (dist == 0) {
|
||||
/* lc is the unmatched char */
|
||||
s->dyn_ltree[lc].Freq++;
|
||||
|
@ -1029,175 +1110,8 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
|||
(ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
|
||||
(ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
|
||||
|
||||
s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
|
||||
s->dyn_ltree[_length_code[lc] + LITERALS + 1].Freq++;
|
||||
s->dyn_dtree[d_code(dist)].Freq++;
|
||||
}
|
||||
|
||||
#ifdef TRUNCATE_BLOCK
|
||||
/* Try to guess if it is profitable to stop the current block here */
|
||||
if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
|
||||
/* Compute an upper bound for the compressed length */
|
||||
ulg out_length = (ulg)s->last_lit*8L;
|
||||
ulg in_length = (ulg)((long)s->strstart - s->block_start);
|
||||
int dcode;
|
||||
for (dcode = 0; dcode < D_CODES; dcode++) {
|
||||
out_length += (ulg)s->dyn_dtree[dcode].Freq *
|
||||
(5L+extra_dbits[dcode]);
|
||||
}
|
||||
out_length >>= 3;
|
||||
Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
|
||||
s->last_lit, in_length, out_length,
|
||||
100L - out_length*100L/in_length));
|
||||
if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
|
||||
}
|
||||
#endif
|
||||
return (s->last_lit == s->lit_bufsize-1);
|
||||
/* We avoid equality with lit_bufsize because of wraparound at 64K
|
||||
* on 16 bit machines and because stored blocks are restricted to
|
||||
* 64K-1 bytes.
|
||||
*/
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Send the block data compressed using the given Huffman trees
|
||||
*/
|
||||
local void compress_block(s, ltree, dtree)
|
||||
deflate_state *s;
|
||||
const ct_data *ltree; /* literal tree */
|
||||
const ct_data *dtree; /* distance tree */
|
||||
{
|
||||
unsigned dist; /* distance of matched string */
|
||||
int lc; /* match length or unmatched char (if dist == 0) */
|
||||
unsigned lx = 0; /* running index in l_buf */
|
||||
unsigned code; /* the code to send */
|
||||
int extra; /* number of extra bits to send */
|
||||
|
||||
if (s->last_lit != 0) do {
|
||||
dist = s->d_buf[lx];
|
||||
lc = s->l_buf[lx++];
|
||||
if (dist == 0) {
|
||||
send_code(s, lc, ltree); /* send a literal byte */
|
||||
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
||||
} else {
|
||||
/* Here, lc is the match length - MIN_MATCH */
|
||||
code = _length_code[lc];
|
||||
send_code(s, code+LITERALS+1, ltree); /* send the length code */
|
||||
extra = extra_lbits[code];
|
||||
if (extra != 0) {
|
||||
lc -= base_length[code];
|
||||
send_bits(s, lc, extra); /* send the extra length bits */
|
||||
}
|
||||
dist--; /* dist is now the match distance - 1 */
|
||||
code = d_code(dist);
|
||||
Assert (code < D_CODES, "bad d_code");
|
||||
|
||||
send_code(s, code, dtree); /* send the distance code */
|
||||
extra = extra_dbits[code];
|
||||
if (extra != 0) {
|
||||
dist -= (unsigned)base_dist[code];
|
||||
send_bits(s, dist, extra); /* send the extra distance bits */
|
||||
}
|
||||
} /* literal or match pair ? */
|
||||
|
||||
/* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
|
||||
Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
|
||||
"pendingBuf overflow");
|
||||
|
||||
} while (lx < s->last_lit);
|
||||
|
||||
send_code(s, END_BLOCK, ltree);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
||||
* - TEXT if the two conditions below are satisfied:
|
||||
* a) There are no non-portable control characters belonging to the
|
||||
* "black list" (0..6, 14..25, 28..31).
|
||||
* b) There is at least one printable character belonging to the
|
||||
* "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
||||
* - BINARY otherwise.
|
||||
* - The following partially-portable control characters form a
|
||||
* "gray list" that is ignored in this detection algorithm:
|
||||
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
|
||||
* IN assertion: the fields Freq of dyn_ltree are set.
|
||||
*/
|
||||
local int detect_data_type(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
/* black_mask is the bit mask of black-listed bytes
|
||||
* set bits 0..6, 14..25, and 28..31
|
||||
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
||||
*/
|
||||
unsigned long black_mask = 0xf3ffc07fUL;
|
||||
int n;
|
||||
|
||||
/* Check for non-textual ("black-listed") bytes. */
|
||||
for (n = 0; n <= 31; n++, black_mask >>= 1)
|
||||
if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
|
||||
return Z_BINARY;
|
||||
|
||||
/* Check for textual ("white-listed") bytes. */
|
||||
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|
||||
|| s->dyn_ltree[13].Freq != 0)
|
||||
return Z_TEXT;
|
||||
for (n = 32; n < LITERALS; n++)
|
||||
if (s->dyn_ltree[n].Freq != 0)
|
||||
return Z_TEXT;
|
||||
|
||||
/* There are no "black-listed" or "white-listed" bytes:
|
||||
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
||||
*/
|
||||
return Z_BINARY;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Reverse the first len bits of a code, using straightforward code (a faster
|
||||
* method would use a table)
|
||||
* IN assertion: 1 <= len <= 15
|
||||
*/
|
||||
local unsigned bi_reverse(code, len)
|
||||
unsigned code; /* the value to invert */
|
||||
int len; /* its bit length */
|
||||
{
|
||||
register unsigned res = 0;
|
||||
do {
|
||||
res |= code & 1;
|
||||
code >>= 1, res <<= 1;
|
||||
} while (--len > 0);
|
||||
return res >> 1;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Flush the bit buffer, keeping at most 7 bits in it.
|
||||
*/
|
||||
local void bi_flush(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
if (s->bi_valid == 16) {
|
||||
put_short(s, s->bi_buf);
|
||||
s->bi_buf = 0;
|
||||
s->bi_valid = 0;
|
||||
} else if (s->bi_valid >= 8) {
|
||||
put_byte(s, (Byte)s->bi_buf);
|
||||
s->bi_buf >>= 8;
|
||||
s->bi_valid -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Flush the bit buffer and align the output on a byte boundary
|
||||
*/
|
||||
local void bi_windup(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
if (s->bi_valid > 8) {
|
||||
put_short(s, s->bi_buf);
|
||||
} else if (s->bi_valid > 0) {
|
||||
put_byte(s, (Byte)s->bi_buf);
|
||||
}
|
||||
s->bi_buf = 0;
|
||||
s->bi_valid = 0;
|
||||
#ifdef ZLIB_DEBUG
|
||||
s->bits_sent = (s->bits_sent+7) & ~7;
|
||||
#endif
|
||||
return (s->sym_next == s->sym_end);
|
||||
}
|
||||
|
|
|
@ -24,12 +24,8 @@
|
|||
Z_DATA_ERROR if the input data was corrupted, including if the input data is
|
||||
an incomplete zlib stream.
|
||||
*/
|
||||
int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong *sourceLen;
|
||||
{
|
||||
int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
uLong *sourceLen) {
|
||||
z_stream stream;
|
||||
int err;
|
||||
const uInt max = (uInt)-1;
|
||||
|
@ -83,11 +79,7 @@ int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
|
|||
err;
|
||||
}
|
||||
|
||||
int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
{
|
||||
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
uLong sourceLen) {
|
||||
return uncompress2(dest, destLen, source, &sourceLen);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -38,6 +38,9 @@
|
|||
# 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
|
||||
|
@ -238,7 +241,11 @@
|
|||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
typedef unsigned long z_size_t;
|
||||
# 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)
|
||||
|
@ -293,14 +300,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# define Z_ARG(args) args
|
||||
# else
|
||||
# define Z_ARG(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
|
||||
|
@ -349,6 +348,9 @@
|
|||
# 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. */
|
||||
|
@ -467,11 +469,18 @@ typedef uLong FAR uLongf;
|
|||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#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) || defined(_LARGEFILE64_SOURCE)
|
||||
# if defined(Z_HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
|
@ -507,7 +516,7 @@ typedef uLong FAR uLongf;
|
|||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#else
|
||||
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -38,6 +38,9 @@
|
|||
# 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
|
||||
|
@ -238,7 +241,11 @@
|
|||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
typedef unsigned long z_size_t;
|
||||
# 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)
|
||||
|
@ -293,14 +300,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# define Z_ARG(args) args
|
||||
# else
|
||||
# define Z_ARG(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
|
||||
|
@ -349,6 +348,9 @@
|
|||
# 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. */
|
||||
|
@ -467,11 +469,18 @@ typedef uLong FAR uLongf;
|
|||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#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) || defined(_LARGEFILE64_SOURCE)
|
||||
# if defined(Z_HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
|
@ -507,7 +516,7 @@ typedef uLong FAR uLongf;
|
|||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#else
|
||||
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = {
|
|||
};
|
||||
|
||||
|
||||
const char * ZEXPORT zlibVersion()
|
||||
{
|
||||
const char * ZEXPORT zlibVersion(void) {
|
||||
return ZLIB_VERSION;
|
||||
}
|
||||
|
||||
uLong ZEXPORT zlibCompileFlags()
|
||||
{
|
||||
uLong ZEXPORT zlibCompileFlags(void) {
|
||||
uLong flags;
|
||||
|
||||
flags = 0;
|
||||
|
@ -61,9 +59,11 @@ uLong ZEXPORT zlibCompileFlags()
|
|||
#ifdef ZLIB_DEBUG
|
||||
flags += 1 << 8;
|
||||
#endif
|
||||
/*
|
||||
#if defined(ASMV) || defined(ASMINF)
|
||||
flags += 1 << 9;
|
||||
#endif
|
||||
*/
|
||||
#ifdef ZLIB_WINAPI
|
||||
flags += 1 << 10;
|
||||
#endif
|
||||
|
@ -119,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags()
|
|||
# endif
|
||||
int ZLIB_INTERNAL z_verbose = verbose;
|
||||
|
||||
void ZLIB_INTERNAL z_error (m)
|
||||
char *m;
|
||||
{
|
||||
void ZLIB_INTERNAL z_error(char *m) {
|
||||
fprintf(stderr, "%s\n", m);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -130,14 +128,12 @@ void ZLIB_INTERNAL z_error (m)
|
|||
/* exported to allow conversion of error code to string for compress() and
|
||||
* uncompress()
|
||||
*/
|
||||
const char * ZEXPORT zError(err)
|
||||
int err;
|
||||
{
|
||||
const char * ZEXPORT zError(int err) {
|
||||
return ERR_MSG(err);
|
||||
}
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
||||
#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.
|
||||
*/
|
||||
|
@ -146,22 +142,14 @@ const char * ZEXPORT zError(err)
|
|||
|
||||
#ifndef HAVE_MEMCPY
|
||||
|
||||
void ZLIB_INTERNAL zmemcpy(dest, source, len)
|
||||
Bytef* dest;
|
||||
const Bytef* source;
|
||||
uInt len;
|
||||
{
|
||||
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(s1, s2, len)
|
||||
const Bytef* s1;
|
||||
const Bytef* s2;
|
||||
uInt len;
|
||||
{
|
||||
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) {
|
||||
uInt j;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
|
@ -170,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp(s1, s2, len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void ZLIB_INTERNAL zmemzero(dest, len)
|
||||
Bytef* dest;
|
||||
uInt len;
|
||||
{
|
||||
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
|
||||
if (len == 0) return;
|
||||
do {
|
||||
*dest++ = 0; /* ??? to be unrolled */
|
||||
|
@ -214,8 +199,7 @@ local ptr_table table[MAX_PTR];
|
|||
* a protected system like OS/2. Use Microsoft C instead.
|
||||
*/
|
||||
|
||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||
{
|
||||
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
||||
voidpf buf;
|
||||
ulg bsize = (ulg)items*size;
|
||||
|
||||
|
@ -240,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
|||
return buf;
|
||||
}
|
||||
|
||||
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
||||
{
|
||||
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||
int n;
|
||||
|
||||
(void)opaque;
|
||||
|
@ -277,14 +260,12 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
|||
# define _hfree hfree
|
||||
#endif
|
||||
|
||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
|
||||
{
|
||||
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 ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||
(void)opaque;
|
||||
_hfree(ptr);
|
||||
}
|
||||
|
@ -297,25 +278,18 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
|||
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
||||
|
||||
#ifndef STDC
|
||||
extern voidp malloc OF((uInt size));
|
||||
extern voidp calloc OF((uInt items, uInt size));
|
||||
extern void free OF((voidpf ptr));
|
||||
extern voidp malloc(uInt size);
|
||||
extern voidp calloc(uInt items, uInt size);
|
||||
extern void free(voidpf ptr);
|
||||
#endif
|
||||
|
||||
voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
|
||||
voidpf opaque;
|
||||
unsigned items;
|
||||
unsigned size;
|
||||
{
|
||||
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 (opaque, ptr)
|
||||
voidpf opaque;
|
||||
voidpf ptr;
|
||||
{
|
||||
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||
(void)opaque;
|
||||
free(ptr);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -29,10 +29,6 @@
|
|||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
|
@ -46,10 +42,21 @@ 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[Z_NEED_DICT-(err)]
|
||||
#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))
|
||||
|
@ -130,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
#if defined(MACOS)
|
||||
# define OS_CODE 7
|
||||
# ifndef Z_SOLO
|
||||
# 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
|
||||
#endif
|
||||
|
||||
#ifdef __acorn
|
||||
|
@ -163,22 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
# define OS_CODE 19
|
||||
#endif
|
||||
|
||||
#if defined(_BEOS_) || defined(RISCOS)
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
||||
# if defined(_WIN32_WCE)
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
# ifndef _PTRDIFF_T_DEFINED
|
||||
typedef int ptrdiff_t;
|
||||
# define _PTRDIFF_T_DEFINED
|
||||
# endif
|
||||
# else
|
||||
# define fdopen(fd,type) _fdopen(fd,type)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||
#pragma warn -8004
|
||||
#pragma warn -8008
|
||||
|
@ -188,8 +170,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
/* provide prototypes for these when building zlib without LFS */
|
||||
#if !defined(_WIN32) && \
|
||||
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
||||
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 */
|
||||
|
@ -228,16 +211,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||
# endif
|
||||
#else
|
||||
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
||||
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
||||
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
|
||||
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 OF((char *m));
|
||||
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 ;}
|
||||
|
@ -254,9 +237,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
#endif
|
||||
|
||||
#ifndef Z_SOLO
|
||||
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
|
||||
unsigned size));
|
||||
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
|
||||
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items,
|
||||
unsigned size);
|
||||
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr);
|
||||
#endif
|
||||
|
||||
#define ZALLOC(strm, items, size) \
|
||||
|
|
Loading…
Reference in New Issue