1 #ifndef NB_DB_H_INCLUDED 2 #define NB_DB_H_INCLUDED 3 4 /* 5 * Redistribution and use in source and binary forms, with or 6 * without modification, are permitted provided that the following 7 * conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above 10 * copyright notice, this list of conditions and the 11 * following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials 16 * provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 26 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 29 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 struct nb_db; 34 struct nb_key; 35 36 typedef int (*nb_db_reqf_t)(struct nb_db *db, struct nb_key *key); 37 38 struct nb_db_if { 39 const char *name; 40 int (*init)(struct nb_db *db, size_t value_size); 41 void (*free)(struct nb_db *db); 42 int (*connect)(struct nb_db *db, struct nb_options *opts); 43 void (*close)(struct nb_db *db); 44 int (*recv)(struct nb_db *db, int count, int *missed); 45 nb_db_reqf_t insert; 46 nb_db_reqf_t replace; 47 nb_db_reqf_t update; 48 nb_db_reqf_t del; 49 nb_db_reqf_t select; 50 }; 51 52 struct nb_db { 53 struct nb_db_if *dif; 54 void *priv; 55 }; 56 57 extern struct nb_db_if *nb_dbs[]; 58 59 struct nb_db_if *nb_db_match(const char *name); 60 61 #endif 62