1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-21 23:38:49 -05:00

Represent bitfields as ints, not enums

Many bitfield variables are declared to be enums, because they are
generated using bitwise operations on enums such. However, their
actual values aren't necessary members of their parent enum, so
declaring them 'int' is more accurate.

Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Ivy Foster 2016-10-12 15:13:32 -05:00 committed by Allan McRae
parent a55adb81d0
commit fa06951d90
24 changed files with 122 additions and 108 deletions

View File

@ -152,7 +152,7 @@ const char SYMEXPORT *alpm_version(void)
/** Get the capabilities of the library. /** Get the capabilities of the library.
* @return a bitmask of the capabilities * @return a bitmask of the capabilities
* */ * */
enum alpm_caps SYMEXPORT alpm_capabilities(void) int SYMEXPORT alpm_capabilities(void)
{ {
return 0 return 0
#ifdef ENABLE_NLS #ifdef ENABLE_NLS

View File

@ -917,14 +917,14 @@ int alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace);
const char *alpm_option_get_dbext(alpm_handle_t *handle); const char *alpm_option_get_dbext(alpm_handle_t *handle);
int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext); int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext);
alpm_siglevel_t alpm_option_get_default_siglevel(alpm_handle_t *handle); int alpm_option_get_default_siglevel(alpm_handle_t *handle);
int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t level); int alpm_option_set_default_siglevel(alpm_handle_t *handle, int level);
alpm_siglevel_t alpm_option_get_local_file_siglevel(alpm_handle_t *handle); int alpm_option_get_local_file_siglevel(alpm_handle_t *handle);
int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level); int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, int level);
alpm_siglevel_t alpm_option_get_remote_file_siglevel(alpm_handle_t *handle); int alpm_option_get_remote_file_siglevel(alpm_handle_t *handle);
int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level); int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int level);
/** @} */ /** @} */
@ -957,7 +957,7 @@ alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle);
* @return an alpm_db_t* on success (the value), NULL on error * @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, alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename,
alpm_siglevel_t level); int level);
/** Unregister all package databases. /** Unregister all package databases.
* @param handle the context handle * @param handle the context handle
@ -983,7 +983,7 @@ const char *alpm_db_get_name(const alpm_db_t *db);
* @param db pointer to the package database * @param db pointer to the package database
* @return the signature verification level * @return the signature verification level
*/ */
alpm_siglevel_t alpm_db_get_siglevel(alpm_db_t *db); int alpm_db_get_siglevel(alpm_db_t *db);
/** Check the validity of a database. /** Check the validity of a database.
* This is most useful for sync databases and verifying signature status. * This is most useful for sync databases and verifying signature status.
@ -1050,14 +1050,14 @@ typedef enum _alpm_db_usage_ {
* @param usage a bitmask of alpm_db_usage_t values * @param usage a bitmask of alpm_db_usage_t values
* @return 0 on success, or -1 on error * @return 0 on success, or -1 on error
*/ */
int alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage); int alpm_db_set_usage(alpm_db_t *db, int usage);
/** Gets the usage of a database. /** Gets the usage of a database.
* @param db pointer to the package database to get the status of * @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 * @param usage pointer to an alpm_db_usage_t to store db's status
* @return 0 on success, or -1 on error * @return 0 on success, or -1 on error
*/ */
int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage); int alpm_db_get_usage(alpm_db_t *db, int *usage);
/** @} */ /** @} */
@ -1081,7 +1081,7 @@ int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage);
* @return 0 on success, -1 on error (pm_errno is set accordingly) * @return 0 on success, -1 on error (pm_errno is set accordingly)
*/ */
int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full, int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
alpm_siglevel_t level, alpm_pkg_t **pkg); int level, alpm_pkg_t **pkg);
/** Find a package in a list by name. /** Find a package in a list by name.
* @param haystack a list of alpm_pkg_t * @param haystack a list of alpm_pkg_t
@ -1318,7 +1318,7 @@ const char *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg);
* @param pkg a pointer to package * @param pkg a pointer to package
* @return an enum member giving the validation method * @return an enum member giving the validation method
*/ */
alpm_pkgvalidation_t alpm_pkg_get_validation(alpm_pkg_t *pkg); int alpm_pkg_get_validation(alpm_pkg_t *pkg);
/* End of alpm_pkg_t accessors */ /* End of alpm_pkg_t accessors */
/* @} */ /* @} */
@ -1480,7 +1480,7 @@ typedef enum _alpm_transflag_t {
* @param handle the context handle * @param handle the context handle
* @return the bitfield of transaction flags * @return the bitfield of transaction flags
*/ */
alpm_transflag_t alpm_trans_get_flags(alpm_handle_t *handle); int alpm_trans_get_flags(alpm_handle_t *handle);
/** Returns a list of packages added by the transaction. /** Returns a list of packages added by the transaction.
* @param handle the context handle * @param handle the context handle
@ -1496,10 +1496,10 @@ alpm_list_t *alpm_trans_get_remove(alpm_handle_t *handle);
/** Initialize the transaction. /** Initialize the transaction.
* @param handle the context handle * @param handle the context handle
* @param flags flags of the transaction (like nodeps, etc) * @param flags flags of the transaction (like nodeps, etc; see alpm_transflag_t)
* @return 0 on success, -1 on error (pm_errno is set accordingly) * @return 0 on success, -1 on error (pm_errno is set accordingly)
*/ */
int alpm_trans_init(alpm_handle_t *handle, alpm_transflag_t flags); int alpm_trans_init(alpm_handle_t *handle, int flags);
/** Prepare a transaction. /** Prepare a transaction.
* @param handle the context handle * @param handle the context handle
@ -1613,7 +1613,8 @@ enum alpm_caps {
}; };
const char *alpm_version(void); const char *alpm_version(void);
enum alpm_caps alpm_capabilities(void); /* Return a bitfield of capabilities using values from 'enum alpm_caps' */
int alpm_capabilities(void);
void alpm_fileconflict_free(alpm_fileconflict_t *conflict); void alpm_fileconflict_free(alpm_fileconflict_t *conflict);
void alpm_depmissing_free(alpm_depmissing_t *miss); void alpm_depmissing_free(alpm_depmissing_t *miss);

View File

@ -47,7 +47,7 @@
/* local database format version */ /* local database format version */
size_t ALPM_LOCAL_DB_VERSION = 9; size_t ALPM_LOCAL_DB_VERSION = 9;
static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq); static int local_db_read(alpm_pkg_t *info, int inforeq);
#define LAZY_LOAD(info, errret) \ #define LAZY_LOAD(info, errret) \
do { \ do { \
@ -117,7 +117,7 @@ static alpm_pkgreason_t _cache_get_reason(alpm_pkg_t *pkg)
return pkg->reason; return pkg->reason;
} }
static alpm_pkgvalidation_t _cache_get_validation(alpm_pkg_t *pkg) static int _cache_get_validation(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC, -1); LAZY_LOAD(INFRQ_DESC, -1);
return pkg->validation; return pkg->validation;
@ -660,7 +660,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info,
f = alpm_list_add(f, alpm_dep_from_string(line)); \ f = alpm_list_add(f, alpm_dep_from_string(line)); \
} while(1) /* note the while(1) and not (0) */ } while(1) /* note the while(1) and not (0) */
static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) static int local_db_read(alpm_pkg_t *info, int inforeq)
{ {
FILE *fp = NULL; FILE *fp = NULL;
char line[1024]; char line[1024];
@ -910,7 +910,7 @@ static void write_deps(FILE *fp, const char *header, alpm_list_t *deplist)
fputc('\n', fp); fputc('\n', fp);
} }
int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq) int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq)
{ {
FILE *fp = NULL; FILE *fp = NULL;
mode_t oldmask; mode_t oldmask;

View File

@ -270,8 +270,8 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
* @return 0 if package is fully valid, -1 and pm_errno otherwise * @return 0 if package is fully valid, -1 and pm_errno otherwise
*/ */
int _alpm_pkg_validate_internal(alpm_handle_t *handle, int _alpm_pkg_validate_internal(alpm_handle_t *handle,
const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level, const char *pkgfile, alpm_pkg_t *syncpkg, int level,
alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation) alpm_siglist_t **sigdata, int *validation)
{ {
int has_sig; int has_sig;
handle->pm_errno = ALPM_ERR_OK; handle->pm_errno = ALPM_ERR_OK;
@ -726,9 +726,9 @@ static int read_sigfile(const char *sigpath, unsigned char **sig)
} }
int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full, int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
alpm_siglevel_t level, alpm_pkg_t **pkg) int level, alpm_pkg_t **pkg)
{ {
alpm_pkgvalidation_t validation = 0; int validation = 0;
char *sigpath; char *sigpath;
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);

View File

@ -71,7 +71,7 @@ static char *get_sync_dir(alpm_handle_t *handle)
static int sync_db_validate(alpm_db_t *db) static int sync_db_validate(alpm_db_t *db)
{ {
alpm_siglevel_t level; int siglevel;
const char *dbpath; const char *dbpath;
if(db->status & DB_STATUS_VALID || db->status & DB_STATUS_MISSING) { if(db->status & DB_STATUS_VALID || db->status & DB_STATUS_MISSING) {
@ -104,20 +104,20 @@ static int sync_db_validate(alpm_db_t *db)
/* this takes into account the default verification level if UNKNOWN /* this takes into account the default verification level if UNKNOWN
* was assigned to this db */ * was assigned to this db */
level = alpm_db_get_siglevel(db); siglevel = alpm_db_get_siglevel(db);
if(level & ALPM_SIG_DATABASE) { if(siglevel & ALPM_SIG_DATABASE) {
int retry, ret; int retry, ret;
do { do {
retry = 0; retry = 0;
alpm_siglist_t *siglist; alpm_siglist_t *siglist;
ret = _alpm_check_pgp_helper(db->handle, dbpath, NULL, ret = _alpm_check_pgp_helper(db->handle, dbpath, NULL,
level & ALPM_SIG_DATABASE_OPTIONAL, level & ALPM_SIG_DATABASE_MARGINAL_OK, siglevel & ALPM_SIG_DATABASE_OPTIONAL, siglevel & ALPM_SIG_DATABASE_MARGINAL_OK,
level & ALPM_SIG_DATABASE_UNKNOWN_OK, &siglist); siglevel & ALPM_SIG_DATABASE_UNKNOWN_OK, &siglist);
if(ret) { if(ret) {
retry = _alpm_process_siglist(db->handle, db->treename, siglist, retry = _alpm_process_siglist(db->handle, db->treename, siglist,
level & ALPM_SIG_DATABASE_OPTIONAL, level & ALPM_SIG_DATABASE_MARGINAL_OK, siglevel & ALPM_SIG_DATABASE_OPTIONAL, siglevel & ALPM_SIG_DATABASE_MARGINAL_OK,
level & ALPM_SIG_DATABASE_UNKNOWN_OK); siglevel & ALPM_SIG_DATABASE_UNKNOWN_OK);
} }
alpm_siglist_cleanup(siglist); alpm_siglist_cleanup(siglist);
free(siglist); free(siglist);
@ -181,7 +181,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
int ret = -1; int ret = -1;
mode_t oldmask; mode_t oldmask;
alpm_handle_t *handle; alpm_handle_t *handle;
alpm_siglevel_t level; int siglevel;
/* Sanity checks */ /* Sanity checks */
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
@ -207,7 +207,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* make sure we have a sane umask */ /* make sure we have a sane umask */
oldmask = umask(0022); oldmask = umask(0022);
level = alpm_db_get_siglevel(db); siglevel = alpm_db_get_siglevel(db);
/* attempt to grab a lock */ /* attempt to grab a lock */
if(_alpm_handle_lock(handle)) { if(_alpm_handle_lock(handle)) {
@ -247,7 +247,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
_alpm_dload_payload_reset(&payload); _alpm_dload_payload_reset(&payload);
updated = (updated || ret == 0); updated = (updated || ret == 0);
if(ret != -1 && updated && (level & ALPM_SIG_DATABASE)) { if(ret != -1 && updated && (siglevel & ALPM_SIG_DATABASE)) {
/* an existing sig file is no good at this point */ /* an existing sig file is no good at this point */
char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db)); char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db));
if(!sigpath) { if(!sigpath) {
@ -292,7 +292,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
payload.handle = handle; payload.handle = handle;
payload.force = 1; payload.force = 1;
payload.errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL); payload.errors_ok = (siglevel & ALPM_SIG_DATABASE_OPTIONAL);
/* set hard upper limit of 16KiB */ /* set hard upper limit of 16KiB */
payload.max_size = 16 * 1024; payload.max_size = 16 * 1024;
@ -343,7 +343,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
static int sync_db_read(alpm_db_t *db, struct archive *archive, static int sync_db_read(alpm_db_t *db, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t **likely_pkg); struct archive_entry *entry, alpm_pkg_t **likely_pkg);
static alpm_pkgvalidation_t _sync_get_validation(alpm_pkg_t *pkg) static int _sync_get_validation(alpm_pkg_t *pkg)
{ {
if(pkg->validation) { if(pkg->validation) {
return pkg->validation; return pkg->validation;
@ -769,7 +769,7 @@ struct db_operations sync_db_ops = {
}; };
alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename, alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
alpm_siglevel_t level) int level)
{ {
alpm_db_t *db; alpm_db_t *db;

View File

@ -44,7 +44,7 @@
/** Register a sync database of packages. */ /** Register a sync database of packages. */
alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle, alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
const char *treename, alpm_siglevel_t level) const char *treename, int siglevel)
{ {
alpm_list_t *i; alpm_list_t *i;
@ -67,7 +67,7 @@ alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
} }
} }
return _alpm_db_register_sync(handle, treename, level); return _alpm_db_register_sync(handle, treename, siglevel);
} }
/* Helper function for alpm_db_unregister{_all} */ /* Helper function for alpm_db_unregister{_all} */
@ -235,7 +235,7 @@ const char SYMEXPORT *alpm_db_get_name(const alpm_db_t *db)
} }
/** Get the signature verification level for a database. */ /** Get the signature verification level for a database. */
alpm_siglevel_t SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db) int SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
{ {
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
if(db->siglevel & ALPM_SIG_USE_DEFAULT) { if(db->siglevel & ALPM_SIG_USE_DEFAULT) {
@ -307,7 +307,7 @@ alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
} }
/** Sets the usage bitmask for a repo */ /** Sets the usage bitmask for a repo */
int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage) int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, int usage)
{ {
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
db->usage = usage; db->usage = usage;
@ -315,7 +315,7 @@ int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage)
} }
/** Gets the usage bitmask for a repo */ /** Gets the usage bitmask for a repo */
int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage) int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, int *usage)
{ {
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
ASSERT(usage != NULL, return -1); ASSERT(usage != NULL, return -1);

View File

@ -71,10 +71,14 @@ struct __alpm_db_t {
alpm_list_t *grpcache; alpm_list_t *grpcache;
alpm_list_t *servers; alpm_list_t *servers;
struct db_operations *ops; struct db_operations *ops;
/* flags determining validity, local, loaded caches, etc. */
enum _alpm_dbstatus_t status; /* bitfields for validity, local, loaded caches, etc. */
alpm_siglevel_t siglevel; /* From _alpm_dbstatus_t */
alpm_db_usage_t usage; int status;
/* alpm_siglevel_t */
int siglevel;
/* alpm_db_usage_t */
int usage;
}; };
@ -86,12 +90,12 @@ int _alpm_db_cmp(const void *d1, const void *d2);
alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles); alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle); alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle);
alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename, alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
alpm_siglevel_t level); int level);
void _alpm_db_unregister(alpm_db_t *db); void _alpm_db_unregister(alpm_db_t *db);
/* be_*.c, backend specific calls */ /* be_*.c, backend specific calls */
int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info); int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info);
int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq); int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq);
int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info); int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info);
char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename); char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename);

