IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

getutent (3)

GETUTENT(3)                    Library functions                   GETUTENT(3)



NAME
       getutent, getutid, getutline, pututline, setutent, endutent, utmpname -
       access utmp file entries

SYNOPSIS
       #include<utmp.h>

       structutmp*getutent(void);
       structutmp*getutid(structutmp*ut);
       structutmp*getutline(structutmp*ut);

       structutmp*pututline(structutmp*ut);

       voidsetutent(void);
       voidendutent(void);

       voidutmpname(constchar*file);

DESCRIPTION
       utmpname() sets the name of the utmp-format file  for  the  other  utmp
       functions  to  access.   If  utmpname() is not used to set the filename
       before the other functions are used, they assume _PATH_UTMP, as defined
       in <paths.h>.

       setutent()  rewinds the file pointer to the beginning of the utmp file.
       It is generally a Good Idea to call it before any of  the  other  func-
       tions.

       endutent()  closes  the  utmp  file.  It should be called when the user
       code is done accessing the file with the other functions.

       getutent() reads a line from the current  file  position  in  the  utmp
       file.  It returns a pointer to a structure containing the fields of the
       line.

       getutid() searches forward from the current file position in  the  utmp
       file based upon ut.  If ut->ut_type is RUN_LVL, BOOT_TIME, NEW_TIME, or
       OLD_TIME, getutid() will find  the  first  entry  whose  ut_type  field
       matches ut->ut_type.  If ut->ut_type is one of INIT_PROCESS, LOGIN_PRO-
       CESS, USER_PROCESS, or DEAD_PROCESS,  getutid()  will  find  the  first
       entry whose ut_id field matches ut->ut_id.

       getutline() searches forward from the current file position in the utmp
       file.  It scans entries whose ut_type is USER_PROCESS or  LOGIN_PROCESS
       and returns the first one whose ut_line field matches ut->ut_line.

       pututline()  writes  the utmp structure ut into the utmp file.  It uses
       getutid() to search for the proper place in the file to insert the  new
       entry.   If it cannot find an appropriate slot for ut, pututline() will
       append the new entry to the end of the file.

RETURNVALUE
       getutent(), getutid(), getutline() and pututline() return a pointer  to
       a staticstructutmp on success, and NULL on failure.

EXAMPLE
       The  following  example  adds and removes a utmp record, assuming it is
       run from within a pseudo terminal.  For usage in  a  real  application,
       you should check the return values of getpwuid() and ttyname().

       #include <string.h>
       #include <stdlib.h>
       #include <pwd.h>
       #include <unistd.h>
       #include <utmp.h>

       int main(int argc, char *argv[])
       {
         struct utmp entry;

         system("echo before adding entry:;who");

         entry.ut_type=USER_PROCESS;
         entry.ut_pid=getpid();
         strcpy(entry.ut_line,ttyname(0)+strlen("/dev/"));
         /* only correct for ptys named /dev/tty[pqr][0-9a-z] */
         strcpy(entry.ut_id,ttyname(0)+strlen("/dev/tty"));
         time(&entry.ut_time);
         strcpy(entry.ut_user,getpwuid(getuid())->pw_name);
         memset(entry.ut_host,0,UT_HOSTSIZE);
         entry.ut_addr=0;
         setutent();
         pututline(&entry);

         system("echo after adding entry:;who");

         entry.ut_type=DEAD_PROCESS;
         memset(entry.ut_line,0,UT_LINESIZE);
         entry.ut_time=0;
         memset(entry.ut_user,0,UT_NAMESIZE);
         setutent();
         pututline(&entry);

         system("echo after removing entry:;who");

         endutent();
         return 0;
       }

FILES
       /var/run/utmp  database of currently logged-in users
       /var/log/wtmp  database of past user logins

