diff options
author | jbj <devnull@localhost> | 2001-10-29 23:39:51 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-10-29 23:39:51 +0000 |
commit | bdae587b2ea0dc058d178cfb6a4f102fa541a0ab (patch) | |
tree | 82574acf544af00270c9387a09734182fee0ac8d /lib/rpmal.c | |
parent | e62f50c8a585566d68bbfdbaf1eead46630e3ca9 (diff) | |
download | rpm-bdae587b2ea0dc058d178cfb6a4f102fa541a0ab.tar.gz rpm-bdae587b2ea0dc058d178cfb6a4f102fa541a0ab.tar.bz2 rpm-bdae587b2ea0dc058d178cfb6a4f102fa541a0ab.zip |
- add some dinky availablePackage methods.
CVS patchset: 5141
CVS date: 2001/10/29 23:39:51
Diffstat (limited to 'lib/rpmal.c')
-rw-r--r-- | lib/rpmal.c | 127 |
1 files changed, 126 insertions, 1 deletions
diff --git a/lib/rpmal.c b/lib/rpmal.c index 8b727c76a..3afabf906 100644 --- a/lib/rpmal.c +++ b/lib/rpmal.c @@ -13,15 +13,72 @@ /*@access Header@*/ /* XXX compared with NULL */ /*@access FD_t@*/ /* XXX compared with NULL */ -/*@access rpmDependencyConflict@*/ /*@access availablePackage@*/ + +typedef /*@abstract@*/ struct fileIndexEntry_s * fileIndexEntry; +typedef /*@abstract@*/ struct dirInfo_s * dirInfo; +typedef /*@abstract@*/ struct availableIndexEntry_s * availableIndexEntry; +typedef /*@abstract@*/ struct availableIndex_s * availableIndex; + /*@access availableIndexEntry@*/ /*@access availableIndex@*/ /*@access fileIndexEntry@*/ /*@access dirInfo@*/ /*@access availableList@*/ +/** \ingroup rpmdep + * A single available item (e.g. a Provides: dependency). + */ +struct availableIndexEntry_s { +/*@dependent@*/ availablePackage package; /*!< Containing package. */ +/*@dependent@*/ const char * entry; /*!< Available item name. */ + size_t entryLen; /*!< No. of bytes in name. */ + enum indexEntryType { + IET_PROVIDES=1 /*!< A Provides: dependency. */ + } type; /*!< Type of available item. */ +}; + +/** \ingroup rpmdep + * Index of all available items. + */ +struct availableIndex_s { +/*@null@*/ availableIndexEntry index; /*!< Array of available items. */ + int size; /*!< No. of available items. */ +}; + +/** \ingroup rpmdep + * A file to be installed/removed. + */ +struct fileIndexEntry_s { + int pkgNum; /*!< Containing package number. */ + int fileFlags; /* MULTILIB */ +/*@dependent@*/ /*@null@*/ const char * baseName; /*!< File basename. */ +}; + +/** \ingroup rpmdep + * A directory to be installed/removed. + */ +struct dirInfo_s { +/*@owned@*/ const char * dirName; /*!< Directory path (+ trailing '/'). */ + int dirNameLen; /*!< No. bytes in directory path. */ +/*@owned@*/ fileIndexEntry files; /*!< Array of files in directory. */ + int numFiles; /*!< No. files in directory. */ +}; + +/** \ingroup rpmdep + * Set of available packages, items, and directories. + */ +struct availableList_s { +/*@owned@*/ /*@null@*/ availablePackage list; /*!< Set of packages. */ + struct availableIndex_s index; /*!< Set of available items. */ + int delta; /*!< Delta for pkg list reallocation. */ + int size; /*!< No. of pkgs in list. */ + int alloced; /*!< No. of pkgs allocated for list. */ + int numDirs; /*!< No. of directories. */ +/*@owned@*/ /*@null@*/ dirInfo dirs; /*!< Set of directories. */ +}; + /*@unchecked@*/ static int _al_debug = 0; @@ -38,6 +95,74 @@ static void alFreeIndex(availableList al) } } +int alGetSize(availableList al) +{ + return al->size; +} + +const void * alGetKey(availableList al, int pkgNum) +{ + const void * key = NULL; + if (al != NULL && pkgNum >= 0 && pkgNum < al->size) { + if (al->list != NULL) { + availablePackage alp = al->list + pkgNum; + key = alp->key; + } + } + return key; +} + +availablePackage alGetPkg(availableList al, int pkgNum) +{ + availablePackage alp = NULL; + if (al != NULL && pkgNum >= 0 && pkgNum < al->size) { + if (al->list != NULL) + alp = al->list + pkgNum; + } +/*@-modfilesys@*/ +if (_al_debug) +fprintf(stderr, "*** alp[%d] %p\n", pkgNum, alp); +/*@=modfilesys@*/ + return alp; +} + +int alGetPkgIndex(availableList al, availablePackage alp) +{ + int pkgNum = -1; + if (al != NULL) { + if (al->list != NULL) + if (alp != NULL && alp >= al->list && alp < (al->list + al->size)) + pkgNum = alp - al->list; + } +/*@-modfilesys@*/ +if (_al_debug) +fprintf(stderr, "*** alp %p[%d]\n", alp, pkgNum); +/*@=modfilesys@*/ + return pkgNum; +} + +const char * alGetPkgNVR(availableList al, availablePackage alp) +{ + const char * pkgNVR = NULL; + + if (al != NULL) { + if (al->list != NULL) + if (alp != NULL && alp >= al->list && alp < (al->list + al->size)) { + char * t; + t = xcalloc(1, strlen(alp->name) + + strlen(alp->version) + + strlen(alp->release) + sizeof("--")); + pkgNVR = t; + t = stpcpy(t, alp->name); + t = stpcpy(t, "-"); + t = stpcpy(t, alp->version); + t = stpcpy(t, "-"); + t = stpcpy(t, alp->release); + } + } + return pkgNVR; +} + availableList alCreate(int delta) { availableList al = xcalloc(1, sizeof(*al)); |