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.
31 extern char *_WINGS_progname
;
35 void __wmessage(int type
, void *extra
, const char *msg
, ...)
41 /* message format: <wings_progname>: <qualifier>: <message>[: <extra info>]"\n" */
42 snprintf(buf
, sizeof(buf
), "%s: ", _WINGS_progname
? _WINGS_progname
: "WINGs");
45 case WMESSAGE_TYPE_WARNING
:
46 snprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1,
48 vsnprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1,
51 case WMESSAGE_TYPE_FATAL
:
52 snprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1,
54 vsnprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1,
57 case WMESSAGE_TYPE_WSYSERROR
:
58 case WMESSAGE_TYPE_WSYSERRORWITHCODE
:
59 snprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1,
61 vsnprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1,
63 snprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1,
64 ": %s", type
== WMESSAGE_TYPE_WSYSERROR
?
65 strerror(errno
) : strerror(*(int *)extra
));
67 case WMESSAGE_TYPE_MESSAGE
:
70 snprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1, ": ");
71 vsnprintf(buf
+ strlen(buf
), sizeof(buf
) - strlen(buf
) - 1, msg
, args
);
75 strncat(buf
+ strlen(buf
), "\n", sizeof(buf
) - strlen(buf
));