1 /************************************************************************
2 **
3 ** @file vsysexits.h
4 ** @author Roman Telezhynskyi <dismine(at)gmail.com>
5 ** @date 28 9, 2015
6 **
7 ** @brief
8 ** @copyright
9 ** This source code is part of the Valentina project, a pattern making
10 ** program, whose allow create and modeling patterns of clothing.
11 ** Copyright (C) 2015 Valentina project
12 ** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
13 **
14 ** Valentina is free software: you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License as published by
16 ** the Free Software Foundation, either version 3 of the License, or
17 ** (at your option) any later version.
18 **
19 ** Valentina is distributed in the hope that it will be useful,
20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ** GNU General Public License for more details.
23 **
24 ** You should have received a copy of the GNU General Public License
25 ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
26 **
27 *************************************************************************/
28
29 #ifndef VSYSEXITS_H
30 #define VSYSEXITS_H
31
32 #include <QTextStream>
33
34 #ifdef __GNUC__
35 #define V_UNUSED __attribute__ ((unused))
36 #else
37 #define V_UNUSED
38 #endif
39
40 static const auto V_UNUSED V_EX_OK = 0; /*Indicate the successful exit.*/
41
42 static const auto V_UNUSED V_EX_USAGE = 64; /*The command was used incorrectly, e.g., with the wrong number of
43 arguments, a bad flag, a bad syntax in a parameter, or whatever.*/
44
45 static const auto V_UNUSED V_EX_DATAERR = 65; /*The input data was incorrect in some way. This should only be
46 used for user's data and not system files.*/
47
48 static const auto V_UNUSED V_EX_NOINPUT = 66; /*An input file (not a system file) did not exist or was not
49 readable.*/
50
51 static const auto V_UNUSED V_EX_UNAVAILABLE = 69; /*A service is unavailable. This can occur if a support program or
52 file does not exist. This can also be used as a catchall message
53 when something you wanted to do doesn't work, but you don't know
54 why.*/
55
56 static const auto V_UNUSED V_EX_SOFTWARE = 70; /*An internal software error has been detected. This should be
57 limited to nonoperating operating system related errors as
58 possible.*/
59
60 static const auto V_UNUSED V_EX_OSERR = 71; /*An operating system error has been detected. This is intended to be
61 used for such things as ``cannot fork'', ``cannot create pipe'', or
62 the like. It includes things like getuid returning a user that does
63 not exist in the passwd file.*/
64
65 static const auto V_UNUSED V_EX_OSFILE = 72; /*Some system file (e.g., /etc/passwd, /var/run/utmp, etc.) does not
66 exist, cannot be opened, or has some sort of error (e.g., syntax
67 error).*/
68
69 static const auto V_UNUSED V_EX_CANTCREAT = 73; /*A (user specified) output file cannot be created.*/
70
71 static const auto V_UNUSED V_EX_IOERR = 74; /*An error occurred while doing I/O on some file.*/
72
73 static const auto V_UNUSED V_EX_NOPERM = 77; /*You did not have sufficient permission to perform the operation.
74 This is not intended for file system problems, which should use
75 EX_NOINPUT or EX_CANTCREAT, but rather for higher level
76 permissions.*/
77
78 static const auto V_UNUSED V_EX_CONFIG = 78; /*Something was found in an unconfigured or misconfigured state.*/
79
80 #undef V_UNUSED
81
82 //---------------------------------------------------------------------------------------------------------------------
vStdErr()83 inline QTextStream& vStdErr()
84 {
85 static QTextStream ts(stderr, QIODevice::Unbuffered | QIODevice::WriteOnly);
86 ts.setCodec("UTF-8");
87 return ts;
88 }
89
90 //---------------------------------------------------------------------------------------------------------------------
vStdOut()91 inline QTextStream& vStdOut()
92 {
93 static QTextStream ts(stdout, QIODevice::Unbuffered | QIODevice::WriteOnly);
94 ts.setCodec("UTF-8");
95 return ts;
96 }
97
98 #endif // VSYSEXITS_H
99