ar.c File Reference
PAYLOAD.

Handle ar(1) archives. More...

`#include "system.h"`
`#include <rpmio_internal.h>`
`#include <rpmmacro.h>`
`#include <ugid.h>`
`#include <ar.h>`
`#include <iosm.h>`
`#include "debug.h"`
Include dependency graph for ar.c:

Go to the source code of this file.

## Macros

#define | _IOSM_INTERNAL
#define | _IOSMRC(_rc) if ((_rc) <= 0) return ((_rc) ? (int) -rc : IOSMERR_HDR_TRAILER)

## Functions

static int | strntoul (const char *str, char **endptr, int base, size_t num)
| Convert string to unsigned integer (with buffer size check). More...
static ssize_t | arRead (void *_iosm, void *buf, size_t count)
int | arHeaderRead (void *_iosm, struct stat *st)
| Read ar(1) header. More...
static ssize_t | arWrite (void *_iosm, const void *buf, size_t count)
int | arHeaderWrite (void *_iosm, struct stat *st)
| Write ar(1) header. More...
int | arTrailerWrite (void *_iosm)
| Write ar(1) trailer. More...

## Variables

int | _ar_debug = 0

## Detailed Description

Handle ar(1) archives.

Definition in file ar.c.

## Macro Definition Documentation

#define _IOSM_INTERNAL

Definition at line 15 of file ar.c.

#define _IOSMRC | ( |  | _rc | ) | if ((_rc) <= 0) return ((_rc) ? (int) -rc : IOSMERR_HDR_TRAILER)

Definition at line 56 of file ar.c.

Referenced by arHeaderRead(), arHeaderWrite(), and arTrailerWrite().

## Function Documentation

int arHeaderRead | ( | void * | _iosm,
|  | struct stat * | st
| ) |  |

Read ar(1) header.

Return values

  _iosm | file path and stat info
  st |

Returns
  0 on success

Definition at line 92 of file ar.c.

References _ar_debug, _iosmNext, _IOSMRC, AR_MAGIC, AR_MARKER, arRead(), fdGetCpioPos(), arHeader_s::filesize, arHeader_s::gid, IOSM_POS, arHeader_s::marker, arHeader_s::mode, arHeader_s::mtime, arHeader_s::name, strntoul(), arHeader_s::uid, xisdigit(), and xstrdup().

Referenced by fsmSetup(), and iosmSetup().

int arHeaderWrite | ( | void * | _iosm,
|  | struct stat * | st
| ) |  |

Write ar(1) header.

Return values

  _iosm | file path and stat info

Parameters

  st |

Returns
  0 on success

Definition at line 235 of file ar.c.

References _ar_debug, _iosmNext, _IOSMRC, AR_MAGIC, AR_MARKER, arWrite(), fdGetCpioPos(), arHeader_s::filesize, arHeader_s::gid, IOSM_PAD, arHeader_s::marker, arHeader_s::mode, arHeader_s::mtime, arHeader_s::name, snprintf(), and arHeader_s::uid.

Referenced by fsmSetup(), and iosmSetup().

static ssize_t arRead | ( | void * | _iosm,
|  | void * | buf,
|  | size_t | count
| ) |  |

static

Definition at line 59 of file ar.c.

References _ar_debug, _iosmNext, and IOSM_DREAD.

Referenced by arHeaderRead().

int arTrailerWrite | ( | void * | _iosm | ) |

Write ar(1) trailer.

Return values

  _iosm | file path and stat info

Returns
  0 on success

Definition at line 308 of file ar.c.

References _ar_debug, _iosmNext, _IOSMRC, arWrite(), and IOSM_PAD.

Referenced by fsmSetup(), and iosmSetup().

static ssize_t arWrite | ( | void * | _iosm,
|  | const void * | buf,
|  | size_t | count
| ) |  |

static

Definition at line 199 of file ar.c.

References _ar_debug, _iosmNext, IOSM_DWRITE, and IOSM_PAD.

Referenced by arHeaderWrite(), and arTrailerWrite().

static int strntoul | ( | const char * | str,
|  | char ** | endptr,
|  | int | base,
|  | size_t | num
| ) |  |

static

Convert string to unsigned integer (with buffer size check).

Parameters

  str | input string

Return values

  *endptr | 1st character not processed

Parameters

  base | numerical conversion base
  num | max no. of bytes to read

Returns
  converted integer

Definition at line 33 of file ar.c.

References alloca().

Referenced by arHeaderRead().

## Variable Documentation

int _ar_debug = 0

Definition at line 23 of file ar.c.

Referenced by arHeaderRead(), arHeaderWrite(), arRead(), arTrailerWrite(), and arWrite().