[svn-inject] Installing original source of libnss-mysql-bg
[manu/libnss-mysql-bg.git] / src / lookup.h
1 /* Copyright (C) 2002 Ben Goodwin
2    This file is part of the nss-mysql library.
3   
4    The nss-mysql library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License as published
6    by the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8   
9    The nss-mysql library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13    You should have received a copy of the GNU General Public License
14    along with the nss-mysql library; if not, write to the Free Software
15    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17
18 #include "nss_mysql.h"
19
20 #ifdef HAVE_NSS_H
21
22 #define SETENT(type)                                                         \
23     NSS_STATUS                                                               \
24     _nss_mysql_set##type (void)                                              \
25     {                                                                        \
26       DN ("_nss_mysql_set" #type)                                            \
27       DENTER                                                                 \
28       LOCK;                                                                  \
29       _nss_mysql_reset_ent (&mresult_##type);                                \
30       UNLOCK;                                                                \
31       DSRETURN (NSS_SUCCESS)                                                 \
32     }
33
34 #define ENDENT(type)                                                         \
35     NSS_STATUS                                                               \
36     _nss_mysql_end##type (void)                                              \
37     {                                                                        \
38       DN ("_nss_mysql_end" #type)                                            \
39       DENTER                                                                 \
40       LOCK;                                                                  \
41       _nss_mysql_reset_ent (&mresult_##type);                                \
42       UNLOCK;                                                                \
43       DSRETURN (NSS_SUCCESS)                                                 \
44     }
45
46 #elif defined (HAVE_NSS_COMMON_H)
47
48 #define SETENT(type)                                                         \
49     NSS_STATUS                                                               \
50     _nss_mysql_set##type (nss_backend_t *be, void *args)                     \
51     {                                                                        \
52       DN ("_nss_mysql_set" #type)                                            \
53       DENTER                                                                 \
54       LOCK;                                                                  \
55       _nss_mysql_reset_ent (&mresult_##type);                                \
56       UNLOCK;                                                                \
57       DSRETURN (NSS_SUCCESS)                                                 \
58     }
59
60 #define ENDENT(type)                                                         \
61     NSS_STATUS                                                               \
62     _nss_mysql_end##type (nss_backend_t *be, void *args)                     \
63     {                                                                        \
64       DN ("_nss_mysql_end" #type)                                            \
65       DENTER                                                                 \
66       LOCK;                                                                  \
67       _nss_mysql_reset_ent (&mresult_##type);                                \
68       UNLOCK;                                                                \
69       DSRETURN (NSS_SUCCESS)                                                 \
70     }
71
72 #define CONSTR(type)                                                         \
73     nss_backend_t *                                                          \
74     _nss_mysql_##type##_constr (const char *db_name, const char *src_name,   \
75                                 const char *cfg_args)                        \
76     {                                                                        \
77       DN ("_nss_mysql_" #type "_constr")                                     \
78       nss_backend_t *be;                                                     \
79       DENTER                                                                 \
80       be = (nss_backend_t *) malloc (sizeof (*be));                          \
81       if (!be)                                                               \
82         DPRETURN (NULL)                                                      \
83       be->ops = type##_ops;                                                  \
84       be->n_ops = sizeof (type##_ops) / sizeof (nss_backend_op_t);           \
85       DPRETURN (be)                                                          \
86     }
87 #endif
88