X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=dict%2Fscantest.c;h=7ca800a9bc354a6a92ad10d4ba1040792807df41;hb=861a4414a4a0d1d1076f97fe8105b0a3a3ab4a31;hp=f9de000038c9b8e1ff8731cc8e396b2703bd9482;hpb=664413d3aab4207a0f895caa87c4a57b022e5998;p=idzebra-moved-to-github.git diff --git a/dict/scantest.c b/dict/scantest.c index f9de000..7ca800a 100644 --- a/dict/scantest.c +++ b/dict/scantest.c @@ -1,5 +1,5 @@ -/* $Id: scantest.c,v 1.4 2005-04-29 18:43:30 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: scantest.c,v 1.7 2006-08-29 12:31:12 adam Exp $ + Copyright (C) 1995-2006 Index Data ApS This file is part of the Zebra server. @@ -15,16 +15,16 @@ 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 Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include #include #include #include - +#include #include #include @@ -43,9 +43,7 @@ static int handler(char *name, const char *info, int pos, void *client) else idx = -pos - 1; -#if 0 - printf ("pos=%d idx=%d name=%s\n", pos, idx, name); -#endif + yaz_log(YLOG_DEBUG, "pos=%d idx=%d name=%s", pos, idx, name); if (idx < 0) return 0; @@ -54,8 +52,8 @@ static int handler(char *name, const char *info, int pos, void *client) return 0; } -int tst(Dict dict, int before, int after, char *scan_term, char **cmp_strs, - int verbose) +int do_scan(Dict dict, int before, int after, char *scan_term, char **cmp_strs, + int verbose) { struct handle_info hi; int i; @@ -65,6 +63,8 @@ int tst(Dict dict, int before, int after, char *scan_term, char **cmp_strs, hi.ar = malloc(sizeof(char*) * (after+before+1)); for (i = 0; i= sizeof(scan_term)-1) + { + fprintf(stderr, "scan term too long\n"); + exit(1); + } + strcpy(scan_term, arg); break; case 'n': number = atoi(arg); @@ -141,48 +171,39 @@ int main(int argc, char **argv) } bfs = bfs_create(".:100M", 0); - if (!bfs) + YAZ_CHECK(bfs); + if (bfs) { - fprintf(stderr, "bfs_create failed\n"); - exit(1); + bf_reset(bfs); + dict = dict_open(bfs, "dict", 10, 1, 0, 0); + YAZ_CHECK(dict); } - dict = dict_open(bfs, "dict", 10, 1, 0, 0); - for (i = 10; i 0 || before > 0) + do_scan(dict, before, after, scan_term, 0, 1); + else + tst(dict); - if (after > 0 || before > 0) - tst(dict, before, after, scan_term, 0, 1); - else - { - if (argc <= 1) - { - char *cs[] = { - "4497", - "4498", - "4499", - "45"}; - strcpy(scan_term, "4499"); - errors += tst(dict, 2, 2, scan_term, cs, 0); - } - if (argc <= 1) - { - char *cs[] = { - "4498", - "4499", - "45", - "450"}; - strcpy(scan_term, "45"); - errors += tst(dict, 2, 2, scan_term, cs, 0); - } + dict_close(dict); } - dict_close(dict); - bfs_destroy(bfs); - if (errors) - exit(1); - exit(0); + if (bfs) + bfs_destroy(bfs); + YAZ_CHECK_TERM; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +