YAZ  5.34.0
Data Structures | Typedefs | Functions
record_conv.h File Reference

Record Conversions Utility. More...

#include <stddef.h>
#include <yaz/wrbuf.h>
#include <yaz/yconfig.h>
#include <yaz/xmltypes.h>
#include <yaz/z-opac.h>

Go to the source code of this file.

Data Structures

struct  yaz_record_conv_type
 

Typedefs

typedef struct yaz_record_conv_structyaz_record_conv_t
 

Functions

yaz_record_conv_t yaz_record_conv_create (void)
 
void yaz_record_conv_destroy (yaz_record_conv_t p)
 
int yaz_record_conv_configure (yaz_record_conv_t p, const xmlNode *node)
 
int yaz_record_conv_configure_t (yaz_record_conv_t p, const xmlNode *node, struct yaz_record_conv_type *types)
 
int yaz_record_conv_record (yaz_record_conv_t p, const char *input_record_buf, size_t input_record_len, WRBUF output_record)
 
int yaz_record_conv_opac_record (yaz_record_conv_t p, Z_OPACRecord *input_record, WRBUF output_record)
 
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)
 
const char * yaz_record_get_output_charset (yaz_record_conv_t p)
 

Detailed Description

Record Conversions Utility.

Definition in file record_conv.h.

Typedef Documentation

◆ yaz_record_conv_t

record conversion handle

Definition at line 45 of file record_conv.h.

Function Documentation

◆ yaz_record_conv_configure()

int yaz_record_conv_configure ( yaz_record_conv_t  p,
const xmlNode *  node 
)

configures record conversion

Parameters
precord conversion handle
nodexmlNode pointer (root element of XML config)
Return values
0success
-1failure

On failure, use yaz_record_conv_get_error to get error string.

<backend syntax='xml'>
  <xslt stylesheet="dc2marcxml.xsl"/>
  <marc inputformat="xml" outputformat="marcxml" outputcharset="marc-8"/>
</backend>
<backend syntax='usmarc' name='F'>
  <marc inputformat="marc" outputformat="marcxml" inputcharset="marc-8"/>
  <xslt stylesheet="marcxml2mods.xsl"/>
  <xslt stylesheet="mods2dc.xsl"/>
</backend>

Definition at line 1208 of file record_conv.c.

References yaz_record_conv_configure_t().

◆ yaz_record_conv_configure_t()

int yaz_record_conv_configure_t ( yaz_record_conv_t  p,
const xmlNode *  node,
struct yaz_record_conv_type types 
)

◆ yaz_record_conv_create()

yaz_record_conv_t yaz_record_conv_create ( void  )

◆ yaz_record_conv_destroy()

void yaz_record_conv_destroy ( yaz_record_conv_t  p)

destroys record handle

Parameters
precord conversion handle

Definition at line 94 of file record_conv.c.

References yaz_record_conv_struct::nmem, nmem_destroy(), yaz_record_conv_struct::path, yaz_record_conv_struct::wr_error, wrbuf_destroy(), xfree, and yaz_record_conv_reset().

Referenced by conf_retrieval(), and yaz_retrieval_reset().

◆ yaz_record_conv_get_error()

const char* yaz_record_conv_get_error ( yaz_record_conv_t  p)

returns error string (for last error)

Parameters
precord conversion handle
Returns
error string

Definition at line 1298 of file record_conv.c.

References yaz_record_conv_struct::wr_error, and wrbuf_cstr().

Referenced by conf_retrieval(), and retrieve_fetch().

◆ yaz_record_conv_opac_record()

int yaz_record_conv_opac_record ( yaz_record_conv_t  p,
Z_OPACRecord input_record,
WRBUF  output_record 
)

◆ yaz_record_conv_record()

int yaz_record_conv_record ( yaz_record_conv_t  p,
const char *  input_record_buf,
size_t  input_record_len,
WRBUF  output_record 
)

performs record conversion on record buffer (OCTET aligned)

Parameters
precord conversion handle
input_record_bufinput record buffer
input_record_lenlength of input record buffer
output_recordresultint record (WRBUF string)
Return values
0success
-1failure

On failure, use yaz_record_conv_get_error to get error string.

Definition at line 1288 of file record_conv.c.

References yaz_record_conv_struct::rules, and yaz_record_conv_record_rule().

Referenced by retrieve_fetch().

◆ yaz_record_conv_set_path()

void yaz_record_conv_set_path ( yaz_record_conv_t  p,
const char *  path 
)

set path for opening stylesheets etc.

Parameters
precord conversion handle
pathfile path (UNIX style with : / Windows with ;)

Definition at line 1303 of file record_conv.c.

References yaz_record_conv_struct::path, xfree, and xstrdup.

Referenced by conf_retrieval().

◆ yaz_record_get_output_charset()

const char* yaz_record_get_output_charset ( yaz_record_conv_t  p)

get output charset for last marc rule

Parameters
precord conversion handle
Returns
charset; 0 if none given

Definition at line 1229 of file record_conv.c.

References yaz_record_conv_type::construct, construct_marc(), yaz_record_conv_rule::info, marc_info::output_charset, yaz_record_conv_struct::rules, and yaz_record_conv_rule::type.

Referenced by retrieve_fetch().