Name
XtAppGetErrorDatabaseText — obtain the error database text for an error or a warning.
Synopsis
void XtAppGetErrorDatabaseText(app_context, name, type, class, default, buffer_return, nbytes, database)
XtAppContext app_context;
String name, type, class;
String default;
String buffer_return;
int nbytes;
XrmDatabase database;
Arguments
app_context
Specifies the application context.
name, typeSpecifies the name and type that are concatenated to form the resource name of the error message.
classSpecifies the resource class of the error message.
defaultSpecifies the default message to use if an error database entry is not found.
buffer_return
Specifies the buffer into which the error message is to be returned.
nbytesSpecifies the size of the buffer in bytes.
databaseSpecifies the name of the alternative database to be used, or specifies NULL if the application’s database is to be used.
Description
Xt’s high-level error and warning message handlers use a resource-like database for storing messages. Messages are looked up by name and class, and the appropriate message retrieved from the database. A custom error message handler can obtain the error database text for an error or a warning by calling XtAppGetErrorDatabaseText.
XtAppGetErrorDatabaseText returns the appropriate message from the error database or returns the specified default message if one is not found in the error database.
On POSIX-based systems, the error database is usually stored in /usr/lib/X11/XtErrorDB. Custom error or warning messages should be appended to this file.
The address of the loaded database can be returned by a call to XtAppGetErrorDatabase (or XtGetErrorDatabase). Note that application-context-specific error handling is not implemented on many systems. Most implementations will have just one set of error handlers. If they are set for different application contexts, the one performed last will prevail.
Typical usage of XtAppGetErrorDatabaseText() is deep in the X Toolkit error handling code. See the code below (slightly modified for clarity) for use of this function from the Xt Intrinsics. The first four arguments to XtAppGetErrorDatabaseText() are just passed in from the XtErrorMsg() call in XtMalloc().
The XtMalloc() call assumes that the default error database (errorDB) has an error message for resource name allocError.malloc of class XtToolkitError. If not found, the default error message "Cannot perform malloc" will be used instead.
You do not need to use this function unless you are writing an Xt error message handler of your own.
void
XtErrorMsg(name, type, class, defaultp, params, num_params)
String name, type, class, defaultp;
String ∗params;
Cardinal ∗num_params;
char buffer[1000], message[1000];
XtGetErrorDatabaseText(name, type, class, defaultp, buffer, 1000);
/∗
∗ Need better solution here, perhaps use lower-level
∗ printf primitives?
∗/
if (num_params == NULL)
XtError(buffer);
else {
(void) sprintf(message, buffer, params[0], params[1],
params[2], params[3], params[4], params[5],
params[6], params[7], params[8], params[9]);
_XtDefaultError(message);
}
}
static void
_XtDefaultError(message)
String message;
{
extern void exit();
(void)fprintf(stderr, "X Toolkit Error: %s\n", message);
exit(1);
}
void
XtGetErrorDatabaseText(name, type, class, defaultp, buffer, nbytes)
register char ∗name, ∗type, ∗class;
char ∗defaultp;
char ∗buffer;
int nbytes;
{
XtAppGetErrorDatabaseText(_XtDefaultAppContext(),
name, type, class, defaultp, buffer, nbytes, NULL);
}
See Also
XtAppGetErrorDatabase(1), XtGetErrorDatabase(1), XtGetErrorDatabaseText(1),
XtErrorMsgHandler(2).