3 Copyright 1993, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
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 OPEN GROUP 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.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
28 * Author: Ralph Mor, X Consortium
34 #include <X11/SM/SMlib.h>
41 * Default Smc error handler.
45 _SmcDefaultErrorHandler(SmcConn smcConn, Bool swap, int offendingMinorOpcode,
46 unsigned long offendingSequence, int errorClass,
47 int severity, SmPointer values)
49 char *pData = (char *) values;
52 switch (offendingMinorOpcode)
54 case SM_RegisterClient:
55 str = "RegisterClient";
57 case SM_InteractRequest:
58 str = "InteractRequest";
63 case SM_SaveYourselfDone:
64 str = "SaveYourselfDone";
66 case SM_CloseConnection:
67 str = "CloseConnection";
69 case SM_SetProperties:
70 str = "SetProperties";
72 case SM_GetProperties:
73 str = "GetProperties";
79 fprintf (stderr, "\n");
81 fprintf (stderr, "XSMP error: Offending minor opcode = %d (%s)\n",
82 offendingMinorOpcode, str);
84 fprintf (stderr, " Offending sequence number = %ld\n",
105 fprintf (stderr, " Error class = %s\n", str);
107 if (severity == IceCanContinue)
109 else if (severity == IceFatalToProtocol)
110 str = "FatalToProtocol";
111 else if (severity == IceFatalToConnection)
112 str = "FatalToConnection";
116 fprintf (stderr, " Severity = %s\n", str);
122 int offset, length, val;
124 EXTRACT_CARD32 (pData, swap, offset);
125 EXTRACT_CARD32 (pData, swap, length);
128 " BadValue Offset = %d\n", offset);
130 " BadValue Length = %d\n", length);
136 else if (length == 2)
138 EXTRACT_CARD16 (pData, swap, val);
142 EXTRACT_CARD32 (pData, swap, val);
146 " BadValue = %d\n", val);
155 fprintf (stderr, "\n");
157 if (severity != IceCanContinue)
164 * Default Sms error handler.
168 _SmsDefaultErrorHandler(SmsConn smsConn, Bool swap, int offendingMinorOpcode,
169 unsigned long offendingSequence, int errorClass,
170 int severity, SmPointer values)
172 char *pData = (char *) values;
175 switch (offendingMinorOpcode)
177 case SM_SaveYourself:
178 str = "SaveYourself";
186 case SM_ShutdownCancelled:
187 str = "ShutdownCancelled";
193 fprintf (stderr, "\n");
195 fprintf (stderr, "XSMP error: Offending minor opcode = %d (%s)\n",
196 offendingMinorOpcode, str);
198 fprintf (stderr, " Offending sequence number = %ld\n",
219 fprintf (stderr, " Error class = %s\n", str);
221 if (severity == IceCanContinue)
223 else if (severity == IceFatalToProtocol)
224 str = "FatalToProtocol";
225 else if (severity == IceFatalToConnection)
226 str = "FatalToConnection";
230 fprintf (stderr, " Severity = %s\n", str);
236 int offset, length, val;
238 EXTRACT_CARD32 (pData, swap, offset);
239 EXTRACT_CARD32 (pData, swap, length);
242 " BadValue Offset = %d\n", offset);
244 " BadValue Length = %d\n", length);
250 else if (length == 2)
252 EXTRACT_CARD16 (pData, swap, val);
256 EXTRACT_CARD32 (pData, swap, val);
260 " BadValue = %d\n", val);
269 fprintf (stderr, "\n\n");
271 /* don't exit() - that would kill the SM - pretty devastating */
277 * This procedure sets the Smc error handler to be the specified
278 * routine. If NULL is passed in the default error handler is restored.
279 * The function's return value is the previous error handler.
283 SmcSetErrorHandler(SmcErrorHandler handler)
285 SmcErrorHandler oldHandler = _SmcErrorHandler;
288 _SmcErrorHandler = handler;
290 _SmcErrorHandler = _SmcDefaultErrorHandler;
298 * This procedure sets the Sms error handler to be the specified
299 * routine. If NULL is passed in the default error handler is restored.
300 * The function's return value is the previous error handler.
304 SmsSetErrorHandler(SmsErrorHandler handler)
306 SmsErrorHandler oldHandler = _SmsErrorHandler;
309 _SmsErrorHandler = handler;
311 _SmsErrorHandler = _SmsDefaultErrorHandler;