1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2010 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <yaz/yconfig.h>
24 #include <idzebra/version.h>
25 #include <idzebra/bfile.h>
26 #include <yaz/wrbuf.h>
30 #define SORT_IDX_ENTRYSIZE 64
32 /** \var zebra_sort_index_t
33 \brief sort index handle
35 typedef struct zebra_sort_index *zebra_sort_index_t;
37 #define ZEBRA_SORT_TYPE_FLAT 1
38 #define ZEBRA_SORT_TYPE_ISAMB 2
39 #define ZEBRA_SORT_TYPE_MULTI 3
41 /** \brief creates sort handle
42 \param bfs block files handle
43 \param write_flag (0=read-only, 1=write and read)
44 \param sort_type one of ZEBRA_SORT_TYPE_..
45 \return sort index handle
47 zebra_sort_index_t zebra_sort_open(BFiles bfs, int write_flag, int sort_type);
49 /** \brief frees sort handle
51 void zebra_sort_close(zebra_sort_index_t si);
53 /** \brief sets type for sort usage
54 \param si sort index handle
55 \param type opaque type .. A sort file for each type is created
57 int zebra_sort_type(zebra_sort_index_t si, int type);
59 /** \brief sets sort system number for read / add / delete
60 \param si sort index handle
61 \param sysno system number
63 void zebra_sort_sysno(zebra_sort_index_t si, zint sysno);
65 /** \brief adds multi-map content to sort file
66 \param si sort index handle
67 \param section_id section of key
68 \param w one or more 0-terminted strings (thus an array)
70 zebra_sort_type and zebra_sort_sysno must be called prior to this
72 void zebra_sort_add(zebra_sort_index_t si, zint section_id, WRBUF w);
75 /** \brief delete sort entry
76 \param si sort index handle
77 \param section_id section of sort key to be deleted
79 zebra_sort_type and zebra_sort_sysno must be called prior to this
81 void zebra_sort_delete(zebra_sort_index_t si, zint section_id);
83 /** \brief reads sort entry
84 \param si sort index handle
85 \param section_id output section ID (may be NULL and it will not be set)
86 \param w resulting buffer
87 \retval 0 could not be read
88 \retval 1 could be read (found)
90 int zebra_sort_read(zebra_sort_index_t si, zint *section_id, WRBUF w);
98 * c-file-style: "Stroustrup"
99 * indent-tabs-mode: nil
101 * vim: shiftwidth=4 tabstop=8 expandtab