[Contents] [Prev. Chapter] [Next Section] [Next Chapter] [Index] [Help]

6    Overview of the DIGITAL UNIX Programming Environment

The DIGITAL UNIX and ULTRIX programming environments are similar and most of the tools in the DIGITAL UNIX programming environment are the same as the ULTRIX equivalent tools. However, some differences exist. This chapter is an overview of those differences, in the following categories:


[Contents] [Prev. Chapter] [Next Section] [Next Chapter] [Index] [Help]

6.1    Alpha Architecture

To take advantage of the Alpha architecture, the DIGITAL UNIX programming environment differs from ULTRIX in the following areas:

These changes, described in the following sections, can affect how a program accesses and manipulates data.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.1.1    Data Representation

The DIGITAL UNIX C data types have been modified and extended to include a 64-bit type. Table 6-0 shows the differences in data types between the ULTRIX and DIGITAL UNIX environments.

Table 6-0:  C Language Data Types

Data Type 32-Bit MIPS or VAX System (Size in Bits) 64-Bit DIGITAL UNIX System (Size in Bits)
char 8 8
short 16 16
int 32 32
long 32 64
long long Not available 64
float 32 (MIPS: IEEE single precision)(VAX: F_floating) 32 (IEEE single precision)
double 64 (MIPS: IEEE double precision)(VAX: G_floating or D_floating) 64 (IEEE double precision)
pointer 32 64

The major differences are that long is defined to be 64 bits; pointer is defined to be 64 bits, extending the address space; and long long, a new data type, is defined to be 64 bits. The long long data type offers the unique name for a 64-bit data type that might give additional interoperability between 32-bit and 64-bit systems.

Like the VAX and MIPS systems, the DIGITAL UNIX system uses right-to-left byte ordering (little endian) for integer types.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.1.2    Data Access

Unlike the VAX and MIPS architectures, which allowed byte and word memory accesses, the Alpha architecture supports only memory accesses of longword (32 bits) or quadword (64 bits). Byte and word accesses are accomplished by multiple instructions, which load a longword or quadword, mask, and shift to get the desired entity. The lack of a single operation for byte and word access might produce incorrect results in cases where you are accessing adjacent byte or word entities in shared memory segments.

For instance, a multithreaded application or multiple processes that have access to adjacent byte data through shared memory or shared memory-mapped files will have to use thread mutual exclusion locking functions or semaphore locks, respectively, to avoid conflicts with accesses to adjacent byte or word data items.

Also, the order in which write operations occur can be different from what the programmer intended. If it is important to guarantee the order in which data is written to memory, use memory barrier instructions.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.1.3    Data Alignment

On both MIPS and Alpha systems the data alignment is implied by the data type. For instance, an int (32 bits) is aligned on a 4-byte boundary. On MIPS systems, a long (32 bits) is also aligned on a 4-byte boundary. But on Alpha systems, a long (64 bits) is aligned on 8-byte boundaries. If you are using assembly language, you will need to understand and code according to these alignment restrictions. If you are using a high-level language, such as C, the compiler will take care of this alignment for you. However, you need to understand these alignment differences when using long and pointer types in structure definitions that are shared between 32-bit and 64-bit systems.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.1.4    File Systems

On the 32-bit MIPS and VAX systems, the maximum size of files and file systems was 2 gigabytes (GB). This limit was imposed by the programming interface and file system, which used a 32-bit integer to represent the file offset in bytes (off_t) when navigating within a file or file system.

On a 64-bit Alpha system, you can now build much larger files and file systems. The off_t file offset is defined to be a long on Alpha systems, which is 64 bits in length. Given this extended capability, it is possible to build files and file systems that cannot be fully accessed by 32-bit systems. You need to keep this in mind when working in a distributed environment where file systems are shared between 32- and 64-bit systems.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.2    Graphical Programming Environment

