rpm  5.4.15
Data Structures | Macros | Enumerations | Functions | Variables
rpmz.c File Reference
#include "system.h"
#include <lzma.h>
#include "rpmz.h"
#include "debug.h"
Include dependency graph for rpmz.c:

Go to the source code of this file.

Data Structures

struct  suffixPairs_s
 
struct  name_id_map
 
struct  option_map
 

Macros

#define _RPMIOB_INTERNAL
 
#define _RPMZ_INTERNAL
 
#define _RPMZ_INTERNAL_XZ
 
#define F_ISSET(_f, _FLAG)   (((_f) & ((RPMZ_FLAGS_##_FLAG) & ~0x40000000)) != RPMZ_FLAGS_NONE)
 
#define RZ_ISSET(_FLAG)   F_ISSET(z->flags, _FLAG)
 

Enumerations

enum  { OPT_SUBBLOCK = INT_MIN, OPT_DELTA, OPT_LZMA1, OPT_LZMA2 }
 
enum  { OPT_SIZE, OPT_RLE, OPT_ALIGN }
 
enum  { OPT_DIST }
 
enum  {
  OPT_PRESET, OPT_DICT, OPT_LC, OPT_LP,
  OPT_PB, OPT_MODE, OPT_NICE, OPT_MF,
  OPT_DEPTH
}
 

Functions

static int checkfd (const char *devnull, int fdno, int flags)
 
static void io_init (void)
 
static void io_unlink (const char *fn, const struct stat *ost)
 
static void io_copy_attrs (rpmz z)
 
static rpmuint64_t physmem (void)
 
static void hw_cores (rpmz z)
 
static void hw_memlimit_init (rpmz z)
 
static void hw_init (rpmz z)
 
static int chkSuffix (const char *fn, const char *suffix)
 Check string for a suffix. More...
 
