@@ -17,7 +17,6 @@ static char sql_query_buffer[2000];
1717// array used to store the string
1818//value obtain by get_val_text
1919unsigned char* array;
20−
2120/*
2221 open an SQLite database file as
2322 specified by the filename argument.
@@ -38,7 +37,6 @@ void* sqlite3_open_idr(const char *filename){
3837 return dbi;
3938
4039}
41−
4240/*
4341 Frees the resource and returns 0 on success
4442 */
@@ -50,12 +48,10 @@ int sqlite3_close_idr(void* db){
5048 free(dbi);
5149 return 0;
5250 }
53−
5451 else {
5552 return res;
5653 }
5754}
58−
5955/*
6056 SQLite wrapper around sqlite3_prepare_v2(),
6157 sqlite3_step(), and sqlite3_finalize().
@@ -64,11 +60,9 @@ int sqlite3_close_idr(void* db){
6460 */
6561int sqlite3_exec_idr(void* db, const char *sql)
6662{
67−
6863 DBinfo* dbi =(DBinfo*) db;
6964 char* err;
7065 int rc;
71−
7266 rc = sqlite3_exec(dbi->db_ptr,sql,NULL, NULL, &err);
7367 if (rc != SQLITE_OK && err != NULL) {
7468 strncpy(dbi->buffer, err, sizeof(dbi->buffer));
@@ -76,7 +70,6 @@ int sqlite3_exec_idr(void* db, const char *sql)
7670 }
7771 return rc;
7872}
79−
8073/*
8174 Gets the error store in the buffer
8275 in the struct. Some certain functions
@@ -86,15 +79,12 @@ char* sqlite3_get_error(void* db) {
8679 DBinfo* dbi =(DBinfo*) db;
8780 return dbi->buffer;
8881}
89−
90−
9182/*
9283 Compiles the query into a byte-code program
9384 Returns a pointer to the sqlite3_stmt pointer
9485 and stores it in the struct.
9586 */
9687void* sqlite3_prepare_idr(void *db,const char *zSql){
97−
9888 sqlite3_stmt* stmt;
9989 const char *tail;
10090
@@ -107,10 +97,8 @@ void* sqlite3_prepare_idr(void *db,const char *zSql){
10797 if(rec != SQLITE_OK){
10898 return NULL;
10999 }
110−
111100 return dbi;
112101}
113−
114102/*
115103 Another wrapper interface that is preserved
116104 for backwards compatibility.
@@ -118,7 +106,6 @@ void* sqlite3_prepare_idr(void *db,const char *zSql){
118106 This was mainly used for testing within the
119107 library.
120108 */
121−
122109void* sqlite3_get_table_idr(void* db,
123110 const char *sql){
124111
@@ -127,9 +114,7 @@ void* sqlite3_get_table_idr(void* db,
127114
128115 Table* tbl = malloc(sizeof(Table));
129116 tbl->database = dbi;
130−
131117 int res = sqlite3_get_table(dbi->db_ptr,sql,&tbl->table_data,&tbl->num_row,&tbl->num_col,&err);
132−
133118 int array_size = sizeof(&tbl->table_data);
134119
135120 if( res != SQLITE_OK && err != NULL){
@@ -137,16 +122,11 @@ void* sqlite3_get_table_idr(void* db,
137122 sqlite3_free(err);
138123 return NULL;
139124 }
140−
141125 tbl -> data_size = array_size;
142− return tbl;
143−
126+ return tbl;
144127}
145128
146−
147−
148129/*
149−
150130 This function executes queries.
151131 This can be used after preparing a query
152132 In case of error or library misuse
@@ -171,7 +151,6 @@ int exec_db(void*p){
171151 if(rc == SQLITE_ERROR && rc == SQLITE_MISUSE){
172152 return 1;
173153 }
174−
175154 row_counter =0;
176155
177156 while (rc == SQLITE_ROW) {
@@ -184,7 +163,6 @@ int exec_db(void*p){
184163 dbi->row_count = row_counter;
185164 dbi->col_count = col;
186165 return rc;
187−
188166}
189167/*
190168 Returns row number from DB Struct
@@ -195,12 +173,9 @@ int sqlite3_get_num_row_v2(void* p){
195173 DBinfo* dbi =(DBinfo*) p;
196174 int row_number =dbi->row_count;
197175 return row_number;
198−
199−
200176}
201177
202178/*
203−
204179 Returns column number from DB Struct
205180 */
206181int sqlite3_get_num_col_v2(void* p){
@@ -208,11 +183,9 @@ int sqlite3_get_num_col_v2(void* p){
208183 DBinfo* dbi =(DBinfo*) p;
209184 int col_number =dbi-> col_count;
210185 return col_number;
211−
212186}
213187
214188/*
215−
216189 Another way of obtaining row number
217190 Thought this function gets the value
218191 from Table struct. The value is stored
@@ -225,12 +198,9 @@ int sqlite3_get_num_row(void* p){
225198 Table* tbl =(Table*) p;
226199 int row_number =tbl->num_row;
227200 return row_number;
228−
229−
230201}
231202
232203/*
233−
234204 Another way of obtaining column number
235205 Thought this function gets the value
236206 from Table struct. The value is stored
@@ -238,13 +208,11 @@ int sqlite3_get_num_row(void* p){
238208 Using this version is not recommended
239209 unless used with get_table
240210 */
241−
242211int sqlite3_get_num_col(void* p){
243212
244213 Table* tbl =(Table*) p;
245214 int col_number =tbl-> num_col;
246− return col_number;
247−
215+ return col_number;
248216}
249217
250218/*
@@ -255,7 +223,6 @@ int sqlite3_get_num_col(void* p){
255223 set the pointer to its initial state
256224 and then calls sqlite3_column_type
257225 to get the type
258−
259226*/
260227int sqlite3_get_data_type(void* p, int nRow, int nCol){
261228
@@ -277,24 +244,18 @@ int sqlite3_get_data_type(void* p, int nRow, int nCol){
277244
278245}
279246/*
280−
281247 Obtains the integer value in a given column
282248*/
283249
284250int sqlite3_get_val_int(void* p, int nCol){
285251
286−
287252 DBinfo* dbi =(DBinfo*) p;
288253 int val, col;
289−
290254 val =sqlite3_column_int(dbi->ppStmt, nCol);
291255 return val;
292−
293−
294256}
295257
296258/*
297−
298259 Obtains the text value
299260 Need to allocate memory to store the string
300261 Use GC_malloc since Boehm garbage collector
@@ -306,16 +267,12 @@ const unsigned char* sqlite3_get_val_text(void* p,int nCol){
306267 DBinfo* dbi =(DBinfo*) p;
307268 int rc,i, val, counter;
308269 const unsigned char* text_val;
309−
310270 array =(unsigned char *) GC_malloc(1000*sizeof(char));
311−
312271 text_val =sqlite3_column_text(dbi->ppStmt, nCol);
313272 memcpy(array, text_val, strlen(text_val));
314−
315273 return array;
316274
317275}
318−
319276float sqlite3_get_float(void* p, int nCol){
320277
321278 DBinfo* dbi =(DBinfo*) p;
@@ -326,7 +283,6 @@ float sqlite3_get_float(void* p, int nCol){
326283 return float_val;
327284
328285}
329−
330286/*
331287 frees the pointer returned by get_table.
332288 */
@@ -336,16 +292,12 @@ void sqlite3_free_table_idr(void* db){
336292 sqlite3_free_table(tbl->table_data);
337293 free(tbl);
338294}
339−
340−
341295int sqlite3_step_idr(void* db){
342296
343297 DBinfo* dbi =(DBinfo*) db;
344298 int rc =sqlite3_step(dbi->ppStmt);
345299 return rc;
346300}
347−
348−
349301/*
350302 Binds integer. This returns a pointer
351303 because of the implementation of BindMulti
@@ -375,7 +327,6 @@ void* sqlite3_bind_float_idr(void* p,int index, float val){
375327 if(rc != SQLITE_OK){
376328 return NULL;
377329 }
378−
379330 return dbi;
380331}
381332
@@ -401,10 +352,7 @@ void* sqlite3_bind_text_idr(void* p,const char* text, int index,int length){
401352 }
402353
403354 return dbi;
404−
405355}
406−
407−
408356/*
409357 Used for testing column count function.
410358 This function prepares query and by passing
@@ -440,17 +388,13 @@ int sqlite3_column_count_idr(void* db, const char* tbl_name){
440388 return rc;
441389}
442390
443−
444391int sqlite3_data_count_idr(void* db){
445392
446393 DBinfo* dbi =(DBinfo*) db;
447394 int rc = sqlite3_data_count(dbi->ppStmt);
448395
449396 return rc;
450−
451397}
452−
453−
454398/*
455399 Must be called after prepare to clean up
456400 the resources.
@@ -466,8 +410,6 @@ int sqlite3_complete_idr(const char *sql){
466410
467411 int rc = sqlite3_complete(sql);
468412 return rc;
469−
470−
471413}
472414
473415/*
@@ -481,12 +423,10 @@ int sqlite3_reset_idr(void* db){
481423 return rc;
482424
483425}
484−
485426/*
486427 The following routines may be used to
487428 obtain column related information.
488429 */
489−
490430const char *sqlite3_column_name_idr(void* db, int N){
491431
492432 DBinfo* dbi=(DBinfo*) db;
@@ -502,8 +442,6 @@ const char *sqlite3_column_decltype_idr(void* db,int n){
502442 return dectype;
503443
504444}
505−
506−
507445int sqlite3_column_bytes_idr(void* db, int n){
508446
509447 DBinfo* dbi=(DBinfo*) db;
@@ -512,7 +450,6 @@ int sqlite3_column_bytes_idr(void* db, int n){
512450
513451
514452}
515−
516453const void *sqlite3_column_blob_idr(void* db, int iCol){
517454 DBinfo* dbi=(DBinfo*) db;
518455 const void* data =sqlite3_column_blob(dbi-> ppStmt, iCol);
@@ -590,7 +527,6 @@ int sqlite3_backup_pagecount_idr(void *backup){
590527 return res;
591528
592529}
593−
594530/*
595531 Get the length of string
596532 Need this in Idris since length will not