CONFORMINGTO
       XPG 2, SVID 2, Linux FSSTND 1.2

       In  XPG2  and  SVID2   the function pututline() is documented to return
       void, and that is what it  does  on  many  systems  (AIX,  HPUX,  Linux
       libc5).  HPUX introduces a new function _pututline() with the prototype
       given above for pututline() (also found in Linux libc5).

       All these functions are  obsolete  now  on  non-Linux  systems.   POSIX
       1003.1-2001,  following  XPG4.2,  does not have any of these functions,
       but instead uses

       #include<utmpx.h>

       structutmpx*getutxent(void);
       structutmpx*getutxid(conststructutmpx*);
       structutmpx*getutxline(conststructutmpx*);
       structutmpx*pututxline(conststructutmpx*);
       voidsetutxent(void);
       voidendutxent(void);

       The utmpx structure is a superset of the  utmp  structure,  with  addi-
       tional  fields, and larger versions of the existing fields.  The corre-
       sponding files are often /var/*/utmpx and /var/*/wtmpx.

       Linux glibc on the other hand does not use utmpx since its utmp  struc-
       ture  is already large enough. The functions getutxent etc. are aliases
       for getutent etc.

SEEALSO
       utmp(5)



                                  1996-07-25                       GETUTENT(3)

CMSG_ALIGNfmodllroundfstrncmp
CMSG_FIRSTHDRfnmatchllroundlstrncpy
CMSG_NXTHDRfopenlocaleconvstrndup
CMSG_SPACEforkptylocaltimestrndupa
MB_CUR_MAXfpathconflockfstrnlen
MB_LEN_MAXfprintflogstrpbrk
__fbufsizefpurgelog10strptime
__flbffputclog1pstrrchr
__fpendingfputc_unlockedlogin_ttystrsep
__fpurgefputslogwtmpstrsignal
__freadablefputs_unlockedlongjmpstrspn
__freadingfputwclrand48strstr
__fsetlockingfputwc_unlockedlrintstrtod
__fwritablefputwslrintfstrtof
__fwritingfputws_unlockedlrintlstrtok
__malloc_hookfreadlroundstrtok_r
__setfpucwfread_unlockedlroundfstrtol
_flushlbffreelroundlstrtold
a64lfreeaddrinfolsearchstrtoll
abortfreehostentmakecontextstrtoq
absfreopenmallocstrtoul
acosfrexpmalloc_hookstrtoull
acoshfscanfmblenstrtouq
addmntentfseekmbrlenstrverscmp
allocafseekombrtowcstrxfrm
alphasortfsetposmbsinitsvc_destroy
argz_addftellmbsnrtowcssvc_freeargs
argz_add_sepftellombsrtowcssvc_getargs
argz_appendftimembstowcssvc_getcaller
argz_countftokmbtowcsvc_getreq
argz_createftrylockfilememalignsvc_getreqset
argz_create_sepftsmemccpysvc_register
argz_deletefts_childrenmemchrsvc_run
argz_extractfts_closememcmpsvc_sendreply
argz_insertfts_openmemcpysvc_unregister
argz_nextfts_readmemfrobsvcerr_auth
argz_replacefts_setmemmemsvcerr_decode
argz_stringifyftwmemmovesvcerr_noproc
asctimefunlockfilememrchrsvcerr_noprog
asinfwidememsetsvcerr_progvers
asinhfwprintfmkdtempsvcerr_systemerr
asprintffwritemkfifosvcerr_weakauth
assertfwrite_unlockedmkstempsvcfd_create
assert_perrorgai_strerrormktempsvcraw_create
atangammamktimesvctcp_create
atan2gammafmodfsvcudp_bufcreate
atanhgammalmpoolsvcudp_create
atexitgcvtmrand48swab
atofget_current_dir_namemtraceswapcontext
atoiget_myaddressmuntraceswprintf
atolgetaddrinfonansysconf
atollgetcnanfsyslog
atoqgetc_unlockednanlsystem
auth_destroygetcharnearbyinttan
authnone_creategetchar_unlockednearbyintftanh
authunix_creategetcwdnearbyintltcdrain
authunix_create_defaultgetdatenetlinktcflow
basenamegetdate_rnextaftertcflush
bcmpgetdelimnextafterftcgetattr
bcopygetdirentriesnextafterltcgetpgrp
bindresvportgetenvnexttowardtcgetsid
bsearchgetfsentnexttowardftcsendbreak
bstringgetfsfilenexttowardltcsetattr
btowcgetfsspecnftwtcsetpgrp
btreegetgrentnl_langinfotdelete
byteordergetgrgidnrand48telldir
bzerogetgrnamntohltempnam
callocgethostbyaddrntohstermios
callrpcgethostbynameon_exittfind
catclosegethostbyname2opendirtgamma
catgetsgethostbyname2_ropenlogtgammaf
catopengethostbyname_ropenptytgammal
cbrtgetipnodebyaddrpathconftimegm
ceilgetipnodebynamepclosetimelocal
ceilfgetlineperrortmpfile
ceillgetloadavgpmap_getmapstmpnam
cfgetispeedgetloginpmap_getporttoascii
cfgetospeedgetmntentpmap_rmtcalltolower
cfmakerawgetnameinfopmap_settoupper
cfsetispeedgetnetbyaddrpmap_unsettowctrans
cfsetospeedgetnetbynamepopentowlower
clearenvgetnetentposix_memaligntowupper
clearerrgetoptpowtrunc
clearerr_unlockedgetopt_longprintftruncf
clnt_broadcastgetopt_long_onlyprofiltruncl
clnt_callgetpasspsignaltsearch
clnt_controlgetprotobynameptsnamettyname
clnt_creategetprotobynumberputcttyname_r
clnt_destroygetprotoentputc_unlockedttyslot
clnt_freeresgetptputchartwalk
clnt_geterrgetpwputchar_unlockedtzset
clnt_pcreateerrorgetpwentputenvulimit
clnt_perrnogetpwnamputpwentundocumented
clnt_perrorgetpwuidputsungetc
clnt_spcreateerrorgetrpcbynamepututlineungetwc
clnt_sperrnogetrpcbynumberpututxlineunlocked_stdio
clnt_sperrorgetrpcentputwunlockpt
clntraw_creategetrpcportputwcunsetenv
clnttcp_creategetsputwc_unlockedupdwtmp
clntudp_bufcreategetservbynameputwcharusleep
clntudp_creategetservbyportputwchar_unlockedutmpname
clockgetserventqecvtva_arg
closedirgetttyentqecvt_rva_end
closeloggetttynamqfcvtva_start
cmsggetumaskqfcvt_rvalloc
confstrgetusershellqgcvtvasprintf
copysigngetutentqsortvdprintf
copysignfgetutidqueueverr
copysignlgetutlineraiseverrx
cosgetutxentrandversionsort
coshgetutxidrandomvfprintf
cryptgetutxlinercmdvfscanf
ctermidgetwre_compvfwprintf
ctimegetwcre_execvprintf
cuseridgetwc_unlockedreaddirvscanf
daemongetwcharreallocvsnprintf
dbgetwchar_unlockedrealpathvsprintf
dbopengetwdrecnovsscanf
difftimeglobregcompvswprintf
dirfdglobfreeregerrorvsyslog
dirnamegmtimeregexvwarn
divgrantptregexecvwarnx
dlclosegsignalregfreevwprintf
dlerrorhashregisterrpcwarn
dlopenhasmntoptremovewarnx
dlsymhcreateremquewcpcpy
dn_comphcreate_rres_initwcpncpy
dn_expandhdestroyres_mkquerywcrtomb
dprintfhdestroy_rres_querywcscasecmp
drand48herrorres_querydomainwcscat
dremhsearchres_searchwcschr
dysizehsearch_rres_sendwcscmp
ecvthstrerrorresolverwcscpy
ecvt_rhtonlrewindwcscspn
encrypthtonsrewinddirwcsdup
endfsenthypotrindexwcslen
endgrenticonvrintwcsncasecmp
endhostenticonv_closerintfwcsncat
endmntenticonv_openrintlwcsncmp
endnetentimaxabsroundwcsncpy
endprotoentindexroundfwcsnlen
endpwentinetroundlwcsnrtombs
endrpcentinet_addrrpcwcspbrk
endserventinet_atonrresvportwcsrchr
endttyentinet_lnaofrtnetlinkwcsrtombs
endusershellinet_makeaddrruserokwcsspn
endutentinet_netofscandirwcsstr
endutxentinet_networkscanfwcstok
envz_addinet_ntoaseed48wcstombs
envz_entryinet_ntopseekdirwcswidth
envz_getinet_ptonsetbufwctob
envz_mergeinfnansetbufferwctomb
envz_removeinitgroupssetenvwctrans
envz_stripinitstatesetfsentwctype
erand48insquesetgrentwcwidth
erfintrosethostentwmemchr
erfciruseroksetjmpwmemcmp
errisalnumsetkeywmemcpy
errnoisalphasetlinebufwmemmove
errxisasciisetlocalewmemset
ether_atonisattysetlogmaskwprintf
ether_aton_risblanksetmntentxdr
ether_hosttoniscntrlsetnetentxdr_accepted_reply
ether_lineisdigitsetprotoentxdr_array
ether_ntoaisgraphsetpwentxdr_authunix_parms
ether_ntoa_risinfsetrpcentxdr_bool
ether_ntohostislowersetserventxdr_bytes
execisnansetstatexdr_callhdr
execlisprintsetttyentxdr_callmsg
execleispunctsetusershellxdr_char
execlpisspacesetutentxdr_destroy
execvisuppersetutxentxdr_double
execvpiswalnumsetvbufxdr_enum
exitiswalphashm_openxdr_float
expiswblanksigaddsetxdr_free
expm1iswcntrlsigdelsetxdr_getpos
fabsiswctypesigemptysetxdr_inline
fabsfiswdigitsigfillsetxdr_int
fabsliswgraphsiginterruptxdr_long
fcloseiswlowersigismemberxdr_opaque
fclosealliswprintsiglongjmpxdr_opaque_auth
fcvtiswpunctsignbitxdr_pmap
fcvt_riswspacesigsetjmpxdr_pmaplist
fdopeniswuppersigsetopsxdr_pointer
feclearexceptiswxdigitsinxdr_reference
fegetenvisxdigitsinhxdr_rejected_reply
fegetexceptflagj0sleepxdr_replymsg
fegetroundj0fsnprintfxdr_setpos
feholdexceptj0lsprintfxdr_short
fenvj1sqrtxdr_string
feofj1fsrandxdr_u_char
feof_unlockedj1lsrand48xdr_u_int
feraiseexceptjnsrandomxdr_u_long
ferrorjnfsscanfxdr_u_short
ferror_unlockedjnlssignalxdr_union
fesetenvjrand48stdargxdr_vector
fesetexceptflagkey_decryptsessionstderrxdr_void
fesetroundkey_encryptsessionstdinxdr_wrapstring
fetestexceptkey_gendesstdioxdrmem_create
feupdateenvkey_secretkey_is_setstdio_extxdrrec_create
fflushkey_setsecretstdoutxdrrec_endofrecord
fflush_unlockedkillpgstpcpyxdrrec_eof
ffsklogctlstpncpyxdrrec_skiprecord
fgetcl64astrcasecmpxdrstdio_create
fgetc_unlockedlabsstrcatxprt_register
fgetgrentlcong48strchrxprt_unregister
fgetposldexpstrcmpy0
fgetpwentldivstrcolly0f
fgetslfindstrcpyy0l
fgets_unlockedlgammastrcspny1
fgetwclgamma_rstrdupy1f
fgetwc_unlockedlgammafstrdupay1l
fgetwslgammaf_rstrerroryn
fgetws_unlockedlgammalstrerror_rynf
filenolgammal_rstrfmonynl
fileno_unlockedllabsstrfry 
finitelldivstrftime 
flockfilellrintstring 
floorllrintfstrlen 
floorfllrintlstrncasecmp 


My Money 2.0.49
Personal financial software
Linux Kernel 2.6 2.6.32-rc8
Linux Kernel
GCstar 1.5.0
Personal collections manager
ImageMagick 6.5.7.9
ImageMagick image processing studio
BibleTime 2.4
Bible study software for Linux / KDE
PHP 5.3.1
Server-side, cross-platform, HTML embedded scripting language.
LFTP 4.0.4
Shell-like command line ftp client.
Tellico 2.1.1
Collection manager for books, music, videos, and bibliographies
Totem 2.28.4
Movie player for Gnome
GNOME 2.29.2
GNOME desktop environment
Free IT Magazines, White Papers, eBooks, and more !
Oracle Magazine

Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.

Vulnerability Management for Dummies

Get all the Facts and See How to Implement a Successful Vulnerability Management Program.

Website Magazine

Has tapped premier talent in the Internet industry for our content and each and every issue will contain practical advice and insights for website owners.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info