Heather Lee Wilson | bdd62c5 | 2013-12-28 15:12:39 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2008 Google Inc. |
| 3 | * |
| 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 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. |
| 15 | */ |
| 16 | typedef struct DatabaseConnection DatabaseConnection; |
| 17 | |
| 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() |
| 22 | */ |
| 23 | typedef unsigned int (*QueryDatabase)( |
| 24 | DatabaseConnection* const connection, const char * const query_string, |
| 25 | void *** const results); |
| 26 | |
| 27 | // Connection to a database. |
| 28 | struct DatabaseConnection { |
| 29 | const char *url; |
| 30 | unsigned int port; |
| 31 | QueryDatabase query_database; |
| 32 | }; |
| 33 | |
| 34 | // Connect to a database. |
| 35 | DatabaseConnection* connect_to_database(const char * const url, |
| 36 | const unsigned int port); |
| 37 | |