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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/* GIO - GLib Input, Output and Streaming Library
*
* Copyright (C) 2009 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* Author: Alexander Larsson <alexl@redhat.com>
*/
#ifndef __META_TREE_H__
#define __META_TREE_H__
#include <glib.h>
typedef struct _MetaTree MetaTree;
typedef struct _MetaLookupCache MetaLookupCache;
typedef enum {
META_KEY_TYPE_NONE,
META_KEY_TYPE_STRING,
META_KEY_TYPE_STRINGV
} MetaKeyType;
/* Note: These are called with the read-lock held, so
don't call any MetaTree operations */
typedef gboolean (*meta_tree_dir_enumerate_callback) (const char *entry,
guint64 last_changed,
gboolean has_children,
gboolean has_data,
gpointer user_data);
typedef gboolean (*meta_tree_keys_enumerate_callback) (const char *key,
MetaKeyType type,
gpointer value,
gpointer user_data);
/* MetaLookupCache is not threadsafe */
MetaLookupCache *meta_lookup_cache_new (void);
void meta_lookup_cache_free (MetaLookupCache *cache);
MetaTree *meta_lookup_cache_lookup_path (MetaLookupCache *cache,
const char *filename,
guint64 device,
gboolean for_write,
char **tree_path);
/* All public MetaTree calls are threadsafe */
MetaTree * meta_tree_open (const char *filename,
gboolean for_write);
MetaTree * meta_tree_lookup_by_name (const char *name,
gboolean for_write);
MetaTree * meta_tree_ref (MetaTree *tree);
void meta_tree_unref (MetaTree *tree);
void meta_tree_refresh (MetaTree *tree);
const char *meta_tree_get_filename (MetaTree *tree);
gboolean meta_tree_exists (MetaTree *tree);
MetaKeyType meta_tree_lookup_key_type (MetaTree *tree,
const char *path,
const char *key);
guint64 meta_tree_get_last_changed (MetaTree *tree,
const char *path);
char * meta_tree_lookup_string (MetaTree *tree,
const char *path,
const char *key);
char ** meta_tree_lookup_stringv (MetaTree *tree,
const char *path,
const char *key);
void meta_tree_enumerate_dir (MetaTree *tree,
const char *path,
meta_tree_dir_enumerate_callback callback,
gpointer user_data);
void meta_tree_enumerate_keys (MetaTree *tree,
const char *path,
meta_tree_keys_enumerate_callback callback,
gpointer user_data);
gboolean meta_tree_flush (MetaTree *tree);
gboolean meta_tree_unset (MetaTree *tree,
const char *path,
const char *key);
gboolean meta_tree_set_string (MetaTree *tree,
const char *path,
const char *key,
const char *value);
gboolean meta_tree_set_stringv (MetaTree *tree,
const char *path,
const char *key,
char **value);
gboolean meta_tree_remove (MetaTree *tree,
const char *path);
gboolean meta_tree_copy (MetaTree *tree,
const char *src,
const char *dest);
#endif /* __META_TREE_H__ */
|