### 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 cmp msg.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 topic (Defining the Message):

#include <dce/dce.h>

#include <dce/dce_msg.h>

#include "dcehelmsg.h"

unsigned32 status;

<. . .>

dce_msg_define_msg_table(hel_msg_table,

sizeof(hel_msg_table) / sizeof(hel_msg_table[0]),

&status);

dce_msg_translate_table( )
Makes a new copy of the specified in-memory message table (that is, updates the table with the contents of a message table, which has changed because of a change in locale).

Note that this routine will fail if the message catalog is not installed or if LANG is not properly set, since the update depends on accessing the contents of the message catalog (unlike the initial table setup, which is done from the code in the dce cmp msg.c file).

The following code fragment shows how dce_msg_translate_table( ) might be called to translate the in-memory table that was set up by the call to dce_msg_define_msg_table( ) in the previous example:

#include <dce/dce.h>

#include <dce/dce_msg.h>

#include <locale.h>

#include "dcehelmsg.h"

char *loc_return;

unsigned32 status;

<. . .>

loc_return = setlocale(LC_MESSAGES, "C");

dce_msg_translate_table(hel_msg_table,

sizeof(hel_msg_table) / sizeof(hel_msg_table[0]),

&status);

###