Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/alpm.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/alpm.h')
-rw-r--r--lib/libalpm/alpm.h203
1 files changed, 99 insertions, 104 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 5af843c4..845bd478 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -74,6 +74,7 @@ typedef enum _pgp_verify_t {
* Structures
*/
+typedef struct __pmhandle_t pmhandle_t;
typedef struct __pmdb_t pmdb_t;
typedef struct __pmpkg_t pmpkg_t;
typedef struct __pmdelta_t pmdelta_t;
@@ -85,14 +86,6 @@ typedef struct __pmconflict_t pmconflict_t;
typedef struct __pmfileconflict_t pmfileconflict_t;
/*
- * Library
- */
-
-int alpm_initialize(void);
-int alpm_release(void);
-const char *alpm_version(void);
-
-/*
* Logging facilities
*/
@@ -107,7 +100,7 @@ typedef enum _pmloglevel_t {
} pmloglevel_t;
typedef void (*alpm_cb_log)(pmloglevel_t, const char *, va_list);
-int alpm_logaction(const char *fmt, ...);
+int alpm_logaction(pmhandle_t *handle, const char *fmt, ...);
/*
* Downloading
@@ -134,10 +127,11 @@ typedef int (*alpm_cb_fetch)(const char *url, const char *localpath,
int force);
/** Fetch a remote pkg.
+ * @param handle the context handle
* @param url URL of the package to download
* @return the downloaded filepath on success, NULL on error
*/
-char *alpm_fetch_pkgurl(const char *url);
+char *alpm_fetch_pkgurl(pmhandle_t *handle, const char *url);
/** @addtogroup alpm_api_options Options
* Libalpm option getters and setters
@@ -145,77 +139,67 @@ char *alpm_fetch_pkgurl(const char *url);
*/
/** Returns the callback used for logging. */
-alpm_cb_log alpm_option_get_logcb(void);
+alpm_cb_log alpm_option_get_logcb(pmhandle_t *handle);
/** Sets the callback used for logging. */
-int alpm_option_set_logcb(alpm_cb_log cb);
+int alpm_option_set_logcb(pmhandle_t *handle, alpm_cb_log cb);
/** Returns the callback used to report download progress. */
-alpm_cb_download alpm_option_get_dlcb(void);
+alpm_cb_download alpm_option_get_dlcb(pmhandle_t *handle);
/** Sets the callback used to report download progress. */
-int alpm_option_set_dlcb(alpm_cb_download cb);
+int alpm_option_set_dlcb(pmhandle_t *handle, alpm_cb_download cb);
/** Returns the downloading callback. */
-alpm_cb_fetch alpm_option_get_fetchcb(void);
+alpm_cb_fetch alpm_option_get_fetchcb(pmhandle_t *handle);
/** Sets the downloading callback. */
-int alpm_option_set_fetchcb(alpm_cb_fetch cb);
+int alpm_option_set_fetchcb(pmhandle_t *handle, alpm_cb_fetch cb);
/** Returns the callback used to report total download size. */
-alpm_cb_totaldl alpm_option_get_totaldlcb(void);
+alpm_cb_totaldl alpm_option_get_totaldlcb(pmhandle_t *handle);
/** Sets the callback used to report total download size. */
-int alpm_option_set_totaldlcb(alpm_cb_totaldl cb);
+int alpm_option_set_totaldlcb(pmhandle_t *handle, alpm_cb_totaldl cb);
+
+/** Returns the root of the destination filesystem. Read-only. */
+const char *alpm_option_get_root(pmhandle_t *handle);
-/** Returns the root of the destination filesystem. */
-const char *alpm_option_get_root(void);
-/** Sets the root of the destination filesystem. */
-int alpm_option_set_root(const char *root);
+/** Returns the path to the database directory. Read-only. */
+const char *alpm_option_get_dbpath(pmhandle_t *handle);
-/** Returns the path to the database directory. */
-const char *alpm_option_get_dbpath(void);
-/** Sets the path to the database directory. */
-int alpm_option_set_dbpath(const char *dbpath);
+/** Get the name of the database lock file. Read-only. */
+const char *alpm_option_get_lockfile(pmhandle_t *handle);
/** @name Accessors to the list of package cache directories.
* @{
*/
-alpm_list_t *alpm_option_get_cachedirs(void);
-int alpm_option_set_cachedirs(alpm_list_t *cachedirs);
-int alpm_option_add_cachedir(const char *cachedir);
-int alpm_option_remove_cachedir(const char *cachedir);
+alpm_list_t *alpm_option_get_cachedirs(pmhandle_t *handle);
+int alpm_option_set_cachedirs(pmhandle_t *handle, alpm_list_t *cachedirs);
+int alpm_option_add_cachedir(pmhandle_t *handle, const char *cachedir);
+int alpm_option_remove_cachedir(pmhandle_t *handle, const char *cachedir);
/** @} */
/** Returns the logfile name. */
-const char *alpm_option_get_logfile(void);
+const char *alpm_option_get_logfile(pmhandle_t *handle);
/** Sets the logfile name. */
-int alpm_option_set_logfile(const char *logfile);
-
-/** Get the name of the database lock file.
- *
- * This properly is read-only, and determined from
- * the database path.
- *
- * @sa alpm_option_set_dbpath(const char*)
- */
-const char *alpm_option_get_lockfile(void);
+int alpm_option_set_logfile(pmhandle_t *handle, const char *logfile);
/** Returns the signature directory path. */
-const char *alpm_option_get_signaturedir(void);
+const char *alpm_option_get_signaturedir(pmhandle_t *handle);
/** Sets the signature directory path. */
-int alpm_option_set_signaturedir(const char *signaturedir);
+int alpm_option_set_signaturedir(pmhandle_t *handle, const char *signaturedir);
/** Returns whether to use syslog (0 is FALSE, TRUE otherwise). */
-int alpm_option_get_usesyslog(void);
+int alpm_option_get_usesyslog(pmhandle_t *handle);
/** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */
-int alpm_option_set_usesyslog(int usesyslog);
+int alpm_option_set_usesyslog(pmhandle_t *handle, int usesyslog);
/** @name Accessors to the list of no-upgrade files.
* These functions modify the list of files which should
* not be updated by package installation.
* @{
*/
-alpm_list_t *alpm_option_get_noupgrades(void);
-int alpm_option_add_noupgrade(const char *pkg);
-int alpm_option_set_noupgrades(alpm_list_t *noupgrade);
-int alpm_option_remove_noupgrade(const char *pkg);
+alpm_list_t *alpm_option_get_noupgrades(pmhandle_t *handle);
+int alpm_option_add_noupgrade(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_noupgrades(pmhandle_t *handle, alpm_list_t *noupgrade);
+int alpm_option_remove_noupgrade(pmhandle_t *handle, const char *pkg);
/** @} */
/** @name Accessors to the list of no-extract files.
@@ -224,10 +208,10 @@ int alpm_option_remove_noupgrade(const char *pkg);
* not be upgraded by a sysupgrade operation.
* @{
*/
-alpm_list_t *alpm_option_get_noextracts(void);
-int alpm_option_add_noextract(const char *pkg);
-int alpm_option_set_noextracts(alpm_list_t *noextract);
-int alpm_option_remove_noextract(const char *pkg);
+alpm_list_t *alpm_option_get_noextracts(pmhandle_t *handle);
+int alpm_option_add_noextract(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_noextracts(pmhandle_t *handle, alpm_list_t *noextract);
+int alpm_option_remove_noextract(pmhandle_t *handle, const char *pkg);
/** @} */
/** @name Accessors to the list of ignored packages.
@@ -235,10 +219,10 @@ int alpm_option_remove_noextract(const char *pkg);
* should be ignored by a sysupgrade.
* @{
*/
-alpm_list_t *alpm_option_get_ignorepkgs(void);
-int alpm_option_add_ignorepkg(const char *pkg);
-int alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs);
-int alpm_option_remove_ignorepkg(const char *pkg);
+alpm_list_t *alpm_option_get_ignorepkgs(pmhandle_t *handle);
+int alpm_option_add_ignorepkg(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_ignorepkgs(pmhandle_t *handle, alpm_list_t *ignorepkgs);
+int alpm_option_remove_ignorepkg(pmhandle_t *handle, const char *pkg);
/** @} */
/** @name Accessors to the list of ignored groups.
@@ -246,25 +230,25 @@ int alpm_option_remove_ignorepkg(const char *pkg);
* should be ignored by a sysupgrade.
* @{
*/
-alpm_list_t *alpm_option_get_ignoregrps(void);
-int alpm_option_add_ignoregrp(const char *grp);
-int alpm_option_set_ignoregrps(alpm_list_t *ignoregrps);
-int alpm_option_remove_ignoregrp(const char *grp);
+alpm_list_t *alpm_option_get_ignoregrps(pmhandle_t *handle);
+int alpm_option_add_ignoregrp(pmhandle_t *handle, const char *grp);
+int alpm_option_set_ignoregrps(pmhandle_t *handle, alpm_list_t *ignoregrps);
+int alpm_option_remove_ignoregrp(pmhandle_t *handle, const char *grp);
/** @} */
/** Returns the targeted architecture. */
-const char *alpm_option_get_arch(void);
+const char *alpm_option_get_arch(pmhandle_t *handle);
/** Sets the targeted architecture. */
-int alpm_option_set_arch(const char *arch);
+int alpm_option_set_arch(pmhandle_t *handle, const char *arch);
-int alpm_option_get_usedelta(void);
-int alpm_option_set_usedelta(int usedelta);
+int alpm_option_get_usedelta(pmhandle_t *handle);
+int alpm_option_set_usedelta(pmhandle_t *handle, int usedelta);
-int alpm_option_get_checkspace(void);
-int alpm_option_set_checkspace(int checkspace);
+int alpm_option_get_checkspace(pmhandle_t *handle);
+int alpm_option_set_checkspace(pmhandle_t *handle, int checkspace);
-pgp_verify_t alpm_option_get_default_sigverify(void);
-int alpm_option_set_default_sigverify(pgp_verify_t level);
+pgp_verify_t alpm_option_get_default_sigverify(pmhandle_t *handle);
+int alpm_option_set_default_sigverify(pmhandle_t *handle, pgp_verify_t level);
/** @} */
@@ -279,20 +263,22 @@ int alpm_option_set_default_sigverify(pgp_verify_t level);
* libalpm functions.
* @return a reference to the local database
*/
-pmdb_t *alpm_option_get_localdb(void);
+pmdb_t *alpm_option_get_localdb(pmhandle_t *handle);
/** Get the list of sync databases.
* Returns a list of pmdb_t structures, one for each registered
* sync database.
+ * @param handle the context handle
* @return a reference to an internal list of pmdb_t structures
*/
-alpm_list_t *alpm_option_get_syncdbs(void);
+alpm_list_t *alpm_option_get_syncdbs(pmhandle_t *handle);
/** Register a sync database of packages.
+ * @param handle the context handle
* @param treename the name of the sync repository
* @return a pmdb_t* on success (the value), NULL on error
*/
-pmdb_t *alpm_db_register_sync(const char *treename);
+pmdb_t *alpm_db_register_sync(pmhandle_t *handle, const char *treename);
/** Unregister a package database.
* @param db pointer to the package database to unregister
@@ -301,9 +287,10 @@ pmdb_t *alpm_db_register_sync(const char *treename);
int alpm_db_unregister(pmdb_t *db);
/** Unregister all package databases.
+ * @param handle the context handle
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_db_unregister_all(void);
+int alpm_db_unregister_all(pmhandle_t *handle);
/** Get the name of a package database.
* @param db pointer to the package database
@@ -311,12 +298,6 @@ int alpm_db_unregister_all(void);
*/
const char *alpm_db_get_name(const pmdb_t *db);
-/** Get a download URL for the package database.
- * @param db pointer to the package database
- * @return a fully-specified download URL, NULL on error
- */
-const char *alpm_db_get_url(const pmdb_t *db);
-
/** @name Accessors to the list of servers for a database.
* @{
*/
@@ -381,6 +362,7 @@ int alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason);
* metadata is found. If it is true, the entire archive is read, which
* serves as a verification of integrity and the filelist can be created.
* The allocated structure should be freed using alpm_pkg_free().
+ * @param handle the context handle
* @param filename location of the package tarball
* @param full whether to stop the load after metadata is read or continue
* through the full archive
@@ -389,8 +371,8 @@ int alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason);
* @param pkg address of the package pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_pkg_load(const char *filename, int full, pgp_verify_t check_sig,
- pmpkg_t **pkg);
+int alpm_pkg_load(pmhandle_t *handle, const char *filename, int full,
+ pgp_verify_t check_sig, pmpkg_t **pkg);
/** Free a package.
* @param pkg package pointer to free
@@ -809,78 +791,89 @@ typedef void (*alpm_trans_cb_conv)(pmtransconv_t, void *, void *,
typedef void (*alpm_trans_cb_progress)(pmtransprog_t, const char *, int, size_t, size_t);
/** Returns the bitfield of flags for the current transaction.
- * @sa _pmtransflag_t
+ * @param handle the context handle
+ * @return the bitfield of transaction flags
*/
-int alpm_trans_get_flags(void);
+pmtransflag_t alpm_trans_get_flags(pmhandle_t *handle);
/** Returns a list of packages added by the transaction.
+ * @param handle the context handle
* @return a list of pmpkg_t structures
*/
-alpm_list_t * alpm_trans_get_add(void);
+alpm_list_t * alpm_trans_get_add(pmhandle_t *handle);
/** Returns the list of packages removed by the transaction.
+ * @param handle the context handle
* @return a list of pmpkg_t structures
*/
-alpm_list_t * alpm_trans_get_remove(void);
+alpm_list_t * alpm_trans_get_remove(pmhandle_t *handle);
/** Initialize the transaction.
+ * @param handle the context handle
* @param flags flags of the transaction (like nodeps, etc)
* @param event event callback function pointer
* @param conv question callback function pointer
* @param progress progress callback function pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_init(pmtransflag_t flags,
+int alpm_trans_init(pmhandle_t *handle, pmtransflag_t flags,
alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress cb_progress);
/** Prepare a transaction.
+ * @param handle the context handle
* @param data the address of an alpm_list where a list
* of pmdepmissing_t objects is dumped (conflicting packages)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_prepare(alpm_list_t **data);
+int alpm_trans_prepare(pmhandle_t *handle, alpm_list_t **data);
/** Commit a transaction.
+ * @param handle the context handle
* @param data the address of an alpm_list where detailed description
* of an error can be dumped (ie. list of conflicting files)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_commit(alpm_list_t **data);
+int alpm_trans_commit(pmhandle_t *handle, alpm_list_t **data);
/** Interrupt a transaction.
+ * @param handle the context handle
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_interrupt(void);
+int alpm_trans_interrupt(pmhandle_t *handle);
/** Release a transaction.
+ * @param handle the context handle
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_release(void);
+int alpm_trans_release(pmhandle_t *handle);
/** @} */
/** @name Common Transactions */
/** @{ */
/** Search for packages to upgrade and add them to the transaction.
+ * @param handle the context handle
* @param enable_downgrade allow downgrading of packages if the remote version is lower
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_sync_sysupgrade(int enable_downgrade);
+int alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade);
/** Add a package to the transaction.
* If the package was loaded by alpm_pkg_load(), it will be freed upon
* alpm_trans_release() invocation.
+ * @param handle the context handle
* @param pkg the package to add
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_add_pkg(pmpkg_t *pkg);
+int alpm_add_pkg(pmhandle_t *handle, pmpkg_t *pkg);
/** Add a package removal action to the transaction.
+ * @param handle the context handle
* @param pkg the package to uninstall
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_remove_pkg(pmpkg_t *pkg);
+int alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg);
/** @} */
@@ -906,16 +899,17 @@ typedef enum _pmdepmod_t {
PM_DEP_MOD_LT
} pmdepmod_t;
-alpm_list_t *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
- alpm_list_t *remove, alpm_list_t *upgrade);
+alpm_list_t *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
+ alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps);
pmpkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring);
-pmpkg_t *alpm_find_dbs_satisfier(alpm_list_t *dbs, const char *depstring);
+pmpkg_t *alpm_find_dbs_satisfier(pmhandle_t *handle,
+ alpm_list_t *dbs, const char *depstring);
const char *alpm_miss_get_target(const pmdepmissing_t *miss);
pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss);
-alpm_list_t *alpm_checkconflicts(alpm_list_t *pkglist);
+alpm_list_t *alpm_checkconflicts(pmhandle_t *handle, alpm_list_t *pkglist);
const char *alpm_conflict_get_package1(pmconflict_t *conflict);
const char *alpm_conflict_get_package2(pmconflict_t *conflict);
@@ -1032,7 +1026,6 @@ enum _pmerrno_t {
PM_ERR_FILE_CONFLICTS,
/* Misc */
PM_ERR_RETRIEVE,
- PM_ERR_WRITE,
PM_ERR_INVALID_REGEX,
/* External library errors */
PM_ERR_LIBARCHIVE,
@@ -1041,18 +1034,20 @@ enum _pmerrno_t {
PM_ERR_GPGME
};
-/** The number of the last error that occurred. */
-extern enum _pmerrno_t pm_errno;
+/** Returns the current error code from the handle. */
+enum _pmerrno_t alpm_errno(pmhandle_t *handle);
/** Returns the string corresponding to an error number. */
-const char *alpm_strerror(int err);
-
-/** Returns the string corresponding to pm_errno. */
-const char *alpm_strerrorlast(void);
+const char *alpm_strerror(enum _pmerrno_t err);
/* End of alpm_api_errors */
/** @} */
+pmhandle_t *alpm_initialize(const char *root, const char *dbpath,
+ enum _pmerrno_t *err);
+int alpm_release(pmhandle_t *handle);
+const char *alpm_version(void);
+
/* End of alpm_api */
/** @} */