/build/buildd/xz-utils-4.999.9beta+20091116/src/xz/message.c File Reference

Printing messages. More...

#include "private.h"
#include <stdarg.h>

Functions

static uint64_t my_time (void)
 Get the current time as microseconds since epoch.
static void lzma_attribute ((format(printf, 3, 4)))
 Wrapper for snprintf() to help constructing a string in pieces.
void message_init (void)
 Initializes the message functions.
void message_verbosity_increase (void)
 Increase verbosity level by one step unless it was at maximum.
void message_verbosity_decrease (void)
 Decrease verbosity level by one step unless it was at minimum.
enum message_verbosity message_verbosity_get (void)
 Get the current verbosity level.
void message_set_files (unsigned int files)
static void print_filename (void)
void message_progress_start (lzma_stream *strm, const char *src_name, uint64_t in_size)
 Start progress info handling.
static const char * progress_percentage (uint64_t in_pos, bool final)
 Make the string indicating completion percentage.
static void progress_sizes_helper (char **pos, size_t *left, uint64_t value, bool final)
static const char * progress_sizes (uint64_t compressed_pos, uint64_t uncompressed_pos, bool final)
static const char * progress_speed (uint64_t uncompressed_pos, uint64_t elapsed)
 Make the string containing the processing speed of uncompressed data.
static const char * progress_time (uint64_t useconds)
static const char * progress_remaining (uint64_t in_pos, uint64_t elapsed)
static uint64_t progress_elapsed (void)
 Calculate the elapsed time as microseconds.
static void progress_pos (uint64_t *in_pos, uint64_t *compressed_pos, uint64_t *uncompressed_pos)
void message_progress_update (void)
static void progress_flush (bool finished)
void message_progress_end (bool success)
 Finishes the progress message if we were in verbose mode.
static void vmessage (enum message_verbosity v, const char *fmt, va_list ap)
void message (enum message_verbosity v, const char *fmt,...)
void message_warning (const char *fmt,...)
void message_error (const char *fmt,...)
void message_fatal (const char *fmt,...)
void message_bug (void)
void message_signal_handler (void)
const char * message_strm (lzma_ret code)
 Convert lzma_ret to a string.
void message_filters (enum message_verbosity v, const lzma_filter *filters)
 Print the filter chain.
void message_try_help (void)
 Print a message that user should try --help.
void message_memlimit (void)
 Print the memory usage limit and exit.
void message_version (void)
 Prints the version number to stdout and exits with exit status SUCCESS.
void message_help (bool long_help)
 Print the help message.

Variables

static unsigned int files_pos = 0
 Number of the current file.
static unsigned int files_total
 Total number of input files; zero if unknown.
static enum message_verbosity verbosity = V_WARNING
 Verbosity level.
static const char * filename
 Filename which we will print with the verbose messages.
static bool first_filename_printed = false
static bool current_filename_printed = false
static bool progress_automatic
static bool progress_started = false
static bool progress_active = false
static lzma_streamprogress_strm
 Pointer to lzma_stream used to do the encoding or decoding.
static uint64_t expected_in_size
static uint64_t start_time
 Time when we started processing the file.
static bool progress_needs_updating = false
static uint64_t progress_next_update
 Elapsed time when the next progress message update should be done.

Detailed Description

Printing messages.


Function Documentation

static uint64_t my_time ( void   )  [static]

Get the current time as microseconds since epoch.

Referenced by message_progress_start(), and progress_elapsed().

static void lzma_attribute ( (format(printf, 3, 4))   )  [static]

Wrapper for snprintf() to help constructing a string in pieces.

void message_init ( void   ) 

Initializes the message functions.

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

References message_signal_handler(), and progress_automatic.

void message_verbosity_increase ( void   ) 

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

References V_DEBUG, and verbosity.

void message_verbosity_decrease ( void   ) 

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

References V_SILENT, and verbosity.

enum message_verbosity message_verbosity_get ( void   ) 

Get the current verbosity level.

References verbosity.

void message_set_files ( unsigned int  files  ) 

Set the total number of files to be processed (stdin is counted as a file here). The default is one.

References files_total.

static void print_filename ( void   )  [static]

Prints the name of the current file if it hasn't been printed already, except if we are processing exactly one stream from stdin to stdout. I think it looks nicer to not print "(stdin)" when --verbose is used in a pipe and no other files are processed.

References current_filename_printed, filename, files_pos, files_total, first_filename_printed, signals_block(), and signals_unblock().

Referenced by message_progress_start(), and message_progress_update().

void message_progress_start ( lzma_stream strm,
const char *  filename,
uint64_t  in_size 
)

Start progress info handling.

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.
filename Name of the input file. stdin_filename is handled specially.
in_size Size of the input file, or zero if unknown.

References current_filename_printed, expected_in_size, filename, files_pos, my_time(), print_filename(), progress_automatic, progress_started, start_time, V_VERBOSE, and verbosity.

Referenced by coder_run().

