1 #ifndef INCLUDED_TEXTS_H
2 #define INCLUDED_TEXTS_H
3 /* vim: set ts=8 sts=4 sw=4 tw=80 noet: */
4 /*======================================================================
5 Copyright (C) 2004,2005,2009,2013 Walter Doekes <walter+tthsum@wjd.nu>
6 This file is part of tthsum.
7 
8 tthsum is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 tthsum 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
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with tthsum.  If not, see <http://www.gnu.org/licenses/>.
20 ======================================================================*/
21 
22 /**
23  * Help and error texts for the tthsum application and the units that
24  * tthsum consists of. Using texts is entirely optional: unless you
25  * define USE_TEXTS, no tthsum unit will try to call any of these
26  * functions.
27  */
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32 
33 /**
34  * The texts by id. If messages are to be translated, only the texts unit will
35  * have to be modified.
36  */
37 enum text_id {
38     ERROR_FROM_OS = -1,
39     ERROR_FIRST = 0,
40     BASE32_INVALID_CHARACTER,
41     ESCAPE_INVALID_ESCAPE,
42     TEXTS_UNKNOWN_ERROR,
43     THEX_INVALID_BLOCK_SIZE,
44     TTHSUM_FILENAME_TOO_LARGE,
45     TTHSUM_LINE_CORRUPT,
46     TTHSUM_MISMATCHED_TTH,
47     UTF8_INVALID_UNICODE,
48     UTF8_INVALID_UTF8,
49     UTF8_OVERLONG_UTF8,
50     ERROR_LAST
51 };
52 
53 /**
54  * Set the last error: context is a short string specifying which function
55  * caused the error, error defines what the error was. Specify the error by
56  * text_id or ERROR_FROM_OS if you want to get the native OS-error message
57  * (from a library call).
58  */
59 void set_error(const char* context, int error);
60 
61 /**
62  * Get the set error as a descriptive message including the context.
63  */
64 const char* get_error();
65 
66 /**
67  * Get a specific text.
68  */
69 const char* get_text(enum text_id id);
70 
71 #ifdef __cplusplus
72 } /* extern "C" */
73 #endif /* __cplusplus */
74 
75 #endif /* INCLUDED_TEXTS_H */
76