kusano fc6ab3
----------------------------------------------------------------
kusano fc6ab3
--  ZLib for Ada thick binding.                               --
kusano fc6ab3
--                                                            --
kusano fc6ab3
--  Copyright (C) 2002-2003 Dmitriy Anisimkov                 --
kusano fc6ab3
--                                                            --
kusano fc6ab3
--  Open source license information is in the zlib.ads file.  --
kusano fc6ab3
----------------------------------------------------------------
kusano fc6ab3
kusano fc6ab3
--  $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $
kusano fc6ab3
kusano fc6ab3
package body ZLib.Thin is
kusano fc6ab3
kusano fc6ab3
   ZLIB_VERSION  : constant Chars_Ptr := zlibVersion;
kusano fc6ab3
kusano fc6ab3
   Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit;
kusano fc6ab3
kusano fc6ab3
   --------------
kusano fc6ab3
   -- Avail_In --
kusano fc6ab3
   --------------
kusano fc6ab3
kusano fc6ab3
   function Avail_In (Strm : in Z_Stream) return UInt is
kusano fc6ab3
   begin
kusano fc6ab3
      return Strm.Avail_In;
kusano fc6ab3
   end Avail_In;
kusano fc6ab3
kusano fc6ab3
   ---------------
kusano fc6ab3
   -- Avail_Out --
kusano fc6ab3
   ---------------
kusano fc6ab3
kusano fc6ab3
   function Avail_Out (Strm : in Z_Stream) return UInt is
kusano fc6ab3
   begin
kusano fc6ab3
      return Strm.Avail_Out;
kusano fc6ab3
   end Avail_Out;
kusano fc6ab3
kusano fc6ab3
   ------------------
kusano fc6ab3
   -- Deflate_Init --
kusano fc6ab3
   ------------------
kusano fc6ab3
kusano fc6ab3
   function Deflate_Init
kusano fc6ab3
     (strm       : Z_Streamp;
kusano fc6ab3
      level      : Int;
kusano fc6ab3
      method     : Int;
kusano fc6ab3
      windowBits : Int;
kusano fc6ab3
      memLevel   : Int;
kusano fc6ab3
      strategy   : Int)
kusano fc6ab3
      return       Int is
kusano fc6ab3
   begin
kusano fc6ab3
      return deflateInit2
kusano fc6ab3
               (strm,
kusano fc6ab3
                level,
kusano fc6ab3
                method,
kusano fc6ab3
                windowBits,
kusano fc6ab3
                memLevel,
kusano fc6ab3
                strategy,
kusano fc6ab3
                ZLIB_VERSION,
kusano fc6ab3
                Z_Stream_Size);
kusano fc6ab3
   end Deflate_Init;
kusano fc6ab3
kusano fc6ab3
   ------------------
kusano fc6ab3
   -- Inflate_Init --
kusano fc6ab3
   ------------------
kusano fc6ab3
kusano fc6ab3
   function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is
kusano fc6ab3
   begin
kusano fc6ab3
      return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size);
kusano fc6ab3
   end Inflate_Init;
kusano fc6ab3
kusano fc6ab3
   ------------------------
kusano fc6ab3
   -- Last_Error_Message --
kusano fc6ab3
   ------------------------
kusano fc6ab3
kusano fc6ab3
   function Last_Error_Message (Strm : in Z_Stream) return String is
kusano fc6ab3
      use Interfaces.C.Strings;
kusano fc6ab3
   begin
kusano fc6ab3
      if Strm.msg = Null_Ptr then
kusano fc6ab3
         return "";
kusano fc6ab3
      else
kusano fc6ab3
         return Value (Strm.msg);
kusano fc6ab3
      end if;
kusano fc6ab3
   end Last_Error_Message;
kusano fc6ab3
kusano fc6ab3
   ------------
kusano fc6ab3
   -- Set_In --
kusano fc6ab3
   ------------
kusano fc6ab3
kusano fc6ab3
   procedure Set_In
kusano fc6ab3
     (Strm   : in out Z_Stream;
kusano fc6ab3
      Buffer : in     Voidp;
kusano fc6ab3
      Size   : in     UInt) is
kusano fc6ab3
   begin
kusano fc6ab3
      Strm.Next_In  := Buffer;
kusano fc6ab3
      Strm.Avail_In := Size;
kusano fc6ab3
   end Set_In;
kusano fc6ab3
kusano fc6ab3
   ------------------
kusano fc6ab3
   -- Set_Mem_Func --
kusano fc6ab3
   ------------------
kusano fc6ab3
kusano fc6ab3
   procedure Set_Mem_Func
kusano fc6ab3
     (Strm   : in out Z_Stream;
kusano fc6ab3
      Opaque : in     Voidp;
kusano fc6ab3
      Alloc  : in     alloc_func;
kusano fc6ab3
      Free   : in     free_func) is
kusano fc6ab3
   begin
kusano fc6ab3
      Strm.opaque := Opaque;
kusano fc6ab3
      Strm.zalloc := Alloc;
kusano fc6ab3
      Strm.zfree  := Free;
kusano fc6ab3
   end Set_Mem_Func;
kusano fc6ab3
kusano fc6ab3
   -------------
kusano fc6ab3
   -- Set_Out --
kusano fc6ab3
   -------------
kusano fc6ab3
kusano fc6ab3
   procedure Set_Out
kusano fc6ab3
     (Strm   : in out Z_Stream;
kusano fc6ab3
      Buffer : in     Voidp;
kusano fc6ab3
      Size   : in     UInt) is
kusano fc6ab3
   begin
kusano fc6ab3
      Strm.Next_Out  := Buffer;
kusano fc6ab3
      Strm.Avail_Out := Size;
kusano fc6ab3
   end Set_Out;
kusano fc6ab3
kusano fc6ab3
   --------------
kusano fc6ab3
   -- Total_In --
kusano fc6ab3
   --------------
kusano fc6ab3
kusano fc6ab3
   function Total_In (Strm : in Z_Stream) return ULong is
kusano fc6ab3
   begin
kusano fc6ab3
      return Strm.Total_In;
kusano fc6ab3
   end Total_In;
kusano fc6ab3
kusano fc6ab3
   ---------------
kusano fc6ab3
   -- Total_Out --
kusano fc6ab3
   ---------------
kusano fc6ab3
kusano fc6ab3
   function Total_Out (Strm : in Z_Stream) return ULong is
kusano fc6ab3
   begin
kusano fc6ab3
      return Strm.Total_Out;
kusano fc6ab3
   end Total_Out;
kusano fc6ab3
kusano fc6ab3
end ZLib.Thin;