278 lines
7.0 KiB
HTML
278 lines
7.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SETALIASENT</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SETALIASENT</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
setaliasent, endaliasent, getaliasent, getaliasent_r,
|
|
getaliasbyname, getaliasbyname_r - read an alias entry
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/aliases.h">aliases.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>void setaliasent(void);</B>
|
|
|
|
<P>
|
|
|
|
<B>void endaliasent(void);</B>
|
|
|
|
<P>
|
|
|
|
<B>struct aliasent *getaliasent(void);</B>
|
|
|
|
<P>
|
|
|
|
<B>int getaliasent_r(struct aliasent *</B><I>result</I><B>,</B>
|
|
|
|
<BR>
|
|
|
|
<B> char *</B><I>buffer</I><B>, size_t </B><I>buflen</I><B>, struct aliasent **</B><I>res</I><B>);</B>
|
|
|
|
<P>
|
|
|
|
<B>struct aliasent *getaliasbyname(const char *</B><I>name</I><B>);</B>
|
|
|
|
<P>
|
|
|
|
<B>int getaliasbyname_r(const char *</B><I>name</I><B>, struct aliasent *</B><I>result</I><B>,</B>
|
|
|
|
<BR>
|
|
|
|
<B> char *</B><I>buffer</I><B>, size_t </B><I>buflen</I><B>, struct aliasent **</B><I>res</I><B>);</B>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
One of the databases available with the Name Service Switch (NSS)
|
|
is the aliases database, that contains mail aliases.
|
|
(To find out which databases are supported, try
|
|
<I>getent --help</I>.)
|
|
|
|
Six functions are provided to access the aliases database.
|
|
<P>
|
|
|
|
The
|
|
<B>getaliasent</B>()
|
|
|
|
function returns a pointer to a structure containing
|
|
the group information from the aliases database.
|
|
The first time it is called it returns the first entry;
|
|
thereafter, it returns successive entries.
|
|
<P>
|
|
|
|
The
|
|
<B>setaliasent</B>()
|
|
|
|
function rewinds the file pointer to the beginning of the
|
|
aliases database.
|
|
<P>
|
|
|
|
The
|
|
<B>endaliasent</B>()
|
|
|
|
function closes the aliases database.
|
|
<P>
|
|
|
|
<B>getaliasent_r</B>()
|
|
|
|
is the reentrant version of the previous function.
|
|
The requested structure
|
|
is stored via the first argument but the programmer needs to fill the other
|
|
arguments also.
|
|
Not providing enough space causes the function to fail.
|
|
<P>
|
|
|
|
The function
|
|
<B>getaliasbyname</B>()
|
|
|
|
takes the name argument and searches the aliases database.
|
|
The entry is returned as a pointer to a
|
|
<I>struct aliasent</I>.
|
|
|
|
<P>
|
|
|
|
<B>getaliasbyname_r</B>()
|
|
|
|
is the reentrant version of the previous function.
|
|
The requested structure
|
|
is stored via the second argument but the programmer needs to fill the other
|
|
arguments also.
|
|
Not providing enough space causes the function to fail.
|
|
<P>
|
|
|
|
The
|
|
<I>struct aliasent</I>
|
|
|
|
is defined in
|
|
<I><<A HREF="file:///usr/include/aliases.h">aliases.h</A>></I>:
|
|
|
|
<P>
|
|
|
|
|
|
|
|
struct aliasent {
|
|
<BR> char *alias_name; /* alias name */
|
|
<BR> size_t alias_members_len;
|
|
<BR> char **alias_members; /* alias name list */
|
|
<BR> int alias_local;
|
|
};
|
|
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
The functions
|
|
<B>getaliasent_r</B>()
|
|
|
|
and
|
|
<B>getaliasbyname_r</B>()
|
|
|
|
return a nonzero value on error.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
The default alias database is the file
|
|
<I>/etc/aliases</I>.
|
|
|
|
This can be changed in the
|
|
<I>/etc/nsswitch.conf</I>
|
|
|
|
file.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>setaliasent</B>(),
|
|
|
|
<B>endaliasent</B>(),
|
|
|
|
<B>getaliasent_r</B>(),
|
|
|
|
<B>getaliasbyname_r</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe locale<BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>getaliasent</B>(),
|
|
|
|
<B>getaliasbyname</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Unsafe<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
These routines are glibc-specific.
|
|
The NeXT system has similar routines:
|
|
<P>
|
|
|
|
|
|
|
|
#include <<A HREF="file:///usr/include/aliasdb.h">aliasdb.h</A>>
|
|
<P>
|
|
void alias_setent(void);
|
|
void alias_endent(void);
|
|
alias_ent *alias_getent(void);
|
|
alias_ent *alias_getbyname(char *name);
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
The following example compiles with
|
|
<I>gcc example.c -o example</I>.
|
|
|
|
It will dump all names in the alias database.
|
|
<P>
|
|
|
|
|
|
#include <<A HREF="file:///usr/include/aliases.h">aliases.h</A>>
|
|
#include <<A HREF="file:///usr/include/stdio.h">stdio.h</A>>
|
|
#include <<A HREF="file:///usr/include/stdlib.h">stdlib.h</A>>
|
|
#include <<A HREF="file:///usr/include/errno.h">errno.h</A>>
|
|
<P>
|
|
int
|
|
main(void)
|
|
{
|
|
<BR> struct aliasent *al;
|
|
<BR> setaliasent();
|
|
<BR> for (;;) {
|
|
<BR> al = getaliasent();
|
|
<BR> if (al == NULL)
|
|
<BR> break;
|
|
<BR> printf("Name: %s\n", al->alias_name);
|
|
<BR> }
|
|
<BR> if (errno) {
|
|
<BR> perror("reading alias");
|
|
<BR> exit(EXIT_FAILURE);
|
|
<BR> }
|
|
<BR> endaliasent();
|
|
<BR> exit(EXIT_SUCCESS);
|
|
}
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getgrent">getgrent</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getpwent">getpwent</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getspent">getspent</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?5+aliases">aliases</A></B>(5)
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">FILES</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">ATTRIBUTES</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">EXAMPLE</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="10"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:56 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|