]> icculus.org git repositories - icculus/xz.git/blob - src/lzma/main.h
Oh well, big messy commit again. Some highlights:
[icculus/xz.git] / src / lzma / main.h
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       main.h
4 /// \brief      Miscellanous declarations
5 //
6 //  Copyright (C) 2008 Lasse Collin
7 //
8 //  This program is free software; you can redistribute it and/or
9 //  modify it under the terms of the GNU Lesser General Public
10 //  License as published by the Free Software Foundation; either
11 //  version 2.1 of the License, or (at your option) any later version.
12 //
13 //  This program is distributed in the hope that it will be useful,
14 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 //  Lesser General Public License for more details.
17 //
18 ///////////////////////////////////////////////////////////////////////////////
19
20 #ifndef MAIN_H
21 #define MAIN_H
22
23 /// Possible exit status values. These are the same as used by gzip and bzip2.
24 enum exit_status_type {
25         E_SUCCESS  = 0,
26         E_ERROR    = 1,
27         E_WARNING  = 2,
28 };
29
30
31 /// If this is true, we will clean up the possibly incomplete output file,
32 /// return to main() as soon as practical. That is, the code needs to poll
33 /// this variable in various places.
34 extern volatile sig_atomic_t user_abort;
35
36
37 /// Block the signals which don't have SA_RESTART and which would just set
38 /// user_abort to true. This is handy when we don't want to handle EINTR
39 /// and don't want SA_RESTART either.
40 extern void signals_block(void);
41
42
43 /// Unblock the signals blocked by signals_block().
44 extern void signals_unblock(void);
45
46
47 /// Sets the exit status after a warning or error has occurred. If new_status
48 /// is EX_WARNING and the old exit status was already EX_ERROR, the exit
49 /// status is not changed.
50 extern void set_exit_status(enum exit_status_type new_status);
51
52
53 /// Exits the program using the given status. This takes care of closing
54 /// stdin, stdout, and stderr and catches possible errors. If we had got
55 /// a signal, this function will raise it so that to the parent process it
56 /// appears that we were killed by the signal sent by the user.
57 extern void my_exit(enum exit_status_type status) lzma_attribute((noreturn));
58
59
60 #endif