2
* Window Maker miscelaneous function library
4
* Copyright (c) 1997-2003 Alfredo K. Kojima
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30
extern char *_WINGS_progname;
36
/*********************************************************************
37
* Returns the system error message associated with error code 'errnum'
38
*********************************************************************/
42
#if defined(HAVE_STRERROR)
43
return strerror(errnum);
44
#elif !defined(HAVE_STRERROR) && defined(BSD)
45
extern int errno, sys_nerr;
47
extern char *sys_errlist[];
49
static char buf[] = "Unknown error 12345678901234567890";
52
return sys_errlist[errnum];
54
snprintf(buf, sizeof(buf), _("Unknown error %d"), errnum);
56
#else /* no strerror() and no sys_errlist[] */
57
static char buf[] = "Error 12345678901234567890";
59
snprintf(buf, sizeof(buf), _("Error %d"), errnum);
65
/*********************************************************************
66
* Prints a message with variable arguments
68
* msg - message to print with optional formatting
69
* ... - arguments to use on formatting
70
*********************************************************************/
72
wmessage(const char *msg, ...)
79
vsnprintf(buf, MAXLINE-3, msg, args);
82
fputs(_WINGS_progname ? _WINGS_progname : "WINGs", stderr);
92
/*********************************************************************
93
* Prints a warning message with variable arguments
95
* msg - message to print with optional formatting
96
* ... - arguments to use on formatting
97
*********************************************************************/
99
wwarning(const char *msg, ...)
106
vsnprintf(buf, MAXLINE-3, msg, args);
109
fputs(_WINGS_progname ? _WINGS_progname : "WINGs", stderr);
110
fputs(_(" warning: "),stderr);
119
/**************************************************************************
120
* Prints a fatal error message with variable arguments and terminates
122
* msg - message to print with optional formatting
123
* ... - arguments to use on formatting
124
**************************************************************************/
126
wfatal(const char *msg, ...)
133
vsnprintf(buf, MAXLINE-3, msg, args);
136
fputs(_WINGS_progname ? _WINGS_progname : "WINGs", stderr);
137
fputs(_(" fatal error: "),stderr);
146
/*********************************************************************
147
* Prints a system error message with variable arguments
149
* msg - message to print with optional formatting
150
* ... - arguments to use on formatting
151
*********************************************************************/
153
wsyserror(const char *msg, ...)
160
vsnprintf(buf, MAXLINE-3, msg, args);
162
fputs(_WINGS_progname ? _WINGS_progname : "WINGs", stderr);
163
fputs(_(" error: "), stderr);
166
fputs(wstrerror(error), stderr);
174
/*********************************************************************
175
* Prints a system error message with variable arguments, being given
178
* error - the error code foe which to print the message
179
* msg - message to print with optional formatting
180
* ... - arguments to use on formatting
181
*********************************************************************/
183
wsyserrorwithcode(int error, const char *msg, ...)
189
vsnprintf(buf, MAXLINE-3, msg, args);
191
fputs(_WINGS_progname ? _WINGS_progname : "WINGs", stderr);
192
fputs(_(" error: "), stderr);
195
fputs(wstrerror(error), stderr);