28 fprintf(stderr,
"Usage: %s PRESET < INFILE > OUTFILE\n"
29 "PRESET is a number 0-9 and can optionally be "
30 "followed by `e' to indicate extreme preset\n",
40 if (argc != 2 ||
argv[1][0] <
'0' ||
argv[1][0] >
'9')
48 if (
argv[1][1] !=
'\0') {
49 if (
argv[1][1] !=
'e' ||
argv[1][2] !=
'\0')
79 msg =
"Memory allocation failed";
83 msg =
"Specified preset is not supported";
87 msg =
"Specified integrity check is not supported";
97 msg =
"Unknown error, possibly a bug";
101 fprintf(stderr,
"Error initializing the encoder: %s (error code %u)\n",
145 fprintf(stderr,
"Read error: %s\n",
187 fprintf(stderr,
"Write error: %s\n",
219 msg =
"Memory allocation failed";
235 msg =
"File size limits exceeded";
250 msg =
"Unknown error, possibly a bug";
254 fprintf(stderr,
"Encoder error: %s (error code %u)\n",
291 if (fclose(stdout)) {
292 fprintf(stderr,
"Write error: %s\n", strerror(errno));
296 return success ? EXIT_SUCCESS : EXIT_FAILURE;
static bool init_encoder(lzma_stream *strm, uint32_t preset)
int main(int argc, char **argv)
static uint32_t get_preset(int argc, char **argv)
static bool compress(lzma_stream *strm, FILE *infile, FILE *outfile)
static void show_usage_and_exit(const char *argv0)
#define LZMA_PRESET_EXTREME
Extreme compression preset.
unsigned char outbuf[SIZE]
unsigned char inbuf[SIZE]
static static fork const void static count static fd const char const char static newpath char char argv
The public API of liblzma data compression library.
static struct sockaddr static addrlen static backlog const void msg
Passing data to and from liblzma.
if(dbg->bits==RZ_SYS_BITS_64)
lzma_ret
Return values used by several functions in liblzma.
@ LZMA_DATA_ERROR
Data is corrupt.
@ LZMA_MEM_ERROR
Cannot allocate memory.
@ LZMA_STREAM_END
End of stream was reached.
@ LZMA_UNSUPPORTED_CHECK
Cannot calculate the integrity check.
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
@ LZMA_OK
Operation completed successfully.
lzma_action
The ‘action’ argument for lzma_code()
@ LZMA_FINISH
Finish the coding operation.
@ LZMA_RUN
Continue coding.
#define LZMA_STREAM_INIT
Initialization for lzma_stream.