Use Bib1-attribute defines. Minor WS-updates.
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 26 Apr 2005 08:11:22 +0000 (08:11 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 26 Apr 2005 08:11:22 +0000 (08:11 +0000)
configure.in
include/idzebra/api.h
index/zebraapi.c
index/zrpn.c

index 9ee2cf2..860823b 100644 (file)
@@ -1,5 +1,5 @@
 dnl Zebra, Index Data ApS, 1995-2005
-dnl $Id: configure.in,v 1.117 2005-03-31 12:55:55 adam Exp $
+dnl $Id: configure.in,v 1.118 2005-04-26 08:11:22 adam Exp $
 dnl
 AC_INIT(include/idzebra/version.h)
 AM_INIT_AUTOMAKE(idzebra,1.4.0)
@@ -26,7 +26,7 @@ else
 fi
 dnl
 dnl ------ YAZ
-YAZ_INIT($yazflag,2.0.29)
+YAZ_INIT($yazflag,2.1.3)
 YAZ_DOC
 dnl ------ Look for Tcl
 dnl See if user has specified location of tclConfig.sh; otherwise
index d2226b4..b22fb86 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: api.h,v 1.18 2005-04-15 10:47:48 adam Exp $
+/* $Id: api.h,v 1.19 2005-04-26 08:11:22 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -161,7 +161,7 @@ YAZ_EXPORT char *zebra_errAdd(ZebraHandle zh);
     \param code pointer to returned error code
     \param addinfo pointer to returned additional info
 */
-YAZ_EXPORT int zebra_result(ZebraHandle zh, int *code, char **addinfo);
+YAZ_EXPORT void zebra_result(ZebraHandle zh, int *code, char **addinfo);
 
 /** \fn void zebra_clearError(ZebraHandle zh)
     \brief clears last error.
@@ -354,7 +354,9 @@ ZEBRA_RES zebra_clean(ZebraHandle zh);
 YAZ_EXPORT
 ZEBRA_RES zebra_init(ZebraHandle zh);
 
-YAZ_EXPORT int zebra_compact(ZebraHandle zh);
+YAZ_EXPORT
+ZEBRA_RES zebra_compact(ZebraHandle zh);
+
 YAZ_EXPORT int zebra_repository_update(ZebraHandle zh, const char *path);
 YAZ_EXPORT int zebra_repository_delete(ZebraHandle zh, const char *path);
 YAZ_EXPORT int zebra_repository_show(ZebraHandle zh, const char *path);
index 02680d4..f2d73c6 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -756,7 +756,7 @@ ZEBRA_RES zebra_select_databases (ZebraHandle zh, int num_bases,
     
     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++)
@@ -787,13 +787,13 @@ ZEBRA_RES zebra_select_databases (ZebraHandle zh, int num_bases,
         {
             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;
             }
         }
@@ -801,7 +801,7 @@ ZEBRA_RES zebra_select_databases (ZebraHandle zh, int num_bases,
         {
             if (cp1)
             {
-                zh->errCode = 23;
+                zh->errCode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
                 return ZEBRA_FAIL;
             }
         }
@@ -810,19 +810,19 @@ ZEBRA_RES zebra_select_databases (ZebraHandle zh, int num_bases,
     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;
@@ -866,7 +866,7 @@ ZEBRA_RES zebra_records_retrieve (ZebraHandle zh, ODR stream,
 
     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;
     }
@@ -883,7 +883,7 @@ ZEBRA_RES zebra_records_retrieve (ZebraHandle zh, ODR stream,
     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;
     }
@@ -924,7 +924,7 @@ ZEBRA_RES zebra_records_retrieve (ZebraHandle zh, ODR stream,
                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;
@@ -945,15 +945,18 @@ ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
     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,
@@ -1297,7 +1300,7 @@ ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *database)
                                   /* explainDatabase */))
     {
         zebra_end_trans (zh);
-       zh->errCode = 224;
+       zh->errCode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
        zh->errString = "database already exist";
        return ZEBRA_FAIL;
     }
@@ -1416,7 +1419,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw)
     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;
     }
@@ -1427,7 +1430,8 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw)
     {
        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;
        }
@@ -1449,7 +1453,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw)
        }
         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;
         }
@@ -1536,7 +1540,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw)
             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;
@@ -1562,13 +1566,13 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw)
         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);
@@ -1610,7 +1614,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw)
             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;
@@ -1647,7 +1651,7 @@ ZEBRA_RES zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
 
     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;
     }
@@ -1747,7 +1751,7 @@ int zebra_repository_show (ZebraHandle zh, const char *path)
     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;
