commit | author | age
|
29b331
|
1 |
/******************************************************************************** |
GW |
2 |
* Copyright: (C) 2020 LingYun IoT System Studio |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Filename: database.h |
|
6 |
* Description: This library used to operate blob packet in sqlite database. |
|
7 |
* |
|
8 |
* Version: 1.0.0(2020年05月13日) |
|
9 |
* Author: Guo Wenxue <guowenxue@gmail.com> |
|
10 |
* ChangeLog: 1, Release initial version on "2020年05月13日 12时14分23秒" |
|
11 |
* |
|
12 |
********************************************************************************/ |
|
13 |
#ifndef _DATABASE_H_ |
|
14 |
#define _DATABASE_H_ |
|
15 |
|
|
16 |
#include "sqlite3.h" |
|
17 |
|
|
18 |
#define SQL_COMMAND_LEN 256 |
|
19 |
|
|
20 |
/* description: open or create sqlite database if not exist |
|
21 |
* input args: |
|
22 |
* $db_file: sqlite database file name |
|
23 |
* return value: <0: failure 0:ok |
|
24 |
* */ |
|
25 |
extern int database_init(const char *db_file); |
|
26 |
|
|
27 |
|
|
28 |
/* description: close sqlite database handler |
|
29 |
* return value: none |
|
30 |
*/ |
|
31 |
extern void database_term(void); |
|
32 |
|
|
33 |
|
|
34 |
/* description: push a blob packet into database |
|
35 |
* input args: |
|
36 |
* $pack: blob packet data address |
|
37 |
* $size: blob packet data bytes |
|
38 |
* return value: <0: failure 0:ok |
|
39 |
*/ |
|
40 |
extern int database_push_packet(void *pack, int size); |
|
41 |
|
|
42 |
|
|
43 |
/* description: pop the first blob packet from database |
|
44 |
* input args: |
|
45 |
* $pack: blob packet output buffer address |
|
46 |
* $size: blob packet output buffer size |
|
47 |
* $byte: blob packet bytes |
|
48 |
* return value: <0: failure 0:ok |
|
49 |
*/ |
|
50 |
extern int database_pop_packet(void *pack, int size, int *bytes); |
|
51 |
|
|
52 |
|
|
53 |
/* description: remove the first blob packet from database |
|
54 |
* input args: none |
|
55 |
* return value: <0: failure 0:ok |
|
56 |
*/ |
|
57 |
extern int database_del_packet(void); |
|
58 |
|
|
59 |
|
|
60 |
#endif /* ----- #ifndef _DATABASE_H_ ----- */ |