YAZ  5.34.0
Data Structures | Macros | Functions | Variables
oid_db.c File Reference

OID Database. More...

#include <stdlib.h>
#include <string.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
 

Macros

#define get_entries(db)   (db->xmalloced==0 ? yaz_oid_standard_entries : db->entries)
 

Functions

yaz_oid_db_t yaz_oid_std (void)
 returns standard OID database More...
 
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 More...
 
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 More...
 
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 More...
 
const char * yaz_oid_to_string (yaz_oid_db_t oid_db, const Odr_oid *oid, oid_class *oclass)
 maps raw OID to string More...
 
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) More...
 
char * oid_name_to_dotstring (oid_class oclass, const char *name, char *oid_buf)
 maps named from standard database to dot notation More...
 
int yaz_oid_is_iso2709 (const Odr_oid *oid)
 checks if OID refers to MARC transfer syntax More...
 
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 More...
 
yaz_oid_db_t yaz_oid_db_new (void)
 creates empty OID database More...
 
void yaz_oid_db_destroy (yaz_oid_db_t oid_db)
 destroys OID database More...
 
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 More...
 

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.

Macro Definition Documentation

◆ get_entries

#define get_entries (   db)    (db->xmalloced==0 ? yaz_oid_standard_entries : db->entries)

Definition at line 38 of file oid_db.c.

Function Documentation

◆ oid_name_to_dotstring()

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

maps named from standard database to dot notation

Parameters
oclassclass of string (enum oid_class)
namenamed OID
oid_bufbuffer for result (must be of size OID_STR_MAX)
Returns
OID string or NULL if name is not registered in database

Definition at line 110 of file oid_db.c.

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

◆ yaz_oid_add()

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_dbdatabase
oclassOID class
namename of OID
new_oidOID value (raw OID)
Return values
0OID added
-1OID name+oclass already exists

Definition at line 128 of file oid_db.c.

References CLASS_NOP, yaz_oid_db::entries, name, 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().

◆ yaz_oid_db_destroy()

void yaz_oid_db_destroy ( yaz_oid_db_t  oid_db)

destroys OID database

Parameters
oid_dbdatabase

Definition at line 170 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_new()

yaz_oid_db_t yaz_oid_db_new ( void  )

creates empty OID database

Returns
database

Definition at line 161 of file oid_db.c.

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

◆ yaz_oid_is_iso2709()

int yaz_oid_is_iso2709 ( const Odr_oid oid)

checks if OID refers to MARC transfer syntax

Parameters
oidraw OID
Return values
1OID is a MARC type
0OID is not a MARC type

Definition at line 119 of file oid_db.c.

References yaz_oid_entry::oid, and oid_oidlen().

Referenced by return_record_wrbuf(), and ztest_fetch().

◆ yaz_oid_std()

yaz_oid_db_t yaz_oid_std ( void  )

◆ yaz_oid_to_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

Parameters
oid_dbOID database
oidraw OID
oclassholds OID class if found (output parameter)
Returns
OID name or NULL if not found in database

Definition at line 78 of file oid_db.c.

References get_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(), yaz_record_render(), and ZOOM_record_error().

◆ yaz_oid_to_string_buf()

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
oidraw OID
oclassholds OID class if found (output parameter)
bufstring buffer for result (must be of size OID_STR_MAX)
Returns
OID string (named or dot notatition)

Definition at line 99 of file oid_db.c.

References CLASS_GENERAL, yaz_oid_entry::oclass, yaz_oid_entry::oid, oid_oid_to_dotstring(), yaz_oid_std(), and yaz_oid_to_string().

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

◆ yaz_oid_trav()

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_dbOID database
funcfunction to be called for each OID
client_datadata to be passed to func (custom defined)

Definition at line 188 of file oid_db.c.

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

◆ yaz_string_to_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_dbOID database
oclassclass of string (enum oid_class)
nameOID 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 40 of file oid_db.c.

References CLASS_GENERAL, get_entries, name, 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().

◆ 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_dbOID database
oclassclass of string (enum oid_class)
nameOID name
nmemmemory for returned OID
Returns
raw OID or NULL if name is unknown (bad)

Definition at line 63 of file oid_db.c.

References name, yaz_oid_entry::oclass, 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().

◆ 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_dbOID database
oclassclass of string (enum oid_class)
nameOID name
odrmemory for returned OID
Returns
raw OID or NULL if name is unknown (bad)

Definition at line 72 of file oid_db.c.

References name, yaz_oid_entry::oclass, 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

◆ standard_db

yaz_oid_db_t standard_db = &standard_db_l

Definition at line 31 of file oid_db.c.

Referenced by yaz_oid_std().

◆ standard_db_l

struct yaz_oid_db standard_db_l
Initial value:
= {
0, 0, 0
}

Definition at line 1 of file oid_db.c.