/********************************************************************************
|
* Copyright: (C) 2020 LingYun IoT System Studio
|
* All rights reserved.
|
*
|
* Filename: database.h
|
* Description: This library used to operate blob packet in sqlite database.
|
*
|
* Version: 1.0.0(2020年05月13日)
|
* Author: Guo Wenxue <guowenxue@gmail.com>
|
* ChangeLog: 1, Release initial version on "2020年05月13日 12时14分23秒"
|
*
|
********************************************************************************/
|
#ifndef _DATABASE_H_
|
#define _DATABASE_H_
|
|
#include "sqlite3.h"
|
|
#define SQL_COMMAND_LEN 256
|
|
/* description: open or create sqlite database if not exist
|
* input args:
|
* $db_file: sqlite database file name
|
* return value: <0: failure 0:ok
|
* */
|
extern int db_open(const char *db_file);
|
|
|
/* description: close sqlite database handler
|
* return value: none
|
*/
|
extern void db_close(void);
|
|
|
/* description: push a blob packet into database
|
* input args:
|
* $pack: blob packet data address
|
* $size: blob packet data bytes
|
* return value: <0: failure 0:ok
|
*/
|
extern int db_write(const void *pack, int size);
|
|
|
/* description: pop the first blob packet from database
|
* input args:
|
* $pack : blob packet output buffer address
|
* $size : blob packet output buffer size
|
* $byte : blob packet bytes
|
* $rowid: rowid of the record
|
* return value: <0: failure 0:ok
|
*/
|
extern int db_read(void *pack, int size, int *bytes, int *rowid);
|
|
|
/* description: remove the first blob packet from database
|
* input args:
|
* $rowid: rowid of the record
|
* return value: <0: failure 0:ok
|
*/
|
extern int db_remove(int rowid);
|
|
|
#endif /* ----- #ifndef _DATABASE_H_ ----- */
|