*/
Records rec_open(BFiles bfs, int rw, int compression_method);
+/** \brief check whether a compression method is supported
+ \param compression_method (REC_COMPRESS_..)
+ \retval 0 if method is unsupported
+ \retval 1 if method is supported
+*/
+int rec_check_compression_method(int compression_method);
+
char *rec_strdup(const char *s, size_t *len);
void rec_prstat(Records p, int verbose);
zint rec_sysno_to_int(zint sysno);
-/** \brief compression types */
+
+/** \brief No compression ("none") */
#define REC_COMPRESS_NONE 0
+/** \brief BZIP2 compression (slow and requires big chunks) */
#define REC_COMPRESS_BZIP2 1
+/** \brief zlib compression (faster and works off small chunks) */
#define REC_COMPRESS_ZLIB 2
+
enum {
recInfo_fileType,
recInfo_filename,
return ZEBRA_OK;
}
+int rec_check_compression_method(int compression_method)
+{
+ switch(compression_method)
+ {
+ case REC_COMPRESS_ZLIB:
+#if HAVE_ZLIB_H
+ return 1;
+#else
+ return 0;
+#endif
+ case REC_COMPRESS_BZIP2:
+#if HAVE_BZLIB_H
+ return 1;
+#else
+ return 0;
+#endif
+ case REC_COMPRESS_NONE:
+ return 1;
+ }
+ return 0;
+}
+
Records rec_open(BFiles bfs, int rw, int compression_method)
{
Records p;
ret = ZEBRA_FAIL;
}
+ if (!rec_check_compression_method(record_compression))
+ {
+ yaz_log(YLOG_FATAL, "unsupported recordCompression: %s",
+ compression_str);
+ ret = ZEBRA_FAIL;
+ }
+
{
const char *index_fname = res_get_def(res, "index", "default.idx");
if (index_fname && *index_fname && strcmp(index_fname, "none"))