static const char* progress_percentage ( uint64_t  in_pos,
bool  final 
) [static]

Make the string indicating completion percentage.

References expected_in_size.

Referenced by message_progress_update().

static const char* progress_sizes ( uint64_t  compressed_pos,
uint64_t  uncompressed_pos,
bool  final 
) [static]

Make the string containing the amount of input processed, amount of output produced, and the compression ratio.

Referenced by message_progress_update().

static const char* progress_speed ( uint64_t  uncompressed_pos,
uint64_t  elapsed 
) [static]

Make the string containing the processing speed of uncompressed data.

Referenced by message_progress_update().

static const char* progress_time ( uint64_t  useconds  )  [static]

Make a string indicating elapsed or remaining time. The format is either M:SS or H:MM:SS depending on if the time is an hour or more.

Referenced by progress_remaining().

static const char* progress_remaining ( uint64_t  in_pos,
uint64_t  elapsed 
) [static]

Make the string to contain the estimated remaining time, or if the amount of input isn't known, how much time has elapsed.

References expected_in_size, and progress_time().

Referenced by message_progress_update().

static uint64_t progress_elapsed ( void   )  [static]

Calculate the elapsed time as microseconds.

References my_time(), and start_time.

Referenced by message_progress_update().

static void progress_pos ( uint64_t *  in_pos,
uint64_t *  compressed_pos,
uint64_t *  uncompressed_pos 
) [static]

Get information about position in the stream. This is currently simple, but it will become more complicated once we have multithreading support.

References opt_mode, lzma_stream::total_in, and lzma_stream::total_out.

Referenced by 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 print_filename(), progress_active, progress_automatic, progress_elapsed(), progress_percentage(), progress_pos(), progress_remaining(), progress_sizes(), progress_speed(), signals_block(), signals_unblock(), V_VERBOSE, and verbosity.

Referenced by coder_normal(), and coder_passthru().

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.

References progress_started.

Referenced by coder_run().

void message_bug ( void   ) 

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

References message_fatal().

void message_signal_handler ( void   ) 

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

References message_fatal().

Referenced by message_init(), and signals_init().

const char* message_strm ( lzma_ret  code  ) 
void message_filters ( enum message_verbosity  v,
const lzma_filter filters 
)
void message_try_help ( void   ) 

Print a message that user should try --help.

References message(), and V_WARNING.

void message_memlimit ( void   ) 

Print the memory usage limit and exit.

References hardware_memlimit_get(), uint64_to_str(), V_SILENT, and verbosity.

void message_version ( void   ) 

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

References LZMA_VERSION, lzma_version_number(), lzma_version_string(), LZMA_VERSION_STRING, V_SILENT, and verbosity.

void message_help ( bool  long_help  ) 

Variable Documentation

unsigned int files_pos = 0 [static]

Number of the current file.

Referenced by message_progress_start(), and print_filename().

unsigned int files_total [static]

Total number of input files; zero if unknown.

Referenced by message_set_files(), and print_filename().

enum message_verbosity verbosity = V_WARNING [static]
const char* filename [static]

Filename which we will print with the verbose messages.

Referenced by message_progress_start(), and print_filename().

bool first_filename_printed = false [static]

True once the a filename has been printed to stderr as part of progress message. If automatic progress updating isn't enabled, this becomes true after the first progress message has been printed due to user sending SIGINFO, SIGUSR1, or SIGALRM. Once this variable is true, we will print an empty line before the next filename to make the output more readable.

Referenced by print_filename().

bool current_filename_printed = false [static]

This is set to true when we have printed the current filename to stderr as part of a progress message. This variable is useful only if not updating progress automatically: if user sends many SIGINFO, SIGUSR1, or SIGALRM signals, we won't print the name of the same file multiple times.

Referenced by message_progress_start(), and print_filename().

bool progress_automatic [static]

True if we should print progress indicator and update it automatically if also verbose >= V_VERBOSE.

Referenced by message_init(), message_progress_start(), and message_progress_update().

bool progress_started = false [static]

True if message_progress_start() has been called but message_progress_end() hasn't been called yet.

Referenced by message_progress_end(), and message_progress_start().

bool progress_active = false [static]

This is true when a progress message was printed and the cursor is still on the same line with the progress message. In that case, a newline has to be printed before any error messages.

Referenced by message_progress_update().

Pointer to lzma_stream used to do the encoding or decoding.

uint64_t expected_in_size [static]

Expected size of the input stream is needed to show completion percentage and estimate remaining time.

Referenced by message_progress_start(), progress_percentage(), and progress_remaining().

uint64_t start_time [static]

Time when we started processing the file.

Referenced by message_progress_start(), and progress_elapsed().

bool progress_needs_updating = false [static]

This is true when progress message printing is wanted. Using the same variable name as above to avoid some ifdefs.

uint64_t progress_next_update [static]

Elapsed time when the next progress message update should be done.


Generated on Mon Dec 21 22:54:41 2009 for XZ Utils by  doxygen 1.6.1