secgateway/Platform/common/database/database.h

162 lines
6.5 KiB
C
Raw Normal View History

2019-07-19 07:54:36 +00:00
#ifndef DB_H
#define DB_H
/* 返回值 */
#define DB_RET_OK 0
#define DB_RET_ERR 1
#define DB_RET_PARAM_NULL 2
#define DB_RET_PARAM_ERR 3
/* 数据库操作类型 */
#define DB_OP_INSERT 1
#define DB_OP_DEL 2
#define DB_OP_UPDATE 3
/* 数据库支持的参数类型 */
#define DB_DATA_INT_TYPE 1
#define DB_DATA_STRING_TYPE 2
#define DB_DATA_FLOAT_TYPE 3
#endif
/* 模块ID */
enum
{
DB_MODULE_ID_INVALID = 0,
DB_MODULE_ID_MAX,
};
2019-07-22 02:44:49 +00:00
/* 数据库TABLE属性 */
#define DB_ROWS 20 /* 支持的最大列数 */
#define DB_COLUMN 1 /* 单次查询获取的条目数 */
#define DB_ROWS_MAX_LEN 99 /* 列支持的最大长度。单位:字节 */
2019-07-22 02:44:49 +00:00
2019-07-19 07:54:36 +00:00
/*********************************************************************************
  * Description  
*
  * Input:  
* module_id - IDID使
  * Output:
* 
  * Return:
*
* NULL -
* NULL -
  * Others:
*
**********************************************************************************/
void * connect_database (int module_id);
/*********************************************************************************
  * Description  
*
  * Input:  
* module_id - IDID使
  * db_handle -
* Output:
* 
  * Return:
* DB_RET_PARAM_NULL - NULL
* DB_RET_ERR -
* DB_RET_OK -
  * Others:
*
**********************************************************************************/
int disconnect_database (int module_id, void * db_handle);
/*********************************************************************************
  * Description  
*
  * Input:  
* module_id - IDID使
  * db_handle -
* table_name -
* sql_str - SQL语句
* Output:
* 
  * Return:
* DB_RET_PARAM_NULL - NULL
* DB_RET_PARAM_NULL - NULL
* DB_RET_ERR -
* DB_RET_OK -
  * Others:
*
**********************************************************************************/
int create_database_table(int module_id, void * db_handle, char * table_name, char * sql_str);
/*********************************************************************************
  * Description  
*
  * Input:  
* module_id - IDID使
  * db_handle -
* op_type - DB_OP_INSERT DB_OP_DEL DB_OP_UPDATE
* table_name -
* sql_str - SQL语句
* param_num - 0SQL注入问题使
* Output:
* 
  * Return:
* DB_RET_PARAM_NULL - NULL
* DB_RET_ERR -
* DB_RET_OK -
  * Others:
*
**********************************************************************************/
int update_database(int module_id, void * db_handle, int op_type, char * table_name, char * sql_str, int param_num, ...);
/*********************************************************************************
  * Description  
*
  * Input:  
* module_id - IDID使
  * db_handle -
* table_name -
* sql_str - SQL语句
* begin_num -
* need_num -
* param_num - 0SQL注入问题使
* Output:
*  return_num -
  * Return:
* NULL -
* NULL - CJSON格式的查询结果
  * Others:
*
**********************************************************************************/
void * select_datebase_by_number(int module_id, void * db_handle, char * table_name, char * sql_str, int begin_num, int need_num, int * return_num, int param_num, ...);
2019-07-22 03:11:02 +00:00
/*********************************************************************************
  * Description  
*
  * Input:  
* module_id - IDID使
* table_name -
* memory_ptr -
* Output:
* 
  * Return:
* DB_RET_PARAM_NULL - NULL
* DB_RET_ERR -
* DB_RET_OK -
  * Others:
*
**********************************************************************************/
int free_database_memory(int module_id, char * table_name, void * memory_ptr);
2019-07-19 07:54:36 +00:00
/*********************************************************************************
  * Description  
*
  * Input:  
* module_id - IDID使
  * db_handle -
* table_name -
* sql_str - SQL语句
* param_num - 0SQL注入问题使
* Output:
*  ret_num -
  * Return:
* DB_RET_PARAM_NULL - NULL
* DB_RET_ERR -
* DB_RET_OK -
  * Others:
*
**********************************************************************************/
int get_select_datebase_number(int module_id, void * db_handle, char * table_name, char * sql_str, int * ret_num, int param_num, ...);