# rpmdb/fprint.c File Reference

`#include "system.h"`
`#include <rpmdb.h>`
`#include <rpmmacro.h>`
`#include "fprint.h"`
`#include "header.h"`
`#include "debug.h"`

Go to the source code of this file.

## Functions

fingerPrintCache | fpCacheCreate (int sizeHint)
| Create finger print cache.
void | fpCacheFree (fingerPrintCache cache)
| Destroy finger print cache.
static struct fprintCacheEntry_s * | cacheContainsDirectory (fingerPrintCache cache, const char *dirName)
| Find directory name entry in cache.
static fingerPrint | doLookup (fingerPrintCache cache, const char *dirName, const char *baseName, int scareMemory)
| Return finger print of a file path.
fingerPrint | fpLookup (fingerPrintCache cache, const char *dirName, const char *baseName, int scareMemory)
| Return finger print of a file path.
unsigned int | fpHashFunction (const void *key)
| Return hash value for a finger print.
int | fpEqual (const void *key1, const void *key2)
| Compare two finger print entries.
void | fpLookupList (fingerPrintCache cache, const char **dirNames, const char **baseNames, const int *dirIndexes, int fileCount, fingerPrint *fpList)
| Return finger prints of an array of file paths.
void | fpLookupHeader (fingerPrintCache cache, Header h, fingerPrint *fpList)
| Return finger prints of all file names in header.

## Detailed Description

Definition in file fprint.c.

## Function Documentation

static struct fprintCacheEntry_s* cacheContainsDirectory | ( | fingerPrintCache | cache,
|  | const char * | dirName |
| ) |  |  | `[static, read]`

Find directory name entry in cache.

Parameters:

  | cache | pointer to fingerprint cache
  | dirName | string to locate in cache

Returns:
  pointer to directory name entry (or NULL if not found).

Definition at line 35 of file fprint.c.

static fingerPrint doLookup | ( | fingerPrintCache | cache,
|  | const char * | dirName,
|  | const char * | baseName,
|  | int | scareMemory |
| ) |  |  | `[static]`

Return finger print of a file path.

Parameters:

  | cache | pointer to fingerprint cache
  | dirName | leading directory name of path
  | baseName | file name of path
  | scareMemory |

Returns:
  pointer to the finger print associated with a file path.

Definition at line 55 of file fprint.c.

fingerPrintCache fpCacheCreate | ( | int | sizeHint | ) |

Create finger print cache.

Parameters:

  | sizeHint | number of elements expected

Returns:
  pointer to initialized fingerprint cache

Definition at line 13 of file fprint.c.

void fpCacheFree | ( | fingerPrintCache | cache | ) |

Destroy finger print cache.

Parameters:

  | cache | pointer to fingerprint cache

Definition at line 23 of file fprint.c.

int fpEqual | ( | const void * | key1,
|  | const void * | key2 |
| ) |  |  |

Compare two finger print entries.

exactly equivalent to FP_EQUAL macro.

Parameters:

  | key1 | finger print 1
  | key2 | finger print 2

Returns:
  result of comparing key1 and key2

Definition at line 209 of file fprint.c.

unsigned int fpHashFunction | ( | const void * | key | ) |

Return hash value for a finger print.

Hash based on dev and inode only!

Parameters:

  | key | pointer to finger print entry

Returns:
  hash value

Definition at line 191 of file fprint.c.

fingerPrint fpLookup | ( | fingerPrintCache | cache,
|  | const char * | dirName,
|  | const char * | baseName,
|  | int | scareMemory |
| ) |  |  |

Return finger print of a file path.

Parameters:

  | cache | pointer to fingerprint cache
  | dirName | leading directory name of file path
  | baseName | base name of file path
  | scareMemory |

Returns:
  pointer to the finger print associated with a file path.

Definition at line 185 of file fprint.c.

void fpLookupHeader | ( | fingerPrintCache | cache,
|  | Header | h,
|  | fingerPrint * | fpList |
| ) |  |  |

Return finger prints of all file names in header.

Warning:
  : scareMemory is assumed!

Parameters:

  | cache | pointer to fingerprint cache
  | h | package header

Return values:

  | fpList | pointer to array of finger prints

Definition at line 247 of file fprint.c.

void fpLookupList | ( | fingerPrintCache | cache,
|  | const char ** | dirNames,
|  | const char ** | baseNames,
|  | const int * | dirIndexes,
|  | int | fileCount,
|  | fingerPrint * | fpList |
| ) |  |  |

Return finger prints of an array of file paths.

Warning:
  : scareMemory is assumed!

Parameters:

  | cache | pointer to fingerprint cache
  | dirNames | directory names
  | baseNames | file base names
  | dirIndexes | index into dirNames for each baseNames
  | fileCount | number of file entries

Return values:

  | fpList | pointer to array of finger prints

Definition at line 227 of file fprint.c.