]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/nss-util.h
Merge pull request #1945 from phomes/indentation-fix
[thirdparty/systemd.git] / src / shared / nss-util.h
CommitLineData
c9fdc26e
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#pragma once
4
5/***
6 This file is part of systemd.
7
8 Copyright 2014 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
24#include <nss.h>
25#include <netdb.h>
ea30eb86 26#include <resolv.h>
c01ff965
LP
27#include <pwd.h>
28#include <grp.h>
29
c9fdc26e
LP
30
31#define NSS_GETHOSTBYNAME_PROTOTYPES(module) \
32enum nss_status _nss_##module##_gethostbyname4_r( \
33 const char *name, \
34 struct gaih_addrtuple **pat, \
35 char *buffer, size_t buflen, \
36 int *errnop, int *h_errnop, \
37 int32_t *ttlp) _public_; \
38enum nss_status _nss_##module##_gethostbyname3_r( \
39 const char *name, \
40 int af, \
41 struct hostent *host, \
42 char *buffer, size_t buflen, \
43 int *errnop, int *h_errnop, \
44 int32_t *ttlp, \
45 char **canonp) _public_; \
46enum nss_status _nss_##module##_gethostbyname2_r( \
47 const char *name, \
48 int af, \
49 struct hostent *host, \
50 char *buffer, size_t buflen, \
51 int *errnop, int *h_errnop) _public_; \
52enum nss_status _nss_##module##_gethostbyname_r( \
53 const char *name, \
54 struct hostent *host, \
55 char *buffer, size_t buflen, \
56 int *errnop, int *h_errnop) _public_
57
58#define NSS_GETHOSTBYADDR_PROTOTYPES(module) \
59enum nss_status _nss_##module##_gethostbyaddr2_r( \
60 const void* addr, socklen_t len, \
61 int af, \
62 struct hostent *host, \
63 char *buffer, size_t buflen, \
64 int *errnop, int *h_errnop, \
65 int32_t *ttlp) _public_; \
66enum nss_status _nss_##module##_gethostbyaddr_r( \
67 const void* addr, socklen_t len, \
68 int af, \
69 struct hostent *host, \
70 char *buffer, size_t buflen, \
71 int *errnop, int *h_errnop) _public_
72
73#define NSS_GETHOSTBYNAME_FALLBACKS(module) \
74enum nss_status _nss_##module##_gethostbyname2_r( \
75 const char *name, \
76 int af, \
77 struct hostent *host, \
78 char *buffer, size_t buflen, \
79 int *errnop, int *h_errnop) { \
80 return _nss_##module##_gethostbyname3_r( \
81 name, \
82 af, \
83 host, \
84 buffer, buflen, \
85 errnop, h_errnop, \
86 NULL, \
87 NULL); \
88} \
89enum nss_status _nss_##module##_gethostbyname_r( \
90 const char *name, \
91 struct hostent *host, \
92 char *buffer, size_t buflen, \
93 int *errnop, int *h_errnop) { \
ea30eb86
LP
94 enum nss_status ret = NSS_STATUS_NOTFOUND; \
95 \
96 if (_res.options & RES_USE_INET6) \
97 ret = _nss_##module##_gethostbyname3_r( \
98 name, \
99 AF_INET6, \
100 host, \
101 buffer, buflen, \
102 errnop, h_errnop, \
103 NULL, \
104 NULL); \
105 if (ret == NSS_STATUS_NOTFOUND) \
106 ret = _nss_##module##_gethostbyname3_r( \
c9fdc26e 107 name, \
ea30eb86 108 AF_INET, \
c9fdc26e
LP
109 host, \
110 buffer, buflen, \
111 errnop, h_errnop, \
112 NULL, \
113 NULL); \
ea30eb86 114 return ret; \
c01ff965
LP
115} \
116struct __useless_struct_to_allow_trailing_semicolon__
c9fdc26e
LP
117
118#define NSS_GETHOSTBYADDR_FALLBACKS(module) \
119enum nss_status _nss_##module##_gethostbyaddr_r( \
120 const void* addr, socklen_t len, \
121 int af, \
122 struct hostent *host, \
123 char *buffer, size_t buflen, \
124 int *errnop, int *h_errnop) { \
125 return _nss_##module##_gethostbyaddr2_r( \
126 addr, len, \
127 af, \
128 host, \
129 buffer, buflen, \
130 errnop, h_errnop, \
131 NULL); \
c01ff965
LP
132} \
133struct __useless_struct_to_allow_trailing_semicolon__
134
135#define NSS_GETPW_PROTOTYPES(module) \
136enum nss_status _nss_##module##_getpwnam_r( \
137 const char *name, \
138 struct passwd *pwd, \
139 char *buffer, size_t buflen, \
140 int *errnop) _public_; \
141enum nss_status _nss_mymachines_getpwuid_r( \
142 uid_t uid, \
143 struct passwd *pwd, \
144 char *buffer, size_t buflen, \
145 int *errnop) _public_
146
147#define NSS_GETGR_PROTOTYPES(module) \
148enum nss_status _nss_##module##_getgrnam_r( \
149 const char *name, \
150 struct group *gr, \
151 char *buffer, size_t buflen, \
152 int *errnop) _public_; \
153enum nss_status _nss_##module##_getgrgid_r( \
154 gid_t gid, \
155 struct group *gr, \
156 char *buffer, size_t buflen, \
157 int *errnop) _public_