OSF DCE Application Development Guide--Core Components

OSF DCE Application Development Guide—Core Components
Both of the DCE message facilities use XPG4 message catalog files (see the X/Open
Portability Guide) to hold message text. The message catalogs are generated by a DCE
utility (called sams) during the application development process, and must be installed in
the correct platform-dependent location in order for the DCE messaging library routines
to be able to find them (and, consequently, the messages) at runtime.
The main purpose of message catalogs is to allow programs’ message text to be stored
and organized (separately from the programs themselves) in a culture- or nationality-
specific way. This enables programs to switch their I/O styles and contents to the form
appropriate to the geographical location (locale) they are running in, simply by using the
appropriate catalog. Thus, it is essential to compose catalogs in such a way that each one
contains message text appropriate only to a single (same) locale.
Questions such as the proper use of locales, proper language style for messages, where
catalogs should be installed, and so on, all fall under the broad topic of
internationalization, and are not discussed in this chapter. The other important aspect of
internationalization, namely character and code set compatibility, is discussed in detail
in Chapter 15.
3.2 DCE Messaging Interface Usage
Use of the DCE messaging API is very straightforward. In the application code itself, all
that is usually required is simply to call one of the output routines, passing it the ID of
the message to be output. The messages themselves must first be defined in a text file
which must then be processed by the DCE sams (symbols and message strings) utility,
which generates the message catalog file along with other C source files that contain
code necessary to facilitate the additional layer of functionality that DCE has added to
the XPG4 message catalog mechanism.
3.2.1 ASimple DCE Messaging Example
The following subsections describe all the steps and code necessary to compile an
application that uses the DCE messaging API to print the familiar ‘‘Hello World’’
message.
3.2.1.1 Defining the Message
For our example, we will define a sams file with the minimum contents necessary to print
the one brief message we want to display. (Additional information on the use of sams
can be found in the sams(1dce) reference page, which contains comprehensive
descriptions of all aspects of the utility.)
3 2 Tandem Computers Incorporated 124245