View File

@ -777,7 +777,7 @@ int SYMEXPORT alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext)
} }
int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle, int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle,
alpm_siglevel_t level) int level)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
@ -790,14 +790,14 @@ int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle,
return 0; return 0;
} }
alpm_siglevel_t SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle) int SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
return handle->siglevel; return handle->siglevel;
} }
int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle, int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle,
alpm_siglevel_t level) int level)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
@ -810,7 +810,7 @@ int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle,
return 0; return 0;
} }
alpm_siglevel_t SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle) int SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
if(handle->localfilesiglevel & ALPM_SIG_USE_DEFAULT) { if(handle->localfilesiglevel & ALPM_SIG_USE_DEFAULT) {
@ -821,7 +821,7 @@ alpm_siglevel_t SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *han
} }
int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle,
alpm_siglevel_t level) int level)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
@ -834,7 +834,7 @@ int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle,
return 0; return 0;
} }
alpm_siglevel_t SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle) int SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
if(handle->remotefilesiglevel & ALPM_SIG_USE_DEFAULT) { if(handle->remotefilesiglevel & ALPM_SIG_USE_DEFAULT) {

View File

@ -97,10 +97,10 @@ struct __alpm_handle_t {
int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */ int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
int checkspace; /* Check disk space before installing */ int checkspace; /* Check disk space before installing */
char *dbext; /* Sync DB extension */ char *dbext; /* Sync DB extension */
alpm_siglevel_t siglevel; /* Default signature verification level */ int siglevel; /* Default signature verification level */
alpm_siglevel_t localfilesiglevel; /* Signature verification level for local file int localfilesiglevel; /* Signature verification level for local file
upgrade operations */ upgrade operations */
alpm_siglevel_t remotefilesiglevel; /* Signature verification level for remote file int remotefilesiglevel; /* Signature verification level for remote file
upgrade operations */ upgrade operations */
/* error code */ /* error code */

View File

@ -92,7 +92,7 @@ static const char *_pkg_get_packager(alpm_pkg_t *pkg) { return pkg->packager;
static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; } static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; }
static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; } static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; }
static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; } static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
static alpm_pkgvalidation_t _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; } static int _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; }
static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; } static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; }
static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg) { return pkg->licenses; } static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg) { return pkg->licenses; }
@ -300,7 +300,7 @@ alpm_pkgreason_t SYMEXPORT alpm_pkg_get_reason(alpm_pkg_t *pkg)
return pkg->ops->get_reason(pkg); return pkg->ops->get_reason(pkg);
} }
alpm_pkgvalidation_t SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg) int SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = ALPM_ERR_OK;

