message.h File Reference

Printing messages to stderr. More...

## Macros

#define | FILTERS_STR_SIZE 512
| Buffer size for message_filters_to_str() More...

## Enumerations

enum | message_verbosity { V_SILENT , V_ERROR , V_WARNING , V_VERBOSE , V_DEBUG }
| Verbosity levels. More...

## Functions

void | message_init (void)
| Initializes the message functions. More...
void | message_verbosity_increase (void)
| Increase verbosity level by one step unless it was at maximum. More...
void | message_verbosity_decrease (void)
| Decrease verbosity level by one step unless it was at minimum. More...
enum message_verbosity | message_verbosity_get (void)
| Get the current verbosity level. More...
void | message (enum message_verbosity verbosity, const char *fmt,...) lzma_attribute((__format__(__printf__
| Print a message if verbosity level is at least "verbosity". More...
void void | message_warning (const char *fmt,...) lzma_attribute((__format__(__printf__
| Prints a warning and possibly sets exit status. More...
void void void | message_error (const char *fmt,...) lzma_attribute((__format__(__printf__
| Prints an error message and sets exit status. More...
void void void void | message_fatal (const char *fmt,...) lzma_attribute((__format__(__printf__
| Prints an error message and exits with EXIT_ERROR. More...
void void void void | lzma_attribute ((__noreturn__))
void | message_bug (void) lzma_attribute((__noreturn__))
void | message_signal_handler (void) lzma_attribute((__noreturn__))
const char * | message_strm (lzma_ret code)
| Convert lzma_ret to a string. More...
void | message_mem_needed (enum message_verbosity v, uint64_t memusage)
| Display how much memory was needed and how much the limit was. More...
void | message_filters_to_str (char buf[FILTERS_STR_SIZE], const lzma_filter *filters, bool all_known)
| Get the filter chain as a string. More...
void | message_filters_show (enum message_verbosity v, const lzma_filter *filters)
| Print the filter chain. More...
void | message_try_help (void)
| Print a message that user should try –help. More...
void | message_version (void) lzma_attribute((__noreturn__))
| Prints the version number to stdout and exits with exit status SUCCESS. More...
void | message_help (bool long_help) lzma_attribute((__noreturn__))
| Print the help message. More...
void | message_set_files (unsigned int files)
| Set the total number of files to be processed. More...
void | message_filename (const char *src_name)
| Set the name of the current file and possibly print it too. More...
void | message_progress_start (lzma_stream *strm, bool is_passthru, uint64_t in_size)
| Start progress info handling. More...
void | message_progress_update (void)
void | message_progress_end (bool finished)
| Finishes the progress message if we were in verbose mode. More...

## Variables

const int | message_progress_sigs []
| Signals used for progress message handling. More...

## Detailed Description

Printing messages to stderr.

## Macro Definition Documentation

## FILTERS_STR_SIZE

#define FILTERS_STR_SIZE 512

Buffer size for message_filters_to_str()

## Enumeration Type Documentation

## message_verbosity

enum message_verbosity

Verbosity levels.

Enumerator
V_SILENT | No messages.
V_ERROR | Only error messages.
V_WARNING | Errors and warnings.
V_VERBOSE | Errors, warnings, and verbose statistics.
V_DEBUG | Very verbose.

## Function Documentation

## message_init()

void message_init | ( | void |  | ) |

Initializes the message functions.

If an error occurs, this function doesn't return.

References progress_automatic.

## message_verbosity_increase()

void message_verbosity_increase | ( | void |  | ) |

Increase verbosity level by one step unless it was at maximum.

References V_DEBUG, and verbosity.

## message_verbosity_decrease()

void message_verbosity_decrease | ( | void |  | ) |

Decrease verbosity level by one step unless it was at minimum.

References V_SILENT, and verbosity.

## message_verbosity_get()

enum message_verbosity message_verbosity_get | ( | void |  | ) |

Get the current verbosity level.

## message()

void message | ( | enum message_verbosity | verbosity,
|  | const char * | fmt,
|  |  | ...
| ) |  |

Print a message if verbosity level is at least "verbosity".

This doesn't touch the exit status.

Referenced by message_try_help().

## message_warning()

void void message_warning | ( | const char * | fmt,
|  |  | ...
| ) |  |

Prints a warning and possibly sets exit status.

The message is printed only if verbosity level is at least V_WARNING. The exit status is set to WARNING unless it was already at ERROR.

Referenced by msg_suffix().

## message_error()

void void void message_error | ( | const char * | fmt,
|  |  | ...
| ) |  |

Prints an error message and sets exit status.

The message is printed only if verbosity level is at least V_ERROR. The exit status is set to ERROR.

Referenced by io_close(), io_pread(), is_empty_filename(), and parse_indexes().

## message_fatal()

void void void void message_fatal | ( | const char * | fmt,
|  |  | ...
| ) |  |

Prints an error message and exits with EXIT_ERROR.

The message is printed only if verbosity level is at least V_ERROR.

Referenced by coder_add_filter(), message_bug(), message_signal_handler(), parse_options(), str_to_uint64(), and suffix_set().

## message_bug()

void message_bug | ( | void |  | ) |

Print an error message that an internal error occurred and exit with EXIT_ERROR.

References message_fatal().

## message_signal_handler()

void message_signal_handler | ( | void |  | ) |

Print a message that establishing signal handlers failed, and exit with exit status ERROR.

References message_fatal().

## message_strm()

const char* message_strm | ( | lzma_ret | code | ) |

Convert lzma_ret to a string.

References LZMA_NO_CHECK.

## message_mem_needed()

void message_mem_needed | ( | enum message_verbosity | v,
|  | uint64_t | memusage
| ) |  |

Display how much memory was needed and how much the limit was.

References hardware_memlimit_get(), opt_mode, round_up_to_mib(), and verbosity.

## message_filters_to_str()

void message_filters_to_str | ( | char | buf[FILTERS_STR_SIZE],
|  | const lzma_filter * | filters,
|  | bool | all_known
| ) |  |

Get the filter chain as a string.

Parameters

  buf | Pointer to caller allocated buffer to hold the filter chain string
  filters | Pointer to the filter chain
  all_known | If true, all filter options are printed. If false, only the options that get stored into .xz headers are printed.

References lzma_options_lzma::dict_size, filters, FILTERS_STR_SIZE, lzma_filter::id, LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA2, LZMA_MF_BT2, LZMA_MF_BT3, LZMA_MF_BT4, LZMA_MF_HC3, LZMA_MF_HC4, LZMA_MODE_FAST, LZMA_MODE_NORMAL, LZMA_VLI_UNKNOWN, lzma_options_lzma::mf, lzma_options_lzma::mode, my_snprintf(), lzma_filter::options, and uint32_to_optstr().

Referenced by message_filters_show().

## message_filters_show()

void message_filters_show | ( | enum message_verbosity | v,
|  | const lzma_filter * | filters
| ) |  |

Print the filter chain.

References filters, FILTERS_STR_SIZE, message_filters_to_str(), and verbosity.

## message_try_help()

void message_try_help | ( | void |  | ) |

Print a message that user should try –help.

References message(), and V_WARNING.

## message_version()

void message_version | ( | void |  | ) |

Prints the version number to stdout and exits with exit status SUCCESS.

## message_help()

void message_help | ( | bool | long_help | ) |

Print the help message.

## message_set_files()

void message_set_files | ( | unsigned int | files | ) |

Set the total number of files to be processed.

Standard input is counted as a file here. This is used when printing the filename via message_filename().

## message_filename()

void message_filename | ( | const char * | src_name | ) |

Set the name of the current file and possibly print it too.

The name is printed immediately if –list was used or if –verbose was used and stderr is a terminal. Even when the filename isn't printed, it is stored so that it can be printed later if needed for progress messages.

References filename, files_pos, opt_mode, progress_automatic, V_VERBOSE, and verbosity.

Referenced by coder_run().

## message_progress_start()

void message_progress_start | ( | lzma_stream * | strm,
|  | bool | is_passthru,
|  | uint64_t | in_size
| ) |  |

Start progress info handling.

message_filename() must be called before this function to set the filename.

This must be paired with a call to message_progress_end() before the given *strm becomes invalid.

Parameters

  strm | Pointer to lzma_stream used for the coding.
  in_size | Size of the input file, or zero if unknown.

References expected_in_size, progress_automatic, progress_is_from_passthru, progress_needs_updating, progress_next_update, progress_started, progress_strm, strm, V_VERBOSE, and verbosity.

## message_progress_update()

void message_progress_update | ( | void |  | ) |

Update the progress info if in verbose mode and enough time has passed since the previous update. This can be called only when message_progress_start() has already been used.

References current_filename_printed, mytime_get_elapsed(), print_filename(), progress_needs_updating, progress_next_update, progress_percentage(), progress_pos(), progress_remaining(), progress_sizes(), progress_speed(), progress_time(), and signals_block().

Referenced by coder_passthru().

## message_progress_end()

void message_progress_end | ( | bool | finished | ) |

Finishes the progress message if we were in verbose mode.

Parameters

  finished | True if the whole stream was successfully coded and output written to the output stream.

## Variable Documentation

## message_progress_sigs

const int message_progress_sigs[]

extern

Signals used for progress message handling.