oid_db.c File Reference

OID Database. More...

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <yaz/yaz-util.h>
#include <yaz/odr.h>
#include <yaz/oid_util.h>
#include <yaz/oid_db.h>

Go to the source code of this file.

Data Structures

struct  yaz_oid_db

Functions

yaz_oid_db_t yaz_oid_std (void)
 returns standard OID database
const Odr_oidyaz_string_to_oid (yaz_oid_db_t oid_db, oid_class oclass, const char *name)
 maps named OID string to raw OID by database lookup
Odr_oidyaz_string_to_oid_nmem (yaz_oid_db_t oid_list, oid_class oclass, const char *name, NMEM nmem)
 creates NMEM malloc'ed OID from string
Odr_oidyaz_string_to_oid_odr (yaz_oid_db_t oid_list, oid_class oclass, const char *name, ODR o)
 creates ODR malloc'ed OID from string
const char * yaz_oid_to_string (yaz_oid_db_t oid_db, const Odr_oid *oid, oid_class *oclass)
 maps raw OID to string
const char * yaz_oid_to_string_buf (const Odr_oid *oid, oid_class *oclass, char *buf)
 maps any OID to string (named or dot-notation)
char * oid_name_to_dotstring (oid_class oclass, const char *name, char *oid_buf)
 maps named from standard database to dot notation
int yaz_oid_is_iso2709 (const Odr_oid *oid)
 checks if OID refers to MARC transfer syntax
int yaz_oid_add (yaz_oid_db_t oid_db, oid_class oclass, const char *name, const Odr_oid *new_oid)
 adds new OID entry to database
yaz_oid_db_t yaz_oid_db_new (void)
 creates empty OID database
void yaz_oid_db_destroy (yaz_oid_db_t oid_db)
 destroys OID database
void yaz_oid_trav (yaz_oid_db_t oid_db, void(*func)(const Odr_oid *oid, oid_class oclass, const char *name, void *client_data), void *client_data)
 traverses OIDs in a database

Variables

struct yaz_oid_db standard_db_l
yaz_oid_db_t standard_db = &standard_db_l


Detailed Description

OID Database.

Definition in file oid_db.c.


Function Documentation

char* oid_name_to_dotstring ( oid_class  oclass,
const char *  name,
char *  oid_buf 
)

maps named from standard database to dot notation

Parameters:
oclass class of string (enum oid_class)
name named OID
oid_buf buffer for result (must be of size OID_STR_MAX)
Returns:
OID string or NULL if name is not registered in database

Definition at line 109 of file oid_db.c.

References yaz_oid_entry::oid, oid_oid_to_dotstring(), yaz_oid_std(), and yaz_string_to_oid().

int yaz_oid_add ( yaz_oid_db_t  oid_db,
oid_class  oclass,
const char *  name,
const Odr_oid new_oid 
)

adds new OID entry to database

Parameters:
oid_db database
oclass OID class
name name of OID
new_oid OID value (raw OID)
Return values:
0 OID added
-1 OID name+oclass already exists

Definition at line 127 of file oid_db.c.

References CLASS_NOP, yaz_oid_db::entries, yaz_oid_entry::name, yaz_oid_db::next, yaz_oid_entry::oclass, yaz_oid_entry::oid, oid_oidcpy(), oid_oidlen(), xmalloc, yaz_oid_db::xmalloced, xstrdup, and yaz_string_to_oid().

void yaz_oid_db_destroy ( yaz_oid_db_t  oid_db  ) 

destroys OID database

Parameters:
oid_db database

Definition at line 169 of file oid_db.c.

References yaz_oid_db::entries, yaz_oid_entry::name, yaz_oid_db::next, xfree, and yaz_oid_db::xmalloced.

yaz_oid_db_t yaz_oid_db_new ( void   ) 

creates empty OID database

Returns:
database

Definition at line 160 of file oid_db.c.

References yaz_oid_db::entries, yaz_oid_db::next, xmalloc, and yaz_oid_db::xmalloced.

int yaz_oid_is_iso2709 ( const Odr_oid oid  ) 

checks if OID refers to MARC transfer syntax

Parameters:
oid raw OID
Return values:
1 OID is a MARC type
0 OID is not a MARC type

Definition at line 118 of file oid_db.c.

References oid_oidlen().

Referenced by ZOOM_record_get(), and ztest_fetch().

yaz_oid_db_t yaz_oid_std ( void   ) 