@@ -1759,7 +1763,7 @@ static int zebra_commit_ex (ZebraHandle zh, int clean_only)
     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");    
@@ -1808,21 +1812,21 @@ static int zebra_commit_ex (ZebraHandle zh, int clean_only)
     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;
@@ -1833,7 +1837,7 @@ ZEBRA_RES zebra_init (ZebraHandle zh)
     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");
@@ -1850,7 +1854,7 @@ ZEBRA_RES zebra_init (ZebraHandle zh)
     return ZEBRA_OK;
 }
 
-int zebra_compact (ZebraHandle zh)
+ZEBRA_RES zebra_compact(ZebraHandle zh)
 {
     BFiles bfs;
     ASSERTZH;
@@ -1858,25 +1862,24 @@ int zebra_compact (ZebraHandle zh)
     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");
@@ -1957,7 +1960,7 @@ int zebra_get_shadow_enable (ZebraHandle zh)
 {
     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)
@@ -2087,8 +2090,8 @@ ZEBRA_RES zebra_delete_record (ZebraHandle zh,
   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;
@@ -2105,10 +2108,11 @@ ZEBRA_RES zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
     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);
 
@@ -2141,7 +2145,7 @@ int zebra_sort_by_specstr (ZebraHandle zh, ODR stream,
     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;
     }
     
index d4be419..5012154 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -29,6 +29,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #endif
 #include <ctype.h>
 
+#include <yaz/diagbib1.h>
 #include "index.h"
 #include <zebra_xpath.h>
 
@@ -1057,7 +1058,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
 
         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;
         }
@@ -1111,7 +1112,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                 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
@@ -1127,7 +1128,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                     oident.value = curAttributeSet;
                     oid_ent_to_oid (&oident, oid);
                     
-                    errCode = 121;
+                    errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET;
                     errString = nmem_strdup(stream, oident.desc);
                 }
                 continue;
@@ -1277,7 +1278,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
         }
@@ -1332,7 +1333,8 @@ static ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
@@ -1354,7 +1356,7 @@ static ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         termz[sizez] = '\0';
         break;
     default:
-        zh->errCode = 124;
+        zh->errCode = YAZ_BIB1_UNSUPP_CODED_VALUE_FOR_TERM;
        return ZEBRA_FAIL;
     }
     return ZEBRA_OK;
@@ -1490,7 +1492,7 @@ static int grep_info_prepare(ZebraHandle zh,
         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;
         }
@@ -1786,20 +1788,20 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                       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;
         }
@@ -1829,7 +1831,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         }
         if (!prefix_len)
         {
-            errCode = 114;
+            errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
             errString = nmem_strdup_i(stream, use_value);
             continue;
         }
@@ -2179,7 +2181,7 @@ static RSET rpn_search_xpath(ZebraHandle zh,
         
         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;
         }
@@ -2357,7 +2359,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     }
     else
     {
-        zh->errCode = 118;
+        zh->errCode = YAZ_BIB1_UNSUPP_STRUCTURE_ATTRIBUTE;
        return ZEBRA_FAIL;
     }
     if (res != ZEBRA_OK)
@@ -2494,13 +2496,13 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs,
            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;
@@ -2518,7 +2520,7 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs,
                }
                break;
            default:
-               zh->errCode = 110;
+               zh->errCode = YAZ_BIB1_OPERATOR_UNSUPP;
                return ZEBRA_FAIL;
            }
            *num_result_sets = 1;
@@ -2547,7 +2549,7 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs,
             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;
@@ -2556,7 +2558,7 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs,
         }
         else
         {
-            zh->errCode = 3;
+            zh->errCode = YAZ_BIB1_UNSUPP_SEARCH;
             return ZEBRA_FAIL;
         }
        *num_result_sets = 1;
@@ -2566,7 +2568,7 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs,
     }
     else
     {
-        zh->errCode = 3;
+        zh->errCode = YAZ_BIB1_UNSUPP_SEARCH;
         return ZEBRA_FAIL;
     }
     return ZEBRA_OK;
@@ -2733,7 +2735,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                        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);
@@ -2749,7 +2751,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
        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;
        }
@@ -2774,7 +2776,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                        attributeset, use_value);
                if (r == -1)
                {
-                   errCode = 114;
+                   errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
                     if (use_string)
                         errString = odr_strdup(stream, use_string);
                     else
@@ -2785,7 +2787,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                    }
                }   
                else
-                   errCode = 121;
+                   errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET;
                continue;
            }
        }