2 * Copyright (c) 1999-2005 Alfredo K. Kojima, Alban G. Hertroys
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 extern struct DAContext
*_daContext
;
33 void _message(const char *label
, const char *fmt
, va_list args
);
40 DASetExpectedVersion(unsigned long expectedVersion
)
42 DAExpectedVersion
= expectedVersion
;
44 if (expectedVersion
> DA_VERSION
)
45 DAWarning("Version of libdockapp (%u) is older than "
46 "version expected (%u)",
53 DAGetDisplay(char *d
, ...)
55 /* Be backward compatible */
56 if (DAExpectedVersion
< 20030126) {
62 argc
= va_arg(ap
, int);
63 argv
= va_arg(ap
, char **);
66 DAOpenDisplay(d
, argc
, argv
);
68 DAWarning("Expected version of libdockapp is not set.");
69 DAWarning("Obsolete call to DAGetDisplay().");
79 DASetDisplay(Display
*display
)
93 DASetWindow(Window window
)
107 DASetLeader(Window leader
)
114 DAGetIconWindow(void)
121 DASetIconWindow(Window icon_win
)
135 DASetDepth(int depth
)
149 DASetVisual(Visual
*visual
)
155 DAWarning(const char *fmt
, ...)
160 _message("Warning", fmt
, args
);
165 DAError(const char *fmt
, ...)
170 _message("Error", fmt
, args
);
181 _message(const char *label
, const char *fmt
, va_list args
)
185 if (_daContext
->programName
!= NULL
) {
186 /* put default string in front of message, add newline */
187 w_fmt
= malloc((strlen(_daContext
->programName
) + strlen(fmt
) + 13) * sizeof(char));
188 sprintf(w_fmt
, "%s: %s: %s\n", _daContext
->programName
, label
, fmt
);
190 w_fmt
= malloc((strlen(fmt
) + 1) * sizeof(char));
191 sprintf(w_fmt
, "%s\n", fmt
);
194 /* print the message */
195 vfprintf(stderr
, w_fmt
, args
);
200 debug(const char *fmt
, ...)
206 _message("debug", fmt
, args
);