Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
app/teodb.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "embedded/jsmn/jsmn.h"
#include "modules/teodb_com.h"
#include "ev_mgr.h"

Macros

#define TDB_VERSION   "0.0.6"
 
#define APPNAME   _ANSI_MAGENTA "teodb" _ANSI_NONE
 
#define DEFAULT_NAMESPACE   "test"
 
#define BINARY   "BINARY"
 
#define JSON   "JSON"
 
#define JSON_LEN   4
 
#define get_data_type()
 Check data type and show message. More...
 

Typedefs

typedef struct json_param json_param
 JSON request parameters structure. More...
 

Functions

void event_cb (ksnetEvMgrClass *ke, ksnetEvMgrEvents event, void *data, size_t data_len, void *user_data)
 Teonet event handler. More...
 
int main (int argc, char **argv)
 Main application function. More...
 

Detailed Description

Author
Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Teonet database based at PBL KEYFILE: – C key file, C-KeyFile An open source C key file implementation, see pblKf functions

Features:

  • ultra fast B* tree implementation for random lookups
  • transaction handling
  • sequential access methods
  • embeddable small footprint, < 35 Kb
  • arbitrary size files, up to 4 terrabytes
  • arbitrary number of records per file, up to 2 ^ 48 records
  • duplicate keys
  • advanced key compression for minimal size B trees
  • keylength up to 255 bytes
  • regression test frame

The basic functions (commands) of the application:

  • set - set data to namespace by key
  • get - get data from namespace by key

whre:

  • Namespace is a filename of PBL KEYFILE
  • key is a duplicate key in PBL KEYFILE
  • data is a data saved in PBL KEYFILE

API:

CMD_D_SET = 129, ///< #129 Set data request: { key, data, data_len, id } } CMD_D_GET, ///< #130 Get data request: { key, id } } CMD_D_LIST, ///< #131 List request: { key, id } } CMD_D_GET_ANSWER, ///< #132 Get data response: { key, data, data_len, id } } CMD_D_LIST_ANSWER, ///< #133 List response: [ { key, id }, ... ]

CMD_D_LIST_LENGTH, ///< #134 List length request: { key, id } } CMD_D_LIST_LENGTH_ANSWER, ///< #135 List response: { listLength, key, id }

CMD_D_LIST_RANGE, ///< #136 List length request: { id, key, from, to } } ///< bynary data structure: typedef struct teo_db_data_range { uint32_t from; ///< From index (begin from zero) uint32_t to; ///< To index (not include)) }; CMD_D_LIST_RANGE_ANSWER, ///< #137 List response: { listLength, key, ID }

Subscribe:

EV_D_SET - #26 send event when database updated

Created on August 20, 2015, 3:36 PM

Macro Definition Documentation

#define APPNAME   _ANSI_MAGENTA "teodb" _ANSI_NONE

Referenced by event_cb().

#define BINARY   "BINARY"
#define DEFAULT_NAMESPACE   "test"

Referenced by event_cb().

#define get_data_type ( )
Value:
rd->data_len && \
rd->data_len > JSON_LEN && \
!strncmp(rd->data, JSON, JSON_LEN) ? 1 : 0; \
"Got cmd: %d, type: %s, from: %s\n", \
rd->cmd, data_type ? JSON : BINARY, rd->from \
)
#define JSON
Definition: app/teodb.c:74
#define rd
#define ksn_printf(ke, module, type, format,...)
Definition: src/utils/utils.h:55
#define ke
#define BINARY
Definition: app/teodb.c:73
#define JSON_LEN
Definition: app/teodb.c:75
#4 Debug message (normal)
Definition: src/utils/utils.h:37
#define APPNAME
Definition: app/teodb.c:69

Check data type and show message.

Referenced by event_cb().

#define JSON   "JSON"
#define JSON_LEN   4
#define TDB_VERSION   "0.0.6"

Referenced by main().

Typedef Documentation

typedef struct json_param json_param

JSON request parameters structure.

key data

Function Documentation

int main ( int  argc,
char **  argv 
)

Main application function.

Parameters
argc
argv
Returns

References event_cb(), ksnetEvMgrInit(), ksnetEvMgrRun(), READ_ALL, TDB_VERSION, teoGetLibteonetVersion(), teoSetAppType(), and teoSetAppVersion().