![]() |
![]()
| ![]() |
![]()
NAMEsdb_init, sdb_open, sdb_query, sdb_close - the Simple Database Library. SYNOPSIS#include <sdb.h> void sdb_init();
DESCRIPTIONThe SDB library allows applications to support multiple database management systems with negligeable overhead, in terms of code as well as system resources. sdb_init() initializes the library and registers the database drivers. It is not necessary to call sdb_init explicitly, since it will be done automatically when needed. sdb_open() opens a database connection that can be used for multiple queries. This is optional; calling sdb_query directly will simply open and close the connection for each query. sdb_open returns a connection id which is used in place of the url in calls to sdb_query. sdb_query() calls the callback once for each row returned. No rows does not indicate an error condition. sdb_query returns the number of rows or -1 for error. The callback takes three arguments, an integer indicating the number of columns in the result, an array of pointers to the fields and a pointer to some arbitrary data that the callback might need. Values are always returned as strings. sdb_close() closes the database connection opened by sdb_open. EXAMPLESThis minimal program runs queries from the command line. #include <stdio.h> #include <stdlib.h> #include <sdb.h> static int callback(int n, char **p, void *closure) { This program can be used to authenticate Squid proxy users. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sdb.h> static int cb_db(int n, char **p, void *closure) { SEE ALSOsdbd.8 Example clients in sdb_client.c and sdbd_client.c. AUTHORCopyright (c) 2000-2005 Ulric Eriksson <ulric@siag.nu> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the Licence, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|