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 ,
27 .BI " struct aliasent *" result ,
29 .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. (To find out
34 which databases are supported, try getent \-\-help .)
35 Six functions are provided to access the aliases database.
39 function returns a pointer to a structure containing
40 the group information from the aliases database.
41 The first time it is called it returns the first entry;
42 thereafter, it returns successive entries.
46 function rewinds the file pointer to the beginning of the
51 function closes the aliases database.
54 is the reentrant version of the previous function. The requested structure
55 is stored via the first argument but the programmer needs to fill the other
56 arguments also. Not providing enough space causes the function to fail.
60 takes the name argument and searches the aliases database. The entry is
61 returned as a pointer to a struct aliasent.
63 .BR getaliasbyname_r ()
64 is the reentrant version of the previous function. The requested structure
65 is stored via the second argument but the programmer need to fill the other
66 arguments also. Not providing enough space causes the function to fail.
68 The struct aliasent is defined in <aliases.h>.
71 char *alias_name; /* alias name */
72 size_t alias_members_len;
73 char **alias_members; /* alias name list */
78 The default alias database is the file
80 This can be changed in the
87 .BR getaliasbyname_r ()
88 return a non-zero value on error.
90 The following example compiles with
91 .IR "gcc example.c \-o example" .
92 It will dump all names in the alias database.
105 if (al == NULL) break;
106 printf("Name: %s\\n", al->alias_name);
109 perror("reading alias");
117 These routines are glibc-specific.
118 The NeXT has similar routines
122 void alias_setent(void);
123 void alias_endent(void);
124 alias_ent *alias_getent(void);
125 alias_ent *alias_getbyname(char *name);
134 .\" /etc/sendmail/aliases
136 .\" newaliases, postalias