APUE Learning Example Source Code
guowenxue
2020-06-07 8a383b8715fc07145fdc3f3e3dbe6ecd93f72989
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/********************************************************************************
 *      Copyright:  (C) 2020 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  sqlite_cli.h
 *    Description:  This head file is for client to save TLV packet in sqlite.
 *
 *        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  _SQLITE_CLI_H_
#define  _SQLITE_CLI_H_
 
#include "sqlite3.h"
#include "tlv_pack.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 clidb_init(const char *db_file);
 
 
/*  description: close sqlite database handler
 * return value: none
 */
extern void clidb_term(void);
 
 
/*  description: push TLV packet into database
 *   input args:
 *               $pack:  tlv packet pointer 
 * return value: <0: failure   0:ok
 */
extern int clidb_push_tlvpack(tlv_buf_t *pack);
 
 
/*  description: pop one TLV packet from database
 *   input args: 
 *               $pack:  tlv packet pointer 
 *               $id:    item ID pointer, which can be used as key when remove
 * return value: <0: failure   0:ok
 */
extern int clidb_pop_tlvpack(tlv_buf_t *pack, int *id);
 
 
/*  description: remove sepcified TLV packet from database
 *   input args: 
 *               $id:    remove item ID
 * return value: <0: failure   0:ok
 */
extern int clidb_del_tlvpack(int id);
 
 
#endif   /* ----- #ifndef _SQLITE_CLI_H_  ----- */