[pacman-dev] [PATCH 00/23] Docs Docs Docs 2: electric boogaloo
Here's a redo of my original docs patch and more. This time it's split in to many commits so it's hopefully easier to review/rebase. Every function, struct and param is now documented. Simply `man libalpm` to get the main page. Then `man libalpm-databases` to see the database section and so on for each section. Also while doing all this, I thought it would make sense to change some function names: I also think alpm_unlock() should be named alpm_db_unlock() and alpm_sync_get_new_version() should be named alpm_pkg_get_new_version() Then the functions could be moved into the db and packages groups repectivley. To be clear I have not actually changed any function names in this patch set. morganamilo (23): doc: remove stray doxygen comment doc: add doc header to alpm.h doc: document error doc: document handle doc: document signatures doc: document depends doc: document callbacks doc: document databases doc: document logging doc: document packages doc: document files and groups doc: document transactions doc: document misc doc: document alpm_list doc: document options doc: move alpm_api group to top of file doc: move top level items into groups doc: configure doxygen doc: update doxyfile doc: rename alpm_api group to alpm doc: add extra documentation to the man page doc: change group names to libalpm_* doc: remove old libalpm man file doc/Doxyfile.in | 83 +- doc/libalpm.3.asciidoc | 37 - doc/meson.build | 1 - lib/libalpm/alpm.h | 2429 +++++++++++++++++++++++++++------------ lib/libalpm/alpm_list.c | 251 ---- lib/libalpm/alpm_list.h | 293 ++++- lib/libalpm/trans.c | 2 - 7 files changed, 2048 insertions(+), 1048 deletions(-) delete mode 100644 doc/libalpm.3.asciidoc -- 2.29.2
--- lib/libalpm/trans.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index c7317c15..303d2fca 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -266,8 +266,6 @@ int SYMEXPORT alpm_trans_release(alpm_handle_t *handle) return 0; } -/** @} */ - void _alpm_trans_free(alpm_trans_t *trans) { if(trans == NULL) { -- 2.29.2
LGTM. Fixes the warning `trans.c:269: warning: unbalanced grouping commands`. On Mon, 7 Dec 2020, at 14:19, morganamilo wrote:
--- lib/libalpm/trans.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index c7317c15..303d2fca 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -266,8 +266,6 @@ int SYMEXPORT alpm_trans_release(alpm_handle_t *handle) return 0; }
-/** @} */ - void _alpm_trans_free(alpm_trans_t *trans) { if(trans == NULL) { -- 2.29.2
--- lib/libalpm/alpm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 50c4bb6b..48ba7fdc 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -20,6 +20,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/** + * @file alpm.h + * @author Pacman Development Team + * @date 7 Dec 2020 + * @brief Arch Linux Package Manager Library + */ + +/** @mainpage alpm + * + * libalpm is a package management library, primaraly used by pacman. + */ + #ifndef ALPM_H #define ALPM_H -- 2.29.2
Spelling of "primarily". On Mon, 7 Dec 2020, at 14:19, morganamilo wrote:
--- lib/libalpm/alpm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 50c4bb6b..48ba7fdc 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -20,6 +20,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/** + * @file alpm.h + * @author Pacman Development Team + * @date 7 Dec 2020 + * @brief Arch Linux Package Manager Library + */ + +/** @mainpage alpm + * + * libalpm is a package management library, primaraly used by pacman. + */ + #ifndef ALPM_H #define ALPM_H
-- 2.29.2
On 09/12/2020 19:29, Colin Woodbury wrote:
Spelling of "primarily".
On Mon, 7 Dec 2020, at 14:19, morganamilo wrote:
--- lib/libalpm/alpm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 50c4bb6b..48ba7fdc 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -20,6 +20,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/** + * @file alpm.h + * @author Pacman Development Team + * @date 7 Dec 2020 + * @brief Arch Linux Package Manager Library + */ + +/** @mainpage alpm + * + * libalpm is a package management library, primaraly used by pacman. + */ + #ifndef ALPM_H #define ALPM_H
-- 2.29.2
Funnily enough I did run a spell checker.. If it's okay with every one, I would rather just merge this as is and fix up the spelling. (mainly due to my laziness of amending all the commits). Once this is merged and everything is in place it's then easy to fix up the docs without any refactoring.
--- lib/libalpm/alpm.h | 122 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 109 insertions(+), 13 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 48ba7fdc..1c2422ca 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -51,102 +51,198 @@ extern "C" { #include <alpm_list.h> /* - * Arch Linux Package Management library + * Opaque Structures */ -/* - * Opaque Structures +/** The libalpm context handle. + * + * This struct represents an instance of libalpm. */ typedef struct __alpm_handle_t alpm_handle_t; + +/** A database. + * + * A database is a container that stores metadata about packages. + * + * A database can be located on the local filesystem or on a remote server. + * + * To use a database, it must first be registered via \link alpm_register_syncdb \endlink. + * If the database is already preasant in dbpath then it will be usable. Otherwise, + * the database needs to be downloaded using \link alpm_db_update \endlink. Even if the + * source of the database is the local filesystem. + * + * After this, the database can be used to query packages and groups. Any packages or groups + * from the database will continue to be owned by the database and do not need to be freed by + * the user. They will be freed when the database is unregistered. + * + * Databases are automatically unregistered when the \link alpm_handle_t \endlink is released. + */ typedef struct __alpm_db_t alpm_db_t; + + +/** A package + * + * A package can be loaded from disk via \link alpm_pkg_load \endlink or retrieved from a database. + * Packages from databases are automatically freed when the database is unregistered. Packages loaded + * from a file must be freed manually. + * + * Packages can then be queried for metadata or added to a \link alpm_trans_t transaction \endlink + * to be added or removed from the system. + */ typedef struct __alpm_pkg_t alpm_pkg_t; + +/** Transaction structure used internally by libalpm */ typedef struct __alpm_trans_t alpm_trans_t; -/** @addtogroup alpm_api_errors Error Codes + +/** @addtogroup alpm_api ALPM + * @brief The libalpm Public API + * @{ + */ + +/** @addtogroup alpm_errors Error Codes + * Error codes returned by libalpm. * @{ */ + +/** libalpm's error type */ typedef enum _alpm_errno_t { + /** No error */ ALPM_ERR_OK = 0, + /** Failed to allocate memory */ ALPM_ERR_MEMORY, + /** A system error occurred */ ALPM_ERR_SYSTEM, + /** Permmision denied */ ALPM_ERR_BADPERMS, + /** Should be a file */ ALPM_ERR_NOT_A_FILE, + /** Should be a directory */ ALPM_ERR_NOT_A_DIR, + /** Function was called with invalid arguments */ ALPM_ERR_WRONG_ARGS, + /** Insufficient disk space */ ALPM_ERR_DISK_SPACE, /* Interface */ + /** Handle should be null */ ALPM_ERR_HANDLE_NULL, + /** Handle should not be null */ ALPM_ERR_HANDLE_NOT_NULL, + /** Failed to acquire lock */ ALPM_ERR_HANDLE_LOCK, /* Databases */ + /** Failed to open database */ ALPM_ERR_DB_OPEN, + /** Failed to create database */ ALPM_ERR_DB_CREATE, + /** Database should not be null */ ALPM_ERR_DB_NULL, + /** Database should be null */ ALPM_ERR_DB_NOT_NULL, + /** The database could not be found */ ALPM_ERR_DB_NOT_FOUND, + /** Database is invalid */ ALPM_ERR_DB_INVALID, + /** Database has an invalid signature */ ALPM_ERR_DB_INVALID_SIG, + /** The localdb is in a newer/older format than libalpm expects */ ALPM_ERR_DB_VERSION, + /** Failed to write to the database */ ALPM_ERR_DB_WRITE, + /** Failed to remove entry from database */ ALPM_ERR_DB_REMOVE, /* Servers */ + /** Server URL is in an invalid format */ ALPM_ERR_SERVER_BAD_URL, + /** The database has no configured servers */ ALPM_ERR_SERVER_NONE, /* Transactions */ + /** A transaction is already initialized */ ALPM_ERR_TRANS_NOT_NULL, + /** A transaction has not been initialized */ ALPM_ERR_TRANS_NULL, + /** Duplicate target in transaction */ ALPM_ERR_TRANS_DUP_TARGET, + /** A transaction has not been initialized */ ALPM_ERR_TRANS_NOT_INITIALIZED, + /** Transaction has not been prepared */ ALPM_ERR_TRANS_NOT_PREPARED, + /** Transaction was aborted */ ALPM_ERR_TRANS_ABORT, + /** Failed to interrupt transaction */ ALPM_ERR_TRANS_TYPE, + /** Tried to commit transaction without locking the database */ ALPM_ERR_TRANS_NOT_LOCKED, + /** A hook failed to run */ ALPM_ERR_TRANS_HOOK_FAILED, /* Packages */ + /** Package not found */ ALPM_ERR_PKG_NOT_FOUND, + /** Package is in ignorepkg */ ALPM_ERR_PKG_IGNORED, + /** Package is invalid */ ALPM_ERR_PKG_INVALID, + /** Package has an invalid checksum */ ALPM_ERR_PKG_INVALID_CHECKSUM, + /** Package has an invalid signature */ ALPM_ERR_PKG_INVALID_SIG, + /** Package does not have a signature */ ALPM_ERR_PKG_MISSING_SIG, + /** Cannot open the package file */ ALPM_ERR_PKG_OPEN, + /** Failed to remove package files */ ALPM_ERR_PKG_CANT_REMOVE, + /** Package has an invalid name */ ALPM_ERR_PKG_INVALID_NAME, + /** Package has an invalid architecute */ ALPM_ERR_PKG_INVALID_ARCH, + /** Unused */ ALPM_ERR_PKG_REPO_NOT_FOUND, /* Signatures */ + /** Signatues are missing */ ALPM_ERR_SIG_MISSING, + /** Signatures are invalid */ ALPM_ERR_SIG_INVALID, /* Dependencies */ + /** Dependencies could not be satisfied */ ALPM_ERR_UNSATISFIED_DEPS, + /** Conflicting dependencies */ ALPM_ERR_CONFLICTING_DEPS, + /** Files conflict */ ALPM_ERR_FILE_CONFLICTS, /* Misc */ + /** Download failed */ ALPM_ERR_RETRIEVE, + /** Invalid Regex */ ALPM_ERR_INVALID_REGEX, /* External library errors */ + /** Error in libarchive */ ALPM_ERR_LIBARCHIVE, + /** Error in libcurl */ ALPM_ERR_LIBCURL, + /** Error in external download program */ ALPM_ERR_EXTERNAL_DOWNLOAD, + /** Error in gpgme */ ALPM_ERR_GPGME, - /* Missing compile-time features */ + /** Missing compile-time features */ ALPM_ERR_MISSING_CAPABILITY_SIGNATURES } alpm_errno_t; -/** Returns the current error code from the handle. */ +/** Returns the current error code from the handle. + * @param handle the context handle + * @return the current error code of the handle + */ alpm_errno_t alpm_errno(alpm_handle_t *handle); -/** Returns the string corresponding to an error number. */ +/** Returns the string corresponding to an error number. + * @param err the error code to get the string for + * @return the string relating to the given error code + */ const char *alpm_strerror(alpm_errno_t err); -/* End of alpm_api_errors */ +/* End of alpm_errors */ /** @} */ -/** @addtogroup alpm_api Public API - * The libalpm Public API - * @{ - */ - typedef int64_t alpm_time_t; /* -- 2.29.2
+/** A package
+ * + * A package can be loaded from disk via \link alpm_pkg_load \endlink or retrieved from a database. + * Packages from databases are automatically freed when the database is unregistered. Packages loaded + * from a file must be freed manually. + * + * Packages can then be queried for metadata or added to a \link alpm_trans_t transaction \endlink + * to be added or removed from the system. + */ typedef struct __alpm_pkg_t alpm_pkg_t; + +/** Transaction structure used internally by libalpm */ typedef struct __alpm_trans_t alpm_trans_t;
-/** @addtogroup alpm_api_errors Error Codes + +/** @addtogroup alpm_api ALPM + * @brief The libalpm Public API + * @{ + */ + +/** @addtogroup alpm_errors Error Codes + * Error codes returned by libalpm. * @{ */ + +/** libalpm's error type */ typedef enum _alpm_errno_t { + /** No error */ ALPM_ERR_OK = 0, + /** Failed to allocate memory */ ALPM_ERR_MEMORY, + /** A system error occurred */ ALPM_ERR_SYSTEM, + /** Permmision denied */ ALPM_ERR_BADPERMS, + /** Should be a file */ ALPM_ERR_NOT_A_FILE, + /** Should be a directory */ ALPM_ERR_NOT_A_DIR, + /** Function was called with invalid arguments */ ALPM_ERR_WRONG_ARGS, + /** Insufficient disk space */ ALPM_ERR_DISK_SPACE, /* Interface */ + /** Handle should be null */ ALPM_ERR_HANDLE_NULL, + /** Handle should not be null */ ALPM_ERR_HANDLE_NOT_NULL, + /** Failed to acquire lock */ ALPM_ERR_HANDLE_LOCK, /* Databases */ + /** Failed to open database */ ALPM_ERR_DB_OPEN, + /** Failed to create database */ ALPM_ERR_DB_CREATE, + /** Database should not be null */ ALPM_ERR_DB_NULL, + /** Database should be null */ ALPM_ERR_DB_NOT_NULL, + /** The database could not be found */ ALPM_ERR_DB_NOT_FOUND, + /** Database is invalid */ ALPM_ERR_DB_INVALID, + /** Database has an invalid signature */ ALPM_ERR_DB_INVALID_SIG, + /** The localdb is in a newer/older format than libalpm expects */ ALPM_ERR_DB_VERSION, + /** Failed to write to the database */ ALPM_ERR_DB_WRITE, + /** Failed to remove entry from database */ ALPM_ERR_DB_REMOVE, /* Servers */ + /** Server URL is in an invalid format */ ALPM_ERR_SERVER_BAD_URL, + /** The database has no configured servers */ ALPM_ERR_SERVER_NONE, /* Transactions */ + /** A transaction is already initialized */ ALPM_ERR_TRANS_NOT_NULL, + /** A transaction has not been initialized */ ALPM_ERR_TRANS_NULL, + /** Duplicate target in transaction */ ALPM_ERR_TRANS_DUP_TARGET, + /** A transaction has not been initialized */ ALPM_ERR_TRANS_NOT_INITIALIZED, + /** Transaction has not been prepared */ ALPM_ERR_TRANS_NOT_PREPARED, + /** Transaction was aborted */ ALPM_ERR_TRANS_ABORT, + /** Failed to interrupt transaction */ ALPM_ERR_TRANS_TYPE, + /** Tried to commit transaction without locking the database */ ALPM_ERR_TRANS_NOT_LOCKED, + /** A hook failed to run */ ALPM_ERR_TRANS_HOOK_FAILED, /* Packages */ + /** Package not found */ ALPM_ERR_PKG_NOT_FOUND, + /** Package is in ignorepkg */ ALPM_ERR_PKG_IGNORED, + /** Package is invalid */ ALPM_ERR_PKG_INVALID, + /** Package has an invalid checksum */ ALPM_ERR_PKG_INVALID_CHECKSUM, + /** Package has an invalid signature */ ALPM_ERR_PKG_INVALID_SIG, + /** Package does not have a signature */ ALPM_ERR_PKG_MISSING_SIG, + /** Cannot open the package file */ ALPM_ERR_PKG_OPEN, + /** Failed to remove package files */ ALPM_ERR_PKG_CANT_REMOVE, + /** Package has an invalid name */ ALPM_ERR_PKG_INVALID_NAME, + /** Package has an invalid architecute */ ALPM_ERR_PKG_INVALID_ARCH, + /** Unused */ ALPM_ERR_PKG_REPO_NOT_FOUND, /* Signatures */ + /** Signatues are missing */ ALPM_ERR_SIG_MISSING, + /** Signatures are invalid */ ALPM_ERR_SIG_INVALID, /* Dependencies */ + /** Dependencies could not be satisfied */ ALPM_ERR_UNSATISFIED_DEPS, + /** Conflicting dependencies */ ALPM_ERR_CONFLICTING_DEPS, + /** Files conflict */ ALPM_ERR_FILE_CONFLICTS, /* Misc */ + /** Download failed */ ALPM_ERR_RETRIEVE, + /** Invalid Regex */ ALPM_ERR_INVALID_REGEX, /* External library errors */ + /** Error in libarchive */ ALPM_ERR_LIBARCHIVE, + /** Error in libcurl */ ALPM_ERR_LIBCURL, + /** Error in external download program */ ALPM_ERR_EXTERNAL_DOWNLOAD, + /** Error in gpgme */ ALPM_ERR_GPGME, - /* Missing compile-time features */ + /** Missing compile-time features */ ALPM_ERR_MISSING_CAPABILITY_SIGNATURES } alpm_errno_t;
-/** Returns the current error code from the handle. */ +/** Returns the current error code from the handle. + * @param handle the context handle + * @return the current error code of the handle + */ alpm_errno_t alpm_errno(alpm_handle_t *handle);
-/** Returns the string corresponding to an error number. */ +/** Returns the string corresponding to an error number. + * @param err the error code to get the string for + * @return the string relating to the given error code + */ const char *alpm_strerror(alpm_errno_t err);
-/* End of alpm_api_errors */ +/* End of alpm_errors */ /** @} */
-/** @addtogroup alpm_api Public API - * The libalpm Public API - * @{ - */ - typedef int64_t alpm_time_t;
/* -- 2.29.2
Sorry, misclicked a send.
+/** A package
How about a period here, to match the line for "database" above.
+ /** Package has an invalid architecute */ ALPM_ERR_PKG_INVALID_ARCH,
Spelling of "architecture".
+ /** Signatues are missing */ ALPM_ERR_SIG_MISSING,
Spelling of "signatures".
--- lib/libalpm/alpm.h | 58 ++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 1c2422ca..178c8f6a 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -243,6 +243,36 @@ const char *alpm_strerror(alpm_errno_t err); /* End of alpm_errors */ /** @} */ + +/** \addtogroup alpm_handle Handle + * @brief Functions to initialize and release libalpm + * @{ + */ + +/** Initializes the library. + * Creates handle, connects to database and creates lockfile. + * This must be called before any other functions are called. + * @param root the root path for all filesystem operations + * @param dbpath the absolute path to the libalpm database + * @param err an optional variable to hold any error return codes + * @return a context handle on success, NULL on error, err will be set if provided + */ +alpm_handle_t *alpm_initialize(const char *root, const char *dbpath, + alpm_errno_t *err); + +/** Release the library. + * Disconnects from the database, removes handle and lockfile + * This should be the last alpm call you make. + * After this returns, handle should be considered invalid and cannot be reused + * in any way. + * @param myhandle the context handle + * @return 0 on success, -1 on error + */ +int alpm_release(alpm_handle_t *handle); + +/* End of alpm_handle */ +/** @} */ + typedef int64_t alpm_time_t; /* @@ -1915,34 +1945,6 @@ char *alpm_compute_sha256sum(const char *filename); /** @} */ -/** \addtogroup alpm_interface Interface Functions - * @brief Functions to initialize and release libalpm - * @{ - */ - -/** Initializes the library. - * Creates handle, connects to database and creates lockfile. - * This must be called before any other functions are called. - * @param root the root path for all filesystem operations - * @param dbpath the absolute path to the libalpm database - * @param err an optional variable to hold any error return codes - * @return a context handle on success, NULL on error, err will be set if provided - */ -alpm_handle_t *alpm_initialize(const char *root, const char *dbpath, - alpm_errno_t *err); - -/** Release the library. - * Disconnects from the database, removes handle and lockfile - * This should be the last alpm call you make. - * After this returns, handle should be considered invalid and cannot be reused - * in any way. - * @param myhandle the context handle - * @return 0 on success, -1 on error - */ -int alpm_release(alpm_handle_t *handle); - -/** @} */ - /** Remove the database lock file * @param handle the context handle * @return 0 on success, -1 on error -- 2.29.2
--- lib/libalpm/alpm.h | 282 +++++++++++++++++++++++++++------------------ 1 file changed, 167 insertions(+), 115 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 178c8f6a..43a47d54 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -265,7 +265,7 @@ alpm_handle_t *alpm_initialize(const char *root, const char *dbpath, * This should be the last alpm call you make. * After this returns, handle should be considered invalid and cannot be reused * in any way. - * @param myhandle the context handle + * @param handle the context handle * @return 0 on success, -1 on error */ int alpm_release(alpm_handle_t *handle); @@ -275,6 +275,172 @@ int alpm_release(alpm_handle_t *handle); typedef int64_t alpm_time_t; +/** @addtogroup alpm_sig Signature checking + * @brief Functions to check signatures + * @{ + */ + +/** PGP signature verification options */ +typedef enum _alpm_siglevel_t { + /** Packages require a signature */ + ALPM_SIG_PACKAGE = (1 << 0), + /** Packages do not require a signature, + * but check packages that do have signatures */ + ALPM_SIG_PACKAGE_OPTIONAL = (1 << 1), + /* Allow packages with signatures that are marginal trust */ + ALPM_SIG_PACKAGE_MARGINAL_OK = (1 << 2), + /** Allow packages with signatues that are unknown trust */ + ALPM_SIG_PACKAGE_UNKNOWN_OK = (1 << 3), + + /** Databases require a signature */ + ALPM_SIG_DATABASE = (1 << 10), + /** Databases do not require a signature, + * but check databases that do have signatures */ + ALPM_SIG_DATABASE_OPTIONAL = (1 << 11), + /** Allow databases with signatures that are marginal trust */ + ALPM_SIG_DATABASE_MARGINAL_OK = (1 << 12), + /** Allow databases with signatues that are unknown trust */ + ALPM_SIG_DATABASE_UNKNOWN_OK = (1 << 13), + + /** The Default siglevel */ + ALPM_SIG_USE_DEFAULT = (1 << 30) +} alpm_siglevel_t; + +/** PGP signature verification status return codes */ +typedef enum _alpm_sigstatus_t { + /** Signature is valid */ + ALPM_SIGSTATUS_VALID, + /** The key has expired */ + ALPM_SIGSTATUS_KEY_EXPIRED, + /** The signature has expired */ + ALPM_SIGSTATUS_SIG_EXPIRED, + /** The key is not in the keyring */ + ALPM_SIGSTATUS_KEY_UNKNOWN, + /** The key has been disabled */ + ALPM_SIGSTATUS_KEY_DISABLED, + /** The signature is invalid */ + ALPM_SIGSTATUS_INVALID +} alpm_sigstatus_t; + + +/** The trust level of a PGP key */ +typedef enum _alpm_sigvalidity_t { + /** The signature is fully trusted */ + ALPM_SIGVALIDITY_FULL, + /** The signature is marginally trusted */ + ALPM_SIGVALIDITY_MARGINAL, + /** The signature is never trusted */ + ALPM_SIGVALIDITY_NEVER, + /** The signature has unknown trust */ + ALPM_SIGVALIDITY_UNKNOWN +} alpm_sigvalidity_t; + +/** A PGP key */ +typedef struct _alpm_pgpkey_t { + /** The actual key data */ + void *data; + /** The key's fingerprint */ + char *fingerprint; + /** UID of the key */ + char *uid; + /** Name of the key's owner */ + char *name; + /** Email of the key's owner */ + char *email; + /** When the key was created */ + alpm_time_t created; + /** When the key expires */ + alpm_time_t expires; + /** The length of the key */ + unsigned int length; + /** has the key been revoked */ + unsigned int revoked; + /** A character representing the encryption algorithm used by the public key + * + * ? = unknown + * R = RSA + * D = DSA + * E = EDDSA + */ + char pubkey_algo; +} alpm_pgpkey_t; + +/** + * Signature result. Contains the key, status, and validity of a given + * signature. + */ +typedef struct _alpm_sigresult_t { + /** The key of the signature */ + alpm_pgpkey_t key; + /** The status of the signature */ + alpm_sigstatus_t status; + /** The validity of the signature */ + alpm_sigvalidity_t validity; +} alpm_sigresult_t; + +/** + * Signature list. Contains the number of signatures found and a pointer to an + * array of results. The array is of size count. + */ +typedef struct _alpm_siglist_t { + /** The amount of results in the array */ + size_t count; + /** An array of sigresults */ + alpm_sigresult_t *results; +} alpm_siglist_t; + +/** + * Check the PGP signature for the given package file. + * @param pkg the package to check + * @param siglist a pointer to storage for signature results + * @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred) + */ +int alpm_pkg_check_pgp_signature(alpm_pkg_t *pkg, alpm_siglist_t *siglist); + +/** + * Check the PGP signature for the given database. + * @param db the database to check + * @param siglist a pointer to storage for signature results + * @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred) + */ +int alpm_db_check_pgp_signature(alpm_db_t *db, alpm_siglist_t *siglist); + +/** + * Clean up and free a signature result list. + * Note that this does not free the siglist object itself in case that + * was allocated on the stack; this is the responsibility of the caller. + * @param siglist a pointer to storage for signature results + * @return 0 on success, -1 on error + */ +int alpm_siglist_cleanup(alpm_siglist_t *siglist); + +/** + * Decode a loaded signature in base64 form. + * @param base64_data the signature to attempt to decode + * @param data the decoded data; must be freed by the caller + * @param data_len the length of the returned data + * @return 0 on success, -1 on failure to properly decode + */ +int alpm_decode_signature(const char *base64_data, + unsigned char **data, size_t *data_len); + +/** + * Extract the Issuer Key ID from a signature + * @param handle the context handle + * @param identifier the identifier of the key. + * This may be the name of the package or the path to the package. + * @param sig PGP signature + * @param len length of signature + * @param keys a pointer to storage for key IDs + * @return 0 on success, -1 on error + */ +int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier, + const unsigned char *sig, const size_t len, alpm_list_t **keys); + +/* End of alpm_sig */ +/** @} */ + + /* * Enumerations * These ones are used in multiple contexts, so are forward-declared. @@ -330,39 +496,6 @@ typedef enum _alpm_fileconflicttype_t { ALPM_FILECONFLICT_FILESYSTEM } alpm_fileconflicttype_t; -/** PGP signature verification options */ -typedef enum _alpm_siglevel_t { - ALPM_SIG_PACKAGE = (1 << 0), - ALPM_SIG_PACKAGE_OPTIONAL = (1 << 1), - ALPM_SIG_PACKAGE_MARGINAL_OK = (1 << 2), - ALPM_SIG_PACKAGE_UNKNOWN_OK = (1 << 3), - - ALPM_SIG_DATABASE = (1 << 10), - ALPM_SIG_DATABASE_OPTIONAL = (1 << 11), - ALPM_SIG_DATABASE_MARGINAL_OK = (1 << 12), - ALPM_SIG_DATABASE_UNKNOWN_OK = (1 << 13), - - ALPM_SIG_USE_DEFAULT = (1 << 30) -} alpm_siglevel_t; - -/** PGP signature verification status return codes */ -typedef enum _alpm_sigstatus_t { - ALPM_SIGSTATUS_VALID, - ALPM_SIGSTATUS_KEY_EXPIRED, - ALPM_SIGSTATUS_SIG_EXPIRED, - ALPM_SIGSTATUS_KEY_UNKNOWN, - ALPM_SIGSTATUS_KEY_DISABLED, - ALPM_SIGSTATUS_INVALID -} alpm_sigstatus_t; - -/** PGP signature verification status return codes */ -typedef enum _alpm_sigvalidity_t { - ALPM_SIGVALIDITY_FULL, - ALPM_SIGVALIDITY_MARGINAL, - ALPM_SIGVALIDITY_NEVER, - ALPM_SIGVALIDITY_UNKNOWN -} alpm_sigvalidity_t; - /* * Structures */ @@ -428,39 +561,6 @@ typedef struct _alpm_backup_t { char *hash; } alpm_backup_t; -typedef struct _alpm_pgpkey_t { - void *data; - char *fingerprint; - char *uid; - char *name; - char *email; - alpm_time_t created; - alpm_time_t expires; - unsigned int length; - unsigned int revoked; - char pubkey_algo; -} alpm_pgpkey_t; - -/** - * Signature result. Contains the key, status, and validity of a given - * signature. - */ -typedef struct _alpm_sigresult_t { - alpm_pgpkey_t key; - alpm_sigstatus_t status; - alpm_sigvalidity_t validity; -} alpm_sigresult_t; - -/** - * Signature list. Contains the number of signatures found and a pointer to an - * array of results. The array is of size count. - */ -typedef struct _alpm_siglist_t { - size_t count; - alpm_sigresult_t *results; -} alpm_siglist_t; - - /* * Hooks */ @@ -1653,54 +1753,6 @@ int alpm_pkg_set_reason(alpm_pkg_t *pkg, alpm_pkgreason_t reason); */ alpm_file_t *alpm_filelist_contains(alpm_filelist_t *filelist, const char *path); -/* - * Signatures - */ - -/** - * Check the PGP signature for the given package file. - * @param pkg the package to check - * @param siglist a pointer to storage for signature results - * @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred) - */ -int alpm_pkg_check_pgp_signature(alpm_pkg_t *pkg, alpm_siglist_t *siglist); - -/** - * Check the PGP signature for the given database. - * @param db the database to check - * @param siglist a pointer to storage for signature results - * @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred) - */ -int alpm_db_check_pgp_signature(alpm_db_t *db, alpm_siglist_t *siglist); - -/** - * Clean up and free a signature result list. - * Note that this does not free the siglist object itself in case that - * was allocated on the stack; this is the responsibility of the caller. - * @param siglist a pointer to storage for signature results - * @return 0 on success, -1 on error - */ -int alpm_siglist_cleanup(alpm_siglist_t *siglist); - -/** - * Decode a loaded signature in base64 form. - * @param base64_data the signature to attempt to decode - * @param data the decoded data; must be freed by the caller - * @param data_len the length of the returned data - * @return 0 on success, -1 on failure to properly decode - */ -int alpm_decode_signature(const char *base64_data, - unsigned char **data, size_t *data_len); - -/** - * Extract the Issuer Key ID from a signature - * @param sig PGP signature - * @param len length of signature - * @param keys a pointer to storage for key IDs - * @return 0 on success, -1 on error - */ -int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier, - const unsigned char *sig, const size_t len, alpm_list_t **keys); /* * Groups -- 2.29.2
--- lib/libalpm/alpm.h | 295 +++++++++++++++++++++++++-------------------- 1 file changed, 164 insertions(+), 131 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 43a47d54..ea99a8b3 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -441,49 +441,26 @@ int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier, /** @} */ -/* - * Enumerations - * These ones are used in multiple contexts, so are forward-declared. +/** @addtogroup alpm_depends Dependency + * @brief Functions dealing with libalpm's dependency and conflict + * information. + * @{ */ -/** Package install reasons. */ -typedef enum _alpm_pkgreason_t { - /** Explicitly requested by the user. */ - ALPM_PKG_REASON_EXPLICIT = 0, - /** Installed as a dependency for another package. */ - ALPM_PKG_REASON_DEPEND = 1 -} alpm_pkgreason_t; - -/** Location a package object was loaded from. */ -typedef enum _alpm_pkgfrom_t { - ALPM_PKG_FROM_FILE = 1, - ALPM_PKG_FROM_LOCALDB, - ALPM_PKG_FROM_SYNCDB -} alpm_pkgfrom_t; - -/** Method used to validate a package. */ -typedef enum _alpm_pkgvalidation_t { - ALPM_PKG_VALIDATION_UNKNOWN = 0, - ALPM_PKG_VALIDATION_NONE = (1 << 0), - ALPM_PKG_VALIDATION_MD5SUM = (1 << 1), - ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2), - ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) -} alpm_pkgvalidation_t; - /** Types of version constraints in dependency specs. */ typedef enum _alpm_depmod_t { - /** No version constraint */ - ALPM_DEP_MOD_ANY = 1, - /** Test version equality (package=x.y.z) */ - ALPM_DEP_MOD_EQ, - /** Test for at least a version (package>=x.y.z) */ - ALPM_DEP_MOD_GE, - /** Test for at most a version (package<=x.y.z) */ - ALPM_DEP_MOD_LE, - /** Test for greater than some version (package>x.y.z) */ - ALPM_DEP_MOD_GT, - /** Test for less than some version (package<x.y.z) */ - ALPM_DEP_MOD_LT + /** No version constraint */ + ALPM_DEP_MOD_ANY = 1, + /** Test version equality (package=x.y.z) */ + ALPM_DEP_MOD_EQ, + /** Test for at least a version (package>=x.y.z) */ + ALPM_DEP_MOD_GE, + /** Test for at most a version (package<=x.y.z) */ + ALPM_DEP_MOD_LE, + /** Test for greater than some version (package>x.y.z) */ + ALPM_DEP_MOD_GT, + /** Test for less than some version (package<x.y.z) */ + ALPM_DEP_MOD_LT } alpm_depmod_t; /** @@ -492,48 +469,187 @@ typedef enum _alpm_depmod_t { * another target in the transaction. */ typedef enum _alpm_fileconflicttype_t { + /** The conflict results with a another target in the transaction */ ALPM_FILECONFLICT_TARGET = 1, + /** The conflict results from a file existing on the filesystem */ ALPM_FILECONFLICT_FILESYSTEM } alpm_fileconflicttype_t; -/* - * Structures - */ - -/** Dependency */ +/** The basic dependency type. + * + * This type is used throughout libalpm, not just for dependencies + * but also conflicts and providers. */ typedef struct _alpm_depend_t { + /** Name of the provider to satisfy this dependnecy */ char *name; + /** Version of the provider to match against (optional) */ char *version; + /** A description of why this dependency is needed (optional) */ char *desc; + /** A hash of name (used internally to speed up conflict checks) */ unsigned long name_hash; + /** How the version should match against the provider */ alpm_depmod_t mod; } alpm_depend_t; -/** Missing dependency */ +/** Missing dependency. */ typedef struct _alpm_depmissing_t { + /** Name of the package that has the dependnecy */ char *target; + /** The dependency that was wanted */ alpm_depend_t *depend; - /* this is used only in the case of a remove dependency error */ + /** If the depmissing was caused by a conflict, the name of the package + * that would be installed, causing the satisfying package to be removed */ char *causingpkg; } alpm_depmissing_t; -/** Conflict */ +/** A conflict that has occurred between two packages. */ typedef struct _alpm_conflict_t { + /** Hash of the first package name + * (used internally to speed up conflict checks) */ unsigned long package1_hash; + /** Hash of the second package name + * (used internally to speed up conflict checks) */ unsigned long package2_hash; + /** Name of the first package */ char *package1; + /** Name of the second package */ char *package2; + /** The conflict */ alpm_depend_t *reason; } alpm_conflict_t; -/** File conflict */ +/** File conflict. + * + * A conflict that has happened due to a two packages containing the same file, + * or a package contains a file that is already on the filesystem and not owned + * by that package. */ typedef struct _alpm_fileconflict_t { + /** The name of the package that caused the conflict */ char *target; + /** The type of conflict */ alpm_fileconflicttype_t type; + /** The name of the file that the package conflicts with */ char *file; + /** The name of the package that also owns the file if there is one*/ char *ctarget; } alpm_fileconflict_t; +/** Checks dependencies and returns missing ones in a list. + * Dependencies can include versions with depmod operators. + * @param handle the context handle + * @param pkglist the list of local packages + * @param remove an alpm_list_t* of packages to be removed + * @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade) + * @param reversedeps handles the backward dependencies + * @return an alpm_list_t* of alpm_depmissing_t pointers. + */ +alpm_list_t *alpm_checkdeps(alpm_handle_t *handle, alpm_list_t *pkglist, + alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps); + +/** Find a package satisfying a specified dependency. + * The dependency can include versions with depmod operators. + * @param pkgs an alpm_list_t* of alpm_pkg_t where the satisfier will be searched + * @param depstring package or provision name, versioned or not + * @return a alpm_pkg_t* satisfying depstring + */ +alpm_pkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring); + +/** Find a package satisfying a specified dependency. + * First look for a literal, going through each db one by one. Then look for + * providers. The first satisfier that belongs to an installed package is + * returned. If no providers belong to an installed package then an + * alpm_question_select_provider_t is created to select the provider. + * The dependency can include versions with depmod operators. + * + * @param handle the context handle + * @param dbs an alpm_list_t* of alpm_db_t where the satisfier will be searched + * @param depstring package or provision name, versioned or not + * @return a alpm_pkg_t* satisfying depstring + */ +alpm_pkg_t *alpm_find_dbs_satisfier(alpm_handle_t *handle, + alpm_list_t *dbs, const char *depstring); + +/** Check the package conflicts in a database + * + * @param handle the context handle + * @param pkglist the list of packages to check + * + * @return an alpm_list_t of alpm_conflict_t + */ +alpm_list_t *alpm_checkconflicts(alpm_handle_t *handle, alpm_list_t *pkglist); + +/** Returns a newly allocated string representing the dependency information. + * @param dep a dependency info structure + * @return a formatted string, e.g. "glibc>=2.12" + */ +char *alpm_dep_compute_string(const alpm_depend_t *dep); + +/** Return a newly allocated dependency information parsed from a string + *\link alpm_dep_free should be used to free the dependency \endlink + * @param depstring a formatted string, e.g. "glibc=2.12" + * @return a dependency info structure + */ +alpm_depend_t *alpm_dep_from_string(const char *depstring); + +/** Free a dependency info structure + * @param dep struct to free + */ +void alpm_dep_free(alpm_depend_t *dep); + +/** Free a fileconflict and its members. + * @param conflict the fileconflict to free + */ +void alpm_fileconflict_free(alpm_fileconflict_t *conflict); + +/** Free a depmissing and its members + * @param miss the depmissing to fre + * */ +void alpm_depmissing_free(alpm_depmissing_t *miss); + +/** + * Free a conflict and its members. + * @param conflict the conflict to free + */ +void alpm_conflict_free(alpm_conflict_t *conflict); + + +/* End of alpm_depends */ +/** @} */ + +/* + * Enumerations + * These ones are used in multiple contexts, so are forward-declared. + */ + +/** Package install reasons. */ +typedef enum _alpm_pkgreason_t { + /** Explicitly requested by the user. */ + ALPM_PKG_REASON_EXPLICIT = 0, + /** Installed as a dependency for another package. */ + ALPM_PKG_REASON_DEPEND = 1 +} alpm_pkgreason_t; + +/** Location a package object was loaded from. */ +typedef enum _alpm_pkgfrom_t { + ALPM_PKG_FROM_FILE = 1, + ALPM_PKG_FROM_LOCALDB, + ALPM_PKG_FROM_SYNCDB +} alpm_pkgfrom_t; + +/** Method used to validate a package. */ +typedef enum _alpm_pkgvalidation_t { + ALPM_PKG_VALIDATION_UNKNOWN = 0, + ALPM_PKG_VALIDATION_NONE = (1 << 0), + ALPM_PKG_VALIDATION_MD5SUM = (1 << 1), + ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2), + ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) +} alpm_pkgvalidation_t; + +/* + * Structures + */ + /** Package group */ typedef struct _alpm_group_t { /** group name */ @@ -1900,76 +2016,6 @@ int alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg); /** @} */ -/** @addtogroup alpm_api_depends Dependency Functions - * Functions dealing with libalpm representation of dependency - * information. - * @{ - */ - -/** Checks dependencies and returns missing ones in a list. - * Dependencies can include versions with depmod operators. - * @param handle the context handle - * @param pkglist the list of local packages - * @param remove an alpm_list_t* of packages to be removed - * @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade) - * @param reversedeps handles the backward dependencies - * @return an alpm_list_t* of alpm_depmissing_t pointers. - */ -alpm_list_t *alpm_checkdeps(alpm_handle_t *handle, alpm_list_t *pkglist, - alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps); - -/** Find a package satisfying a specified dependency. - * The dependency can include versions with depmod operators. - * @param pkgs an alpm_list_t* of alpm_pkg_t where the satisfier will be searched - * @param depstring package or provision name, versioned or not - * @return a alpm_pkg_t* satisfying depstring - */ -alpm_pkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring); - -/** Find a package satisfying a specified dependency. - * First look for a literal, going through each db one by one. Then look for - * providers. The first satisfier that belongs to an installed package is - * returned. If no providers belong to an installed package then an - * alpm_question_select_provider_t is created to select the provider. - * The dependency can include versions with depmod operators. - * - * @param handle the context handle - * @param dbs an alpm_list_t* of alpm_db_t where the satisfier will be searched - * @param depstring package or provision name, versioned or not - * @return a alpm_pkg_t* satisfying depstring - */ -alpm_pkg_t *alpm_find_dbs_satisfier(alpm_handle_t *handle, - alpm_list_t *dbs, const char *depstring); - -/** - * @brief Check the package conflicts in a database - * - * @param handle the context handle - * @param pkglist the list of packages to check - * - * @return an alpm_list_t of alpm_conflict_t - */ -alpm_list_t *alpm_checkconflicts(alpm_handle_t *handle, alpm_list_t *pkglist); - -/** Returns a newly allocated string representing the dependency information. - * @param dep a dependency info structure - * @return a formatted string, e.g. "glibc>=2.12" - */ -char *alpm_dep_compute_string(const alpm_depend_t *dep); - -/** Return a newly allocated dependency information parsed from a string - * @param depstring a formatted string, e.g. "glibc=2.12" - * @return a dependency info structure - */ -alpm_depend_t *alpm_dep_from_string(const char *depstring); - -/** Free a dependency info structure - * @param dep struct to free - */ -void alpm_dep_free(alpm_depend_t *dep); - -/** @} */ - /** @} */ /* @@ -2021,19 +2067,6 @@ const char *alpm_version(void); * */ int alpm_capabilities(void); -/** - * Free a fileconflict and its members. - * @param conflict the fileconflict to free - */ -void alpm_fileconflict_free(alpm_fileconflict_t *conflict); -void alpm_depmissing_free(alpm_depmissing_t *miss); - -/** - * Free a conflict and its members. - * @param conflict the conflict to free - */ -void alpm_conflict_free(alpm_conflict_t *conflict); - /* End of alpm_api */ /** @} */ -- 2.29.2
+ /** Name of the provider to satisfy this dependnecy */ char *name;
Spelling of "dependency" here and on the `*target` field. On Mon, 7 Dec 2020, at 14:19, morganamilo wrote:
--- lib/libalpm/alpm.h | 295 +++++++++++++++++++++++++-------------------- 1 file changed, 164 insertions(+), 131 deletions(-)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 43a47d54..ea99a8b3 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -441,49 +441,26 @@ int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier, /** @} */
-/* - * Enumerations - * These ones are used in multiple contexts, so are forward-declared. +/** @addtogroup alpm_depends Dependency + * @brief Functions dealing with libalpm's dependency and conflict + * information. + * @{ */
-/** Package install reasons. */ -typedef enum _alpm_pkgreason_t { - /** Explicitly requested by the user. */ - ALPM_PKG_REASON_EXPLICIT = 0, - /** Installed as a dependency for another package. */ - ALPM_PKG_REASON_DEPEND = 1 -} alpm_pkgreason_t; - -/** Location a package object was loaded from. */ -typedef enum _alpm_pkgfrom_t { - ALPM_PKG_FROM_FILE = 1, - ALPM_PKG_FROM_LOCALDB, - ALPM_PKG_FROM_SYNCDB -} alpm_pkgfrom_t; - -/** Method used to validate a package. */ -typedef enum _alpm_pkgvalidation_t { - ALPM_PKG_VALIDATION_UNKNOWN = 0, - ALPM_PKG_VALIDATION_NONE = (1 << 0), - ALPM_PKG_VALIDATION_MD5SUM = (1 << 1), - ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2), - ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) -} alpm_pkgvalidation_t; - /** Types of version constraints in dependency specs. */ typedef enum _alpm_depmod_t { - /** No version constraint */ - ALPM_DEP_MOD_ANY = 1, - /** Test version equality (package=x.y.z) */ - ALPM_DEP_MOD_EQ, - /** Test for at least a version (package>=x.y.z) */ - ALPM_DEP_MOD_GE, - /** Test for at most a version (package<=x.y.z) */ - ALPM_DEP_MOD_LE, - /** Test for greater than some version (package>x.y.z) */ - ALPM_DEP_MOD_GT, - /** Test for less than some version (package<x.y.z) */ - ALPM_DEP_MOD_LT + /** No version constraint */ + ALPM_DEP_MOD_ANY = 1, + /** Test version equality (package=x.y.z) */ + ALPM_DEP_MOD_EQ, + /** Test for at least a version (package>=x.y.z) */ + ALPM_DEP_MOD_GE, + /** Test for at most a version (package<=x.y.z) */ + ALPM_DEP_MOD_LE, + /** Test for greater than some version (package>x.y.z) */ + ALPM_DEP_MOD_GT, + /** Test for less than some version (package<x.y.z) */ + ALPM_DEP_MOD_LT } alpm_depmod_t;
/** @@ -492,48 +469,187 @@ typedef enum _alpm_depmod_t { * another target in the transaction. */ typedef enum _alpm_fileconflicttype_t { + /** The conflict results with a another target in the transaction */ ALPM_FILECONFLICT_TARGET = 1, + /** The conflict results from a file existing on the filesystem */ ALPM_FILECONFLICT_FILESYSTEM } alpm_fileconflicttype_t;
-/* - * Structures - */ - -/** Dependency */ +/** The basic dependency type. + * + * This type is used throughout libalpm, not just for dependencies + * but also conflicts and providers. */ typedef struct _alpm_depend_t { + /** Name of the provider to satisfy this dependnecy */ char *name; + /** Version of the provider to match against (optional) */ char *version; + /** A description of why this dependency is needed (optional) */ char *desc; + /** A hash of name (used internally to speed up conflict checks) */ unsigned long name_hash; + /** How the version should match against the provider */ alpm_depmod_t mod; } alpm_depend_t;
-/** Missing dependency */ +/** Missing dependency. */ typedef struct _alpm_depmissing_t { + /** Name of the package that has the dependnecy */ char *target; + /** The dependency that was wanted */ alpm_depend_t *depend; - /* this is used only in the case of a remove dependency error */ + /** If the depmissing was caused by a conflict, the name of the package + * that would be installed, causing the satisfying package to be removed */ char *causingpkg; } alpm_depmissing_t;
-/** Conflict */ +/** A conflict that has occurred between two packages. */ typedef struct _alpm_conflict_t { + /** Hash of the first package name + * (used internally to speed up conflict checks) */ unsigned long package1_hash; + /** Hash of the second package name + * (used internally to speed up conflict checks) */ unsigned long package2_hash; + /** Name of the first package */ char *package1; + /** Name of the second package */ char *package2; + /** The conflict */ alpm_depend_t *reason; } alpm_conflict_t;
-/** File conflict */ +/** File conflict. + * + * A conflict that has happened due to a two packages containing the same file, + * or a package contains a file that is already on the filesystem and not owned + * by that package. */ typedef struct _alpm_fileconflict_t { + /** The name of the package that caused the conflict */ char *target; + /** The type of conflict */ alpm_fileconflicttype_t type; + /** The name of the file that the package conflicts with */ char *file; + /** The name of the package that also owns the file if there is one*/ char *ctarget; } alpm_fileconflict_t;
+/** Checks dependencies and returns missing ones in a list. + * Dependencies can include versions with depmod operators. + * @param handle the context handle + * @param pkglist the list of local packages + * @param remove an alpm_list_t* of packages to be removed + * @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade) + * @param reversedeps handles the backward dependencies + * @return an alpm_list_t* of alpm_depmissing_t pointers. + */ +alpm_list_t *alpm_checkdeps(alpm_handle_t *handle, alpm_list_t *pkglist, + alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps); + +/** Find a package satisfying a specified dependency. + * The dependency can include versions with depmod operators. + * @param pkgs an alpm_list_t* of alpm_pkg_t where the satisfier will be searched + * @param depstring package or provision name, versioned or not + * @return a alpm_pkg_t* satisfying depstring + */ +alpm_pkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring); + +/** Find a package satisfying a specified dependency. + * First look for a literal, going through each db one by one. Then look for + * providers. The first satisfier that belongs to an installed package is + * returned. If no providers belong to an installed package then an + * alpm_question_select_provider_t is created to select the provider. + * The dependency can include versions with depmod operators. + * + * @param handle the context handle + * @param dbs an alpm_list_t* of alpm_db_t where the satisfier will be searched + * @param depstring package or provision name, versioned or not + * @return a alpm_pkg_t* satisfying depstring + */ +alpm_pkg_t *alpm_find_dbs_satisfier(alpm_handle_t *handle, + alpm_list_t *dbs, const char *depstring); + +/** Check the package conflicts in a database + * + * @param handle the context handle + * @param pkglist the list of packages to check + * + * @return an alpm_list_t of alpm_conflict_t + */ +alpm_list_t *alpm_checkconflicts(alpm_handle_t *handle, alpm_list_t *pkglist); + +/** Returns a newly allocated string representing the dependency information. + * @param dep a dependency info structure + * @return a formatted string, e.g. "glibc>=2.12" + */ +char *alpm_dep_compute_string(const alpm_depend_t *dep); + +/** Return a newly allocated dependency information parsed from a string + *\link alpm_dep_free should be used to free the dependency \endlink + * @param depstring a formatted string, e.g. "glibc=2.12" + * @return a dependency info structure + */ +alpm_depend_t *alpm_dep_from_string(const char *depstring); + +/** Free a dependency info structure + * @param dep struct to free + */ +void alpm_dep_free(alpm_depend_t *dep); + +/** Free a fileconflict and its members. + * @param conflict the fileconflict to free + */ +void alpm_fileconflict_free(alpm_fileconflict_t *conflict); + +/** Free a depmissing and its members + * @param miss the depmissing to fre + * */ +void alpm_depmissing_free(alpm_depmissing_t *miss); + +/** + * Free a conflict and its members. + * @param conflict the conflict to free + */ +void alpm_conflict_free(alpm_conflict_t *conflict); + + +/* End of alpm_depends */ +/** @} */ + +/* + * Enumerations + * These ones are used in multiple contexts, so are forward-declared. + */ + +/** Package install reasons. */ +typedef enum _alpm_pkgreason_t { + /** Explicitly requested by the user. */ + ALPM_PKG_REASON_EXPLICIT = 0, + /** Installed as a dependency for another package. */ + ALPM_PKG_REASON_DEPEND = 1 +} alpm_pkgreason_t; + +/** Location a package object was loaded from. */ +typedef enum _alpm_pkgfrom_t { + ALPM_PKG_FROM_FILE = 1, + ALPM_PKG_FROM_LOCALDB, + ALPM_PKG_FROM_SYNCDB +} alpm_pkgfrom_t; + +/** Method used to validate a package. */ +typedef enum _alpm_pkgvalidation_t { + ALPM_PKG_VALIDATION_UNKNOWN = 0, + ALPM_PKG_VALIDATION_NONE = (1 << 0), + ALPM_PKG_VALIDATION_MD5SUM = (1 << 1), + ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2), + ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) +} alpm_pkgvalidation_t; + +/* + * Structures + */ + /** Package group */ typedef struct _alpm_group_t { /** group name */ @@ -1900,76 +2016,6 @@ int alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg);
/** @} */
-/** @addtogroup alpm_api_depends Dependency Functions - * Functions dealing with libalpm representation of dependency - * information. - * @{ - */ - -/** Checks dependencies and returns missing ones in a list. - * Dependencies can include versions with depmod operators. - * @param handle the context handle - * @param pkglist the list of local packages - * @param remove an alpm_list_t* of packages to be removed - * @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade) - * @param reversedeps handles the backward dependencies - * @return an alpm_list_t* of alpm_depmissing_t pointers. - */ -alpm_list_t *alpm_checkdeps(alpm_handle_t *handle, alpm_list_t *pkglist, - alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps); - -/** Find a package satisfying a specified dependency. - * The dependency can include versions with depmod operators. - * @param pkgs an alpm_list_t* of alpm_pkg_t where the satisfier will be searched - * @param depstring package or provision name, versioned or not - * @return a alpm_pkg_t* satisfying depstring - */ -alpm_pkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring); - -/** Find a package satisfying a specified dependency. - * First look for a literal, going through each db one by one. Then look for - * providers. The first satisfier that belongs to an installed package is - * returned. If no providers belong to an installed package then an - * alpm_question_select_provider_t is created to select the provider. - * The dependency can include versions with depmod operators. - * - * @param handle the context handle - * @param dbs an alpm_list_t* of alpm_db_t where the satisfier will be searched - * @param depstring package or provision name, versioned or not - * @return a alpm_pkg_t* satisfying depstring - */ -alpm_pkg_t *alpm_find_dbs_satisfier(alpm_handle_t *handle, - alpm_list_t *dbs, const char *depstring); - -/** - * @brief Check the package conflicts in a database - * - * @param handle the context handle - * @param pkglist the list of packages to check - * - * @return an alpm_list_t of alpm_conflict_t - */ -alpm_list_t *alpm_checkconflicts(alpm_handle_t *handle, alpm_list_t *pkglist); - -/** Returns a newly allocated string representing the dependency information. - * @param dep a dependency info structure - * @return a formatted string, e.g. "glibc>=2.12" - */ -char *alpm_dep_compute_string(const alpm_depend_t *dep); - -/** Return a newly allocated dependency information parsed from a string - * @param depstring a formatted string, e.g. "glibc=2.12" - * @return a dependency info structure - */ -alpm_depend_t *alpm_dep_from_string(const char *depstring); - -/** Free a dependency info structure - * @param dep struct to free - */ -void alpm_dep_free(alpm_depend_t *dep); - -/** @} */ - /** @} */
/* @@ -2021,19 +2067,6 @@ const char *alpm_version(void); * */ int alpm_capabilities(void);
-/** - * Free a fileconflict and its members. - * @param conflict the fileconflict to free - */ -void alpm_fileconflict_free(alpm_fileconflict_t *conflict); -void alpm_depmissing_free(alpm_depmissing_t *miss); - -/** - * Free a conflict and its members. - * @param conflict the conflict to free - */ -void alpm_conflict_free(alpm_conflict_t *conflict); - /* End of alpm_api */ /** @} */
-- 2.29.2
--- lib/libalpm/alpm.h | 439 ++++++++++++++++++++++++++++----------------- 1 file changed, 271 insertions(+), 168 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index ea99a8b3..a8d48432 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -617,105 +617,12 @@ void alpm_conflict_free(alpm_conflict_t *conflict); /* End of alpm_depends */ /** @} */ -/* - * Enumerations - * These ones are used in multiple contexts, so are forward-declared. - */ - -/** Package install reasons. */ -typedef enum _alpm_pkgreason_t { - /** Explicitly requested by the user. */ - ALPM_PKG_REASON_EXPLICIT = 0, - /** Installed as a dependency for another package. */ - ALPM_PKG_REASON_DEPEND = 1 -} alpm_pkgreason_t; - -/** Location a package object was loaded from. */ -typedef enum _alpm_pkgfrom_t { - ALPM_PKG_FROM_FILE = 1, - ALPM_PKG_FROM_LOCALDB, - ALPM_PKG_FROM_SYNCDB -} alpm_pkgfrom_t; - -/** Method used to validate a package. */ -typedef enum _alpm_pkgvalidation_t { - ALPM_PKG_VALIDATION_UNKNOWN = 0, - ALPM_PKG_VALIDATION_NONE = (1 << 0), - ALPM_PKG_VALIDATION_MD5SUM = (1 << 1), - ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2), - ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) -} alpm_pkgvalidation_t; - -/* - * Structures - */ - -/** Package group */ -typedef struct _alpm_group_t { - /** group name */ - char *name; - /** list of alpm_pkg_t packages */ - alpm_list_t *packages; -} alpm_group_t; -/** File in a package */ -typedef struct _alpm_file_t { - char *name; - off_t size; - mode_t mode; -} alpm_file_t; - -/** Package filelist container */ -typedef struct _alpm_filelist_t { - size_t count; - alpm_file_t *files; -} alpm_filelist_t; - -/** Local package or package file backup entry */ -typedef struct _alpm_backup_t { - char *name; - char *hash; -} alpm_backup_t; - -/* - * Hooks - */ - -typedef enum _alpm_hook_when_t { - ALPM_HOOK_PRE_TRANSACTION = 1, - ALPM_HOOK_POST_TRANSACTION -} alpm_hook_when_t; - -/* - * Logging facilities - */ - -/** \addtogroup alpm_log Logging Functions - * @brief Functions to log using libalpm +/** \addtogroup alpm_cb Callbacks + * @brief Functions and structures for libalpm's callbacks * @{ */ -/** Logging Levels */ -typedef enum _alpm_loglevel_t { - ALPM_LOG_ERROR = 1, - ALPM_LOG_WARNING = (1 << 1), - ALPM_LOG_DEBUG = (1 << 2), - ALPM_LOG_FUNCTION = (1 << 3) -} alpm_loglevel_t; - -typedef void (*alpm_cb_log)(alpm_loglevel_t, const char *, va_list); - -/** A printf-like function for logging. - * @param handle the context handle - * @param prefix caller-specific prefix for the log - * @param fmt output format - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int alpm_logaction(alpm_handle_t *handle, const char *prefix, - const char *fmt, ...) __attribute__((format(printf, 3, 4))); - -/** @} */ - /** * Type of events. */ @@ -790,7 +697,7 @@ typedef enum _alpm_event_type_t { /** A .pacnew file was created; See alpm_event_pacnew_created_t for arguments. */ ALPM_EVENT_PACNEW_CREATED, /** A .pacsave file was created; See alpm_event_pacsave_created_t for - * arguments */ + * arguments. */ ALPM_EVENT_PACSAVE_CREATED, /** Processing hooks will be started. */ ALPM_EVENT_HOOK_START, @@ -798,100 +705,123 @@ typedef enum _alpm_event_type_t { ALPM_EVENT_HOOK_DONE, /** A hook is starting */ ALPM_EVENT_HOOK_RUN_START, - /** A hook has finished running */ + /** A hook has finished running. */ ALPM_EVENT_HOOK_RUN_DONE } alpm_event_type_t; +/** An event that may reprisent any event. */ typedef struct _alpm_event_any_t { - /** Type of event. */ + /** Type of event */ alpm_event_type_t type; } alpm_event_any_t; +/** An enum over the kind of package operations. */ typedef enum _alpm_package_operation_t { /** Package (to be) installed. (No oldpkg) */ ALPM_PACKAGE_INSTALL = 1, /** Package (to be) upgraded */ ALPM_PACKAGE_UPGRADE, - /** Package (to be) re-installed. */ + /** Package (to be) re-installed */ ALPM_PACKAGE_REINSTALL, - /** Package (to be) downgraded. */ + /** Package (to be) downgraded */ ALPM_PACKAGE_DOWNGRADE, - /** Package (to be) removed. (No newpkg) */ + /** Package (to be) removed (No newpkg) */ ALPM_PACKAGE_REMOVE } alpm_package_operation_t; +/** A package operation event occurred. */ typedef struct _alpm_event_package_operation_t { - /** Type of event. */ + /** Type of event */ alpm_event_type_t type; - /** Type of operation. */ + /** Type of operation */ alpm_package_operation_t operation; - /** Old package. */ + /** Old package */ alpm_pkg_t *oldpkg; - /** New package. */ + /** New package */ alpm_pkg_t *newpkg; } alpm_event_package_operation_t; +/** An optional dependency was removed. */ typedef struct _alpm_event_optdep_removal_t { - /** Type of event. */ + /** Type of event */ alpm_event_type_t type; - /** Package with the optdep. */ + /** Package with the optdep */ alpm_pkg_t *pkg; - /** Optdep being removed. */ + /** Optdep being removed */ alpm_depend_t *optdep; } alpm_event_optdep_removal_t; +/** A scriptlet was ran. */ typedef struct _alpm_event_scriptlet_info_t { - /** Type of event. */ + /** Type of event */ alpm_event_type_t type; - /** Line of scriptlet output. */ + /** Line of scriptlet output */ const char *line; } alpm_event_scriptlet_info_t; + +/** A database is missing. + * + * The database is registered but has not been downloaded + */ typedef struct _alpm_event_database_missing_t { - /** Type of event. */ + /** Type of event */ alpm_event_type_t type; - /** Name of the database. */ + /** Name of the database */ const char *dbname; } alpm_event_database_missing_t; +/** A package was downloaded. */ typedef struct _alpm_event_pkgdownload_t { - /** Type of event. */ + /** Type of event */ alpm_event_type_t type; /** Name of the file */ const char *file; } alpm_event_pkgdownload_t; +/** A pacnew file was created. */ typedef struct _alpm_event_pacnew_created_t { - /** Type of event. */ + /** Type of event */ alpm_event_type_t type; /** Whether the creation was result of a NoUpgrade or not */ int from_noupgrade; - /** Old package. */ + /** Old package */ alpm_pkg_t *oldpkg; - /** New Package. */ + /** New Package */ alpm_pkg_t *newpkg; /** Filename of the file without the .pacnew suffix */ const char *file; } alpm_event_pacnew_created_t; +/** A pacsave file was created. */ typedef struct _alpm_event_pacsave_created_t { - /** Type of event. */ + /** Type of event */ alpm_event_type_t type; - /** Old package. */ + /** Old package */ alpm_pkg_t *oldpkg; - /** Filename of the file without the .pacsave suffix. */ + /** Filename of the file without the .pacsave suffix */ const char *file; } alpm_event_pacsave_created_t; +/** Kind of hook. */ +typedef enum _alpm_hook_when_t { + /* Pre transaction hook */ + ALPM_HOOK_PRE_TRANSACTION = 1, + /* Post transaction hook */ + ALPM_HOOK_POST_TRANSACTION +} alpm_hook_when_t; + +/** pre/post transaction hooks are to be ran. */ typedef struct _alpm_event_hook_t { - /** Type of event.*/ + /** Type of event*/ alpm_event_type_t type; - /** Type of hooks. */ + /** Type of hook */ alpm_hook_when_t when; } alpm_event_hook_t; +/** A pre/post transaction hook was ran. */ typedef struct _alpm_event_hook_run_t { - /** Type of event.*/ + /** Type of event */ alpm_event_type_t type; /** Name of hook */ const char *name; @@ -904,185 +834,260 @@ typedef struct _alpm_event_hook_run_t { } alpm_event_hook_run_t; /** Events. - * This is an union passed to the callback, that allows the frontend to know + * This is a union passed to the callback that allows the frontend to know * which type of event was triggered (via type). It is then possible to * typecast the pointer to the right structure, or use the union field, in order * to access event-specific data. */ typedef union _alpm_event_t { + /** Type of event it's always safe to access this. */ alpm_event_type_t type; + /** The any event type. It's always safe to access this. */ alpm_event_any_t any; + /** Package operation */ alpm_event_package_operation_t package_operation; + /** An optdept was remove */ alpm_event_optdep_removal_t optdep_removal; + /** A scriptlet was ran */ alpm_event_scriptlet_info_t scriptlet_info; + /** A database is missing */ alpm_event_database_missing_t database_missing; + /** A package was downloaded */ alpm_event_pkgdownload_t pkgdownload; + /** A pacnew file was created */ alpm_event_pacnew_created_t pacnew_created; + /** A pacsave file was created */ alpm_event_pacsave_created_t pacsave_created; + /** Pre/post transaction hooks are being ran */ alpm_event_hook_t hook; + /** A hook was ran */ alpm_event_hook_run_t hook_run; } alpm_event_t; -/** Event callback. */ +/** Event callback. + * + * Called when an event occurs + * @param event the event that occurred */ typedef void (*alpm_cb_event)(alpm_event_t *); /** - * Type of questions. + * Type of question. * Unlike the events or progress enumerations, this enum has bitmask values * so a frontend can use a bitmask map to supply preselected answers to the * different types of questions. */ typedef enum _alpm_question_type_t { + /** Should target in ignorepkg be installed anyway? */ ALPM_QUESTION_INSTALL_IGNOREPKG = (1 << 0), + /** Should a package be replaced? */ ALPM_QUESTION_REPLACE_PKG = (1 << 1), + /** Should a conflicting package be removed? */ ALPM_QUESTION_CONFLICT_PKG = (1 << 2), + /** Should a corrupted package be deleted? */ ALPM_QUESTION_CORRUPTED_PKG = (1 << 3), + /** Should unresolvable targets be removed from the transaction? */ ALPM_QUESTION_REMOVE_PKGS = (1 << 4), + /** Provider selection */ ALPM_QUESTION_SELECT_PROVIDER = (1 << 5), + /** Should a key be imported? */ ALPM_QUESTION_IMPORT_KEY = (1 << 6) } alpm_question_type_t; +/** A question that can represent any other question. */ typedef struct _alpm_question_any_t { - /** Type of question. */ + /** Type of question */ alpm_question_type_t type; - /** Answer. */ + /** Answer */ int answer; } alpm_question_any_t; +/** Should target in ignorepkg be installed anyway? */ typedef struct _alpm_question_install_ignorepkg_t { - /** Type of question. */ + /** Type of question */ alpm_question_type_t type; - /** Answer: whether or not to install pkg anyway. */ + /** Answer: whether or not to install pkg anyway */ int install; - /* Package in IgnorePkg/IgnoreGroup. */ + /** The ignored package that we are deciding whether to install */ alpm_pkg_t *pkg; } alpm_question_install_ignorepkg_t; +/** Should a package be replaced? */ typedef struct _alpm_question_replace_t { - /** Type of question. */ + /** Type of question */ alpm_question_type_t type; - /** Answer: whether or not to replace oldpkg with newpkg. */ + /** Answer: whether or not to replace oldpkg with newpkg */ int replace; - /* Package to be replaced. */ + /** Package to be replaced */ alpm_pkg_t *oldpkg; - /* Package to replace with. */ + /** Package to replace with.*/ alpm_pkg_t *newpkg; - /* DB of newpkg */ + /** DB of newpkg */ alpm_db_t *newdb; } alpm_question_replace_t; +/** Should a conflicting package be removed? */ typedef struct _alpm_question_conflict_t { - /** Type of question. */ + /** Type of question */ alpm_question_type_t type; - /** Answer: whether or not to remove conflict->package2. */ + /** Answer: whether or not to remove conflict->package2 */ int remove; - /** Conflict info. */ + /** Conflict info */ alpm_conflict_t *conflict; } alpm_question_conflict_t; +/** Should a corrupted package be deleted? */ typedef struct _alpm_question_corrupted_t { - /** Type of question. */ + /** Type of question */ alpm_question_type_t type; - /** Answer: whether or not to remove filepath. */ + /** Answer: whether or not to remove filepath */ int remove; - /** Filename to remove */ + /** File to remove */ const char *filepath; /** Error code indicating the reason for package invalidity */ alpm_errno_t reason; } alpm_question_corrupted_t; +/** Should unresolvable targets be removed from the transaction? */ typedef struct _alpm_question_remove_pkgs_t { - /** Type of question. */ + /** Type of question */ alpm_question_type_t type; - /** Answer: whether or not to skip packages. */ + /** Answer: whether or not to skip packages */ int skip; - /** List of alpm_pkg_t* with unresolved dependencies. */ + /** List of alpm_pkg_t* with unresolved dependencies */ alpm_list_t *packages; } alpm_question_remove_pkgs_t; +/** Provider selection */ typedef struct _alpm_question_select_provider_t { - /** Type of question. */ + /** Type of question */ alpm_question_type_t type; - /** Answer: which provider to use (index from providers). */ + /** Answer: which provider to use (index from providers) */ int use_index; - /** List of alpm_pkg_t* as possible providers. */ + /** List of alpm_pkg_t* as possible providers */ alpm_list_t *providers; - /** What providers provide for. */ + /** What providers provide for */ alpm_depend_t *depend; } alpm_question_select_provider_t; +/** Should a key be imported? */ typedef struct _alpm_question_import_key_t { - /** Type of question. */ + /** Type of question */ alpm_question_type_t type; - /** Answer: whether or not to import key. */ + /** Answer: whether or not to import key */ int import; - /** The key to import. */ + /** The key to import */ alpm_pgpkey_t *key; } alpm_question_import_key_t; /** * Questions. - * This is an union passed to the callback, that allows the frontend to know + * This is an union passed to the callback that allows the frontend to know * which type of question was triggered (via type). It is then possible to * typecast the pointer to the right structure, or use the union field, in order * to access question-specific data. */ typedef union _alpm_question_t { + /** The type of question. It's always safe to access this. */ alpm_question_type_t type; + /** A question that can represent any question. + * It's always safe to access this. */ alpm_question_any_t any; + /** Should target in ignorepkg be installed anyway? */ alpm_question_install_ignorepkg_t install_ignorepkg; + /** Should a package be replaced? */ alpm_question_replace_t replace; + /** Should a conflicting package be removed? */ alpm_question_conflict_t conflict; + /** Should a corrupted package be deleted? */ alpm_question_corrupted_t corrupted; + /** Should unresolvable targets be removed from the transaction? */ alpm_question_remove_pkgs_t remove_pkgs; + /** Provider selection */ alpm_question_select_provider_t select_provider; + /** Should a key be imported? */ alpm_question_import_key_t import_key; } alpm_question_t; -/** Question callback */ +/** Question callback. + * + * This callback allows user to give input and decide what to do during certain events + * @param question the question being asked. + */ typedef void (*alpm_cb_question)(alpm_question_t *); -/** Progress */ +/** An enum over different kinds of progress alerts. */ typedef enum _alpm_progress_t { + /** Package install */ ALPM_PROGRESS_ADD_START, + /** Package upgrade */ ALPM_PROGRESS_UPGRADE_START, + /** Package downgrade */ ALPM_PROGRESS_DOWNGRADE_START, + /** Package reinstall */ ALPM_PROGRESS_REINSTALL_START, + /** Package removal */ ALPM_PROGRESS_REMOVE_START, + /** Conflict checking */ ALPM_PROGRESS_CONFLICTS_START, + /** Diskspace checking */ ALPM_PROGRESS_DISKSPACE_START, + /** Package Integrity checking */ ALPM_PROGRESS_INTEGRITY_START, + /** Loading packages from disk */ ALPM_PROGRESS_LOAD_START, + /** Checking signatures of packages */ ALPM_PROGRESS_KEYRING_START } alpm_progress_t; +/** Progress callback + * + * Alert the front end about the progress of certain events. + * Allows the implementation of loading bars for events that + * make take a while to complete. + * @param progress the kind of event that is progressing + * @param pkg for package operations, the name of the package being operated on + * @param percent the percent completion of the action + * @param howmany the total amount of items in the action + * @param current the current amount of items completed + */ /** Progress callback */ -typedef void (*alpm_cb_progress)(alpm_progress_t, const char *, int, size_t, size_t); +typedef void (*alpm_cb_progress)(alpm_progress_t progress, const char *pkg, + int percent, size_t howmany, size_t current); /* * Downloading */ -/* File download events. +/** File download events. * These events are reported by ALPM via download callback. */ -typedef enum { - ALPM_DOWNLOAD_INIT, /* alpm initializes file download logic */ - ALPM_DOWNLOAD_PROGRESS, /* download progress reported */ - ALPM_DOWNLOAD_COMPLETED /* alpm is about to release data related to the file */ +typedef enum _alpm_download_event_type_t { + /** A download was started */ + ALPM_DOWNLOAD_INIT, + /** A download made progress */ + ALPM_DOWNLOAD_PROGRESS, + /** A download completed */ + ALPM_DOWNLOAD_COMPLETED } alpm_download_event_type_t; -typedef struct { - int optional; /* whether this file is optional and thus the errors could be ignored */ +/** Context struct for when a download starts. */ +typedef struct _alpm_download_event_init_t { + /** whether this file is optional and thus the errors could be ignored */ + int optional; } alpm_download_event_init_t; -typedef struct { - off_t downloaded; /* amount of data downloaded */ - off_t total; /* total amount need to be downloaded */ +/** Context struct for when a download progresses. */ +typedef struct _alpm_download_event_progress_t { + /** Amount of data downloaded */ + off_t downloaded; + /** Total amount need to be downloaded */ + off_t total; } alpm_download_event_progress_t; -typedef struct { - /* total bytes in file */ + +/** Context struct for when a download completes. */ +typedef struct _alpm_download_event_completed_t { + /** Total bytes in file */ off_t total; - /* download result code: + /** download result code: * 0 - download completed successfully * 1 - the file is up-to-date * -1 - error @@ -1098,6 +1103,10 @@ typedef struct { typedef void (*alpm_cb_download)(const char *filename, alpm_download_event_type_t event, void *data); + +/** Total Download callback. + * @param total amount that will be downloaded during \link alpm_trans_commit \endlink. + */ typedef void (*alpm_cb_totaldl)(off_t total); /** A callback for downloading files @@ -1110,6 +1119,100 @@ typedef void (*alpm_cb_totaldl)(off_t total); typedef int (*alpm_cb_fetch)(const char *url, const char *localpath, int force); +/* End of alpm_cb */ +/** @} */ + + +/* + * Enumerations + * These ones are used in multiple contexts, so are forward-declared. + */ + +/** Package install reasons. */ +typedef enum _alpm_pkgreason_t { + /** Explicitly requested by the user. */ + ALPM_PKG_REASON_EXPLICIT = 0, + /** Installed as a dependency for another package. */ + ALPM_PKG_REASON_DEPEND = 1 +} alpm_pkgreason_t; + +/** Location a package object was loaded from. */ +typedef enum _alpm_pkgfrom_t { + ALPM_PKG_FROM_FILE = 1, + ALPM_PKG_FROM_LOCALDB, + ALPM_PKG_FROM_SYNCDB +} alpm_pkgfrom_t; + +/** Method used to validate a package. */ +typedef enum _alpm_pkgvalidation_t { + ALPM_PKG_VALIDATION_UNKNOWN = 0, + ALPM_PKG_VALIDATION_NONE = (1 << 0), + ALPM_PKG_VALIDATION_MD5SUM = (1 << 1), + ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2), + ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) +} alpm_pkgvalidation_t; + +/* + * Structures + */ + +/** Package group */ +typedef struct _alpm_group_t { + /** group name */ + char *name; + /** list of alpm_pkg_t packages */ + alpm_list_t *packages; +} alpm_group_t; + +/** File in a package */ +typedef struct _alpm_file_t { + char *name; + off_t size; + mode_t mode; +} alpm_file_t; + +/** Package filelist container */ +typedef struct _alpm_filelist_t { + size_t count; + alpm_file_t *files; +} alpm_filelist_t; + +/** Local package or package file backup entry */ +typedef struct _alpm_backup_t { + char *name; + char *hash; +} alpm_backup_t; + +/* + * Logging facilities + */ + +/** \addtogroup alpm_log Logging Functions + * @brief Functions to log using libalpm + * @{ + */ + +/** Logging Levels */ +typedef enum _alpm_loglevel_t { + ALPM_LOG_ERROR = 1, + ALPM_LOG_WARNING = (1 << 1), + ALPM_LOG_DEBUG = (1 << 2), + ALPM_LOG_FUNCTION = (1 << 3) +} alpm_loglevel_t; + +typedef void (*alpm_cb_log)(alpm_loglevel_t, const char *, va_list); + +/** A printf-like function for logging. + * @param handle the context handle + * @param prefix caller-specific prefix for the log + * @param fmt output format + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int alpm_logaction(alpm_handle_t *handle, const char *prefix, + const char *fmt, ...) __attribute__((format(printf, 3, 4))); + +/** @} */ + /** Fetch a list of remote packages. * @param handle the context handle * @param urls list of package URLs to download -- 2.29.2
--- lib/libalpm/alpm.h | 468 ++++++++++++++++++++++++--------------------- 1 file changed, 249 insertions(+), 219 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index a8d48432..c71c275f 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -94,6 +94,38 @@ typedef struct __alpm_pkg_t alpm_pkg_t; /** Transaction structure used internally by libalpm */ typedef struct __alpm_trans_t alpm_trans_t; +/* + * Structures + */ + +/** Package group */ +typedef struct _alpm_group_t { + /** group name */ + char *name; + /** list of alpm_pkg_t packages */ + alpm_list_t *packages; +} alpm_group_t; + +/** File in a package */ +typedef struct _alpm_file_t { + char *name; + off_t size; + mode_t mode; +} alpm_file_t; + +/** Package filelist container */ +typedef struct _alpm_filelist_t { + size_t count; + alpm_file_t *files; +} alpm_filelist_t; + +/** Local package or package file backup entry */ +typedef struct _alpm_backup_t { + char *name; + char *hash; +} alpm_backup_t; + + /** @addtogroup alpm_api ALPM * @brief The libalpm Public API @@ -1123,6 +1155,223 @@ typedef int (*alpm_cb_fetch)(const char *url, const char *localpath, /** @} */ +/** @addtogroup alpm_databases Database + * @brief Functions to query and manipulate the database of libalpm. + * @{ + */ + +/** Get the database of locally installed packages. + * The returned pointer points to an internal structure + * of libalpm which should only be manipulated through + * libalpm functions. + * @return a reference to the local database + */ +alpm_db_t *alpm_get_localdb(alpm_handle_t *handle); + +/** Get the list of sync databases. + * Returns a list of alpm_db_t structures, one for each registered + * sync database. + * + * @param handle the context handle + * @return a reference to an internal list of alpm_db_t structures + */ +alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle); + +/** Register a sync database of packages. + * Databases can not be registered when there is an active transaction. + * + * @param handle the context handle + * @param treename the name of the sync repository + * @param level what level of signature checking to perform on the + * database; note that this must be a '.sig' file type verification + * @return an alpm_db_t* on success (the value), NULL on error + */ +alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename, + int level); + +/** Unregister all package databases. + * Databases can not be unregistered while there is an active transaction. + * + * @param handle the context handle + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int alpm_unregister_all_syncdbs(alpm_handle_t *handle); + +/** Unregister a package database. + * Databases can not be unregistered when there is an active transaction. + * + * @param db pointer to the package database to unregister + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int alpm_db_unregister(alpm_db_t *db); + +/** Get the name of a package database. + * @param db pointer to the package database + * @return the name of the package database, NULL on error + */ +const char *alpm_db_get_name(const alpm_db_t *db); + +/** Get the signature verification level for a database. + * Will return the default verification level if this database is set up + * with ALPM_SIG_USE_DEFAULT. + * @param db pointer to the package database + * @return the signature verification level + */ +int alpm_db_get_siglevel(alpm_db_t *db); + +/** Check the validity of a database. + * This is most useful for sync databases and verifying signature status. + * If invalid, the handle error code will be set accordingly. + * @param db pointer to the package database + * @return 0 if valid, -1 if invalid (pm_errno is set accordingly) + */ +int alpm_db_get_valid(alpm_db_t *db); + +/** @name Server accessors + * @{ + */ + +/** Get the list of servers assigned to this db. + * @param db pointer to the database to get the servers from + * @return a char* list of servers + */ +alpm_list_t *alpm_db_get_servers(const alpm_db_t *db); + +/** Sets the list of servers for the database to use. + * @param db the database to set the servers + * @param servers a char* list of servers. Note: the database will + * take ownership of the list and it should no longer be + * freed by the caller + */ +int alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers); + +/** Add a download server to a database. + * @param db database pointer + * @param url url of the server + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int alpm_db_add_server(alpm_db_t *db, const char *url); + +/** Remove a download server from a database. + * @param db database pointer + * @param url url of the server + * @return 0 on success, 1 on server not present, + * -1 on error (pm_errno is set accordingly) + */ +int alpm_db_remove_server(alpm_db_t *db, const char *url); + +/* End of server accessors */ +/** @} */ + +/** Update package databases. + * + * An update of the package databases in the list \a dbs will be attempted. + * Unless \a force is true, the update will only be performed if the remote + * databases were modified since the last update. + * + * This operation requires a database lock, and will return an applicable error + * if the lock could not be obtained. + * + * Example: + * @code + * alpm_list_t *dbs = alpm_get_syncdbs(config->handle); + * ret = alpm_db_update(config->handle, dbs, force); + * if(ret < 0) { + * pm_printf(ALPM_LOG_ERROR, _("failed to synchronize all databases (%s)\n"), + * alpm_strerror(alpm_errno(config->handle))); + * } + * @endcode + * + * @note After a successful update, the \link alpm_db_get_pkgcache() + * package cache \endlink will be invalidated + * @param handle the context handle + * @param dbs list of package databases to update + * @param force if true, then forces the update, otherwise update only in case + * the databases aren't up to date + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int alpm_db_update(alpm_handle_t *handle, alpm_list_t *dbs, int force); + +/** Get a package entry from a package database. + * Looking up a package is O(1) and will be significantly faster than + * iterating over the pkgcahe. + * @param db pointer to the package database to get the package from + * @param name of the package + * @return the package entry on success, NULL on error + */ +alpm_pkg_t *alpm_db_get_pkg(alpm_db_t *db, const char *name); + +/** Get the package cache of a package database. + * This is a list of all packages the db contains. + * @param db pointer to the package database to get the package from + * @return the list of packages on success, NULL on error + */ +alpm_list_t *alpm_db_get_pkgcache(alpm_db_t *db); + +/** Get a group entry from a package database. + * Looking up a group is O(1) and will be significantly faster than + * iterating over the groupcahe. + * @param db pointer to the package database to get the group from + * @param name of the group + * @return the groups entry on success, NULL on error + */ +alpm_group_t *alpm_db_get_group(alpm_db_t *db, const char *name); + +/** Get the group cache of a package database. + * @param db pointer to the package database to get the group from + * @return the list of groups on success, NULL on error + */ +alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db); + +/** Searches a database with regular expressions. + * @param db pointer to the package database to search in + * @param needles a list of regular expressions to search for + * @param ret pointer to list for storing packages matching all + * regular expressions - must point to an empty (NULL) alpm_list_t *. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int alpm_db_search(alpm_db_t *db, const alpm_list_t *needles, + alpm_list_t **ret); + +/** The usage level of a database. */ +typedef enum _alpm_db_usage_t { + /** Enable refreshes for this database */ + ALPM_DB_USAGE_SYNC = 1, + /** Enable search for this database */ + ALPM_DB_USAGE_SEARCH = (1 << 1), + /** Enable installing packages from this database */ + ALPM_DB_USAGE_INSTALL = (1 << 2), + /** Enable sysupgrades with this database */ + ALPM_DB_USAGE_UPGRADE = (1 << 3), + /** Enable all usage levels */ + ALPM_DB_USAGE_ALL = (1 << 4) - 1, +} alpm_db_usage_t; + +/** @name Usage accessors + * @{ + */ + +/** Sets the usage of a database. + * @param db pointer to the package database to set the status for + * @param usage a bitmask of alpm_db_usage_t values + * @return 0 on success, or -1 on error + */ +int alpm_db_set_usage(alpm_db_t *db, int usage); + +/** Gets the usage of a database. + * @param db pointer to the package database to get the status of + * @param usage pointer to an alpm_db_usage_t to store db's status + * @return 0 on success, or -1 on error + */ +int alpm_db_get_usage(alpm_db_t *db, int *usage); + +/* End of usage accessors */ +/** @} */ + +/* End of alpm_databases */ +/** @} */ + + /* * Enumerations * These ones are used in multiple contexts, so are forward-declared. @@ -1152,37 +1401,6 @@ typedef enum _alpm_pkgvalidation_t { ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) } alpm_pkgvalidation_t; -/* - * Structures - */ - -/** Package group */ -typedef struct _alpm_group_t { - /** group name */ - char *name; - /** list of alpm_pkg_t packages */ - alpm_list_t *packages; -} alpm_group_t; - -/** File in a package */ -typedef struct _alpm_file_t { - char *name; - off_t size; - mode_t mode; -} alpm_file_t; - -/** Package filelist container */ -typedef struct _alpm_filelist_t { - size_t count; - alpm_file_t *files; -} alpm_filelist_t; - -/** Local package or package file backup entry */ -typedef struct _alpm_backup_t { - char *name; - char *hash; -} alpm_backup_t; - /* * Logging facilities */ @@ -1405,194 +1623,6 @@ int alpm_option_set_parallel_downloads(alpm_handle_t *handle, unsigned int num_s /** @} */ -/** @addtogroup alpm_api_databases Database Functions - * Functions to query and manipulate the database of libalpm. - * @{ - */ - -/** Get the database of locally installed packages. - * The returned pointer points to an internal structure - * of libalpm which should only be manipulated through - * libalpm functions. - * @return a reference to the local database - */ -alpm_db_t *alpm_get_localdb(alpm_handle_t *handle); - -/** Get the list of sync databases. - * Returns a list of alpm_db_t structures, one for each registered - * sync database. - * @param handle the context handle - * @return a reference to an internal list of alpm_db_t structures - */ -alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle); - -/** Register a sync database of packages. - * @param handle the context handle - * @param treename the name of the sync repository - * @param level what level of signature checking to perform on the - * database; note that this must be a '.sig' file type verification - * @return an alpm_db_t* on success (the value), NULL on error - */ -alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename, - int level); - -/** Unregister all package databases. - * @param handle the context handle - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int alpm_unregister_all_syncdbs(alpm_handle_t *handle); - -/** Unregister a package database. - * @param db pointer to the package database to unregister - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int alpm_db_unregister(alpm_db_t *db); - -/** Get the name of a package database. - * @param db pointer to the package database - * @return the name of the package database, NULL on error - */ -const char *alpm_db_get_name(const alpm_db_t *db); - -/** Get the signature verification level for a database. - * Will return the default verification level if this database is set up - * with ALPM_SIG_USE_DEFAULT. - * @param db pointer to the package database - * @return the signature verification level - */ -int alpm_db_get_siglevel(alpm_db_t *db); - -/** Check the validity of a database. - * This is most useful for sync databases and verifying signature status. - * If invalid, the handle error code will be set accordingly. - * @param db pointer to the package database - * @return 0 if valid, -1 if invalid (pm_errno is set accordingly) - */ -int alpm_db_get_valid(alpm_db_t *db); - -/** @name Accessors to the list of servers for a database. - * @{ - */ - -/** Get the list of servers assigned to this db. - * @param db pointer to the database to get the servers from - * @return a char* list of servers - */ -alpm_list_t *alpm_db_get_servers(const alpm_db_t *db); - -/** Sets the list of servers for the database to use. - * @param db the database to set the servers - * @param a char* list of servers. Note: the database will - * take ownership of the list and it should no longer be - * freed by the caller - */ -int alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers); - -/** Add a download server to a database. - * @param db database pointer - * @param url url of the server - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int alpm_db_add_server(alpm_db_t *db, const char *url); - -/** Remove a download server from a database. - * @param db database pointer - * @param url url of the server - * @return 0 on success, 1 on server not present, - * -1 on error (pm_errno is set accordingly) - */ -int alpm_db_remove_server(alpm_db_t *db, const char *url); -/** @} */ - -/** Update package databases - * - * An update of the package databases in the list \a dbs will be attempted. - * Unless \a force is true, the update will only be performed if the remote - * databases were modified since the last update. - * - * This operation requires a database lock, and will return an applicable error - * if the lock could not be obtained. - * - * Example: - * @code - * alpm_list_t *dbs = alpm_get_syncdbs(); - * ret = alpm_db_update(config->handle, dbs, force); - * if(ret < 0) { - * pm_printf(ALPM_LOG_ERROR, _("failed to synchronize all databases (%s)\n"), - * alpm_strerror(alpm_errno(config->handle))); - * } - * @endcode - * - * @note After a successful update, the \link alpm_db_get_pkgcache() - * package cache \endlink will be invalidated - * @param handle the context handle - * @param dbs list of package databases to update - * @param force if true, then forces the update, otherwise update only in case - * the databases aren't up to date - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int alpm_db_update(alpm_handle_t *handle, alpm_list_t *dbs, int force); - -/** Get a package entry from a package database. - * @param db pointer to the package database to get the package from - * @param name of the package - * @return the package entry on success, NULL on error - */ -alpm_pkg_t *alpm_db_get_pkg(alpm_db_t *db, const char *name); - -/** Get the package cache of a package database. - * @param db pointer to the package database to get the package from - * @return the list of packages on success, NULL on error - */ -alpm_list_t *alpm_db_get_pkgcache(alpm_db_t *db); - -/** Get a group entry from a package database. - * @param db pointer to the package database to get the group from - * @param name of the group - * @return the groups entry on success, NULL on error - */ -alpm_group_t *alpm_db_get_group(alpm_db_t *db, const char *name); - -/** Get the group cache of a package database. - * @param db pointer to the package database to get the group from - * @return the list of groups on success, NULL on error - */ -alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db); - -/** Searches a database with regular expressions. - * @param db pointer to the package database to search in - * @param needles a list of regular expressions to search for - * @param ret pointer to list for storing packages matching all - * regular expressions - must point to an empty (NULL) alpm_list_t *. - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int alpm_db_search(alpm_db_t *db, const alpm_list_t *needles, - alpm_list_t **ret); - -typedef enum _alpm_db_usage_t { - ALPM_DB_USAGE_SYNC = 1, - ALPM_DB_USAGE_SEARCH = (1 << 1), - ALPM_DB_USAGE_INSTALL = (1 << 2), - ALPM_DB_USAGE_UPGRADE = (1 << 3), - ALPM_DB_USAGE_ALL = (1 << 4) - 1, -} alpm_db_usage_t; - -/** Sets the usage of a database. - * @param db pointer to the package database to set the status for - * @param usage a bitmask of alpm_db_usage_t values - * @return 0 on success, or -1 on error - */ -int alpm_db_set_usage(alpm_db_t *db, int usage); - -/** Gets the usage of a database. - * @param db pointer to the package database to get the status of - * @param usage pointer to an alpm_db_usage_t to store db's status - * @return 0 on success, or -1 on error - */ -int alpm_db_get_usage(alpm_db_t *db, int *usage); - -/** @} */ - /** @addtogroup alpm_api_packages Package Functions * Functions to manipulate libalpm packages * @{ -- 2.29.2
--- lib/libalpm/alpm.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index c71c275f..ea690abc 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -1412,13 +1412,27 @@ typedef enum _alpm_pkgvalidation_t { /** Logging Levels */ typedef enum _alpm_loglevel_t { - ALPM_LOG_ERROR = 1, - ALPM_LOG_WARNING = (1 << 1), - ALPM_LOG_DEBUG = (1 << 2), - ALPM_LOG_FUNCTION = (1 << 3) + /** Error */ + ALPM_LOG_ERROR = 1, + /** Warning */ + ALPM_LOG_WARNING = (1 << 1), + /** Debug */ + ALPM_LOG_DEBUG = (1 << 2), + /** Function */ + ALPM_LOG_FUNCTION = (1 << 3) } alpm_loglevel_t; -typedef void (*alpm_cb_log)(alpm_loglevel_t, const char *, va_list); + +/** The callback type for logging. + * + * libalpm will call this function whenever something is to be logged. + * many libalpm will produce log output. Additionally any calls to \link alpm_logaction + * \endlink will also call this callback. + * @param level the currently set loglevel + * @param fmt the printf like format string + * @param args printf like arguments + */ +typedef void (*alpm_cb_log)(alpm_loglevel_t level, const char *fmt, va_list args); /** A printf-like function for logging. * @param handle the context handle @@ -1429,6 +1443,7 @@ typedef void (*alpm_cb_log)(alpm_loglevel_t, const char *, va_list); int alpm_logaction(alpm_handle_t *handle, const char *prefix, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +/* End of alpm_log */ /** @} */ /** Fetch a list of remote packages. -- 2.29.2
--- lib/libalpm/alpm.h | 164 ++++++++++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 68 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index ea690abc..5ee99711 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -1368,43 +1368,11 @@ int alpm_db_get_usage(alpm_db_t *db, int *usage); /* End of usage accessors */ /** @} */ + /* End of alpm_databases */ /** @} */ -/* - * Enumerations - * These ones are used in multiple contexts, so are forward-declared. - */ - -/** Package install reasons. */ -typedef enum _alpm_pkgreason_t { - /** Explicitly requested by the user. */ - ALPM_PKG_REASON_EXPLICIT = 0, - /** Installed as a dependency for another package. */ - ALPM_PKG_REASON_DEPEND = 1 -} alpm_pkgreason_t; - -/** Location a package object was loaded from. */ -typedef enum _alpm_pkgfrom_t { - ALPM_PKG_FROM_FILE = 1, - ALPM_PKG_FROM_LOCALDB, - ALPM_PKG_FROM_SYNCDB -} alpm_pkgfrom_t; - -/** Method used to validate a package. */ -typedef enum _alpm_pkgvalidation_t { - ALPM_PKG_VALIDATION_UNKNOWN = 0, - ALPM_PKG_VALIDATION_NONE = (1 << 0), - ALPM_PKG_VALIDATION_MD5SUM = (1 << 1), - ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2), - ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) -} alpm_pkgvalidation_t; - -/* - * Logging facilities - */ - /** \addtogroup alpm_log Logging Functions * @brief Functions to log using libalpm * @{ @@ -1446,17 +1414,6 @@ int alpm_logaction(alpm_handle_t *handle, const char *prefix, /* End of alpm_log */ /** @} */ -/** Fetch a list of remote packages. - * @param handle the context handle - * @param urls list of package URLs to download - * @param fetched list of filepaths to the fetched packages, each item - * corresponds to one in `urls` list. This is an output parameter, - * the caller should provide a pointer to an empty list - * (*fetched === NULL) and the callee fills the list with data. - * @return 0 on success or -1 on failure - */ -int alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls, - alpm_list_t **fetched); /** @addtogroup alpm_api_options Options * Libalpm option getters and setters @@ -1638,11 +1595,44 @@ int alpm_option_set_parallel_downloads(alpm_handle_t *handle, unsigned int num_s /** @} */ -/** @addtogroup alpm_api_packages Package Functions +/** @addtogroup alpm_packages Package Functions * Functions to manipulate libalpm packages * @{ */ +/** Package install reasons. */ +typedef enum _alpm_pkgreason_t { + /** Explicitly requested by the user. */ + ALPM_PKG_REASON_EXPLICIT = 0, + /** Installed as a dependency for another package. */ + ALPM_PKG_REASON_DEPEND = 1 +} alpm_pkgreason_t; + +/** Location a package object was loaded from. */ +typedef enum _alpm_pkgfrom_t { + /** Loaded from a file via \link alpm_pkg_load \endlink */ + ALPM_PKG_FROM_FILE = 1, + /** From the local database */ + ALPM_PKG_FROM_LOCALDB, + /** From a sync database */ + ALPM_PKG_FROM_SYNCDB +} alpm_pkgfrom_t; + + +/** Method used to validate a package. */ +typedef enum _alpm_pkgvalidation_t { + /** The package's validation type is unknown */ + ALPM_PKG_VALIDATION_UNKNOWN = 0, + /** The package does not have any validation */ + ALPM_PKG_VALIDATION_NONE = (1 << 0), + /** The package is validated with md5 */ + ALPM_PKG_VALIDATION_MD5SUM = (1 << 1), + /** The package is validated with sha256 */ + ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2), + /** The package is validated with a PGP signature */ + ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3) +} alpm_pkgvalidation_t; + /** Create a package from a file. * If full is false, the archive is read only until all necessary * metadata is found. If it is true, the entire archive is read, which @@ -1660,6 +1650,18 @@ int alpm_option_set_parallel_downloads(alpm_handle_t *handle, unsigned int num_s int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full, int level, alpm_pkg_t **pkg); +/** Fetch a list of remote packages. + * @param handle the context handle + * @param urls list of package URLs to download + * @param fetched list of filepaths to the fetched packages, each item + * corresponds to one in `urls` list. This is an output parameter, + * the caller should provide a pointer to an empty list + * (*fetched === NULL) and the callee fills the list with data. + * @return 0 on success or -1 on failure + */ +int alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls, + alpm_list_t **fetched); + /** Find a package in a list by name. * @param haystack a list of alpm_pkg_t * @param needle the package name @@ -1668,6 +1670,8 @@ int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full, alpm_pkg_t *alpm_pkg_find(alpm_list_t *haystack, const char *needle); /** Free a package. + * Only packages loaded with \link alpm_pkg_load \endlink can be freed. + * Packages from databases will be freed by libalpm when they are unregistered. * @param pkg package pointer to free * @return 0 on success, -1 on error (pm_errno is set accordingly) */ @@ -1724,6 +1728,9 @@ int alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg); * Any pointer returned by these functions points to internal structures * allocated by libalpm. They should not be freed nor modified in any * way. + * + * For loaded packages, they will be freed when \link alpm_pkg_free \endlink is called. + * For database packages, they will be freed when the database is unregistered. * @{ */ @@ -1927,8 +1934,36 @@ int alpm_pkg_get_sig(alpm_pkg_t *pkg, unsigned char **sig, size_t *sig_len); */ int alpm_pkg_get_validation(alpm_pkg_t *pkg); +/** Returns whether the package has an install scriptlet. + * @return 0 if FALSE, TRUE otherwise + */ +int alpm_pkg_has_scriptlet(alpm_pkg_t *pkg); + +/** Returns the size of the files that will be downloaded to install a + * package. + * @param newpkg the new package to upgrade to + * @return the size of the download + */ +off_t alpm_pkg_download_size(alpm_pkg_t *newpkg); + +/** Set install reason for a package in the local database. + * The provided package object must be from the local database or this method + * will fail. The write to the local database is performed immediately. + * @param pkg the package to update + * @param reason the new install reason + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int alpm_pkg_set_reason(alpm_pkg_t *pkg, alpm_pkgreason_t reason); + + /* End of alpm_pkg_t accessors */ -/* @} */ +/** @} */ + + +/** @name Changelog functions + * Functions for reading the changelog + * @{ + */ /** Open a package changelog for reading. * Similar to fopen in functionality, except that the returned 'file @@ -1953,10 +1988,20 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size, /** Close a package changelog for reading. * @param pkg the package to close the changelog of (either file or db) + * @param fp the 'file stream' to the package changelog to close * @return 0 on success, -1 on error */ int alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp); +/* End of changelog accessors */ +/** @} */ + + +/** @name Mtree functions + * Functions for reading the mtree + * @{ + */ + /** Open a package mtree file for reading. * @param pkg the local package to read the mtree of * @return an archive structure for the package mtree file @@ -1974,35 +2019,18 @@ int alpm_pkg_mtree_next(const alpm_pkg_t *pkg, struct archive *archive, /** Close a package mtree file. * @param pkg the local package to close the mtree of - * @param the archive to close + * @param archive the archive to close */ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive); -/** Returns whether the package has an install scriptlet. - * @return 0 if FALSE, TRUE otherwise - */ -int alpm_pkg_has_scriptlet(alpm_pkg_t *pkg); - -/** Returns the size of the files that will be downloaded to install a - * package. - * @param newpkg the new package to upgrade to - * @return the size of the download - */ -off_t alpm_pkg_download_size(alpm_pkg_t *newpkg); - -/** Set install reason for a package in the local database. - * The provided package object must be from the local database or this method - * will fail. The write to the local database is performed immediately. - * @param pkg the package to update - * @param reason the new install reason - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int alpm_pkg_set_reason(alpm_pkg_t *pkg, alpm_pkgreason_t reason); +/* End of mtree accessors */ +/** @} */ -/* End of alpm_pkg */ +/* End of alpm_packages */ /** @} */ + /* * Filelists */ -- 2.29.2
--- lib/libalpm/alpm.h | 102 +++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 5ee99711..30bfb06d 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -94,44 +94,82 @@ typedef struct __alpm_pkg_t alpm_pkg_t; /** Transaction structure used internally by libalpm */ typedef struct __alpm_trans_t alpm_trans_t; -/* - * Structures +/** @addtogroup alpm_api ALPM + * @brief The libalpm Public API + * @{ */ -/** Package group */ -typedef struct _alpm_group_t { - /** group name */ - char *name; - /** list of alpm_pkg_t packages */ - alpm_list_t *packages; -} alpm_group_t; +/** @addtogroup alpm_files Files + * @brief Functions for package files + * @{ + */ /** File in a package */ typedef struct _alpm_file_t { - char *name; - off_t size; - mode_t mode; + /** Name of the file */ + char *name; + /** Size of the file */ + off_t size; + /** The file's permissions */ + mode_t mode; } alpm_file_t; /** Package filelist container */ typedef struct _alpm_filelist_t { - size_t count; - alpm_file_t *files; + /** Amount of files in the array */ + size_t count; + /** An array of files */ + alpm_file_t *files; } alpm_filelist_t; /** Local package or package file backup entry */ typedef struct _alpm_backup_t { - char *name; - char *hash; + /** Name of the file (without .pacsave extension) */ + char *name; + /** Hash of the filename (used internally) */ + char *hash; } alpm_backup_t; +/** Determines whether a package filelist contains a given path. + * The provided path should be relative to the install root with no leading + * slashes, e.g. "etc/localtime". When searching for directories, the path must + * have a trailing slash. + * @param filelist a pointer to a package filelist + * @param path the path to search for in the package + * @return a pointer to the matching file or NULL if not found + */ +alpm_file_t *alpm_filelist_contains(alpm_filelist_t *filelist, const char *path); + +/* End of alpm_files */ +/** @} */ -/** @addtogroup alpm_api ALPM - * @brief The libalpm Public API +/** @addtogroup alpm_groups Groups + * @brief Functions for package groups * @{ */ +/** Package group */ +typedef struct _alpm_group_t { + /** group name */ + char *name; + /** list of alpm_pkg_t packages */ + alpm_list_t *packages; +} alpm_group_t; + +/** Find group members across a list of databases. + * If a member exists in several databases, only the first database is used. + * IgnorePkg is also handled. + * @param dbs the list of alpm_db_t * + * @param name the name of the group + * @return the list of alpm_pkg_t * (caller is responsible for alpm_list_free) + */ +alpm_list_t *alpm_find_group_pkgs(alpm_list_t *dbs, const char *name); + +/* End of alpm_groups */ +/** @} */ + + /** @addtogroup alpm_errors Error Codes * Error codes returned by libalpm. * @{ @@ -2031,34 +2069,6 @@ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive); /** @} */ -/* - * Filelists - */ - -/** Determines whether a package filelist contains a given path. - * The provided path should be relative to the install root with no leading - * slashes, e.g. "etc/localtime". When searching for directories, the path must - * have a trailing slash. - * @param filelist a pointer to a package filelist - * @param path the path to search for in the package - * @return a pointer to the matching file or NULL if not found - */ -alpm_file_t *alpm_filelist_contains(alpm_filelist_t *filelist, const char *path); - - -/* - * Groups - */ - -/** Find group members across a list of databases. - * If a member exists in several databases, only the first database is used. - * IgnorePkg is also handled. - * @param dbs the list of alpm_db_t * - * @param name the name of the group - * @return the list of alpm_pkg_t * (caller is responsible for alpm_list_free) - */ -alpm_list_t *alpm_find_group_pkgs(alpm_list_t *dbs, const char *name); - /* * Sync */ -- 2.29.2
--- lib/libalpm/alpm.h | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 30bfb06d..76ae5722 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -2068,18 +2068,26 @@ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive); /* End of alpm_packages */ /** @} */ - -/* - * Sync - */ - /** Check for new version of pkg in sync repos * (only the first occurrence is considered in sync) */ alpm_pkg_t *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync); -/** @addtogroup alpm_api_trans Transaction Functions - * Functions to manipulate libalpm transactions +/** @addtogroup alpm_trans Transaction + * @brief Functions to manipulate libalpm transactions + * + * Transactions are the way to add/remove packages to/from the system. + * Only one transaction can exist at a time. + * + * The basic workflow of a transaction is to: + * + * - Initialize with \link alpm_trans_init \endlink + * - Choose which packages to add with \link alpm_add_pkg \endlink and \link alpm_remove_pkg \endlink + * - Prepare the transaction with \link alpm_trans_prepare \endlink + * - Commit the transaction with \link alpm_trans_commit \endlink + * - Release the transaction with \link alpm_trans_release \endlink + * + * A transaction can be released at any time. A transaction does not have to be committed. * @{ */ @@ -2172,10 +2180,11 @@ int alpm_trans_interrupt(alpm_handle_t *handle); * @return 0 on success, -1 on error (pm_errno is set accordingly) */ int alpm_trans_release(alpm_handle_t *handle); -/** @} */ -/** @name Common Transactions */ -/** @{ */ +/** @name Add/Remove packages + * These functions remove/add packages to the transactions + * @{ + * */ /** Search for packages to upgrade and add them to the transaction. * @param handle the context handle @@ -2186,22 +2195,24 @@ int alpm_sync_sysupgrade(alpm_handle_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. + * \link alpm_trans_release \endlink 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(alpm_handle_t *handle, alpm_pkg_t *pkg); -/** Add a package removal action to the transaction. +/** Add a package removal 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(alpm_handle_t *handle, alpm_pkg_t *pkg); +/* End of add/remove packages */ /** @} */ +/* End of alpm_trans */ /** @} */ /* -- 2.29.2
--- lib/libalpm/alpm.h | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 76ae5722..494a8319 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -2068,11 +2068,6 @@ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive); /* End of alpm_packages */ /** @} */ -/** Check for new version of pkg in sync repos - * (only the first occurrence is considered in sync) - */ -alpm_pkg_t *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync); - /** @addtogroup alpm_trans Transaction * @brief Functions to manipulate libalpm transactions * @@ -2212,20 +2207,25 @@ int alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg); /* End of add/remove packages */ /** @} */ + /* End of alpm_trans */ /** @} */ -/* - * Helpers - */ - -/* checksums */ /** \addtogroup alpm_misc Miscellaneous Functions * @brief Various libalpm functions * @{ */ +/** Check for new version of pkg in syncdbs. + * + * If the same package appears multiple dbs only the first will be checked + * + * This only checks the syncdb for a newer version. It does not access the network at all. + * See \link alpm_db_update \endlink to update a database. + */ +alpm_pkg_t *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync); + /** Get the md5 sum of file. * @param filename name of the file * @return the checksum on success, NULL on error @@ -2238,8 +2238,6 @@ char *alpm_compute_md5sum(const char *filename); */ char *alpm_compute_sha256sum(const char *filename); -/** @} */ - /** Remove the database lock file * @param handle the context handle * @return 0 on success, -1 on error @@ -2248,10 +2246,14 @@ char *alpm_compute_sha256sum(const char *filename); */ int alpm_unlock(alpm_handle_t *handle); +/** Enum of possible compile time features */ enum alpm_caps { - ALPM_CAPABILITY_NLS = (1 << 0), - ALPM_CAPABILITY_DOWNLOADER = (1 << 1), - ALPM_CAPABILITY_SIGNATURES = (1 << 2) + /** localization */ + ALPM_CAPABILITY_NLS = (1 << 0), + /** Ability to download */ + ALPM_CAPABILITY_DOWNLOADER = (1 << 1), + /** Signature checking */ + ALPM_CAPABILITY_SIGNATURES = (1 << 2) }; /** Get the version of library. @@ -2264,6 +2266,9 @@ const char *alpm_version(void); * */ int alpm_capabilities(void); +/* End of alpm_misc */ +/** @} */ + /* End of alpm_api */ /** @} */ -- 2.29.2
--- lib/libalpm/alpm_list.c | 251 --------------------------------- lib/libalpm/alpm_list.h | 299 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 295 insertions(+), 255 deletions(-) diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index fe0c2906..2ecc8e0b 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -32,23 +32,8 @@ #define SYMEXPORT __attribute__((visibility("default"))) #define SYMHIDDEN __attribute__((visibility("internal"))) -/** - * @addtogroup alpm_list List Functions - * @brief Functions to manipulate alpm_list_t lists. - * - * These functions are designed to create, destroy, and modify lists of - * type alpm_list_t. This is an internal list type used by libalpm that is - * publicly exposed for use by frontends if desired. - * - * @{ */ - /* Allocation */ -/** - * @brief Free a list, but not the contained data. - * - * @param list the list to free - */ void SYMEXPORT alpm_list_free(alpm_list_t *list) { alpm_list_t *it = list; @@ -60,12 +45,6 @@ void SYMEXPORT alpm_list_free(alpm_list_t *list) } } -/** - * @brief Free the internal data of a list structure. - * - * @param list the list to free - * @param fn a free function for the internal data - */ void SYMEXPORT alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn) { alpm_list_t *it = list; @@ -83,28 +62,12 @@ void SYMEXPORT alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn) /* Mutators */ -/** - * @brief Add a new item to the end of the list. - * - * @param list the list to add to - * @param data the new item to be added to the list - * - * @return the resultant list - */ alpm_list_t SYMEXPORT *alpm_list_add(alpm_list_t *list, void *data) { alpm_list_append(&list, data); return list; } -/** - * @brief Add a new item to the end of the list. - * - * @param list the list to add to - * @param data the new item to be added to the list - * - * @return the newly added item - */ alpm_list_t SYMEXPORT *alpm_list_append(alpm_list_t **list, void *data) { alpm_list_t *ptr; @@ -131,14 +94,6 @@ alpm_list_t SYMEXPORT *alpm_list_append(alpm_list_t **list, void *data) return ptr; } -/** - * @brief Duplicate and append a string to a list. - * - * @param list the list to append to - * @param data the string to duplicate and append - * - * @return the newly added item - */ alpm_list_t SYMEXPORT *alpm_list_append_strdup(alpm_list_t **list, const char *data) { alpm_list_t *ret; @@ -151,15 +106,6 @@ alpm_list_t SYMEXPORT *alpm_list_append_strdup(alpm_list_t **list, const char *d } } -/** - * @brief Add items to a list in sorted order. - * - * @param list the list to add to - * @param data the new item to be added to the list - * @param fn the comparison function to use to determine order - * - * @return the resultant list - */ alpm_list_t SYMEXPORT *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn) { if(!fn || !list) { @@ -202,17 +148,6 @@ alpm_list_t SYMEXPORT *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_ } } -/** - * @brief Join two lists. - * The two lists must be independent. Do not free the original lists after - * calling this function, as this is not a copy operation. The list pointers - * passed in should be considered invalid after calling this function. - * - * @param first the first list - * @param second the second list - * - * @return the resultant joined list - */ alpm_list_t SYMEXPORT *alpm_list_join(alpm_list_t *first, alpm_list_t *second) { alpm_list_t *tmp; @@ -235,15 +170,6 @@ alpm_list_t SYMEXPORT *alpm_list_join(alpm_list_t *first, alpm_list_t *second) return first; } -/** - * @brief Merge the two sorted sublists into one sorted list. - * - * @param left the first list - * @param right the second list - * @param fn comparison function for determining merge order - * - * @return the resultant list - */ alpm_list_t SYMEXPORT *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn) { @@ -305,15 +231,6 @@ alpm_list_t SYMEXPORT *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, return newlist; } -/** - * @brief Sort a list of size `n` using mergesort algorithm. - * - * @param list the list to sort - * @param n the size of the list - * @param fn the comparison function for determining order - * - * @return the resultant list - */ alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, size_t n, alpm_list_fn_cmp fn) { @@ -339,15 +256,6 @@ alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, size_t n, return list; } -/** - * @brief Remove an item from the list. - * item is not freed; this is the responsibility of the caller. - * - * @param haystack the list to remove the item from - * @param item the item to remove from the list - * - * @return the resultant list - */ alpm_list_t SYMEXPORT *alpm_list_remove_item(alpm_list_t *haystack, alpm_list_t *item) { @@ -385,17 +293,6 @@ alpm_list_t SYMEXPORT *alpm_list_remove_item(alpm_list_t *haystack, return haystack; } - -/** - * @brief Remove an item from the list. - * - * @param haystack the list to remove the item from - * @param needle the data member of the item we're removing - * @param fn the comparison function for searching - * @param data output parameter containing data of the removed item - * - * @return the resultant list - */ alpm_list_t SYMEXPORT *alpm_list_remove(alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn, void **data) { @@ -430,15 +327,6 @@ alpm_list_t SYMEXPORT *alpm_list_remove(alpm_list_t *haystack, return haystack; } -/** - * @brief Remove a string from a list. - * - * @param haystack the list to remove the item from - * @param needle the data member of the item we're removing - * @param data output parameter containing data of the removed item - * - * @return the resultant list - */ alpm_list_t SYMEXPORT *alpm_list_remove_str(alpm_list_t *haystack, const char *needle, char **data) { @@ -446,15 +334,6 @@ alpm_list_t SYMEXPORT *alpm_list_remove_str(alpm_list_t *haystack, (alpm_list_fn_cmp)strcmp, (void **)data); } -/** - * @brief Create a new list without any duplicates. - * - * This does NOT copy data members. - * - * @param list the list to copy - * - * @return a new list containing non-duplicate items - */ alpm_list_t SYMEXPORT *alpm_list_remove_dupes(const alpm_list_t *list) { const alpm_list_t *lp = list; @@ -471,13 +350,6 @@ alpm_list_t SYMEXPORT *alpm_list_remove_dupes(const alpm_list_t *list) return newlist; } -/** - * @brief Copy a string list, including data. - * - * @param list the list to copy - * - * @return a copy of the original list - */ alpm_list_t SYMEXPORT *alpm_list_strdup(const alpm_list_t *list) { const alpm_list_t *lp = list; @@ -492,13 +364,6 @@ alpm_list_t SYMEXPORT *alpm_list_strdup(const alpm_list_t *list) return newlist; } -/** - * @brief Copy a list, without copying data. - * - * @param list the list to copy - * - * @return a copy of the original list - */ alpm_list_t SYMEXPORT *alpm_list_copy(const alpm_list_t *list) { const alpm_list_t *lp = list; @@ -513,16 +378,6 @@ alpm_list_t SYMEXPORT *alpm_list_copy(const alpm_list_t *list) return newlist; } -/** - * @brief Copy a list and copy the data. - * Note that the data elements to be copied should not contain pointers - * and should also be of constant size. - * - * @param list the list to copy - * @param size the size of each data element - * - * @return a copy of the original list, data copied as well - */ alpm_list_t SYMEXPORT *alpm_list_copy_data(const alpm_list_t *list, size_t size) { @@ -546,13 +401,6 @@ alpm_list_t SYMEXPORT *alpm_list_copy_data(const alpm_list_t *list, return newlist; } -/** - * @brief Create a new list in reverse order. - * - * @param list the list to copy - * - * @return a new list in reverse order - */ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list) { const alpm_list_t *lp; @@ -580,14 +428,6 @@ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list) /* Accessors */ -/** - * @brief Return nth element from list (starting from 0). - * - * @param list the list - * @param n the index of the item to find (n < alpm_list_count(list) IS needed) - * - * @return an alpm_list_t node for index `n` - */ alpm_list_t SYMEXPORT *alpm_list_nth(const alpm_list_t *list, size_t n) { const alpm_list_t *i = list; @@ -597,13 +437,6 @@ alpm_list_t SYMEXPORT *alpm_list_nth(const alpm_list_t *list, size_t n) return (alpm_list_t *)i; } -/** - * @brief Get the next element of a list. - * - * @param node the list node - * - * @return the next element, or NULL when no more elements exist - */ inline alpm_list_t SYMEXPORT *alpm_list_next(const alpm_list_t *node) { if(node) { @@ -613,13 +446,6 @@ inline alpm_list_t SYMEXPORT *alpm_list_next(const alpm_list_t *node) } } -/** - * @brief Get the previous element of a list. - * - * @param list the list head - * - * @return the previous element, or NULL when no previous element exist - */ inline alpm_list_t SYMEXPORT *alpm_list_previous(const alpm_list_t *list) { if(list && list->prev->next) { @@ -629,13 +455,6 @@ inline alpm_list_t SYMEXPORT *alpm_list_previous(const alpm_list_t *list) } } -/** - * @brief Get the last item in the list. - * - * @param list the list - * - * @return the last element in the list - */ alpm_list_t SYMEXPORT *alpm_list_last(const alpm_list_t *list) { if(list) { @@ -647,13 +466,6 @@ alpm_list_t SYMEXPORT *alpm_list_last(const alpm_list_t *list) /* Misc */ -/** - * @brief Get the number of items in a list. - * - * @param list the list - * - * @return the number of list items - */ size_t SYMEXPORT alpm_list_count(const alpm_list_t *list) { size_t i = 0; @@ -665,15 +477,6 @@ size_t SYMEXPORT alpm_list_count(const alpm_list_t *list) return i; } -/** - * @brief Find an item in a list. - * - * @param needle the item to search - * @param haystack the list - * @param fn the comparison function for searching (!= NULL) - * - * @return `needle` if found, NULL otherwise - */ void SYMEXPORT *alpm_list_find(const alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn) { @@ -693,30 +496,12 @@ static int ptr_cmp(const void *p, const void *q) return (p != q); } -/** - * @brief Find an item in a list. - * - * Search for the item whose data matches that of the `needle`. - * - * @param needle the data to search for (== comparison) - * @param haystack the list - * - * @return `needle` if found, NULL otherwise - */ void SYMEXPORT *alpm_list_find_ptr(const alpm_list_t *haystack, const void *needle) { return alpm_list_find(haystack, needle, ptr_cmp); } -/** - * @brief Find a string in a list. - * - * @param needle the string to search for - * @param haystack the list - * - * @return `needle` if found, NULL otherwise - */ char SYMEXPORT *alpm_list_find_str(const alpm_list_t *haystack, const char *needle) { @@ -724,20 +509,6 @@ char SYMEXPORT *alpm_list_find_str(const alpm_list_t *haystack, (alpm_list_fn_cmp)strcmp); } -/** - * @brief Find the differences between list `left` and list `right` - * - * The two lists must be sorted. Items only in list `left` are added to the - * `onlyleft` list. Items only in list `right` are added to the `onlyright` - * list. - * - * @param left the first list - * @param right the second list - * @param fn the comparison function - * @param onlyleft pointer to the first result list - * @param onlyright pointer to the second result list - * - */ void SYMEXPORT alpm_list_diff_sorted(const alpm_list_t *left, const alpm_list_t *right, alpm_list_fn_cmp fn, alpm_list_t **onlyleft, alpm_list_t **onlyright) @@ -782,15 +553,6 @@ void SYMEXPORT alpm_list_diff_sorted(const alpm_list_t *left, } -/** - * @brief Find the items in list `lhs` that are not present in list `rhs`. - * - * @param lhs the first list - * @param rhs the second list - * @param fn the comparison function - * - * @return a list containing all items in `lhs` not present in `rhs` - */ alpm_list_t SYMEXPORT *alpm_list_diff(const alpm_list_t *lhs, const alpm_list_t *rhs, alpm_list_fn_cmp fn) { @@ -809,17 +571,6 @@ alpm_list_t SYMEXPORT *alpm_list_diff(const alpm_list_t *lhs, return ret; } -/** - * @brief Copy a list and data into a standard C array of fixed length. - * Note that the data elements are shallow copied so any contained pointers - * will point to the original data. - * - * @param list the list to copy - * @param n the size of the list - * @param size the size of each data element - * - * @return an array version of the original list, data copied as well - */ void SYMEXPORT *alpm_list_to_array(const alpm_list_t *list, size_t n, size_t size) { @@ -840,5 +591,3 @@ void SYMEXPORT *alpm_list_to_array(const alpm_list_t *list, size_t n, } return array; } - -/** @} */ diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h index 38094c7b..1eac3043 100644 --- a/lib/libalpm/alpm_list.h +++ b/lib/libalpm/alpm_list.h @@ -17,6 +17,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + + +/** + * @file alpm_list.h + * @author Pacman Development Team + * @date 7 Dec 2020 + * @brief A doubly linked list for use with libalpm + */ + #ifndef ALPM_LIST_H #define ALPM_LIST_H @@ -31,12 +40,20 @@ extern "C" { #endif /** - * @brief Linked list type used by libalpm. + * @addtogroup alpm_list List Functions + * @brief Functions to manipulate alpm_list_t lists. + * + * These functions are designed to create, destroy, and modify lists of + * type alpm_list_t. This is an internal list type used by libalpm that is + * publicly exposed for use by frontends if desired. * * It is exposed so front ends can use it to prevent the need to reimplement * lists of their own; however, it is not required that the front end uses * it. + * @{ */ + +/** A doubly linked list */ typedef struct __alpm_list_t { /** data held by the list node */ void *data; @@ -46,48 +63,322 @@ typedef struct __alpm_list_t { struct __alpm_list_t *next; } alpm_list_t; +/** Frees a list and its contents */ #define FREELIST(p) do { alpm_list_free_inner(p, free); alpm_list_free(p); p = NULL; } while(0) -typedef void (*alpm_list_fn_free)(void *); /* item deallocation callback */ -typedef int (*alpm_list_fn_cmp)(const void *, const void *); /* item comparison callback */ +/** item deallocation callback. + * @param the item to free + */ +typedef void (*alpm_list_fn_free)(void * item); + +/** item comparison callback */ +typedef int (*alpm_list_fn_cmp)(const void *, const void *); /* allocation */ + +/** Free a list, but not the contained data. + * + * @param list the list to free + */ void alpm_list_free(alpm_list_t *list); + +/** Free the internal data of a list structure but not the list itself. + * + * @param list the list to free + * @param fn a free function for the internal data + */ void alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn); /* item mutators */ + +/** Add a new item to the end of the list. + * + * @param list the list to add to + * @param data the new item to be added to the list + * + * @return the resultant list + */ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data); + +/** + * @brief Add a new item to the end of the list. + * + * @param list the list to add to + * @param data the new item to be added to the list + * + * @return the newly added item + */ alpm_list_t *alpm_list_append(alpm_list_t **list, void *data); + +/** + * @brief Duplicate and append a string to a list. + * + * @param list the list to append to + * @param data the string to duplicate and append + * + * @return the newly added item + */ alpm_list_t *alpm_list_append_strdup(alpm_list_t **list, const char *data); + +/** + * @brief Add items to a list in sorted order. + * + * @param list the list to add to + * @param data the new item to be added to the list + * @param fn the comparison function to use to determine order + * + * @return the resultant list + */ alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn); + +/** + * @brief Join two lists. + * The two lists must be independent. Do not free the original lists after + * calling this function, as this is not a copy operation. The list pointers + * passed in should be considered invalid after calling this function. + * + * @param first the first list + * @param second the second list + * + * @return the resultant joined list + */ alpm_list_t *alpm_list_join(alpm_list_t *first, alpm_list_t *second); + +/** + * @brief Merge the two sorted sublists into one sorted list. + * + * @param left the first list + * @param right the second list + * @param fn comparison function for determining merge order + * + * @return the resultant list + */ alpm_list_t *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn); + +/** + * @brief Sort a list of size `n` using mergesort algorithm. + * + * @param list the list to sort + * @param n the size of the list + * @param fn the comparison function for determining order + * + * @return the resultant list + */ alpm_list_t *alpm_list_msort(alpm_list_t *list, size_t n, alpm_list_fn_cmp fn); + +/** + * @brief Remove an item from the list. + * item is not freed; this is the responsibility of the caller. + * + * @param haystack the list to remove the item from + * @param item the item to remove from the list + * + * @return the resultant list + */ alpm_list_t *alpm_list_remove_item(alpm_list_t *haystack, alpm_list_t *item); + +/** + * @brief Remove an item from the list. + * + * @param haystack the list to remove the item from + * @param needle the data member of the item we're removing + * @param fn the comparison function for searching + * @param data output parameter containing data of the removed item + * + * @return the resultant list + */ alpm_list_t *alpm_list_remove(alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn, void **data); + +/** + * @brief Remove a string from a list. + * + * @param haystack the list to remove the item from + * @param needle the data member of the item we're removing + * @param data output parameter containing data of the removed item + * + * @return the resultant list + */ alpm_list_t *alpm_list_remove_str(alpm_list_t *haystack, const char *needle, char **data); + +/** + * @brief Create a new list without any duplicates. + * + * This does NOT copy data members. + * + * @param list the list to copy + * + * @return a new list containing non-duplicate items + */ alpm_list_t *alpm_list_remove_dupes(const alpm_list_t *list); + +/** + * @brief Copy a string list, including data. + * + * @param list the list to copy + * + * @return a copy of the original list + */ alpm_list_t *alpm_list_strdup(const alpm_list_t *list); + +/** + * @brief Copy a list, without copying data. + * + * @param list the list to copy + * + * @return a copy of the original list + */ alpm_list_t *alpm_list_copy(const alpm_list_t *list); + +/** + * @brief Copy a list and copy the data. + * Note that the data elements to be copied should not contain pointers + * and should also be of constant size. + * + * @param list the list to copy + * @param size the size of each data element + * + * @return a copy of the original list, data copied as well + */ alpm_list_t *alpm_list_copy_data(const alpm_list_t *list, size_t size); + +/** + * @brief Create a new list in reverse order. + * + * @param list the list to copy + * + * @return a new list in reverse order + */ alpm_list_t *alpm_list_reverse(alpm_list_t *list); /* item accessors */ + + +/** + * @brief Return nth element from list (starting from 0). + * + * @param list the list + * @param n the index of the item to find (n < alpm_list_count(list) IS needed) + * + * @return an alpm_list_t node for index `n` + */ alpm_list_t *alpm_list_nth(const alpm_list_t *list, size_t n); + +/** + * @brief Get the next element of a list. + * + * @param list the list node + * + * @return the next element, or NULL when no more elements exist + */ alpm_list_t *alpm_list_next(const alpm_list_t *list); + +/** + * @brief Get the previous element of a list. + * + * @param list the list head + * + * @return the previous element, or NULL when no previous element exist + */ alpm_list_t *alpm_list_previous(const alpm_list_t *list); + +/** + * @brief Get the last item in the list. + * + * @param list the list + * + * @return the last element in the list + */ alpm_list_t *alpm_list_last(const alpm_list_t *list); /* misc */ + +/** + * @brief Get the number of items in a list. + * + * @param list the list + * + * @return the number of list items + */ size_t alpm_list_count(const alpm_list_t *list); + +/** + * @brief Find an item in a list. + * + * @param needle the item to search + * @param haystack the list + * @param fn the comparison function for searching (!= NULL) + * + * @return `needle` if found, NULL otherwise + */ void *alpm_list_find(const alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn); + +/** + * @brief Find an item in a list. + * + * Search for the item whose data matches that of the `needle`. + * + * @param needle the data to search for (== comparison) + * @param haystack the list + * + * @return `needle` if found, NULL otherwise + */ void *alpm_list_find_ptr(const alpm_list_t *haystack, const void *needle); + +/** + * @brief Find a string in a list. + * + * @param needle the string to search for + * @param haystack the list + * + * @return `needle` if found, NULL otherwise + */ char *alpm_list_find_str(const alpm_list_t *haystack, const char *needle); -alpm_list_t *alpm_list_diff(const alpm_list_t *lhs, const alpm_list_t *rhs, alpm_list_fn_cmp fn); + +/** + * @brief Find the differences between list `left` and list `right` + * + * The two lists must be sorted. Items only in list `left` are added to the + * `onlyleft` list. Items only in list `right` are added to the `onlyright` + * list. + * + * @param left the first list + * @param right the second list + * @param fn the comparison function + * @param onlyleft pointer to the first result list + * @param onlyright pointer to the second result list + * + */ void alpm_list_diff_sorted(const alpm_list_t *left, const alpm_list_t *right, alpm_list_fn_cmp fn, alpm_list_t **onlyleft, alpm_list_t **onlyright); + +/** + * @brief Find the items in list `lhs` that are not present in list `rhs`. + * + * @param lhs the first list + * @param rhs the second list + * @param fn the comparison function + * + * @return a list containing all items in `lhs` not present in `rhs` + */ + +alpm_list_t *alpm_list_diff(const alpm_list_t *lhs, const alpm_list_t *rhs, alpm_list_fn_cmp fn); + +/** + * @brief Copy a list and data into a standard C array of fixed length. + * Note that the data elements are shallow copied so any contained pointers + * will point to the original data. + * + * @param list the list to copy + * @param n the size of the list + * @param size the size of each data element + * + * @return an array version of the original list, data copied as well + */ void *alpm_list_to_array(const alpm_list_t *list, size_t n, size_t size); +/* End of alpm_list */ +/** @} */ + #ifdef __cplusplus } #endif -- 2.29.2
--- lib/libalpm/alpm.h | 592 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 564 insertions(+), 28 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 494a8319..05dec6c7 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -1453,186 +1453,722 @@ int alpm_logaction(alpm_handle_t *handle, const char *prefix, /** @} */ -/** @addtogroup alpm_api_options Options +/** @addtogroup alpm_options Options * Libalpm option getters and setters * @{ */ -/** Returns the callback used for logging. */ +/** @name Accessors for callbacks + * @{ + */ + +/** Returns the callback used for logging. + * @param handle the context handle + * @return the currently set log callback + */ alpm_cb_log alpm_option_get_logcb(alpm_handle_t *handle); -/** Sets the callback used for logging. */ + +/** Sets the callback used for logging. + * @param handle the context handle + * @param cb the cb to use + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb); -/** Returns the callback used to report download progress. */ +/** Returns the callback used to report download progress. + * @param handle the context handle + * @return the currently set download callback + */ alpm_cb_download alpm_option_get_dlcb(alpm_handle_t *handle); -/** Sets the callback used to report download progress. */ + +/** Sets the callback used to report download progress. + * @param handle the context handle + * @param cb the cb to use + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_dlcb(alpm_handle_t *handle, alpm_cb_download cb); -/** Returns the downloading callback. */ +/** Returns the downloading callback. + * @param handle the context handle + * @return the currently set fetch callback + */ alpm_cb_fetch alpm_option_get_fetchcb(alpm_handle_t *handle); -/** Sets the downloading callback. */ + +/** Sets the downloading callback. + * @param handle the context handle + * @param cb the cb to use + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_fetchcb(alpm_handle_t *handle, alpm_cb_fetch cb); -/** Returns the callback used to report total download size. */ +/** Returns the callback used to report total download size. + * @param handle the context handle + * @return the currently set total download callback + */ alpm_cb_totaldl alpm_option_get_totaldlcb(alpm_handle_t *handle); -/** Sets the callback used to report total download size. */ + +/** Sets the callback used to report total download size. + * @param handle the context handle + * @param cb the cb to use + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_totaldlcb(alpm_handle_t *handle, alpm_cb_totaldl cb); -/** Returns the callback used for events. */ + +/** Returns the callback used for events. + * @param handle the context handle + * @return the currently set event callback + */ alpm_cb_event alpm_option_get_eventcb(alpm_handle_t *handle); -/** Sets the callback used for events. */ + +/** Sets the callback used for events. + * @param handle the context handle + * @param cb the cb to use + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_eventcb(alpm_handle_t *handle, alpm_cb_event cb); -/** Returns the callback used for questions. */ +/** Returns the callback used for questions. + * @param handle the context handle + * @return the currently set question callback + */ alpm_cb_question alpm_option_get_questioncb(alpm_handle_t *handle); -/** Sets the callback used for questions. */ + +/** Sets the callback used for questions. + * @param handle the context handle + * @param cb the cb to use + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_questioncb(alpm_handle_t *handle, alpm_cb_question cb); -/** Returns the callback used for operation progress. */ + +/**Returns the callback used for operation progress. + * @param handle the context handle + * @return the currently set progress callback + */ alpm_cb_progress alpm_option_get_progresscb(alpm_handle_t *handle); -/** Sets the callback used for operation progress. */ + +/** Sets the callback used for operation progress. + * @param handle the context handle + * @param cb the cb to use + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_progresscb(alpm_handle_t *handle, alpm_cb_progress cb); +/* End of callback accessors */ +/** @} */ + + +/** @name Accessors to the root directory + * + * The root directory is the prefix to which libalpm installs packages to. + * Hooks and scriptlets will also be run in a chroot to ensure they behave correctly + * in alternative roots. + * @{ + */ -/** Returns the root of the destination filesystem. Read-only. */ +/** Returns the root path. Read-only. + * @param handle the context handle + */ const char *alpm_option_get_root(alpm_handle_t *handle); +/* End of root accessors */ +/** @} */ + + +/** @name Accessors to the database path + * + * The dbpath is where libalpm stores the local db and + * downloads sync databases. + * @{ + */ -/** Returns the path to the database directory. Read-only. */ +/** Returns the path to the database directory. Read-only. + * @param handle the context handle + */ const char *alpm_option_get_dbpath(alpm_handle_t *handle); +/* End of dbpath accessors */ +/** @} */ + + +/** @name Accessors to the lockfile + * + * The lockfile is used to ensure two instances of libalpm can not write + * to the database at the same time. The lock file is created when + * committing a transaction and released when the transaction completes. + * Or when calling \link alpm_unlock \endlink. + * @{ + */ -/** Get the name of the database lock file. Read-only. */ +/** Get the name of the database lock file. Read-only. + * This is the name that the lockfile would have. It does not + * matter if the lockfile actually exists on disk. + * @param handle the context handle + */ const char *alpm_option_get_lockfile(alpm_handle_t *handle); +/* End of lockfile accessors */ +/** @} */ /** @name Accessors to the list of package cache directories. + * + * This is where libalpm will store downloaded packages. * @{ */ + +/** Gets the currently configured cachedirs, + * @param handle the context handle + * @return a char* list of cache directories + */ alpm_list_t *alpm_option_get_cachedirs(alpm_handle_t *handle); + +/** Sets the cachedirs. + * @param handle the context handle + * @param cachedirs a char* list of cachdirs. The list will be duped and + * the original will still need to be freed by the caller. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_cachedirs(alpm_handle_t *handle, alpm_list_t *cachedirs); + +/** Append a cachedir to the configured cachedirs. + * @param handle the context handle + * @param cachedir the cachedir to add + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_add_cachedir(alpm_handle_t *handle, const char *cachedir); + +/** Remove a cachedir from the configured cachedirs. + * @param handle the context handle + * @param cachedir the cachedir to remove + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_remove_cachedir(alpm_handle_t *handle, const char *cachedir); +/* End of cachedir accessors */ /** @} */ + /** @name Accessors to the list of package hook directories. + * + * libalpm will search these directories for hooks to run. A hook in + * a later directory will override previous hooks if they have the same name. * @{ */ + +/** Gets the currently configured hookdirs, + * @param handle the context handle + * @return a char* list of hook directories + */ alpm_list_t *alpm_option_get_hookdirs(alpm_handle_t *handle); + +/** Sets the hookdirs. + * @param handle the context handle + * @param hookdirs a char* list of hookdirs. The list will be duped and + * the original will still need to be freed by the caller. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_hookdirs(alpm_handle_t *handle, alpm_list_t *hookdirs); + +/** Append a hookdir to the configured hookdirs. + * @param handle the context handle + * @param hookdir the hookdir to add + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_add_hookdir(alpm_handle_t *handle, const char *hookdir); + +/** Remove a hookdir from the configured hookdirs. + * @param handle the context handle + * @param hookdir the hookdir to remove + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_remove_hookdir(alpm_handle_t *handle, const char *hookdir); +/* End of hookdir accessors */ /** @} */ + +/** @name Accessors to the list of overwritable files. + * + * Normally libalpm will refuse to install a package that owns files that + * are already on disk and not owned by that package. + * + * If a conflicting file matches a glob in the overwrite_files list, then no + * conflict will be raised and libalpm will simply overwrite the file. + * @{ + */ + +/** Gets the currently configured overwritable files, + * @param handle the context handle + * @return a char* list of overwritable file globs + */ alpm_list_t *alpm_option_get_overwrite_files(alpm_handle_t *handle); + +/** Sets the overwritable files. + * @param handle the context handle + * @param globs a char* list of overwritable file globs. The list will be duped and + * the original will still need to be freed by the caller. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_overwrite_files(alpm_handle_t *handle, alpm_list_t *globs); + +/** Append an overwritable file to the configured overwritable files. + * @param handle the context handle + * @param glob the file glob to add + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_add_overwrite_file(alpm_handle_t *handle, const char *glob); + +/** Remove a file glob from the configured overwritable files globs. + * @note The overwritable file list contains a list of globs. The glob to + * remove must exactly match the entry to remove. There is no glob expansion. + * @param handle the context handle + * @param glob the file glob to remove + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_remove_overwrite_file(alpm_handle_t *handle, const char *glob); +/* End of overwrite accessors */ +/** @} */ + -/** Returns the logfile name. */ +/** @name Accessors to the log file + * + * This controls where libalpm will save log output to. + * @{ + */ + +/** Gets the filepath to the currently set logfile. + * @param handle the context handle + * @return the path to the logfile + */ const char *alpm_option_get_logfile(alpm_handle_t *handle); -/** Sets the logfile name. */ + +/** Sets the logfile path. + * @param handle the context handle + * @param logfile path to the new location of the logfile + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_logfile(alpm_handle_t *handle, const char *logfile); +/* End of logfile accessors */ +/** @} */ + + +/** @name Accessors to the GPG directory + * + * This controls where libalpm will store GnuPG's files. + * @{ + */ -/** Returns the path to libalpm's GnuPG home directory. */ +/** Returns the path to libalpm's GnuPG home directory. + * @param handle the context handle + * @return the path to libalpms's GnuPG home directory + */ const char *alpm_option_get_gpgdir(alpm_handle_t *handle); -/** Sets the path to libalpm's GnuPG home directory. */ + +/** Sets the path to libalpm's GnuPG home directory. + * @param handle the context handle + * @param gpgdir the gpgdir to set + */ int alpm_option_set_gpgdir(alpm_handle_t *handle, const char *gpgdir); +/* End of gpdir accessors */ +/** @} */ + -/** Returns whether to use syslog (0 is FALSE, TRUE otherwise). */ +/** @name Accessors for use syslog + * + * This controls whether libalpm will also use the syslog. Even if this option + * is enabled, libalpm will still try to log to its log file. + * @{ + */ + +/** Returns whether to use syslog (0 is FALSE, TRUE otherwise). + * @param handle the context handle + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_get_usesyslog(alpm_handle_t *handle); -/** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */ + +/** Sets whether to use syslog (0 is FALSE, TRUE otherwise). + * @param handle the context handle + * @param usesyslog whether to use the syslog (0 is FALSE, TRUE otherwise) + */ int alpm_option_set_usesyslog(alpm_handle_t *handle, int usesyslog); +/* End of usesyslog accessors */ +/** @} */ + /** @name Accessors to the list of no-upgrade files. * These functions modify the list of files which should * not be updated by package installation. * @{ */ + +/** Get the list of no-upgrade files + * @param handle the context handle + * @return the char* list of no-upgrade files + */ alpm_list_t *alpm_option_get_noupgrades(alpm_handle_t *handle); + +/** Add a file to the no-upgrade list + * @param handle the context handle + * @param path the path to add + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_add_noupgrade(alpm_handle_t *handle, const char *path); + +/** Sets the list of no-upgrade files + * @param handle the context handle + * @param noupgrade a char* list of file to not upgrade. + * The list will be duped and the original will still need to be freed by the caller. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_noupgrades(alpm_handle_t *handle, alpm_list_t *noupgrade); + +/** Remove an entry from the no-upgrade list + * @param handle the context handle + * @param path the path to remove + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_remove_noupgrade(alpm_handle_t *handle, const char *path); + +/** Test if a path matches any of the globs in the no-upgrade list + * @param handle the context handle + * @param path the path to test + * @return 0 is the path matches a glob, negative if there is no match and + * positive is the match was inverted + */ int alpm_option_match_noupgrade(alpm_handle_t *handle, const char *path); +/* End of noupgrade accessors */ /** @} */ + /** @name Accessors to the list of no-extract files. * These functions modify the list of filenames which should * be skipped packages which should * not be upgraded by a sysupgrade operation. * @{ */ + +/** Get the list of no-extract files + * @param handle the context handle + * @return the char* list of no-extract files + */ alpm_list_t *alpm_option_get_noextracts(alpm_handle_t *handle); + +/** Add a file to the no-extract list + * @param handle the context handle + * @param path the path to add + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_add_noextract(alpm_handle_t *handle, const char *path); + +/** Sets the list of no-extract files + * @param handle the context handle + * @param noextract a char* list of file to not extract. + * The list will be duped and the original will still need to be freed by the caller. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_noextracts(alpm_handle_t *handle, alpm_list_t *noextract); + +/** Remove an entry from the no-extract list + * @param handle the context handle + * @param path the path to remove + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_remove_noextract(alpm_handle_t *handle, const char *path); + +/** Test if a path matches any of the globs in the no-extract list + * @param handle the context handle + * @param path the path to test + * @return 0 is the path matches a glob, negative if there is no match and + * positive is the match was inverted + */ int alpm_option_match_noextract(alpm_handle_t *handle, const char *path); +/* End of noextract accessors */ /** @} */ + /** @name Accessors to the list of ignored packages. * These functions modify the list of packages that * should be ignored by a sysupgrade. + * + * Entries in this list may be globs and only match the package's + * name. Providers are not taken into account. * @{ */ + +/** Get the list of ignored packages + * @param handle the context handle + * @return the char* list of ignored packages + */ alpm_list_t *alpm_option_get_ignorepkgs(alpm_handle_t *handle); + +/** Add a file to the ignored package list + * @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_option_add_ignorepkg(alpm_handle_t *handle, const char *pkg); + +/** Sets the list of packages to ignore + * @param handle the context handle + * @param ignorepkgs a char* list of packages to ignore + * The list will be duped and the original will still need to be freed by the caller. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_ignorepkgs(alpm_handle_t *handle, alpm_list_t *ignorepkgs); + +/** Remove an entry from the ignorepkg list + * @param handle the context handle + * @param pkg the package to remove + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_remove_ignorepkg(alpm_handle_t *handle, const char *pkg); +/* End of ignorepkg accessors */ /** @} */ + /** @name Accessors to the list of ignored groups. * These functions modify the list of groups whose packages * should be ignored by a sysupgrade. + * + * Entries in this list may be globs. * @{ */ + +/** Get the list of ignored groups + * @param handle the context handle + * @return the char* list of ignored groups + */ alpm_list_t *alpm_option_get_ignoregroups(alpm_handle_t *handle); + +/** Add a file to the ignored group list + * @param handle the context handle + * @param grp the group to add + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_add_ignoregroup(alpm_handle_t *handle, const char *grp); + +/** Sets the list of groups to ignore + * @param handle the context handle + * @param ignoregrps a char* list of groups to ignore + * The list will be duped and the original will still need to be freed by the caller. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_ignoregroups(alpm_handle_t *handle, alpm_list_t *ignoregrps); + +/** Remove an entry from the ignoregroup list + * @param handle the context handle + * @param grp the group to remove + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_remove_ignoregroup(alpm_handle_t *handle, const char *grp); +/* End of ignoregroup accessors */ /** @} */ + /** @name Accessors to the list of ignored dependencies. * These functions modify the list of dependencies that * should be ignored by a sysupgrade. + * + * This is effectivley a list of virtual providers that + * packages can use to satisfy their dependencies. * @{ */ + +/** Gets the list of dependencies that are assumed to be met + * @param handle the context handle + * @return a list of alpm_depend_t* + */ alpm_list_t *alpm_option_get_assumeinstalled(alpm_handle_t *handle); + +/** Add a depend to the assumed installed list + * @param handle the context handle + * @param dep the dependency to add + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_add_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep); + +/** Sets the list of dependnecies that are assumed to be met + * @param handle the context handle + * @param deps a list of *alpm_depend_t + * The list will be duped and the original will still need to be freed by the caller. + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_assumeinstalled(alpm_handle_t *handle, alpm_list_t *deps); + +/** Remove an entry from the assume installed list + * @param handle the context handle + * @param dep the dep to remove + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_remove_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep); +/* End of assunmeinstalled accessors */ /** @} */ -/** Returns the targeted architecture. */ + +/** @name Accessors for the configured architecture + * + * libalpm will only install packages that match the configured architecture. + * The architecture does not need to match the physical architecture. + * It can just be treated as a label. + * @{ + */ + +/** Returns the allowed package architecture. + * @param handle the context handle + * @return the configured package architecture + */ const char *alpm_option_get_arch(alpm_handle_t *handle); -/** Sets the targeted architecture. */ + +/** Sets the allowed package architecture. + * @param handle the context handle + * @param arch the architecture to set + */ int alpm_option_set_arch(alpm_handle_t *handle, const char *arch); +/* End of arch accessors */ +/** @} */ + + +/** @name Accessors for check space. + * + * This controls whether libalpm will check if there is sufficient before + * installing packages. + * @{ + */ +/** Get whether or not checking for free space before installing packages is enabled. + * @param handle the context handle + * @return 0 if disabled, 1 if enabled + */ int alpm_option_get_checkspace(alpm_handle_t *handle); + +/** Enable/disable checking free space before installing packages. + * @param handle the context handle + * @param checkspace 0 for disabled, 1 for enabled + */ int alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace); +/* End of checkspace accessors */ +/** @} */ + + +/** @name Accessors for the database extension + * + * This controls the extension used for sync databases. libalpm will use this + * extension to both lookup remote databses and as the name used when opening + * reading them. + * + * This is useful for file databases. Seems as files can increase the size of + * a database by quite a lot, a server could hold a database without files under + * one extension, and another with files under another extension. + * + * Which one is downloaded and used then depends on this setting. + * @{ + */ +/** Gets the configured database extension. + * @param handle the context handle + * @return the configured database extension + */ const char *alpm_option_get_dbext(alpm_handle_t *handle); + +/** Sets the database extension. + * @param handle the context handle + * @param dbext the database extension to use + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext); +/* End of dbext accessors */ +/** @} */ + + +/** @name Accessors for the signature levels + * @{ + */ +/** Get the default siglevel. + * @param handle the context handle + * @return a \link alpm_siglevel_t \endlink bitfield of the siglevel + */ int alpm_option_get_default_siglevel(alpm_handle_t *handle); + +/** Set the default siglevel. + * @param handle the context handle + * @param level a \link alpm_siglevel_t \endlink bitfield of the level to set + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_default_siglevel(alpm_handle_t *handle, int level); +/** Get the configured local file siglevel. + * @param handle the context handle + * @return a \link alpm_siglevel_t \endlink bitfield of the siglevel + */ int alpm_option_get_local_file_siglevel(alpm_handle_t *handle); + +/** Set the local file siglevel. + * @param handle the context handle + * @param level a \link alpm_siglevel_t \endlink bitfield of the level to set + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, int level); +/** Get the configured remote file siglevel. + * @param handle the context handle + * @return a \link alpm_siglevel_t \endlink bitfield of the siglevel + */ int alpm_option_get_remote_file_siglevel(alpm_handle_t *handle); + +/** Set the remote file siglevel. + * @param handle the context handle + * @param level a \link alpm_siglevel_t \endlink bitfield of the level to set + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int level); +/* End of signature accessors */ +/** @} */ + +/** @name Accessors for download timeout + * + * By default, libalpm will timeout if a download has been transferring + * less than 1 byte for 10 seconds. + * @{ + */ + +/** Enables/disables the download timeout. + * @param handle the context handle + * @param disable_dl_timeout 0 for enabled, 1 for disabled + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ int alpm_option_set_disable_dl_timeout(alpm_handle_t *handle, unsigned short disable_dl_timeout); +/* End of disable_dl_timeout accessors */ +/** @} */ + +/** @name Accessors for parallel downloads + * \link alpm_db_update \endlink, \link alpm_fetch_pkgurl \endlink and + * \link alpm_trans_commit \endlink can all download packages in parallel. + * This setting configures how many packages can be downloaded in parallel, + * + * By default this value is set to 1, meaning packages are downloading + * sequentially. + * + * @{ + */ + +/** Gets the number of parallel streams to download database and package files. + * @param handle the context handle + * @return the number of parallel streams to download database and package files + */ int alpm_option_get_parallel_downloads(alpm_handle_t *handle); /** Sets number of parallel streams to download database and package files. - * If the function is not called then the default value of '1' stream - * (i.e. sequential download) is used. * @param handle the context handle * @param num_streams number of parallel download streams * @return 0 on success, -1 on error */ int alpm_option_set_parallel_downloads(alpm_handle_t *handle, unsigned int num_streams); +/* End of parallel_downloads accessors */ +/** @} */ + +/* End of alpm_options */ /** @} */ + /** @addtogroup alpm_packages Package Functions * Functions to manipulate libalpm packages * @{ -- 2.29.2
--- lib/libalpm/alpm.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 05dec6c7..4673f639 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -50,6 +50,11 @@ extern "C" { #include <alpm_list.h> +/** @addtogroup alpm_api ALPM + * @brief The libalpm Public API + * @{ + */ + /* * Opaque Structures */ @@ -94,11 +99,6 @@ typedef struct __alpm_pkg_t alpm_pkg_t; /** Transaction structure used internally by libalpm */ typedef struct __alpm_trans_t alpm_trans_t; -/** @addtogroup alpm_api ALPM - * @brief The libalpm Public API - * @{ - */ - /** @addtogroup alpm_files Files * @brief Functions for package files * @{ -- 2.29.2
--- lib/libalpm/alpm.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 4673f639..e9cc7c85 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -62,6 +62,7 @@ extern "C" { /** The libalpm context handle. * * This struct represents an instance of libalpm. + * @ingroup alpm_handle */ typedef struct __alpm_handle_t alpm_handle_t; @@ -81,6 +82,7 @@ typedef struct __alpm_handle_t alpm_handle_t; * the user. They will be freed when the database is unregistered. * * Databases are automatically unregistered when the \link alpm_handle_t \endlink is released. + * @ingroup alpm_databases */ typedef struct __alpm_db_t alpm_db_t; @@ -93,12 +95,20 @@ typedef struct __alpm_db_t alpm_db_t; * * Packages can then be queried for metadata or added to a \link alpm_trans_t transaction \endlink * to be added or removed from the system. + * @ingroup alpm_packages */ typedef struct __alpm_pkg_t alpm_pkg_t; -/** Transaction structure used internally by libalpm */ +/** Transaction structure used internally by libalpm + * @ingroup alpm_trans + * */ typedef struct __alpm_trans_t alpm_trans_t; + +/** The time type used by libalpm. Represents a unix time stamp + * @ingroup alpm_misc */ +typedef int64_t alpm_time_t; + /** @addtogroup alpm_files Files * @brief Functions for package files * @{ @@ -343,7 +353,6 @@ int alpm_release(alpm_handle_t *handle); /* End of alpm_handle */ /** @} */ -typedef int64_t alpm_time_t; /** @addtogroup alpm_sig Signature checking * @brief Functions to check signatures -- 2.29.2
- only document public alpm items (alpm_*) - hide typedef'd structs (_alpm_pkg_t shows as alpm_pkg_t) - enable inline struct definitions (this stops having a man page for every single struct) --- doc/Doxyfile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 78481dd5..e2101a28 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -53,7 +53,7 @@ DISTRIBUTE_GROUP_DOC = NO SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO INLINE_SIMPLE_STRUCTS = NO -TYPEDEF_HIDES_STRUCT = NO +TYPEDEF_HIDES_STRUCT = YES SYMBOL_CACHE_SIZE = 0 LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- @@ -107,14 +107,14 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = ../lib/libalpm/ +INPUT = ../lib/libalpm/alpm.h ../lib/libalpm/alpm_list.h INPUT_ENCODING = UTF-8 FILE_PATTERNS = RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = _alpm_* __alpm_* EXAMPLE_PATH = EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO -- 2.29.2
--- doc/Doxyfile.in | 81 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 22 deletions(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index e2101a28..776318da 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -1,4 +1,4 @@ -# Doxyfile 1.8.2 +# Doxyfile 1.8.20 #--------------------------------------------------------------------------- # Project related configuration options @@ -10,7 +10,9 @@ PROJECT_BRIEF = "Arch Linux Package Manager Library" PROJECT_LOGO = OUTPUT_DIRECTORY = @OUTPUT_DIRECTORY@ CREATE_SUBDIRS = NO +ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English +OUTPUT_TEXT_DIRECTION = None BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = "The $name class" \ @@ -31,36 +33,41 @@ STRIP_FROM_PATH = STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES +JAVADOC_BANNER = NO QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +PYTHON_DOCSTRING = YES INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 4 ALIASES = -TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +OPTIMIZE_OUTPUT_SLICE = NO EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES +TOC_INCLUDE_HEADINGS = 5 AUTOLINK_SUPPORT = YES BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO +GROUP_NESTED_COMPOUNDS = NO SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO -INLINE_SIMPLE_STRUCTS = NO +INLINE_SIMPLE_STRUCTS = YES TYPEDEF_HIDES_STRUCT = YES -SYMBOL_CACHE_SIZE = 0 LOOKUP_CACHE_SIZE = 0 +NUM_PROC_THREADS = 1 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = NO EXTRACT_PRIVATE = NO +EXTRACT_PRIV_VIRTUAL = NO EXTRACT_PACKAGE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES @@ -73,7 +80,9 @@ HIDE_IN_BODY_DOCS = YES INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO +HIDE_COMPOUND_REFERENCE= NO SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO FORCE_LOCAL_INCLUDES = NO INLINE_INFO = YES SORT_MEMBER_DOCS = YES @@ -95,26 +104,29 @@ FILE_VERSION_FILTER = LAYOUT_FILE = CITE_BIB_FILES = #--------------------------------------------------------------------------- -# configuration options related to warning and progress messages +# Configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO +WARN_AS_ERROR = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- -# configuration options related to the input files +# Configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = ../lib/libalpm/alpm.h ../lib/libalpm/alpm_list.h +INPUT = ../lib/libalpm/alpm.h \ + ../lib/libalpm/alpm_list.h INPUT_ENCODING = UTF-8 FILE_PATTERNS = RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = _alpm_* __alpm_* +EXCLUDE_SYMBOLS = _alpm_* \ + __alpm_* EXAMPLE_PATH = EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO @@ -123,8 +135,9 @@ INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- -# configuration options related to source browsing +# Configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO @@ -132,16 +145,17 @@ STRIP_CODE_COMMENTS = NO REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES USE_HTAGS = NO VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index +# Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- -# configuration options related to the HTML output +# Configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = NO HTML_OUTPUT = html @@ -155,6 +169,7 @@ HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES +HTML_DYNAMIC_MENUS = YES HTML_DYNAMIC_SECTIONS = NO HTML_INDEX_NUM_ENTRIES = 100 GENERATE_DOCSET = NO @@ -184,33 +199,47 @@ GENERATE_TREEVIEW = NO ENUM_VALUES_PER_LINE = 4 TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +HTML_FORMULA_FORMAT = png FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +FORMULA_MACROFILE = USE_MATHJAX = NO +MATHJAX_FORMAT = HTML-CSS MATHJAX_RELPATH = http://www.mathjax.org/mathjax MATHJAX_EXTENSIONS = +MATHJAX_CODEFILE = SEARCHENGINE = NO SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- -# configuration options related to the LaTeX output +# Configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex +LATEX_MAKEINDEX_CMD = makeindex COMPACT_LATEX = NO PAPER_TYPE = letter EXTRA_PACKAGES = LATEX_HEADER = LATEX_FOOTER = +LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_FILES = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain +LATEX_TIMESTAMP = NO +LATEX_EMOJI_DIRECTORY = #--------------------------------------------------------------------------- -# configuration options related to the RTF output +# Configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf @@ -218,27 +247,31 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = +RTF_SOURCE_CODE = NO #--------------------------------------------------------------------------- -# configuration options related to the man page output +# Configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = YES MAN_OUTPUT = . MAN_EXTENSION = .3 +MAN_SUBDIR = MAN_LINKS = NO #--------------------------------------------------------------------------- -# configuration options related to the XML output +# Configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = XML_PROGRAMLISTING = YES +XML_NS_MEMB_FILE_SCOPE = NO #--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output +# Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- +GENERATE_DOCBOOK = NO +DOCBOOK_OUTPUT = docbook +DOCBOOK_PROGRAMLISTING = NO GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- -# configuration options related to the Perl module output +# Configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO @@ -262,18 +295,18 @@ PREDEFINED = HAVE_CONFIG_H= \ EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration options related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl +EXTERNAL_PAGES = YES #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = NO -MSCGEN_PATH = +DIA_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = YES DOT_NUM_THREADS = 0 @@ -297,6 +330,10 @@ INTERACTIVE_SVG = NO DOT_PATH = DOTFILE_DIRS = MSCFILE_DIRS = +DIAFILE_DIRS = +PLANTUML_JAR_PATH = +PLANTUML_CFG_FILE = +PLANTUML_INCLUDE_PATH = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 3 DOT_TRANSPARENT = NO -- 2.29.2
LGTM. These fix a number of warnings about obsolete fields. Did you rerun the wizard to generate this? On Mon, 7 Dec 2020, at 14:19, morganamilo wrote:
--- doc/Doxyfile.in | 81 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 22 deletions(-)
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index e2101a28..776318da 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -1,4 +1,4 @@ -# Doxyfile 1.8.2 +# Doxyfile 1.8.20
#--------------------------------------------------------------------------- # Project related configuration options @@ -10,7 +10,9 @@ PROJECT_BRIEF = "Arch Linux Package Manager Library" PROJECT_LOGO = OUTPUT_DIRECTORY = @OUTPUT_DIRECTORY@ CREATE_SUBDIRS = NO +ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English +OUTPUT_TEXT_DIRECTION = None BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = "The $name class" \ @@ -31,36 +33,41 @@ STRIP_FROM_PATH = STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES +JAVADOC_BANNER = NO QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +PYTHON_DOCSTRING = YES INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 4 ALIASES = -TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +OPTIMIZE_OUTPUT_SLICE = NO EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES +TOC_INCLUDE_HEADINGS = 5 AUTOLINK_SUPPORT = YES BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO +GROUP_NESTED_COMPOUNDS = NO SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO -INLINE_SIMPLE_STRUCTS = NO +INLINE_SIMPLE_STRUCTS = YES TYPEDEF_HIDES_STRUCT = YES -SYMBOL_CACHE_SIZE = 0 LOOKUP_CACHE_SIZE = 0 +NUM_PROC_THREADS = 1 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = NO EXTRACT_PRIVATE = NO +EXTRACT_PRIV_VIRTUAL = NO EXTRACT_PACKAGE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES @@ -73,7 +80,9 @@ HIDE_IN_BODY_DOCS = YES INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO +HIDE_COMPOUND_REFERENCE= NO SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO FORCE_LOCAL_INCLUDES = NO INLINE_INFO = YES SORT_MEMBER_DOCS = YES @@ -95,26 +104,29 @@ FILE_VERSION_FILTER = LAYOUT_FILE = CITE_BIB_FILES = #--------------------------------------------------------------------------- -# configuration options related to warning and progress messages +# Configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO +WARN_AS_ERROR = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- -# configuration options related to the input files +# Configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = ../lib/libalpm/alpm.h ../lib/libalpm/alpm_list.h +INPUT = ../lib/libalpm/alpm.h \ + ../lib/libalpm/alpm_list.h INPUT_ENCODING = UTF-8 FILE_PATTERNS = RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = _alpm_* __alpm_* +EXCLUDE_SYMBOLS = _alpm_* \ + __alpm_* EXAMPLE_PATH = EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO @@ -123,8 +135,9 @@ INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- -# configuration options related to source browsing +# Configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO @@ -132,16 +145,17 @@ STRIP_CODE_COMMENTS = NO REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES USE_HTAGS = NO VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index +# Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- -# configuration options related to the HTML output +# Configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = NO HTML_OUTPUT = html @@ -155,6 +169,7 @@ HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES +HTML_DYNAMIC_MENUS = YES HTML_DYNAMIC_SECTIONS = NO HTML_INDEX_NUM_ENTRIES = 100 GENERATE_DOCSET = NO @@ -184,33 +199,47 @@ GENERATE_TREEVIEW = NO ENUM_VALUES_PER_LINE = 4 TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +HTML_FORMULA_FORMAT = png FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +FORMULA_MACROFILE = USE_MATHJAX = NO +MATHJAX_FORMAT = HTML-CSS MATHJAX_RELPATH = http://www.mathjax.org/mathjax MATHJAX_EXTENSIONS = +MATHJAX_CODEFILE = SEARCHENGINE = NO SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- -# configuration options related to the LaTeX output +# Configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex +LATEX_MAKEINDEX_CMD = makeindex COMPACT_LATEX = NO PAPER_TYPE = letter EXTRA_PACKAGES = LATEX_HEADER = LATEX_FOOTER = +LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_FILES = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain +LATEX_TIMESTAMP = NO +LATEX_EMOJI_DIRECTORY = #--------------------------------------------------------------------------- -# configuration options related to the RTF output +# Configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf @@ -218,27 +247,31 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = +RTF_SOURCE_CODE = NO #--------------------------------------------------------------------------- -# configuration options related to the man page output +# Configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = YES MAN_OUTPUT = . MAN_EXTENSION = .3 +MAN_SUBDIR = MAN_LINKS = NO #--------------------------------------------------------------------------- -# configuration options related to the XML output +# Configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = XML_PROGRAMLISTING = YES +XML_NS_MEMB_FILE_SCOPE = NO #--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output +# Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- +GENERATE_DOCBOOK = NO +DOCBOOK_OUTPUT = docbook +DOCBOOK_PROGRAMLISTING = NO GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- -# configuration options related to the Perl module output +# Configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO @@ -262,18 +295,18 @@ PREDEFINED = HAVE_CONFIG_H= \ EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration options related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl +EXTERNAL_PAGES = YES #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = NO -MSCGEN_PATH = +DIA_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = YES DOT_NUM_THREADS = 0 @@ -297,6 +330,10 @@ INTERACTIVE_SVG = NO DOT_PATH = DOTFILE_DIRS = MSCFILE_DIRS = +DIAFILE_DIRS = +PLANTUML_JAR_PATH = +PLANTUML_CFG_FILE = +PLANTUML_INCLUDE_PATH = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 3 DOT_TRANSPARENT = NO -- 2.29.2
--- lib/libalpm/alpm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index e9cc7c85..a0de9b13 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -50,7 +50,7 @@ extern "C" { #include <alpm_list.h> -/** @addtogroup alpm_api ALPM +/** @addtogroup alpm alpm * @brief The libalpm Public API * @{ */ -- 2.29.2
--- lib/libalpm/alpm.h | 10 ++++++++-- lib/libalpm/alpm_list.h | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index a0de9b13..b2772f19 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -50,8 +50,14 @@ extern "C" { #include <alpm_list.h> -/** @addtogroup alpm alpm - * @brief The libalpm Public API +/** @addtogroup alpm The libalpm Public API + * + * @section see_also See Also + * \b alpm_list(3), + * \b alpm-hooks(5), + * \b makepkg(8), + * \b pacman(8), + * \b pacman.conf(5) * @{ */ diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h index 1eac3043..01fa092c 100644 --- a/lib/libalpm/alpm_list.h +++ b/lib/libalpm/alpm_list.h @@ -24,6 +24,16 @@ * @author Pacman Development Team * @date 7 Dec 2020 * @brief A doubly linked list for use with libalpm + * + * @section see_also See Also + * \b alpm(3), + * \b alpm-hooks(5), + * \b makepkg(8), + * \b pacman(8), + * \b pacman.conf(5) + * @{ + */ + */ #ifndef ALPM_LIST_H -- 2.29.2
Also change the group's title to point to the group's man page. This makes generated man pages be named libalpm_* which is more consistent with what library man pages are usually called. --- doc/meson.build | 1 - lib/libalpm/alpm.h | 80 +++++++++++++++++++++++++---------------- lib/libalpm/alpm_list.h | 22 ++---------- 3 files changed, 53 insertions(+), 50 deletions(-) diff --git a/doc/meson.build b/doc/meson.build index e24172fd..570dc765 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -9,7 +9,6 @@ manpages = [ { 'name': 'PKGBUILD.5', 'extra_depends' : [ 'PKGBUILD-example.txt' ] }, { 'name': 'makepkg.conf.5' }, { 'name': 'pacman.conf.5' }, - { 'name': 'libalpm.3' }, { 'name': 'BUILDINFO.5' }, { 'name': 'pacman-conf.8' }, ] diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index b2772f19..dd28b191 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -21,13 +21,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/** - * @file alpm.h - * @author Pacman Development Team - * @date 7 Dec 2020 - * @brief Arch Linux Package Manager Library - */ - /** @mainpage alpm * * libalpm is a package management library, primaraly used by pacman. @@ -50,14 +43,41 @@ extern "C" { #include <alpm_list.h> -/** @addtogroup alpm The libalpm Public API +/** @addtogroup libalpm The libalpm Public API + * + * + * libalpm is a package management library, primaraly used by pacman. + * + * For ease of access, the libalpm manual has been split up into several sections. * - * @section see_also See Also - * \b alpm_list(3), + * @section bugs Bugs + * Bugs? You must be kidding; there are no bugs in this software. But if we happen to be wrong, + * submit a bug report with as much detail as possible at the Arch Linux Bug Tracker in the + * Pacman section. + * + * @section see_also See also + * \b libalpm-list(3), * \b alpm-hooks(5), * \b makepkg(8), - * \b pacman(8), - * \b pacman.conf(5) + * + * @section maintainers Maintainers + * Current maintainers: + * + * - Allan McRae <allan@archlinux.org> + * - Andrew Gregory <andrew.gregory.8@gmail.com> + * - Dave Reisner <dreisner@archlinux.org> + * - Eli Schwartz <eschwartz@archlinux.org> + * + * Past major contributors: + * + * - Judd Vinet <jvinet@zeroflux.org> + * - Aurelien Foret <aurelien@archlinux.org> + * - Aaron Griffin <aaron@archlinux.org> + * - Dan McGee <dan@archlinux.org> + * - Xavier Chantry <shiningxc@gmail.com> + * - Nagy Gabor <ngaba@bibl.u-szeged.hu> + * + * For additional contributors, use git shortlog -s on the pacman.git repository. * @{ */ @@ -68,7 +88,7 @@ extern "C" { /** The libalpm context handle. * * This struct represents an instance of libalpm. - * @ingroup alpm_handle + * @ingroup libalpm-handle */ typedef struct __alpm_handle_t alpm_handle_t; @@ -88,7 +108,7 @@ typedef struct __alpm_handle_t alpm_handle_t; * the user. They will be freed when the database is unregistered. * * Databases are automatically unregistered when the \link alpm_handle_t \endlink is released. - * @ingroup alpm_databases + * @ingroup libalpm-databases */ typedef struct __alpm_db_t alpm_db_t; @@ -101,21 +121,21 @@ typedef struct __alpm_db_t alpm_db_t; * * Packages can then be queried for metadata or added to a \link alpm_trans_t transaction \endlink * to be added or removed from the system. - * @ingroup alpm_packages + * @ingroup libalpm-packages */ typedef struct __alpm_pkg_t alpm_pkg_t; /** Transaction structure used internally by libalpm - * @ingroup alpm_trans + * @ingroup libalpm-trans * */ typedef struct __alpm_trans_t alpm_trans_t; /** The time type used by libalpm. Represents a unix time stamp - * @ingroup alpm_misc */ + * @ingroup libalpm-misc */ typedef int64_t alpm_time_t; -/** @addtogroup alpm_files Files +/** @addtogroup libalpm-files libalpm-files(3) * @brief Functions for package files * @{ */ @@ -160,7 +180,7 @@ alpm_file_t *alpm_filelist_contains(alpm_filelist_t *filelist, const char *path) /** @} */ -/** @addtogroup alpm_groups Groups +/** @addtogroup libalpm-groups libalpm-groups(3) * @brief Functions for package groups * @{ */ @@ -186,7 +206,7 @@ alpm_list_t *alpm_find_group_pkgs(alpm_list_t *dbs, const char *name); /** @} */ -/** @addtogroup alpm_errors Error Codes +/** @addtogroup libalpm-errors libalpm-errors(3) * Error codes returned by libalpm. * @{ */ @@ -330,7 +350,7 @@ const char *alpm_strerror(alpm_errno_t err); /** @} */ -/** \addtogroup alpm_handle Handle +/** \addtogroup libalpm-handle libalpm-handle(3) * @brief Functions to initialize and release libalpm * @{ */ @@ -360,7 +380,7 @@ int alpm_release(alpm_handle_t *handle); /** @} */ -/** @addtogroup alpm_sig Signature checking +/** @addtogroup libalpm-sig libalpm-sig(3) * @brief Functions to check signatures * @{ */ @@ -526,7 +546,7 @@ int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier, /** @} */ -/** @addtogroup alpm_depends Dependency +/** @addtogroup libalpm-depends libalpm-depends(3) * @brief Functions dealing with libalpm's dependency and conflict * information. * @{ @@ -703,7 +723,7 @@ void alpm_conflict_free(alpm_conflict_t *conflict); /** @} */ -/** \addtogroup alpm_cb Callbacks +/** \addtogroup libalpm-cb libalpm-cb(3) * @brief Functions and structures for libalpm's callbacks * @{ */ @@ -1208,7 +1228,7 @@ typedef int (*alpm_cb_fetch)(const char *url, const char *localpath, /** @} */ -/** @addtogroup alpm_databases Database +/** @addtogroup libalpm-databases libalpm-database(3) * @brief Functions to query and manipulate the database of libalpm. * @{ */ @@ -1426,7 +1446,7 @@ int alpm_db_get_usage(alpm_db_t *db, int *usage); /** @} */ -/** \addtogroup alpm_log Logging Functions +/** \addtogroup libalpm-log alpm-log(3) * @brief Functions to log using libalpm * @{ */ @@ -1468,7 +1488,7 @@ int alpm_logaction(alpm_handle_t *handle, const char *prefix, /** @} */ -/** @addtogroup alpm_options Options +/** @addtogroup libalpm-options libalpm-options(3) * Libalpm option getters and setters * @{ */ @@ -2184,7 +2204,7 @@ int alpm_option_set_parallel_downloads(alpm_handle_t *handle, unsigned int num_s /** @} */ -/** @addtogroup alpm_packages Package Functions +/** @addtogroup libalpm-packages libalpm-packages(3) * Functions to manipulate libalpm packages * @{ */ @@ -2619,7 +2639,7 @@ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive); /* End of alpm_packages */ /** @} */ -/** @addtogroup alpm_trans Transaction +/** @addtogroup libalpm-trans libalpm-trans(3) * @brief Functions to manipulate libalpm transactions * * Transactions are the way to add/remove packages to/from the system. @@ -2763,7 +2783,7 @@ int alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg); /** @} */ -/** \addtogroup alpm_misc Miscellaneous Functions +/** \addtogroup libalpm-misc libalpm-misc(3) * @brief Various libalpm functions * @{ */ diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h index 01fa092c..620cfbfd 100644 --- a/lib/libalpm/alpm_list.h +++ b/lib/libalpm/alpm_list.h @@ -19,23 +19,6 @@ */ -/** - * @file alpm_list.h - * @author Pacman Development Team - * @date 7 Dec 2020 - * @brief A doubly linked list for use with libalpm - * - * @section see_also See Also - * \b alpm(3), - * \b alpm-hooks(5), - * \b makepkg(8), - * \b pacman(8), - * \b pacman.conf(5) - * @{ - */ - - */ - #ifndef ALPM_LIST_H #define ALPM_LIST_H @@ -50,7 +33,8 @@ extern "C" { #endif /** - * @addtogroup alpm_list List Functions + * @ingroup libalpm + * @addtogroup libalpm-list libalpm-list(3) * @brief Functions to manipulate alpm_list_t lists. * * These functions are designed to create, destroy, and modify lists of @@ -60,7 +44,7 @@ extern "C" { * It is exposed so front ends can use it to prevent the need to reimplement * lists of their own; however, it is not required that the front end uses * it. - * @{ + * @{ */ /** A doubly linked list */ -- 2.29.2
On 8/12/20 8:19 am, morganamilo wrote:
Also change the group's title to point to the group's man page.
This makes generated man pages be named libalpm_* which is more consistent with what library man pages are usually called. ---
I have applied all patches up to this point. Bit confiused about a section below:
doc/meson.build | 1 - lib/libalpm/alpm.h | 80 +++++++++++++++++++++++++---------------- lib/libalpm/alpm_list.h | 22 ++---------- 3 files changed, 53 insertions(+), 50 deletions(-)
diff --git a/doc/meson.build b/doc/meson.build index e24172fd..570dc765 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -9,7 +9,6 @@ manpages = [ { 'name': 'PKGBUILD.5', 'extra_depends' : [ 'PKGBUILD-example.txt' ] }, { 'name': 'makepkg.conf.5' }, { 'name': 'pacman.conf.5' }, - { 'name': 'libalpm.3' }, { 'name': 'BUILDINFO.5' }, { 'name': 'pacman-conf.8' }, ] diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index b2772f19..dd28b191 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -21,13 +21,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/** - * @file alpm.h - * @author Pacman Development Team - * @date 7 Dec 2020 - * @brief Arch Linux Package Manager Library - */ - /** @mainpage alpm * * libalpm is a package management library, primaraly used by pacman. @@ -50,14 +43,41 @@ extern "C" {
#include <alpm_list.h>
-/** @addtogroup alpm The libalpm Public API +/** @addtogroup libalpm The libalpm Public API + * + * + * libalpm is a package management library, primaraly used by pacman. + * + * For ease of access, the libalpm manual has been split up into several sections. * - * @section see_also See Also - * \b alpm_list(3), + * @section bugs Bugs + * Bugs? You must be kidding; there are no bugs in this software. But if we happen to be wrong, + * submit a bug report with as much detail as possible at the Arch Linux Bug Tracker in the + * Pacman section. + * + * @section see_also See also + * \b libalpm-list(3), * \b alpm-hooks(5), * \b makepkg(8), - * \b pacman(8), - * \b pacman.conf(5) + *
There seems to be a lot of duplication from our footer.asciidoc here. Why?
+ * @section maintainers Maintainers + * Current maintainers: + * + * - Allan McRae <allan@archlinux.org> + * - Andrew Gregory <andrew.gregory.8@gmail.com> + * - Dave Reisner <dreisner@archlinux.org> + * - Eli Schwartz <eschwartz@archlinux.org> + * + * Past major contributors: + * + * - Judd Vinet <jvinet@zeroflux.org> + * - Aurelien Foret <aurelien@archlinux.org> + * - Aaron Griffin <aaron@archlinux.org> + * - Dan McGee <dan@archlinux.org> + * - Xavier Chantry <shiningxc@gmail.com> + * - Nagy Gabor <ngaba@bibl.u-szeged.hu> + * + * For additional contributors, use git shortlog -s on the pacman.git repository. * @{ */
@@ -68,7 +88,7 @@ extern "C" { /** The libalpm context handle. * * This struct represents an instance of libalpm. - * @ingroup alpm_handle + * @ingroup libalpm-handle */ typedef struct __alpm_handle_t alpm_handle_t;
@@ -88,7 +108,7 @@ typedef struct __alpm_handle_t alpm_handle_t; * the user. They will be freed when the database is unregistered. * * Databases are automatically unregistered when the \link alpm_handle_t \endlink is released. - * @ingroup alpm_databases + * @ingroup libalpm-databases */ typedef struct __alpm_db_t alpm_db_t;
@@ -101,21 +121,21 @@ typedef struct __alpm_db_t alpm_db_t; * * Packages can then be queried for metadata or added to a \link alpm_trans_t transaction \endlink * to be added or removed from the system. - * @ingroup alpm_packages + * @ingroup libalpm-packages */ typedef struct __alpm_pkg_t alpm_pkg_t;
/** Transaction structure used internally by libalpm - * @ingroup alpm_trans + * @ingroup libalpm-trans * */ typedef struct __alpm_trans_t alpm_trans_t;
/** The time type used by libalpm. Represents a unix time stamp - * @ingroup alpm_misc */ + * @ingroup libalpm-misc */ typedef int64_t alpm_time_t;
-/** @addtogroup alpm_files Files +/** @addtogroup libalpm-files libalpm-files(3) * @brief Functions for package files * @{ */ @@ -160,7 +180,7 @@ alpm_file_t *alpm_filelist_contains(alpm_filelist_t *filelist, const char *path) /** @} */
-/** @addtogroup alpm_groups Groups +/** @addtogroup libalpm-groups libalpm-groups(3) * @brief Functions for package groups * @{ */ @@ -186,7 +206,7 @@ alpm_list_t *alpm_find_group_pkgs(alpm_list_t *dbs, const char *name); /** @} */
-/** @addtogroup alpm_errors Error Codes +/** @addtogroup libalpm-errors libalpm-errors(3) * Error codes returned by libalpm. * @{ */ @@ -330,7 +350,7 @@ const char *alpm_strerror(alpm_errno_t err); /** @} */
-/** \addtogroup alpm_handle Handle +/** \addtogroup libalpm-handle libalpm-handle(3) * @brief Functions to initialize and release libalpm * @{ */ @@ -360,7 +380,7 @@ int alpm_release(alpm_handle_t *handle); /** @} */
-/** @addtogroup alpm_sig Signature checking +/** @addtogroup libalpm-sig libalpm-sig(3) * @brief Functions to check signatures * @{ */ @@ -526,7 +546,7 @@ int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier, /** @} */
-/** @addtogroup alpm_depends Dependency +/** @addtogroup libalpm-depends libalpm-depends(3) * @brief Functions dealing with libalpm's dependency and conflict * information. * @{ @@ -703,7 +723,7 @@ void alpm_conflict_free(alpm_conflict_t *conflict); /** @} */
-/** \addtogroup alpm_cb Callbacks +/** \addtogroup libalpm-cb libalpm-cb(3) * @brief Functions and structures for libalpm's callbacks * @{ */ @@ -1208,7 +1228,7 @@ typedef int (*alpm_cb_fetch)(const char *url, const char *localpath, /** @} */
-/** @addtogroup alpm_databases Database +/** @addtogroup libalpm-databases libalpm-database(3) * @brief Functions to query and manipulate the database of libalpm. * @{ */ @@ -1426,7 +1446,7 @@ int alpm_db_get_usage(alpm_db_t *db, int *usage); /** @} */
-/** \addtogroup alpm_log Logging Functions +/** \addtogroup libalpm-log alpm-log(3) * @brief Functions to log using libalpm * @{ */ @@ -1468,7 +1488,7 @@ int alpm_logaction(alpm_handle_t *handle, const char *prefix, /** @} */
-/** @addtogroup alpm_options Options +/** @addtogroup libalpm-options libalpm-options(3) * Libalpm option getters and setters * @{ */ @@ -2184,7 +2204,7 @@ int alpm_option_set_parallel_downloads(alpm_handle_t *handle, unsigned int num_s /** @} */
-/** @addtogroup alpm_packages Package Functions +/** @addtogroup libalpm-packages libalpm-packages(3) * Functions to manipulate libalpm packages * @{ */ @@ -2619,7 +2639,7 @@ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive); /* End of alpm_packages */ /** @} */
-/** @addtogroup alpm_trans Transaction +/** @addtogroup libalpm-trans libalpm-trans(3) * @brief Functions to manipulate libalpm transactions * * Transactions are the way to add/remove packages to/from the system. @@ -2763,7 +2783,7 @@ int alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg); /** @} */
-/** \addtogroup alpm_misc Miscellaneous Functions +/** \addtogroup libalpm-misc libalpm-misc(3) * @brief Various libalpm functions * @{ */ diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h index 01fa092c..620cfbfd 100644 --- a/lib/libalpm/alpm_list.h +++ b/lib/libalpm/alpm_list.h @@ -19,23 +19,6 @@ */
-/** - * @file alpm_list.h - * @author Pacman Development Team - * @date 7 Dec 2020 - * @brief A doubly linked list for use with libalpm - * - * @section see_also See Also - * \b alpm(3), - * \b alpm-hooks(5), - * \b makepkg(8), - * \b pacman(8), - * \b pacman.conf(5) - * @{ - */ - - */ - #ifndef ALPM_LIST_H #define ALPM_LIST_H
@@ -50,7 +33,8 @@ extern "C" { #endif
/** - * @addtogroup alpm_list List Functions + * @ingroup libalpm + * @addtogroup libalpm-list libalpm-list(3) * @brief Functions to manipulate alpm_list_t lists. * * These functions are designed to create, destroy, and modify lists of @@ -60,7 +44,7 @@ extern "C" { * It is exposed so front ends can use it to prevent the need to reimplement * lists of their own; however, it is not required that the front end uses * it. - * @{ + * @{ */
/** A doubly linked list */
On 21/12/2020 01:47, Allan McRae wrote:
There seems to be a lot of duplication from our footer.asciidoc here. Why?
Just because I don't know how to de duplicate it. Doxygen does not seem to provide a way to use asciidoc or include a raw footer. I don't know how else to do about it.
--- doc/libalpm.3.asciidoc | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 doc/libalpm.3.asciidoc diff --git a/doc/libalpm.3.asciidoc b/doc/libalpm.3.asciidoc deleted file mode 100644 index 79ea5409..00000000 --- a/doc/libalpm.3.asciidoc +++ /dev/null @@ -1,37 +0,0 @@ -libalpm(3) -========== - -Name ----- -libalpm - Arch Linux Package Management (ALPM) library - - -Synopsis --------- -For ease of access, the libalpm manual has been split up into several sections. - -*TODO:* Yes, this man page needs a lot of work. Once we get around to doing -good Doxygen documentation, it will improve. We promise. - -*alpm_databases*:: Database Functions -*alpm_interface*:: Interface Functions -*alpm_list*:: List Functions -*alpm_log*:: Logging Functions -*alpm_misc*:: Miscellaneous Functions -*alpm_packages*:: Package Functions -*alpm_sync*:: Sync Functions -*alpm_trans*:: Transaction Functions - - -Configuration -------------- -See linkman:pacman.conf[5] for more details on configuring libalpm using the -'pacman.conf' file. - - -See Also --------- -linkman:alpm-hooks[5], linkman:makepkg[8], linkman:pacman[8], -linkman:pacman.conf[5] - -include::footer.asciidoc[] -- 2.29.2
I enjoy writing docs, is there anywhere you'd like a hand? On Mon, 7 Dec 2020, at 14:19, morganamilo wrote:
Here's a redo of my original docs patch and more.
This time it's split in to many commits so it's hopefully easier to review/rebase.
Every function, struct and param is now documented.
Simply `man libalpm` to get the main page. Then `man libalpm-databases` to see the database section and so on for each section.
Also while doing all this, I thought it would make sense to change some function names:
I also think alpm_unlock() should be named alpm_db_unlock() and alpm_sync_get_new_version() should be named alpm_pkg_get_new_version()
Then the functions could be moved into the db and packages groups repectivley.
To be clear I have not actually changed any function names in this patch set.
morganamilo (23): doc: remove stray doxygen comment doc: add doc header to alpm.h doc: document error doc: document handle doc: document signatures doc: document depends doc: document callbacks doc: document databases doc: document logging doc: document packages doc: document files and groups doc: document transactions doc: document misc doc: document alpm_list doc: document options doc: move alpm_api group to top of file doc: move top level items into groups doc: configure doxygen doc: update doxyfile doc: rename alpm_api group to alpm doc: add extra documentation to the man page doc: change group names to libalpm_* doc: remove old libalpm man file
doc/Doxyfile.in | 83 +- doc/libalpm.3.asciidoc | 37 - doc/meson.build | 1 - lib/libalpm/alpm.h | 2429 +++++++++++++++++++++++++++------------ lib/libalpm/alpm_list.c | 251 ---- lib/libalpm/alpm_list.h | 293 ++++- lib/libalpm/trans.c | 2 - 7 files changed, 2048 insertions(+), 1048 deletions(-) delete mode 100644 doc/libalpm.3.asciidoc
-- 2.29.2
On 07/12/2020 22:59, Colin Woodbury wrote:
I enjoy writing docs, is there anywhere you'd like a hand?
On Mon, 7 Dec 2020, at 14:19, morganamilo wrote:
Here's a redo of my original docs patch and more.
This time it's split in to many commits so it's hopefully easier to review/rebase.
Every function, struct and param is now documented.
Simply `man libalpm` to get the main page. Then `man libalpm-databases` to see the database section and so on for each section.
Also while doing all this, I thought it would make sense to change some function names:
I also think alpm_unlock() should be named alpm_db_unlock() and alpm_sync_get_new_version() should be named alpm_pkg_get_new_version()
Then the functions could be moved into the db and packages groups repectivley.
To be clear I have not actually changed any function names in this patch set.
morganamilo (23): doc: remove stray doxygen comment doc: add doc header to alpm.h doc: document error doc: document handle doc: document signatures doc: document depends doc: document callbacks doc: document databases doc: document logging doc: document packages doc: document files and groups doc: document transactions doc: document misc doc: document alpm_list doc: document options doc: move alpm_api group to top of file doc: move top level items into groups doc: configure doxygen doc: update doxyfile doc: rename alpm_api group to alpm doc: add extra documentation to the man page doc: change group names to libalpm_* doc: remove old libalpm man file
doc/Doxyfile.in | 83 +- doc/libalpm.3.asciidoc | 37 - doc/meson.build | 1 - lib/libalpm/alpm.h | 2429 +++++++++++++++++++++++++++------------ lib/libalpm/alpm_list.c | 251 ---- lib/libalpm/alpm_list.h | 293 ++++- lib/libalpm/trans.c | 2 - 7 files changed, 2048 insertions(+), 1048 deletions(-) delete mode 100644 doc/libalpm.3.asciidoc
-- 2.29.2
You're a little late now ;) I guess go review it for me :P
participants (4)
-
Allan McRae
-
Colin Woodbury
-
Morgan Adamiec
-
morganamilo