From: Adam Dickmeiss Date: Tue, 21 Oct 2008 14:37:17 +0000 (+0200) Subject: Fixed record logging on Windows (-d). X-Git-Tag: v1.1.0~81^2~4 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=6518f2160a4dfcd5e521f9beb3310ad16c5acf05;p=pazpar2-moved-to-github.git Fixed record logging on Windows (-d). Fixed record logging on Windows (-d). Passing a FILE* between DLLs using different C-runtimes is problematic (read does not work). So we are using xmlDocDumpFormatMemory instead of xmlDocFormatDump . --- diff --git a/src/logic.c b/src/logic.c index a882ac3..2096f30 100644 --- a/src/logic.c +++ b/src/logic.c @@ -95,6 +95,24 @@ struct parameters global_parameters = 15 // Connect timeout }; +static void log_xml_doc(xmlDoc *doc) +{ + FILE *lf = yaz_log_file(); + xmlChar *result = 0; + int len = 0; +#if LIBXML_VERSION >= 20600 + xmlDocDumpFormatMemory(doc, &result, &len, 1); +#else + xmlDocDumpMemory(doc, &result, &len); +#endif + if (lf && len) + { + fwrite(result, 1, len, lf); + fprintf(lf, "\n"); + } + xmlFree(result); +} + // Recursively traverse query structure to extract terms. void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num) { @@ -165,17 +183,8 @@ xmlDoc *record_to_xml(struct session_database *sdb, const char *rec) if (global_parameters.dump_records) { - FILE *lf = yaz_log_file(); - if (lf) - { - yaz_log(YLOG_LOG, "Un-normalized record from %s", db->url); -#if LIBXML_VERSION >= 20600 - xmlDocFormatDump(lf, rdoc, 1); -#else - xmlDocDump(lf, rdoc); -#endif - fprintf(lf, "\n"); - } + yaz_log(YLOG_LOG, "Un-normalized record from %s", db->url); + log_xml_doc(rdoc); } return rdoc; @@ -282,19 +291,9 @@ xmlDoc *normalize_record(struct session_database *sdb, struct session *se, if (global_parameters.dump_records) { - FILE *lf = yaz_log_file(); - - if (lf) - { - yaz_log(YLOG_LOG, "Normalized record from %s", - sdb->database->url); -#if LIBXML_VERSION >= 20600 - xmlDocFormatDump(lf, rdoc, 1); -#else - xmlDocDump(lf, rdoc); -#endif - fprintf(lf, "\n"); - } + yaz_log(YLOG_LOG, "Normalized record from %s", + sdb->database->url); + log_xml_doc(rdoc); } } return rdoc;