Node and Host Name Sizes on HP-UX: Using the Expanded Capabilities of HP-UX

10
Programmer Notes: Overview for Updating Programs
Most application code is unaffected by the node and host name expansion. However, some
applications need to be recompiled with options that select name expansion. In a subset of those
cases, some code modification might be necessary.
This section describes how software developers can determine whether a product might need
modification and, if so, how to enhance the product to accommodate expanded node and host
names. Enhanced programs also operate correctly in systems where the names are not long.
Programs that have no dependencies on node or host name size, or that are enhanced for the
expanded sizes, are said to be expanded node and host name clean.
Developers should read this section in its entirety, along with the related appendixes, in order to
understand all the issues. Developers should also become familiar with the administrative issues
described in HP Product Limitations.
Is The Program Already Clean?
Programs in which the source code does not use any of the following symbols are already clean and
need no further consideration:
For node names: sys/utsname.h, utsname, utsname.nodename,
uname(),SYS_NMLN,SNLEN,UTSLEN
For host names: gethostname(), sethostname(), MAXHOSTNAMELEN
Note that some programs use literal constants when one of the preceding symbolic constants (those
with full capitalization) should have been used instead. These programs might pass a symbol search
but still do not support the expanded size for node or host names.
The Basics
Most programs that are not already clean simply need to be recompiled to use expanded versions of
the interfaces. This entails adding the compiler option -D_HPUX_API_LEVEL=20040821 to the
makefile.
3
This does the following:
Selects expanded values for MAXHOSTNAMELEN, SYS_NMLN, SNLEN, and UTSLEN.
Defines an expanded utsname structure.
Causes source references to uname() to link to the expanded version of the function in libc.
All elements (source files) of a program that reference any of the preceding symbols must be
recompiled to ensure they all have compatible data layouts. If a function in one compilation unit
passes a buffer of MAXHOSTNAMELEN bytes to a function in another compilation unit, it is important to
ensure both functions are using the same size. The same concern applies to the other symbols as
well.
3
Note that this can also be defined in the source file itself, with #define _HPUX_API_LEVEL 20040821. However, it must
be the first line of the source (it must precede any #include directives), and it must appear in all source files that comprise the
program. Specifing the compiler option in the makefile is generally less error-prone. Note also that future versions of HP-UX
may define API levels with identifiers greater than 20040821. These future versions are cumulative and will include all the
features of API level 20040821.