forked from jcline/fuse-google-drive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgd_cache.h
73 lines (54 loc) · 2.12 KB
/
gd_cache.h
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
fuse-google-drive: a fuse filesystem wrapper for Google Drive
Copyright (C) 2012 James Cline
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _GOOGLE_DRIVE_CACHE_H
#define _GOOGLE_DRIVE_CACHE_H
#include <libxml/tree.h>
#include <pthread.h>
struct str_t {
char *str;
size_t len;
};
// Do we need to represent folders differently from files?
// For the time being, ignore folders
struct gd_fs_entry_t {
char *author; // the file owner?
char *author_email;
char *lastModifiedBy; // do we even care about this?
char *lastModifiedBy_email;
char *filename; // 'title' in the XML from directory-list
char *resourceID;
char *src; // The url for downloading the file
struct str_t cache;
int cached;
unsigned long size; // file size in bytes, 'gd:quotaBytesUsed' in XML
char *md5; // 'docs:md5Checksum' in XML, might be useful later
// Add some data we can use in getattr()
// Linked list
struct gd_fs_entry_t *next;
};
// Since hsearch et al are likely not threadsafe we need to use a read write
// lock to prevent corruption. The write lock should only be taken when we
// need to add a new item.
// What to do about removing a file? Just mark the entry as invalid? There is
// no removal action for hsearch et al.
// Does this also need a condition variable?
struct gd_fs_lock_t {
pthread_rwlock_t *lock;
};
struct gd_fs_entry_t* gd_fs_entry_from_xml(xmlDocPtr xml, xmlNodePtr node);
struct gd_fs_entry_t* gd_fs_entry_find(const char* key);
int create_hash_table(size_t size, const struct gd_fs_entry_t* head);
void destroy_hash_table();
#endif