static char * changeSuffix (const char *fn, const char *old, const char *new)
 Return (malloc'd) string with new suffix substituted for old. More...
 
static const char * uncompressedFN (rpmz z)
 Return (malloc'd) uncompressed file name. More...
 
static const char * compressedFN (rpmz z)
 Return (malloc'd) compressed file name. More...
 
static rpmRC rpmzProcess (rpmz z, const char *ifn)
 
static rpmRC rpmzFini (rpmz z, rpmRC rc)
 
static rpmRC rpmzInit (rpmz z, const char *ifn)
 
static rpmRC rpmzCopy (rpmz z, rpmiob iob)
 
static void signals_init (void)
 
static void signals_fini (void)
 
static int signals_terminating (int terminate)
 
static void signals_exit (void)
 
static void parse_options (const char *str, const option_map *opts, void(*set)(void *filter_options, rpmuint32_t key, rpmuint64_t value), void *filter_options)
 
static void set_subblock (void *options, rpmuint32_t key, rpmuint64_t value)
 
static lzma_options_subblock * options_subblock (const char *str)
 
static void set_delta (void *options, rpmuint32_t key, rpmuint64_t value)
 
static lzma_options_delta * options_delta (const char *str)
 
static void set_lzma (void *options, rpmuint32_t key, rpmuint64_t value)
 
static lzma_options_lzma * options_lzma (const char *str)
 
static void coder_add_filter (rpmz z, lzma_vli id, void *options)
 
static rpmuint64_t hw_memlimit_encoder (rpmz z)
 
static rpmuint64_t hw_memlimit_decoder (rpmz z)
 
static void message_filters (int code, const lzma_filter *filters)
 
static void memlimit_too_small (rpmuint64_t memory_usage, rpmuint64_t memory_limit)
 
static void coder_set_compression_settings (rpmz z)
 
void rpmzArgCallback (poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, void *data)
 
int main (int argc, char *argv[])
 

Variables

static int _debug = 0
 
struct rpmz_s __rpmz
 
rpmz _rpmz = &__rpmz
 
static struct suffixPairs_s suffixPairs []
 
static int signals_init_count
 
static struct poptOption rpmzFiltersPoptTable []
 
static struct poptOption rpmzPrivatePoptTable []
 
static struct poptOption optionsTable []
 

Macro Definition Documentation

#define _RPMIOB_INTERNAL

Definition at line 25 of file rpmz.c.

#define _RPMZ_INTERNAL

Definition at line 26 of file rpmz.c.

#define _RPMZ_INTERNAL_XZ

Definition at line 27 of file rpmz.c.

#define F_ISSET (   _f,
  _FLAG 
)    (((_f) & ((RPMZ_FLAGS_##_FLAG) & ~0x40000000)) != RPMZ_FLAGS_NONE)

Definition at line 65 of file rpmz.c.

Referenced by coder_set_compression_settings(), main(), rpmzFini(), and rpmzInit().

#define RZ_ISSET (   _FLAG)    F_ISSET(z->flags, _FLAG)

Definition at line 66 of file rpmz.c.

Enumeration Type Documentation

anonymous enum
Enumerator
OPT_SUBBLOCK 
OPT_DELTA 
OPT_LZMA1 
OPT_LZMA2 

Definition at line 56 of file rpmz.c.

anonymous enum
Enumerator
OPT_SIZE 
OPT_RLE 
OPT_ALIGN 

Definition at line 1028 of file rpmz.c.

anonymous enum
Enumerator
OPT_DIST 

Definition at line 1074 of file rpmz.c.

anonymous enum
Enumerator
OPT_PRESET 
OPT_DICT 
OPT_LC 
OPT_LP 
OPT_PB 
OPT_MODE 
OPT_NICE 
OPT_MF 
OPT_DEPTH 

Definition at line 1108 of file rpmz.c.

Function Documentation

static char* changeSuffix ( const char *  fn,
const char *  old,
const char *  new 
)
static

Return (malloc'd) string with new suffix substituted for old.

Parameters
fnstring
oldold suffix
newnew suffix
Returns
new string

Definition at line 457 of file rpmz.c.

References stpcpy(), and xmalloc.

Referenced by compressedFN(), and uncompressedFN().

static int checkfd ( const char *  devnull,
int  fdno,
int  flags 
)
static

Definition at line 99 of file rpmz.c.

References errno.

Referenced by io_init().

static int chkSuffix ( const char *  fn,
const char *  suffix 
)
static

Check string for a suffix.

Parameters
fnstring
suffixsuffix
Returns
1 if string ends with suffix

Definition at line 439 of file rpmz.c.

References _debug.

Referenced by compressedFN(), and uncompressedFN().

static void coder_add_filter ( rpmz  z,
lzma_vli  id,
void *  options 
)
static

Definition at line 1200 of file rpmz.c.

References _, __progname, and options.

Referenced by coder_set_compression_settings(), and rpmzArgCallback().

static void coder_set_compression_settings ( rpmz  z)
static
static const char* compressedFN ( rpmz  z)
static

Return (malloc'd) compressed file name.

Parameters
zrpmz container
Returns
compressed file name

Definition at line 513 of file rpmz.c.

References _debug, changeSuffix(), chkSuffix(), suffixPairs_s::csuffix, suffixPairs_s::format, rpmGetPath(), suffixPairs, and suffixPairs_s::usuffix.

Referenced by rpmzInit().

static void hw_cores ( rpmz  z)
static

Definition at line 347 of file rpmz.c.

References name.

Referenced by hw_init().

static void hw_init ( rpmz  z)
static

Definition at line 399 of file rpmz.c.

References hw_cores(), and hw_memlimit_init().

Referenced by main().

static rpmuint64_t hw_memlimit_decoder ( rpmz  z)
static

Definition at line 1224 of file rpmz.c.

Referenced by coder_set_compression_settings().

static rpmuint64_t hw_memlimit_encoder ( rpmz  z)
static

Definition at line 1217 of file rpmz.c.

Referenced by coder_set_compression_settings().

static void hw_memlimit_init ( rpmz  z)
static

Definition at line 382 of file rpmz.c.

References physmem().

Referenced by hw_init().

static void io_copy_attrs ( rpmz  z)
static

Definition at line 167 of file rpmz.c.

References _, errno, Fchmod(), Fchown(), Fileno(), mode, rpmlog(), RPMLOG_WARNING, Utime(), and Utimes().

Referenced by rpmzFini().

static void io_init ( void  )
static

Definition at line 112 of file rpmz.c.

References checkfd().

Referenced by main().

static void io_unlink ( const char *  fn,
const struct stat *  ost 
)
static

Definition at line 140 of file rpmz.c.

References _, errno, Lstat(), rpmlog(), RPMLOG_ERR, and Unlink().

Referenced by rpmzFini().

int main ( int  argc,
char *  argv[] 
)
static void memlimit_too_small ( rpmuint64_t  memory_usage,
rpmuint64_t  memory_limit 
)
static

Definition at line 1319 of file rpmz.c.

References _, EXIT_FAILURE, rpmlog(), and RPMLOG_CRIT.

Referenced by coder_set_compression_settings().

static void message_filters ( int  code,
const lzma_filter *  filters 
)
static

< mask for one priority

Definition at line 1231 of file rpmz.c.

References __progname, i, mode, rpmlog(), RPMLOG_MASK, RPMLOG_PRI, rpmlogSetMask(), and stpcpy().

Referenced by coder_set_compression_settings().

static lzma_options_delta* options_delta ( const char *  str)
static

Definition at line 1089 of file rpmz.c.

References options, parse_options(), set_delta(), and xmalloc.

Referenced by rpmzArgCallback().

static lzma_options_lzma* options_lzma ( const char *  str)
static

Definition at line 1146 of file rpmz.c.

References options, parse_options(), set_lzma(), and xmalloc.

Referenced by rpmzArgCallback().

static lzma_options_subblock* options_subblock ( const char *  str)
static

Definition at line 1048 of file rpmz.c.

References options, parse_options(), set_subblock(), and xmalloc.

Referenced by rpmzArgCallback().

static void parse_options ( const char *  str,
const option_map opts,
void(*)(void *filter_options, rpmuint32_t key, rpmuint64_t value)  set,
void *  filter_options 
)
static
static rpmuint64_t physmem ( void  )
static

Definition at line 314 of file rpmz.c.

References name.

Referenced by hw_memlimit_init().

void rpmzArgCallback ( poptContext  con,
enum poptCallbackReason  reason,
const struct poptOption *  opt,
const char *  arg,
void *  data 
)
static rpmRC rpmzCopy ( rpmz  z,
rpmiob  iob 
)
static

Definition at line 766 of file rpmz.c.

References Ferror(), Fread(), Fwrite(), RPMRC_FAIL, and RPMRC_OK.

Referenced by rpmzProcess().

static rpmRC rpmzFini ( rpmz  z,
rpmRC  rc 
)
static

Definition at line 541 of file rpmz.c.

References _, _debug, _free(), errno, F_ISSET, Fclose(), Fflush(), io_copy_attrs(), io_unlink(), rpmlog(), RPMLOG_ERR, RPMRC_FAIL, RPMRC_OK, and Unlink().

Referenced by rpmzProcess().

static rpmRC rpmzInit ( rpmz  z,
const char *  ifn 
)
static
static rpmRC rpmzProcess ( rpmz  z,
const char *  ifn 
)
static

Definition at line 786 of file rpmz.c.

References RPMRC_OK, rpmzCopy(), rpmzFini(), and rpmzInit().

Referenced by main(), and rpmzInit().

static void set_delta ( void *  options,
rpmuint32_t  key,
rpmuint64_t  value 
)
static

Definition at line 1079 of file rpmz.c.

References OPT_DIST, and options.

Referenced by options_delta().

static void set_lzma ( void *  options,
rpmuint32_t  key,
rpmuint64_t  value 
)
static

Definition at line 1121 of file rpmz.c.

References _, OPT_DEPTH, OPT_DICT, OPT_LC, OPT_LP, OPT_MF, OPT_MODE, OPT_NICE, OPT_PB, OPT_PRESET, and options.

Referenced by options_lzma().

static void set_subblock ( void *  options,
rpmuint32_t  key,
rpmuint64_t  value 
)
static

Definition at line 1035 of file rpmz.c.

References OPT_ALIGN, OPT_RLE, OPT_SIZE, and options.

Referenced by options_subblock().

static void signals_exit ( void  )
static

Definition at line 885 of file rpmz.c.

References signals_fini().

Referenced by main().

static void signals_fini ( void  )
static

Definition at line 817 of file rpmz.c.

References rpmsqEnable().

Referenced by signals_exit().

static void signals_init ( void  )
static

Definition at line 801 of file rpmz.c.

References rpmsqEnable().

Referenced by main().

static int signals_terminating ( int  terminate)
static

Definition at line 833 of file rpmz.c.

References rpmsqCaught.

Referenced by main().

static const char* uncompressedFN ( rpmz  z)
static

Return (malloc'd) uncompressed file name.

Parameters
zrpmz container
Returns
uncompressed file name

Definition at line 484 of file rpmz.c.

References _debug, changeSuffix(), chkSuffix(), suffixPairs_s::csuffix, suffixPairs_s::format, suffixPairs, suffixPairs_s::usuffix, and xstrdup().

Referenced by rpmzInit().

Variable Documentation

struct rpmz_s __rpmz
Initial value:
= {
.stdin_fn = "(stdin)",
.stdout_fn = "(stdout)",
.format = RPMZ_FORMAT_AUTO,
.level = 6,
.nb = 16 * BUFSIZ,
.ifmode = "rb",
.ofmode = "wb",
._auto_adjust = 1,
._format_compress_auto = RPMZ_FORMAT_GZIP,
._checksum = LZMA_CHECK_CRC64,
}
const char * mode
Definition: mongo.h:440

Definition at line 69 of file rpmz.c.

Referenced by main().

int _debug = 0
static

Definition at line 33 of file rpmz.c.

Referenced by chkSuffix(), compressedFN(), main(), rpmzFini(), rpmzInit(), and uncompressedFN().

rpmz _rpmz = &__rpmz

Definition at line 94 of file rpmz.c.

Referenced by main(), and rpmzArgCallback().

struct poptOption optionsTable[]
static

Definition at line 1796 of file rpmz.c.

struct poptOption rpmzFiltersPoptTable[]
static

Definition at line 1693 of file rpmz.c.

struct poptOption rpmzPrivatePoptTable[]
static

Definition at line 1759 of file rpmz.c.

int signals_init_count
static

Definition at line 799 of file rpmz.c.

struct suffixPairs_s suffixPairs[]
static
Initial value:
= {
{ RPMZ_FORMAT_XZ, ".xz", "" },
{ RPMZ_FORMAT_XZ, ".txz", ".tar" },
{ RPMZ_FORMAT_LZMA, ".lzma","" },
{ RPMZ_FORMAT_LZMA, ".tlz", ".tar" },
{ RPMZ_FORMAT_GZIP, ".gz", "" },
{ RPMZ_FORMAT_GZIP, ".tgz", ".tar" },
{ RPMZ_FORMAT_ZLIB, ".zz", "" },
{ RPMZ_FORMAT_ZLIB, ".tzz", ".tar" },
{ RPMZ_FORMAT_ZIP2, ".zip", "" },
{ RPMZ_FORMAT_BZIP2, ".bz2", "" },
{ RPMZ_FORMAT_RAW, NULL, NULL }
}

Referenced by compressedFN(), and uncompressedFN().