Rename rec_rm to rec_free. Annotate the recindex.h file a bit.
[idzebra-moved-to-github.git] / index / recindex.h
1 /* $Id: recindex.h,v 1.29 2006-09-15 10:45:13 adam Exp $
2    Copyright (C) 1995-2006
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
21 */
22
23 #ifndef RECINDEX_H
24 #define RECINDEX_H
25
26 #include <idzebra/util.h>
27 #include <zebra-lock.h>
28 #include <idzebra/bfile.h>
29
30 YAZ_BEGIN_CDECL
31
32 #define REC_NO_INFO 8
33
34 typedef struct record_info {
35     SYSNO sysno;
36     int newFlag;
37     char *info[REC_NO_INFO];
38     size_t size[REC_NO_INFO];
39     char buf_size[REC_NO_INFO][6];
40     size_t size_size[REC_NO_INFO];
41     Zebra_mutex mutex;
42 } *Record;
43
44 typedef struct records_info *Records;
45
46 /** \brief marks record for deletion (on file storage)
47     \param p records handle
48     \param recpp record pointer
49     \returns ZEBRA_OK / ZEBRA_FAIL
50 */
51 ZEBRA_RES rec_del(Records p, Record *recpp);
52
53 /** \brief frees record (from memory)
54     \param recpp record pointer
55 */
56 void rec_free(Record *recpp);
57
58 /** \brief puts record (writes into file storage)
59     \param p records handle
60     \param recpp record pointer
61     \returns ZEBRA_OK / ZEBRA_FAIL
62 */
63 ZEBRA_RES rec_put(Records p, Record *recpp);
64
65 /** \brief creates new record (to be written to file storage)
66     \param p records handle
67     \returns record pointer (or NULL on error)
68 */
69 Record rec_new(Records p);
70 /** \brief gets record - with given system number
71     \param p records handle
72     \param sysno system ID (external number)
73     \returns record pointer (or NULL on error)
74 */
75 Record rec_get(Records p, SYSNO sysno);
76
77 /** \brief gets root record
78     \param p records handle
79     \returns record pointer (or NULL on error)
80 */
81 Record rec_get_root(Records p);
82 ZEBRA_RES rec_close (Records *p);
83
84 /** \brief opens records system
85     \param bfs block file storage
86     \param rw read-write flag(0=read only, 1=write)
87     \param compression_method REC_COMPRESS_ type 
88 */
89 Records rec_open(BFiles bfs, int rw, int compression_method);
90
91 char *rec_strdup(const char *s, size_t *len);
92 void rec_prstat(Records p);
93
94 SYSNO rec_sysno_to_int(SYSNO sysno);
95
96 /** \brief compression types */
97 #define REC_COMPRESS_NONE   0
98 #define REC_COMPRESS_BZIP2  1
99
100 enum { 
101     recInfo_fileType, 
102     recInfo_filename, 
103     recInfo_delKeys, 
104     recInfo_databaseName,
105     recInfo_storeData,
106     recInfo_attr,
107     recInfo_sortKeys
108 };
109
110 YAZ_END_CDECL
111 #endif
112 /*
113  * Local variables:
114  * c-basic-offset: 4
115  * indent-tabs-mode: nil
116  * End:
117  * vim: shiftwidth=4 tabstop=8 expandtab
118  */
119