OSF DCE Application Development Guide--Introduction and Style Guide

OSF DCE Application Development Guide—Introduction and Style Guide
Messages do not need to be hard-coded into applications
Message routing can be better controlled
The following routine shows how a server can report a status code returned from an API
routine:
void
print_server_error(
char *caller, /* Routine that received the error. */
error_status_t status) /* Status we want to print the message for. */
{
dce_error_string_t error_string;
int print_status;
dce_error_inq_text(status, error_string, &print_status);
dce_svc_printf(SERVER_ERROR_MSG, caller, error_string);
}
The dce_error_inq_text() routine looks up the status number in a standard table and
returns a string of text that describes the error status. The serviceability routine
dce_svc_printf() then displays the message, logs it to one or more files, or both.
The following code shows some typical tasks when setting up the server for
serviceability:
/* The following calls set up default routing of serviceability */
/* messages. */
for (i = 0, route_error = FALSE; (i < MAX_DEFAULT_ROUTES)
&& (!route_error); i++)
{
printf("Setting default route %s ...\n", default_routes[i]);
dce_svc_routing(default_routes[i], &status);
if (status != svc_s_ok)
{
print_server_error("dce_svc_routing(default_routes[i])", status);
}
}
/* Get serviceability handle... */
smp_svc_handle = dce_svc_register(smp_svc_table,
(idl_char*)"smp", &status);
if (status != error_status_ok)
{
print_server_error("dce_svc_register()", status);
exit(1);
}
/* Set the default serviceability debug level and route... */
dce_svc_debug_routing(default_debug_route, &status);
/* Set up in-memory serviceability message table... */
114 Tandem Computers Incorporated 124246