2
* RabbitSign - Tools for signing TI graphing calculator software
3
* Copyright (C) 2009 Benjamin Moody
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License as
7
* published by the Free Software Foundation; either version 3 of the
8
* License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
29
# ifdef HAVE_STRINGS_H
34
#include "rabbitsign.h"
37
static const char* progname;
39
static RSMessageFunc errorfunc, messagefunc;
40
static void *errorfuncdata, *messagefuncdata;
42
void rs_set_progname(s)
48
void rs_set_verbose(v)
54
void rs_set_error_func(RSMessageFunc func, void* data)
60
void rs_set_message_func(RSMessageFunc func, void* data)
63
messagefuncdata = data;
66
static void print_message(const RSKey* key, const RSProgram* prgm,
69
if (prgm && prgm->filename)
70
fprintf(stderr, "%s: ", prgm->filename);
71
else if (key && key->filename)
72
fprintf(stderr, "%s: ", key->filename);
74
fprintf(stderr, "%s: ", progname);
79
/* Display a critical error */
80
void rs_error(const RSKey* key, const RSProgram* prgm, const char* fmt, ...)
86
strcpy(msg, "error: ");
87
rs_vsnprintf(msg + 7, sizeof(msg) - 7, fmt, ap);
91
(*errorfunc)(key, prgm, msg, errorfuncdata);
93
print_message(key, prgm, msg);
96
/* Display a warning message */
97
void rs_warning(const RSKey* key, const RSProgram* prgm, const char* fmt, ...)
103
strcpy(msg, "warning: ");
104
rs_vsnprintf(msg + 9, sizeof(msg) - 9, fmt, ap);
108
(*errorfunc)(key, prgm, msg, errorfuncdata);
110
print_message(key, prgm, msg);
113
/* Display an informative message */
114
void rs_message(int level, const RSKey* key, const RSProgram* prgm,
115
const char* fmt, ...)
124
rs_vsnprintf(msg, sizeof(msg), fmt, ap);
128
(*messagefunc)(key, prgm, msg, messagefuncdata);
130
print_message(key, prgm, msg);