C99 initialisers
[exim.git] / src / src / lookups / passwd.c
... / ...
CommitLineData
1/*************************************************
2* Exim - an Internet mail transport agent *
3*************************************************/
4
5/* Copyright (c) University of Cambridge 1995 - 2015 */
6/* See the file NOTICE for conditions of use and distribution. */
7
8#include "../exim.h"
9
10
11
12/*************************************************
13* Open entry point *
14*************************************************/
15
16/* See local README for interface description */
17
18static void *
19passwd_open(const uschar * filename, uschar ** errmsg)
20{
21filename = filename; /* Keep picky compilers happy */
22errmsg = errmsg;
23return (void *)(-1); /* Just return something non-null */
24}
25
26
27
28
29/*************************************************
30* Find entry point for passwd *
31*************************************************/
32
33/* See local README for interface description */
34
35static int
36passwd_find(void * handle, const uschar * filename, const uschar * keystring,
37 int length, uschar ** result, uschar ** errmsg, uint * do_cache,
38 const uschar * opts)
39{
40struct passwd *pw;
41
42handle = handle; /* Keep picky compilers happy */
43filename = filename;
44length = length;
45errmsg = errmsg;
46do_cache = do_cache;
47
48if (!route_finduser(keystring, &pw, NULL)) return FAIL;
49*result = string_sprintf("*:%d:%d:%s:%s:%s", (int)pw->pw_uid, (int)pw->pw_gid,
50 pw->pw_gecos, pw->pw_dir, pw->pw_shell);
51return OK;
52}
53
54
55
56/*************************************************
57* Version reporting entry point *
58*************************************************/
59
60/* See local README for interface description. */
61
62#include "../version.h"
63
64void
65passwd_version_report(FILE *f)
66{
67#ifdef DYNLOOKUP
68fprintf(f, "Library version: passwd: Exim version %s\n", EXIM_VERSION_STR);
69#endif
70}
71
72static lookup_info _lookup_info = {
73 .name = US"passwd", /* lookup name */
74 .type = lookup_querystyle, /* query-style lookup */
75 .open = passwd_open, /* open function */
76 .check = NULL, /* no check function */
77 .find = passwd_find, /* find function */
78 .close = NULL, /* no close function */
79 .tidy = NULL, /* no tidy function */
80 .quote = NULL, /* no quoting function */
81 .version_report = passwd_version_report /* version reporting */
82};
83
84#ifdef DYNLOOKUP
85#define passwd_lookup_module_info _lookup_module_info
86#endif
87
88static lookup_info *_lookup_list[] = { &_lookup_info };
89lookup_module_info passwd_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
90
91/* End of lookups/passwd.c */