X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=bfile%2Ftstbfile1.c;h=3f972a509c65d2303ed29cc9e2bc099dda5df8a3;hp=f2a4903c2d9c689957cc8712e0df27758070cffd;hb=ba0720e26f508ba3396e232d2f82037c0e701698;hpb=deff57cfa9d9b39c4a4f1c9b82a64c6e61d821a4 diff --git a/bfile/tstbfile1.c b/bfile/tstbfile1.c index f2a4903..3f972a5 100644 --- a/bfile/tstbfile1.c +++ b/bfile/tstbfile1.c @@ -1,8 +1,5 @@ -/* $Id: tstbfile1.c,v 1.1 2005-03-30 09:25:23 adam Exp $ - Copyright (C) 1995-2005 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2011 Index Data Zebra 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 @@ -15,29 +12,41 @@ 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 +#if HAVE_CONFIG_H +#include +#endif #include +#include #include +#include void tst1(BFiles bfs) { int version = 1; BFile bf; + const char *more_info = 0; bf_reset(bfs); bf = bf_xopen(bfs, "tst", /* block size */ 32, /* wr */ 1, "tstmagic", &version, 0 /* more_info */); - - bf_xclose(bf, version, 0 /* no more info */); + YAZ_CHECK(bf); + if (!bf) + return; + bf_xclose(bf, version, "more info"); bf = bf_xopen(bfs, "tst", /* block size */ 32, - /* wr */ 1, "tstmagic", &version, 0 /* more_info */); + /* wr */ 1, "tstmagic", &version, &more_info); + YAZ_CHECK(bf); + if (!bf) + return; + + YAZ_CHECK(strcmp(more_info, "more info") == 0); bf_xclose(bf, version, 0 /* no more info */); } @@ -51,35 +60,25 @@ void tst2(BFiles bfs) bf = bf_xopen(bfs, "tst", /* block size */ 32, /* wr */ 1, "tstmagic", &version, 0 /* more_info */); - + YAZ_CHECK(bf); + if (!bf) + return; bno = 0; for (i = 1; i<30; i++) { int j; for (j = 0; j= 0 && no_in_use <= BLOCKS); + YAZ_CHECK(no_in_use >= 0); + YAZ_CHECK(no_in_use <= BLOCKS); if (r < 5 && (BLOCKS - no_in_use) > 0) { /* alloc phase */ @@ -149,7 +151,7 @@ void tst3(BFiles bfs) j++; } } - assert(tblocks[to_free-start-1]); + YAZ_CHECK(tblocks[to_free-start-1]); bf_free(bf, to_free - start, tblocks); } else @@ -162,18 +164,36 @@ void tst3(BFiles bfs) bf_xclose(bf, version, 0); } -int main(int argc, char **argv) +static void tst(void) { BFiles bfs = bfs_create(0, /* register: current dir, no limit */ 0 /* base: current dir */ ); + YAZ_CHECK(bfs); if (!bfs) - exit(1); + return; tst1(bfs); tst2(bfs); tst3(bfs); bf_reset(bfs); bfs_destroy(bfs); - exit(0); } + +int main(int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + YAZ_CHECK_LOG(); + tst(); + YAZ_CHECK_TERM; +} + +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +