United States-English |
|
|
HP-UX Reference > Ggetutx(3C)HP-UX 11i Version 3: February 2007 |
|
NAMEgetutx: endutxent(), getutxent(), getutxid(), getutxline(), pututxline(), setutxent() — access utmpx file entry SYNOPSIS#include <utmpx.h> struct utmpx *getutxent(void); struct utmpx *getutxid(const struct utmpx *id); struct utmpx *getutxline(const struct utmpx *line); struct utmpx *pututxline(const struct utmpx *utmpx); void setutxent(void); void endutxent(void); Remarks:The ut_addr field in the utmpx structure is deprecated and will be obsoleted and removed in a future release. If this field is needed, use the getuts() functions (see getuts(3C)). DESCRIPTIONgetutxent(), getutxid(), and getutxline() each return a pointer to a structure of the following type: struct utmpx { char ut_user[24]; /* User login name */ char ut_id[4]; /* /etc/inittab id (usually line #) */ char ut_line[12]; /* device name (console, lnxx) */ pid_t ut_pid; /* process id */ short ut_type; /* type of entry */ struct __exit_status { short __e_termination; /* Process termination status */ short __e_exit; /* Process exit status */ } ut_exit; /* The exit status of a process */ /* marked as DEAD_PROCESS. */ unsigned short ut_reserved1; /* Reserved for future use */ struct timeval { time_t tv_sec; /* seconds */ long tv_usec; /* and microseconds */ } ut_tv; /* time entry was made */ char ut_host[64]; /* host name, if remote; NOT SUPPORTED */ unsigned long ut_addr; /* Internet addr of host, if remote; */ /* TO BE OBSOLETED */ char ut_reserved2[12] ; /* Reserved for future use */ };
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; otherwise 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 structure returned by getutxent(), getutxid(), or getutxline() if the user has just modified those contents and passed the pointer back to pututxline(). RETURN VALUEThese 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 structure if successful. If pututline() fails upon writing to utmpx, it returns a NULL pointer. If putuline() is successful in writing to the utmpx file but fails in writing to the utmp file, then pututline() 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. WARNINGSThe ut_addr field in the utmpx structure is deprecated and will be obsoleted and removed in a future release. If this field is needed, use the getuts() functions (see getuts(3C)). |
Printable version | ||
|