source: trunk/client/src/dircache.h@ 971

Last change on this file since 971 was 969, checked in by Yuri Dario, 9 years ago

Use a forward reference to smbwrp_fileinfo instead of including the
header. ticket#274.

File size: 2.8 KB
Line 
1/*
2 Directory caching code for Netdrive plugins.
3 Copyright (C) netlabs.org 2010-2016
4*/
5
6#ifndef __DIRCACHE_H__
7#define __DIRCACHE_H__
8
9#include <limits.h>
10
11#define NDPL_LARGEFILES
12#define INCL_LONGLONG
13#include <ndextpl2.h>
14
15//
16// enable if not defined in your plugin
17//
18// dircache code uses only the fname field to scan the directory listing.
19// other fields are just passed to FNADD callback as are.
20//
21#if 0
22typedef struct smbwrp_fileinfo
23{
24 unsigned long long size;
25 unsigned long mtime;
26 unsigned type;
27 char fname[PATH_MAX];
28} smbwrp_fileinfo;
29#else
30
31// define as forward reference here
32typedef struct smbwrp_fileinfo smbwrp_fileinfo;
33
34#endif
35
36/*
37 * An entry in the directory cache contains one directory listing.
38 */
39typedef struct DirectoryCacheEntry
40{
41 struct DirectoryCacheEntry *pNext;
42 struct DirectoryCacheEntry *pPrev;
43
44 smbwrp_fileinfo *aInfos;
45 int cInfos;
46 int cInfosAllocated;
47
48 char *pszPath;
49 ULONG ulHash;
50 ULONG ulLastUpdateTime;
51 int fInvalid;
52} DirectoryCacheEntry;
53
54typedef struct DirectoryCache
55{
56 NDMUTEX mutex;
57
58 DirectoryCacheEntry *pEntriesHead;
59 DirectoryCacheEntry *pEntriesTail;
60 int cEntries;
61 int fEnabled;
62 unsigned long ulExpirationTime;
63 int cMaxEntries;
64 // resource handle, used only for per-share logging
65 void* resource;
66} DirectoryCache;
67
68enum {
69 CacheFault = 0,
70 CacheOk = 1
71};
72
73
74/* Directory cache helpers. */
75int dircache_create(DirectoryCache **ppdc, void* pRes, int cachetimeout, int cachedepth);
76void dircache_delete(DirectoryCache *pdc);
77
78/* callback for fsphAddFile32L */
79typedef void FNADDDIRENTRY(const char *mnt, smbwrp_fileinfo *finfo,
80 const char *mask, void *state);
81typedef FNADDDIRENTRY *PFNADDDIRENTRY;
82
83/* directory cache scanning */
84int dircache_list_files(DirectoryCache *pdc, PFNADDDIRENTRY fn,
85 void *plist,
86 char* dir_mask, char* fullpath,
87 int *ptotal_received);
88int dircache_find_path(DirectoryCache *pdc,
89 const char *path,
90 smbwrp_fileinfo *finfo,
91 unsigned long *pulAge);
92
93/* directory cache creation */
94void *dircache_write_begin(DirectoryCache *pdc,
95 char* dir_mask, char* fullpath,
96 int cFiles);
97void dircache_write_entry(DirectoryCache *pdc, void *dircachectx,
98 const smbwrp_fileinfo *finfo);
99void dircache_write_end(DirectoryCache *pdc, void *dircachectx);
100
101/* directory cache invalidation */
102void dircache_invalidate(DirectoryCache *pdc,
103 const char *path,
104 int fParent);
105
106#endif // __DIRCACHE_H__
Note: See TracBrowser for help on using the repository browser.