# lib/rpmal.c File Reference

`#include "system.h"`
`#include <rpmio.h>`
`#include <rpmcb.h>`
`#include <rpmlib.h>`
`#include "rpmal.h"`
`#include "rpmds.h"`
`#include "rpmfi.h"`
`#include "debug.h"`

Include dependency graph for rpmal.c:

Go to the source code of this file.

## Data Structures

struct | availablePackage_s
| Info about a single package to be installed. More...
struct | availableIndexEntry_s
| A single available item (e.g. More...
struct | availableIndex_s
| Index of all available items. More...
struct | fileIndexEntry_s
| A file to be installed/removed. More...
struct | dirInfo_s
| A directory to be installed/removed. More...
struct | rpmal_s
| Set of available packages, items, and directories. More...

## Defines

#define | _RPMDS_INTERNAL

## Typedefs

typedef struct availablePackage_s * | availablePackage
typedef struct availableIndexEntry_s * | availableIndexEntry
typedef struct availableIndex_s * | availableIndex
typedef struct fileIndexEntry_s * | fileIndexEntry
typedef struct dirInfo_s * | dirInfo

## Functions

static void | rpmalFreeIndex (rpmal al)
| Destroy available item index.
static alNum | alKey2Num (const rpmal al, alKey pkgKey)
static alKey | alNum2Key (const rpmal al, alNum pkgNum)
rpmal | rpmalCreate (int delta)
| Initialize available packckages, items, and directory list.
rpmal | rpmalFree (rpmal al)
| Free available packages, items, and directory members.
static int | dieCompare (const void *one, const void *two)
| Compare two directory info entries by name (qsort/bsearch).
static int | fieCompare (const void *one, const void *two)
| Compare two file info entries by name (qsort/bsearch).
void | rpmalDel (rpmal al, alKey pkgKey)
| Delete package from available list.
alKey | rpmalAdd (rpmal *alistp, alKey pkgKey, fnpyKey key, rpmds provides, rpmfi fi, uint32_t tscolor)
| Add package to available list.
static int | indexcmp (const void *one, const void *two)
| Compare two available index entries by name (qsort/bsearch).
void | rpmalAddProvides (rpmal al, alKey pkgKey, rpmds provides, uint32_t tscolor)
| Add package provides to available list index.
void | rpmalMakeIndex (rpmal al)
| Generate index for available list.
fnpyKey * | rpmalAllFileSatisfiesDepend (const rpmal al, const rpmds ds, alKey *keyp)
| Check added package file lists for package(s) that provide a file.
fnpyKey * | rpmalAllSatisfiesDepend (const rpmal al, const rpmds ds, alKey *keyp)
| Check added package file lists for package(s) that have a provide.
fnpyKey | rpmalSatisfiesDepend (const rpmal al, const rpmds ds, alKey *keyp)
| Check added package file lists for first package that has a provide.

## Variables

int | _rpmal_debug = 0

## Detailed Description

Definition in file rpmal.c.

## Define Documentation

#define _RPMDS_INTERNAL

Definition at line 12 of file rpmal.c.

## Typedef Documentation

typedef struct availableIndex_s* availableIndex

Definition at line 65 of file rpmal.c.

typedef struct availableIndexEntry_s* availableIndexEntry

Definition at line 47 of file rpmal.c.

typedef struct availablePackage_s* availablePackage

Definition at line 18 of file rpmal.c.

typedef struct dirInfo_s* dirInfo

Definition at line 92 of file rpmal.c.

typedef struct fileIndexEntry_s* fileIndexEntry

Definition at line 78 of file rpmal.c.

## Function Documentation

static alNum alKey2Num | ( | const rpmal | al,
|  | alKey | pkgKey |
| ) |  |  | `[inline, static]`

Definition at line 150 of file rpmal.c.

Referenced by rpmalAdd(), rpmalAddProvides(), rpmalAllSatisfiesDepend(), and rpmalDel().

static alKey alNum2Key | ( | const rpmal | al,
|  | alNum | pkgNum |
| ) |  |  | `[inline, static]`

Definition at line 161 of file rpmal.c.

Referenced by rpmalAllFileSatisfiesDepend(), and rpmalMakeIndex().

static int dieCompare | ( | const void * | one,
|  | const void * | two |
| ) |  |  | `[static]`

Compare two directory info entries by name (qsort/bsearch).

Parameters:

  | one | 1st directory info
  | two | 2nd directory info

Returns:
  result of comparison

Definition at line 249 of file rpmal.c.

References dirInfo_s::dirName, and dirInfo_s::dirNameLen.

Referenced by rpmalAdd(), rpmalAllFileSatisfiesDepend(), and rpmalDel().

static int fieCompare | ( | const void * | one,
|  | const void * | two |
| ) |  |  | `[static]`

Compare two file info entries by name (qsort/bsearch).

Parameters:

  | one | 1st directory info
  | two | 2nd directory info

Returns:
  result of comparison

Definition at line 274 of file rpmal.c.

References _rpmal_debug, fileIndexEntry_s::baseName, and fileIndexEntry_s::baseNameLen.

Referenced by rpmalAdd(), and rpmalAllFileSatisfiesDepend().

static int indexcmp | ( | const void * | one,
|  | const void * | two |
| ) |  |  | `[static]`

Compare two available index entries by name (qsort/bsearch).

Parameters:

  | one | 1st available index entry
  | two | 2nd available index entry

Returns:
  result of comparison

Definition at line 598 of file rpmal.c.

References availableIndexEntry_s::entry, and availableIndexEntry_s::entryLen.

Referenced by rpmalAllSatisfiesDepend(), and rpmalMakeIndex().

alKey rpmalAdd | ( | rpmal * | alistp,
|  | alKey | pkgKey,
|  | fnpyKey | key,
|  | rpmds | provides,
|  | rpmfi | fi,
|  | uint32_t | tscolor |
| ) |  |  |

Add package to available list.

Parameters:

  | alistp | address of available list
  | pkgKey | package key, RPMAL_NOMATCH to force an append
  | key | associated file name/python object
  | provides | provides dependency set
  | fi | file info set
  | tscolor | transaction color bits

Returns:
  available package index

Definition at line 418 of file rpmal.c.

References _rpmal_debug, alKey2Num(), alloca(), rpmal_s::alloced, fileIndexEntry_s::baseName, fileIndexEntry_s::baseNameLen, rpmal_s::delta, dieCompare(), dirInfo_s::dirName, dirInfo_s::dirNameLen, rpmal_s::dirs, availablePackage_s::fi, fileIndexEntry_s::ficolor, fieCompare(), dirInfo_s::files, availablePackage_s::key, rpmal_s::list, next, rpmal_s::numDirs, dirInfo_s::numFiles, fileIndexEntry_s::pkgNum, availablePackage_s::provides, RPMAL_NOMATCH, rpmalCreate(), rpmalDel(), rpmalFreeIndex(), rpmdsLink, rpmfiBN(), rpmfiDC(), rpmfiDN(), rpmfiDX(), rpmfiFC(), rpmfiFColor(), rpmfiFN(), rpmfiInit(), rpmfiLink, rpmfiNext(), rpmfiSetDX(), rpmfiUnlink, rpmal_s::size, availablePackage_s::tscolor, xrealloc(), and xstrdup().

Referenced by rpmal_Add(), rpmtsAddInstallElement(), and rpmtsOrder().

void rpmalAddProvides | ( | rpmal | al,
|  | alKey | pkgKey,
|  | rpmds | provides,
|  | uint32_t | tscolor |
| ) |  |  |

Add package provides to available list index.

Parameters:

  | al | available list
  | pkgKey | package key
  | provides | added package provides
  | tscolor | transaction color bits

Definition at line 614 of file rpmal.c.

References alKey2Num(), availableIndexEntry_s::entry, availableIndexEntry_s::entryIx, availableIndexEntry_s::entryLen, availableIndex_s::index, rpmal_s::index, availableIndex_s::k, availableIndexEntry_s::pkgKey, rpmdsColor(), rpmdsInit(), rpmdsIx(), rpmdsNext(), availableIndex_s::size, rpmal_s::size, and availableIndexEntry_s::type.

Referenced by rpmal_AddProvides(), and rpmalMakeIndex().

fnpyKey* rpmalAllFileSatisfiesDepend | ( | const rpmal | al,
|  | const rpmds | ds,
|  | alKey * | keyp |
| ) |  |  |

Check added package file lists for package(s) that provide a file.

Parameters:

  | al | available list
  | ds | dependency set

Return values:

  | keyp | added package key pointer (or NULL)

Returns:
  associated package key(s), NULL if none

Definition at line 687 of file rpmal.c.

References _, _free(), _rpmal_debug, alloca(), alNum2Key(), fileIndexEntry_s::baseName, fileIndexEntry_s::baseNameLen, dieCompare(), dirInfo_s::dirName, dirName, dirInfo_s::dirNameLen, rpmal_s::dirs, fileIndexEntry_s::ficolor, fieCompare(), dirInfo_s::files, availablePackage_s::key, rpmal_s::list, rpmal_s::numDirs, dirInfo_s::numFiles, fileIndexEntry_s::pkgNum, RPMAL_NOMATCH, rpmdsN(), rpmdsNotify(), availablePackage_s::tscolor, xrealloc(), and xstrdup().

Referenced by rpmalAllSatisfiesDepend().

fnpyKey* rpmalAllSatisfiesDepend | ( | const rpmal | al,
|  | const rpmds | ds,
|  | alKey * | keyp |
| ) |  |  |

Check added package file lists for package(s) that have a provide.

Parameters:

  | al | available list
  | ds | dependency set

Return values:

  | keyp | added package key pointer (or NULL)

Returns:
  associated package key(s), NULL if none

Definition at line 786 of file rpmal.c.

References _, _free(), alKey2Num(), alloca(), availableIndexEntry_s::entry, availableIndexEntry_s::entryIx, availableIndexEntry_s::entryLen, availableIndex_s::index, rpmal_s::index, indexcmp(), availablePackage_s::key, rpmal_s::list, availableIndexEntry_s::pkgKey, availablePackage_s::provides, RPMAL_NOMATCH, rpmalAllFileSatisfiesDepend(), rpmdsCompare(), rpmdsN(), rpmdsNext(), rpmdsNotify(), rpmdsSetIx(), availableIndex_s::size, availableIndexEntry_s::type, and xrealloc().

Referenced by checkPackageDeps(), rpmalSatisfiesDepend(), and rpmtsAvailable().

rpmal rpmalCreate | ( | int | delta | ) |

Initialize available packckages, items, and directory list.

Parameters:

  | delta | no. of entries to add on each realloc

Returns:
  al new available list

Definition at line 195 of file rpmal.c.

References rpmal_s::alloced, rpmal_s::delta, rpmal_s::dirs, availableIndex_s::index, rpmal_s::index, rpmal_s::list, rpmal_s::numDirs, availableIndex_s::size, rpmal_s::size, and xcalloc().

Referenced by rpmalAdd().

void rpmalDel | ( | rpmal | al,
|  | alKey | pkgKey |
| ) |  |  |

Delete package from available list.

Parameters:

  | al | available list
  | pkgKey | package key

Definition at line 305 of file rpmal.c.

References _free(), _rpmal_debug, alKey2Num(), alloca(), fileIndexEntry_s::baseName, fileIndexEntry_s::baseNameLen, dieCompare(), dirInfo_s::dirName, dirInfo_s::dirNameLen, rpmal_s::dirs, availablePackage_s::fi, dirInfo_s::files, rpmal_s::list, rpmal_s::numDirs, dirInfo_s::numFiles, fileIndexEntry_s::pkgNum, availablePackage_s::provides, rpmdsFree(), rpmfiDC(), rpmfiDN(), rpmfiFC(), rpmfiFree(), rpmfiSetDX(), and xrealloc().

Referenced by rpmal_Del(), and rpmalAdd().

rpmal rpmalFree | ( | rpmal | al | ) |

Free available packages, items, and directory members.

Parameters:

  | al | available list

Returns:
  NULL always

Definition at line 213 of file rpmal.c.

References _free(), rpmal_s::alloced, dirInfo_s::dirName, rpmal_s::dirs, availablePackage_s::fi, dirInfo_s::files, rpmal_s::list, rpmal_s::numDirs, availablePackage_s::provides, rpmalFreeIndex(), rpmdsFree(), rpmfiFree(), and rpmal_s::size.

Referenced by rpmal_dealloc(), rpmtsClean(), and rpmtsFree().

static void rpmalFreeIndex | ( | rpmal | al | ) | `[static]`

Destroy available item index.

Parameters:

  | al | available list

Definition at line 127 of file rpmal.c.

References _free(), availableIndex_s::index, rpmal_s::index, and availableIndex_s::size.

Referenced by rpmalAdd(), and rpmalFree().

void rpmalMakeIndex | ( | rpmal | al | ) |

Generate index for available list.

Parameters:

  | al | available list

Definition at line 657 of file rpmal.c.

References alNum2Key(), availableIndex_s::index, rpmal_s::index, indexcmp(), availableIndex_s::k, rpmal_s::list, availablePackage_s::provides, rpmalAddProvides(), rpmdsCount(), rpmal_s::size, availableIndex_s::size, availablePackage_s::tscolor, and xrealloc().

Referenced by rpmal_MakeIndex(), rpmtsCheck(), rpmtsOrder(), and unsatisfiedDepend().

fnpyKey rpmalSatisfiesDepend | ( | const rpmal | al,
|  | const rpmds | ds,
|  | alKey * | keyp |
| ) |  |  |

Check added package file lists for first package that has a provide.

Todo:
  Eliminate.

Parameters:

  | al | available list
  | ds | dependency set

Return values:

  | keyp | added package key pointer (or NULL)

Returns:
  associated package key, NULL if none

Definition at line 872 of file rpmal.c.

References rpmalAllSatisfiesDepend().

Referenced by addRelation(), and unsatisfiedDepend().

## Variable Documentation

int _rpmal_debug = 0

Definition at line 21 of file rpmal.c.

Referenced by fieCompare(), rpmal_Debug(), rpmalAdd(), rpmalAllFileSatisfiesDepend(), and rpmalDel().