OSF DCE Application Development Guide--Core Components
Using the DCE Serviceability Application Interface
hel_svc_handle = dce_svc_register(hel_svc_table, \
(idl_char*)"hel", &status);
if (status != svc_s_ok)
{
printf("dce_svc_register failed\n");
exit(1);
}
This call is the only initialization we need if we have installed our message catalog and
are willing to depend on the message(s) being extracted from there. However, if we wish
to have the messages available in program memory (and thus not depend on the catalog’s
being correctly installed), then we have to call dce_msg_define_msg_table( ) to
initialize the in-memory table, as follows:
#include <dce/dce_msg.h>
#include "dcehelmsg.h"
<. . .>
dce_msg_define_msg_table(hel_msg_table,
sizeof(hel_msg_table) / sizeof(hel_msg_table[0]),
&status);
if (status != svc_s_ok)
{
printf("dce_svc_define_msg_table failed\n");
exit(1);
}
Now we can call dce_svc_printf() to print the message, as follows:
#include "dcehelmac.h"
<. . .>
dce_svc_printf(HEL_S_HELLO_MSG);
Note the argument HEL_S_HELLO_MSG, which we did not define in the hel.sams file.
HEL_S_HELLO_MSG is, in fact, a macro that was generated by sams from our
definition for the hel_s_hello message, as you can see from the following code:
start
code hel_s_hello
subcomponent hel_s_main
attributes "svc_c_sev_notice | svc_c_route_stderr"
text "Hello World"
explanation "?"
action "None required."
end
The macro automatically generates the long argument list that must be passed to
dce_svc_printf() to get it to print the message. The code for this convenience macro is
124245 Tandem Computers Incorporated 4−9