The DIGITAL UNIX DECwindows Motif windowing environment is based on the industry-standard OSF/Motif Version 1.2.3 graphical user interface, featuring three-dimensional visuals and consistent operation and style. The ULTRIX and UWS OSF/Motif graphical interface is based on Version 1.2.2 of OSF/MOtif. Because OSF/Motif Version 1.2.3 does not include new features, there should be no migration issues between the ULTRIX and UWS and DIGITAL UNIX system programming environments. However, the DECwindows XUI interface available on ULTRIX systems is different from the DIGITAL UNIX interface. The following sections discuss these differences.

The DECwindows Motif programming environment provides libraries and tools for developing graphical applications for workstations. This graphical programming environment includes:

Creating graphical applications for the DECwindows Motif environment is similar to creating applications for the XUI environment. Programmers who are experienced in developing XUI applications or who are porting existing XUI applications to Motif should note the following differences:

For information about how to design Motif compliant applications, see the OSF/Motif Style Guide manual and the DECwindows Companion to the OSF/Motif Style Guide manual.

For more complete information about porting XUI applications to Motif, see the Porting XUI Applications to Motif manual.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.3    Software Development Tools

Like ULTRIX systems, DIGITAL UNIX systems have a variety of software development tools. You can use these tools as you port applications to a DIGITAL UNIX system, as well as when you develop new applications on a DIGITAL UNIX system.

This section gives an overview of the following DIGITAL UNIX software development tools, highlighting differences from the ULTRIX software development tools:

This section gives an overview of only the DIGITAL UNIX C preprocessor and C compiler, because they are part of the DIGITAL UNIX product. In addition, other compilers, such as DIGITAL Fortran and DIGITAL Pascal, are available for use on the DIGITAL UNIX system.

Note

The ULTRIX RISC programming environment for Version 4.3A and higher systems use the MIPS Version 3.0 compilation system, as does the DIGITAL UNIX system. Earlier versions of ULTRIX RISC programming environments were based on the MIPS Version 2.10 compiler.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.3.1    The C Preprocessor

The C preprocessor (cpp) on DIGITAL UNIX systems is similar to the preprocessor (cpp) on ULTRIX systems. Like the ULTRIX preprocessor, the DIGITAL UNIX preprocessor interprets directives, such as #include and #define. The syntax for specifying directives is the same as the syntax on ULTRIX systems.

The DIGITAL UNIX system defines a number of preprocessor symbols. Some of these symbols are different from the equivalent symbol on an ULTRIX system. For information about DIGITAL UNIX predefined symbols, see Section 7.4.1.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.3.2    The C Compiler

