diff options
-rw-r--r-- | lib/libalpm/add.c | 37 | ||||
-rw-r--r-- | lib/libalpm/alpm.h | 38 | ||||
-rw-r--r-- | lib/libalpm/alpm_list.c | 42 | ||||
-rw-r--r-- | lib/libalpm/alpm_list.h | 18 | ||||
-rw-r--r-- | lib/libalpm/backup.c | 4 | ||||
-rw-r--r-- | lib/libalpm/backup.h | 2 | ||||
-rw-r--r-- | lib/libalpm/be_files.c | 4 | ||||
-rw-r--r-- | lib/libalpm/cache.c | 2 | ||||
-rw-r--r-- | lib/libalpm/db.c | 66 | ||||
-rw-r--r-- | lib/libalpm/db.h | 6 | ||||
-rw-r--r-- | lib/libalpm/error.c | 2 | ||||
-rw-r--r-- | lib/libalpm/group.c | 4 | ||||
-rw-r--r-- | lib/libalpm/handle.c | 9 | ||||
-rw-r--r-- | lib/libalpm/package.c | 6 | ||||
-rw-r--r-- | lib/libalpm/server.c | 4 | ||||
-rw-r--r-- | lib/libalpm/server.h | 2 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 10 | ||||
-rw-r--r-- | src/pacman/query.c | 4 | ||||
-rw-r--r-- | src/pacman/remove.c | 8 | ||||
-rw-r--r-- | src/pacman/sync.c | 3 | ||||
-rw-r--r-- | src/pacman/util.c | 8 | ||||
-rw-r--r-- | src/pacman/util.h | 4 |
22 files changed, 146 insertions, 137 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index efcfedd4..9ffc8349 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -284,7 +284,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) struct archive *archive; struct archive_entry *entry; char cwd[PATH_MAX] = ""; - alpm_list_t *targ, *lp; + alpm_list_t *targ; const int archive_flags = ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME; @@ -383,7 +383,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) /* copy the remove skiplist over */ tr->skip_remove = alpm_list_strdup(trans->skip_remove); - alpm_list_t *b; + const alpm_list_t *b; /* Add files in the NEW package's backup array to the noupgrade array * so this removal operation doesn't kill them */ @@ -557,14 +557,17 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) hash_pkg = _alpm_SHAFile(tempfile); } - /* append the new md5 or sha1 hash to it's respective entry in newpkg's backup - * (it will be the new orginal) */ - for(lp = alpm_pkg_get_backup(newpkg); lp; lp = lp->next) { - if(!lp->data || strcmp(lp->data, entryname) != 0) { + /* append the new md5 or sha1 hash to it's respective entry + * in newpkg's backup (it will be the new orginal) */ + alpm_list_t *backups; + for(backups = alpm_pkg_get_backup(newpkg); backups; + backups = alpm_list_next(backups)) { + char *oldbackup = alpm_list_getdata(backups); + if(!oldbackup || strcmp(oldbackup, entryname) != 0) { continue; } char *backup = NULL; - int backup_len = strlen(lp->data) + 2; /* tab char and null byte */ + int backup_len = strlen(oldbackup) + 2; /* tab char and null byte */ if(use_md5) { backup_len += 32; /* MD5s are 32 chars in length */ @@ -577,10 +580,10 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) RET_ERR(PM_ERR_MEMORY, -1); } - sprintf(backup, "%s\t%s", (char *)lp->data, hash_pkg); + sprintf(backup, "%s\t%s", oldbackup, hash_pkg); backup[backup_len-1] = '\0'; - FREE(lp->data); - lp->data = backup; + FREE(oldbackup); + backups->data = backup; } if(use_md5) { @@ -698,11 +701,13 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) } /* calculate an hash if this is in newpkg's backup */ - for(lp = alpm_pkg_get_backup(newpkg); lp; lp = lp->next) { + alpm_list_t *b; + for(b = alpm_pkg_get_backup(newpkg); b; b = b->next) { char *backup = NULL, *hash = NULL; - int backup_len = strlen(lp->data) + 2; /* tab char and null byte */ + char *oldbackup = alpm_list_getdata(b); + int backup_len = strlen(oldbackup) + 2; /* tab char and null byte */ - if(!lp->data || strcmp(lp->data, entryname) != 0) { + if(!oldbackup || strcmp(oldbackup, entryname) != 0) { continue; } _alpm_log(PM_LOG_DEBUG, _("appending backup entry for %s"), filename); @@ -720,11 +725,11 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) RET_ERR(PM_ERR_MEMORY, -1); } - sprintf(backup, "%s\t%s", (char *)lp->data, hash); + sprintf(backup, "%s\t%s", oldbackup, hash); backup[backup_len-1] = '\0'; FREE(hash); - FREE(lp->data); - lp->data = backup; + FREE(oldbackup); + b->data = backup; } } } diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 7d374b47..9cdda068 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -113,19 +113,19 @@ 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); +void alpm_option_add_noupgrade(const char *pkg); void alpm_option_set_noupgrades(alpm_list_t *noupgrade); alpm_list_t *alpm_option_get_noextracts(); -void alpm_option_add_noextract(char *pkg); +void alpm_option_add_noextract(const char *pkg); void alpm_option_set_noextracts(alpm_list_t *noextract); alpm_list_t *alpm_option_get_ignorepkgs(); -void alpm_option_add_ignorepkg(char *pkg); +void alpm_option_add_ignorepkg(const char *pkg); void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs); alpm_list_t *alpm_option_get_holdpkgs(); -void alpm_option_add_holdpkg(char *pkg); +void alpm_option_add_holdpkg(const char *pkg); void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs); time_t alpm_option_get_upgradedelay(); @@ -137,10 +137,6 @@ void alpm_option_set_xfercommand(const char *cmd); unsigned short alpm_option_get_nopassiveftp(); void alpm_option_set_nopassiveftp(unsigned short nopasv); -alpm_list_t *alpm_option_get_needles(); -void alpm_option_add_needle(char *needle); -void alpm_option_set_needles(alpm_list_t *needles); - pmdb_t *alpm_option_get_localdb(); alpm_list_t *alpm_option_get_syncdbs(); @@ -151,8 +147,8 @@ alpm_list_t *alpm_option_get_syncdbs(); pmdb_t *alpm_db_register(const char *treename); int alpm_db_unregister(pmdb_t *db); -const char *alpm_db_get_name(pmdb_t *db); -const char *alpm_db_get_url(pmdb_t *db); +const char *alpm_db_get_name(const pmdb_t *db); +const char *alpm_db_get_url(const pmdb_t *db); int alpm_db_setserver(pmdb_t *db, const char *url); @@ -164,7 +160,7 @@ alpm_list_t *alpm_db_whatprovides(pmdb_t *db, const char *name); pmgrp_t *alpm_db_readgrp(pmdb_t *db, const char *name); alpm_list_t *alpm_db_getgrpcache(pmdb_t *db); -alpm_list_t *alpm_db_search(pmdb_t *db, alpm_list_t* needles); +alpm_list_t *alpm_db_search(pmdb_t *db, const alpm_list_t* needles); alpm_list_t *alpm_db_get_upgrades(); @@ -188,13 +184,13 @@ typedef enum _pmpkghasarch_t { } pmpkghasarch_t; */ -int alpm_pkg_load(char *filename, pmpkg_t **pkg); +int alpm_pkg_load(const 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); +char *alpm_fetch_pkgurl(const char *url); int alpm_pkg_vercmp(const char *ver1, const char *ver2); -char *alpm_pkg_name_hasarch(char *pkgname); +char *alpm_pkg_name_hasarch(const char *pkgname); const char *alpm_pkg_get_filename(pmpkg_t *pkg); const char *alpm_pkg_get_name(pmpkg_t *pkg); @@ -225,8 +221,8 @@ unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg); /* * Groups */ -const char *alpm_grp_get_name(pmgrp_t *grp); -alpm_list_t *alpm_grp_get_pkgs(pmgrp_t *grp); +const char *alpm_grp_get_name(const pmgrp_t *grp); +const alpm_list_t *alpm_grp_get_pkgs(const pmgrp_t *grp); /* * Sync @@ -239,9 +235,9 @@ typedef enum _pmsynctype_t { PM_SYNC_TYPE_DEPEND } pmsynctype_t; -pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync); -pmpkg_t *alpm_sync_get_pkg(pmsyncpkg_t *sync); -void *alpm_sync_get_data(pmsyncpkg_t *sync); +pmsynctype_t alpm_sync_get_type(const pmsyncpkg_t *sync); +pmpkg_t *alpm_sync_get_pkg(const pmsyncpkg_t *sync); +void *alpm_sync_get_data(const pmsyncpkg_t *sync); /* * Transactions @@ -383,7 +379,7 @@ const char *alpm_conflict_get_ctarget(pmconflict_t *conflict); * Helpers */ -/* md5sums */ +/* checksums */ char *alpm_get_md5sum(char *name); char *alpm_get_sha1sum(char *name); @@ -459,7 +455,7 @@ enum _pmerrno_t { extern enum _pmerrno_t pm_errno; -char *alpm_strerror(int err); +const char *alpm_strerror(int err); #ifdef __cplusplus } diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index 037f57ba..cd99f596 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -345,9 +345,10 @@ alpm_list_t *alpm_list_remove_node(alpm_list_t *node) * * @return a new list containing non-duplicate items */ -alpm_list_t SYMEXPORT *alpm_list_remove_dupes(alpm_list_t *list) +alpm_list_t SYMEXPORT *alpm_list_remove_dupes(const alpm_list_t *list) { /* TODO does removing the strdup here cause invalid free's anywhere? */ - alpm_list_t *lp = list, *newlist = NULL; + const alpm_list_t *lp = list; + alpm_list_t *newlist = NULL; while(lp) { if(!alpm_list_find(newlist, lp->data)) { newlist = alpm_list_add(newlist, lp->data); @@ -366,9 +367,10 @@ alpm_list_t SYMEXPORT *alpm_list_remove_dupes(alpm_list_t *list) * * @return a copy of the original list */ -alpm_list_t *alpm_list_strdup(alpm_list_t *list) +alpm_list_t *alpm_list_strdup(const alpm_list_t *list) { - alpm_list_t *lp = list, *newlist = NULL; + const alpm_list_t *lp = list; + alpm_list_t *newlist = NULL; while(lp) { newlist = alpm_list_add(newlist, strdup(lp->data)); lp = lp->next; @@ -404,9 +406,9 @@ alpm_list_t *alpm_list_reverse(alpm_list_t *list) * * @return the first element in the list */ -inline alpm_list_t SYMEXPORT *alpm_list_first(alpm_list_t *list) +inline alpm_list_t SYMEXPORT *alpm_list_first(const alpm_list_t *list) { - return(list); + return((alpm_list_t*)list); } /** @@ -417,13 +419,13 @@ inline alpm_list_t SYMEXPORT *alpm_list_first(alpm_list_t *list) * * @return an alpm_list_t node for index `n` */ -alpm_list_t *alpm_list_nth(alpm_list_t *list, int n) +alpm_list_t *alpm_list_nth(const alpm_list_t *list, int n) { - alpm_list_t *i = list; + const alpm_list_t *i = list; while(n--) { i = i->next; } - return(i); + return((alpm_list_t*)i); } /** @@ -433,7 +435,7 @@ alpm_list_t *alpm_list_nth(alpm_list_t *list, int n) * * @return the next element, or NULL when no more elements exist */ -inline alpm_list_t SYMEXPORT *alpm_list_next(alpm_list_t *node) +inline alpm_list_t SYMEXPORT *alpm_list_next(const alpm_list_t *node) { return(node->next); } @@ -445,13 +447,13 @@ inline alpm_list_t SYMEXPORT *alpm_list_next(alpm_list_t *node) * * @return the last element in the list */ -alpm_list_t *alpm_list_last(alpm_list_t *list) +alpm_list_t *alpm_list_last(const alpm_list_t *list) { - alpm_list_t *i = list; + const alpm_list_t *i = list; while(i && i->next) { i = i->next; } - return(i); + return((alpm_list_t*)i); } /** @@ -497,9 +499,9 @@ int SYMEXPORT alpm_list_count(const alpm_list_t *list) * * @return 1 if `needle` is found, 0 otherwise */ -int SYMEXPORT alpm_list_find(alpm_list_t *haystack, const void *needle) +int SYMEXPORT alpm_list_find(const alpm_list_t *haystack, const void *needle) { - alpm_list_t *lp = haystack; + const alpm_list_t *lp = haystack; while(lp) { if(lp->data == needle) { return(1); @@ -518,9 +520,9 @@ int SYMEXPORT alpm_list_find(alpm_list_t *haystack, const void *needle) * * @return 1 if `needle` is found, 0 otherwise */ -int SYMEXPORT alpm_list_find_str(alpm_list_t *haystack, const char *needle) +int SYMEXPORT alpm_list_find_str(const alpm_list_t *haystack, const char *needle) { - alpm_list_t *lp = haystack; + const alpm_list_t *lp = haystack; while(lp) { if(lp->data && strcmp((const char *)lp->data, needle) == 0) { return(1); @@ -543,9 +545,11 @@ int SYMEXPORT alpm_list_find_str(alpm_list_t *haystack, const char *needle) * * @return a list containing all items in `lhs` not present in `rhs` */ -alpm_list_t *alpm_list_diff(alpm_list_t *lhs, alpm_list_t *rhs, alpm_list_fn_cmp fn) +alpm_list_t *alpm_list_diff(const alpm_list_t *lhs, + const alpm_list_t *rhs, alpm_list_fn_cmp fn) { - alpm_list_t *i, *j, *ret = NULL; + const alpm_list_t *i, *j; + alpm_list_t *ret = NULL; for(i = lhs; i; i = i->next) { int found = 0; for(j = rhs; j; j = j->next) { diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h index 5812907f..10d01df2 100644 --- a/lib/libalpm/alpm_list.h +++ b/lib/libalpm/alpm_list.h @@ -60,22 +60,22 @@ alpm_list_t *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_f alpm_list_t *alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn); alpm_list_t *alpm_list_remove(alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn, void **data); alpm_list_t *alpm_list_remove_node(alpm_list_t *node); -alpm_list_t *alpm_list_remove_dupes(alpm_list_t *list); -alpm_list_t *alpm_list_strdup(alpm_list_t *list); +alpm_list_t *alpm_list_remove_dupes(const alpm_list_t *list); +alpm_list_t *alpm_list_strdup(const alpm_list_t *list); alpm_list_t *alpm_list_reverse(alpm_list_t *list); /* item accessors */ -alpm_list_t *alpm_list_first(alpm_list_t *list); -alpm_list_t *alpm_list_nth(alpm_list_t *list, int n); -alpm_list_t *alpm_list_next(alpm_list_t *list); -alpm_list_t *alpm_list_last(alpm_list_t *list); +alpm_list_t *alpm_list_first(const alpm_list_t *list); +alpm_list_t *alpm_list_nth(const alpm_list_t *list, int n); +alpm_list_t *alpm_list_next(const alpm_list_t *list); +alpm_list_t *alpm_list_last(const alpm_list_t *list); void *alpm_list_getdata(const alpm_list_t *entry); /* misc */ int alpm_list_count(const alpm_list_t *list); -int alpm_list_find(alpm_list_t *haystack, const void *needle); -int alpm_list_find_str(alpm_list_t *haystack,const char *needle); -alpm_list_t *alpm_list_diff(alpm_list_t *lhs, alpm_list_t *rhs, alpm_list_fn_cmp fn); +int alpm_list_find(const alpm_list_t *haystack, const void *needle); +int 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); #ifdef __cplusplus } diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c index aeb0dea7..ffd45086 100644 --- a/lib/libalpm/backup.c +++ b/lib/libalpm/backup.c @@ -36,9 +36,9 @@ /* Look for a filename in a pmpkg_t.backup list. If we find it, * then we return the md5 or sha1 hash (parsed from the same line) */ -char *_alpm_needbackup(const char *file, alpm_list_t *backup) +char *_alpm_needbackup(const char *file, const alpm_list_t *backup) { - alpm_list_t *lp; + const alpm_list_t *lp; ALPM_LOG_FUNC; diff --git a/lib/libalpm/backup.h b/lib/libalpm/backup.h index dde907f0..6df8e251 100644 --- a/lib/libalpm/backup.h +++ b/lib/libalpm/backup.h @@ -23,7 +23,7 @@ #include "alpm_list.h" -char *_alpm_needbackup(const char *file, alpm_list_t *backup); +char *_alpm_needbackup(const char *file, const alpm_list_t *backup); #endif /* _ALPM_BACKUP_H */ diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index b936c6b8..2cd14e15 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -715,7 +715,7 @@ int _alpm_db_remove(pmdb_t *db, pmpkg_t *info) * Returns 0 on success, 1 on error * */ -int _alpm_db_getlastupdate(pmdb_t *db, char *ts) +int _alpm_db_getlastupdate(const pmdb_t *db, char *ts) { FILE *fp; char file[PATH_MAX]; @@ -747,7 +747,7 @@ int _alpm_db_getlastupdate(pmdb_t *db, char *ts) /* writes the dbpath/.lastupdate with the contents of *ts */ -int _alpm_db_setlastupdate(pmdb_t *db, char *ts) +int _alpm_db_setlastupdate(const pmdb_t *db, char *ts) { FILE *fp; char file[PATH_MAX]; diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c index 55ca6f51..0a3cd1e2 100644 --- a/lib/libalpm/cache.c +++ b/lib/libalpm/cache.c @@ -204,7 +204,7 @@ int _alpm_db_load_grpcache(pmdb_t *db) _alpm_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename); for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) { - alpm_list_t *i; + const alpm_list_t *i; pmpkg_t *pkg = lp->data; for(i = alpm_pkg_get_groups(pkg); i; i = i->next) { diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index e6c784cc..7536e678 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -258,6 +258,35 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) return(0); } +const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db) +{ + ALPM_LOG_FUNC; + + /* Sanity checks */ + ASSERT(handle != NULL, return(NULL)); + ASSERT(db != NULL, return(NULL)); + + return db->treename; +} + +const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db) +{ + char path[PATH_MAX]; + pmserver_t *s; + + ALPM_LOG_FUNC; + + /* Sanity checks */ + ASSERT(handle != NULL, return(NULL)); + ASSERT(db != NULL, return(NULL)); + + s = (pmserver_t*)db->servers->data; + + snprintf(path, PATH_MAX, "%s://%s%s", s->s_url->scheme, s->s_url->host, s->s_url->doc); + return strdup(path); +} + + /** 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 @@ -344,7 +373,7 @@ alpm_list_t SYMEXPORT *alpm_db_getgrpcache(pmdb_t *db) * @param needles the list of strings to search for * @return the list of packages on success, NULL on error */ -alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, alpm_list_t* needles) +alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles) { ALPM_LOG_FUNC; @@ -361,7 +390,7 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, alpm_list_t* needles) alpm_list_t SYMEXPORT *alpm_db_get_upgrades() { alpm_list_t *syncpkgs = NULL; - alpm_list_t *i, *j, *k, *m; + const alpm_list_t *i, *j, *k, *m; ALPM_LOG_FUNC; @@ -540,9 +569,10 @@ int _alpm_db_cmp(const void *db1, const void *db2) return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename)); } -alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles) +alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles) { - alpm_list_t *i, *j, *k, *ret = NULL; + const alpm_list_t *i, *j, *k; + alpm_list_t *ret = NULL; ALPM_LOG_FUNC; @@ -659,32 +689,4 @@ pmdb_t *_alpm_db_register(const char *treename) return(db); } -const char SYMEXPORT *alpm_db_get_name(pmdb_t *db) -{ - ALPM_LOG_FUNC; - - /* Sanity checks */ - ASSERT(handle != NULL, return(NULL)); - ASSERT(db != NULL, return(NULL)); - - return db->treename; -} - -const char *alpm_db_get_url(pmdb_t *db) -{ - char path[PATH_MAX]; - pmserver_t *s; - - ALPM_LOG_FUNC; - - /* Sanity checks */ - ASSERT(handle != NULL, return(NULL)); - ASSERT(db != NULL, return(NULL)); - - s = (pmserver_t*)db->servers->data; - - snprintf(path, PATH_MAX, "%s://%s%s", s->s_url->scheme, s->s_url->host, s->s_url->doc); - return strdup(path); -} - /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index d8d6f2be..3c97e580 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -51,7 +51,7 @@ struct __pmdb_t { pmdb_t *_alpm_db_new(const char *dbpath, const char *treename); void _alpm_db_free(pmdb_t *db); int _alpm_db_cmp(const void *db1, const void *db2); -alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles); +alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles); pmdb_t *_alpm_db_register(const char *treename); /* be.c, backend specific calls */ @@ -63,8 +63,8 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, const char *target); int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq); 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); +int _alpm_db_getlastupdate(const pmdb_t *db, char *ts); +int _alpm_db_setlastupdate(const pmdb_t *db, char *ts); #endif /* _ALPM_DB_H */ diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c index 0775567c..67d8b1f2 100644 --- a/lib/libalpm/error.c +++ b/lib/libalpm/error.c @@ -30,7 +30,7 @@ #include "alpm.h" /* TODO does this really need a file all on its own? */ -char SYMEXPORT *alpm_strerror(int err) +const char SYMEXPORT *alpm_strerror(int err) { switch(err) { /* System */ diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c index bd2280eb..58759d0d 100644 --- a/lib/libalpm/group.c +++ b/lib/libalpm/group.c @@ -71,7 +71,7 @@ int _alpm_grp_cmp(const void *g1, const void *g2) return(strcmp(grp1->name, grp2->name)); } -const char SYMEXPORT *alpm_grp_get_name(pmgrp_t *grp) +const char SYMEXPORT *alpm_grp_get_name(const pmgrp_t *grp) { ALPM_LOG_FUNC; @@ -81,7 +81,7 @@ const char SYMEXPORT *alpm_grp_get_name(pmgrp_t *grp) return grp->name; } -alpm_list_t SYMEXPORT *alpm_grp_get_pkgs(pmgrp_t *grp) +const alpm_list_t SYMEXPORT *alpm_grp_get_pkgs(const pmgrp_t *grp) { ALPM_LOG_FUNC; diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 45f4e8af..ac817a51 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -242,7 +242,7 @@ void SYMEXPORT alpm_option_set_usesyslog(unsigned short usesyslog) handle->usesyslog = usesyslog; } -void SYMEXPORT alpm_option_add_noupgrade(char *pkg) +void SYMEXPORT alpm_option_add_noupgrade(const char *pkg) { handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg)); } @@ -253,17 +253,18 @@ void SYMEXPORT alpm_option_set_noupgrades(alpm_list_t *noupgrade) if(noupgrade) handle->noupgrade = noupgrade; } -void SYMEXPORT alpm_option_add_noextract(char *pkg) +void SYMEXPORT alpm_option_add_noextract(const char *pkg) { handle->noextract = alpm_list_add(handle->noextract, strdup(pkg)); } + void SYMEXPORT alpm_option_set_noextracts(alpm_list_t *noextract) { if(handle->noextract) FREELIST(handle->noextract); if(noextract) handle->noextract = noextract; } -void SYMEXPORT alpm_option_add_ignorepkg(char *pkg) +void SYMEXPORT alpm_option_add_ignorepkg(const char *pkg) { handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg)); } @@ -273,7 +274,7 @@ void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs) if(ignorepkgs) handle->ignorepkg = ignorepkgs; } -void SYMEXPORT alpm_option_add_holdpkg(char *pkg) +void SYMEXPORT alpm_option_add_holdpkg(const char *pkg) { handle->holdpkg = alpm_list_add(handle->holdpkg, strdup(pkg)); } diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 7f20b9e0..e25ecbe4 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -61,7 +61,7 @@ * @param pkg address of the package pointer * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int SYMEXPORT alpm_pkg_load(char *filename, pmpkg_t **pkg) +int SYMEXPORT alpm_pkg_load(const char *filename, pmpkg_t **pkg) { _alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_load"); @@ -210,7 +210,7 @@ static char *_supported_archs[] = { * * @return pointer to start of -ARCH text if it exists, else NULL */ -char SYMEXPORT *alpm_pkg_name_hasarch(char *pkgname) +char SYMEXPORT *alpm_pkg_name_hasarch(const char *pkgname) { /* TODO remove this when we transfer everything over to -ARCH * @@ -732,7 +732,7 @@ int _alpm_pkg_splitname(const char *target, char *name, char *version, int witha * used when we want to install or add a package */ void _alpm_pkg_update_requiredby(pmpkg_t *pkg) { - alpm_list_t *i, *j; + const alpm_list_t *i, *j; pmdb_t *localdb = alpm_option_get_localdb(); for(i = _alpm_db_get_pkgcache(localdb); i; i = i->next) { diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c index c36f9ba8..ec1b03f3 100644 --- a/lib/libalpm/server.c +++ b/lib/libalpm/server.c @@ -47,7 +47,7 @@ * @return the downloaded filename on success, NULL on error * @addtogroup alpm_misc */ -char SYMEXPORT *alpm_fetch_pkgurl(char *url) +char SYMEXPORT *alpm_fetch_pkgurl(const char *url) { ALPM_LOG_FUNC; @@ -420,7 +420,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, return(done ? 0 : -1); } -char *_alpm_fetch_pkgurl(char *target) +char *_alpm_fetch_pkgurl(const char *target) { pmserver_t *server; char *filename; diff --git a/lib/libalpm/server.h b/lib/libalpm/server.h index b560f831..76758d21 100644 --- a/lib/libalpm/server.h +++ b/lib/libalpm/server.h @@ -41,7 +41,7 @@ int _alpm_downloadfiles(alpm_list_t *servers, const char *localpath, alpm_list_t int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, alpm_list_t *files, const char *mtime1, char *mtime2); -char *_alpm_fetch_pkgurl(char *target); +char *_alpm_fetch_pkgurl(const char *target); #endif /* _ALPM_SERVER_H */ diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 2178d1bd..632e510b 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -367,8 +367,8 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy */ static int syncpkg_cmp(const void *s1, const void *s2) { - pmsyncpkg_t *sp1 = (pmsyncpkg_t *)s1; - pmsyncpkg_t *sp2 = (pmsyncpkg_t *)s2; + const pmsyncpkg_t *sp1 = s1; + const pmsyncpkg_t *sp2 = s2; pmpkg_t *p1, *p2; p1 = alpm_sync_get_pkg(sp1); @@ -1085,7 +1085,7 @@ pmsyncpkg_t *_alpm_sync_find(alpm_list_t *syncpkgs, const char* pkgname) return(NULL); /* not found */ } -pmsynctype_t SYMEXPORT alpm_sync_get_type(pmsyncpkg_t *sync) +pmsynctype_t SYMEXPORT alpm_sync_get_type(const pmsyncpkg_t *sync) { /* Sanity checks */ ASSERT(sync != NULL, return(-1)); @@ -1093,7 +1093,7 @@ pmsynctype_t SYMEXPORT alpm_sync_get_type(pmsyncpkg_t *sync) return sync->type; } -pmpkg_t SYMEXPORT *alpm_sync_get_pkg(pmsyncpkg_t *sync) +pmpkg_t SYMEXPORT *alpm_sync_get_pkg(const pmsyncpkg_t *sync) { /* Sanity checks */ ASSERT(sync != NULL, return(NULL)); @@ -1101,7 +1101,7 @@ pmpkg_t SYMEXPORT *alpm_sync_get_pkg(pmsyncpkg_t *sync) return sync->pkg; } -void SYMEXPORT *alpm_sync_get_data(pmsyncpkg_t *sync) +void SYMEXPORT *alpm_sync_get_data(const pmsyncpkg_t *sync) { /* Sanity checks */ ASSERT(sync != NULL, return(NULL)); diff --git a/src/pacman/query.c b/src/pacman/query.c index 3e993bf0..3863572f 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -182,7 +182,7 @@ static int query_group(alpm_list_t *targets) if(targets == NULL) { for(j = alpm_db_getgrpcache(db_local); j; j = alpm_list_next(j)) { pmgrp_t *grp = alpm_list_getdata(j); - alpm_list_t *p, *pkgnames; + const alpm_list_t *p, *pkgnames; const char *grpname; grpname = alpm_grp_get_name(grp); @@ -197,7 +197,7 @@ static int query_group(alpm_list_t *targets) package = alpm_list_getdata(i); pmgrp_t *grp = alpm_db_readgrp(db_local, package); if(grp) { - alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp); + const alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp); for(p = pkgnames; p; p = alpm_list_next(p)) { printf("%s %s\n", package, (char *)alpm_list_getdata(p)); } diff --git a/src/pacman/remove.c b/src/pacman/remove.c index c76fc69a..9b4adce0 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -47,7 +47,7 @@ extern pmdb_t *db_local; */ int pacman_remove(alpm_list_t *targets) { - alpm_list_t *i, *j, *data = NULL, *finaltargs = NULL; + alpm_list_t *i, *data = NULL, *finaltargs = NULL; int retval = 0; if(targets == NULL) { @@ -61,14 +61,14 @@ int pacman_remove(alpm_list_t *targets) pmgrp_t *grp = alpm_db_readgrp(db_local, alpm_list_getdata(i)); if(grp) { int all; - alpm_list_t *pkgnames = alpm_grp_get_pkgs(grp); + const alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp); printf(_(":: group %s:\n"), alpm_grp_get_name(grp)); list_display(" ", pkgnames); all = yesno(_(" Remove whole content? [Y/n] ")); - for(j = pkgnames; j; j = alpm_list_next(j)) { - char *pkg = alpm_list_getdata(j); + for(p = pkgnames; p; p = alpm_list_next(p)) { + char *pkg = alpm_list_getdata(p); if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), pkg, (char *)alpm_list_getdata(i))) { finaltargs = alpm_list_add(finaltargs, strdup(pkg)); } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 92a1607a..fa99797c 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -572,7 +572,8 @@ int pacman_sync(alpm_list_t *targets) found++; printf(_(":: group %s:\n"), targ); /* remove dupe entries in case a package exists in multiple repos */ - alpm_list_t *pkgs = alpm_list_remove_dupes(alpm_grp_get_pkgs(grp)); + const alpm_list_t *grppkgs = alpm_grp_get_pkgs(grp); + alpm_list_t *pkgs = alpm_list_remove_dupes(grppkgs); list_display(" ", pkgs); if(yesno(_(":: Install whole content? [Y/n] "))) { for(k = pkgs; k; k = alpm_list_next(k)) { diff --git a/src/pacman/util.c b/src/pacman/util.c index e88001ac..eda32524 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -280,9 +280,9 @@ char *strreplace(const char *str, const char *needle, const char *replace) return newstr; } -void list_display(const char *title, alpm_list_t *list) +void list_display(const char *title, const alpm_list_t *list) { - alpm_list_t *i; + const alpm_list_t *i; int cols, len; len = strlen(title); @@ -315,10 +315,10 @@ void list_display(const char *title, alpm_list_t *list) * retrieved from a transaction object */ /* TODO move to output.c? or just combine util and output */ -void display_targets(alpm_list_t *syncpkgs) +void display_targets(const alpm_list_t *syncpkgs) { char *str; - alpm_list_t *i, *j; + const alpm_list_t *i, *j; alpm_list_t *targets = NULL, *to_remove = NULL; /* TODO these are some messy variable names */ unsigned long size = 0, isize = 0, rsize = 0, dispsize = 0; diff --git a/src/pacman/util.h b/src/pacman/util.h index 80d1b02c..065f9531 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -44,8 +44,8 @@ void indentprint(const char *str, int indent); char *strtoupper(char *str); char *strtrim(char *str); char *strreplace(const char *str, const char *needle, const char *replace); -void list_display(const char *title, alpm_list_t *list); -void display_targets(alpm_list_t *syncpkgs); +void list_display(const char *title, const alpm_list_t *list); +void display_targets(const alpm_list_t *syncpkgs); int yesno(char *fmt, ...); #endif /* _PM_UTIL_H */ |