HP-UX Reference (11i v2 03/08) - 3 Library Functions A-M (vol 6)
g
getbootpent(3X) getbootpent(3X)
entry in the /etc/bootptab
file (or from an alternate file specified by a
call to
setbootpent()
), including leading, or embedded, comment lines.
Each subsequent call returns a pointer to the next entry in the file so that suc-
cessive calls can be used to search the entire file.
If no file is currently in memory,
getbootpent() reads the
/etc/bootptab file prior to doing its work.
The returned array exists in static space (malloc’d memory) overwritten by the
next call (so previously returned pointers become invalid). However, each
array element’s
bp_text pointer points to text in an in-memory copy of the
file. This text is not altered by the next call (nor by changes to the file itself).
Hence, it is possible to copy an entry’s array in order to save it, as illustrated
in EXAMPLES below. The data remains valid until the next call of
set-
bootpent() or endbootpent()
.
If there are comments after the last entry, they are returned as a separate
entry with no data parts.
setbootpent()
Opens the specified file for reading by getbootpent()
, reads a copy into
memory, and closes the file (which as a side-effect releases any locks on the
file; see lockf(2)). If the given path is a null pointer or a null string,
set-
bootpent() opens and reads /etc/bootptab
.
If the last file opened by
setbootpent()
(or implicitly by getboot-
pent()) was /etc/bootptab
, a subsequent call to setbootpent() for
the same file rewinds the file to the beginning, making visible any recent
changes to the file, without first requiring a call to
endbootpent()
.
endbootpent() Frees the in-memory copy of the last file opened by
setbootpent(),or
getbootpent().
putbootpent() Writes (to the current location in the stream specified by bootpfile) the ASCII
equivalent of the specified array of
bootpent structures containing one file
entry, and its leading, or embedded, comments (a total of numfields array ele-
ments). Entries are written in canonical form, meaning the entry name and
each data field are on separate lines, data fields are preceded by one tab each,
and each line except the last ends with ‘‘:\’’. If numfields is less than or equal
to zero, nothing is written.
parse_bp_htype()
Converts a host address type from string to numeric format (HTYPE_*) in the
same manner as
bootpd.
parse_bp_haddr()
Converts a host (hardware, link level) address from string to binary format in
the same manner as
bootpd given a host address type (HTYPE_*). The cal-
ling program’s result, which must be an array containing at least
MAXHAD-
DRLEN elements, is modified to hold the host address binary value, and
bytes is modified to indicate the length in bytes of the resulting address.
This can be used to compare two host addresses, independent of string
representations. source is modified to point to the first char after the parsed
address.
parse_bp_iaddr() Converts an internet address from string to binary format in the same manner
as bootpd. This can be used to compare two internet addresses, independent
of string representations. The calling program’s result is modified to hold the
internet address binary value. source is modified to point to the first char
after the parsed address.
Field Definitions
If
bootpent.bp_type is BP_DATA, the associated text is one field from the current entry, either the
name field or one of the tag fields. Null tag fields (two colons in a row) are ignored, not returned.
If
bootpent.bp_type is BP_COMMENT or BP_BLANK, the associated text is one comment line or
blank line from the file, either preceding the current entry or embedded in it following a data line that
was continued with a backslash. The text is exactly as it appears in the file, including any whitespace
appearing on a blank line, and there is no trailing newline.
Section 3−−346 Hewlett-Packard Company − 2 − HP-UX 11i Version 2: August 2003