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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/*
* Buxton
*
* Copyright (C) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stdint.h>
#include <sys/types.h>
#include <glib.h>
#include "buxton2.h"
#include "buxton_error.h"
#ifndef CONFPATH
# warning "CONFPATH is not set. default value is used"
# define CONFPATH "/etc/buxton.conf"
#endif
#ifndef MODULE_DIR
# warning "MODULE_DIR is not set. default value is used"
# define MODULE_DIR "/usr/lib/buxton"
#endif
#ifndef BASE_DB_DIR
# warning "BASE_DB_DIR is not set. default value is used"
# define BASE_DB_DIR "/var/lib/buxton"
#endif
#ifndef DB_DIR
# warning "DB_DIR is not set. default value is used"
# define DB_DIR "/var/lib/buxton"
#endif
#ifndef TMPFS_DIR
# warning "TMPFS_DIR is not set. default value is used"
# define TMPFS_DIR "/run/buxton"
#endif
#ifndef SOCKPATH
# warning "SOCKPATH is not set. default value is used"
# define SOCKPATH "/run/buxton-0"
#endif
/*
LAYER_SYSTEM - STORAGE_PERSISTENT - LAYER_ATTRIBUTE_RO
\ - LAYER_ATTRIBUTE_RW
STORAGE_VOLATILE - LAYER_ATTRIBUTE_RO
- LAYER_ATTRIBUTE_RW
LAYER_USER - ...
*/
enum layer_type {
LAYER_UNKNWON = 0,
LAYER_SYSTEM,
LAYER_USER,
LAYER_MAX, /* sentinel value */
};
enum storage_type {
STORAGE_UNKNOWN = 0,
STORAGE_PERSISTENT,
STORAGE_VOLATILE,
STORAGE_MAX, /* sentinel value */
};
enum layer_attribute_type {
LAYER_ATTRIBUTE_RW = BUXTON_LAYER_NORMAL,
LAYER_ATTRIBUTE_RO = BUXTON_LAYER_BASE,
LAYER_ATTRIBUTE_MAX = BUXTON_LAYER_MAX, /* sentinel value */
};
struct layer {
gchar *name;
enum layer_type type;
gchar *backend;
enum storage_type storage;
gchar *description;
};
enum value_type {
VALUE_TYPE_UNKNOWN = BUXTON_TYPE_UNKNOWN, /**< Unknown type */
VALUE_TYPE_STRING = BUXTON_TYPE_STRING, /**< String type */
VALUE_TYPE_INT32 = BUXTON_TYPE_INT32, /**< 32bit integer type */
VALUE_TYPE_UINT32 = BUXTON_TYPE_UINT32, /**< 32bit unsigned integer type */
VALUE_TYPE_INT64 = BUXTON_TYPE_INT64, /**< 64bit integer type */
VALUE_TYPE_UINT64 = BUXTON_TYPE_UINT64, /**< 64bit unsigned integer type */
VALUE_TYPE_DOUBLE = BUXTON_TYPE_DOUBLE, /**< double-precision float type */
VALUE_TYPE_BOOLEAN = BUXTON_TYPE_BOOLEAN, /**< boolean type */
VALUE_TYPE_MAX = BUXTON_TYPE_MAX /* sentinel value */
};
enum priv_type {
PRIV_READ = BUXTON_PRIV_READ, /**< Read privilege type */
PRIV_WRITE = BUXTON_PRIV_WRITE, /**< Write privilege type */
};
enum message_type {
MSG_UNKNOWN = 0,
/* basic request */
MSG_SET,
MSG_GET,
MSG_CREAT,
MSG_UNSET,
MSG_LIST,
MSG_NOTIFY,
MSG_UNNOTIFY,
MSG_NOTI,
/* privilege request */
MSG_SET_WP,
MSG_SET_RP,
MSG_GET_WP,
MSG_GET_RP,
/* Daemon control request */
MSG_CTRL,
MSG_MAX, /* sentinel value */
};
struct buxton_layer {
int refcnt;
char *name;
uid_t uid;
enum layer_attribute_type type;
};
int layer_create(const char *layer_name, struct buxton_layer **layer);
void layer_free(struct buxton_layer *layer);
struct buxton_layer *layer_ref(struct buxton_layer *layer);
struct buxton_layer *layer_unref(struct buxton_layer *layer);
struct buxton_value {
enum value_type type;
union {
char *s;
int32_t i;
uint32_t u;
int64_t i64;
uint64_t u64;
double d;
int32_t b;
} value;
};
void value_free(struct buxton_value *val);
void key_list_free(char **keys);
int get_search_key(const struct buxton_layer *layer, const char *key,
const char *uid, char **layer_key);
|