1 #ifndef AUTH_MAPPING_INCLUDED
2 #define AUTH_MAPPING_INCLUDED
3 /*
4   (C) 2012, 2013 Percona LLC and/or its affiliates
5 
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; version 2 of the License.
9 
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18 
19 */
20 
21 /**
22  @file
23 
24  PAM authentication for MySQL, interface for user mapping.
25 
26 */
27 
28 #include <stdlib.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /** Mapping iterator. It's not exposed outsude */
35 struct mapping_iter;
36 
37 /** Create iterator through mapping string.
38     Initially iterator set to position before first
39     key-value pair. On success non-NULL pointer returned, otherwise NULL */
40 struct mapping_iter *mapping_iter_new(const char *mapping_string);
41 
42 /** Move iterator to next key-value pair.
43     On success pointer to key position in string returned,
44     otherwise NULL */
45 const char *mapping_iter_next(struct mapping_iter *it);
46 
47 /** Finish iteration and release iterator */
48 void mapping_iter_free(struct mapping_iter *it);
49 
50 /** Get key at current iterator position. On success buf returned,
51     otherwise NULL */
52 char *mapping_iter_get_key(struct mapping_iter *it, char *buf, size_t buf_len);
53 
54 /** Get value at current iterator position. On success buf returned,
55     otherwise NULL */
56 char *mapping_iter_get_value(struct mapping_iter *it, char *buf, size_t buf_len);
57 
58 /** Get value by given key. On success value_buf returned,
59     otherwise NULL */
60 char *mapping_lookup_user(const char *key, char *value_buf, size_t value_buf_len,
61                         const char *mapping_string);
62 
63 /** Get service name for auth_string. On success buf returned,
64     otherwise NULL */
65 char *mapping_get_service_name(char *buf, size_t buf_len,
66                                const char *mapping_string);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif
73