chiark / gitweb /
9331f31f7d28c12fd7a80479daa9a401608ac473
[chiark-tcl.git] / cdb / chiark_tcl_cdb.h
1 /*
2  * cdb, cdb-wr - Tcl bindings for tinycdb and a journalling write extension
3  * Copyright 2006-2012 Ian Jackson
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301, USA.
19  */
20
21 #ifndef CHIARK_TCL_CDB_H
22 #define CHIARK_TCL_CDB_H
23
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <fcntl.h>
27 #include <unistd.h>
28
29 #include <ctype.h>
30 #include <stdio.h>
31
32 #include <cdb.h>
33
34 #include "hbytes.h"
35 #include "cdb+tcmdif.h"
36
37 #define RWSCF_OKJUNK 002
38
39 extern const IdDataSpec cdbtcl_databases, cdbtcl_rwdatabases;
40
41 /*---------- from lookup.c ----------*/
42
43 int cht_cdb_donesomelookup(Tcl_Interp *ip, void *db_v,
44                            Tcl_Obj *def, Tcl_Obj **result,
45                            const Byte *data, int dlen,
46                            int (*storeanswer)(Tcl_Interp *ip, Tcl_Obj **result,
47                                               const Byte *data, int len));
48 int cht_cdb_storeanswer_string(Tcl_Interp *ip, Tcl_Obj **result,
49                                const Byte *data, int len);
50 int cht_cdb_storeanswer_hb(Tcl_Interp *ip, Tcl_Obj **result,
51                            const Byte *data, int len);
52 int cht_cdb_lookup_cdb(Tcl_Interp *ip, struct cdb *cdb,
53                        const Byte *key, int klen,
54                        const Byte **data_r, int *dlen_r);
55
56 /*---------- macros ----------*/
57
58 #define PE(m) do{                                               \
59     rc= cht_posixerr(ip, errno, "failed to " m); goto x_rc;     \
60   }while(0)
61
62 #endif /*CHIARK_TCL_CDB_H*/