]> arthur.barton.de Git - netatalk.git/blob - libatalk/acl/cache.h
Merge remote-tracking branch 'remotes/origin/branch-netatalk-2-1'
[netatalk.git] / libatalk / acl / cache.h
1 /*
2    $Id: cache.h,v 1.1 2009-02-02 11:55:01 franklahm Exp $
3    Copyright (c) 2008,2009 Frank Lahm <franklahm@gmail.com>
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
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
16 #ifndef LDAPCACHE_H
17 #define LDAPCACHE_H
18
19 /* 
20  * We need to cache all LDAP querie results, they just take too long.
21  * We do hashing with chaining. Two caches are needed:
22  * 1) name -> uuid, indexed by a hash(f(): hashstring) of the name
23  * 2) uuid -> name, indexed by a hash of the uuid(f(): hashuuid)
24  * Both hash funcs result in a value 0-255 with which we index a array.
25  * We malloc and free all elements as needed.
26  * The cache caches for CACHESECONDS.
27  */
28
29 #define CACHESECONDS 600
30
31 /******************************************************** 
32  * Interface
33  ********************************************************/
34
35 /* 
36  *   name: search for this name
37  *   type: of type USER or GROUP
38  *   uuid: if found copies uuid into this buffer
39  * returns 0 on success, !=0 if not found or on errors
40  */
41 extern int search_cachebyname( const char *name, uuidtype_t type, uuidp_t uuid);
42
43 /* 
44  *   inname: name
45  *   inuuid: uuid
46  *   type: USER or GROUP
47  *   (uid: unused)
48  * returns 0 on success, !=0 on memory errors
49  */
50 extern int add_cachebyname( const char *inname, const uuidp_t inuuid, const uuidtype_t type, const unsigned long uid);
51
52 /* same as above but for the uuid cache */
53 extern int search_cachebyuuid( uuidp_t uuidp, char **name, uuidtype_t *type);
54 extern int add_cachebyuuid( uuidp_t inuuid, const char *inname, uuidtype_t type, const unsigned long uid);
55
56 #endif /* LDAPCACHE_H */