# rpmdb/legacy.c File Reference

`#include "system.h"`
`#include "rpmio_internal.h"`
`#include <rpmlib.h>`
`#include <rpmmacro.h>`
`#include "misc.h"`
`#include "legacy.h"`
`#include "debug.h"`

Include dependency graph for legacy.c:

Go to the source code of this file.

## Defines

#define | alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))

## Functions

static int | open_dso (const char *path, pid_t *pidp, size_t *fsizep)
| Open a file descriptor to verify file MD5 and size.
int | dodigest (int digestalgo, const char *fn, unsigned char *digest, int asAscii, size_t *fsizep)
| Return digest and size of a file.
int | domd5 (const char *fn, unsigned char *digest, int asAscii, size_t *fsizep)
| Return MD5 digest and size of a file.

## Detailed Description

Definition in file legacy.c.

## Define Documentation

#define alloca_strdup | ( | _s |  | ) | strcpy(alloca(strlen(_s)+1), (_s))

Definition at line 35 of file legacy.c.

## Function Documentation

int dodigest | ( | int | digestalgo,
|  | const char * | fn,
|  | unsigned char * | digest,
|  | int | asAscii,
|  | size_t * | fsizep |
| ) |  |  |

Return digest and size of a file.

Parameters:

  | digestalgo | digest algorithm to use
  | fn | file name

Return values:

  | digest | address of md5sum

Parameters:

  | asAscii | return md5sum as ascii string?

Return values:

  | *fsizep | file size pointer (or NULL)

Returns:
  0 on success, 1 on error

Definition at line 152 of file legacy.c.

References _free(), Fclose(), fdDup(), fdFiniDigest(), fdInitDigest(), Ferror(), Fopen(), Fread(), open_dso(), RPMDIGEST_NONE, rpmDigestFinal(), rpmDigestInit(), rpmDigestUpdate(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath().

Referenced by domd5(), genCpioListAndHeader(), handleOverlappedFiles(), rpmAddSignature(), rpmfiDecideFate(), and rpmVerifyFile().

int domd5 | ( | const char * | fn,
|  | unsigned char * | digest,
|  | int | asAscii,
|  | size_t * | fsizep |
| ) |  |  |

Return MD5 digest and size of a file.

Parameters:

  | fn | file name

Return values:

  | digest | address of md5sum

Parameters:

  | asAscii | return md5sum as ascii string?

Return values:

  | *fsizep | file size pointer (or NULL)

Returns:
  0 on success, 1 on error

Definition at line 257 of file legacy.c.

References dodigest(), and PGPHASHALGO_MD5.

static int open_dso | ( | const char * | path,
|  | pid_t * | pidp,
|  | size_t * | fsizep |
| ) |  |  | `[static]`

Open a file descriptor to verify file MD5 and size.

Parameters:

  | path | file path

Return values:

  | pidp | prelink helper pid or 0
  | fsizep | file size

Returns:
  -1 on error, otherwise, an open file descriptor

Definition at line 45 of file legacy.c.

References rpmExpand(), and unsetenv().

Referenced by dodigest().