[106af12] | 1 | /* message.h |
---|
[9af1d7a] | 2 | * Function prototypes for message.c |
---|
[6cc96a9] | 3 | * Copyright (C) 1998-2024 Olly Betts |
---|
[846746e] | 4 | * |
---|
[89231c4] | 5 | * This program is free software; you can redistribute it and/or modify |
---|
| 6 | * it under the terms of the GNU General Public License as published by |
---|
| 7 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 8 | * (at your option) any later version. |
---|
[846746e] | 9 | * |
---|
| 10 | * This program is distributed in the hope that it will be useful, |
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[89231c4] | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | * GNU General Public License for more details. |
---|
[846746e] | 14 | * |
---|
[89231c4] | 15 | * You should have received a copy of the GNU General Public License |
---|
| 16 | * along with this program; if not, write to the Free Software |
---|
[ecbc6c18] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[9af1d7a] | 18 | */ |
---|
| 19 | |
---|
| 20 | #ifndef MESSAGE_H /* only include once */ |
---|
| 21 | #define MESSAGE_H |
---|
| 22 | |
---|
[8df22e9] | 23 | #ifdef __cplusplus |
---|
| 24 | extern "C" { |
---|
| 25 | #endif |
---|
| 26 | |
---|
[7f94ee7] | 27 | #include <stdarg.h> |
---|
| 28 | |
---|
[7dbc68f] | 29 | #include "filename.h" |
---|
[9af1d7a] | 30 | |
---|
[a420b49] | 31 | #define STDERR stdout |
---|
| 32 | |
---|
[f8e03f3] | 33 | #define CHARSET_BAD -1 |
---|
| 34 | #define CHARSET_USASCII 0 |
---|
| 35 | #define CHARSET_ISO_8859_1 1 |
---|
| 36 | #define CHARSET_DOSCP850 2 |
---|
| 37 | #define CHARSET_UTF8 4 |
---|
| 38 | #define CHARSET_WINCP1252 5 |
---|
| 39 | #define CHARSET_ISO_8859_15 6 |
---|
[f0a0b05] | 40 | #define CHARSET_ISO_8859_2 8 |
---|
[4fa44e7] | 41 | #define CHARSET_WINCP1250 9 |
---|
[6a4871e] | 42 | |
---|
[25ab06b] | 43 | extern int msg_warnings; /* keep track of how many warnings we've given */ |
---|
| 44 | extern int msg_errors; /* and how many (non-fatal) errors */ |
---|
[a2f9d5c] | 45 | |
---|
[cf54765] | 46 | /* The language code - e.g. "en_GB" */ |
---|
[25ab06b] | 47 | extern const char *msg_lang; |
---|
[cf54765] | 48 | /* If the language code has a country specific qualification, then this will |
---|
| 49 | * be just the language code. Otherwise it's NULL. e.g. "en" */ |
---|
[c0a9908] | 50 | extern const char *msg_lang2; |
---|
[f2a6ce4] | 51 | |
---|
[b39e24a] | 52 | void msg_init(char *const *argv); |
---|
[9af1d7a] | 53 | |
---|
[25ab06b] | 54 | const char *msg_cfgpth(void); |
---|
[b88b171] | 55 | const char *msg_exepth(void); |
---|
[bdfe97f] | 56 | const char *msg_appname(void); |
---|
[9af1d7a] | 57 | |
---|
[c8fcf66] | 58 | /* Return the message string corresponding to number en */ |
---|
[25ab06b] | 59 | const char *msg(int en); |
---|
[a420b49] | 60 | |
---|
[37d6b84] | 61 | /* These need to fit within DIAG_SEVERITY_MASK defined in datain.h. */ |
---|
| 62 | #define DIAG_INFO 0x00 |
---|
| 63 | #define DIAG_WARN 0x01 |
---|
| 64 | #define DIAG_ERR 0x02 |
---|
| 65 | #define DIAG_FATAL 0x03 |
---|
| 66 | |
---|
[da96015] | 67 | void v_report(int severity, const char *fnm, int line, int col, int en, va_list ap); |
---|
[a420b49] | 68 | |
---|
[37d6b84] | 69 | void diag(int severity, int en, ...); |
---|
| 70 | |
---|
| 71 | #define information(...) diag(DIAG_INFO, __VA_ARGS__) |
---|
| 72 | #define warning(...) diag(DIAG_WARN, __VA_ARGS__) |
---|
| 73 | #define error(...) diag(DIAG_ERR, __VA_ARGS__) |
---|
| 74 | #define fatalerror(...) diag(DIAG_FATAL, __VA_ARGS__) |
---|
| 75 | |
---|
| 76 | void diag_in_file(int severity, const char *fnm, int line, int en, ...); |
---|
[9af1d7a] | 77 | |
---|
[37d6b84] | 78 | #define information_in_file(...) diag_in_file(DIAG_INFO, __VA_ARGS__) |
---|
| 79 | #define warning_in_file(...) diag_in_file(DIAG_WARN, __VA_ARGS__) |
---|
| 80 | #define error_in_file(...) diag_in_file(DIAG_ERR, __VA_ARGS__) |
---|
| 81 | #define fatalerror_in_file(...) diag_in_file(DIAG_FATAL, __VA_ARGS__) |
---|
[9af1d7a] | 82 | |
---|
[a420b49] | 83 | int select_charset(int charset_code); |
---|
[9af1d7a] | 84 | |
---|
[8df22e9] | 85 | #ifdef __cplusplus |
---|
| 86 | } |
---|
| 87 | #endif |
---|
| 88 | |
---|
[9990aab] | 89 | /* Define MSG_SETUP_PROJ_SEARCH_PATH before including this header to enable the |
---|
| 90 | * hooks to setup proj's search path to be relative to the executable if this |
---|
| 91 | * is a relocatable install. |
---|
| 92 | */ |
---|
| 93 | #ifdef MSG_SETUP_PROJ_SEARCH_PATH |
---|
| 94 | /* We only need this on these platforms. */ |
---|
| 95 | # if OS_WIN32 |
---|
| 96 | # include <proj.h> |
---|
| 97 | # define msg_init(ARGV) do {\ |
---|
| 98 | (msg_init)(ARGV); \ |
---|
[6cc96a9] | 99 | const char* msg_init_proj_path = use_path(msg_cfgpth(), "proj");\ |
---|
[9990aab] | 100 | proj_context_set_search_paths(PJ_DEFAULT_CTX, 1, &msg_init_proj_path);\ |
---|
| 101 | } while (0) |
---|
| 102 | # endif |
---|
| 103 | #endif |
---|
| 104 | |
---|
[9af1d7a] | 105 | #endif /* MESSAGE_H */ |
---|