HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)
g
getutx(3C) getutx(3C)
setutxent() Resets the input stream to the beginning of the file. This should be done before
each search for a new entry if it is desired that the entire file be examined.
endutxent() Closes the currently open file.
The most current entry is saved in a static structure. Multiple accesses require that the structure be
copied before further accesses are made. During each call to either
getutxid() or getutxline(),
the static structure is examined before performing more
I/O. If the contents of the static structure match
what the routine is searching for, no additional searching is done. Therefore, if using
getutxline()
to search for multiple occurrences, it is necessary to zero out the static structure after each success; other-
wise
getutxline() simply returns the same pointer over and over again. There is one exception to
the rule about removing the structure before a new read: The implicit read done by
pututxline() (if
it finds that it is not already at the correct place in the file) does not alter the contents of the static struc-
ture returned by
getutxent(), getutxid(),or
getutxline() if the user has just modified those
contents and passed the pointer back to
pututxline()
.
RETURN VALUE
These functions return a
NULL pointer upon failure to read (whether for permissions or having reached
end-of-file), or upon failure to write. They also return a
NULL pointer if the size of the file is not an
integral multiple of
sizeof(struct utmpx)
.
If
pututxline() is successful, it returns a pointer to a static location containing the most current
utmpx entry. The contents of this structure are identical to the contents of the supplied utmpx
struc-
ture if successful. If
pututline() fails upon writing to utmpx, it returns a NULL pointer. If
putu-
line()
is successful in writing to the utmpx file but fails in writing to the
utmp file, then putut-
line() will behave as if it succeeded. Note that the utmpx file and the utmp file may not be in sync
due to the above behavior.
pututxline() is only guaranteed to have written to the utmpx file upon
successful completion.
FILES
/etc/utmp
/etc/utmpx
/var/adm/wtmp
SEE ALSO
getut(3C), getutent(3C), ttyslot(3C), utmp(4), thread_safety(5).
STANDARDS CONFORMANCE
endutxent(): XPG4.2
getutxent(): XPG4.2
getutxid(): XPG4.2
getutxline(): XPG4.2
pututxline(): XPG4.2
setutxent(): XPG4.2
Section 3−−454 Hewlett-Packard Company − 2 − HP-UX 11i Version 2: September 2004