]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 2003 Walter Harms (walter.harms@informatik.uni-oldenburg.de) |
2297bf0e | 2 | .\" |
38f20bb9 | 3 | .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE) |
fea681da | 4 | .\" Distributed under GPL |
38f20bb9 | 5 | .\" %%%LICENSE_END |
fea681da MK |
6 | .\" |
7 | .\" Polished a bit, added a little, aeb | |
8 | .\" | |
4b8c67d9 | 9 | .TH SETALIASENT 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da MK |
10 | .SH NAME |
11 | setaliasent, endaliasent, getaliasent, getaliasent_r, | |
12 | getaliasbyname, getaliasbyname_r \- read an alias entry | |
13 | .SH SYNOPSIS | |
14 | .B #include <aliases.h> | |
68e4db0a | 15 | .PP |
0daa9e92 | 16 | .B "void setaliasent(void);" |
68e4db0a | 17 | .PP |
0daa9e92 | 18 | .B "void endaliasent(void);" |
68e4db0a | 19 | .PP |
0daa9e92 | 20 | .B "struct aliasent *getaliasent(void);" |
68e4db0a | 21 | .PP |
fea681da MK |
22 | .BI "int getaliasent_r(struct aliasent *" result "," |
23 | .br | |
b9f02710 | 24 | .BI " char *" buffer ", size_t " buflen ", struct aliasent **" res ); |
68e4db0a | 25 | .PP |
fea681da | 26 | .BI "struct aliasent *getaliasbyname(const char *" name ); |
68e4db0a | 27 | .PP |
b9f02710 | 28 | .BI "int getaliasbyname_r(const char *" name ", struct aliasent *" result , |
fea681da | 29 | .br |
b9f02710 | 30 | .BI " char *" buffer ", size_t " buflen ", struct aliasent **" res ); |
fea681da MK |
31 | .SH DESCRIPTION |
32 | One of the databases available with the Name Service Switch (NSS) | |
c13182ef | 33 | is the aliases database, that contains mail aliases. |
c9942389 MK |
34 | (To find out which databases are supported, try |
35 | .IR "getent \-\-help" .) | |
fea681da MK |
36 | Six functions are provided to access the aliases database. |
37 | .PP | |
c13182ef | 38 | The |
63aa9df0 | 39 | .BR getaliasent () |
fea681da MK |
40 | function returns a pointer to a structure containing |
41 | the group information from the aliases database. | |
c13182ef | 42 | The first time it is called it returns the first entry; |
fea681da MK |
43 | thereafter, it returns successive entries. |
44 | .PP | |
c13182ef | 45 | The |
63aa9df0 | 46 | .BR setaliasent () |
fea681da MK |
47 | function rewinds the file pointer to the beginning of the |
48 | aliases database. | |
49 | .PP | |
c13182ef | 50 | The |
63aa9df0 | 51 | .BR endaliasent () |
fea681da MK |
52 | function closes the aliases database. |
53 | .PP | |
63aa9df0 | 54 | .BR getaliasent_r () |
c13182ef | 55 | is the reentrant version of the previous function. |
b9f02710 | 56 | The requested structure |
fea681da | 57 | is stored via the first argument but the programmer needs to fill the other |
b9f02710 MK |
58 | arguments also. |
59 | Not providing enough space causes the function to fail. | |
fea681da MK |
60 | .PP |
61 | The function | |
63aa9df0 | 62 | .BR getaliasbyname () |
c13182ef MK |
63 | takes the name argument and searches the aliases database. |
64 | The entry is returned as a pointer to a | |
65 | .IR "struct aliasent" . | |
fea681da | 66 | .PP |
63aa9df0 | 67 | .BR getaliasbyname_r () |
c13182ef | 68 | is the reentrant version of the previous function. |
b9f02710 | 69 | The requested structure |
f5ff0796 | 70 | is stored via the second argument but the programmer needs to fill the other |
c13182ef | 71 | arguments also. |
b9f02710 | 72 | Not providing enough space causes the function to fail. |
fea681da | 73 | .PP |
c13182ef | 74 | The |
b9f02710 | 75 | .I "struct aliasent" |
c13182ef | 76 | is defined in |
b9f02710 | 77 | .IR <aliases.h> : |
e646a1ba | 78 | .PP |
088a639b | 79 | .in +4n |
e646a1ba | 80 | .EX |
fea681da | 81 | struct aliasent { |
6beb1671 | 82 | char *alias_name; /* alias name */ |
c13182ef | 83 | size_t alias_members_len; |
b24ac2ee | 84 | char **alias_members; /* alias name list */ |
b9f02710 | 85 | int alias_local; |
fea681da | 86 | }; |
b8302363 | 87 | .EE |
088a639b | 88 | .in |
47297adb | 89 | .SH RETURN VALUE |
fea681da | 90 | The functions |
63aa9df0 | 91 | .BR getaliasent_r () |
fea681da | 92 | and |
63aa9df0 | 93 | .BR getaliasbyname_r () |
c7094399 | 94 | return a nonzero value on error. |
2b2581ee MK |
95 | .SH FILES |
96 | The default alias database is the file | |
97 | .IR /etc/aliases . | |
98 | This can be changed in the | |
99 | .I /etc/nsswitch.conf | |
100 | file. | |
764ae61f ZL |
101 | .SH ATTRIBUTES |
102 | For an explanation of the terms used in this section, see | |
103 | .BR attributes (7). | |
74714ea8 | 104 | .ad l |
764ae61f ZL |
105 | .TS |
106 | allbox; | |
107 | lbw19 lb lb | |
108 | l l l. | |
109 | Interface Attribute Value | |
110 | T{ | |
111 | .BR setaliasent (), | |
112 | .BR endaliasent (), | |
113 | .BR getaliasent_r (), | |
114 | .BR getaliasbyname_r () | |
115 | T} Thread safety MT-Safe locale | |
116 | T{ | |
117 | .BR getaliasent (), | |
118 | .BR getaliasbyname () | |
119 | T} Thread safety MT-Unsafe | |
120 | .TE | |
74714ea8 | 121 | .ad |
47297adb | 122 | .SH CONFORMING TO |
8382f16d | 123 | These routines are glibc-specific. |
9db92f16 | 124 | The NeXT system has similar routines: |
e646a1ba | 125 | .PP |
a6e2f128 | 126 | .in +4n |
e646a1ba | 127 | .EX |
2b2581ee | 128 | #include <aliasdb.h> |
31a7b24e | 129 | |
2b2581ee MK |
130 | void alias_setent(void); |
131 | void alias_endent(void); | |
132 | alias_ent *alias_getent(void); | |
133 | alias_ent *alias_getbyname(char *name); | |
b8302363 | 134 | .EE |
a6e2f128 | 135 | .in |
fea681da | 136 | .SH EXAMPLE |
c13182ef | 137 | The following example compiles with |
c65433e6 | 138 | .IR "gcc example.c \-o example" . |
fea681da | 139 | It will dump all names in the alias database. |
bdd915e2 MK |
140 | .PP |
141 | .EX | |
fea681da MK |
142 | #include <aliases.h> |
143 | #include <stdio.h> | |
144 | #include <stdlib.h> | |
145 | #include <errno.h> | |
146 | ||
c13182ef MK |
147 | int |
148 | main(void) | |
cf0a9ace MK |
149 | { |
150 | struct aliasent *al; | |
151 | setaliasent(); | |
152 | for (;;) { | |
153 | al = getaliasent(); | |
c13182ef | 154 | if (al == NULL) |
cf0a9ace | 155 | break; |
29059a65 | 156 | printf("Name: %s\\n", al\->alias_name); |
cf0a9ace MK |
157 | } |
158 | if (errno) { | |
159 | perror("reading alias"); | |
160 | exit(EXIT_FAILURE); | |
161 | } | |
162 | endaliasent(); | |
163 | exit(EXIT_SUCCESS); | |
fea681da | 164 | } |
bdd915e2 | 165 | .EE |
47297adb | 166 | .SH SEE ALSO |
fea681da MK |
167 | .BR getgrent (3), |
168 | .BR getpwent (3), | |
169 | .BR getspent (3), | |
170 | .BR aliases (5) | |
171 | .\" | |
172 | .\" /etc/sendmail/aliases | |
173 | .\" Yellow Pages | |
174 | .\" newaliases, postalias |