X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fsrwutil.c;h=5cc58e65aa9c031f8ea17b13ea3afef78e41c2e4;hb=74e62ec12177e6dc1ff3c578f6e96186f5e63a13;hp=a3459fec14f95eb752e72f8783e11b52056b8374;hpb=66651add5da56151f986e44957cfafc8ee81578c;p=yaz-moved-to-github.git diff --git a/src/srwutil.c b/src/srwutil.c index a3459fe..5cc58e6 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -1,8 +1,6 @@ -/* - * Copyright (C) 1995-2007, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2008 Index Data * See the file LICENSE for details. - * - * $Id: srwutil.c,v 1.65 2008-01-28 09:51:02 adam Exp $ */ /** * \file srwutil.c @@ -341,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)