File: cache.h

package info (click to toggle)
netatalk 2.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,716 kB
  • sloc: ansic: 85,115; sh: 10,385; perl: 1,703; makefile: 1,363
file content (40 lines) | stat: -rw-r--r-- 1,660 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
   $Id: cache.h,v 1.1 2009-02-02 11:55:01 franklahm Exp $
   Copyright (c) 2008,2009 Frank Lahm <franklahm@gmail.com>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
 
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 */

#ifndef LDAPCACHE_H
#define LDAPCACHE_H

/* 
 * We need to cache all LDAP querie results, they just take too long.
 * We do hashing with chaining. Two caches are needed:
 * 1) name -> uuid, indexed by a hash(f(): hashstring) of the name
 * 2) uuid -> name, indexed by a hash of the uuid(f(): hashuuid)
 * Both hash funcs result in a value 0-255 with which we index a array.
 * We malloc and free all elements as needed.
 * The cache caches for CACHESECONDS.
 */

#define CACHESECONDS 600

/******************************************************** 
 * Interface
 ********************************************************/

extern int search_cachebyname( const char *name, uuidtype_t *type, uuidp_t uuid);
extern int add_cachebyname( const char *inname, const uuidp_t inuuid, const uuidtype_t type, const unsigned long uid);
extern int search_cachebyuuid( uuidp_t uuidp, char **name, uuidtype_t *type);
extern int add_cachebyuuid( uuidp_t inuuid, const char *inname, uuidtype_t type, const unsigned long uid);

#endif /* LDAPCACHE_H */