View File

@ -52,7 +52,7 @@ struct pkg_operations {
const char *(*get_arch) (alpm_pkg_t *); const char *(*get_arch) (alpm_pkg_t *);
off_t (*get_isize) (alpm_pkg_t *); off_t (*get_isize) (alpm_pkg_t *);
alpm_pkgreason_t (*get_reason) (alpm_pkg_t *); alpm_pkgreason_t (*get_reason) (alpm_pkg_t *);
alpm_pkgvalidation_t (*get_validation) (alpm_pkg_t *); int (*get_validation) (alpm_pkg_t *);
int (*has_scriptlet) (alpm_pkg_t *); int (*has_scriptlet) (alpm_pkg_t *);
alpm_list_t *(*get_licenses) (alpm_pkg_t *); alpm_list_t *(*get_licenses) (alpm_pkg_t *);
@ -130,11 +130,14 @@ struct __alpm_pkg_t {
char *file; char *file;
} origin_data; } origin_data;
alpm_dbinfrq_t infolevel;
alpm_pkgvalidation_t validation;
alpm_pkgfrom_t origin; alpm_pkgfrom_t origin;
alpm_pkgreason_t reason; alpm_pkgreason_t reason;
int scriptlet; int scriptlet;
/* Bitfield from alpm_dbinfrq_t */
int infolevel;
/* Bitfield from alpm_pkgvalidation_t */
int validation;
}; };
alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src); alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src);
@ -145,8 +148,8 @@ void _alpm_pkg_free(alpm_pkg_t *pkg);
void _alpm_pkg_free_trans(alpm_pkg_t *pkg); void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
int _alpm_pkg_validate_internal(alpm_handle_t *handle, int _alpm_pkg_validate_internal(alpm_handle_t *handle,
const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level, const char *pkgfile, alpm_pkg_t *syncpkg, int level,
alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation); alpm_siglist_t **sigdata, int *validation);
alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
const char *pkgfile, int full); const char *pkgfile, int full);

