1 .\" Copyright 2003 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under GPL
7 .\" Polished a bit, added a little, aeb
9 .TH SETALIASENT 3 2017-09-15 "GNU" "Linux Programmer's Manual"
11 setaliasent, endaliasent, getaliasent, getaliasent_r,
12 getaliasbyname, getaliasbyname_r \- read an alias entry
14 .B #include <aliases.h>
16 .B "void setaliasent(void);"
18 .B "void endaliasent(void);"
20 .B "struct aliasent *getaliasent(void);"
22 .BI "int getaliasent_r(struct aliasent *" result ","
24 .BI " char *" buffer ", size_t " buflen ", struct aliasent **" res );
26 .BI "struct aliasent *getaliasbyname(const char *" name );
28 .BI "int getaliasbyname_r(const char *" name ", struct aliasent *" result ,
30 .BI " char *" buffer ", size_t " buflen ", struct aliasent **" res );
32 One of the databases available with the Name Service Switch (NSS)
33 is the aliases database, that contains mail aliases.
34 (To find out which databases are supported, try
35 .IR "getent \-\-help" .)
36 Six functions are provided to access the aliases database.
40 function returns a pointer to a structure containing
41 the group information from the aliases database.
42 The first time it is called it returns the first entry;
43 thereafter, it returns successive entries.
47 function rewinds the file pointer to the beginning of the
52 function closes the aliases database.
55 is the reentrant version of the previous function.
56 The requested structure
57 is stored via the first argument but the programmer needs to fill the other
59 Not providing enough space causes the function to fail.
63 takes the name argument and searches the aliases database.
64 The entry is returned as a pointer to a
65 .IR "struct aliasent" .
67 .BR getaliasbyname_r ()
68 is the reentrant version of the previous function.
69 The requested structure
70 is stored via the second argument but the programmer needs to fill the other
72 Not providing enough space causes the function to fail.
82 char *alias_name; /* alias name */
83 size_t alias_members_len;
84 char **alias_members; /* alias name list */
93 .BR getaliasbyname_r ()
94 return a nonzero value on error.
96 The default alias database is the file
98 This can be changed in the
102 For an explanation of the terms used in this section, see
109 Interface Attribute Value
113 .BR getaliasent_r (),
114 .BR getaliasbyname_r ()
115 T} Thread safety MT-Safe locale
118 .BR getaliasbyname ()
119 T} Thread safety MT-Unsafe
123 These routines are glibc-specific.
124 The NeXT system has similar routines:
130 void alias_setent(void);
131 void alias_endent(void);
132 alias_ent *alias_getent(void);
133 alias_ent *alias_getbyname(char *name);
137 The following example compiles with
138 .IR "gcc example.c \-o example" .
139 It will dump all names in the alias database.
156 printf("Name: %s\en", al\->alias_name);
159 perror("reading alias");
172 .\" /etc/sendmail/aliases
174 .\" newaliases, postalias