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 */
20typedef enum {
21	DCET_FREE,
22	DCET_USED,
23	DCET_END
24} dirCacheEntryType_t;
25
26#define DC_BITMAP_SIZE 128
27
28typedef struct dirCacheEntry_t {
29	dirCacheEntryType_t type;
30	unsigned int beginSlot;
31	unsigned int endSlot;
32	wchar_t *shortName;
33	wchar_t *longName;
34	struct directory dir;
35} dirCacheEntry_t;
36
37typedef struct dirCache_t {
38	struct dirCacheEntry_t **entries;
39	int nr_entries;
40	unsigned int nrHashed;
41	unsigned int bm0[DC_BITMAP_SIZE];
42	unsigned int bm1[DC_BITMAP_SIZE];
43	unsigned int bm2[DC_BITMAP_SIZE];
44} dirCache_t;
45
46int isHashed(dirCache_t *cache, wchar_t *name);
47int growDirCache(dirCache_t *cache, int slot);
48dirCache_t *allocDirCache(Stream_t *Stream, int slot);
49dirCacheEntry_t *addUsedEntry(dirCache_t *Stream, int begin, int end,
50			      wchar_t *longName, wchar_t *shortName,
51			      struct directory *dir);
52void freeDirCache(Stream_t *Stream);
53dirCacheEntry_t *addFreeEntry(dirCache_t *Stream,
54			      unsigned int begin, unsigned int end);
55dirCacheEntry_t *addEndEntry(dirCache_t *Stream, int pos);
56dirCacheEntry_t *lookupInDircache(dirCache_t *Stream, int pos);
57#endif
58