const char* yaz_oid_to_string ( yaz_oid_db_t  oid_db,
const Odr_oid oid,
oid_class oclass 
)

maps raw OID to string

Parameters:
oid_db OID database
oid raw OID
oclass holds OID class if found (output parameter)
Returns:
OID name or NULL if not found in database

Definition at line 77 of file oid_db.c.

References yaz_oid_db::entries, yaz_oid_entry::name, yaz_oid_db::next, yaz_oid_entry::oclass, yaz_oid_entry::oid, and oid_oidcmp().

Referenced by yaz_oid_to_string_buf(), ZOOM_record_error(), and ZOOM_record_get().

const char* yaz_oid_to_string_buf ( const Odr_oid oid,
oid_class oclass,
char *  buf 
)

maps any OID to string (named or dot-notation)

Parameters:
oid raw OID
oclass holds OID class if found (output parameter)
buf string buffer for result (must be of size OID_STR_MAX)
Returns:
OID string (named or dot notatition)

Definition at line 98 of file oid_db.c.

References CLASS_GENERAL, oid_oid_to_dotstring(), and yaz_oid_to_string().

Referenced by display_grs1(), response_default_diag(), yaz_attribute_element_to_wrbuf(), yaz_query2xml_attribute_element(), yaz_query2xml_rpn(), yaz_rpnquery_to_wrbuf(), z_ext_record_oid(), z_ext_record_oid_any(), zlog_attributes(), and ztest_esrequest().

void yaz_oid_trav ( yaz_oid_db_t  oid_db,
void(*)(const Odr_oid *oid, oid_class oclass, const char *name, void *client_data)  func,
void *  client_data 
)

traverses OIDs in a database

Parameters:
oid_db OID database
func function to be called for each OID
client_data data to be passed to func (custom defined)

Definition at line 187 of file oid_db.c.

References yaz_oid_db::entries, yaz_oid_entry::name, yaz_oid_db::next, yaz_oid_entry::oclass, and yaz_oid_entry::oid.

const Odr_oid* yaz_string_to_oid ( yaz_oid_db_t  oid_db,
oid_class  oclass,
const char *  name 
)

maps named OID string to raw OID by database lookup

Parameters:
oid_db OID database
oclass class of string (enum oid_class)
name OID name
Returns:
raw OID or NULL if name is unknown (bad)
This function only maps known names in the database provided. Use yaz_string_to_oid_nmem or yaz_string_to_oid_odr to map any named OID in dot-notation (1.2.8).

Definition at line 39 of file oid_db.c.

References CLASS_GENERAL, yaz_oid_db::entries, yaz_oid_entry::name, yaz_oid_db::next, yaz_oid_entry::oclass, yaz_oid_entry::oid, and yaz_matchstr().

Referenced by oid_name_to_dotstring(), yaz_oid_add(), and yaz_string_to_oid_nmem().

Odr_oid* yaz_string_to_oid_nmem ( yaz_oid_db_t  oid_db,
oid_class  oclass,
const char *  name,
NMEM  nmem 
)

creates NMEM malloc'ed OID from string

Parameters:
oid_db OID database
oclass class of string (enum oid_class)
name OID name
nmem memory for returned OID
Returns:
raw OID or NULL if name is unknown (bad)

Definition at line 62 of file oid_db.c.

References odr_getoidbystr_nmem(), odr_oiddup_nmem(), yaz_oid_entry::oid, and yaz_string_to_oid().

Referenced by cql_transform_parse_tok_line(), and yaz_string_to_oid_odr().

Odr_oid* yaz_string_to_oid_odr ( yaz_oid_db_t  oid_db,
oid_class  oclass,
const char *  name,
ODR  odr 
)

creates ODR malloc'ed OID from string

Parameters:
oid_db OID database
oclass class of string (enum oid_class)
name OID name
odr memory for returned OID
Returns:
raw OID or NULL if name is unknown (bad)

Definition at line 71 of file oid_db.c.

References odr_getmem, and yaz_string_to_oid_nmem().

Referenced by conf_retrieval(), create_update_package(), otherInfo_attach(), query_oid_getvalbyname(), yaz_xml2query_attribute_element(), yaz_xml2query_rpn(), and zoom_yaz_str_to_z3950oid().


Variable Documentation

Definition at line 32 of file oid_db.c.

Initial value:

Definition at line 29 of file oid_db.c.


Generated on Mon Dec 29 12:08:47 2008 for YAZ by  doxygen 1.5.6