View File

@ -1056,7 +1056,7 @@ static int check_keyring(alpm_handle_t *handle)
for(i = handle->trans->add; i; i = i->next, current++) { for(i = handle->trans->add; i; i = i->next, current++) {
alpm_pkg_t *pkg = i->data; alpm_pkg_t *pkg = i->data;
alpm_siglevel_t level; int level;
int percent = (current * 100) / numtargs; int percent = (current * 100) / numtargs;
PROGRESS(handle, ALPM_PROGRESS_KEYRING_START, "", percent, PROGRESS(handle, ALPM_PROGRESS_KEYRING_START, "", percent,
@ -1126,8 +1126,8 @@ static int check_validity(alpm_handle_t *handle,
alpm_pkg_t *pkg; alpm_pkg_t *pkg;
char *path; char *path;
alpm_siglist_t *siglist; alpm_siglist_t *siglist;
alpm_siglevel_t level; int siglevel;
alpm_pkgvalidation_t validation; int validation;
alpm_errno_t error; alpm_errno_t error;
}; };
size_t current = 0; size_t current = 0;
@ -1151,10 +1151,10 @@ static int check_validity(alpm_handle_t *handle,
current_bytes += v.pkg->size; current_bytes += v.pkg->size;
v.path = _alpm_filecache_find(handle, v.pkg->filename); v.path = _alpm_filecache_find(handle, v.pkg->filename);
v.level = alpm_db_get_siglevel(alpm_pkg_get_db(v.pkg)); v.siglevel = alpm_db_get_siglevel(alpm_pkg_get_db(v.pkg));
if(_alpm_pkg_validate_internal(handle, v.path, v.pkg, if(_alpm_pkg_validate_internal(handle, v.path, v.pkg,
v.level, &v.siglist, &v.validation) == -1) { v.siglevel, &v.siglist, &v.validation) == -1) {
struct validity *invalid; struct validity *invalid;
v.error = handle->pm_errno; v.error = handle->pm_errno;
MALLOC(invalid, sizeof(struct validity), return -1); MALLOC(invalid, sizeof(struct validity), return -1);
@ -1181,9 +1181,9 @@ static int check_validity(alpm_handle_t *handle,
_("%s: missing required signature\n"), v->pkg->name); _("%s: missing required signature\n"), v->pkg->name);
} else if(v->error == ALPM_ERR_PKG_INVALID_SIG) { } else if(v->error == ALPM_ERR_PKG_INVALID_SIG) {
_alpm_process_siglist(handle, v->pkg->name, v->siglist, _alpm_process_siglist(handle, v->pkg->name, v->siglist,
v->level & ALPM_SIG_PACKAGE_OPTIONAL, v->siglevel & ALPM_SIG_PACKAGE_OPTIONAL,
v->level & ALPM_SIG_PACKAGE_MARGINAL_OK, v->siglevel & ALPM_SIG_PACKAGE_MARGINAL_OK,
v->level & ALPM_SIG_PACKAGE_UNKNOWN_OK); v->siglevel & ALPM_SIG_PACKAGE_UNKNOWN_OK);
prompt_to_delete(handle, v->path, v->error); prompt_to_delete(handle, v->path, v->error);
} else if(v->error == ALPM_ERR_PKG_INVALID_CHECKSUM) { } else if(v->error == ALPM_ERR_PKG_INVALID_CHECKSUM) {
prompt_to_delete(handle, v->path, v->error); prompt_to_delete(handle, v->path, v->error);

View File

@ -48,7 +48,7 @@
*/ */
/** Initialize the transaction. */ /** Initialize the transaction. */
int SYMEXPORT alpm_trans_init(alpm_handle_t *handle, alpm_transflag_t flags) int SYMEXPORT alpm_trans_init(alpm_handle_t *handle, int flags)
{ {
alpm_trans_t *trans; alpm_trans_t *trans;
@ -415,7 +415,7 @@ cleanup:
return retval; return retval;
} }
alpm_transflag_t SYMEXPORT alpm_trans_get_flags(alpm_handle_t *handle) int SYMEXPORT alpm_trans_get_flags(alpm_handle_t *handle)
{ {
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);

View File

@ -37,7 +37,8 @@ typedef enum _alpm_transstate_t {
/* Transaction */ /* Transaction */
struct __alpm_trans_t { struct __alpm_trans_t {
alpm_transflag_t flags; /* bitfield of alpm_transflag_t flags */
int flags;
alpm_transstate_t state; alpm_transstate_t state;
alpm_list_t *unresolvable; /* list of (alpm_pkg_t *) */ alpm_list_t *unresolvable; /* list of (alpm_pkg_t *) */
alpm_list_t *add; /* list of (alpm_pkg_t *) */ alpm_list_t *add; /* list of (alpm_pkg_t *) */
@ -46,7 +47,8 @@ struct __alpm_trans_t {
}; };
void _alpm_trans_free(alpm_trans_t *trans); void _alpm_trans_free(alpm_trans_t *trans);
int _alpm_trans_init(alpm_trans_t *trans, alpm_transflag_t flags); /* flags is a bitfield of alpm_transflag_t flags */
int _alpm_trans_init(alpm_trans_t *trans, int flags);
int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath, int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath,
const char *script, const char *ver, const char *oldver, int is_archive); const char *script, const char *ver, const char *oldver, int is_archive);

View File

@ -131,6 +131,8 @@ int _alpm_ldconfig(alpm_handle_t *handle);
int _alpm_str_cmp(const void *s1, const void *s2); int _alpm_str_cmp(const void *s1, const void *s2);
char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename); char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
const char *_alpm_filecache_setup(alpm_handle_t *handle); const char *_alpm_filecache_setup(alpm_handle_t *handle);
/* Unlike many uses of alpm_pkgvalidation_t, _alpm_test_checksum expects
* an enum value rather than a bitfield. */
int _alpm_test_checksum(const char *filepath, const char *expected, alpm_pkgvalidation_t type); int _alpm_test_checksum(const char *filepath, const char *expected, alpm_pkgvalidation_t type);
int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b); int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b);
int _alpm_splitname(const char *target, char **name, char **version, int _alpm_splitname(const char *target, char **name, char **version,

View File

@ -325,10 +325,10 @@ int config_set_arch(const char *arch)
* @param linenum current line number in file * @param linenum current line number in file
* @return 0 on success, 1 on any parsing error * @return 0 on success, 1 on any parsing error
*/ */
static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, static int process_siglevel(alpm_list_t *values, int *storage,
alpm_siglevel_t *storage_mask, const char *file, int linenum) int *storage_mask, const char *file, int linenum)
{ {
alpm_siglevel_t level = *storage, mask = *storage_mask; int level = *storage, mask = *storage_mask;
alpm_list_t *i; alpm_list_t *i;
int ret = 0; int ret = 0;
@ -421,13 +421,12 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
} }
/** /**
* Merge the package entires of two signature verification levels. * Merge the package entries of two signature verification levels.
* @param base initial siglevel * @param base initial siglevel
* @param over overridden siglevel * @param over overriding siglevel
* @return merged siglevel * @return merged siglevel
*/ */
static alpm_siglevel_t merge_siglevel(alpm_siglevel_t base, static int merge_siglevel(int base, int over, int mask)
alpm_siglevel_t over, alpm_siglevel_t mask)
{ {
return mask ? (over & mask) | (base & ~mask) : over; return mask ? (over & mask) | (base & ~mask) : over;
} }
@ -845,11 +844,11 @@ struct section_t {
int depth; int depth;
}; };
static int process_usage(alpm_list_t *values, alpm_db_usage_t *usage, static int process_usage(alpm_list_t *values, int *usage,
const char *file, int linenum) const char *file, int linenum)
{ {
alpm_list_t *i; alpm_list_t *i;
alpm_db_usage_t level = *usage; int level = *usage;
int ret = 0; int ret = 0;
for(i = values; i; i = i->next) { for(i = values; i; i = i->next) {

View File

@ -37,9 +37,9 @@ typedef struct __colstr_t {
typedef struct __config_repo_t { typedef struct __config_repo_t {
char *name; char *name;
alpm_list_t *servers; alpm_list_t *servers;
alpm_db_usage_t usage; int usage;
alpm_siglevel_t siglevel; int siglevel;
alpm_siglevel_t siglevel_mask; int siglevel_mask;
} config_repo_t; } config_repo_t;
typedef struct __config_t { typedef struct __config_t {
@ -95,14 +95,16 @@ typedef struct __config_t {
unsigned short group; unsigned short group;
unsigned short noask; unsigned short noask;
unsigned int ask; unsigned int ask;
alpm_transflag_t flags; /* Bitfield of alpm_transflag_t */
alpm_siglevel_t siglevel; int flags;
alpm_siglevel_t localfilesiglevel; /* Bitfields of alpm_siglevel_t */
alpm_siglevel_t remotefilesiglevel; int siglevel;
int localfilesiglevel;
int remotefilesiglevel;
alpm_siglevel_t siglevel_mask; int siglevel_mask;
alpm_siglevel_t localfilesiglevel_mask; int localfilesiglevel_mask;
alpm_siglevel_t remotefilesiglevel_mask; int remotefilesiglevel_mask;
/* conf file options */ /* conf file options */
/* I Love Candy! */ /* I Love Candy! */

View File

@ -230,7 +230,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
break; break;
} }
alpm_pkgvalidation_t v = alpm_pkg_get_validation(pkg); int v = alpm_pkg_get_validation(pkg);
if(v) { if(v) {
if(v & ALPM_PKG_VALIDATION_NONE) { if(v & ALPM_PKG_VALIDATION_NONE) {
validation = alpm_list_add(validation, _("None")); validation = alpm_list_add(validation, _("None"));

View File

@ -630,7 +630,7 @@ static int process_target(const char *target, int error)
if(targname && targname != targstring) { if(targname && targname != targstring) {
alpm_db_t *db; alpm_db_t *db;
const char *dbname; const char *dbname;
alpm_db_usage_t usage; int usage;
*targname = '\0'; *targname = '\0';
targname++; targname++;

View File

@ -89,15 +89,15 @@ int pacman_upgrade(alpm_list_t *targets)
for(i = targets, n = 0; i; i = alpm_list_next(i), n++) { for(i = targets, n = 0; i; i = alpm_list_next(i), n++) {
const char *targ = i->data; const char *targ = i->data;
alpm_pkg_t *pkg; alpm_pkg_t *pkg;
alpm_siglevel_t level; int siglevel;
if(file_is_remote[n]) { if(file_is_remote[n]) {
level = alpm_option_get_remote_file_siglevel(config->handle); siglevel = alpm_option_get_remote_file_siglevel(config->handle);
} else { } else {
level = alpm_option_get_local_file_siglevel(config->handle); siglevel = alpm_option_get_local_file_siglevel(config->handle);
} }
if(alpm_pkg_load(config->handle, targ, 1, level, &pkg) != 0) { if(alpm_pkg_load(config->handle, targ, 1, siglevel, &pkg) != 0) {
pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", pm_printf(ALPM_LOG_ERROR, "'%s': %s\n",
targ, alpm_strerror(alpm_errno(config->handle))); targ, alpm_strerror(alpm_errno(config->handle)));
retval = 1; retval = 1;

View File

@ -61,7 +61,7 @@ enum {
CELL_FREE = (1 << 3) CELL_FREE = (1 << 3)
}; };
int trans_init(alpm_transflag_t flags, int check_valid) int trans_init(int flags, int check_valid)
{ {
int ret; int ret;

View File

@ -45,7 +45,8 @@ typedef struct _pm_target_t {
} pm_target_t; } pm_target_t;
void trans_init_error(void); void trans_init_error(void);
int trans_init(alpm_transflag_t flags, int check_valid); /* flags is a bitfield of alpm_transflag_t flags */
int trans_init(int flags, int check_valid);
int trans_release(void); int trans_release(void);
int needs_root(void); int needs_root(void);
int check_syncdbs(size_t need_repos, int check_valid); int check_syncdbs(size_t need_repos, int check_valid);

View File

@ -68,11 +68,11 @@ static void checkdbs(alpm_list_t *dbnames)
{ {
alpm_db_t *db = NULL; alpm_db_t *db = NULL;
alpm_list_t *i; alpm_list_t *i;
const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL; const int siglevel = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
for(i = dbnames; i; i = alpm_list_next(i)) { for(i = dbnames; i; i = alpm_list_next(i)) {
const char *dbname = i->data; const char *dbname = i->data;
db = alpm_register_syncdb(handle, dbname, level); db = alpm_register_syncdb(handle, dbname, siglevel);
if(db == NULL) { if(db == NULL) {
fprintf(stderr, "error: could not register sync database '%s' (%s)\n", fprintf(stderr, "error: could not register sync database '%s' (%s)\n",
dbname, alpm_strerror(alpm_errno(handle))); dbname, alpm_strerror(alpm_errno(handle)));

View File

@ -43,7 +43,7 @@ int main(int argc, char *argv[])
alpm_handle_t *handle; alpm_handle_t *handle;
alpm_errno_t err; alpm_errno_t err;
alpm_pkg_t *pkg = NULL; alpm_pkg_t *pkg = NULL;
const alpm_siglevel_t level = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL; const int siglevel = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL;
if(argc != 2) { if(argc != 2) {
fprintf(stderr, "testpkg (pacman) v" PACKAGE_VERSION "\n\n" fprintf(stderr, "testpkg (pacman) v" PACKAGE_VERSION "\n\n"
@ -64,7 +64,7 @@ int main(int argc, char *argv[])
/* set gpgdir to default */ /* set gpgdir to default */
alpm_option_set_gpgdir(handle, GPGDIR); alpm_option_set_gpgdir(handle, GPGDIR);
if(alpm_pkg_load(handle, argv[1], 1, level, &pkg) == -1 if(alpm_pkg_load(handle, argv[1], 1, siglevel, &pkg) == -1
|| pkg == NULL) { || pkg == NULL) {
err = alpm_errno(handle); err = alpm_errno(handle);
switch(err) { switch(err) {