Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c2
-rw-r--r--lib/libalpm/alpm.c6
-rw-r--r--lib/libalpm/alpm.h132
-rw-r--r--lib/libalpm/be_files.c2
-rw-r--r--lib/libalpm/cache.c8
-rw-r--r--lib/libalpm/cache.h6
-rw-r--r--lib/libalpm/conflict.c2
-rw-r--r--lib/libalpm/conflict.h2
-rw-r--r--lib/libalpm/db.c2
-rw-r--r--lib/libalpm/db.h20
-rw-r--r--lib/libalpm/deps.c39
-rw-r--r--lib/libalpm/deps.h17
-rw-r--r--lib/libalpm/handle.c32
-rw-r--r--lib/libalpm/handle.h4
-rw-r--r--lib/libalpm/log.c2
-rw-r--r--lib/libalpm/log.h4
-rw-r--r--lib/libalpm/package.c4
-rw-r--r--lib/libalpm/package.h15
-rw-r--r--lib/libalpm/sync.c2
-rw-r--r--lib/libalpm/sync.h2
-rw-r--r--lib/libalpm/trans.c6
-rw-r--r--lib/libalpm/trans.h28
-rw-r--r--lib/libalpm/util.c4
-rw-r--r--lib/libalpm/util.h2
-rw-r--r--lib/libalpm/versioncmp.c14
25 files changed, 207 insertions, 150 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 5f7c024c..38c0c9aa 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -332,7 +332,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
register struct archive *archive;
struct archive_entry *entry;
char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
- unsigned char cb_state;
+ pmtransprog_t cb_state;
time_t t;
alpm_list_t *targ, *lp;
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index c604f4f5..6bfaaada 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -63,7 +63,7 @@
/* Globals */
pmhandle_t *handle = NULL;
-enum __pmerrno_t pm_errno;
+enum _pmerrno_t pm_errno;
/** \addtogroup alpm_interface Interface Functions
* @brief Functions to initialize and release libalpm
@@ -622,7 +622,9 @@ alpm_list_t *alpm_db_search(pmdb_t *db)
* @param progress progress callback function pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress)
+int alpm_trans_init(pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress progress)
{
char path[PATH_MAX];
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 1a227224..68723a0c 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -71,13 +71,15 @@ int alpm_release(void);
*/
/* Levels */
-#define PM_LOG_DEBUG 0x01
-#define PM_LOG_ERROR 0x02
-#define PM_LOG_WARNING 0x04
-#define PM_LOG_FLOW1 0x08
-#define PM_LOG_FLOW2 0x10
-#define PM_LOG_FUNCTION 0x20
-#define PM_LOG_DOWNLOAD 0x40
+typedef enum _pmloglevel_t {
+ PM_LOG_DEBUG = 0x01,
+ PM_LOG_ERROR = 0x02,
+ PM_LOG_WARNING = 0x04,
+ PM_LOG_FLOW1 = 0x08,
+ PM_LOG_FLOW2 = 0x10,
+ PM_LOG_FUNCTION = 0x20,
+ PM_LOG_DOWNLOAD = 0x40
+} pmloglevel_t;
typedef void (*alpm_cb_log)(unsigned short, char *);
int alpm_logaction(char *fmt, ...);
@@ -100,8 +102,8 @@ void alpm_option_set_logcb(alpm_cb_log cb);
alpm_cb_download alpm_option_get_dlcb();
void alpm_option_set_dlcb(alpm_cb_download cb);
-unsigned char alpm_option_get_logmask();
-void alpm_option_set_logmask(unsigned char mask);
+unsigned short alpm_option_get_logmask();
+void alpm_option_set_logmask(unsigned short mask);
const char *alpm_option_get_root();
void alpm_option_set_root(const char *root);
@@ -115,8 +117,8 @@ void alpm_option_set_cachedir(const char *cachedir);
const char *alpm_option_get_logfile();
void alpm_option_set_logfile(const char *logfile);
-unsigned char alpm_option_get_usesyslog();
-void alpm_option_set_usesyslog(unsigned char usesyslog);
+unsigned short alpm_option_get_usesyslog();
+void alpm_option_set_usesyslog(unsigned short usesyslog);
alpm_list_t *alpm_option_get_noupgrades();
void alpm_option_add_noupgrade(char *pkg);
@@ -188,19 +190,26 @@ alpm_list_t *alpm_db_search(pmdb_t *db);
/* Info parameters */
/* reasons -- ie, why the package was installed */
-#define PM_PKG_REASON_EXPLICIT 0 /* explicitly requested by the user */
-#define PM_PKG_REASON_DEPEND 1 /* installed as a dependency for another package */
+typedef enum _pmpkgreason_t {
+ PM_PKG_REASON_EXPLICIT = 0, /* explicitly requested by the user */
+ PM_PKG_REASON_DEPEND = 1 /* installed as a dependency for another package */
+} pmpkgreason_t;
/* package name formats */
-#define PM_PKG_WITHOUT_ARCH 0 /* pkgname-pkgver-pkgrel, used under PM_DBPATH */
-#define PM_PKG_WITH_ARCH 1 /* ie, pkgname-pkgver-pkgrel-arch, used under PM_CACHEDIR */
+/*
+typedef enum _pmpkghasarch_t {
+ PM_PKG_WITHOUT_ARCH = 0, / pkgname-pkgver-pkgrel, used under PM_DBPATH /
+ PM_PKG_WITH_ARCH = 1 / pkgname-pkgver-pkgrel-arch, used under PM_CACHEDIR /
+} pmpkghasarch_t;
+*/
int alpm_pkg_load(char *filename, pmpkg_t **pkg);
int alpm_pkg_free(pmpkg_t *pkg);
int alpm_pkg_checkmd5sum(pmpkg_t *pkg);
int alpm_pkg_checksha1sum(pmpkg_t *pkg);
char *alpm_fetch_pkgurl(char *url);
-int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this_section);
+int alpm_parse_config(char *file, alpm_cb_db_register callback,
+ const char *this_section);
int alpm_pkg_vercmp(const char *ver1, const char *ver2);
char *alpm_pkg_name_hasarch(char *pkgname);
@@ -218,7 +227,7 @@ const char *alpm_pkg_get_sha1sum(pmpkg_t *pkg);
const char *alpm_pkg_get_arch(pmpkg_t *pkg);
unsigned long alpm_pkg_get_size(pmpkg_t *pkg);
unsigned long alpm_pkg_get_isize(pmpkg_t *pkg);
-unsigned char alpm_pkg_get_reason(pmpkg_t *pkg);
+pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg);
@@ -229,7 +238,7 @@ alpm_list_t *alpm_pkg_get_provides(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_replaces(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_files(pmpkg_t *pkg);
alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg);
-unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg);
+unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg);
/*
* Groups
@@ -242,13 +251,13 @@ alpm_list_t *alpm_grp_get_packages(pmgrp_t *grp);
*/
/* Types */
-enum {
+typedef enum _pmsynctype_t {
PM_SYNC_TYPE_REPLACE = 1,
PM_SYNC_TYPE_UPGRADE,
PM_SYNC_TYPE_DEPEND
-};
+} pmsynctype_t;
-unsigned char alpm_sync_get_type(pmsyncpkg_t *sync);
+pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync);
pmpkg_t *alpm_sync_get_package(pmsyncpkg_t *sync);
void *alpm_sync_get_data(pmsyncpkg_t *sync);
@@ -257,30 +266,32 @@ void *alpm_sync_get_data(pmsyncpkg_t *sync);
*/
/* Types */
-enum {
+typedef enum _pmtranstype_t {
PM_TRANS_TYPE_ADD = 1,
PM_TRANS_TYPE_REMOVE,
PM_TRANS_TYPE_UPGRADE,
PM_TRANS_TYPE_SYNC
-};
+} pmtranstype_t;
/* Flags */
-#define PM_TRANS_FLAG_NODEPS 0x01
-#define PM_TRANS_FLAG_FORCE 0x02
-#define PM_TRANS_FLAG_NOSAVE 0x04
-#define PM_TRANS_FLAG_FRESHEN 0x08
-#define PM_TRANS_FLAG_CASCADE 0x10
-#define PM_TRANS_FLAG_RECURSE 0x20
-#define PM_TRANS_FLAG_DBONLY 0x40
-#define PM_TRANS_FLAG_DEPENDSONLY 0x80
-#define PM_TRANS_FLAG_ALLDEPS 0x100
-#define PM_TRANS_FLAG_DOWNLOADONLY 0x200
-#define PM_TRANS_FLAG_NOSCRIPTLET 0x400
-#define PM_TRANS_FLAG_NOCONFLICTS 0x800
-#define PM_TRANS_FLAG_PRINTURIS 0x1000
+typedef enum _pmtransflag_t {
+ PM_TRANS_FLAG_NODEPS = 0x01,
+ PM_TRANS_FLAG_FORCE = 0x02,
+ PM_TRANS_FLAG_NOSAVE = 0x04,
+ PM_TRANS_FLAG_FRESHEN = 0x08,
+ PM_TRANS_FLAG_CASCADE = 0x10,
+ PM_TRANS_FLAG_RECURSE = 0x20,
+ PM_TRANS_FLAG_DBONLY = 0x40,
+ PM_TRANS_FLAG_DEPENDSONLY = 0x80,
+ PM_TRANS_FLAG_ALLDEPS = 0x100,
+ PM_TRANS_FLAG_DOWNLOADONLY = 0x200,
+ PM_TRANS_FLAG_NOSCRIPTLET = 0x400,
+ PM_TRANS_FLAG_NOCONFLICTS = 0x800,
+ PM_TRANS_FLAG_PRINTURIS = 0x1000
+} pmtransflag_t;
/* Transaction Events */
-enum {
+typedef enum _pmtransevt_t {
PM_TRANS_EVT_CHECKDEPS_START = 1,
PM_TRANS_EVT_CHECKDEPS_DONE,
PM_TRANS_EVT_FILECONFLICTS_START,
@@ -306,10 +317,10 @@ enum {
PM_TRANS_EVT_PRINTURI,
PM_TRANS_EVT_RETRIEVE_START,
PM_TRANS_EVT_RETRIEVE_LOCAL
-};
+} pmtransevt_t;
/* Transaction Conversations (ie, questions) */
-enum {
+typedef enum _pmtransconv_t {
PM_TRANS_CONV_INSTALL_IGNOREPKG = 0x01,
PM_TRANS_CONV_REPLACE_PKG = 0x02,
PM_TRANS_CONV_CONFLICT_PKG = 0x04,
@@ -317,30 +328,33 @@ enum {
PM_TRANS_CONV_LOCAL_NEWER = 0x10,
PM_TRANS_CONV_LOCAL_UPTODATE = 0x20,
PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
-};
+} pmtransconv_t;
/* Transaction Progress */
-enum {
+typedef enum _pmtransprog_t {
PM_TRANS_PROGRESS_ADD_START,
PM_TRANS_PROGRESS_UPGRADE_START,
PM_TRANS_PROGRESS_REMOVE_START,
PM_TRANS_PROGRESS_CONFLICTS_START
-};
+} pmtransprog_t;
/* Transaction Event callback */
-typedef void (*alpm_trans_cb_event)(unsigned char, void *, void *);
+typedef void (*alpm_trans_cb_event)(pmtransevt_t, void *, void *);
/* Transaction Conversation callback */
-typedef void (*alpm_trans_cb_conv)(unsigned char, void *, void *, void *, int *);
+typedef void (*alpm_trans_cb_conv)(pmtransconv_t, void *, void *,
+ void *, int *);
/* Transaction Progress callback */
-typedef void (*alpm_trans_cb_progress)(unsigned char, char *, int, int, int);
+typedef void (*alpm_trans_cb_progress)(pmtransprog_t, char *, int, int, int);
-unsigned char alpm_trans_get_type();
+pmtranstype_t alpm_trans_get_type();
unsigned int alpm_trans_get_flags();
alpm_list_t * alpm_trans_get_targets();
alpm_list_t * alpm_trans_get_packages();
-int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv, alpm_trans_cb_progress cb_progress);
+int alpm_trans_init(pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress cb_progress);
int alpm_trans_sysupgrade(void);
int alpm_trans_addtarget(char *target);
int alpm_trans_prepare(alpm_list_t **data);
@@ -351,21 +365,22 @@ int alpm_trans_release(void);
* Dependencies and conflicts
*/
-enum {
+typedef enum _pmdepmod_t {
PM_DEP_MOD_ANY = 1,
PM_DEP_MOD_EQ,
PM_DEP_MOD_GE,
PM_DEP_MOD_LE
-};
-enum {
+} pmdepmod_t;
+
+typedef enum _pmdeptype_t {
PM_DEP_TYPE_DEPEND = 1,
PM_DEP_TYPE_REQUIRED,
PM_DEP_TYPE_CONFLICT
-};
+} pmdeptype_t;
const char *alpm_dep_get_target(pmdepmissing_t *miss);
-unsigned char alpm_dep_get_type(pmdepmissing_t *miss);
-unsigned char alpm_dep_get_mod(pmdepmissing_t *miss);
+pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss);
+pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss);
const char *alpm_dep_get_name(pmdepmissing_t *miss);
const char *alpm_dep_get_version(pmdepmissing_t *miss);
@@ -373,19 +388,20 @@ const char *alpm_dep_get_version(pmdepmissing_t *miss);
* File conflicts
*/
-enum {
+typedef enum _pmconflicttype_t {
PM_CONFLICT_TYPE_TARGET = 1,
PM_CONFLICT_TYPE_FILE
-};
+} pmconflicttype_t;
const char *alpm_conflict_get_target(pmconflict_t *conflict);
-unsigned char alpm_conflict_get_type(pmconflict_t *conflict);
+pmconflicttype_t alpm_conflict_get_type(pmconflict_t *conflict);
const char *alpm_conflict_get_file(pmconflict_t *conflict);
const char *alpm_conflict_get_ctarget(pmconflict_t *conflict);
/*
* Helpers
*/
+
/* md5sums */
char *alpm_get_md5sum(char *name);
@@ -394,7 +410,7 @@ char *alpm_get_sha1sum(char *name);
/*
* Errors
*/
-enum __pmerrno_t {
+enum _pmerrno_t {
PM_ERR_MEMORY = 1,
PM_ERR_SYSTEM,
PM_ERR_BADPERMS,
@@ -466,7 +482,7 @@ enum __pmerrno_t {
PM_ERR_FORK_FAILED
};
-extern enum __pmerrno_t pm_errno;
+extern enum _pmerrno_t pm_errno;
char *alpm_strerror(int err);
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index ba3e45a4..19e2bf1f 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -98,7 +98,7 @@ void _alpm_db_rewind(pmdb_t *db)
rewinddir(db->handle);
}
-pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq)
+pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq)
{
struct dirent *ent = NULL;
struct stat sbuf;
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index db04b465..d03cf203 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -41,12 +41,12 @@
/* Returns a new package cache from db.
* It frees the cache if it already exists.
*/
-int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel)
+int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
pmpkg_t *info;
int count = 0;
/* The group cache needs INFRQ_DESC as well */
- /*unsigned char infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
+ /* pmdbinfrq_t infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
if(db == NULL) {
return(-1);
@@ -86,7 +86,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
}
}
-alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
if(db == NULL) {
return(NULL);
@@ -101,7 +101,7 @@ alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
return(db->pkgcache);
}
-int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel)
+int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
{
int reloaded = 0;
/* for each pkg, check and reload if the requested
diff --git a/lib/libalpm/cache.h b/lib/libalpm/cache.h
index c17b8268..0ec2863e 100644
--- a/lib/libalpm/cache.h
+++ b/lib/libalpm/cache.h
@@ -27,12 +27,12 @@
#include "package.h"
/* packages */
-int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel);
+int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
void _alpm_db_free_pkgcache(pmdb_t *db);
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
-alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
-int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel);
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
+int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target);
/* groups */
int _alpm_db_load_grpcache(pmdb_t *db);
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 088320e6..58ffb726 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -368,7 +368,7 @@ const char *alpm_conflict_get_target(pmconflict_t *conflict)
return conflict->target;
}
-unsigned char alpm_conflict_get_type(pmconflict_t *conflict)
+pmconflicttype_t alpm_conflict_get_type(pmconflict_t *conflict)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h
index 07225991..69ce727c 100644
--- a/lib/libalpm/conflict.h
+++ b/lib/libalpm/conflict.h
@@ -28,7 +28,7 @@
struct __pmconflict_t {
char target[PKG_NAME_LEN];
- unsigned char type;
+ pmconflicttype_t type;
char file[CONFLICT_FILE_LEN];
char ctarget[PKG_NAME_LEN];
};
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 363ce2a5..1dece32d 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -110,7 +110,7 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles)
char *matched = NULL;
regex_t reg;
- if(regcomp(&reg, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0) {
+ if(regcomp(&reg, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) {
RET_ERR(PM_ERR_INVALID_REGEX, NULL);
}
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 6d9ddd2c..024fb78d 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -27,12 +27,14 @@
#include <limits.h>
/* Database entries */
-#define INFRQ_NONE 0x00
-#define INFRQ_DESC 0x01
-#define INFRQ_DEPENDS 0x02
-#define INFRQ_FILES 0x04
-#define INFRQ_SCRIPTLET 0x08
-#define INFRQ_ALL 0xFF
+typedef enum _pmdbinfrq_t {
+ INFRQ_NONE = 0x00,
+ INFRQ_DESC = 0x01,
+ INFRQ_DEPENDS = 0x02,
+ INFRQ_FILES = 0x04,
+ INFRQ_SCRIPTLET = 0x08,
+ INFRQ_ALL = 0xFF
+} pmdbinfrq_t;
/* Database */
struct __pmdb_t {
@@ -55,9 +57,9 @@ int _alpm_db_install(pmdb_t *db, const char *dbfile);
int _alpm_db_open(pmdb_t *db);
void _alpm_db_close(pmdb_t *db);
void _alpm_db_rewind(pmdb_t *db);
-pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq);
-int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info);
-int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq);
+pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq);
+int _alpm_db_read(pmdb_t *db, pmdbinfrq_t inforeq, pmpkg_t *info);
+int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info);
int _alpm_db_getlastupdate(pmdb_t *db, char *ts);
int _alpm_db_setlastupdate(pmdb_t *db, char *ts);
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 31aba2b4..3393f01f 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -44,8 +44,9 @@
extern pmhandle_t *handle;
-pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod,
- const char *depname, const char *depversion)
+pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
+ pmdepmod_t depmod, const char *depname,
+ const char *depversion)
{
pmdepmissing_t *miss;
@@ -187,7 +188,8 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode)
* dependencies can include versions with depmod operators.
*
*/
-alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages)
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
+ alpm_list_t *packages)
{
pmdepend_t depend;
alpm_list_t *i, *j, *k;
@@ -224,7 +226,7 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
continue;
}
if(_alpm_pkg_isin(p->name, packages)) {
- /* this package is also in the upgrade list, so don't worry about it */
+ /* this package also in the upgrade list, so don't worry about it */
continue;
}
_alpm_db_read(db, INFRQ_DEPENDS, p);
@@ -246,8 +248,10 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
FREELISTPTR(provides);
}
if(!_alpm_depcmp(tp, &depend)) {
- _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), depend.name, p->name);
- miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod, depend.name, depend.version);
+ _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
+ depend.name, p->name);
+ miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod,
+ depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -278,7 +282,8 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
_alpm_splitdep((char *)j->data, &depend);
found = 0;
/* check database for literal packages */
- for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS); k && !found; k = k->next) {
+ for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS);
+ k && !found; k = k->next) {
pmpkg_t *p = (pmpkg_t *)k->data;
found = _alpm_depcmp(p, &depend);
}
@@ -316,8 +321,9 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
/* else if still not found... */
if(!found) {
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as a dependency for %s"),
- depend.name, tp->name);
- miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod, depend.name, depend.version);
+ depend.name, tp->name);
+ miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod,
+ depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -363,8 +369,10 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
}
}
if(!found) {
- _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), reqname, tp->name);
- miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED, PM_DEP_MOD_ANY, j->data, NULL);
+ _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
+ reqname, tp->name);
+ miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED,
+ PM_DEP_MOD_ANY, j->data, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {
@@ -512,8 +520,9 @@ alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
*
* make sure *list and *trail are already initialized
*/
-int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
- alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data)
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
+ alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
+ alpm_list_t **data)
{
alpm_list_t *i, *j;
alpm_list_t *targ;
@@ -647,7 +656,7 @@ const char *alpm_dep_get_target(pmdepmissing_t *miss)
return miss->target;
}
-unsigned char alpm_dep_get_type(pmdepmissing_t *miss)
+pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
@@ -656,7 +665,7 @@ unsigned char alpm_dep_get_type(pmdepmissing_t *miss)
return miss->type;
}
-unsigned char alpm_dep_get_mod(pmdepmissing_t *miss)
+pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index d34d1eca..f69e1d5f 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -30,7 +30,7 @@
/* Dependency */
struct __pmdepend_t {
- unsigned char mod;
+ pmdepmod_t mod;
char name[PKG_NAME_LEN];
char version[PKG_VERSION_LEN];
};
@@ -38,19 +38,22 @@ struct __pmdepend_t {
/* Missing dependency */
struct __pmdepmissing_t {
char target[PKG_NAME_LEN];
- unsigned char type;
+ pmdeptype_t type;
pmdepend_t depend;
};
-pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod,
- const char *depname, const char *depversion);
+pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
+ pmdepmod_t depmod, const char *depname,
+ const char *depversion);
int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack);
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode);
-alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages);
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
+ alpm_list_t *packages);
int _alpm_splitdep(char *depstr, pmdepend_t *depend);
alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs);
-int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
- alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data);
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
+ alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
+ alpm_list_t **data);
#endif /* _ALPM_DEPS_H */
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 42490f6e..1c31e41d 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -117,12 +117,12 @@ int _alpm_handle_free(pmhandle_t *handle)
alpm_cb_log alpm_option_get_logcb() { return handle->logcb; }
alpm_cb_download alpm_option_get_dlcb() { return handle->dlcb; }
-unsigned char alpm_option_get_logmask() { return handle->logmask; }
+unsigned short alpm_option_get_logmask() { return handle->logmask; }
const char *alpm_option_get_root() { return handle->root; }
const char *alpm_option_get_dbpath() { return handle->dbpath; }
const char *alpm_option_get_cachedir() { return handle->cachedir; }
const char *alpm_option_get_logfile() { return handle->logfile; }
-unsigned char alpm_option_get_usesyslog() { return handle->usesyslog; }
+unsigned short alpm_option_get_usesyslog() { return handle->usesyslog; }
alpm_list_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
alpm_list_t *alpm_option_get_noextracts() { return handle->noextract; }
alpm_list_t *alpm_option_get_ignorepkgs() { return handle->ignorepkg; }
@@ -135,13 +135,16 @@ alpm_list_t *alpm_option_get_needles() { return handle->needles; }
unsigned short alpm_option_get_usecolor() { return handle->use_color; }
pmdb_t *alpm_option_get_localdb() { return handle->db_local; }
-alpm_list_t *alpm_option_get_syncdbs() { return handle->dbs_sync; }
+alpm_list_t *alpm_option_get_syncdbs()
+{
+ return handle->dbs_sync;
+}
void alpm_option_set_logcb(alpm_cb_log cb) { handle->logcb = cb; }
void alpm_option_set_dlcb(alpm_cb_download cb) { handle->dlcb = cb; }
-void alpm_option_set_logmask(unsigned char mask) { handle->logmask = mask; }
+void alpm_option_set_logmask(unsigned short mask) { handle->logmask = mask; }
void alpm_option_set_root(const char *root)
{
@@ -176,12 +179,16 @@ void alpm_option_set_logfile(const char *logfile)
}
}
-void alpm_option_set_usesyslog(unsigned char usesyslog) { handle->usesyslog = usesyslog; }
+void alpm_option_set_usesyslog(unsigned short usesyslog)
+{
+ handle->usesyslog = usesyslog;
+}
void alpm_option_add_noupgrade(char *pkg)
{
handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
}
+
void alpm_option_set_noupgrades(alpm_list_t *noupgrade)
{
if(handle->noupgrade) FREELIST(handle->noupgrade);
@@ -218,7 +225,10 @@ void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs)
if(holdpkgs) handle->holdpkg = holdpkgs;
}
-void alpm_option_set_upgradedelay(time_t delay) { handle->upgradedelay = delay; }
+void alpm_option_set_upgradedelay(time_t delay)
+{
+ handle->upgradedelay = delay;
+}
void alpm_option_set_xfercommand(const char *cmd)
{
@@ -226,7 +236,10 @@ void alpm_option_set_xfercommand(const char *cmd)
if(cmd) handle->xfercommand = strdup(cmd);
}
-void alpm_option_set_nopassiveftp(unsigned short nopasv) { handle->nopassiveftp = nopasv; }
+void alpm_option_set_nopassiveftp(unsigned short nopasv)
+{
+ handle->nopassiveftp = nopasv;
+}
void alpm_option_set_chomp(unsigned short chomp) { handle->chomp = chomp; }
@@ -239,6 +252,9 @@ void alpm_option_set_needles(alpm_list_t *needles)
if(handle->needles) FREELIST(handle->needles);
if(needles) handle->needles = needles;
}
-void alpm_option_set_usecolor(unsigned short usecolor) { handle->use_color = usecolor; }
+void alpm_option_set_usecolor(unsigned short usecolor)
+{
+ handle->use_color = usecolor;
+}
/* vim: set ts=2 sw=2 et: */
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index eb5f734e..0b0ddd0c 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -45,12 +45,12 @@ typedef struct _pmhandle_t {
/* options */
alpm_cb_log logcb; /* Log callback function */
alpm_cb_download dlcb; /* Download callback function */
- unsigned char logmask; /* Output mask for logging functions */
+ unsigned short logmask; /* Output mask for logging functions */
char *root; /* Root path, default '/' */
char *dbpath; /* Base path to pacman's DBs */
char *cachedir; /* Base path to pacman's cache */
char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
- unsigned char usesyslog; /* Use syslog instead of logfile? */
+ unsigned short usesyslog; /* Use syslog instead of logfile? */
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
alpm_list_t *noextract; /* List of packages NOT to extrace */ /*TODO is this used?*/
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index 2b543ae6..c1d2aa6a 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -27,7 +27,7 @@
#include "alpm.h"
#include "log.h"
-void _alpm_log(unsigned char flag, char *fmt, ...)
+void _alpm_log(pmloglevel_t flag, char *fmt, ...)
{
alpm_cb_log logcb = alpm_option_get_logcb();
if(logcb == NULL) {
diff --git a/lib/libalpm/log.h b/lib/libalpm/log.h
index ab35e72b..471f4b79 100644
--- a/lib/libalpm/log.h
+++ b/lib/libalpm/log.h
@@ -21,9 +21,11 @@
#ifndef _ALPM_LOG_H
#define _ALPM_LOG_H
+#include "alpm.h"
+
#define LOG_STR_LEN 1024
-void _alpm_log(unsigned char flag, char *fmt, ...);
+void _alpm_log(pmloglevel_t flag, char *fmt, ...);
#endif /* _ALPM_LOG_H */
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index eaeca1cd..f35797be 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -606,7 +606,7 @@ unsigned long alpm_pkg_get_isize(pmpkg_t *pkg)
return pkg->isize;
}
-unsigned char alpm_pkg_get_reason(pmpkg_t *pkg)
+pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
@@ -741,7 +741,7 @@ alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg)
return pkg->backup;
}
-unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg)
+unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 616131d5..50052326 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -30,11 +30,12 @@
#endif
#include "alpm.h"
+#include "db.h"
-enum {
+typedef enum _pmpkgfrom_t {
PKG_FROM_CACHE = 1,
PKG_FROM_FILE
-};
+} pmpkgfrom_t;
/* Packages */
#define PKG_FILENAME_LEN 512
@@ -65,10 +66,10 @@ struct __pmpkg_t {
char arch[PKG_ARCH_LEN];
unsigned long size;
unsigned long isize;
- unsigned char scriptlet;
- unsigned char force;
+ unsigned short scriptlet;
+ unsigned short force;
time_t date;
- unsigned char reason;
+ pmpkgreason_t reason;
alpm_list_t *desc_localized;
alpm_list_t *license;
alpm_list_t *replaces;
@@ -81,9 +82,9 @@ struct __pmpkg_t {
alpm_list_t *conflicts;
alpm_list_t *provides;
/* internal */
- unsigned char origin;
+ unsigned short origin;
void *data;
- unsigned char infolevel;
+ pmdbinfrq_t infolevel;
};
#define FREEPKG(p) do { if(p){_alpm_pkg_free(p); p = NULL;}} while(0)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index a4f527ed..1fd7c3cd 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -1069,7 +1069,7 @@ error:
return(-1);
}
-unsigned char alpm_sync_get_type(pmsyncpkg_t *sync)
+pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync)
{
/* Sanity checks */
ASSERT(sync != NULL, return(-1));
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index c01afd64..a2e2e11e 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -27,7 +27,7 @@
/* Sync package */
struct __pmsyncpkg_t {
- unsigned char type;
+ pmsynctype_t type;
pmpkg_t *pkg;
void *data;
};
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 20425b63..75d3489b 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -85,7 +85,9 @@ void _alpm_trans_free(void *data)
FREE(trans);
}
-int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress)
+int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress progress)
{
/* Sanity checks */
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -226,7 +228,7 @@ int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data)
return(0);
}
-unsigned char alpm_trans_get_type()
+pmtranstype_t alpm_trans_get_type()
{
/* Sanity checks */
ASSERT(handle != NULL, return(-1));
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index 2fcec2ed..8d5c6362 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -26,11 +26,21 @@
#include "alpm.h"
+typedef enum _pmtransstate_t {
+ STATE_IDLE = 0,
+ STATE_INITIALIZED,
+ STATE_PREPARED,
+ STATE_DOWNLOADING,
+ STATE_COMMITING,
+ STATE_COMMITED,
+ STATE_INTERRUPTED
+} pmtransstate_t;
+
/* Transaction */
struct __pmtrans_t {
- unsigned char type;
+ pmtranstype_t type;
unsigned int flags;
- unsigned char state;
+ pmtransstate_t state;
alpm_list_t *targets; /* alpm_list_t of (char *) */
alpm_list_t *packages; /* alpm_list_t of (pmpkg_t *) or (pmsyncpkg_t *) */
alpm_list_t *skiplist; /* alpm_list_t of (char *) */
@@ -39,16 +49,6 @@ struct __pmtrans_t {
alpm_trans_cb_progress cb_progress;
};
-enum {
- STATE_IDLE = 0,
- STATE_INITIALIZED,
- STATE_PREPARED,
- STATE_DOWNLOADING,
- STATE_COMMITING,
- STATE_COMMITED,
- STATE_INTERRUPTED
-};
-
#define FREETRANS(p) \
do { \
if(p) { \
@@ -77,7 +77,9 @@ do { \
pmtrans_t *_alpm_trans_new(void);
void _alpm_trans_free(void *data);
-int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress);
+int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, unsigned int flags,
+ alpm_trans_cb_event event, alpm_trans_cb_conv conv,
+ alpm_trans_cb_progress progress);
int _alpm_trans_sysupgrade(pmtrans_t *trans);
int _alpm_trans_addtarget(pmtrans_t *trans, char *target);
int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data);
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index ad7bf8ee..ce9083d5 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -66,7 +66,7 @@
#ifdef __sun__
/* This is a replacement for strsep which is not portable (missing on Solaris).
- * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
+ * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
char* strsep(char** str, const char* delims)
{
char* token;
@@ -342,7 +342,7 @@ int _alpm_rmrf(char *path)
return(0);
}
-int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str)
+int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str)
{
_alpm_log(PM_LOG_DEBUG, _("logaction called: %s"), str);
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 378233d2..098c15a4 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -62,7 +62,7 @@ int _alpm_lckmk(char *file);
int _alpm_lckrm(char *file);
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
int _alpm_rmrf(char *path);
-int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str);
+int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
int _alpm_ldconfig(char *root);
#ifdef _ALPM_TRANS_H
int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans);
diff --git a/lib/libalpm/versioncmp.c b/lib/libalpm/versioncmp.c
index 045f2a24..8f7c7389 100644
--- a/lib/libalpm/versioncmp.c
+++ b/lib/libalpm/versioncmp.c
@@ -253,17 +253,19 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
} else {
int cmp = _alpm_versioncmp(pkg->version, dep->version);
switch(dep->mod) {
- case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
- case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
- case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
+ case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
+ case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
+ case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
+ default: equal = 1; break;
}
}
char *mod = "~=";
switch(dep->mod) {
- case PM_DEP_MOD_EQ: mod = "=="; break;
- case PM_DEP_MOD_GE: mod = ">="; break;
- case PM_DEP_MOD_LE: mod = "<="; break;
+ case PM_DEP_MOD_EQ: mod = "=="; break;
+ case PM_DEP_MOD_GE: mod = ">="; break;
+ case PM_DEP_MOD_LE: mod = "<="; break;
+ default: break;
}
if(strlen(dep->version) > 0) {