From: Adam Dickmeiss Date: Wed, 28 May 2008 18:01:54 +0000 (+0200) Subject: Added yaz_mk_sru_surrogate to create SRU surrogate diagnostic. X-Git-Tag: v3.0.30~35 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=1aef63af06fa380247c91d12cd7288981985a406;p=yaz-moved-to-github.git Added yaz_mk_sru_surrogate to create SRU surrogate diagnostic. --- diff --git a/debian/rules b/debian/rules index faef7b6..de88e2d 100755 --- a/debian/rules +++ b/debian/rules @@ -98,7 +98,7 @@ binary-arch: build install dh_fixperms # dh_perl # dh_python - dh_makeshlibs -V 'libyaz3 (>= 3.0.27)' + dh_makeshlibs -V 'libyaz3 (>= 3.0.29)' dh_installdeb dh_shlibdeps -l debian/libyaz3/usr/lib dh_gencontrol diff --git a/include/yaz/srw.h b/include/yaz/srw.h index 4609411..680ee12 100644 --- a/include/yaz/srw.h +++ b/include/yaz/srw.h @@ -292,6 +292,9 @@ int sru_decode_surrogate_diagnostics(const char *buf, size_t len, Z_SRW_diagnostic **diag, int *num, ODR odr); +YAZ_EXPORT +void yaz_mk_sru_surrogate(ODR o, Z_SRW_record *record, int pos, + int code, const char *details); YAZ_END_CDECL diff --git a/src/seshigh.c b/src/seshigh.c index a0d79fa..3e10403 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -735,29 +735,7 @@ static int srw_bend_fetch(association *assoc, int pos, if (rr.errcode && rr.surrogate_flag) { int code = yaz_diag_bib1_to_srw(rr.errcode); - const char *message = yaz_diag_srw_str(code); - int len = 200; - if (message) - len += strlen(message); - if (rr.errstring) - len += strlen(rr.errstring); - - record->recordData_buf = (char *) odr_malloc(o, len); - - sprintf(record->recordData_buf, "\n" - " info:srw/diagnostic/1/%d\n", code); - if (rr.errstring) - sprintf(record->recordData_buf + strlen(record->recordData_buf), - "
%s
\n", rr.errstring); - if (message) - sprintf(record->recordData_buf + strlen(record->recordData_buf), - " %s\n", message); - sprintf(record->recordData_buf + strlen(record->recordData_buf), - "
\n"); - record->recordData_len = strlen(record->recordData_buf); - record->recordPosition = odr_intdup(o, pos); - record->recordSchema = "info:srw/schema/1/diagnostics-v1.1"; + yaz_mk_sru_surrogate(o, record, pos, code, rr.errstring); return 0; } else if (rr.len >= 0) @@ -765,7 +743,8 @@ static int srw_bend_fetch(association *assoc, int pos, record->recordData_buf = rr.record; record->recordData_len = rr.len; record->recordPosition = odr_intdup(o, pos); - record->recordSchema = odr_strdup_null(o, rr.schema); + record->recordSchema = odr_strdup_null( + o, rr.schema ? rr.schema : srw_req->recordSchema); } if (rr.errcode) { diff --git a/src/srwutil.c b/src/srwutil.c index 7d1da02..5cc58e6 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -339,6 +339,34 @@ void yaz_add_sru_update_diagnostic(ODR o, Z_SRW_diagnostic **d, } +void yaz_mk_sru_surrogate(ODR o, Z_SRW_record *record, int pos, + int code, const char *details) +{ + const char *message = yaz_diag_srw_str(code); + int len = 200; + if (message) + len += strlen(message); + if (details) + len += strlen(details); + + record->recordData_buf = (char *) odr_malloc(o, len); + + sprintf(record->recordData_buf, "\n" + " info:srw/diagnostic/1/%d\n", code); + if (details) + sprintf(record->recordData_buf + strlen(record->recordData_buf), + "
%s
\n", details); + if (message) + sprintf(record->recordData_buf + strlen(record->recordData_buf), + " %s\n", message); + sprintf(record->recordData_buf + strlen(record->recordData_buf), + "
\n"); + record->recordData_len = strlen(record->recordData_buf); + record->recordPosition = odr_intdup(o, pos); + record->recordSchema = "info:srw/schema/1/diagnostics-v1.1"; +} + static void grab_charset(ODR o, const char *content_type, char **charset) { if (charset)