* SQLite3 result set
*/
typedef struct {
- char **pazResult; /* Result of the query */
- unsigned int pnRow; /* Number of result rows */
- unsigned int pnColumn; /* Number of result columns */
- unsigned int curRow; /* Current row */
- char *pzErrmsg; /* Error message */
+ char **pazResult; /* Result of the query */
+ int pnRow; /* Number of result rows */
+ int pnColumn; /* Number of result columns */
+ unsigned int curRow; /* Current row */
+ char *pzErrmsg; /* Error message */
} sqlite3_res_t;
/* forward references */
* Private methods
*/
-void
-sqlite3_destroy(dbinstance_t *db) {
+static void
+dlz_sqlite3_destroy(dbinstance_t *db) {
/* release DB connection */
if (db->dbconn != NULL) {
sqlite3_close((sqlite3 *)db->dbconn);
* multithreaded operation.
*/
static void
-sqlite3_destroy_dblist(db_list_t *dblist) {
+dlz_sqlite3_destroy_dblist(db_list_t *dblist) {
dbinstance_t *ndbi = NULL;
dbinstance_t *dbi = NULL;
dbi = ndbi;
ndbi = DLZ_LIST_NEXT(dbi, link);
- sqlite3_destroy(dbi);
+ dlz_sqlite3_destroy(dbi);
}
/* release memory for the list structure */
sqlite3_instance_t *db = (sqlite3_instance_t *)dbdata;
char *querystring = NULL;
sqlite3_res_t *rs = NULL;
- unsigned int i = 0;
- unsigned int j = 0;
int qres = 0;
if ((query == COUNTZONE && rsp != NULL) ||
* into this function to minimize code.
*/
-char **
-sqlite3_fetch_row(sqlite3_res_t *rs) {
+static char **
+dlz_sqlite3_fetch_row(sqlite3_res_t *rs) {
char **retval = NULL;
if (rs != NULL) {
if (rs->pnRow > 0U && rs->curRow < rs->pnRow) {
return (retval);
}
-unsigned int
-sqlite3_num_fields(sqlite3_res_t *rs) {
+static unsigned int
+dlz_sqlite3_num_fields(sqlite3_res_t *rs) {
unsigned int retval = 0;
if (rs != NULL) {
retval = rs->pnColumn;
return (retval);
}
-unsigned int
-sqlite3_num_rows(sqlite3_res_t *rs) {
+static unsigned int
+dlz_sqlite3_num_rows(sqlite3_res_t *rs) {
unsigned int retval = 0;
if (rs != NULL) {
retval = rs->pnRow;
return (retval);
}
-void
-sqlite3_free_result(sqlite3_res_t *rs) {
+static void
+dlz_sqlite3_free_result(sqlite3_res_t *rs) {
if (rs != NULL) {
sqlite3_free_table(rs->pazResult);
free(rs);
}
static isc_result_t
-sqlite3_process_rs(sqlite3_instance_t *db, dns_sdlzlookup_t *lookup,
- sqlite3_res_t *rs) {
+dlz_sqlite3_process_rs(sqlite3_instance_t *db, dns_sdlzlookup_t *lookup,
+ sqlite3_res_t *rs) {
isc_result_t result = ISC_R_NOTFOUND;
char **row;
unsigned int fields;
- unsigned int i, j;
+ unsigned int j;
char *tmpString;
char *endp;
int ttl;
- row = sqlite3_fetch_row(rs); /* get a row from the result set */
- fields = sqlite3_num_fields(rs); /* how many columns in result set */
+ row = dlz_sqlite3_fetch_row(rs); /* get a row from the result set */
+ fields = dlz_sqlite3_num_fields(rs); /* how many columns in result set
+ */
while (row != NULL) {
unsigned int len = 0;
"to allocate "
"memory for temporary "
"string");
- sqlite3_free_result(rs);
+ dlz_sqlite3_free_result(rs);
return (ISC_R_FAILURE);
}
}
if (result != ISC_R_SUCCESS) {
- sqlite3_free_result(rs);
+ dlz_sqlite3_free_result(rs);
db->log(ISC_LOG_ERROR, "putrr returned error: %d",
result);
return (ISC_R_FAILURE);
}
- row = sqlite3_fetch_row(rs);
+ row = dlz_sqlite3_fetch_row(rs);
}
- sqlite3_free_result(rs);
+ dlz_sqlite3_free_result(rs);
return (result);
}
result = sqlite3_get_resultset(name, NULL, NULL, FINDZONE, dbdata, &rs);
if (result != ISC_R_SUCCESS || rs == NULL) {
if (rs != NULL) {
- sqlite3_free_result(rs);
+ dlz_sqlite3_free_result(rs);
}
db->log(ISC_LOG_ERROR, "SQLite3 module: unable to return "
/*
* if we returned any rows, the zone is supported.
*/
- rows = sqlite3_num_rows(rs);
- sqlite3_free_result(rs);
+ rows = dlz_sqlite3_num_rows(rs);
+ dlz_sqlite3_free_result(rs);
if (rows > 0) {
sqlite3_get_resultset(name, NULL, NULL, COUNTZONE, dbdata,
NULL);
if (result != ISC_R_SUCCESS || rs == NULL) {
if (rs != NULL) {
- sqlite3_free_result(rs);
+ dlz_sqlite3_free_result(rs);
}
db->log(ISC_LOG_ERROR, "SQLite3 module: unable to return "
"result set for ALLOWXFR query");
* count how many rows in result set; if we returned any,
* zone xfr is allowed.
*/
- rows = sqlite3_num_rows(rs);
- sqlite3_free_result(rs);
+ rows = dlz_sqlite3_num_rows(rs);
+ dlz_sqlite3_free_result(rs);
if (rows > 0) {
return (ISC_R_SUCCESS);
}
result = ISC_R_NOTFOUND;
- fields = sqlite3_num_fields(rs);
- row = sqlite3_fetch_row(rs);
+ fields = dlz_sqlite3_num_fields(rs);
+ row = dlz_sqlite3_fetch_row(rs);
while (row != NULL) {
if (fields < 4) {
db->log(ISC_LOG_ERROR, "SQLite3 module: too few fields "
break;
}
- row = sqlite3_fetch_row(rs);
+ row = dlz_sqlite3_fetch_row(rs);
}
cleanup:
if (rs != NULL) {
- sqlite3_free_result(rs);
+ dlz_sqlite3_free_result(rs);
}
return (result);
if (result != ISC_R_SUCCESS) {
if (rs != NULL) {
- sqlite3_free_result(rs);
+ dlz_sqlite3_free_result(rs);
}
db->log(ISC_LOG_ERROR, "SQLite3 module: unable to return "
"result set for AUTHORITY query");
/*
* lookup and authority result sets are processed in the same
- * manner: sqlite3_process_rs does the job for both functions.
+ * manner: dlz_sqlite3_process_rs does the job for both functions.
*/
- return (sqlite3_process_rs(db, lookup, rs));
+ return (dlz_sqlite3_process_rs(db, lookup, rs));
}
/*% If zone is supported, lookup up a (or multiple) record(s) in it */
/* if we didn't get a result set, log an err msg. */
if (result != ISC_R_SUCCESS) {
if (rs != NULL) {
- sqlite3_free_result(rs);
+ dlz_sqlite3_free_result(rs);
}
db->log(ISC_LOG_ERROR, "SQLite3 module: unable to return "
"result set for LOOKUP query");
/*
* lookup and authority result sets are processed in the same
- * manner: sqlite3_process_rs does the job for both functions.
+ * manner: dlz_sqlite3_process_rs does the job for both functions.
*/
- return (sqlite3_process_rs(db, lookup, rs));
+ return (dlz_sqlite3_process_rs(db, lookup, rs));
}
/*%
sqlite3_instance_t *db = (sqlite3_instance_t *)dbdata;
/* cleanup the list of DBI's */
if (db->db != NULL) {
- sqlite3_destroy_dblist((db_list_t *)(db->db));
+ dlz_sqlite3_destroy_dblist((db_list_t *)(db->db));
}
if (db->dbname != NULL) {