-/* $Id: zebraapi.c,v 1.161 2005-04-15 10:47:48 adam Exp $
+/* $Id: zebraapi.c,v 1.162 2005-04-26 08:11:22 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
if (num_bases < 1)
{
- zh->errCode = 23;
+ zh->errCode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
return ZEBRA_FAIL;
}
for (i = 0; i < zh->num_basenames; i++)
{
if (!cp1)
{
- zh->errCode = 23;
+ zh->errCode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
return -1;
}
if (len != cp1 - basenames[i] ||
memcmp (basenames[i], new_reg, len))
{
- zh->errCode = 23;
+ zh->errCode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
return -1;
}
}
{
if (cp1)
{
- zh->errCode = 23;
+ zh->errCode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
return ZEBRA_FAIL;
}
}
xfree(new_reg);
if (!zh->res)
{
- zh->errCode = 109;
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
return ZEBRA_FAIL;
}
if (!zh->lock_normal || !zh->lock_shadow)
{
- zh->errCode = 2;
+ zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
return ZEBRA_FAIL;
}
return ZEBRA_OK;
}
-ZEBRA_RES zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query,
- const char *setname, zint *hits)
+ZEBRA_RES zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query,
+ const char *setname, zint *hits)
{
ZEBRA_RES r;
ASSERTZH;
if (!zh->res)
{
- zh->errCode = 30;
+ zh->errCode = YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST;
zh->errString = odr_strdup(stream, setname);
return ZEBRA_FAIL;
}
if (!poset)
{
yaz_log (YLOG_DEBUG, "zebraPosSetCreate error");
- zh->errCode = 30;
+ zh->errCode = YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST;
zh->errString = nmem_strdup (stream->mem, setname);
ret = ZEBRA_FAIL;
}
char num_str[20];
sprintf (num_str, ZINT_FORMAT, pos_array[i]);
- zh->errCode = 13;
+ zh->errCode = YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE;
zh->errString = odr_strdup (stream, num_str);
ret = ZEBRA_FAIL;
break;
YAZ_PQF_Parser pqf_parser = yaz_pqf_create ();
Z_AttributesPlusTerm *zapt;
int *attributeSet;
+ ZEBRA_RES res;
if (!(zapt = yaz_pqf_scan(pqf_parser, stream, &attributeSet, query)))
{
- yaz_pqf_destroy (pqf_parser);
- return ZEBRA_FAIL;
+ res = ZEBRA_FAIL;
+ zh->errCode = YAZ_BIB1_SCAN_MALFORMED_SCAN;
}
+ else
+ res = zebra_scan(zh, stream, zapt, VAL_BIB1,
+ position, num_entries, entries, is_partial);
yaz_pqf_destroy (pqf_parser);
- return zebra_scan(zh, stream, zapt, VAL_BIB1,
- position, num_entries, entries, is_partial);
+ return res;
}
ZEBRA_RES zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
/* explainDatabase */))
{
zebra_end_trans (zh);
- zh->errCode = 224;
+ zh->errCode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
zh->errString = "database already exist";
return ZEBRA_FAIL;
}
zebra_select_default_database(zh);
if (!zh->res)
{
- zh->errCode = 2;
+ zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
zh->errString = "zebra_begin_trans: no database selected";
return ZEBRA_FAIL;
}
{
if (rw && !strchr(zh->user_perm, 'w'))
{
- zh->errCode = 223;
+ zh->errCode =
+ YAZ_BIB1_ES_PERMISSION_DENIED_ON_ES_CANNOT_MODIFY_OR_DELETE;
zh->errString = 0;
return ZEBRA_FAIL;
}
}
if (zh->trans_no != 1)
{
- zh->errCode = 2;
+ zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
zh->errString = "zebra_begin_trans: write trans not allowed within read trans";
return ZEBRA_FAIL;
}
zh->trans_no--;
zh->trans_w_no = 0;
- zh->errCode = 2;
+ zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
zh->errString = "zebra_begin_trans: cannot open register";
yaz_log(YLOG_FATAL, zh->errString);
return ZEBRA_FAIL;
if (!zh->res)
{
(zh->trans_no)--;
- zh->errCode = 109;
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
return ZEBRA_FAIL;
}
if (!zh->lock_normal || !zh->lock_shadow)
{
(zh->trans_no)--;
- zh->errCode = 2;
+ zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
return ZEBRA_FAIL;
}
zebra_get_state (zh, &val, &seqno);
zebra_unlock (zh->lock_normal);
zebra_unlock (zh->lock_shadow);
zh->trans_no--;
- zh->errCode = 109;
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
return ZEBRA_FAIL;
}
zh->reg->last_val = val;
if (!zh->res || !zh->reg)
{
- zh->errCode = 2;
+ zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
zh->errString = "zebra_end_trans: no open transaction";
return ZEBRA_FAIL;
}
return zh->errCode;
}
-static int zebra_commit_ex (ZebraHandle zh, int clean_only)
+static int zebra_commit_ex(ZebraHandle zh, int clean_only)
{
int seqno;
char val;
zebra_select_default_database(zh);
if (!zh->res)
{
- zh->errCode = 109;
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
return -1;
}
rval = res_get (zh->res, "shadow");
return 0;
}
-ZEBRA_RES zebra_clean (ZebraHandle zh)
+ZEBRA_RES zebra_clean(ZebraHandle zh)
{
ASSERTZH;
yaz_log(log_level, "zebra_clean");
return zebra_commit_ex(zh, 1);
}
-ZEBRA_RES zebra_commit (ZebraHandle zh)
+ZEBRA_RES zebra_commit(ZebraHandle zh)
{
ASSERTZH;
yaz_log(log_level, "zebra_commit");
return zebra_commit_ex(zh, 0);
}
-ZEBRA_RES zebra_init (ZebraHandle zh)
+ZEBRA_RES zebra_init(ZebraHandle zh)
{
const char *rval;
BFiles bfs = 0;
zebra_select_default_database(zh);
if (!zh->res)
{
- zh->errCode = 109;
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
return ZEBRA_FAIL;
}
rval = res_get (zh->res, "shadow");
return ZEBRA_OK;
}
-int zebra_compact (ZebraHandle zh)
+ZEBRA_RES zebra_compact(ZebraHandle zh)
{
BFiles bfs;
ASSERTZH;
zh->errCode = 0;
if (!zh->res)
{
- zh->errCode = 109;
- return -1;
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
+ return ZEBRA_FAIL;
}
bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
inv_compact (bfs);
bfs_destroy (bfs);
- return 0;
+ return ZEBRA_OK;
}
-int zebra_result (ZebraHandle zh, int *code, char **addinfo)
+void zebra_result(ZebraHandle zh, int *code, char **addinfo)
{
ASSERTZH;
yaz_log(log_level, "zebra_result");
*code = zh->errCode;
*addinfo = zh->errString;
- return 0;
}
-void zebra_shadow_enable (ZebraHandle zh, int value)
+void zebra_shadow_enable(ZebraHandle zh, int value)
{
ASSERTZH;
yaz_log(log_level, "zebra_shadow_enable");
{
ASSERTZH;
yaz_log(log_level, "zebra_get_shadow_enable");
- return (zh->shadow_enable);
+ return zh->shadow_enable;
}
void zebra_set_shadow_enable (ZebraHandle zh, int value)
Searching
*/
-ZEBRA_RES zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
- const char *setname, zint *numhits)
+ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query,
+ const char *setname, zint *numhits)
{
zint hits = 0;
ZEBRA_RES res = ZEBRA_OK;
if (!query)
{
yaz_log (YLOG_WARN, "bad query %s\n", pqf_query);
+ zh->errCode = YAZ_BIB1_MALFORMED_QUERY;
res = ZEBRA_FAIL;
}
else
- res = zebra_search_RPN (zh, odr, query, setname, &hits);
+ res = zebra_search_RPN(zh, odr, query, setname, &hits);
odr_destroy(odr);
if (!sort_sequence)
{
yaz_log(YLOG_WARN, "invalid sort specs '%s'", sort_spec);
- zh->errCode = 207;
+ zh->errCode = YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE;
return -1;
}
-/* $Id: zrpn.c,v 1.178 2005-04-25 21:40:34 adam Exp $
+/* $Id: zrpn.c,v 1.179 2005-04-26 08:11:22 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#endif
#include <ctype.h>
+#include <yaz/diagbib1.h>
#include "index.h"
#include <zebra_xpath.h>
if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
{
- zh->errCode = 109; /* Database unavailable */
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
zh->errString = basenames[base_no];
return ZEBRA_FAIL;
}
if (r == -1)
{
/* set was found, but value wasn't defined */
- errCode = 114;
+ errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
if (use_string)
errString = nmem_strdup(stream, use_string);
else
oident.value = curAttributeSet;
oid_ent_to_oid (&oident, oid);
- errCode = 121;
+ errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET;
errString = nmem_strdup(stream, oident.desc);
}
continue;
strcat(term_dict, ")");
break;
default:
- zh->errCode = 120;
+ zh->errCode = YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE;
zh->errString = nmem_strdup_i(stream, truncation_value);
return ZEBRA_FAIL;
}
if (ret == (size_t)(-1))
{
ret = yaz_iconv(zh->iconv_to_utf8, 0, 0, 0, 0);
- zh->errCode = 125;
+ zh->errCode =
+ YAZ_BIB1_QUERY_TERM_INCLUDES_CHARS_THAT_DO_NOT_TRANSLATE_INTO_;
return -1;
}
*outbuf = 0;
termz[sizez] = '\0';
break;
default:
- zh->errCode = 124;
+ zh->errCode = YAZ_BIB1_UNSUPP_CODED_VALUE_FOR_TERM;
return ZEBRA_FAIL;
}
return ZEBRA_OK;
grep_info->termset = resultSetAdd(zh, termset_name, 1);
if (!grep_info->termset)
{
- zh->errCode = 128;
+ zh->errCode = YAZ_BIB1_ILLEGAL_RESULT_SET_NAME;
zh->errString = nmem_strdup(stream, termset_name);
return -1;
}
curAttributeSet, use_value, r);
if (r == -1)
{
- errCode = 114;
+ errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
if (use_string)
errString = nmem_strdup(stream, use_string);
else
errString = nmem_strdup_i (stream, use_value);
}
else
- errCode = 121;
+ errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET;
continue;
}
}
if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
{
- zh->errCode = 109; /* Database unavailable */
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
zh->errString = basenames[base_no];
return -1;
}
}
if (!prefix_len)
{
- errCode = 114;
+ errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
errString = nmem_strdup_i(stream, use_value);
continue;
}
if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
{
- zh->errCode = 109; /* Database unavailable */
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
zh->errString = basenames[base_no];
return rset;
}
}
else
{
- zh->errCode = 118;
+ zh->errCode = YAZ_BIB1_UNSUPP_STRUCTURE_ATTRIBUTE;
return ZEBRA_FAIL;
}
if (res != ZEBRA_OK)
case Z_Operator_prox:
if (zop->u.prox->which != Z_ProximityOperator_known)
{
- zh->errCode = 132;
+ zh->errCode = YAZ_BIB1_UNSUPP_PROX_UNIT_CODE;
return ZEBRA_FAIL;
}
if (*zop->u.prox->u.known != Z_ProxUnit_word)
{
char *val = (char *) nmem_malloc(stream, 16);
- zh->errCode = 132;
+ zh->errCode = YAZ_BIB1_UNSUPP_PROX_UNIT_CODE;
zh->errString = val;
sprintf(val, "%d", *zop->u.prox->u.known);
return ZEBRA_FAIL;
}
break;
default:
- zh->errCode = 110;
+ zh->errCode = YAZ_BIB1_OPERATOR_UNSUPP;
return ZEBRA_FAIL;
}
*num_result_sets = 1;
rset = resultSetRef(zh, zs->u.simple->u.resultSetId);
if (!rset)
{
- zh->errCode = 30;
+ zh->errCode = YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST;
zh->errString =
nmem_strdup(stream, zs->u.simple->u.resultSetId);
return ZEBRA_FAIL;
}
else
{
- zh->errCode = 3;
+ zh->errCode = YAZ_BIB1_UNSUPP_SEARCH;
return ZEBRA_FAIL;
}
*num_result_sets = 1;
}
else
{
- zh->errCode = 3;
+ zh->errCode = YAZ_BIB1_UNSUPP_SEARCH;
return ZEBRA_FAIL;
}
return ZEBRA_OK;
rank_type, &complete_flag, &sort_flag))
{
*num_entries = 0;
- zh->errCode = 113;
+ zh->errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_TYPE;
return ZEBRA_FAIL;
}
yaz_log(YLOG_DEBUG, "use_value = %d", use_value);
if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
{
zh->errString = basenames[base_no];
- zh->errCode = 109; /* Database unavailable */
+ zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
*num_entries = 0;
return ZEBRA_FAIL;
}
attributeset, use_value);
if (r == -1)
{
- errCode = 114;
+ errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
if (use_string)
errString = odr_strdup(stream, use_string);
else
}
}
else
- errCode = 121;
+ errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET;
continue;
}
}