Imported Upstream version 4.0.43
[platform/upstream/mtools.git] / dirCache.h
1 #ifndef MTOOLS_DIRCACHE_H
2 #define MTOOLS_DIRCACHE_H
3
4 /*  Copyright 1997,1999,2001-2003,2008,2009 Alain Knaff.
5  *  This file is part of mtools.
6  *
7  *  Mtools is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  Mtools is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include "stream.h"
22 typedef enum {
23         DCET_FREE,
24         DCET_USED,
25         DCET_END
26 } dirCacheEntryType_t;
27
28 #define DC_BITMAP_SIZE 128
29
30 typedef struct dirCacheEntry_t dirCacheEntry_t;
31
32 typedef struct dirCache_t {
33         struct dirCacheEntry_t **entries;
34         unsigned int nr_entries;
35         unsigned int nrHashed;
36         unsigned int bm0[DC_BITMAP_SIZE];
37         unsigned int bm1[DC_BITMAP_SIZE];
38         unsigned int bm2[DC_BITMAP_SIZE];
39 } dirCache_t;
40
41 int growDirCache(dirCache_t *cache, unsigned int slot);
42 dirCache_t *allocDirCache(Stream_t *Stream, unsigned int slot);
43 void freeDirCache(Stream_t *Stream);
44 dirCacheEntry_t *addFreeEntry(dirCache_t *Stream,
45                               unsigned int begin, unsigned int end);
46 dirCacheEntry_t *addFreeEndEntry(dirCache_t *Stream,
47                                  unsigned int begin, unsigned int end,
48                                  int isAtEnd);
49 dirCacheEntry_t *addEndEntry(dirCache_t *Stream, unsigned int pos);
50 dirCacheEntry_t *lookupInDircache(dirCache_t *Stream, unsigned int pos);
51 #endif