Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/getgrnam.html
2024-02-19 00:21:47 -05:00

218 lines
8.5 KiB
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 The Open Group, All Rights Reserved -->
<title>getgrnam</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="getgrnam"></a> <a name="tag_03_223"></a><!-- getgrnam -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_223_01"></a>NAME</h4>
<blockquote>getgrnam, getgrnam_r - search group database for a name</blockquote>
<h4><a name="tag_03_223_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><code><tt>#include &lt;<a href="../basedefs/grp.h.html">grp.h</a>&gt;<br>
<br>
struct group *getgrnam(const char *</tt><i>name</i><tt>);<br>
</tt></code></p>
<div class="box"><code><tt><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> int getgrnam_r(const char *</tt><i>name</i><tt>, struct group *</tt><i>grp</i><tt>, char
*</tt><i>buffer</i><tt>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size_t</tt> <i>bufsize</i><tt>, struct group **</tt><i>result</i><tt>); <img src=
"../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
<tt><br>
</tt></blockquote>
<h4><a name="tag_03_223_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>getgrnam</i>() function shall search the group database for an entry with a matching <i>name</i>.</p>
<p>The <i>getgrnam</i>() function need not be reentrant. A function that is not required to be reentrant is not required to be
thread-safe.</p>
<p><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The <i>getgrnam_r</i>() function shall update the <b>group</b> structure pointed to by <i>grp</i> and store a pointer to that
structure at the location pointed to by <i>result</i>. The structure shall contain an entry from the group database with a matching
<i>gid</i> or <i>name</i>. Storage referenced by the <b>group</b> structure is allocated from the memory provided with the
<i>buffer</i> parameter, which is <i>bufsize</i> bytes in size. The maximum size needed for this buffer can be determined with the
{_SC_GETGR_R_SIZE_MAX} <a href="../functions/sysconf.html"><i>sysconf</i>()</a> parameter. A NULL pointer is returned at the
location pointed to by <i>result</i> on error or if the requested entry is not found. <img src="../images/opt-end.gif" alt=
"[Option End]" border="0"></p>
</blockquote>
<h4><a name="tag_03_223_04"></a>RETURN VALUE</h4>
<blockquote>
<p>The <i>getgrnam</i>() function shall return a pointer to a <b>struct group</b> with the structure defined in <a href=
"../basedefs/grp.h.html"><i>&lt;grp.h&gt;</i></a> with a matching entry if one is found. The <i>getgrnam</i>() function shall
return a null pointer if either the requested entry was not found, or an error occurred. On error, <i>errno</i> shall be set to
indicate the error.</p>
<p>The return value may point to a static area which is overwritten by a subsequent call to <a href=
"../functions/getgrent.html"><i>getgrent</i>()</a>, <a href="../functions/getgrgid.html"><i>getgrgid</i>()</a>, or
<i>getgrnam</i>().</p>
<p><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If successful, the <i>getgrnam_r</i>() function shall return zero; otherwise, an error number shall be returned to indicate the
error. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
</blockquote>
<h4><a name="tag_03_223_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>getgrnam</i>() and <i>getgrnam_r</i>() functions may fail if:</p>
<dl compact>
<dt>[EIO]</dt>
<dd>An I/O error has occurred.</dd>
<dt>[EINTR]</dt>
<dd>A signal was caught during <i>getgrnam</i>().</dd>
<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 <i>getgrnam_r</i>() function may fail if:</p>
<dl compact>
<dt>[ERANGE]</dt>
<dd><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Insufficient storage was supplied via <i>buffer</i> and <i>bufsize</i> to contain the data to be referenced by the resulting
<b>group</b> structure. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
</dl>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_223_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_223_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>Applications wishing to check for error situations should set <i>errno</i> to 0 before calling <i>getgrnam</i>(). If
<i>errno</i> is set on return, an error occurred.</p>
<p>The <i>getgrnam_r</i>() function is thread-safe and shall return values in a user-supplied buffer instead of possibly using a
static data area that may be overwritten by each call.</p>
</blockquote>
<h4><a name="tag_03_223_08"></a>RATIONALE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_223_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_223_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="endgrent.html"><i>endgrent</i>()</a> , <a href="getgrgid.html"><i>getgrgid</i>()</a> , the Base Definitions volume of
IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/grp.h.html"><i>&lt;grp.h&gt;</i></a>, <a href=
"../basedefs/limits.h.html"><i>&lt;limits.h&gt;</i></a>, <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_223_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 1. Derived from System V Release 2.0.</p>
</blockquote>
<h4><a name="tag_03_223_12"></a>Issue 5</h4>
<blockquote>
<p>Normative text previously in the APPLICATION USAGE section is moved to the RETURN VALUE section.</p>
<p>The <i>getgrnam_r</i>() function is included for alignment with the POSIX Threads Extension.</p>
<p>A note indicating that the <i>getgrnam</i>() function need not be reentrant is added to the DESCRIPTION.</p>
</blockquote>
<h4><a name="tag_03_223_13"></a>Issue 6</h4>
<blockquote>
<p>The <i>getgrnam_r</i>() function is marked as part of the Thread-Safe Functions option.</p>
<p>In the DESCRIPTION, the note about reentrancy is expanded to cover thread-safety.</p>
<p>In the SYNOPSIS, the optional include of the <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> header is
removed.</p>
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
<ul>
<li>
<p>The requirement to include <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> has been removed. Although <a
href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> was required for conforming implementations of previous POSIX
specifications, it was not required for UNIX applications.</p>
</li>
<li>
<p>In the RETURN VALUE section, the requirement to set <i>errno</i> on error is added.</p>
</li>
<li>
<p>The [EIO], [EINTR], [EMFILE], and [ENFILE] optional error conditions are added.</p>
</li>
</ul>
<p>The APPLICATION USAGE section is updated to include a note on the thread-safe function and its avoidance of possibly using a
static data area.</p>
<p>IEEE PASC Interpretation 1003.1 #116 is applied, changing the description of the size of the buffer from <i>bufsize</i>
characters to bytes.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<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>