Like the ULTRIX C compiler driver, the DIGITAL UNIX C driver performs several tasks. You can enter the cc command to run the C preprocessor, the C compiler, or the linker. Normally, you use the cc command to run all three tools and to compile and link your application. Like most ULTRIX C compilers, the DIGITAL UNIX C compiler supports optimizing code. In addition, the compiler supports DIGITAL UNIX features, such as linking with shared libraries and creating function prototypes. (For more information about the features and general use of the compiler, see the Programmer's Guide.)

For compatibility with ULTRIX compilers, the DIGITAL UNIX compiler supports several modes for compiling applications. You choose which mode the compiler operates in by using one of the following command-line options:

Option Description
-std0 Invokes a mode that compiles C applications as defined by Kernighan and Ritchie (K&R), with some ANSI extensions such as function prototypes. This mode is the default mode.
-std Invokes a mode that compiles applications according to the ANSI standard. The mode allows certain extensions to the ANSI standard, such as C++ style comments and casting of the left-hand side of an assignment operator.
-std1 Invokes a mode that compiles applications in strict accordance with the ANSI standard.

For information about using these options to compile ULTRIX programs on DIGITAL UNIX systems, see Section 7.4.

Many applications written for the ULTRIX programming environment will compile with no changes. However, there are certain behaviors that are present in the ULTRIX system that are not in the default DIGITAL UNIX system. Most of these behaviors will not be caught at compile time but will instead cause an application to fail when it is run.

The DIGITAL UNIX system is written using a hierarchy of interfaces and definitions. Using the default interface, -D_OSF_SOURCE, applications will be able to make use of all the features specified by the OSF Application Environment Specification (AES). If other specific operating system environments are needed, you can use the following symbols:

For example, applications needing a fully POSIX-conforming environment should be compiled with the -D_POSIX_SOURCE compiler switch. Applications needing a strict ANSI-conforming environment should be compiled with the -D_ANSI_SOURCE and -stdl compiler switches.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.3.3    The Linker

In most instances, you can use the compiler to link separate application object files into a single executable application.

As part of the compilation process, compiler drivers call the linker, ld, to combine one or more object files into a single application object file. The linker's operation is essentially similar on the two systems; the most important difference is that by default the DIGITAL UNIX linker links with shared libraries; the ULTRIX system does not support shared libraries. The DIGITAL UNIX linker resolves external references, searches libraries, and performs all other processing required to create object files that are ready for execution. The resulting object module can either be executed or can serve as input to a separate ld command. (You can invoke the linker separately from the compiler by entering the ld command.)

The DIGITAL UNIX linker also supports C++ automatic constructors and destructors, and new options.

On DIGITAL UNIX systems, you normally use the linker to create shared libraries. For information about using and creating shared libraries, see Chapter 8. To link your application with shared libraries, use the appropriate compiler driver. To inhibit linking with shared libraries, use the driver's -non_shared option.

Because the DIGITAL UNIX environment is a 64-bit environment, the linker, by default, loads the program text and data in the high 64-bit virtual address space of the process (between 0xFFFFFFFFFFFFFFFF and 0x0000000100000000). As a result, there are no addresses accessible with a 32-bit address. If your source code contains any unintended pointer truncations, they will trap into the kernel and cause a run-time error. You can change this default behavior by using the -T or -D options to change the text and data segment origin, respectively.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.3.4    The Debugger

The primary debugging tool on DIGITAL UNIX systems is dbx, which is a source-level debugger. This debugger is the same tool that is available on ULTRIX systems, and you can use it the same as you used the ULTRIX dbx. The differences between the DIGITAL UNIX and ULTRIX versions of dbx are that the DIGITAL UNIX debugger has been enhanced to support debugging applications that are linked with shared libraries.

The ULTRIX window interface to dbx, which is dxdb, is not supplied on DIGITAL UNIX systems. If you develop software in a window environment, you can purchase and install the DEC FUSE product. DEC FUSE is a software development, analysis, and maintenance environment for programmers. DEC FUSE offers a set of tools with a DEC OSF/Motif user interface and graphics options in an integrated setting. DEC FUSE tools include an editor, a code manager, a program builder, a debugger, a cross-referencer, and a call graph browser.

DIGITAL UNIX systems also include another debugging tool, kdbx. The kdbx utility is an interactive, crash analysis and kernel debugging tool that replaces the ULTRIX crash program. As a kernel debugging tool, kdbx serves as a front end to the dbx debugger, and enables you to examine the running kernel or dump files created by savecore. The kdbx utility is also insensitive to version numbers, and can be customized and extended. For more information on the kdbx utility, see the Kernel Debugging manual.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.3.5    Other Programming Tools

DIGITAL UNIX systems have other programming tools that are available on ULTRIX. These tools have been modified to support the ANSI C language dialect, shared libraries, and 64-bit data types. Otherwise, their use is the same as their ULTRIX equivalents.

The following list gives a brief description of each tool. (For more information about the tools, see the reference page for each individual tool.)


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.4    Source File Control

Like the ULTRIX system, the DIGITAL UNIX system supports the Source Code Control System (SCCS). The DIGITAL UNIX system also supports the Revision Control System (RCS), which is an unsupported subset on the ULTRIX system. The SCCS and RCS utilities allow you to store application modules in a directory, track changes made to those module files, and monitor access to the files. The SCCS and RCS utilities on DIGITAL UNIX systems are the same as the SCCS and RCS you use on ULTRIX systems. For more information about SCCS and RCS, see the Programming Support Tools manual.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.5    Product Installation Tools

Once you port your application to DIGITAL UNIX, you might want to create a software package for it, for distribution to other users. Like ULTRIX systems, the DIGITAL UNIX system has utilities that you can use to install, remove, combine, validate, and configure applications.

To create a software package, you use the following utilities:

Unlike the ULTRIX setld command, the DIGITAL UNIX setld command does not install software into a Diskless Management Services (DMS) area. The DMS software is not provided on DIGITAL UNIX systems.

See the Programming Support Tools manual for descriptions of the program installation tools and the process of building setld-compatible kits.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.6    Shared Libraries

The DIGITAL UNIX system provides shared libraries as part of the programming environment. Shared libraries are libraries linked in a file organized like a demand-paged executable program. Like other programs, the libraries contain data and text sections and export entry points or data objects. Multiple processes can use the entry points simultaneously or use the data objects (each process has a private copy of the data objects).

Unlike most programs, shared libraries contain no fixed-base address. Shared libraries contain symbol and relocation information. When you link your application with a shared library, the executable application does not contain the library routines; instead, the application contains the information it needs to load the shared library at startup time and to access the shared routines and private data at execution time.

The following shared libraries are elements of all DIGITAL UNIX systems:

libDXm.so libc.so libids.so
libMrm.so libc_r.so libids_nox.so
libX11.so libchf.so libimg.so
libXaw.so libcda.so libips.so
libXext.so libdnet_stub.so liblkwdxm.so
libXie.so libdl.so libm.so
libXm.so libdps.so libmach.so
libXmu.so libdpstk.so libpsres.so
libXt.so libdvr.so libpthreads.so
libbkr.so libdvs.so libsys5.so

The following shared libraries are also elements of all systems, but were not documented earlier in this manual:

libXimp.so libXv.so libaud.so
libcdrom.so libcmalib.so libcurses.so
libiconv.so libmxr.so libproplist.so
libsecurity.so libtli.so libxti.so

Starting with DIGITAL UNIX Version 3.0, the following shared libraries are elements of all systems:

libDXterm.so libXIE.so libXi.so

These libraries are located in the /usr/shlib directory.

In addition to shared libraries, the DIGITAL UNIX system provides archive libraries. Archive libraries are traditional ULTRIX libraries. When you link your application with them, the image for library routines you call is included in your application image. You can link DIGITAL UNIX applications to either the new shared libraries or the traditional archive libraries. To help you decide which libraries to use, this section describes some advantages of using shared libraries and some restrictions on using them.

For information on how to link your application with DIGITAL UNIX shared libraries and how to create shared libraries, see Chapter 8.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.6.1    Using Shared Libraries

The following list details the advantages of using shared libraries on DIGITAL UNIX systems:


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.6.2    Changing from Archive Libraries to Shared Libraries

Normally, you can use shared libraries in any application and create any library as a shared library. In most cases, the effect of using shared libraries instead of archive libraries should be transparent; however, a few restrictions on using and creating shared libraries do exist. The following list describes these restrictions:


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.7    Standard Application Programming Interfaces

In addition to making your source code portable with respect to applicable language standards, you must make your applications conform to specific application programming interfaces (APIs) in order to link correctly and produce correct results. The DIGITAL UNIX system supports the following APIs:


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.8    Network Programming Software

The networking programming facilities available in the DIGITAL UNIX system provide a high degree of commonality and interoperability with the ULTRIX system. Both systems provide APIs, including X/Open Transport Interface (XTI), Data Link Interface (DLI), and sockets, as described in the following sections. In addition, DIGITAL UNIX provides support for STREAMS, which is compatible with System V Release 3.2 STREAMS.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.8.1    X/Open Transport Interface

The X/Open Transport Interface (XTI) defines a transport interface for networking applications that is independent of any specific transport provider. The XTI design and implementation on DIGITAL UNIX are new. XTI applications are interoperable between ULTRIX and DIGITAL UNIX systems. XTI is similar to, and backward compatible with, the System V Transport Layer Interface (TLI). Libraries for both XTI (-lxti) and TLI (-ltli) are provided. See Section 7.8 and the Network Programmer's Guide for more information.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.8.2    Data Link Interface

The Data Link Interface (DLI) defines a transport interface for networking applications on Ethernet and Fiber Distributed Data Interface (FDDI) networks. DLI applications are interoperable between ULTRIX and DIGITAL UNIX systems. On DIGITAL UNIX systems, the location of the dli_var.h library is /usr/include/dli/dli_var.h. In addition, the sockaddr_dl structure has a new field, dli_len, in the first byte. See the Network Programmer's Guide for more information.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.8.3    Sockets Interface

Sockets are the end points of communication channels and are used much the same way as file descriptors are used. The socket interface provided by DIGITAL UNIX is compatible with the ULTRIX socket interface. See the Network Programmer's Guide for more information.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.8.4    SNMP Compatibility

DIGITAL UNIX and ULTRIX both support the Simple Network Management Protocol (SNMP) Agent. The DIGITAL UNIX system does not support the ULTRIX Extended SNMP Agent for defining private Management Information Base (MIB) objects through a set of library routines. See Section 7.6.1 for more information.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.9    Distributed Services Programming Software

This section discusses the following distributed services programming facilities:


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.9.1    Remote Procedure Calling

The ULTRIX system provides a general RPC mechanism, DEC RPC Version 1.0, which is based on and is compatible with the RPC component of the Hewlett-Packard/Apollo Network Computing System (NCS), Version 1.5. DIGITAL UNIX systems do not provide a development or run-time environment for DEC RPC Version 1.0. Specifically, the DEC RPC Version 1.0 components, which include the Network Interface Definition Language (NIDL) compiler, the Location Brokers (Local Location Broker and Global Location Broker), and the RPC run-time library, are unavailable.

DIGITAL UNIX and ULTRIX systems both provide the capabilities to interoperate with the Sun Microsystems ONC (Open Network Computing environment). DIGITAL UNIX systems also enable ONC RPC application development by providing a high-level set of operations that can be used to execute procedures on remote systems across a network. See the Programming with ONC RPC manual for more information on using ONC RPC.

As part of the Distributed Computing Environment (DCE), OSF has defined an RPC mechanism that integrates with the other DCE components (for example, Cell Directory Service and Global Naming - X.500). Components to support this mechanism are not part of the base DIGITAL UNIX product. See the DIGITAL DCE Starter Kit for these features.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.9.2    Network Authentication

Kerberos is an authentication service that validates the identity of a user or service, preventing fraudulent requests. It provides a programming interface for authentication by applications communicating across a TCP/IP network with a socket interface. The ULTRIX system supports a version of Kerberos that is derived from MIT/Athena's Kerberos Version 4. No Kerberos programming interfaces are available on the DIGITAL UNIX system. Many binaries that were built with Kerberos on an ULTRIX system will run on DIGITAL UNIX systems when using an ULTRIX server, as long as the ULTRIX system is Version 4.2 or higher. See Section 7.6.1 and Section B.18 for more information.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.9.3    Naming Services

The DIGITAL UNIX system supports both the Berkeley Internet Name Domain (BIND) service and the Network Information Services (NIS, formerly YP) service. Both of these services are interoperable between ULTRIX and DIGITAL UNIX systems. By itself, the BIND name service allows you to distribute a host naming database. The NIS service can distribute several different databases. BIND and NIS support equivalent functions in the run-time library.

The Hesiod service, available on ULTRIX systems, is not supported by the DIGITAL UNIX system. No Hesiod programming interfaces exist on DIGITAL UNIX systems. See Section B.18 for more information.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10    Internationalization Features

An internationalized application allows users to interact with that application in their native language. The application is also designed to reflect the culture of the user's region. For example, data such as dates and monetary values are displayed or read as input in the style of that region.

The DIGITAL UNIX internationalization features are compatible with the ANSI C, POSIX, and XPG4 specifications for an international programming environment.

In addition to the ULTRIX internationalization features, the DIGITAL UNIX internationalization features provide the following:

Some differences exist between the ULTRIX and DIGITAL UNIX internationalization features. The following sections give an overview of the differences. For more information about the DIGITAL UNIX internationalization features, see Writing Software for the International Market and the i18n_intro command.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.1    Message Catalog System

The message catalog system isolates program messages from the body of your program. This isolation makes it easier for you to translate messages into other languages. The message catalog system consists of message extraction tools, tools for translating messages, a tool for generating message catalogs, and routines for accessing message catalogs.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.1.1    Message Extraction Tools (extract, strextract, and strmerge)

Like the ULTRIX system, the DIGITAL UNIX system provides the extract, strextract, and strmerge commands that extract message text from your program and store it in a message text source file. In most ways, these commands are the same as their ULTRIX equivalent. This section describes the two ways the commands differ between the DIGITAL UNIX and ULTRIX systems.

The output file name for the strextract command, and therefore the input file name for the strmerge command, is different. On DIGITAL UNIX systems the intermediate file that strextract creates is named filename.str. On ULTRIX systems, this file is named filename.msg.

The other difference is the name of the internationalization directory. On DIGITAL UNIX systems, related internationalization files are stored in the /usr/lib/nls directory. On ULTRIX systems, these files are stored in the /usr/lib/intln directory. This change affects the following:


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.1.2    Tool for Translating Messages (trans)

You can use the DIGITAL UNIX trans command to help you translate message text source files from one native language to another. This command is the same as the ULTRIX trans command.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.1.3    Tools for Creating a Message Catalog (mkcatdefs and gencat)

The DIGITAL UNIX system provides the mkcatdefs and gencat commands, which work together to generate a formatted message catalog. Some system limits that affect the gencat command have increased on DIGITAL UNIX systems. See Table B--1 for complete information. Other than the difference in the system limits, the DIGITAL UNIX gencat command is the same as the ULTRIX gencat command. The mkcatdefs command is the same on both systems.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.1.4    Routines for Accessing a Message Catalog (catopen, catgets, and catclose)

You use the DIGITAL UNIX catopen, catgets, and catclose library routines to open, read messages from, and close message catalogs. These routines are the same as the ULTRIX routines of the same names.

By default, these routines search the /usr/lib/nls/msg/%L /%N path for a message catalog. In the preceding pathname, %L represents the locale name specified by the LANG environment variable, and %N represents the name of the message catalog passed to the catopen function. Typically, the name of the message catalog is messages.cat.

The DIGITAL UNIX catopen routine differs from the ULTRIX catopen routine in two ways. First, the DIGITAL UNIX catopen routine does not search the current directory for message catalogs. The ULTRIX catopen routine searches the current directory for message catalogs it does not find in either the /usr/lib/nls/msg/%L /%N directory or the directories specified by the NLSPATH environment variable. Second, the DIGITAL UNIX catopen routine ignores the NLSPATH environment variable when it attempts to find a message catalog for the root user. The routine searches only the /usr/lib/nls/msg/%L /%N directory. This difference affects applications that use the setuid system call to become the root user.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.2    Program Localization

Writing an international application involves more than isolating and translating program messages. The application must also reflect the culture of the user by displaying dates and times, monetary values, numbers, alphabetic lists, and so on in the style that the user expects. On DIGITAL UNIX systems (as on ULTRIX systems), the application behavior in these areas is controlled by the program's locale.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.2.1    Announcement Mechanism

You control which locale an application runs in by defining environment variables. The environment variables announce to the system what local data the application should use.

The DIGITAL UNIX system provides the same environment variables as the ULTRIX system, with the addition of LC_ALL and LC_MESSAGES. The following list describes these environment variables:

The only difference between these environment variables on a DIGITAL UNIX system and on an ULTRIX system is the naming convention used for the locales. For information about defining these environment variables, see Section 3.1.3.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.2.2    The setlocale Routine

To determine what locale has been set, you call the setlocale routine in your program. This routine has the following format:

setlocale (category, locale)

The category argument specifies the category for which you are requesting locale information, that is, LANG, LC_COLLATE, LC_CTYPE, and so on. The locale argument is usually an empty string ( "" ) that causes the setlocale routine to determine the setting of a category by reading the corresponding environment variable. However, you can specify a locale name in this argument. If you do, be aware that the naming convention for the DIGITAL UNIX locales is different from the ULTRIX naming convention. For information about the names of DIGITAL UNIX locales, see the Technical Overview.

By default, setlocale expects the locale-specific data to be in the language support databases contained in the /usr/lib/nls/loc directory (the /usr/lib/intln directory on ULTRIX systems).

On ULTRIX systems, you can store the locale-specific data in a directory that is not in the default search path. You specify where the locale-specific data is by defining the INTLINFO variable. On DIGITAL UNIX systems you specify where the locale-specific data is by defining the LOCPATH variable.

Except for these differences, the setlocale routine is the same on DIGITAL UNIX and ULTRIX systems.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.3    Creating Locale-Specific Information

On DIGITAL UNIX systems, you can create your own locale-specific information. Use the localedef command to process locale and character map files and produce a locale database. This command replaces the ULTRIX ic command. For information about using the localedef command, see localedef(1).


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.10.4    The iconv Command

Like the ULTRIX iconv command, the DIGITAL UNIX iconv command converts the encoding of characters in one codeset to another codeset. On DIGITAL UNIX systems, you can use iconv to convert between a number of character sets. The system provides conversion tables in the /usr/lib/nls/loc/iconv directory. For information about using iconv to convert codesets, see iconv(1).


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.11    Event-Logging Software

On DIGITAL UNIX systems, system events are recorded using two facilities:

The binary event logging is like the binary error logging provided on ULTRIX systems. There are differences between the system logging facilities on ULTRIX and DIGITAL UNIX systems. Both the ULTRIX and DIGITAL UNIX systems provide a set of application interfaces for syslog. See Section B.16 for more information.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

6.12    Security

The Security manual contains information about migrating a programming interface from ULTRIX to DIGITAL UNIX, including basic migration issues and ways to move ULTRIX authentication files to a DIGITAL UNIX system.

The DIGITAL UNIX system does not support the functions for getting and setting authorization entries in the auth database. See the discussion of secauthmigrate in the Security manual for more information. Additionally, Section B.18 contains a list of security-related header files that exist in ULTRIX but do not exist on a DIGITAL UNIX system.


[Contents] [Prev. Chapter] [Prev. Section] [Next Chapter] [Index] [Help]

6.13    Curses Libraries

The curses package is a set of cursor optimization routines for writing screen-management programs. ULTRIX and DIGITAL UNIX systems both support X/Open and BSD curses library routines. The capabilities in both of these libraries have been extended beyond what is available with Version 4.2 and Version 4.3 of the ULTRIX system. For example, the DIGITAL UNIX curses package provides multibyte character support.

ULTRIX applications will need to change references to header files and libraries. See Section 7.2, Section 7.7, and Section 4.7 for more information.


[Contents] [Prev. Chapter] [Prev. Section] [Next Chapter] [Index] [Help]