libUnihan  0.5.3
sqlite_functions.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright © 2008 Red Hat, Inc. All rights reserved.
10  * Copyright © 2008 Ding-Yi Chen <dchen at redhat dot com>
11  *
12  * This file is part of the libUnihan Project.
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License as published by the Free Software Foundation; either
17  * version 2 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this program; if not, write to the
26  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
27  * Boston, MA 02111-1307 USA
28  */
29 
30 
31 
32 #ifndef SQLITE_FUNCTIONS_H_
33 #define SQLITE_FUNCTIONS_H_
34 #include <sqlite3.h>
35 #include "str_functions.h"
36 
44 #ifndef SQLITE_OPEN_READONLY
45 
48 #define SQLITE_OPEN_READONLY 0x00000001
49 #endif
50 
51 #ifndef SQLITE_OPEN_READWRITE
52 
55 #define SQLITE_OPEN_READWRITE 0x00000002
56 #endif
57 
58 #ifndef SQLITE_OPEN_CREATE
59 
64 #define SQLITE_OPEN_CREATE 0x00000004
65 #endif
66 
78 #ifndef SQL_RESULT_FIELD_CHUNK_SIZE
79 
82 # define SQL_RESULT_FIELD_CHUNK_SIZE 2048
83 #endif
84 
85 #ifndef SQL_RESULT_FIELD_ELEMENT_COUNT
86 
89 # define SQL_RESULT_FIELD_ELEMENT_COUNT 128
90 #endif
91 
92 #ifndef SQL_RESULT_FIELD_CONST_COUNT
93 
97 # define SQL_RESULT_FIELD_CONST_COUNT 0
98 #endif
99 
100 #ifndef SQL_RESULT_RESULT_CHUNK_SIZE
101 
104 # define SQL_RESULT_RESULT_CHUNK_SIZE 65536
105 #endif
106 
107 #ifndef SQL_RESULT_RESULT_ELEMENT_COUNT
108 
111 # define SQL_RESULT_RESULT_ELEMENT_COUNT 512
112 #endif
113 
114 #ifndef SQL_RESULT_RESULT_CONST_COUNT
115 
118 # define SQL_RESULT_RESULT_CONST_COUNT 0
119 #endif
120 
146 typedef struct {
149  int colCount;
151  char *errMsg;
152 } SQL_Result;
153 
160 
168 StringList *sql_result_free(SQL_Result *sResult, gboolean freeResult);
169 
182 int sqlite_count_matches(sqlite3 *db,const char * sqlClause,char **errMsg_ptr);
183 
191 SQL_Result *sqlite_get_sql_result(sqlite3 *db, const char *sqlClause);
192 
199 SQL_Result *sqlite_get_tableNames(sqlite3 *db);
200 
217 StringList *sqlite_get_fieldNames(sqlite3 *db,const char * sqlClause, int *execResult_ptr, char **errMsg_ptr);
218 
231 char *sqlite_value_signed_text(sqlite3_value *value);
232 
245 char *sqlite_value_signed_text_buffer(char *buf,sqlite3_value *value);
246 
247 #endif /* SQLITE_FUNCTIONS_H_ */
248 
int sqlite_count_matches(sqlite3 *db, const char *sqlClause, char **errMsg_ptr)
Count the matches returned by SQL clause.
StringList is a structure that stores a list of constant strings.
Definition: str_functions.h:47
String processing functions.
StringList * sqlite_get_fieldNames(sqlite3 *db, const char *sqlClause, int *execResult_ptr, char **errMsg_ptr)
Get the fields of result table of a SQL clause.
SQL_Result * sqlite_get_tableNames(sqlite3 *db)
Get the list of table names in the database.
Data structure that holds the result of SQL functions and command.
Definition: sqlite_functions.h:146
int execResult
sqlite3_exec result code. Initial value is -1, which means the result is not ready.
Definition: sqlite_functions.h:150
char * sqlite_value_signed_text_buffer(char *buf, sqlite3_value *value)
Store the value as signed string to provided buffer.
StringList * resultList
StringList that holds returned results.
Definition: sqlite_functions.h:148
StringList * sql_result_free(SQL_Result *sResult, gboolean freeResult)
Free a SQL_Result instance.
SQL_Result * sql_result_new()
New a SQL_Result instance.
char * errMsg
Eroor messages from sqlite3_exec().
Definition: sqlite_functions.h:151
StringList * fieldList
StringList that holds returned fields.
Definition: sqlite_functions.h:147
SQL_Result * sqlite_get_sql_result(sqlite3 *db, const char *sqlClause)
Get the results of SQL clause.
char * sqlite_value_signed_text(sqlite3_value *value)
Return the value as signed string.
int colCount
Column count. Value 0 usually implied that no matched results.
Definition: sqlite_functions.h:149