OSF DCE Application Development Guide--Core Components

DCE Application Messaging
All that remains now is to create a simple C program that calls a DCE messaging routine
to output the ‘‘Hello World’’ message.
3.2.1.3 Program Source
The complete source code for hello.c is as follows:
#include <dce/dce_svc.h>
#include "dcehelmsg.h"
int
main(
int argc,
char *argv[])
{
dce_printf(hello_msg);
}
To build the application, you simply
Process the hel.sams file with the sams command.
Build and link hello from the following modules:
dcehelmsg.c
hello.c
When executed, the program will print the following:
Hello World
This is the text of the hello_msg message as defined in the hel.sams file.
3.2.1.4 DCE Messaging and Message Catalogs
The reader may be wondering why, in the previous example, it was not necessary to
explicitly open the message catalog before making the call to retrieve and print the
message itself. The answer is that dce_printf( ) takes care of this step implicitly. It is
able to find the message catalog because the catalog’s name is generated from the
component field in the first part of the sams file. Of course, for this to work, the
message catalog must be installed in the correct system-defined location before the
application is run.
An application may even dispense with the use of installed message catalogs altogether,
and use ‘‘in-memory’’ message tables instead. The necessary code to declare the sams
124245 Tandem Computers Incorporated 35