1 .\" Copyright 2003 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" Distributed under GPL
4 .\" Polished a bit, added a little, aeb
6 .TH SETALIASENT 3 2003-09-09 "GNU" "access mail aliases database"
8 setaliasent, endaliasent, getaliasent, getaliasent_r,
9 getaliasbyname, getaliasbyname_r \- read an alias entry
11 .B #include <aliases.h>
13 .BI "void setaliasent(void);"
15 .BI "void endaliasent(void);"
17 .BI "struct aliasent *getaliasent(void);"
19 .BI "int getaliasent_r(struct aliasent *" result ","
21 .BI " char *" buffer ", size_t " buflen ", struct aliasent **" res );
23 .BI "struct aliasent *getaliasbyname(const char *" name );
25 .BI "int getaliasbyname_r(const char *" name ", struct aliasent *" result ,
27 .BI " char *" buffer ", size_t " buflen ", struct aliasent **" res );
29 One of the databases available with the Name Service Switch (NSS)
30 is the aliases database, that contains mail aliases. (To find out
31 which databases are supported, try getent \-\-help .)
32 Six functions are provided to access the aliases database.
36 function returns a pointer to a structure containing
37 the group information from the aliases database.
38 The first time it is called it returns the first entry;
39 thereafter, it returns successive entries.
43 function rewinds the file pointer to the beginning of the
48 function closes the aliases database.
51 is the reentrant version of the previous function.
52 The requested structure
53 is stored via the first argument but the programmer needs to fill the other
55 Not providing enough space causes the function to fail.
59 takes the name argument and searches the aliases database.
60 The entry is returned as a pointer to a
61 .IR "struct aliasent" .
63 .BR getaliasbyname_r ()
64 is the reentrant version of the previous function.
65 The requested structure
66 is stored via the second argument but the programmer needs to fill the other
68 Not providing enough space causes the function to fail.
77 char *alias_name; /* alias name */
78 size_t alias_members_len;
79 char **alias_members; /* alias name list */
84 The default alias database is the file
86 This can be changed in the
93 .BR getaliasbyname_r ()
94 return a non-zero value on error.
96 The following example compiles with
97 .IR "gcc example.c \-o example" .
98 It will dump all names in the alias database.
115 printf("Name: %s\\n", al->alias_name);
118 perror("reading alias");
126 These routines are glibc-specific.
127 The NeXT has similar routines
131 void alias_setent(void);
132 void alias_endent(void);
133 alias_ent *alias_getent(void);
134 alias_ent *alias_getbyname(char *name);
143 .\" /etc/sendmail/aliases
145 .\" newaliases, postalias