projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use strcmp instead of stricmp for -install,-remove options
[yaz-moved-to-github.git]
/
src
/
record_conv.c
diff --git
a/src/record_conv.c
b/src/record_conv.c
index
7327ef4
..
8c00ebb
100644
(file)
--- a/
src/record_conv.c
+++ b/
src/record_conv.c
@@
-2,7
+2,7
@@
* Copyright (C) 2005-2006, Index Data ApS
* See the file LICENSE for details.
*
* Copyright (C) 2005-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: record_conv.c,v 1.3 2006-05-04 15:31:04 adam Exp $
+ * $Id: record_conv.c,v 1.6 2006-05-07 17:45:41 adam Exp $
*/
/**
* \file record_conv.c
*/
/**
* \file record_conv.c
@@
-31,19
+31,19
@@
/** \brief The internal structure for yaz_record_conv_t */
struct yaz_record_conv_struct {
/** \brief The internal structure for yaz_record_conv_t */
struct yaz_record_conv_struct {
- /** memory for configuration */
+ /** \brief memory for configuration */
NMEM nmem;
NMEM nmem;
- /** conversion rules (allocated using NMEM) */
+ /** \brief conversion rules (allocated using NMEM) */
struct yaz_record_conv_rule *rules;
struct yaz_record_conv_rule *rules;
- /** pointer to last conversion rule pointer in chain */
+ /** \brief pointer to last conversion rule pointer in chain */
struct yaz_record_conv_rule **rules_p;
struct yaz_record_conv_rule **rules_p;
- /** string buffer for error messages */
+ /** \brief string buffer for error messages */
WRBUF wr_error;
WRBUF wr_error;
- /** path for opening files */
+ /** \brief path for opening files */
char *path;
};
char *path;
};
@@
-72,7
+72,7
@@
struct yaz_record_conv_rule {
struct yaz_record_conv_rule *next;
};
struct yaz_record_conv_rule *next;
};
-/** reset rules+configuration */
+/** \brief reset rules+configuration */
static void yaz_record_conv_reset(yaz_record_conv_t p)
{
struct yaz_record_conv_rule *r;
static void yaz_record_conv_reset(yaz_record_conv_t p)
{
struct yaz_record_conv_rule *r;
@@
-120,6
+120,7
@@
void yaz_record_conv_destroy(yaz_record_conv_t p)
}
}
}
}
+/** \brief adds a rule */
static struct yaz_record_conv_rule *add_rule(yaz_record_conv_t p,
enum YAZ_RECORD_CONV_RULE type)
{
static struct yaz_record_conv_rule *add_rule(yaz_record_conv_t p,
enum YAZ_RECORD_CONV_RULE type)
{
@@
-131,6
+132,7
@@
static struct yaz_record_conv_rule *add_rule(yaz_record_conv_t p,
return r;
}
return r;
}
+/** \brief parse 'xslt' conversion node */
static int conv_xslt(yaz_record_conv_t p, const xmlNode *ptr)
{
struct _xmlAttr *attr;
static int conv_xslt(yaz_record_conv_t p, const xmlNode *ptr)
{
struct _xmlAttr *attr;
@@
-143,7
+145,7
@@
static int conv_xslt(yaz_record_conv_t p, const xmlNode *ptr)
stylesheet = (const char *) attr->children->content;
else
{
stylesheet = (const char *) attr->children->content;
else
{
- wrbuf_printf(p->wr_error, "Bad attribute '%s'."
+ wrbuf_printf(p->wr_error, "Bad attribute '%s'"
"Expected stylesheet.", attr->name);
return -1;
}
"Expected stylesheet.", attr->name);
return -1;
}
@@
-179,6
+181,7
@@
static int conv_xslt(yaz_record_conv_t p, const xmlNode *ptr)
return 0;
}
return 0;
}
+/** \brief parse 'marc' conversion node */
static int conv_marc(yaz_record_conv_t p, const xmlNode *ptr)
{
struct _xmlAttr *attr;
static int conv_marc(yaz_record_conv_t p, const xmlNode *ptr)
{
struct _xmlAttr *attr;
@@
-207,7
+210,7
@@
static int conv_marc(yaz_record_conv_t p, const xmlNode *ptr)
output_format = (const char *) attr->children->content;
else
{
output_format = (const char *) attr->children->content;
else
{
- wrbuf_printf(p->wr_error, "Bad attribute '%s'.", attr->name);
+ wrbuf_printf(p->wr_error, "Bad attribute '%s'", attr->name);
return -1;
}
}
return -1;
}
}
@@
-320,7
+323,7
@@
int yaz_record_conv_configure(yaz_record_conv_t p, const void *ptr_v)
else
{
wrbuf_printf(p->wr_error, "Bad element '%s'."
else
{
wrbuf_printf(p->wr_error, "Bad element '%s'."
- "Expected marc, xslt, ..", ptr->name);
+ "Expected marc, xslt, ..", ptr->name);
return -1;
}
}
return -1;
}
}
@@
-333,7
+336,9
@@
int yaz_record_conv_configure(yaz_record_conv_t p, const void *ptr_v)
return 0;
}
return 0;
}
-int yaz_record_conv_record(yaz_record_conv_t p, const char *input_record,
+int yaz_record_conv_record(yaz_record_conv_t p,
+ const char *input_record_buf,
+ size_t input_record_len,
WRBUF output_record)
{
int ret = 0;
WRBUF output_record)
{
int ret = 0;
@@
-341,7
+346,7
@@
int yaz_record_conv_record(yaz_record_conv_t p, const char *input_record,
struct yaz_record_conv_rule *r = p->rules;
wrbuf_rewind(p->wr_error);
struct yaz_record_conv_rule *r = p->rules;
wrbuf_rewind(p->wr_error);
- wrbuf_puts(record, input_record);
+ wrbuf_write(record, input_record_buf, input_record_len);
for (; ret == 0 && r; r = r->next)
{
if (r->which == YAZ_RECORD_CONV_RULE_XSLT)
for (; ret == 0 && r; r = r->next)
{
if (r->which == YAZ_RECORD_CONV_RULE_XSLT)
@@
-435,13
+440,10
@@
const char *yaz_record_conv_get_error(yaz_record_conv_t p)
void yaz_record_conv_set_path(yaz_record_conv_t p, const char *path)
{
void yaz_record_conv_set_path(yaz_record_conv_t p, const char *path)
{
- if (p)
- {
- xfree(p->path);
- p->path = 0;
- if (path)
- p->path = xstrdup(path);
- }
+ xfree(p->path);
+ p->path = 0;
+ if (path)
+ p->path = xstrdup(path);
}
#endif
}
#endif