APUE course source code
guowenxue
119 mins ago 805b28fc2e633bcd9c823a4b23614378ebfd50a1
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
61
62
/********************************************************************************
 *      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_  ----- */