Report compiler in -d -bV. Clang compat.
[exim.git] / src / src / lookups / nis.c
CommitLineData
0a49a7a4 1/* $Cambridge: exim/src/src/lookups/nis.c,v 1.5 2009/11/16 19:50:38 nm4 Exp $ */
0756eb3c
PH
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
0a49a7a4 7/* Copyright (c) University of Cambridge 1995 - 2009 */
0756eb3c
PH
8/* See the file NOTICE for conditions of use and distribution. */
9
10#include "../exim.h"
11#include "lf_functions.h"
0756eb3c
PH
12
13#include <rpcsvc/ypclnt.h>
14
15
16/*************************************************
17* Open entry point *
18*************************************************/
19
20/* See local README for interface description. This serves for both
21the "nis" and "nis0" lookup types. */
22
e6d225ae 23static void *
0756eb3c
PH
24nis_open(uschar *filename, uschar **errmsg)
25{
26char *nis_domain;
27if (yp_get_default_domain(&nis_domain) != 0)
28 {
29 *errmsg = string_sprintf("failed to get default NIS domain");
30 return NULL;
31 }
32return nis_domain;
33}
34
35
36
37/*************************************************
38* Find entry point for nis *
39*************************************************/
40
41/* See local README for interface description. A separate function is used
42for nis0 because they are so short it isn't worth trying to use any common
43code. */
44
e6d225ae 45static int
0756eb3c
PH
46nis_find(void *handle, uschar *filename, uschar *keystring, int length,
47 uschar **result, uschar **errmsg, BOOL *do_cache)
48{
49int rc;
50uschar *nis_data;
51int nis_data_length;
52do_cache = do_cache; /* Placate picky compilers */
53if ((rc = yp_match(CS handle, CS filename, CS keystring, length,
54 CSS &nis_data, &nis_data_length)) == 0)
55 {
56 *result = string_copy(nis_data);
57 (*result)[nis_data_length] = 0; /* remove final '\n' */
58 return OK;
59 }
60return (rc == YPERR_KEY || rc == YPERR_MAP)? FAIL : DEFER;
61}
62
63
64
65/*************************************************
66* Find entry point for nis0 *
67*************************************************/
68
69/* See local README for interface description. */
70
e6d225ae 71static int
0756eb3c
PH
72nis0_find(void *handle, uschar *filename, uschar *keystring, int length,
73 uschar **result, uschar **errmsg, BOOL *do_cache)
74{
75int rc;
76uschar *nis_data;
77int nis_data_length;
78do_cache = do_cache; /* Placate picky compilers */
79if ((rc = yp_match(CS handle, CS filename, CS keystring, length + 1,
80 CSS &nis_data, &nis_data_length)) == 0)
81 {
82 *result = string_copy(nis_data);
83 (*result)[nis_data_length] = 0; /* remove final '\n' */
84 return OK;
85 }
86return (rc == YPERR_KEY || rc == YPERR_MAP)? FAIL : DEFER;
87}
88
6545de78
PP
89
90
91/*************************************************
92* Version reporting entry point *
93*************************************************/
94
95/* See local README for interface description. */
96
97#include "../version.h"
98
99void
100nis_version_report(FILE *f)
101{
102#ifdef DYNLOOKUP
103fprintf(f, "Library version: NIS: Exim version %s\n", EXIM_VERSION_STR);
104#endif
105}
106
107
e6d225ae
DW
108static lookup_info nis_lookup_info = {
109 US"nis", /* lookup name */
110 0, /* not abs file, not query style*/
111 nis_open, /* open function */
112 NULL, /* check function */
113 nis_find, /* find function */
114 NULL, /* no close function */
115 NULL, /* no tidy function */
6545de78
PP
116 NULL, /* no quoting function */
117 nis_version_report /* version reporting */
e6d225ae
DW
118};
119
120static lookup_info nis0_lookup_info = {
121 US"nis0", /* lookup name */
122 0, /* not absfile, not query style */
123 nis_open, /* sic */ /* open function */
124 NULL, /* check function */
125 nis0_find, /* find function */
126 NULL, /* no close function */
127 NULL, /* no tidy function */
6545de78
PP
128 NULL, /* no quoting function */
129 NULL /* no version reporting (redundant) */
e6d225ae
DW
130};
131
132#ifdef DYNLOOKUP
133#define nis_lookup_module_info _lookup_module_info
134#endif
135
136static lookup_info *_lookup_list[] = { &nis_lookup_info, &nis0_lookup_info };
137lookup_module_info nis_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 2 };
0756eb3c
PH
138
139/* End of lookups/nis.c */