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

35
char idnumber[SNLEN];
# if _INCLUDE_HPUX_API_LEVEL >= 20040821
char reserved1[SYS_NMLN];
char reserved2[SYS_NMLN];
# endif
}
extern int uname(struct utsname *) ATTR;
If an application is built with no special options, it has the original layout for the utsname structure,
and the binary name of the uname() function is uname(). Applications that are enhanced for the
expanded node name are built with the compiler option D_HPUX_API_LEVEL=20040821. This
option selects the expanded utsname structure layout (along with two additional fields reserved for
future use), and the binary name of the function is uname{20040821}().
Note also that the symbolic constants have different values based on the compilation mode. These
values are consistent with the structure definition. The same conditional compilation is applied to the
MAXHOSTNAMELEN constant in another header file.
The libc library contains the uname() and the uname{20040821}() functions. These are built
into two separate objects from a common source.
Re-export of utsname Structure
Consider the following interface:
struct xyz {
int xyz_field1;
struct utsname xyz_field2;
}
extern int get_xyz(struct xyz *);
If this interface is exported outside the product, to client application code, it is said to re-export the
utsname interface.
Interface Inherits Version
When the code that implements the preceding interface is rebuilt with the
D_HPUX_API_LEVEL=20040821 compiler option, the structure xyz and the function
get_xyz()inherit the version identifier 20040821. Thus, only client programs that are also built
with the D_HPUX_API_LEVEL=20040821 option can bind to the expanded get_xyz() function.
Conversely, if the code that implements this interface is not rebuilt, only client programs that are not
built with the D_HPUX_API_LEVEL=20040821 option can bind to it.
While the version is implicitly inherited and exhibited in the binary name for this structure and
function, it might be a good idea to explicitly add the version attribute. This can improve clarity for
any developers attempting to read and understand the program source code.
Options for Interfaces Which Re-export the utsname Structure
Developers have three choices when an interface re-exports the utsname structure:
Support only the original version, build without expanded API level.
Support only the expanded versions, build with D_HPUX_API_LEVEL=20040821 option.
Support both versions.