~ubuntu-branches/ubuntu/lucid/fpc/lucid-proposed

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/zlib/zlib.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-10-09 23:29:00 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081009232900-553f61m37jkp6upv
Tags: 2.2.2-4
[ Torsten Werner ]
* Update ABI version in fpc-depends automatically.
* Remove empty directories from binary package fpc-source.

[ Mazen Neifer ]
* Removed leading path when calling update-alternatives to remove a Linitian
  error.
* Fixed clean target.
* Improved description of packages. (Closes: #498882)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{$ifndef NO_SMART_LINK}
2
 
{$smartlink on}
3
 
{$endif}
4
 
unit zlib;
5
 
 
6
 
interface
7
 
 
8
 
{ Needed for array of const }
9
 
{$mode objfpc}
10
 
{ for linux for linking with libc }
11
 
{$ifdef unix}
12
 
  {$linklib c}
13
 
{$endif}
14
 
{$PACKRECORDS 4}
15
 
 
16
 
uses
17
 
  ctypes;
18
 
 
19
 
const
20
 
  ZLIB_VERSION = '1.1.3';
21
 
 
22
 
{$ifdef netware}  {zlib.nlm comes with netware6}
23
 
  libz='zlib';
24
 
{$else}
25
 
  {$ifdef windows}
26
 
    libz='zlib1';
27
 
  {$else windows}
28
 
    libz='z';
29
 
  {$endif windows}
30
 
{$endif}
31
 
 
32
 
type
33
 
  { Compatible with paszlib }
34
 
  Uint    = Longint;
35
 
  Ulong   = Longint;
36
 
  Ulongf  = Longint;
37
 
  Pulongf = ^Ulongf;
38
 
  z_off_t = longint;
39
 
  pbyte   = ^byte;
40
 
  pbytef  = ^byte;
41
 
 
42
 
  TAllocfunc = function (opaque:pointer; items:uInt; size:uInt):pointer;cdecl;
43
 
  TFreeFunc = procedure (opaque:pointer; address:pointer);cdecl;
44
 
 
45
 
  TInternalState = record
46
 
    end;
47
 
  PInternalState = ^TInternalstate;
48
 
 
49
 
  TZStream = record
50
 
    next_in : pbytef;
51
 
    avail_in : uInt;
52
 
    total_in : uLong;
53
 
    next_out : pbytef;
54
 
    avail_out : uInt;
55
 
    total_out : uLong;
56
 
    msg : pbytef;
57
 
    state : PInternalState;
58
 
    zalloc : TAllocFunc;
59
 
    zfree : TFreeFunc;
60
 
    opaque : pointer;
61
 
    data_type : longint;
62
 
    adler : uLong;
63
 
    reserved : uLong;
64
 
  end;
65
 
  TZStreamRec = TZStream;
66
 
  PZstream = ^TZStream;
67
 
  gzFile = pointer;
68
 
 
69
 
 
70
 
const
71
 
  Z_NO_FLUSH = 0;
72
 
 
73
 
  Z_PARTIAL_FLUSH = 1;
74
 
  Z_SYNC_FLUSH = 2;
75
 
  Z_FULL_FLUSH = 3;
76
 
  Z_FINISH = 4;
77
 
 
78
 
  Z_OK = 0;
79
 
  Z_STREAM_END = 1;
80
 
  Z_NEED_DICT = 2;
81
 
  Z_ERRNO = -(1);
82
 
  Z_STREAM_ERROR = -(2);
83
 
  Z_DATA_ERROR = -(3);
84
 
  Z_MEM_ERROR = -(4);
85
 
  Z_BUF_ERROR = -(5);
86
 
  Z_VERSION_ERROR = -(6);
87
 
 
88
 
  Z_NO_COMPRESSION = 0;
89
 
  Z_BEST_SPEED = 1;
90
 
  Z_BEST_COMPRESSION = 9;
91
 
  Z_DEFAULT_COMPRESSION = -(1);
92
 
 
93
 
  Z_FILTERED = 1;
94
 
  Z_HUFFMAN_ONLY = 2;
95
 
  Z_DEFAULT_STRATEGY = 0;
96
 
 
97
 
  Z_BINARY = 0;
98
 
  Z_ASCII = 1;
99
 
  Z_UNKNOWN = 2;
100
 
 
101
 
  Z_DEFLATED = 8;
102
 
 
103
 
  Z_NULL = 0;
104
 
 
105
 
function zlibVersionpchar:pchar;cdecl;external libz name 'zlibVersion';
106
 
function zlibVersion:string;
107
 
function deflate(var strm:TZStream; flush:longint):longint;cdecl;external libz name 'deflate';
108
 
function deflateEnd(var strm:TZStream):longint;cdecl;external libz name 'deflateEnd';
109
 
function inflate(var strm:TZStream; flush:longint):longint;cdecl;external libz name 'inflate';
110
 
function inflateEnd(var strm:TZStream):longint;cdecl;external libz name 'inflateEnd';
111
 
function deflateSetDictionary(var strm:TZStream;dictionary : pbytef; dictLength:uInt):longint;cdecl;external libz name 'deflateSetDictionary';
112
 
function deflateCopy(var dest,source:TZstream):longint;cdecl;external libz name 'deflateCopy';
113
 
function deflateReset(var strm:TZStream):longint;cdecl;external libz name 'deflateReset';
114
 
function deflateParams(var strm:TZStream; level:longint; strategy:longint):longint;cdecl;external libz name 'deflateParams';
115
 
function inflateSetDictionary(var strm:TZStream;dictionary : pbytef; dictLength:uInt):longint;cdecl;external libz name 'inflateSetDictionary';
116
 
function inflateSync(var strm:TZStream):longint;cdecl;external libz name 'inflateSync';
117
 
function inflateReset(var strm:TZStream):longint;cdecl;external libz name 'inflateReset';
118
 
function compress(dest:pbytef;destLen:puLongf; source : pbytef; sourceLen:uLong):cint;cdecl;external libz name 'compress';
119
 
function compress2(dest:pbytef;destLen:puLongf; source : pbytef; sourceLen:uLong; level:cint):cint;cdecl;external libz name 'compress2';
120
 
function uncompress(dest:pbytef;destLen:puLongf; source : pbytef; sourceLen:uLong):cint;cdecl;external libz name 'uncompress';
121
 
function gzopen(path:pchar; mode:pchar):gzFile;cdecl;external libz name 'gzopen';
122
 
function gzdopen(fd:longint; mode:pchar):gzFile;cdecl;external libz name 'gzdopen';
123
 
function gzsetparams(thefile:gzFile; level:longint; strategy:longint):longint;cdecl;external libz name 'gzsetparams';
124
 
function gzread(thefile:gzFile; buf:pointer; len:cardinal):longint;cdecl;external libz name 'gzread';
125
 
function gzwrite(thefile:gzFile; buf:pointer; len:cardinal):longint;cdecl;external libz name 'gzwrite';
126
 
function gzprintf(thefile:gzFile; format:pbytef; args:array of const):longint;cdecl;external libz name 'gzprintf';
127
 
function gzputs(thefile:gzFile; s:pbytef):longint;cdecl;external libz name 'gzputs';
128
 
function gzgets(thefile:gzFile; buf:pbytef; len:longint):pbytef;cdecl;external libz name 'gzgets';
129
 
function gzputc(thefile:gzFile; c:char):char;cdecl;external libz name 'gzputc';
130
 
function gzgetc(thefile:gzFile):char;cdecl;external libz name 'gzgetc';
131
 
function gzflush(thefile:gzFile; flush:longint):longint;cdecl;external libz name 'gzflush';
132
 
function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;cdecl;external libz name 'gzseek';
133
 
function gzrewind(thefile:gzFile):longint;cdecl;external libz name 'gzrewind';
134
 
function gztell(thefile:gzFile):z_off_t;cdecl;external libz name 'gztell';
135
 
function gzeof(thefile:gzFile):longbool;cdecl;external libz name 'gzeof';
136
 
function gzclose(thefile:gzFile):longint;cdecl;external libz name 'gzclose';
137
 
function gzerror(thefile:gzFile; var errnum:longint):pbytef;cdecl;external libz name 'gzerror';
138
 
function adler32(adler:uLong;buf : pbytef; len:uInt):uLong;cdecl;external libz name 'adler32';
139
 
function crc32(crc:uLong;buf : pbytef; len:uInt):uLong;cdecl;external libz name 'crc32';
140
 
function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;cdecl;external libz name 'deflateInit_';
141
 
function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;cdecl;external libz name 'inflateInit_';
142
 
function deflateInit(var strm:TZStream;level : longint) : longint;
143
 
function inflateInit(var strm:TZStream) : longint;
144
 
function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;cdecl;external libz name 'deflateInit2_';
145
 
function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;cdecl;external libz name 'inflateInit2_';
146
 
function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
147
 
function inflateInit2(var strm:TZStream;windowBits : longint) : longint;
148
 
function zErrorpchar(err:longint):pchar;cdecl;external libz name 'zError';
149
 
function zError(err:longint):string;
150
 
function inflateSyncPoint(z:PZstream):longint;cdecl;external libz name 'inflateSyncPoint';
151
 
function get_crc_table:pointer;cdecl;external libz name 'get_crc_table';
152
 
 
153
 
function zlibAllocMem(AppData: Pointer; Items, Size: Integer): Pointer; cdecl;
154
 
procedure zlibFreeMem(AppData, Block: Pointer);  cdecl;
155
 
 
156
 
implementation
157
 
 
158
 
uses
159
 
  strings;
160
 
 
161
 
function zlibversion : string;
162
 
  begin
163
 
     zlibversion:=strpas(zlibversionpchar);
164
 
  end;
165
 
 
166
 
function deflateInit(var strm:TZStream;level : longint) : longint;
167
 
  begin
168
 
     deflateInit:=deflateInit_(strm,level,ZLIB_VERSION,sizeof(TZStream));
169
 
  end;
170
 
 
171
 
function inflateInit(var strm:TZStream) : longint;
172
 
  begin
173
 
     inflateInit:=inflateInit_(strm,ZLIB_VERSION,sizeof(TZStream));
174
 
  end;
175
 
 
176
 
function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
177
 
  begin
178
 
     deflateInit2:=deflateInit2_(strm,level,method,windowBits,memLevel,strategy,ZLIB_VERSION,sizeof(TZStream));
179
 
  end;
180
 
 
181
 
function inflateInit2(var strm:TZStream;windowBits : longint) : longint;
182
 
  begin
183
 
     inflateInit2:=inflateInit2_(strm,windowBits,ZLIB_VERSION,sizeof(TZStream));
184
 
  end;
185
 
 
186
 
function zError(err:longint):string;
187
 
  begin
188
 
     zerror:=Strpas(zErrorpchar(err));
189
 
  end;
190
 
 
191
 
function zlibAllocMem(AppData: Pointer; Items, Size: Integer): Pointer; cdecl;
192
 
 
193
 
  begin
194
 
    Result := AllocMem(Items * Size);
195
 
  end;
196
 
 
197
 
procedure zlibFreeMem(AppData, Block: Pointer);  cdecl;
198
 
 
199
 
  begin
200
 
    FreeMem(Block);
201
 
  end;
202
 
 
203
 
 
204
 
end.