-
Notifications
You must be signed in to change notification settings - Fork 3
/
dpkgdb.pas
427 lines (388 loc) · 13.3 KB
/
dpkgdb.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
{
Automatically converted by H2Pas 1.0.0 from dpkg-db.h
manually fixed by Peter Michael green to make it
build successfully;
The following command line parameters were used:
-d
-C
-c
-e
dpkg-db.h
}
{
* libdpkg - Debian packaging suite library routines
* dpkg-db.h - declarations for in-core package database management
*
* Copyright © 1994,1995 Ian Jackson <[email protected]>
* Copyright © 2000,2001 Wichert Akkerman
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
}
unit dpkgdb;
interface
uses
ctypes;
{$linklib dpkg}
{$linklib c}
{$linklib gcc}
{$PACKRECORDS C}
{$mode objfpc}
{$calling cdecl}
type
dpkg_error = record
errortype: cint;
str: pchar;
end;
pdpkg_error = ^dpkg_error;
type
deptype = Longint;
Const
dep_suggests = 0;
dep_recommends = 1;
dep_depends = 2;
dep_predepends = 3;
dep_breaks = 4;
dep_conflicts = 5;
dep_provides = 6;
dep_replaces = 7;
dep_enhances = 8;
type
depverrel = Longint;
Const
dvrf_earlier = 0001;
dvrf_later = 0002;
dvrf_strict = 0010;
dvrf_orequal = 0020;
dvrf_builtup = 0100;
dvr_none = 0200;
dvr_earlierequal = (dvrf_builtup or dvrf_earlier) or dvrf_orequal;
dvr_earlierstrict = (dvrf_builtup or dvrf_earlier) or dvrf_strict;
dvr_laterequal = (dvrf_builtup or dvrf_later) or dvrf_orequal;
dvr_laterstrict = (dvrf_builtup or dvrf_later) or dvrf_strict;
dvr_exact = 0400;
Const
want_unknown = 0;
want_install = 1;
want_hold = 2;
want_deinstall = 3;
want_purge = 4;
want_sentinel = 5;
Const
eflag_ok = 0;
eflag_reinstreq = 1;
Const
stat_notinstalled = 0;
stat_configfiles = 1;
stat_halfinstalled = 2;
stat_unpacked = 3;
stat_halfconfigured = 4;
stat_triggersawaited = 5;
stat_triggerspending = 6;
stat_installed = 7;
Const
pri_required = 0;
pri_important = 1;
pri_standard = 2;
pri_optional = 3;
pri_extra = 4;
pri_other = 5;
pri_unknown = 6;
pri_unset = -(1);
Type
Pdependency = ^dependency;
Pdeppossi = ^deppossi;
PFILE = ^FILE;
Ppkginfo = ^pkginfo;
Ppkginfoperfile = ^pkginfoperfile;
//Ppkgiterator = ^pkgiterator;
//Pvarbuf = ^varbuf;
Pversionrevision = ^versionrevision;
{$ifndef LIBDPKG_DPKG_DB_H}
{$define LIBDPKG_DPKG_DB_H}
{ $include <sys/types.h>}
{ $include <stdbool.h>}
{ $include <stdio.h>}
{ $include <dpkg/macros.h>}
{ $include <dpkg/varbuf.h>}
versionrevision = record
epoch : culong;
version : pchar;
revision : pchar;
end;
dependency = record
up : ppkginfo;
next : pdependency;
list : pdeppossi;
_type : deptype;
end;
bool=cbool;
deppossi = record
up : ^dependency;
ed : ppkginfo;
next : pdeppossi;
rev_next : pdeppossi;
rev_prev : pdeppossi;
version : versionrevision;
verrel : depverrel;
cyclebreak : bool;
end;
(* Const before type ignored *)
(* Const before type ignored *)
parbitraryfield = ^arbitraryfield;
arbitraryfield = record
next : parbitraryfield;
name : ^cchar;
value : ^cchar;
end;
(* Const before type ignored *)
(* Const before type ignored *)
pconffile = ^conffile;
conffile = record
next : pconffile;
name : ^cchar;
hash : ^cchar;
obsolete : bool;
end;
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
pfiledetails = ^filedetails;
filedetails = record
next : pfiledetails;
name : ^cchar;
msdosname : ^cchar;
size : ^cchar;
md5sum : ^cchar;
end;
{ pif }
{ The ‘essential’ flag, true = yes, false = no (absent). }
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
pkginfoperfile = record
depends : ^dependency;
depended : ^deppossi;
essential : bool;
description : ^cchar;
maintainer : ^cchar;
source : ^cchar;
architecture : ^cchar;
installedsize : ^cchar;
origin : ^cchar;
bugs : ^cchar;
version : versionrevision;
conffiles : ^conffile;
arbs : ^arbitraryfield;
end;
{ Node indicates that parent's Triggers-Pending mentions name. }
{ NB that these nodes do double duty: after they're removed from
* a package's trigpend list, references may be preserved by the
* trigger cycle checker (see trigproc.c).
}
(* Const before type ignored *)
ptrigpend = ^trigpend;
trigpend = record
next : ptrigpend;
name : ^cchar;
end;
{ Node indicates that aw's Triggers-Awaited mentions pend. }
ptrigaw = ^trigaw;
trigaw = record
aw : ppkginfo;
pend : ppkginfo;
samepend_next : ptrigaw;
sameaw : record
next : ptrigaw;
prev : ptrigaw;
end;
end;
perpackagestate = record
{undefined structure}
end;
{ dselect and dpkg have different versions of this }
{ pig }
(* Const before type ignored *)
{ Not allowed except as special sentinel value
in some places }
{ Bitmask. }
(* Const before type ignored *)
(* Const before type ignored *)
{ ->aw == this }
{ ->pend == this, non-NULL for us when Triggers-Pending. }
pkginfo = record
next : ppkginfo;
name : ^cchar;
want : Longint;
eflag : Longint;
status : Longint;
priority : Longint;
otherpriority : ^cchar;
section : ^cchar;
configversion : versionrevision;
files : ^filedetails;
installed : pkginfoperfile;
available : pkginfoperfile;
clientdata : ^perpackagestate;
trigaw : record
head : ^trigaw;
tail : ^trigaw;
end;
othertrigaw_head : ^trigaw;
trigpend_head : ^trigpend;
end;
{** from dbmodify.c ** }
{ Those marked with \*s*\ are possible returns from modstatdb_init. }
{s }(* error
msdbrw_readonly/*s*/, msdbrw_needsuperuserlockonly/*s*/,
{s } {s } { Now some optional flags: }
{ flags start at 0100 }
in enum_list *)
modstatdb_rw = Longint;
function modstatdb_is_locked(admindir:pchar):bool;cdecl;external;
(* Const before type ignored *)
procedure modstatdb_lock(admindir:pchar);cdecl;external;
procedure modstatdb_unlock;cdecl;external;
(* error
enum modstatdb_rw modstatdb_init(const char *admindir, enum modstatdb_rw reqrwflags);
in declaration at line 205 *)
procedure modstatdb_note(pkg:Ppkginfo);cdecl;external;
procedure modstatdb_note_ifwrite(pkg:Ppkginfo);cdecl;external;
procedure modstatdb_checkpoint;cdecl;external;
procedure modstatdb_shutdown;cdecl;external;
(* Const before type ignored *)
function pkgadmindir:pchar;cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
function pkgadminfile(pkg:Ppkginfo; whichfile:pchar):pchar;cdecl;external;
{** from database.c ** }
(* error
struct pkginfo *findpackage(const char *name);
in declaration at line 216 *)
procedure blankpackage(pp:Ppkginfo);cdecl;external;
procedure blankpackageperfile(pifp:Ppkginfoperfile);cdecl;external;
procedure blankversion(_para1:Pversionrevision);cdecl;external;
function informative(pkg:Ppkginfo; info:Ppkginfoperfile):bool;cdecl;external;
function countpackages:cint;cdecl;external;
procedure resetpackages;cdecl;external;
(* error
struct pkgiterator *iterpkgstart(void);
in declaration at line 224 *)
(* error
struct pkginfo *iterpkgnext(struct pkgiterator
in declaration at line 225 *)
//procedure iterpkgend(_para1:Ppkgiterator);cdecl;external;
procedure hashreport(_para1:PFILE);cdecl;external;
{** from parse.c ** }
{ Store in `available' in-core structures, not `status' }
{ Throw up an error if `Status' encountered }
{ Ignore priority/section info if we already have any }
{ Ignore files info if we already have them }
{ Ignore packages with older versions already read. }
{ Perform laxer parsing, used to transition to stricter parsing. }
type
parsedbflags = Longint;
Const
pdb_recordavailable = 001;
pdb_rejectstatus = 002;
pdb_weakclassification = 004;
pdb_ignorefiles = 010;
pdb_ignoreolder = 020;
pdb_lax_parser = 040;
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
type
ppchar = ^pchar;
function illegal_packagename(p:pchar; ep:Ppchar):pchar;cdecl;external;
(* Const before type ignored *)
//function parsedb(filename:pchar; _para2:parsedbflags; donep:PPpkginfo; warnto:PFILE; warncount:pcint):cint;cdecl;external;
//procedure copy_dependency_links(pkg:Ppkginfo; updateme:PPdependency; newdepends:Pdependency; available:bool);cdecl;external;
{** from parsehelp.c ** }
(* Const before type ignored *)
type
namevalue = record
name : pchar;
value : cint;
length : cint;
end;
(* Const before type ignored *)
// var
// booleaninfos : array of namevalue;cvar;external;
(* Const before type ignored *)
// priorityinfos : array of namevalue;cvar;external;
(* Const before type ignored *)
// statusinfos : array of namevalue;cvar;external;
(* Const before type ignored *)
// eflaginfos : array of namevalue;cvar;external;
(* Const before type ignored *)
// wantinfos : array of namevalue;cvar;external;
(* Const before type ignored *)
function informativeversion(version:Pversionrevision):bool;cdecl;external;
type
versiondisplayepochwhen = Longint;
Const
vdew_never = 0;
vdew_nonambig = 1;
vdew_always = 2;
(* Const before type ignored *)
//procedure varbufversion(_para1:Pvarbuf; _para2:Pversionrevision; _para3:versiondisplayepochwhen);cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
function parseversion(rversion:Pversionrevision; _para2:pchar;err:pdpkg_error):cint;cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
function versiondescribe(_para1:Pversionrevision; _para2:versiondisplayepochwhen):pchar;cdecl;external;
{** from dump.c ** }
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
procedure writerecord(_para1:PFILE; _para2:pchar; _para3:Ppkginfo; _para4:Ppkginfoperfile);cdecl;external;
(* Const before type ignored *)
procedure writedb(filename:pchar; available:bool; mustsync:bool);cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
//procedure varbufrecord(_para1:Pvarbuf; _para2:Ppkginfo; _para3:Ppkginfoperfile);cdecl;external;
//procedure varbufdependency(vb:Pvarbuf; dep:Pdependency);cdecl;external;
{ NB THE VARBUF MUST HAVE BEEN INITIALISED AND WILL NOT BE NULL-TERMINATED }
{** from vercmp.c ** }
function versionsatisfied(it:Ppkginfoperfile; against:Pdeppossi):bool;cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
function versionsatisfied3(it:Pversionrevision; ref:Pversionrevision; verrel:depverrel):bool;cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
function versioncompare(version:Pversionrevision; refversion:Pversionrevision):cint;cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
function epochsdiffer(a:Pversionrevision; b:Pversionrevision):bool;cdecl;external;
{** from nfmalloc.c ** }
type
size_t = csize_t;
function nfmalloc(_para1:size_t):pointer;cdecl;external;
(* Const before type ignored *)
function nfstrsave(_para1:pchar):pchar;cdecl;external;
(* Const before type ignored *)
function nfstrnsave(_para1:pchar; _para2:size_t):pchar;cdecl;external;
procedure nffreeall;cdecl;external;
{$endif}
{ LIBDPKG_DPKG_DB_H }
(* error
#endif /* LIBDPKG_DPKG_DB_H */ *)
implementation
end.