]> icculus.org git repositories - icculus/xz.git/blob - src/xz/message.h
Some xz man changes.
[icculus/xz.git] / src / xz / message.h
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       message.h
4 /// \brief      Printing messages to stderr
5 //
6 //  Author:     Lasse Collin
7 //
8 //  This file has been put into the public domain.
9 //  You can do whatever you want with this file.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12
13 /// Verbosity levels
14 enum message_verbosity {
15         V_SILENT,   ///< No messages
16         V_ERROR,    ///< Only error messages
17         V_WARNING,  ///< Errors and warnings
18         V_VERBOSE,  ///< Errors, warnings, and verbose statistics
19         V_DEBUG,    ///< Debugging, FIXME remove?
20 };
21
22
23 /// \brief      Initializes the message functions
24 ///
25 /// \param      argv0       Name of the program i.e. argv[0] from main()
26 /// \param      verbosity   Verbosity level
27 ///
28 /// If an error occurs, this function doesn't return.
29 ///
30 extern void message_init(const char *argv0);
31
32
33 /// Increase verbosity level by one step unless it was at maximum.
34 extern void message_verbosity_increase(void);
35
36 /// Decrease verbosity level by one step unless it was at minimum.
37 extern void message_verbosity_decrease(void);
38
39
40 /// Set the total number of files to be processed (stdin is counted as a file
41 /// here). The default is one.
42 extern void message_set_files(unsigned int files);
43
44
45 /// \brief      Print a message if verbosity level is at least "verbosity"
46 ///
47 /// This doesn't touch the exit status.
48 extern void message(enum message_verbosity verbosity, const char *fmt, ...)
49                 lzma_attribute((format(printf, 2, 3)));
50
51
52 /// \brief      Prints a warning and possibly sets exit status
53 ///
54 /// The message is printed only if verbosity level is at least V_WARNING.
55 /// The exit status is set to WARNING unless it was already at ERROR.
56 extern void message_warning(const char *fmt, ...)
57                 lzma_attribute((format(printf, 1, 2)));
58
59
60 /// \brief      Prints an error message and sets exit status
61 ///
62 /// The message is printed only if verbosity level is at least V_ERROR.
63 /// The exit status is set to ERROR.
64 extern void message_error(const char *fmt, ...)
65                 lzma_attribute((format(printf, 1, 2)));
66
67
68 /// \brief      Prints an error message and exits with EXIT_ERROR
69 ///
70 /// The message is printed only if verbosity level is at least V_ERROR.
71 extern void message_fatal(const char *fmt, ...)
72                 lzma_attribute((format(printf, 1, 2)))
73                 lzma_attribute((noreturn));
74
75
76 /// Print an error message that an internal error occurred and exit with
77 /// EXIT_ERROR.
78 extern void message_bug(void) lzma_attribute((noreturn));
79
80
81 /// Print a message that establishing signal handlers failed, and exit with
82 /// exit status ERROR.
83 extern void message_signal_handler(void) lzma_attribute((noreturn));
84
85
86 /// Convert lzma_ret to a string.
87 extern const char *message_strm(lzma_ret code);
88
89
90 /// Print the filter chain.
91 extern void message_filters(
92                 enum message_verbosity v, const lzma_filter *filters);
93
94
95 /// Print a message that user should try --help.
96 extern void message_try_help(void);
97
98
99 /// Prints the version number to stdout and exits with exit status SUCCESS.
100 extern void message_version(void) lzma_attribute((noreturn));
101
102
103 /// Print the help message.
104 extern void message_help(bool long_help) lzma_attribute((noreturn));
105
106
107 /// \brief      Start progress info handling
108 ///
109 /// This must be paired with a call to message_progress_end() before the
110 /// given *strm becomes invalid.
111 ///
112 /// \param      strm      Pointer to lzma_stream used for the coding.
113 /// \param      filename  Name of the input file. stdin_filename is
114 ///                       handled specially.
115 /// \param      in_size   Size of the input file, or zero if unknown.
116 ///
117 extern void message_progress_start(
118                 lzma_stream *strm, const char *filename, uint64_t in_size);
119
120
121 /// Update the progress info if in verbose mode and enough time has passed
122 /// since the previous update. This can be called only when
123 /// message_progress_start() has already been used.
124 extern void message_progress_update(void);
125
126
127 /// \brief      Finishes the progress message if we were in verbose mode
128 ///
129 /// \param      finished    True if the whole stream was successfully coded
130 ///                         and output written to the output stream.
131 ///
132 extern void message_progress_end(bool finished);