1 /*
2  * alpm.h
3  *
4  *  Copyright (c) 2006-2019 Pacman Development Team <pacman-dev@archlinux.org>
5  *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
6  *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
7  *  Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
8  *  Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23 module alpm.alpm;
24 
25 import alpm.alpm_list;
26 import core.stdc.config;
27 import core.stdc.stdlib;
28 import core.stdc.stdarg;
29 
30 extern (C):
31 
32 alias off_t = int;
33 alias mode_t = uint;
34 struct archive;
35 struct archive_entry;
36 
37 /* int64_t */
38 /* off_t */
39 /* va_list */
40 
41 /* libarchive */
42 
43 /*
44  * Arch Linux Package Management library
45  */
46 
47 /*
48  * Opaque Structures
49  */
50 struct __alpm_handle_t;
51 alias alpm_handle_t = __alpm_handle_t;
52 struct __alpm_db_t;
53 alias alpm_db_t = __alpm_db_t;
54 struct __alpm_pkg_t;
55 alias alpm_pkg_t = __alpm_pkg_t;
56 struct __alpm_trans_t;
57 alias alpm_trans_t = __alpm_trans_t;
58 
59 /** @addtogroup alpm_api_errors Error Codes
60  * @{
61  */
62 enum _alpm_errno_t
63 {
64     ALPM_ERR_OK = 0,
65     ALPM_ERR_MEMORY = 1,
66     ALPM_ERR_SYSTEM = 2,
67     ALPM_ERR_BADPERMS = 3,
68     ALPM_ERR_NOT_A_FILE = 4,
69     ALPM_ERR_NOT_A_DIR = 5,
70     ALPM_ERR_WRONG_ARGS = 6,
71     ALPM_ERR_DISK_SPACE = 7,
72     /* Interface */
73     ALPM_ERR_HANDLE_NULL = 8,
74     ALPM_ERR_HANDLE_NOT_NULL = 9,
75     ALPM_ERR_HANDLE_LOCK = 10,
76     /* Databases */
77     ALPM_ERR_DB_OPEN = 11,
78     ALPM_ERR_DB_CREATE = 12,
79     ALPM_ERR_DB_NULL = 13,
80     ALPM_ERR_DB_NOT_NULL = 14,
81     ALPM_ERR_DB_NOT_FOUND = 15,
82     ALPM_ERR_DB_INVALID = 16,
83     ALPM_ERR_DB_INVALID_SIG = 17,
84     ALPM_ERR_DB_VERSION = 18,
85     ALPM_ERR_DB_WRITE = 19,
86     ALPM_ERR_DB_REMOVE = 20,
87     /* Servers */
88     ALPM_ERR_SERVER_BAD_URL = 21,
89     ALPM_ERR_SERVER_NONE = 22,
90     /* Transactions */
91     ALPM_ERR_TRANS_NOT_NULL = 23,
92     ALPM_ERR_TRANS_NULL = 24,
93     ALPM_ERR_TRANS_DUP_TARGET = 25,
94     ALPM_ERR_TRANS_NOT_INITIALIZED = 26,
95     ALPM_ERR_TRANS_NOT_PREPARED = 27,
96     ALPM_ERR_TRANS_ABORT = 28,
97     ALPM_ERR_TRANS_TYPE = 29,
98     ALPM_ERR_TRANS_NOT_LOCKED = 30,
99     ALPM_ERR_TRANS_HOOK_FAILED = 31,
100     /* Packages */
101     ALPM_ERR_PKG_NOT_FOUND = 32,
102     ALPM_ERR_PKG_IGNORED = 33,
103     ALPM_ERR_PKG_INVALID = 34,
104     ALPM_ERR_PKG_INVALID_CHECKSUM = 35,
105     ALPM_ERR_PKG_INVALID_SIG = 36,
106     ALPM_ERR_PKG_MISSING_SIG = 37,
107     ALPM_ERR_PKG_OPEN = 38,
108     ALPM_ERR_PKG_CANT_REMOVE = 39,
109     ALPM_ERR_PKG_INVALID_NAME = 40,
110     ALPM_ERR_PKG_INVALID_ARCH = 41,
111     ALPM_ERR_PKG_REPO_NOT_FOUND = 42,
112     /* Signatures */
113     ALPM_ERR_SIG_MISSING = 43,
114     ALPM_ERR_SIG_INVALID = 44,
115     /* Dependencies */
116     ALPM_ERR_UNSATISFIED_DEPS = 45,
117     ALPM_ERR_CONFLICTING_DEPS = 46,
118     ALPM_ERR_FILE_CONFLICTS = 47,
119     /* Misc */
120     ALPM_ERR_RETRIEVE = 48,
121     ALPM_ERR_INVALID_REGEX = 49,
122     /* External library errors */
123     ALPM_ERR_LIBARCHIVE = 50,
124     ALPM_ERR_LIBCURL = 51,
125     ALPM_ERR_EXTERNAL_DOWNLOAD = 52,
126     ALPM_ERR_GPGME = 53,
127     /* Missing compile-time features */
128     ALPM_ERR_MISSING_CAPABILITY_SIGNATURES = 54
129 }
130 
131 alias alpm_errno_t = _alpm_errno_t;
132 
133 /** Returns the current error code from the handle. */
134 alpm_errno_t alpm_errno (alpm_handle_t* handle);
135 
136 /** Returns the string corresponding to an error number. */
137 const(char)* alpm_strerror (alpm_errno_t err);
138 
139 /* End of alpm_api_errors */
140 /** @} */
141 
142 /** @addtogroup alpm_api Public API
143  * The libalpm Public API
144  * @{
145  */
146 
147 alias alpm_time_t = c_long;
148 
149 /*
150  * Enumerations
151  * These ones are used in multiple contexts, so are forward-declared.
152  */
153 
154 /** Package install reasons. */
155 enum _alpm_pkgreason_t
156 {
157     /** Explicitly requested by the user. */
158     ALPM_PKG_REASON_EXPLICIT = 0,
159     /** Installed as a dependency for another package. */
160     ALPM_PKG_REASON_DEPEND = 1
161 }
162 
163 alias alpm_pkgreason_t = _alpm_pkgreason_t;
164 
165 /** Location a package object was loaded from. */
166 enum _alpm_pkgfrom_t
167 {
168     ALPM_PKG_FROM_FILE = 1,
169     ALPM_PKG_FROM_LOCALDB = 2,
170     ALPM_PKG_FROM_SYNCDB = 3
171 }
172 
173 alias alpm_pkgfrom_t = _alpm_pkgfrom_t;
174 
175 /** Method used to validate a package. */
176 enum _alpm_pkgvalidation_t
177 {
178     ALPM_PKG_VALIDATION_UNKNOWN = 0,
179     ALPM_PKG_VALIDATION_NONE = 1 << 0,
180     ALPM_PKG_VALIDATION_MD5SUM = 1 << 1,
181     ALPM_PKG_VALIDATION_SHA256SUM = 1 << 2,
182     ALPM_PKG_VALIDATION_SIGNATURE = 1 << 3
183 }
184 
185 alias alpm_pkgvalidation_t = _alpm_pkgvalidation_t;
186 
187 /** Types of version constraints in dependency specs. */
188 enum _alpm_depmod_t
189 {
190     /** No version constraint */
191     ALPM_DEP_MOD_ANY = 1,
192     /** Test version equality (package=x.y.z) */
193     ALPM_DEP_MOD_EQ = 2,
194     /** Test for at least a version (package>=x.y.z) */
195     ALPM_DEP_MOD_GE = 3,
196     /** Test for at most a version (package<=x.y.z) */
197     ALPM_DEP_MOD_LE = 4,
198     /** Test for greater than some version (package>x.y.z) */
199     ALPM_DEP_MOD_GT = 5,
200     /** Test for less than some version (package<x.y.z) */
201     ALPM_DEP_MOD_LT = 6
202 }
203 
204 alias alpm_depmod_t = _alpm_depmod_t;
205 
206 /**
207  * File conflict type.
208  * Whether the conflict results from a file existing on the filesystem, or with
209  * another target in the transaction.
210  */
211 enum _alpm_fileconflicttype_t
212 {
213     ALPM_FILECONFLICT_TARGET = 1,
214     ALPM_FILECONFLICT_FILESYSTEM = 2
215 }
216 
217 alias alpm_fileconflicttype_t = _alpm_fileconflicttype_t;
218 
219 /** PGP signature verification options */
220 enum _alpm_siglevel_t
221 {
222     ALPM_SIG_PACKAGE = 1 << 0,
223     ALPM_SIG_PACKAGE_OPTIONAL = 1 << 1,
224     ALPM_SIG_PACKAGE_MARGINAL_OK = 1 << 2,
225     ALPM_SIG_PACKAGE_UNKNOWN_OK = 1 << 3,
226 
227     ALPM_SIG_DATABASE = 1 << 10,
228     ALPM_SIG_DATABASE_OPTIONAL = 1 << 11,
229     ALPM_SIG_DATABASE_MARGINAL_OK = 1 << 12,
230     ALPM_SIG_DATABASE_UNKNOWN_OK = 1 << 13,
231 
232     ALPM_SIG_USE_DEFAULT = 1 << 30
233 }
234 
235 alias alpm_siglevel_t = _alpm_siglevel_t;
236 
237 /** PGP signature verification status return codes */
238 enum _alpm_sigstatus_t
239 {
240     ALPM_SIGSTATUS_VALID = 0,
241     ALPM_SIGSTATUS_KEY_EXPIRED = 1,
242     ALPM_SIGSTATUS_SIG_EXPIRED = 2,
243     ALPM_SIGSTATUS_KEY_UNKNOWN = 3,
244     ALPM_SIGSTATUS_KEY_DISABLED = 4,
245     ALPM_SIGSTATUS_INVALID = 5
246 }
247 
248 alias alpm_sigstatus_t = _alpm_sigstatus_t;
249 
250 /** PGP signature verification status return codes */
251 enum _alpm_sigvalidity_t
252 {
253     ALPM_SIGVALIDITY_FULL = 0,
254     ALPM_SIGVALIDITY_MARGINAL = 1,
255     ALPM_SIGVALIDITY_NEVER = 2,
256     ALPM_SIGVALIDITY_UNKNOWN = 3
257 }
258 
259 alias alpm_sigvalidity_t = _alpm_sigvalidity_t;
260 
261 /*
262  * Structures
263  */
264 
265 /** Dependency */
266 struct _alpm_depend_t
267 {
268     char* name;
269     char* version_;
270     char* desc;
271     c_ulong name_hash;
272     alpm_depmod_t mod;
273 }
274 
275 alias alpm_depend_t = _alpm_depend_t;
276 
277 /** Missing dependency */
278 struct _alpm_depmissing_t
279 {
280     char* target;
281     alpm_depend_t* depend;
282     /* this is used only in the case of a remove dependency error */
283     char* causingpkg;
284 }
285 
286 alias alpm_depmissing_t = _alpm_depmissing_t;
287 
288 /** Conflict */
289 struct _alpm_conflict_t
290 {
291     c_ulong package1_hash;
292     c_ulong package2_hash;
293     char* package1;
294     char* package2;
295     alpm_depend_t* reason;
296 }
297 
298 alias alpm_conflict_t = _alpm_conflict_t;
299 
300 /** File conflict */
301 struct _alpm_fileconflict_t
302 {
303     char* target;
304     alpm_fileconflicttype_t type;
305     char* file;
306     char* ctarget;
307 }
308 
309 alias alpm_fileconflict_t = _alpm_fileconflict_t;
310 
311 /** Package group */
312 struct _alpm_group_t
313 {
314     /** group name */
315     char* name;
316     /** list of alpm_pkg_t packages */
317     alpm_list_t* packages;
318 }
319 
320 alias alpm_group_t = _alpm_group_t;
321 
322 /** File in a package */
323 struct _alpm_file_t
324 {
325     char* name;
326     off_t size;
327     mode_t mode;
328 }
329 
330 alias alpm_file_t = _alpm_file_t;
331 
332 /** Package filelist container */
333 struct _alpm_filelist_t
334 {
335     size_t count;
336     alpm_file_t* files;
337 }
338 
339 alias alpm_filelist_t = _alpm_filelist_t;
340 
341 /** Local package or package file backup entry */
342 struct _alpm_backup_t
343 {
344     char* name;
345     char* hash;
346 }
347 
348 alias alpm_backup_t = _alpm_backup_t;
349 
350 struct _alpm_pgpkey_t
351 {
352     void* data;
353     char* fingerprint;
354     char* uid;
355     char* name;
356     char* email;
357     alpm_time_t created;
358     alpm_time_t expires;
359     uint length;
360     uint revoked;
361     char pubkey_algo;
362 }
363 
364 alias alpm_pgpkey_t = _alpm_pgpkey_t;
365 
366 /**
367  * Signature result. Contains the key, status, and validity of a given
368  * signature.
369  */
370 struct _alpm_sigresult_t
371 {
372     alpm_pgpkey_t key;
373     alpm_sigstatus_t status;
374     alpm_sigvalidity_t validity;
375 }
376 
377 alias alpm_sigresult_t = _alpm_sigresult_t;
378 
379 /**
380  * Signature list. Contains the number of signatures found and a pointer to an
381  * array of results. The array is of size count.
382  */
383 struct _alpm_siglist_t
384 {
385     size_t count;
386     alpm_sigresult_t* results;
387 }
388 
389 alias alpm_siglist_t = _alpm_siglist_t;
390 
391 /*
392  * Hooks
393  */
394 
395 enum _alpm_hook_when_t
396 {
397     ALPM_HOOK_PRE_TRANSACTION = 1,
398     ALPM_HOOK_POST_TRANSACTION = 2
399 }
400 
401 alias alpm_hook_when_t = _alpm_hook_when_t;
402 
403 /*
404  * Logging facilities
405  */
406 
407 /** Logging Levels */
408 enum _alpm_loglevel_t
409 {
410     ALPM_LOG_ERROR = 1,
411     ALPM_LOG_WARNING = 1 << 1,
412     ALPM_LOG_DEBUG = 1 << 2,
413     ALPM_LOG_FUNCTION = 1 << 3
414 }
415 
416 alias alpm_loglevel_t = _alpm_loglevel_t;
417 
418 alias alpm_cb_log = void function (alpm_loglevel_t, const(char)*, va_list);
419 
420 int alpm_logaction (
421     alpm_handle_t* handle,
422     const(char)* prefix,
423     const(char)* fmt,
424     ...);
425 
426 /**
427  * Type of events.
428  */
429 enum _alpm_event_type_t
430 {
431     /** Dependencies will be computed for a package. */
432     ALPM_EVENT_CHECKDEPS_START = 1,
433     /** Dependencies were computed for a package. */
434     ALPM_EVENT_CHECKDEPS_DONE = 2,
435     /** File conflicts will be computed for a package. */
436     ALPM_EVENT_FILECONFLICTS_START = 3,
437     /** File conflicts were computed for a package. */
438     ALPM_EVENT_FILECONFLICTS_DONE = 4,
439     /** Dependencies will be resolved for target package. */
440     ALPM_EVENT_RESOLVEDEPS_START = 5,
441     /** Dependencies were resolved for target package. */
442     ALPM_EVENT_RESOLVEDEPS_DONE = 6,
443     /** Inter-conflicts will be checked for target package. */
444     ALPM_EVENT_INTERCONFLICTS_START = 7,
445     /** Inter-conflicts were checked for target package. */
446     ALPM_EVENT_INTERCONFLICTS_DONE = 8,
447     /** Processing the package transaction is starting. */
448     ALPM_EVENT_TRANSACTION_START = 9,
449     /** Processing the package transaction is finished. */
450     ALPM_EVENT_TRANSACTION_DONE = 10,
451     /** Package will be installed/upgraded/downgraded/re-installed/removed; See
452     	 * alpm_event_package_operation_t for arguments. */
453     ALPM_EVENT_PACKAGE_OPERATION_START = 11,
454     /** Package was installed/upgraded/downgraded/re-installed/removed; See
455     	 * alpm_event_package_operation_t for arguments. */
456     ALPM_EVENT_PACKAGE_OPERATION_DONE = 12,
457     /** Target package's integrity will be checked. */
458     ALPM_EVENT_INTEGRITY_START = 13,
459     /** Target package's integrity was checked. */
460     ALPM_EVENT_INTEGRITY_DONE = 14,
461     /** Target package will be loaded. */
462     ALPM_EVENT_LOAD_START = 15,
463     /** Target package is finished loading. */
464     ALPM_EVENT_LOAD_DONE = 16,
465     /** Scriptlet has printed information; See alpm_event_scriptlet_info_t for
466     	 * arguments. */
467     ALPM_EVENT_SCRIPTLET_INFO = 17,
468     /** Files will be downloaded from a repository. */
469     ALPM_EVENT_RETRIEVE_START = 18,
470     /** Files were downloaded from a repository. */
471     ALPM_EVENT_RETRIEVE_DONE = 19,
472     /** Not all files were successfully downloaded from a repository. */
473     ALPM_EVENT_RETRIEVE_FAILED = 20,
474     /** A file will be downloaded from a repository; See alpm_event_pkgdownload_t
475     	 * for arguments */
476     ALPM_EVENT_PKGDOWNLOAD_START = 21,
477     /** A file was downloaded from a repository; See alpm_event_pkgdownload_t
478     	 * for arguments */
479     ALPM_EVENT_PKGDOWNLOAD_DONE = 22,
480     /** A file failed to be downloaded from a repository; See
481     	 * alpm_event_pkgdownload_t for arguments */
482     ALPM_EVENT_PKGDOWNLOAD_FAILED = 23,
483     /** Disk space usage will be computed for a package. */
484     ALPM_EVENT_DISKSPACE_START = 24,
485     /** Disk space usage was computed for a package. */
486     ALPM_EVENT_DISKSPACE_DONE = 25,
487     /** An optdepend for another package is being removed; See
488     	 * alpm_event_optdep_removal_t for arguments. */
489     ALPM_EVENT_OPTDEP_REMOVAL = 26,
490     /** A configured repository database is missing; See
491     	 * alpm_event_database_missing_t for arguments. */
492     ALPM_EVENT_DATABASE_MISSING = 27,
493     /** Checking keys used to create signatures are in keyring. */
494     ALPM_EVENT_KEYRING_START = 28,
495     /** Keyring checking is finished. */
496     ALPM_EVENT_KEYRING_DONE = 29,
497     /** Downloading missing keys into keyring. */
498     ALPM_EVENT_KEY_DOWNLOAD_START = 30,
499     /** Key downloading is finished. */
500     ALPM_EVENT_KEY_DOWNLOAD_DONE = 31,
501     /** A .pacnew file was created; See alpm_event_pacnew_created_t for arguments. */
502     ALPM_EVENT_PACNEW_CREATED = 32,
503     /** A .pacsave file was created; See alpm_event_pacsave_created_t for
504     	 * arguments */
505     ALPM_EVENT_PACSAVE_CREATED = 33,
506     /** Processing hooks will be started. */
507     ALPM_EVENT_HOOK_START = 34,
508     /** Processing hooks is finished. */
509     ALPM_EVENT_HOOK_DONE = 35,
510     /** A hook is starting */
511     ALPM_EVENT_HOOK_RUN_START = 36,
512     /** A hook has finished running */
513     ALPM_EVENT_HOOK_RUN_DONE = 37
514 }
515 
516 alias alpm_event_type_t = _alpm_event_type_t;
517 
518 struct _alpm_event_any_t
519 {
520     /** Type of event. */
521     alpm_event_type_t type;
522 }
523 
524 alias alpm_event_any_t = _alpm_event_any_t;
525 
526 enum _alpm_package_operation_t
527 {
528     /** Package (to be) installed. (No oldpkg) */
529     ALPM_PACKAGE_INSTALL = 1,
530     /** Package (to be) upgraded */
531     ALPM_PACKAGE_UPGRADE = 2,
532     /** Package (to be) re-installed. */
533     ALPM_PACKAGE_REINSTALL = 3,
534     /** Package (to be) downgraded. */
535     ALPM_PACKAGE_DOWNGRADE = 4,
536     /** Package (to be) removed. (No newpkg) */
537     ALPM_PACKAGE_REMOVE = 5
538 }
539 
540 alias alpm_package_operation_t = _alpm_package_operation_t;
541 
542 struct _alpm_event_package_operation_t
543 {
544     /** Type of event. */
545     alpm_event_type_t type;
546     /** Type of operation. */
547     alpm_package_operation_t operation;
548     /** Old package. */
549     alpm_pkg_t* oldpkg;
550     /** New package. */
551     alpm_pkg_t* newpkg;
552 }
553 
554 alias alpm_event_package_operation_t = _alpm_event_package_operation_t;
555 
556 struct _alpm_event_optdep_removal_t
557 {
558     /** Type of event. */
559     alpm_event_type_t type;
560     /** Package with the optdep. */
561     alpm_pkg_t* pkg;
562     /** Optdep being removed. */
563     alpm_depend_t* optdep;
564 }
565 
566 alias alpm_event_optdep_removal_t = _alpm_event_optdep_removal_t;
567 
568 struct _alpm_event_scriptlet_info_t
569 {
570     /** Type of event. */
571     alpm_event_type_t type;
572     /** Line of scriptlet output. */
573     const(char)* line;
574 }
575 
576 alias alpm_event_scriptlet_info_t = _alpm_event_scriptlet_info_t;
577 
578 struct _alpm_event_database_missing_t
579 {
580     /** Type of event. */
581     alpm_event_type_t type;
582     /** Name of the database. */
583     const(char)* dbname;
584 }
585 
586 alias alpm_event_database_missing_t = _alpm_event_database_missing_t;
587 
588 struct _alpm_event_pkgdownload_t
589 {
590     /** Type of event. */
591     alpm_event_type_t type;
592     /** Name of the file */
593     const(char)* file;
594 }
595 
596 alias alpm_event_pkgdownload_t = _alpm_event_pkgdownload_t;
597 
598 struct _alpm_event_pacnew_created_t
599 {
600     /** Type of event. */
601     alpm_event_type_t type;
602     /** Whether the creation was result of a NoUpgrade or not */
603     int from_noupgrade;
604     /** Old package. */
605     alpm_pkg_t* oldpkg;
606     /** New Package. */
607     alpm_pkg_t* newpkg;
608     /** Filename of the file without the .pacnew suffix */
609     const(char)* file;
610 }
611 
612 alias alpm_event_pacnew_created_t = _alpm_event_pacnew_created_t;
613 
614 struct _alpm_event_pacsave_created_t
615 {
616     /** Type of event. */
617     alpm_event_type_t type;
618     /** Old package. */
619     alpm_pkg_t* oldpkg;
620     /** Filename of the file without the .pacsave suffix. */
621     const(char)* file;
622 }
623 
624 alias alpm_event_pacsave_created_t = _alpm_event_pacsave_created_t;
625 
626 struct _alpm_event_hook_t
627 {
628     /** Type of event.*/
629     alpm_event_type_t type;
630     /** Type of hooks. */
631     alpm_hook_when_t when;
632 }
633 
634 alias alpm_event_hook_t = _alpm_event_hook_t;
635 
636 struct _alpm_event_hook_run_t
637 {
638     /** Type of event.*/
639     alpm_event_type_t type;
640     /** Name of hook */
641     const(char)* name;
642     /** Description of hook to be outputted */
643     const(char)* desc;
644     /** position of hook being run */
645     size_t position;
646     /** total hooks being run */
647     size_t total;
648 }
649 
650 alias alpm_event_hook_run_t = _alpm_event_hook_run_t;
651 
652 /** Events.
653  * This is an union passed to the callback, that allows the frontend to know
654  * which type of event was triggered (via type). It is then possible to
655  * typecast the pointer to the right structure, or use the union field, in order
656  * to access event-specific data. */
657 union _alpm_event_t
658 {
659     alpm_event_type_t type;
660     alpm_event_any_t any;
661     alpm_event_package_operation_t package_operation;
662     alpm_event_optdep_removal_t optdep_removal;
663     alpm_event_scriptlet_info_t scriptlet_info;
664     alpm_event_database_missing_t database_missing;
665     alpm_event_pkgdownload_t pkgdownload;
666     alpm_event_pacnew_created_t pacnew_created;
667     alpm_event_pacsave_created_t pacsave_created;
668     alpm_event_hook_t hook;
669     alpm_event_hook_run_t hook_run;
670 }
671 
672 alias alpm_event_t = _alpm_event_t;
673 
674 /** Event callback. */
675 alias alpm_cb_event = void function (alpm_event_t*);
676 
677 /**
678  * Type of questions.
679  * Unlike the events or progress enumerations, this enum has bitmask values
680  * so a frontend can use a bitmask map to supply preselected answers to the
681  * different types of questions.
682  */
683 enum _alpm_question_type_t
684 {
685     ALPM_QUESTION_INSTALL_IGNOREPKG = 1 << 0,
686     ALPM_QUESTION_REPLACE_PKG = 1 << 1,
687     ALPM_QUESTION_CONFLICT_PKG = 1 << 2,
688     ALPM_QUESTION_CORRUPTED_PKG = 1 << 3,
689     ALPM_QUESTION_REMOVE_PKGS = 1 << 4,
690     ALPM_QUESTION_SELECT_PROVIDER = 1 << 5,
691     ALPM_QUESTION_IMPORT_KEY = 1 << 6
692 }
693 
694 alias alpm_question_type_t = _alpm_question_type_t;
695 
696 struct _alpm_question_any_t
697 {
698     /** Type of question. */
699     alpm_question_type_t type;
700     /** Answer. */
701     int answer;
702 }
703 
704 alias alpm_question_any_t = _alpm_question_any_t;
705 
706 struct _alpm_question_install_ignorepkg_t
707 {
708     /** Type of question. */
709     alpm_question_type_t type;
710     /** Answer: whether or not to install pkg anyway. */
711     int install;
712     /* Package in IgnorePkg/IgnoreGroup. */
713     alpm_pkg_t* pkg;
714 }
715 
716 alias alpm_question_install_ignorepkg_t = _alpm_question_install_ignorepkg_t;
717 
718 struct _alpm_question_replace_t
719 {
720     /** Type of question. */
721     alpm_question_type_t type;
722     /** Answer: whether or not to replace oldpkg with newpkg. */
723     int replace;
724     /* Package to be replaced. */
725     alpm_pkg_t* oldpkg;
726     /* Package to replace with. */
727     alpm_pkg_t* newpkg;
728     /* DB of newpkg */
729     alpm_db_t* newdb;
730 }
731 
732 alias alpm_question_replace_t = _alpm_question_replace_t;
733 
734 struct _alpm_question_conflict_t
735 {
736     /** Type of question. */
737     alpm_question_type_t type;
738     /** Answer: whether or not to remove conflict->package2. */
739     int remove;
740     /** Conflict info. */
741     alpm_conflict_t* conflict;
742 }
743 
744 alias alpm_question_conflict_t = _alpm_question_conflict_t;
745 
746 struct _alpm_question_corrupted_t
747 {
748     /** Type of question. */
749     alpm_question_type_t type;
750     /** Answer: whether or not to remove filepath. */
751     int remove;
752     /** Filename to remove */
753     const(char)* filepath;
754     /** Error code indicating the reason for package invalidity */
755     alpm_errno_t reason;
756 }
757 
758 alias alpm_question_corrupted_t = _alpm_question_corrupted_t;
759 
760 struct _alpm_question_remove_pkgs_t
761 {
762     /** Type of question. */
763     alpm_question_type_t type;
764     /** Answer: whether or not to skip packages. */
765     int skip;
766     /** List of alpm_pkg_t* with unresolved dependencies. */
767     alpm_list_t* packages;
768 }
769 
770 alias alpm_question_remove_pkgs_t = _alpm_question_remove_pkgs_t;
771 
772 struct _alpm_question_select_provider_t
773 {
774     /** Type of question. */
775     alpm_question_type_t type;
776     /** Answer: which provider to use (index from providers). */
777     int use_index;
778     /** List of alpm_pkg_t* as possible providers. */
779     alpm_list_t* providers;
780     /** What providers provide for. */
781     alpm_depend_t* depend;
782 }
783 
784 alias alpm_question_select_provider_t = _alpm_question_select_provider_t;
785 
786 struct _alpm_question_import_key_t
787 {
788     /** Type of question. */
789     alpm_question_type_t type;
790     /** Answer: whether or not to import key. */
791     int import_;
792     /** The key to import. */
793     alpm_pgpkey_t* key;
794 }
795 
796 alias alpm_question_import_key_t = _alpm_question_import_key_t;
797 
798 /**
799  * Questions.
800  * This is an union passed to the callback, that allows the frontend to know
801  * which type of question was triggered (via type). It is then possible to
802  * typecast the pointer to the right structure, or use the union field, in order
803  * to access question-specific data. */
804 union _alpm_question_t
805 {
806     alpm_question_type_t type;
807     alpm_question_any_t any;
808     alpm_question_install_ignorepkg_t install_ignorepkg;
809     alpm_question_replace_t replace;
810     alpm_question_conflict_t conflict;
811     alpm_question_corrupted_t corrupted;
812     alpm_question_remove_pkgs_t remove_pkgs;
813     alpm_question_select_provider_t select_provider;
814     alpm_question_import_key_t import_key;
815 }
816 
817 alias alpm_question_t = _alpm_question_t;
818 
819 /** Question callback */
820 alias alpm_cb_question = void function (alpm_question_t*);
821 
822 /** Progress */
823 enum _alpm_progress_t
824 {
825     ALPM_PROGRESS_ADD_START = 0,
826     ALPM_PROGRESS_UPGRADE_START = 1,
827     ALPM_PROGRESS_DOWNGRADE_START = 2,
828     ALPM_PROGRESS_REINSTALL_START = 3,
829     ALPM_PROGRESS_REMOVE_START = 4,
830     ALPM_PROGRESS_CONFLICTS_START = 5,
831     ALPM_PROGRESS_DISKSPACE_START = 6,
832     ALPM_PROGRESS_INTEGRITY_START = 7,
833     ALPM_PROGRESS_LOAD_START = 8,
834     ALPM_PROGRESS_KEYRING_START = 9
835 }
836 
837 alias alpm_progress_t = _alpm_progress_t;
838 
839 /** Progress callback */
840 alias alpm_cb_progress = void function (alpm_progress_t, const(char)*, int, size_t, size_t);
841 
842 /*
843  * Downloading
844  */
845 
846 /** Type of download progress callbacks.
847  * @param filename the name of the file being downloaded
848  * @param xfered the number of transferred bytes
849  * @param total the total number of bytes to transfer
850  */
851 alias alpm_cb_download = void function (
852     const(char)* filename,
853     off_t xfered,
854     off_t total);
855 
856 alias alpm_cb_totaldl = void function (off_t total);
857 
858 /** A callback for downloading files
859  * @param url the URL of the file to be downloaded
860  * @param localpath the directory to which the file should be downloaded
861  * @param force whether to force an update, even if the file is the same
862  * @return 0 on success, 1 if the file exists and is identical, -1 on
863  * error.
864  */
865 alias alpm_cb_fetch = int function (
866     const(char)* url,
867     const(char)* localpath,
868     int force);
869 
870 /** Fetch a remote pkg.
871  * @param handle the context handle
872  * @param url URL of the package to download
873  * @return the downloaded filepath on success, NULL on error
874  */
875 char* alpm_fetch_pkgurl (alpm_handle_t* handle, const(char)* url);
876 
877 /** @addtogroup alpm_api_options Options
878  * Libalpm option getters and setters
879  * @{
880  */
881 
882 /** Returns the callback used for logging. */
883 alpm_cb_log alpm_option_get_logcb (alpm_handle_t* handle);
884 /** Sets the callback used for logging. */
885 int alpm_option_set_logcb (alpm_handle_t* handle, alpm_cb_log cb);
886 
887 /** Returns the callback used to report download progress. */
888 alpm_cb_download alpm_option_get_dlcb (alpm_handle_t* handle);
889 /** Sets the callback used to report download progress. */
890 int alpm_option_set_dlcb (alpm_handle_t* handle, alpm_cb_download cb);
891 
892 /** Returns the downloading callback. */
893 alpm_cb_fetch alpm_option_get_fetchcb (alpm_handle_t* handle);
894 /** Sets the downloading callback. */
895 int alpm_option_set_fetchcb (alpm_handle_t* handle, alpm_cb_fetch cb);
896 
897 /** Returns the callback used to report total download size. */
898 alpm_cb_totaldl alpm_option_get_totaldlcb (alpm_handle_t* handle);
899 /** Sets the callback used to report total download size. */
900 int alpm_option_set_totaldlcb (alpm_handle_t* handle, alpm_cb_totaldl cb);
901 
902 /** Returns the callback used for events. */
903 alpm_cb_event alpm_option_get_eventcb (alpm_handle_t* handle);
904 /** Sets the callback used for events. */
905 int alpm_option_set_eventcb (alpm_handle_t* handle, alpm_cb_event cb);
906 
907 /** Returns the callback used for questions. */
908 alpm_cb_question alpm_option_get_questioncb (alpm_handle_t* handle);
909 /** Sets the callback used for questions. */
910 int alpm_option_set_questioncb (alpm_handle_t* handle, alpm_cb_question cb);
911 
912 /** Returns the callback used for operation progress. */
913 alpm_cb_progress alpm_option_get_progresscb (alpm_handle_t* handle);
914 /** Sets the callback used for operation progress. */
915 int alpm_option_set_progresscb (alpm_handle_t* handle, alpm_cb_progress cb);
916 
917 /** Returns the root of the destination filesystem. Read-only. */
918 const(char)* alpm_option_get_root (alpm_handle_t* handle);
919 
920 /** Returns the path to the database directory. Read-only. */
921 const(char)* alpm_option_get_dbpath (alpm_handle_t* handle);
922 
923 /** Get the name of the database lock file. Read-only. */
924 const(char)* alpm_option_get_lockfile (alpm_handle_t* handle);
925 
926 /** @name Accessors to the list of package cache directories.
927  * @{
928  */
929 alpm_list_t* alpm_option_get_cachedirs (alpm_handle_t* handle);
930 int alpm_option_set_cachedirs (alpm_handle_t* handle, alpm_list_t* cachedirs);
931 int alpm_option_add_cachedir (alpm_handle_t* handle, const(char)* cachedir);
932 int alpm_option_remove_cachedir (alpm_handle_t* handle, const(char)* cachedir);
933 /** @} */
934 
935 /** @name Accessors to the list of package hook directories.
936  * @{
937  */
938 alpm_list_t* alpm_option_get_hookdirs (alpm_handle_t* handle);
939 int alpm_option_set_hookdirs (alpm_handle_t* handle, alpm_list_t* hookdirs);
940 int alpm_option_add_hookdir (alpm_handle_t* handle, const(char)* hookdir);
941 int alpm_option_remove_hookdir (alpm_handle_t* handle, const(char)* hookdir);
942 /** @} */
943 
944 alpm_list_t* alpm_option_get_overwrite_files (alpm_handle_t* handle);
945 int alpm_option_set_overwrite_files (alpm_handle_t* handle, alpm_list_t* globs);
946 int alpm_option_add_overwrite_file (alpm_handle_t* handle, const(char)* glob);
947 int alpm_option_remove_overwrite_file (alpm_handle_t* handle, const(char)* glob);
948 
949 /** Returns the logfile name. */
950 const(char)* alpm_option_get_logfile (alpm_handle_t* handle);
951 /** Sets the logfile name. */
952 int alpm_option_set_logfile (alpm_handle_t* handle, const(char)* logfile);
953 
954 /** Returns the path to libalpm's GnuPG home directory. */
955 const(char)* alpm_option_get_gpgdir (alpm_handle_t* handle);
956 /** Sets the path to libalpm's GnuPG home directory. */
957 int alpm_option_set_gpgdir (alpm_handle_t* handle, const(char)* gpgdir);
958 
959 /** Returns whether to use syslog (0 is FALSE, TRUE otherwise). */
960 int alpm_option_get_usesyslog (alpm_handle_t* handle);
961 /** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */
962 int alpm_option_set_usesyslog (alpm_handle_t* handle, int usesyslog);
963 
964 /** @name Accessors to the list of no-upgrade files.
965  * These functions modify the list of files which should
966  * not be updated by package installation.
967  * @{
968  */
969 alpm_list_t* alpm_option_get_noupgrades (alpm_handle_t* handle);
970 int alpm_option_add_noupgrade (alpm_handle_t* handle, const(char)* path);
971 int alpm_option_set_noupgrades (alpm_handle_t* handle, alpm_list_t* noupgrade);
972 int alpm_option_remove_noupgrade (alpm_handle_t* handle, const(char)* path);
973 int alpm_option_match_noupgrade (alpm_handle_t* handle, const(char)* path);
974 /** @} */
975 
976 /** @name Accessors to the list of no-extract files.
977  * These functions modify the list of filenames which should
978  * be skipped packages which should
979  * not be upgraded by a sysupgrade operation.
980  * @{
981  */
982 alpm_list_t* alpm_option_get_noextracts (alpm_handle_t* handle);
983 int alpm_option_add_noextract (alpm_handle_t* handle, const(char)* path);
984 int alpm_option_set_noextracts (alpm_handle_t* handle, alpm_list_t* noextract);
985 int alpm_option_remove_noextract (alpm_handle_t* handle, const(char)* path);
986 int alpm_option_match_noextract (alpm_handle_t* handle, const(char)* path);
987 /** @} */
988 
989 /** @name Accessors to the list of ignored packages.
990  * These functions modify the list of packages that
991  * should be ignored by a sysupgrade.
992  * @{
993  */
994 alpm_list_t* alpm_option_get_ignorepkgs (alpm_handle_t* handle);
995 int alpm_option_add_ignorepkg (alpm_handle_t* handle, const(char)* pkg);
996 int alpm_option_set_ignorepkgs (alpm_handle_t* handle, alpm_list_t* ignorepkgs);
997 int alpm_option_remove_ignorepkg (alpm_handle_t* handle, const(char)* pkg);
998 /** @} */
999 
1000 /** @name Accessors to the list of ignored groups.
1001  * These functions modify the list of groups whose packages
1002  * should be ignored by a sysupgrade.
1003  * @{
1004  */
1005 alpm_list_t* alpm_option_get_ignoregroups (alpm_handle_t* handle);
1006 int alpm_option_add_ignoregroup (alpm_handle_t* handle, const(char)* grp);
1007 int alpm_option_set_ignoregroups (alpm_handle_t* handle, alpm_list_t* ignoregrps);
1008 int alpm_option_remove_ignoregroup (alpm_handle_t* handle, const(char)* grp);
1009 /** @} */
1010 
1011 /** @name Accessors to the list of ignored dependencies.
1012  * These functions modify the list of dependencies that
1013  * should be ignored by a sysupgrade.
1014  * @{
1015  */
1016 alpm_list_t* alpm_option_get_assumeinstalled (alpm_handle_t* handle);
1017 int alpm_option_add_assumeinstalled (alpm_handle_t* handle, const(alpm_depend_t)* dep);
1018 int alpm_option_set_assumeinstalled (alpm_handle_t* handle, alpm_list_t* deps);
1019 int alpm_option_remove_assumeinstalled (alpm_handle_t* handle, const(alpm_depend_t)* dep);
1020 /** @} */
1021 
1022 /** Returns the targeted architecture. */
1023 const(char)* alpm_option_get_arch (alpm_handle_t* handle);
1024 /** Sets the targeted architecture. */
1025 int alpm_option_set_arch (alpm_handle_t* handle, const(char)* arch);
1026 
1027 int alpm_option_get_checkspace (alpm_handle_t* handle);
1028 int alpm_option_set_checkspace (alpm_handle_t* handle, int checkspace);
1029 
1030 const(char)* alpm_option_get_dbext (alpm_handle_t* handle);
1031 int alpm_option_set_dbext (alpm_handle_t* handle, const(char)* dbext);
1032 
1033 int alpm_option_get_default_siglevel (alpm_handle_t* handle);
1034 int alpm_option_set_default_siglevel (alpm_handle_t* handle, int level);
1035 
1036 int alpm_option_get_local_file_siglevel (alpm_handle_t* handle);
1037 int alpm_option_set_local_file_siglevel (alpm_handle_t* handle, int level);
1038 
1039 int alpm_option_get_remote_file_siglevel (alpm_handle_t* handle);
1040 int alpm_option_set_remote_file_siglevel (alpm_handle_t* handle, int level);
1041 
1042 int alpm_option_set_disable_dl_timeout (alpm_handle_t* handle, ushort disable_dl_timeout);
1043 
1044 /** @} */
1045 
1046 /** @addtogroup alpm_api_databases Database Functions
1047  * Functions to query and manipulate the database of libalpm.
1048  * @{
1049  */
1050 
1051 /** Get the database of locally installed packages.
1052  * The returned pointer points to an internal structure
1053  * of libalpm which should only be manipulated through
1054  * libalpm functions.
1055  * @return a reference to the local database
1056  */
1057 alpm_db_t* alpm_get_localdb (alpm_handle_t* handle);
1058 
1059 /** Get the list of sync databases.
1060  * Returns a list of alpm_db_t structures, one for each registered
1061  * sync database.
1062  * @param handle the context handle
1063  * @return a reference to an internal list of alpm_db_t structures
1064  */
1065 alpm_list_t* alpm_get_syncdbs (alpm_handle_t* handle);
1066 
1067 /** Register a sync database of packages.
1068  * @param handle the context handle
1069  * @param treename the name of the sync repository
1070  * @param level what level of signature checking to perform on the
1071  * database; note that this must be a '.sig' file type verification
1072  * @return an alpm_db_t* on success (the value), NULL on error
1073  */
1074 alpm_db_t* alpm_register_syncdb (
1075     alpm_handle_t* handle,
1076     const(char)* treename,
1077     int level);
1078 
1079 /** Unregister all package databases.
1080  * @param handle the context handle
1081  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1082  */
1083 int alpm_unregister_all_syncdbs (alpm_handle_t* handle);
1084 
1085 /** Unregister a package database.
1086  * @param db pointer to the package database to unregister
1087  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1088  */
1089 int alpm_db_unregister (alpm_db_t* db);
1090 
1091 /** Get the name of a package database.
1092  * @param db pointer to the package database
1093  * @return the name of the package database, NULL on error
1094  */
1095 const(char)* alpm_db_get_name (const(alpm_db_t)* db);
1096 
1097 /** Get the signature verification level for a database.
1098  * Will return the default verification level if this database is set up
1099  * with ALPM_SIG_USE_DEFAULT.
1100  * @param db pointer to the package database
1101  * @return the signature verification level
1102  */
1103 int alpm_db_get_siglevel (alpm_db_t* db);
1104 
1105 /** Check the validity of a database.
1106  * This is most useful for sync databases and verifying signature status.
1107  * If invalid, the handle error code will be set accordingly.
1108  * @param db pointer to the package database
1109  * @return 0 if valid, -1 if invalid (pm_errno is set accordingly)
1110  */
1111 int alpm_db_get_valid (alpm_db_t* db);
1112 
1113 /** @name Accessors to the list of servers for a database.
1114  * @{
1115  */
1116 alpm_list_t* alpm_db_get_servers (const(alpm_db_t)* db);
1117 int alpm_db_set_servers (alpm_db_t* db, alpm_list_t* servers);
1118 int alpm_db_add_server (alpm_db_t* db, const(char)* url);
1119 int alpm_db_remove_server (alpm_db_t* db, const(char)* url);
1120 /** @} */
1121 
1122 int alpm_db_update (int force, alpm_db_t* db);
1123 
1124 /** Get a package entry from a package database.
1125  * @param db pointer to the package database to get the package from
1126  * @param name of the package
1127  * @return the package entry on success, NULL on error
1128  */
1129 alpm_pkg_t* alpm_db_get_pkg (alpm_db_t* db, const(char)* name);
1130 
1131 /** Get the package cache of a package database.
1132  * @param db pointer to the package database to get the package from
1133  * @return the list of packages on success, NULL on error
1134  */
1135 alpm_list_t* alpm_db_get_pkgcache (alpm_db_t* db);
1136 
1137 /** Get a group entry from a package database.
1138  * @param db pointer to the package database to get the group from
1139  * @param name of the group
1140  * @return the groups entry on success, NULL on error
1141  */
1142 alpm_group_t* alpm_db_get_group (alpm_db_t* db, const(char)* name);
1143 
1144 /** Get the group cache of a package database.
1145  * @param db pointer to the package database to get the group from
1146  * @return the list of groups on success, NULL on error
1147  */
1148 alpm_list_t* alpm_db_get_groupcache (alpm_db_t* db);
1149 
1150 /** Searches a database with regular expressions.
1151  * @param db pointer to the package database to search in
1152  * @param needles a list of regular expressions to search for
1153  * @return the list of packages matching all regular expressions on success, NULL on error
1154  */
1155 alpm_list_t* alpm_db_search (alpm_db_t* db, const(alpm_list_t)* needles);
1156 
1157 enum _alpm_db_usage_t
1158 {
1159     ALPM_DB_USAGE_SYNC = 1,
1160     ALPM_DB_USAGE_SEARCH = 1 << 1,
1161     ALPM_DB_USAGE_INSTALL = 1 << 2,
1162     ALPM_DB_USAGE_UPGRADE = 1 << 3,
1163     ALPM_DB_USAGE_ALL = (1 << 4) - 1
1164 }
1165 
1166 alias alpm_db_usage_t = _alpm_db_usage_t;
1167 
1168 /** Sets the usage of a database.
1169  * @param db pointer to the package database to set the status for
1170  * @param usage a bitmask of alpm_db_usage_t values
1171  * @return 0 on success, or -1 on error
1172  */
1173 int alpm_db_set_usage (alpm_db_t* db, int usage);
1174 
1175 /** Gets the usage of a database.
1176  * @param db pointer to the package database to get the status of
1177  * @param usage pointer to an alpm_db_usage_t to store db's status
1178  * @return 0 on success, or -1 on error
1179  */
1180 int alpm_db_get_usage (alpm_db_t* db, int* usage);
1181 
1182 /** @} */
1183 
1184 /** @addtogroup alpm_api_packages Package Functions
1185  * Functions to manipulate libalpm packages
1186  * @{
1187  */
1188 
1189 /** Create a package from a file.
1190  * If full is false, the archive is read only until all necessary
1191  * metadata is found. If it is true, the entire archive is read, which
1192  * serves as a verification of integrity and the filelist can be created.
1193  * The allocated structure should be freed using alpm_pkg_free().
1194  * @param handle the context handle
1195  * @param filename location of the package tarball
1196  * @param full whether to stop the load after metadata is read or continue
1197  * through the full archive
1198  * @param level what level of package signature checking to perform on the
1199  * package; note that this must be a '.sig' file type verification
1200  * @param pkg address of the package pointer
1201  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1202  */
1203 int alpm_pkg_load (
1204     alpm_handle_t* handle,
1205     const(char)* filename,
1206     int full,
1207     int level,
1208     alpm_pkg_t** pkg);
1209 
1210 /** Find a package in a list by name.
1211  * @param haystack a list of alpm_pkg_t
1212  * @param needle the package name
1213  * @return a pointer to the package if found or NULL
1214  */
1215 alpm_pkg_t* alpm_pkg_find (alpm_list_t* haystack, const(char)* needle);
1216 
1217 /** Free a package.
1218  * @param pkg package pointer to free
1219  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1220  */
1221 int alpm_pkg_free (alpm_pkg_t* pkg);
1222 
1223 /** Check the integrity (with md5) of a package from the sync cache.
1224  * @param pkg package pointer
1225  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1226  */
1227 int alpm_pkg_checkmd5sum (alpm_pkg_t* pkg);
1228 
1229 /** Compare two version strings and determine which one is 'newer'. */
1230 int alpm_pkg_vercmp (const(char)* a, const(char)* b);
1231 
1232 /** Computes the list of packages requiring a given package.
1233  * The return value of this function is a newly allocated
1234  * list of package names (char*), it should be freed by the caller.
1235  * @param pkg a package
1236  * @return the list of packages requiring pkg
1237  */
1238 alpm_list_t* alpm_pkg_compute_requiredby (alpm_pkg_t* pkg);
1239 
1240 /** Computes the list of packages optionally requiring a given package.
1241  * The return value of this function is a newly allocated
1242  * list of package names (char*), it should be freed by the caller.
1243  * @param pkg a package
1244  * @return the list of packages optionally requiring pkg
1245  */
1246 alpm_list_t* alpm_pkg_compute_optionalfor (alpm_pkg_t* pkg);
1247 
1248 /** Test if a package should be ignored.
1249  * Checks if the package is ignored via IgnorePkg, or if the package is
1250  * in a group ignored via IgnoreGroup.
1251  * @param handle the context handle
1252  * @param pkg the package to test
1253  * @return 1 if the package should be ignored, 0 otherwise
1254  */
1255 int alpm_pkg_should_ignore (alpm_handle_t* handle, alpm_pkg_t* pkg);
1256 
1257 /** @name Package Property Accessors
1258  * Any pointer returned by these functions points to internal structures
1259  * allocated by libalpm. They should not be freed nor modified in any
1260  * way.
1261  * @{
1262  */
1263 
1264 /** Gets the name of the file from which the package was loaded.
1265  * @param pkg a pointer to package
1266  * @return a reference to an internal string
1267  */
1268 const(char)* alpm_pkg_get_filename (alpm_pkg_t* pkg);
1269 
1270 /** Returns the package base name.
1271  * @param pkg a pointer to package
1272  * @return a reference to an internal string
1273  */
1274 const(char)* alpm_pkg_get_base (alpm_pkg_t* pkg);
1275 
1276 /** Returns the package name.
1277  * @param pkg a pointer to package
1278  * @return a reference to an internal string
1279  */
1280 const(char)* alpm_pkg_get_name (alpm_pkg_t* pkg);
1281 
1282 /** Returns the package version as a string.
1283  * This includes all available epoch, version, and pkgrel components. Use
1284  * alpm_pkg_vercmp() to compare version strings if necessary.
1285  * @param pkg a pointer to package
1286  * @return a reference to an internal string
1287  */
1288 const(char)* alpm_pkg_get_version (alpm_pkg_t* pkg);
1289 
1290 /** Returns the origin of the package.
1291  * @return an alpm_pkgfrom_t constant, -1 on error
1292  */
1293 alpm_pkgfrom_t alpm_pkg_get_origin (alpm_pkg_t* pkg);
1294 
1295 /** Returns the package description.
1296  * @param pkg a pointer to package
1297  * @return a reference to an internal string
1298  */
1299 const(char)* alpm_pkg_get_desc (alpm_pkg_t* pkg);
1300 
1301 /** Returns the package URL.
1302  * @param pkg a pointer to package
1303  * @return a reference to an internal string
1304  */
1305 const(char)* alpm_pkg_get_url (alpm_pkg_t* pkg);
1306 
1307 /** Returns the build timestamp of the package.
1308  * @param pkg a pointer to package
1309  * @return the timestamp of the build time
1310  */
1311 alpm_time_t alpm_pkg_get_builddate (alpm_pkg_t* pkg);
1312 
1313 /** Returns the install timestamp of the package.
1314  * @param pkg a pointer to package
1315  * @return the timestamp of the install time
1316  */
1317 alpm_time_t alpm_pkg_get_installdate (alpm_pkg_t* pkg);
1318 
1319 /** Returns the packager's name.
1320  * @param pkg a pointer to package
1321  * @return a reference to an internal string
1322  */
1323 const(char)* alpm_pkg_get_packager (alpm_pkg_t* pkg);
1324 
1325 /** Returns the package's MD5 checksum as a string.
1326  * The returned string is a sequence of 32 lowercase hexadecimal digits.
1327  * @param pkg a pointer to package
1328  * @return a reference to an internal string
1329  */
1330 const(char)* alpm_pkg_get_md5sum (alpm_pkg_t* pkg);
1331 
1332 /** Returns the package's SHA256 checksum as a string.
1333  * The returned string is a sequence of 64 lowercase hexadecimal digits.
1334  * @param pkg a pointer to package
1335  * @return a reference to an internal string
1336  */
1337 const(char)* alpm_pkg_get_sha256sum (alpm_pkg_t* pkg);
1338 
1339 /** Returns the architecture for which the package was built.
1340  * @param pkg a pointer to package
1341  * @return a reference to an internal string
1342  */
1343 const(char)* alpm_pkg_get_arch (alpm_pkg_t* pkg);
1344 
1345 /** Returns the size of the package. This is only available for sync database
1346  * packages and package files, not those loaded from the local database.
1347  * @param pkg a pointer to package
1348  * @return the size of the package in bytes.
1349  */
1350 off_t alpm_pkg_get_size (alpm_pkg_t* pkg);
1351 
1352 /** Returns the installed size of the package.
1353  * @param pkg a pointer to package
1354  * @return the total size of files installed by the package.
1355  */
1356 off_t alpm_pkg_get_isize (alpm_pkg_t* pkg);
1357 
1358 /** Returns the package installation reason.
1359  * @param pkg a pointer to package
1360  * @return an enum member giving the install reason.
1361  */
1362 alpm_pkgreason_t alpm_pkg_get_reason (alpm_pkg_t* pkg);
1363 
1364 /** Returns the list of package licenses.
1365  * @param pkg a pointer to package
1366  * @return a pointer to an internal list of strings.
1367  */
1368 alpm_list_t* alpm_pkg_get_licenses (alpm_pkg_t* pkg);
1369 
1370 /** Returns the list of package groups.
1371  * @param pkg a pointer to package
1372  * @return a pointer to an internal list of strings.
1373  */
1374 alpm_list_t* alpm_pkg_get_groups (alpm_pkg_t* pkg);
1375 
1376 /** Returns the list of package dependencies as alpm_depend_t.
1377  * @param pkg a pointer to package
1378  * @return a reference to an internal list of alpm_depend_t structures.
1379  */
1380 alpm_list_t* alpm_pkg_get_depends (alpm_pkg_t* pkg);
1381 
1382 /** Returns the list of package optional dependencies.
1383  * @param pkg a pointer to package
1384  * @return a reference to an internal list of alpm_depend_t structures.
1385  */
1386 alpm_list_t* alpm_pkg_get_optdepends (alpm_pkg_t* pkg);
1387 
1388 /** Returns a list of package check dependencies
1389  * @param pkg a pointer to package
1390  * @return a reference to an internal list of alpm_depend_t structures.
1391  */
1392 alpm_list_t* alpm_pkg_get_checkdepends (alpm_pkg_t* pkg);
1393 
1394 /** Returns a list of package make dependencies
1395  * @param pkg a pointer to package
1396  * @return a reference to an internal list of alpm_depend_t structures.
1397  */
1398 alpm_list_t* alpm_pkg_get_makedepends (alpm_pkg_t* pkg);
1399 
1400 /** Returns the list of packages conflicting with pkg.
1401  * @param pkg a pointer to package
1402  * @return a reference to an internal list of alpm_depend_t structures.
1403  */
1404 alpm_list_t* alpm_pkg_get_conflicts (alpm_pkg_t* pkg);
1405 
1406 /** Returns the list of packages provided by pkg.
1407  * @param pkg a pointer to package
1408  * @return a reference to an internal list of alpm_depend_t structures.
1409  */
1410 alpm_list_t* alpm_pkg_get_provides (alpm_pkg_t* pkg);
1411 
1412 /** Returns the list of packages to be replaced by pkg.
1413  * @param pkg a pointer to package
1414  * @return a reference to an internal list of alpm_depend_t structures.
1415  */
1416 alpm_list_t* alpm_pkg_get_replaces (alpm_pkg_t* pkg);
1417 
1418 /** Returns the list of files installed by pkg.
1419  * The filenames are relative to the install root,
1420  * and do not include leading slashes.
1421  * @param pkg a pointer to package
1422  * @return a pointer to a filelist object containing a count and an array of
1423  * package file objects
1424  */
1425 alpm_filelist_t* alpm_pkg_get_files (alpm_pkg_t* pkg);
1426 
1427 /** Returns the list of files backed up when installing pkg.
1428  * @param pkg a pointer to package
1429  * @return a reference to a list of alpm_backup_t objects
1430  */
1431 alpm_list_t* alpm_pkg_get_backup (alpm_pkg_t* pkg);
1432 
1433 /** Returns the database containing pkg.
1434  * Returns a pointer to the alpm_db_t structure the package is
1435  * originating from, or NULL if the package was loaded from a file.
1436  * @param pkg a pointer to package
1437  * @return a pointer to the DB containing pkg, or NULL.
1438  */
1439 alpm_db_t* alpm_pkg_get_db (alpm_pkg_t* pkg);
1440 
1441 /** Returns the base64 encoded package signature.
1442  * @param pkg a pointer to package
1443  * @return a reference to an internal string
1444  */
1445 const(char)* alpm_pkg_get_base64_sig (alpm_pkg_t* pkg);
1446 
1447 /** Returns the method used to validate a package during install.
1448  * @param pkg a pointer to package
1449  * @return an enum member giving the validation method
1450  */
1451 int alpm_pkg_get_validation (alpm_pkg_t* pkg);
1452 
1453 /* End of alpm_pkg_t accessors */
1454 /* @} */
1455 
1456 /** Open a package changelog for reading.
1457  * Similar to fopen in functionality, except that the returned 'file
1458  * stream' could really be from an archive as well as from the database.
1459  * @param pkg the package to read the changelog of (either file or db)
1460  * @return a 'file stream' to the package changelog
1461  */
1462 void* alpm_pkg_changelog_open (alpm_pkg_t* pkg);
1463 
1464 /** Read data from an open changelog 'file stream'.
1465  * Similar to fread in functionality, this function takes a buffer and
1466  * amount of data to read. If an error occurs pm_errno will be set.
1467  * @param ptr a buffer to fill with raw changelog data
1468  * @param size the size of the buffer
1469  * @param pkg the package that the changelog is being read from
1470  * @param fp a 'file stream' to the package changelog
1471  * @return the number of characters read, or 0 if there is no more data or an
1472  * error occurred.
1473  */
1474 size_t alpm_pkg_changelog_read (
1475     void* ptr,
1476     size_t size,
1477     const(alpm_pkg_t)* pkg,
1478     void* fp);
1479 
1480 int alpm_pkg_changelog_close (const(alpm_pkg_t)* pkg, void* fp);
1481 
1482 /** Open a package mtree file for reading.
1483  * @param pkg the local package to read the changelog of
1484  * @return a archive structure for the package mtree file
1485  */
1486 archive* alpm_pkg_mtree_open (alpm_pkg_t* pkg);
1487 
1488 /** Read next entry from a package mtree file.
1489  * @param pkg the package that the mtree file is being read from
1490  * @param archive the archive structure reading from the mtree file
1491  * @param entry an archive_entry to store the entry header information
1492  * @return 0 if end of archive is reached, non-zero otherwise.
1493  */
1494 int alpm_pkg_mtree_next (
1495     const(alpm_pkg_t)* pkg,
1496     archive* archive,
1497     archive_entry** entry);
1498 
1499 int alpm_pkg_mtree_close (const(alpm_pkg_t)* pkg, archive* archive);
1500 
1501 /** Returns whether the package has an install scriptlet.
1502  * @return 0 if FALSE, TRUE otherwise
1503  */
1504 int alpm_pkg_has_scriptlet (alpm_pkg_t* pkg);
1505 
1506 /** Returns the size of download.
1507  * Returns the size of the files that will be downloaded to install a
1508  * package.
1509  * @param newpkg the new package to upgrade to
1510  * @return the size of the download
1511  */
1512 off_t alpm_pkg_download_size (alpm_pkg_t* newpkg);
1513 
1514 /** Set install reason for a package in the local database.
1515  * The provided package object must be from the local database or this method
1516  * will fail. The write to the local database is performed immediately.
1517  * @param pkg the package to update
1518  * @param reason the new install reason
1519  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1520  */
1521 int alpm_pkg_set_reason (alpm_pkg_t* pkg, alpm_pkgreason_t reason);
1522 
1523 /* End of alpm_pkg */
1524 /** @} */
1525 
1526 /*
1527  * Filelists
1528  */
1529 
1530 /** Determines whether a package filelist contains a given path.
1531  * The provided path should be relative to the install root with no leading
1532  * slashes, e.g. "etc/localtime". When searching for directories, the path must
1533  * have a trailing slash.
1534  * @param filelist a pointer to a package filelist
1535  * @param path the path to search for in the package
1536  * @return a pointer to the matching file or NULL if not found
1537  */
1538 alpm_file_t* alpm_filelist_contains (alpm_filelist_t* filelist, const(char)* path);
1539 
1540 /*
1541  * Signatures
1542  */
1543 
1544 int alpm_pkg_check_pgp_signature (alpm_pkg_t* pkg, alpm_siglist_t* siglist);
1545 
1546 int alpm_db_check_pgp_signature (alpm_db_t* db, alpm_siglist_t* siglist);
1547 
1548 int alpm_siglist_cleanup (alpm_siglist_t* siglist);
1549 
1550 int alpm_decode_signature (
1551     const(char)* base64_data,
1552     ubyte** data,
1553     size_t* data_len);
1554 
1555 int alpm_extract_keyid (
1556     alpm_handle_t* handle,
1557     const(char)* identifier,
1558     const(ubyte)* sig,
1559     const size_t len,
1560     alpm_list_t** keys);
1561 
1562 /*
1563  * Groups
1564  */
1565 
1566 alpm_list_t* alpm_find_group_pkgs (alpm_list_t* dbs, const(char)* name);
1567 
1568 /*
1569  * Sync
1570  */
1571 
1572 alpm_pkg_t* alpm_sync_get_new_version (alpm_pkg_t* pkg, alpm_list_t* dbs_sync);
1573 
1574 /** @addtogroup alpm_api_trans Transaction Functions
1575  * Functions to manipulate libalpm transactions
1576  * @{
1577  */
1578 
1579 /** Transaction flags */
1580 enum _alpm_transflag_t
1581 {
1582     /** Ignore dependency checks. */
1583     ALPM_TRANS_FLAG_NODEPS = 1,
1584     /* (1 << 1) flag can go here */
1585     /** Delete files even if they are tagged as backup. */
1586     ALPM_TRANS_FLAG_NOSAVE = 1 << 2,
1587     /** Ignore version numbers when checking dependencies. */
1588     ALPM_TRANS_FLAG_NODEPVERSION = 1 << 3,
1589     /** Remove also any packages depending on a package being removed. */
1590     ALPM_TRANS_FLAG_CASCADE = 1 << 4,
1591     /** Remove packages and their unneeded deps (not explicitly installed). */
1592     ALPM_TRANS_FLAG_RECURSE = 1 << 5,
1593     /** Modify database but do not commit changes to the filesystem. */
1594     ALPM_TRANS_FLAG_DBONLY = 1 << 6,
1595     /* (1 << 7) flag can go here */
1596     /** Use ALPM_PKG_REASON_DEPEND when installing packages. */
1597     ALPM_TRANS_FLAG_ALLDEPS = 1 << 8,
1598     /** Only download packages and do not actually install. */
1599     ALPM_TRANS_FLAG_DOWNLOADONLY = 1 << 9,
1600     /** Do not execute install scriptlets after installing. */
1601     ALPM_TRANS_FLAG_NOSCRIPTLET = 1 << 10,
1602     /** Ignore dependency conflicts. */
1603     ALPM_TRANS_FLAG_NOCONFLICTS = 1 << 11,
1604     /* (1 << 12) flag can go here */
1605     /** Do not install a package if it is already installed and up to date. */
1606     ALPM_TRANS_FLAG_NEEDED = 1 << 13,
1607     /** Use ALPM_PKG_REASON_EXPLICIT when installing packages. */
1608     ALPM_TRANS_FLAG_ALLEXPLICIT = 1 << 14,
1609     /** Do not remove a package if it is needed by another one. */
1610     ALPM_TRANS_FLAG_UNNEEDED = 1 << 15,
1611     /** Remove also explicitly installed unneeded deps (use with ALPM_TRANS_FLAG_RECURSE). */
1612     ALPM_TRANS_FLAG_RECURSEALL = 1 << 16,
1613     /** Do not lock the database during the operation. */
1614     ALPM_TRANS_FLAG_NOLOCK = 1 << 17
1615 }
1616 
1617 alias alpm_transflag_t = _alpm_transflag_t;
1618 
1619 /** Returns the bitfield of flags for the current transaction.
1620  * @param handle the context handle
1621  * @return the bitfield of transaction flags
1622  */
1623 int alpm_trans_get_flags (alpm_handle_t* handle);
1624 
1625 /** Returns a list of packages added by the transaction.
1626  * @param handle the context handle
1627  * @return a list of alpm_pkg_t structures
1628  */
1629 alpm_list_t* alpm_trans_get_add (alpm_handle_t* handle);
1630 
1631 /** Returns the list of packages removed by the transaction.
1632  * @param handle the context handle
1633  * @return a list of alpm_pkg_t structures
1634  */
1635 alpm_list_t* alpm_trans_get_remove (alpm_handle_t* handle);
1636 
1637 /** Initialize the transaction.
1638  * @param handle the context handle
1639  * @param flags flags of the transaction (like nodeps, etc; see alpm_transflag_t)
1640  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1641  */
1642 int alpm_trans_init (alpm_handle_t* handle, int flags);
1643 
1644 /** Prepare a transaction.
1645  * @param handle the context handle
1646  * @param data the address of an alpm_list where a list
1647  * of alpm_depmissing_t objects is dumped (conflicting packages)
1648  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1649  */
1650 int alpm_trans_prepare (alpm_handle_t* handle, alpm_list_t** data);
1651 
1652 /** Commit a transaction.
1653  * @param handle the context handle
1654  * @param data the address of an alpm_list where detailed description
1655  * of an error can be dumped (i.e. list of conflicting files)
1656  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1657  */
1658 int alpm_trans_commit (alpm_handle_t* handle, alpm_list_t** data);
1659 
1660 /** Interrupt a transaction.
1661  * @param handle the context handle
1662  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1663  */
1664 int alpm_trans_interrupt (alpm_handle_t* handle);
1665 
1666 /** Release a transaction.
1667  * @param handle the context handle
1668  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1669  */
1670 int alpm_trans_release (alpm_handle_t* handle);
1671 /** @} */
1672 
1673 /** @name Common Transactions */
1674 /** @{ */
1675 
1676 /** Search for packages to upgrade and add them to the transaction.
1677  * @param handle the context handle
1678  * @param enable_downgrade allow downgrading of packages if the remote version is lower
1679  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1680  */
1681 int alpm_sync_sysupgrade (alpm_handle_t* handle, int enable_downgrade);
1682 
1683 /** Add a package to the transaction.
1684  * If the package was loaded by alpm_pkg_load(), it will be freed upon
1685  * alpm_trans_release() invocation.
1686  * @param handle the context handle
1687  * @param pkg the package to add
1688  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1689  */
1690 int alpm_add_pkg (alpm_handle_t* handle, alpm_pkg_t* pkg);
1691 
1692 /** Add a package removal action to the transaction.
1693  * @param handle the context handle
1694  * @param pkg the package to uninstall
1695  * @return 0 on success, -1 on error (pm_errno is set accordingly)
1696  */
1697 int alpm_remove_pkg (alpm_handle_t* handle, alpm_pkg_t* pkg);
1698 
1699 /** @} */
1700 
1701 /** @addtogroup alpm_api_depends Dependency Functions
1702  * Functions dealing with libalpm representation of dependency
1703  * information.
1704  * @{
1705  */
1706 
1707 alpm_list_t* alpm_checkdeps (
1708     alpm_handle_t* handle,
1709     alpm_list_t* pkglist,
1710     alpm_list_t* remove,
1711     alpm_list_t* upgrade,
1712     int reversedeps);
1713 alpm_pkg_t* alpm_find_satisfier (alpm_list_t* pkgs, const(char)* depstring);
1714 alpm_pkg_t* alpm_find_dbs_satisfier (
1715     alpm_handle_t* handle,
1716     alpm_list_t* dbs,
1717     const(char)* depstring);
1718 
1719 alpm_list_t* alpm_checkconflicts (alpm_handle_t* handle, alpm_list_t* pkglist);
1720 
1721 /** Returns a newly allocated string representing the dependency information.
1722  * @param dep a dependency info structure
1723  * @return a formatted string, e.g. "glibc>=2.12"
1724  */
1725 char* alpm_dep_compute_string (const(alpm_depend_t)* dep);
1726 
1727 /** Return a newly allocated dependency information parsed from a string
1728  * @param depstring a formatted string, e.g. "glibc=2.12"
1729  * @return a dependency info structure
1730  */
1731 alpm_depend_t* alpm_dep_from_string (const(char)* depstring);
1732 
1733 /** Free a dependency info structure
1734  * @param dep struct to free
1735  */
1736 void alpm_dep_free (alpm_depend_t* dep);
1737 
1738 /** @} */
1739 
1740 /** @} */
1741 
1742 /*
1743  * Helpers
1744  */
1745 
1746 /* checksums */
1747 char* alpm_compute_md5sum (const(char)* filename);
1748 char* alpm_compute_sha256sum (const(char)* filename);
1749 
1750 alpm_handle_t* alpm_initialize (
1751     const(char)* root,
1752     const(char)* dbpath,
1753     alpm_errno_t* err);
1754 int alpm_release (alpm_handle_t* handle);
1755 int alpm_unlock (alpm_handle_t* handle);
1756 
1757 enum alpm_caps
1758 {
1759     ALPM_CAPABILITY_NLS = 1 << 0,
1760     ALPM_CAPABILITY_DOWNLOADER = 1 << 1,
1761     ALPM_CAPABILITY_SIGNATURES = 1 << 2
1762 }
1763 
1764 const(char)* alpm_version ();
1765 /* Return a bitfield of capabilities using values from 'enum alpm_caps' */
1766 int alpm_capabilities ();
1767 
1768 void alpm_fileconflict_free (alpm_fileconflict_t* conflict);
1769 void alpm_depmissing_free (alpm_depmissing_t* miss);
1770 void alpm_conflict_free (alpm_conflict_t* conflict);
1771 
1772 /* End of alpm_api */
1773 /** @} */
1774 
1775 /* ALPM_H */