OSF DCE Application Development Guide--Core Components

OSF DCE Application Development Guide—Core Components
#include <dce/dce.h>
#include <dce/dce_msg.h>
#include "dcehelmsg.h"
unsigned char *my_msg;
unsigned32 status;
<. . .>
my_msg = dce_msg_get_default_msg(hello_msg, &status);
printf("Message is: %s\n", my_msg);
Note that, in order for this call to be successful,
dce_msg_define_msg_table( ) must first have been called to set the
table up in memory. For an example of how this is done, see the
following section.
3.3.3 Message Table Routines
The two routines in this group are intended to be used to perform manipulations on the
in-memory message table.
The in-memory table is implemented with code generated by sams and contained in the
dce cmpmsg.c module (where cmp is the component name of the application, as specified
in the component field in part I of the sams file). This file must then be compiled and
linked with the application, and dce_msg_define_msg_table( ) is called at runtime to set
up the table.
Note that, even if an in-memory table is defined, the DCE messaging routines still will
always attempt first to extract the specified message from the message catalog, and only
if unsuccessful will they revert to the in-memory table. The exception to this rule is
dce_msg_get_default_msg( ), which always attempts to retrieve the in-memory message
only.
dce_msg_define_msg_table( )
Installs a default in-memory message table accessible to DCE messaging
routines. This routine is intended to be used by programs that load all
messages from a catalog into memory in order to avoid file access
overhead on message retrieval.
The following code fragment shows how dce_msg_define_msg_table()
might be called to set up an in-memory message table consisting of the
contents of the messages defined in hel.sams earlier in this chapter:
#include <dce/dce.h>
#include <dce/dce_msg.h>
#include "dcehelmsg.h"
unsigned32 status;
3 14 Tandem Computers Incorporated 124245