X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=cdb%2Fchiark_tcl_cdb.h;h=fef668c6efeede8127ac150ae7daea21226bc836;hb=8bd326d28120a2274f13364198ef925602231be6;hp=63259a86d1896d5690a7c76ebbe3cbc9ebc82d3d;hpb=9eb8c5c8a5caa7264d7d3464cf650baffb42a05c;p=chiark-tcl.git diff --git a/cdb/chiark_tcl_cdb.h b/cdb/chiark_tcl_cdb.h index 63259a8..fef668c 100644 --- a/cdb/chiark_tcl_cdb.h +++ b/cdb/chiark_tcl_cdb.h @@ -1,4 +1,19 @@ /* + * cdb, cdb-wr - Tcl bindings for tinycdb and a journalling write extension + * Copyright 2006-2012 Ian Jackson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library; if not, see . */ #ifndef CHIARK_TCL_CDB_H @@ -23,17 +38,23 @@ extern const IdDataSpec cdbtcl_databases, cdbtcl_rwdatabases; /*---------- from lookup.c ----------*/ -int cht_cdb_dosomelookup(Tcl_Interp *ip, void *db_v, - const char *key, Tcl_Obj *def, - Tcl_Obj **result, - int (*somelookup)(Tcl_Interp *ip, void *db_v, - const char *key, - const Byte **data_r, int *len_r), - int (*storeanswer)(Tcl_Interp *ip, Tcl_Obj **result, - const Byte *data, int len)); +int cht_cdb_donesomelookup(Tcl_Interp *ip, void *db_v, + Tcl_Obj *def, Tcl_Obj **result, + const Byte *data, int dlen, + int (*storeanswer)(Tcl_Interp *ip, Tcl_Obj **result, + const Byte *data, int len)); int cht_cdb_storeanswer_string(Tcl_Interp *ip, Tcl_Obj **result, const Byte *data, int len); int cht_cdb_storeanswer_hb(Tcl_Interp *ip, Tcl_Obj **result, const Byte *data, int len); +int cht_cdb_lookup_cdb(Tcl_Interp *ip, struct cdb *cdb, + const Byte *key, int klen, + const Byte **data_r, int *dlen_r); + +/*---------- macros ----------*/ + +#define PE(m) do{ \ + rc= cht_posixerr(ip, errno, "failed to " m); goto x_rc; \ + }while(0) #endif /*CHIARK_TCL_CDB_H*/