⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getpwent.html

📁 posix标准英文,html格式
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2004 IEEE and The Open Group, All Rights Reserved --><title>endpwent</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="endpwent"></a> <a name="tag_03_121"></a><!-- endpwent --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright &copy; 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_121_01"></a>NAME</h4><blockquote>endpwent, getpwent, setpwent - user database functions</blockquote><h4><a name="tag_03_121_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include &lt;<a href="../basedefs/pwd.h.html">pwd.h</a>&gt;<br><br> void endpwent(void);<br> struct passwd *getpwent(void);<br> void setpwent(void); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_121_03"></a>DESCRIPTION</h4><blockquote><p>These functions shall retrieve information about users.</p><p>The <i>getpwent</i>() function shall return a pointer to a structure containing the broken-out fields of an entry in the userdatabase. Each entry in the user database contains a <b>passwd</b> structure. When first called, <i>getpwent</i>() shall return apointer to a <b>passwd</b> structure containing the first entry in the user database. Thereafter, it shall return a pointer to a<b>passwd</b> structure containing the next entry in the user database. Successive calls can be used to search the entire userdatabase.</p><p>If an end-of-file or an error is encountered on reading, <i>getpwent</i>() shall return a null pointer.</p><p>An implementation that provides extended security controls may impose further implementation-defined restrictions on accessingthe user database. In particular, the system may deny the existence of some or all of the user database entries associated withusers other than the caller.</p><p>The <i>setpwent</i>() function effectively rewinds the user database to allow repeated searches.</p><p>The <i>endpwent</i>() function may be called to close the user database when processing is complete.</p><p>These functions need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe.</p></blockquote><h4><a name="tag_03_121_04"></a>RETURN VALUE</h4><blockquote><p>The <i>getpwent</i>() function shall return a null pointer on end-of-file or error.</p></blockquote><h4><a name="tag_03_121_05"></a>ERRORS</h4><blockquote><p>The <i>getpwent</i>(), <i>setpwent</i>(), and <i>endpwent</i>() functions may fail if:</p><dl compact><dt>[EIO]</dt><dd>An I/O error has occurred.</dd></dl><p>In addition, <i>getpwent</i>() and <i>setpwent</i>() may fail if:</p><dl compact><dt>[EMFILE]</dt><dd>{OPEN_MAX} file descriptors are currently open in the calling process.</dd><dt>[ENFILE]</dt><dd>The maximum allowable number of files is currently open in the system.</dd></dl><p>The return value may point to a static area which is overwritten by a subsequent call to <a href="../functions/getpwuid.html"><i>getpwuid</i>()</a>, <a href="../functions/getpwnam.html"><i>getpwnam</i>()</a>, or<i>getpwent</i>().<br></p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_121_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_121_06_01"></a>Searching the User Database</h5><p>The following example uses the <i>getpwent</i>() function to get successive entries in the user database, returning a pointer toa <b>passwd</b> structure that contains information about each user. The call to <i>endpwent</i>() closes the user database andcleans up.</p><pre><tt>#include &lt;pwd.h&gt;...struct passwd *p;...while ((p = getpwent ()) != NULL) {...}<br>endpwent();...</tt></pre></blockquote><h4><a name="tag_03_121_07"></a>APPLICATION USAGE</h4><blockquote><p>These functions are provided due to their historical usage. Applications should avoid dependencies on fields in the passworddatabase, whether the database is a single file, or where in the file system name space the database resides. Applications shoulduse <a href="../functions/getpwuid.html"><i>getpwuid</i>()</a> whenever possible because it avoids these dependencies.</p></blockquote><h4><a name="tag_03_121_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_121_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_121_10"></a>SEE ALSO</h4><blockquote><p><a href="endgrent.html"><i>endgrent</i>()</a>, <a href="getlogin.html"><i>getlogin</i>()</a>, <a href="getpwnam.html"><i>getpwnam</i>()</a>, <a href="getpwuid.html"><i>getpwuid</i>()</a>, the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/pwd.h.html"><i>&lt;pwd.h&gt;</i></a></p></blockquote><h4><a name="tag_03_121_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4, Version 2.</p></blockquote><h4><a name="tag_03_121_12"></a>Issue 5</h4><blockquote><p>Moved from X/OPEN UNIX extension to BASE.</p><p>Normative text previously in the APPLICATION USAGE section is moved to the RETURN VALUE section.</p><p>A note indicating that these functions need not be reentrant is added to the DESCRIPTION.</p></blockquote><h4><a name="tag_03_121_13"></a>Issue 6</h4><blockquote><p>In the DESCRIPTION, the note about reentrancy is expanded to cover thread-safety.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -