2 * Copyright 2008 Google Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 typedef struct DatabaseConnection DatabaseConnection;
18 /* Function that takes an SQL query string and sets results to an array of
19 * pointers with the result of the query. The value returned specifies the
20 * number of items in the returned array of results. The returned array of
21 * results are statically allocated and should not be deallocated using free()
23 typedef unsigned int (*QueryDatabase)(
24 DatabaseConnection* const connection, const char * const query_string,
25 void *** const results);
27 /* Connection to a database. */
28 struct DatabaseConnection {
31 QueryDatabase query_database;
34 /* Connect to a database. */
35 DatabaseConnection* connect_to_database(const char * const url,
36 const unsigned int port);