Teonet library
0.4.7
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "config.h"
#include <pbl.h>
#include "teodb.h"
#include "conf.h"
#include "utils/utils.h"
Macros | |
#define | get_file_path(namespace) |
Functions | |
ksnTDBClass * | ksnTDBinit (void *ke) |
Initialize PBL KeyFile module. More... | |
void | ksnTDBdestroy (ksnTDBClass *kf) |
Destroy PBL KeyFile module. More... | |
void | ksnTDBnamespaceSet (ksnTDBClass *kf, const char *namespace) |
Set current namespace. More... | |
char * | ksnTDBnamespaceGet (ksnTDBClass *kf) |
Get current namespace. More... | |
void | ksnTDBnamespaceRemove (ksnTDBClass *kf, const char *namespace) |
Remove namespace and all it contains. More... | |
int | ksnTDBflush (ksnTDBClass *kf) |
Flush a key file. More... | |
void * | ksnTDBgetStr (ksnTDBClass *kf, const char *key, size_t *data_len) |
Get data by string key from default namespace. More... | |
void * | ksnTDBget (ksnTDBClass *kf, const void *key, size_t key_len, size_t *data_len) |
Get data by string key from default namespace. More... | |
int | ksnTDBsetStr (ksnTDBClass *kf, const char *key, void *data, size_t data_len) |
Add (insert or update) data by string key to default namespace. More... | |
int | ksnTDBset (ksnTDBClass *kf, const void *key, size_t key_len, void *data, size_t data_len) |
Add (insert or update) data by key to default namespace. More... | |
int | ksnTDBdeleteStr (ksnTDBClass *kf, const char *key) |
Delete all records with string key. More... | |
int | ksnTDBdelete (ksnTDBClass *kf, const void *key, size_t key_len) |
Delete all records with key. More... | |
void * | ksnTDBgetNsStr (ksnTDBClass *kf, const char *namespace, const char *key, size_t *data_len) |
Get data by string key from namespace. More... | |
void * | ksnTDBgetNs (ksnTDBClass *kf, const char *namespace, const void *key, size_t key_len, size_t *data_len) |
Get data by key from namespace. More... | |
int | ksnTDBsetNsStr (ksnTDBClass *kf, const char *namespace, const char *key, void *data, size_t data_len) |
Add (insert or update) data by string key to namespace. More... | |
int | ksnTDBsetNs (ksnTDBClass *kf, const char *namespace, const void *key, size_t key_len, void *data, size_t data_len) |
Add (insert or update) data by key to namespace. More... | |
int | ksnTDBdeleteNsStr (ksnTDBClass *kf, const char *namespace, const char *key) |
Delete all records with key. More... | |
int | ksnTDBdeleteNs (ksnTDBClass *kf, const char *namespace, const void *key, size_t key_len) |
Delete all records with key. More... | |
int | ksnTDBkeyList (ksnTDBClass *kf, const char *key, ksnet_stringArr *argv) |
Get list of keys //. More... | |
Teonet database module based at PBL KeyFile
Created on August 20, 2015, 4:33 PM
#define get_file_path | ( | namespace | ) |
Referenced by ksnTDBnamespaceRemove(), and ksnTDBnamespaceSet().
int ksnTDBdelete | ( | ksnTDBClass * | kf, |
const void * | key, | ||
size_t | key_len | ||
) |
Delete all records with key.
kf | Pointer to ksnTDBClass |
key | Binary key |
key_len | Key length |
References data, free(), ksnTDBClass::k, and ksnTDBget().
Referenced by event_cb(), ksnTDBdeleteNs(), and ksnTDBdeleteStr().
int ksnTDBdeleteNs | ( | ksnTDBClass * | kf, |
const char * | namespace, | ||
const void * | key, | ||
size_t | key_len | ||
) |
Delete all records with key.
kf | Pointer to ksnTDBClass |
namespace | String with namespace |
key | Binary key |
key_len | Key length |
References free(), ksnTDBdelete(), ksnTDBnamespaceGet(), and ksnTDBnamespaceSet().
Referenced by ksnTDBdeleteNsStr().
|
inline |
Delete all records with key.
kf | Pointer to ksnTDBClass |
namespace | String with namespace |
key | String with key |
References ksnTDBdeleteNs().
Referenced by test_3_4().
|
inline |
Delete all records with string key.
kf | Pointer to ksnTDBClass |
key | String with key |
References ksnTDBdelete().
Referenced by event_cb(), and test_3_3().
|
inline |
Destroy PBL KeyFile module.
kf | Pointer to ksnTDBClass |
References free(), and ksnTDBnamespaceSet().
Referenced by modules_destroy(), test_3_1(), test_3_2(), test_3_3(), test_3_4(), test_3_5(), and test_3_template().
|
inline |
void* ksnTDBget | ( | ksnTDBClass * | kf, |
const void * | key, | ||
size_t | key_len, | ||
size_t * | data_len | ||
) |
Get data by string key from default namespace.
kf | Pointer to ksnTDBClass |
key | String with key |
key_len | Key length |
data_len | [out] Length of data |
References data, ksnTDBClass::k, KSN_BUFFER_SM_SIZE, and malloc().
Referenced by event_cb(), ksnTDBdelete(), ksnTDBgetNs(), and ksnTDBgetStr().
void* ksnTDBgetNs | ( | ksnTDBClass * | kf, |
const char * | namespace, | ||
const void * | key, | ||
size_t | key_len, | ||
size_t * | data_len | ||
) |
Get data by key from namespace.
kf | Pointer to ksnTDBClass |
namespace | String with namespace |
key | Binary key |
key_len | Key length |
data_len | [out] Data length |
References data, free(), ksnTDBget(), ksnTDBnamespaceGet(), and ksnTDBnamespaceSet().
Referenced by ksnTDBgetNsStr().
|
inline |
Get data by string key from namespace.
kf | Pointer to ksnTDBClass |
namespace | String with namespace |
key | String with key |
data_len | [out] Data length |
References ksnTDBgetNs().
Referenced by test_3_4().
|
inline |
Get data by string key from default namespace.
kf | Pointer to ksnTDBClass |
key | String with key |
data_len | [out] Length of data |
References ksnTDBget().
Referenced by event_cb(), test_3_2(), and test_3_3().
ksnTDBClass* ksnTDBinit | ( | void * | ke | ) |
Initialize PBL KeyFile module.
ke | Pointer to ksnTDBClass |
References ksnTDBClass::defNameSpace, ksnTDBClass::k, ksnTDBClass::ke, ke, and malloc().
Referenced by modules_init(), test_3_1(), test_3_2(), test_3_3(), test_3_4(), test_3_5(), and test_3_template().
int ksnTDBkeyList | ( | ksnTDBClass * | kf, |
const char * | key, | ||
ksnet_stringArr * | argv | ||
) |
Get list of keys //.
kf | Pointer to ksnTDBClass |
key | |
argv | Pointer to ksnet_stringArr |
References ksnTDBClass::k, KSN_BUFFER_SM_SIZE, and ksnet_stringArrAdd().
Referenced by event_cb(), and test_3_5().
|
inline |
Get current namespace.
kf | Pointer to ksnTDBClass |
References ksnTDBClass::defNameSpace.
Referenced by ksnTDBdeleteNs(), ksnTDBgetNs(), and ksnTDBsetNs().
void ksnTDBnamespaceRemove | ( | ksnTDBClass * | kf, |
const char * | namespace | ||
) |
Remove namespace and all it contains.
kf | Pointer to ksnTDBClass |
namespace | String with namespace |
References get_file_path, and ksnTDBnamespaceSet().
Referenced by test_3_2(), test_3_3(), test_3_4(), and test_3_5().
void ksnTDBnamespaceSet | ( | ksnTDBClass * | kf, |
const char * | namespace | ||
) |
Set current namespace.
Set namespace to use in ksnTdbGet, ksnTdbSet and ksnTdbDelete functions to get, set or delete data without select namespace.
kf | Pointer to ksnTDBClass |
namespace | String with namespace |
References ksnTDBClass::defNameSpace, free(), get_file_path, and ksnTDBClass::k.
Referenced by event_cb(), ksnTDBdeleteNs(), ksnTDBdestroy(), ksnTDBgetNs(), ksnTDBnamespaceRemove(), ksnTDBsetNs(), test_3_2(), test_3_3(), and test_3_5().
int ksnTDBset | ( | ksnTDBClass * | kf, |
const void * | key, | ||
size_t | key_len, | ||
void * | data, | ||
size_t | data_len | ||
) |
Add (insert or update) data by key to default namespace.
kf | Pointer to ksnTDBClass |
key | Binary key |
key_len | Key length |
data | Pointer to data |
data_len | Data length |
References ksnTDBClass::k, and KSN_BUFFER_SM_SIZE.
Referenced by event_cb(), ksnTDBsetNs(), and ksnTDBsetStr().
int ksnTDBsetNs | ( | ksnTDBClass * | kf, |
const char * | namespace, | ||
const void * | key, | ||
size_t | key_len, | ||
void * | data, | ||
size_t | data_len | ||
) |
Add (insert or update) data by key to namespace.
kf | Pointer to ksnTDBClass |
namespace | String with namespace |
key | Binary key |
key_len | Key length |
data | Pointer to data |
data_len | [out] Data length |
References free(), ksnTDBnamespaceGet(), ksnTDBnamespaceSet(), and ksnTDBset().
Referenced by ksnTDBsetNsStr().
|
inline |
Add (insert or update) data by string key to namespace.
kf | Pointer to ksnTDBClass |
namespace | String with namespace |
key | String with key |
data | Pointer to data |
data_len | [out] Data length |
References ksnTDBsetNs().
Referenced by test_3_4().
|
inline |
Add (insert or update) data by string key to default namespace.
kf | Pointer to ksnTDBClass |
key | String with key |
data | Pointer to data |
data_len | Data length |
References ksnTDBset().
Referenced by event_cb(), test_3_2(), test_3_3(), and test_3_5().