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

34
Multiple Data Interfaces
The preceding discussion concentrated on function interfaces. Another possibility is that a data
structure exported by a library is accessed directly by client code that uses the library.
For data that is read-only by clients, the general approach to be used by the provider is to update
both the original and enhanced versions of the data structure at the same time (where the two have
common fields).
For data that is potentially written by clients, all code that reads or writes the data must be operating
on the same version. The recommendation is that only one version of that structure (possibly the
expanded version) be supported. The FLV mechanism helps to ensure that clients reference only the
same version of the data structure as the library exports.
FLV Applied to HP-UX Node Name Interfaces
This section describes how HP-UX 11i uses FLV to provide multiple versions of the node name
interfaces.
FLV is used for node name interfaces only, not host name interfaces. For the node name interfaces,
version identifiers are assigned to the utsname structure and the uname() function. No other
interfaces have version identifiers.
The setuname(), sethostname(), and gethostname() functions all accept a size parameter
to specify how many significant bytes are being passed in or can be accepted. These functions can
handle original sizes or new sizes; there is no need for separate versions.
The SYS_NMLN, SNLEN, UTSLEN, and MAXHOSTNAMELEN interfaces are all constants. FLV cannot
apply version identifiers to constants.
The sys/utsname.h header file defines the node name-related constants, the utsname structure,
and the uname function. This header file depends on the header stdsyms.h to process the
_HPUX_API_LEVEL definition and, in turn, define the _INCLUDE_HPUX_API_LEVEL symbol to be
used in other header files. The HP-UX sys/utsname.h header file, in simplified form looks like:
#include <sys/stdsyms.h>
#if _INCLUDE_HPUX_API_LEVEL >= 20040821
#define SYS_NMLN 257
#define SNLEN 257
#define UTSLEN 257
#define ATTR __attribute((version_id(“20040821”)))
#else
#define SYS_NMLN 9
#define SNLEN 15
#define UTSLEN 9
#define ATTR /* no version */
#endif
struct ATTR utsname {
char sysname[SYS_NMLN];
char nodename[SYS_NMLN];
char release[SYS_NMLN];
char version[SYS_NMLN];
char machine[SYS_NMLN];