lzmainfo.c (3829a7346880c0e2bec70a23c3169714fb0b1e58) lzmainfo.c (e0f0e66dfeda9df4f104f48bd42d5a28d8ae631e)
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file lzmainfo.c
4/// \brief lzmainfo tool for compatibility with LZMA Utils
5//
6// Author: Lasse Collin
7//
8// This file has been put into the public domain.

--- 6 unchanged lines hidden (view full) ---

15#include <errno.h>
16
17#include "lzma.h"
18#include "getopt.h"
19#include "tuklib_gettext.h"
20#include "tuklib_progname.h"
21#include "tuklib_exit.h"
22
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file lzmainfo.c
4/// \brief lzmainfo tool for compatibility with LZMA Utils
5//
6// Author: Lasse Collin
7//
8// This file has been put into the public domain.

--- 6 unchanged lines hidden (view full) ---

15#include <errno.h>
16
17#include "lzma.h"
18#include "getopt.h"
19#include "tuklib_gettext.h"
20#include "tuklib_progname.h"
21#include "tuklib_exit.h"
22
23#ifdef TUKLIB_DOSLIKE
24# include <fcntl.h>
25# include <io.h>
26#endif
23
27
28
24static void lzma_attribute((noreturn))
25help(void)
26{
27 printf(
28_("Usage: %s [--help] [--version] [FILE]...\n"
29"Show information stored in the .lzma file header"), progname);
30
31 printf(_(

--- 6 unchanged lines hidden (view full) ---

38
39 tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, true);
40}
41
42
43static void lzma_attribute((noreturn))
44version(void)
45{
29static void lzma_attribute((noreturn))
30help(void)
31{
32 printf(
33_("Usage: %s [--help] [--version] [FILE]...\n"
34"Show information stored in the .lzma file header"), progname);
35
36 printf(_(

--- 6 unchanged lines hidden (view full) ---

43
44 tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, true);
45}
46
47
48static void lzma_attribute((noreturn))
49version(void)
50{
46 puts("lzmainfo (" PACKAGE_NAME ") " PACKAGE_VERSION);
51 puts("lzmainfo (" PACKAGE_NAME ") " LZMA_VERSION_STRING);
47 tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, true);
48}
49
50
51/// Parse command line options.
52static void
53parse_args(int argc, char **argv)
54{

--- 90 unchanged lines hidden (view full) ---

145 printf("%" PRIu64 " MB (%" PRIu64 " bytes)",
146 (uncompressed_size + 512 * 1024)
147 / (1024 * 1024),
148 uncompressed_size);
149
150 lzma_options_lzma *opt = filter.options;
151
152 printf("\nDictionary size: "
52 tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, true);
53}
54
55
56/// Parse command line options.
57static void
58parse_args(int argc, char **argv)
59{

--- 90 unchanged lines hidden (view full) ---

150 printf("%" PRIu64 " MB (%" PRIu64 " bytes)",
151 (uncompressed_size + 512 * 1024)
152 / (1024 * 1024),
153 uncompressed_size);
154
155 lzma_options_lzma *opt = filter.options;
156
157 printf("\nDictionary size: "
153 "%u MB (2^%u bytes)\n"
158 "%" PRIu32 " MB (2^%" PRIu32 " bytes)\n"
154 "Literal context bits (lc): %" PRIu32 "\n"
155 "Literal pos bits (lp): %" PRIu32 "\n"
156 "Number of pos bits (pb): %" PRIu32 "\n",
157 (opt->dict_size + 512 * 1024) / (1024 * 1024),
158 my_log2(opt->dict_size), opt->lc, opt->lp, opt->pb);
159
160 free(opt);
161

--- 4 unchanged lines hidden (view full) ---

166extern int
167main(int argc, char **argv)
168{
169 tuklib_progname_init(argv);
170 tuklib_gettext_init(PACKAGE, LOCALEDIR);
171
172 parse_args(argc, argv);
173
159 "Literal context bits (lc): %" PRIu32 "\n"
160 "Literal pos bits (lp): %" PRIu32 "\n"
161 "Number of pos bits (pb): %" PRIu32 "\n",
162 (opt->dict_size + 512 * 1024) / (1024 * 1024),
163 my_log2(opt->dict_size), opt->lc, opt->lp, opt->pb);
164
165 free(opt);
166

--- 4 unchanged lines hidden (view full) ---

171extern int
172main(int argc, char **argv)
173{
174 tuklib_progname_init(argv);
175 tuklib_gettext_init(PACKAGE, LOCALEDIR);
176
177 parse_args(argc, argv);
178
179#ifdef TUKLIB_DOSLIKE
180 setmode(fileno(stdin), O_BINARY);
181#endif
182
174 int ret = EXIT_SUCCESS;
175
176 // We print empty lines around the output only when reading from
177 // files specified on the command line. This is due to how
178 // LZMA Utils did it.
179 if (optind == argc) {
180 if (lzmainfo("(stdin)", stdin))
181 ret = EXIT_FAILURE;

--- 29 unchanged lines hidden ---
183 int ret = EXIT_SUCCESS;
184
185 // We print empty lines around the output only when reading from
186 // files specified on the command line. This is due to how
187 // LZMA Utils did it.
188 if (optind == argc) {
189 if (lzmainfo("(stdin)", stdin))
190 ret = EXIT_FAILURE;

--- 29 unchanged lines hidden ---