40 #ifndef SYNCDB_API_H_INCLUDED
41 #define SYNCDB_API_H_INCLUDED
49 #define SYNCDB_AGENT_MAX_MSG_SIZE 8000
55 #define SYNCDB_TABLE_NAME_SIZE 32
60 #define SYNCDB_MAX_STR_LEN 256
65 #define SYNCDB_RECORD_MAX_SIZE (1024*64)
69 #define SYNCDB_TABLE_TYPE_RECORD 0
70 #define SYNCDB_TABLE_TYPE_STORABLE_RECORD 1
71 #define SYNCDB_TABLE_TYPE_AVL_TREE 2
72 #define SYNCDB_TABLE_TYPE_QUEUE 3
77 #define SYNCDB_ERROR (-1)
78 #define SYNCDB_MAX_CLIENTS (-2)
79 #define SYNCDB_DUPNAME (-3)
80 #define SYNCDB_NO_TABLE (-4)
81 #define SYNCDB_FULL (-5)
82 #define SYNCDB_SIZE (-6)
83 #define SYNCDB_NOT_FOUND (-7)
84 #define SYNCDB_SCHEMA_ERROR (-8)
85 #define SYNCDB_ENTRY_EXISTS (-9)
95 #define SYNCDB_TABLE_STAT_EXISTS (1 << 0)
104 #define SYNCDB_TABLE_STAT_CHANGED (1 << 1)
115 #define SYNCDB_TABLE_STAT_AVL_TREE_PURGED (1 << 2)
125 #define SYNCDB_TABLE_STAT_NEW_TABLE (1 << 3)
136 #define SYNCDB_TABLE_FLAG_STORABLE (1 << 0)
142 #define SYNCDB_TABLE_FLAG_NVRAM (1 << 1)
148 #define SYNCDB_TABLE_FLAG_FILE_LOAD (1 << 2)
155 #define SYNCDB_TABLE_FLAG_EXISTS (1 << 3)
162 #define SYNCDB_TABLE_FLAG_NSF (1 << 4)
235 #define SYNCDB_JSON_MAX_SCHEMA_SIZE (SYNCDB_RECORD_MAX_SIZE)
262 SYNCDB_JSON_NUMBER = 1,
263 SYNCDB_JSON_STRING = 2,
264 SYNCDB_JSON_ARRAY = 3
352 unsigned int node_schema_size,
354 unsigned int buf_size,
355 unsigned int *schema_size,
356 unsigned int data_element_size,
605 unsigned int table_version,
606 unsigned int max_elements,
607 unsigned int max_live_elements,
608 unsigned int node_size,
609 unsigned int key_size,
612 unsigned int schema_size);
644 unsigned int table_version,
645 unsigned int node_size,
648 unsigned int schema_size);
817 unsigned int field_offset,
818 unsigned int field_size);
858 int *delete_pending);
914 unsigned int field_offset,
915 unsigned int field_size,
917 int *delete_pending);
956 int *delete_pending);
997 int *delete_pending);
1015 unsigned int sync_mode,
1016 unsigned int max_msg_size);
int num_non_deleted_elements
Number of records that are not in delete-pending state.
int client_id
Unique Syncdb client identifier.
int table_type
If the table exists then this specifies the table type.
Integer size is not 1, 2, 4, or 8.
Data element has 8 or more bytes beyond last schema node.
int num_elements
Number of records in the table.
int syncdbTableDelete(syncdbClientHandle_t *client_id, char *table_name)
Delete specified table or all tables.
int syncdbAvlTableCreate(syncdbClientHandle_t *client_id, char *table_name, unsigned int table_version, unsigned int max_elements, unsigned int max_live_elements, unsigned int node_size, unsigned int key_size, unsigned int flags, char *schema, unsigned int schema_size)
Create AVL Table.
int syncdbUtilSchemaCreate(syncdbJsonNode_t *element_node, unsigned int node_schema_size, char *schema_buf, unsigned int buf_size, unsigned int *schema_size, unsigned int data_element_size, syncdbSchemaError_e *schema_error)
Generate a storable record schema.
int cmd_socket
Socket for sending commands to Syncdb process.
int client_id
syncdb client ID of the client for which to retrieve the status
The element has the same name as another element in the schema.
int syncdbTableStore(syncdbClientHandle_t *client_id, char *table_name, unsigned int nvram)
Store specified table or all tables into the file system.
int syncdbInsert(syncdbClientHandle_t *client_id, char *table_name, void *element, unsigned int size)
Insert a new entry into the AVL table.
Default value for an integer does not fit into size.
int syncdbClientStatusGet(syncdbClientHandle_t *client_id, syncdbClientStatus_t *client_status)
Get client information for the specified client ID.
struct syncdbJsonNode_s syncdbJsonNode_t
The JSON node definition.
int syncdbGet(syncdbClientHandle_t *client_id, char *table_name, void *element, unsigned int size, int *delete_pending)
Get an entry from the table.
int syncdbGetNextChanged(syncdbClientHandle_t *client_id, char *table_name, void *element, unsigned int size, int *delete_pending)
Get the Next Changed entry from the table.
unsigned int data_size
The size of this data element in bytes.
#define SYNCDB_MAX_STR_LEN
Maximum length for string fields used by syncdb.
syncdbSchemaError_e
The following errors may be reported during schema validation.
int syncdbClientRegister(char *client_name, syncdbClientHandle_t *client_id)
Register a new client with the syncdb.
int syncdbFieldGet(syncdbClientHandle_t *client_id, char *table_name, void *element, unsigned int size, unsigned int field_offset, unsigned int field_size, int flags_unchanged, int *delete_pending)
Get the specified field in an entry from the table.
#define SYNCDB_TABLE_NAME_SIZE
Maximum size of the text string that uniquely identifies a database table.
int syncdbNsfModeSet(syncdbClientHandle_t *client_id, unsigned int sync_mode, unsigned int max_msg_size)
Tell SyncDB that it should start or stop data sync with the backup manager.
unsigned int table_version
The version of the table.
unsigned int data_offset
Offset of this element from the beginning of the data buffer.
Data type is not Number, String or Array.
int syncdbFieldSet(syncdbClientHandle_t *client_id, char *table_name, void *element, unsigned int size, unsigned int field_offset, unsigned int field_size)
Set the specified field in an entry in the table.
int num_table_purges
Number of AVL tree purge events sent to the client.
int notify_socket
Socket for waiting on events from Syncdb process.
unsigned long long default_number
Default value for SYNCDB_JSON_NUMBER object.
The JSON node definition.
char * data_name
The unique identifier for this variable.
int num_commands
Total number of commands issued by this client.
Schema nodes overlap each other.
int syncdbGetNext(syncdbClientHandle_t *client_id, char *table_name, void *element, unsigned int size, int *delete_pending)
Get the Next entry from the table.
No node with offset set to 0.
char * default_string
Default value for SYNCDB_JSON_STRING object.
int syncdbClientDeregister(syncdbClientHandle_t *client_id)
Deregister a client from the syncdb.
int num_table_change_events
Total number of table-change notifications sent to the client.
Found an element with size equal to 0.
Default value for a string does not fit into size.
syncdbJsonDataType_e
The syncdb supports the following JSON data types: SYNCDB_JSON_NUMBER - A numeric value...
int syncdbRecordTableCreate(syncdbClientHandle_t *client_id, char *table_name, unsigned int table_version, unsigned int node_size, unsigned int flags, char *schema, unsigned int schema_size)
Create a Record Table.
int syncdbTableStatusGet(syncdbClientHandle_t *client_id, int num_tables, syncdbDataTableStatus_t *table_list)
Get Table Status as it pertains to the specified client.
int syncdbTableChangeNotify(syncdbClientHandle_t *client_id, char *table_name)
Notify this client about changes to the specified table.
pthread_mutex_t client_lock
Per-client semaphore.
Two schema nodes have an 8 or more byte gap between them.
Schema node offset plus size is larger than data element.
int syncdbTableChangeCheck(syncdbClientHandle_t *client_id, int timeout_secs)
Check whether any change notifications are pending for this client.
int syncdbSet(syncdbClientHandle_t *client_id, char *table_name, void *element, unsigned int size)
Set an entry in the table.
unsigned int table_status
Bit Mask.
unsigned int table_flags
Flags specified on table creation.
int syncdbDelete(syncdbClientHandle_t *client_id, char *table_name, void *element, unsigned int size)
Delete an entry from the AVL table.
int client_pid
Linux Process ID for this client.