BRL-CAD
Collaboration diagram for Database5:

Files

file  binunif.c
 
file  db5_bin.c
 
file  db5_alloc.c
 
file  db5_attr.c
 
file  db5_io.c
 
file  db5_types.c
 

Data Structures

struct  db5_type
 

Functions

int db5_write_free (struct db_i *dbip, struct directory *dp, size_t length)
 
int db5_realloc (struct db_i *dbip, struct directory *dp, struct bu_external *ep)
 
const char * db5_standard_attribute (int idx)
 
int db5_is_standard_attribute (const char *attr_want)
 
int db5_standardize_attribute (const char *attr)
 
HIDDEN int boolean_attribute (int attr)
 
HIDDEN void attr_add (struct bu_attribute_value_set *newavs, int attr_type, const char *stdattr, const char *value)
 
size_t db5_standardize_avs (struct bu_attribute_value_set *avs)
 
void db5_sync_attr_to_comb (struct rt_comb_internal *comb, const struct bu_attribute_value_set *avs, struct directory *dp)
 
void db5_sync_comb_to_attr (struct bu_attribute_value_set *avs, const struct rt_comb_internal *comb)
 
int db5_header_is_valid (const unsigned char *hp)
 
int db5_select_length_encoding (size_t len)
 
size_t db5_decode_length (size_t *lenp, const unsigned char *cp, int format)
 
int db5_decode_signed (size_t *lenp, const unsigned char *cp, int format)
 
unsigned char * db5_encode_length (unsigned char *cp, size_t val, int format)
 
int db5_crack_disk_header (struct db5_raw_internal *rip, const unsigned char *cp)
 
const unsigned char * db5_get_raw_internal_ptr (struct db5_raw_internal *rip, const unsigned char *ip)
 
int db5_get_raw_internal_fp (struct db5_raw_internal *rip, FILE *fp)
 
void db5_export_object3 (struct bu_external *out, int dli, const char *name, const unsigned char hidden, const struct bu_external *attrib, const struct bu_external *body, int major, int minor, int a_zzz, int b_zzz)
 
void db5_make_free_object_hdr (struct bu_external *ep, size_t length)
 
void db5_make_free_object (struct bu_external *ep, size_t length)
 
int rt_db_cvt_to_external5 (struct bu_external *ext, const char *name, const struct rt_db_internal *ip, double conv2mm, struct db_i *dbip, struct resource *resp, const int major)
 
int db_wrap_v5_external (struct bu_external *ep, const char *name)
 
int db_put_external5 (struct bu_external *ep, struct directory *dp, struct db_i *dbip)
 
int rt_db_put_internal5 (struct directory *dp, struct db_i *dbip, struct rt_db_internal *ip, struct resource *resp, const int major)
 
int rt_binunif_import5_minor_type (struct rt_db_internal *, const struct bu_external *, const mat_t, const struct db_i *, struct resource *, int)
 
int rt_db_external5_to_internal5 (struct rt_db_internal *ip, const struct bu_external *ep, const char *name, const struct db_i *dbip, const mat_t mat, struct resource *resp)
 
int rt_db_get_internal5 (struct rt_db_internal *ip, const struct directory *dp, const struct db_i *dbip, const mat_t mat, struct resource *resp)
 
void db5_export_color_table (struct bu_vls *ostr, struct db_i *dbip)
 
void db5_import_color_table (char *cp)
 
int db5_put_color_table (struct db_i *dbip)
 
int db5_get_attributes (const struct db_i *dbip, struct bu_attribute_value_set *avs, const struct directory *dp)
 
int db5_type_tag_from_major (char **tag, const int major)
 
int db5_type_descrip_from_major (char **descrip, const int major)
 
int db5_type_tag_from_codes (char **tag, const int major, const int minor)
 
int db5_type_descrip_from_codes (char **descrip, const int major, const int minor)
 
int db5_type_codes_from_tag (int *major, int *minor, const char *tag)
 
int db5_type_codes_from_descrip (int *major, int *minor, const char *descrip)
 
size_t db5_type_sizeof_h_binu (const int minor)
 
size_t db5_type_sizeof_n_binu (const int minor)
 

Variables

const struct db5_attr_ctype db5_attr_std []
 

Detailed Description

Function Documentation

int db5_write_free ( struct db_i dbip,
struct directory dp,
size_t  length 
)

Create a v5 database "free" object of the specified size, and place it at the indicated location in the database.

There are two interesting cases:

  • The free object is "small". Just write it all at once.
  • The free object is "large". Write header and trailer separately
Returns
0 OK
-1 Fail. This is a horrible error.

Definition at line 40 of file db5_alloc.c.

References BU_EXTERNAL_INIT, bu_free_external(), directory::d_flags, directory::d_un, db5_make_free_object(), db5_make_free_object_hdr(), db_write(), bu_external::ext_buf, bu_external::ext_nbytes, directory::ptr, RT_CK_DBI, RT_CK_DIR, and RT_DIR_INMEM.

Referenced by db5_realloc(), and db_delete().

Here is the call graph for this function:

int db5_realloc ( struct db_i dbip,
struct directory dp,
struct bu_external ep 
)

Change the size of a v5 database object.

If the object is getting smaller, break it into two pieces, and write out free objects for both. The caller is expected to re-write new data on the first one.

If the object is getting larger, seek a suitable "hole" large enough to hold it, throwing back any surplus, properly marked.

If the object is getting larger and there is no suitable "hole" in the database, extend the file, write a free object in the new space, and write a free object in the old space.

There is no point to trying to extend in place, that would require two searches through the memory map, and doesn't save any disk I/O.

Returns - 0 OK -1 Failure

Definition at line 96 of file db5_alloc.c.

References BU_ASSERT_LONG, BU_CK_EXTERNAL, bu_log(), bu_malloc(), bu_realloc(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db5_write_free(), db_dirbuild(), db_i::dbi_eof, db_i::dbi_freep, db_i::dbi_read_only, DEBUG_DB, bu_external::ext_nbytes, if(), mem_map::m_addr, mem_map::m_size, MAP_NULL, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_DIR_PHONY_ADDR, RT_G_DEBUG, rt_memalloc_nosplit(), and rt_memfree().

Referenced by db_put_external5(), and rt_db_put_internal5().

Here is the call graph for this function:

const char* db5_standard_attribute ( int  idx)
int db5_is_standard_attribute ( const char *  attr_want)

Definition at line 136 of file db5_attr.c.

References BU_STR_EQUIV, and db5_standard_attribute().

Referenced by write_comb().

Here is the call graph for this function:

int db5_standardize_attribute ( const char *  attr)

Definition at line 152 of file db5_attr.c.

References BU_STR_EQUIV, bu_vls_addr(), bu_vls_free(), bu_vls_init(), bu_vls_strncpy(), db5_attr_std, and strchr().

Referenced by db5_standardize_avs(), and rt_comb_adjust().

Here is the call graph for this function:

HIDDEN int boolean_attribute ( int  attr)

Definition at line 192 of file db5_attr.c.

Referenced by attr_add().

HIDDEN void attr_add ( struct bu_attribute_value_set newavs,
int  attr_type,
const char *  stdattr,
const char *  value 
)

Definition at line 203 of file db5_attr.c.

References boolean_attribute(), bu_avs_add(), bu_avs_remove(), and bu_str_true().

Referenced by db5_standardize_avs().

Here is the call graph for this function:

size_t db5_standardize_avs ( struct bu_attribute_value_set avs)
int db5_header_is_valid ( const unsigned char *  hp)

Verify that this is a valid header for a BRL-CAD v5 database.

Returns - 0 Not valid v5 header 1 Valid v5 header

Definition at line 46 of file db5_io.c.

Referenced by db5_scan(), and db_version().

int db5_select_length_encoding ( size_t  len)

Given a number to encode, decide which is the smallest encoding format which will contain it.

Definition at line 84 of file db5_io.c.

Referenced by db5_export_object3(), db5_make_free_object(), db5_make_free_object_hdr(), and rt_comb_export5().

size_t db5_decode_length ( size_t *  lenp,
const unsigned char *  cp,
int  format 
)

Given a variable-width length field in network order (XDR), store it in *lenp.

This routine processes unsigned values.

Returns - The number of bytes of input that were decoded.

Definition at line 94 of file db5_io.c.

References bu_bomb(), BU_GLONG, BU_GLONGLONG, and BU_GSHORT.

Referenced by db5_get_raw_internal_fp(), db5_get_raw_internal_ptr(), db5_import_attributes(), and rt_comb_import5().

Here is the call graph for this function:

int db5_decode_signed ( size_t *  lenp,
const unsigned char *  cp,
int  format 
)

Given a variable-width length field in network order (XDR), store it in *lenp.

This routine processes signed values.

Returns - The number of bytes of input that were decoded.

Definition at line 119 of file db5_io.c.

References bu_bomb(), BU_GLONG, BU_GLONGLONG, and BU_GSHORT.

Referenced by rt_comb_import5().

Here is the call graph for this function:

unsigned char* db5_encode_length ( unsigned char *  cp,
size_t  val,
int  format 
)

Given a value and a variable-width format spec, store it in network order.

Returns - pointer to next available byte.

Definition at line 152 of file db5_io.c.

References bu_bomb(), and htonll.

Referenced by db5_export_object3(), db5_make_free_object(), db5_make_free_object_hdr(), rt_comb_export5(), and rt_comb_v5_serialize().

Here is the call graph for this function:

int db5_crack_disk_header ( struct db5_raw_internal *  rip,
const unsigned char *  cp 
)

Returns - 0 on success -1 on error

Definition at line 182 of file db5_io.c.

References bu_log(), DEBUG_DB, and RT_G_DEBUG.

Referenced by db5_get_raw_internal_fp(), and db5_get_raw_internal_ptr().

Here is the call graph for this function:

const unsigned char* db5_get_raw_internal_ptr ( struct db5_raw_internal *  rip,
const unsigned char *  ip 
)

Returns - on success, pointer to first unused byte NULL, on error

Definition at line 245 of file db5_io.c.

References BU_EXTERNAL_INIT, bu_log(), db5_crack_disk_header(), and db5_decode_length().

Referenced by db5_get_attributes(), db5_replace_attributes(), db5_scan(), db5_update_attributes(), db_dirbuild(), db_wrap_v5_external(), ged_hide(), ged_unhide(), get_diff_components(), rt_db_external5_to_internal5(), and rt_retrieve_binunif().

Here is the call graph for this function:

int db5_get_raw_internal_fp ( struct db5_raw_internal *  rip,
FILE *  fp 
)

Returns - 0 on success -1 on EOF -2 on error

Definition at line 305 of file db5_io.c.

References BU_EXTERNAL_INIT, bu_log(), bu_malloc(), db5_crack_disk_header(), and db5_decode_length().

Referenced by db5_scan().

Here is the call graph for this function:

void db5_export_object3 ( struct bu_external out,
int  dli,
const char *  name,
const unsigned char  hidden,
const struct bu_external attrib,
const struct bu_external body,
int  major,
int  minor,
int  a_zzz,
int  b_zzz 
)

A routine for merging together the three optional parts of an object into the final on-disk format. Results in extra data copies, but serves as a starting point for testing. Any of name, attrib, and body may be null.

Definition at line 420 of file db5_io.c.

References BU_ASSERT_LONG, BU_ASSERT_PTR, bu_bomb(), BU_CK_EXTERNAL, BU_EXTERNAL_INIT, bu_malloc(), db5_encode_length(), db5_select_length_encoding(), bu_external::ext_buf, and bu_external::ext_nbytes.

Referenced by db5_fwrite_ident(), db5_replace_attributes(), db5_update_attributes(), db5_update_ident(), db_create_inmem(), db_wrap_v5_external(), ged_hide(), ged_unhide(), rt_db_cvt_to_external5(), and rt_mk_binunif().

Here is the call graph for this function:

void db5_make_free_object_hdr ( struct bu_external ep,
size_t  length 
)

Make only the front (header) portion of a free object. This is used when operating on very large contiguous free objects in the database (e.g. 50 MBytes).

Definition at line 572 of file db5_io.c.

References BU_ASSERT_SIZE_T, bu_calloc(), BU_CK_EXTERNAL, db5_encode_length(), db5_select_length_encoding(), bu_external::ext_buf, and bu_external::ext_nbytes.

Referenced by db5_write_free().

Here is the call graph for this function:

void db5_make_free_object ( struct bu_external ep,
size_t  length 
)

Make a complete, zero-filled, free object. Note that free objects can sometimes get quite large.

Definition at line 601 of file db5_io.c.

References BU_ASSERT_SIZE_T, bu_calloc(), BU_CK_EXTERNAL, db5_encode_length(), db5_select_length_encoding(), bu_external::ext_buf, and bu_external::ext_nbytes.

Referenced by db5_write_free().

Here is the call graph for this function:

int rt_db_cvt_to_external5 ( struct bu_external ext,
const char *  name,
const struct rt_db_internal ip,
double  conv2mm,
struct db_i dbip,
struct resource resp,
const int  major 
)

The attributes are taken from ip->idb_avs

If present, convert attributes to on-disk format. This must happen after exporting the body, in case the ft_export5() method happened to extend the attribute set. Combinations are one "solid" which does this.

The internal representation is NOT freed, that's the caller's job.

The 'ext' pointer is accepted in uninitialized form, and an initialized structure is always returned, so that the caller may free it even when an error return is given.

Returns - 0 OK -1 FAIL

Definition at line 632 of file db5_io.c.

References BU_AVS_MAGIC, BU_CK_EXTERNAL, BU_EXTERNAL_INIT, bu_free_external(), bu_log(), db5_export_attributes(), db5_export_object3(), rt_functab::ft_export5, rt_db_internal::idb_avs, rt_db_internal::idb_meth, bu_attribute_value_set::magic, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_CK_RESOURCE, and rt_uniresource.

Referenced by nmg_stash_model_to_file(), rt_db_put_internal5(), and wdb_put_internal().

Here is the call graph for this function:

int db_wrap_v5_external ( struct bu_external ep,
const char *  name 
)

Definition at line 702 of file db5_io.c.

References BU_ASSERT_LONG, BU_CK_EXTERNAL, BU_EXTERNAL_INIT, bu_free_external(), bu_log(), BU_STR_EQUAL, db5_export_object3(), db5_get_raw_internal_ptr(), and bu_external::ext_buf.

Referenced by db_put_external5(), and wdb_export_external().

Here is the call graph for this function:

int db_put_external5 ( struct bu_external ep,
struct directory dp,
struct db_i dbip 
)

Given that caller already has an external representation of the database object, update it to have a new name (taken from dp->d_namep) in that external representation, and write the new object into the database, obtaining different storage if the size has changed.

Changing the name on a v5 object is a relatively expensive operation.

Caller is responsible for freeing memory of external representation, using bu_free_external().

This routine is used to efficiently support MGED's "cp" and "keep" commands, which don't need to import and decompress objects just to rename and copy them.

Returns - -1 error 0 success

Definition at line 744 of file db5_io.c.

References BU_ASSERT_LONG, BU_CK_EXTERNAL, bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db5_realloc(), db_wrap_v5_external(), db_write(), db_i::dbi_filename, db_i::dbi_read_only, db_i::dbi_version, DEBUG_DB, bu_external::ext_buf, bu_external::ext_nbytes, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_DIR_PHONY_ADDR, and RT_G_DEBUG.

Referenced by db5_replace_attributes(), db5_update_attributes(), db_put_external(), and rt_mk_binunif().

Here is the call graph for this function:

int rt_db_put_internal5 ( struct directory dp,
struct db_i dbip,
struct rt_db_internal ip,
struct resource resp,
const int  major 
)

Convert the internal representation of a solid to the external one, and write it into the database.

Applications and middleware shouldn't call this directly, they should use the version-generic interface "rt_db_put_internal()".

The internal representation is always freed. (Not the pointer, just the contents).

Returns - <0 error 0 success

Definition at line 789 of file db5_io.c.

References BU_ASSERT_LONG, BU_CK_EXTERNAL, BU_EXTERNAL_INIT, bu_free_external(), bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db5_realloc(), db_write(), db_i::dbi_version, bu_external::ext_buf, bu_external::ext_nbytes, directory::ptr, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_CK_DIR, RT_CK_RESOURCE, rt_db_cvt_to_external5(), rt_db_free_internal(), RT_DIR_INMEM, and RT_DIR_PHONY_ADDR.

Referenced by rt_db_put_internal().

Here is the call graph for this function:

int rt_binunif_import5_minor_type ( struct rt_db_internal ip,
const struct bu_external ep,
const mat_t  mat,
const struct db_i dbip,
struct resource resp,
int  minor_type 
)
int rt_db_external5_to_internal5 ( struct rt_db_internal ip,
const struct bu_external ep,
const char *  name,
const struct db_i dbip,
const mat_t  mat,
struct resource resp 
)

Given an object in external form, convert it to internal form. The caller is responsible for freeing the external form.

Returns - <0 On error id On success.

Definition at line 854 of file db5_io.c.

References bn_mat_identity, BU_ASSERT_LONG, bu_avs_init_empty(), BU_AVS_MAGIC, BU_CK_EXTERNAL, bu_log(), db5_get_raw_internal_ptr(), db5_import_attributes(), db5_standardize_avs(), db_i::dbi_version, bu_external::ext_buf, rt_functab::ft_import5, ID_BINUNIF, rt_db_internal::idb_avs, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_minor_type, bu_attribute_value_set::magic, OBJ, rt_binunif_import5_minor_type(), RT_CK_DB_INTERNAL, RT_CK_DBI, RT_CK_RESOURCE, rt_db_free_internal(), and rt_uniresource.

Referenced by rt_db_get_internal5().

Here is the call graph for this function:

int rt_db_get_internal5 ( struct rt_db_internal ip,
const struct directory dp,
const struct db_i dbip,
const mat_t  mat,
struct resource resp 
)

Get an object from the database, and convert it into its internal representation.

Applications and middleware shouldn't call this directly, they should use the generic interface "rt_db_get_internal()".

Returns - <0 On error id On success.

Definition at line 961 of file db5_io.c.

References BU_ASSERT_LONG, BU_EXTERNAL_INIT_ZERO, bu_free_external(), directory::d_namep, db_get_external(), db_i::dbi_version, RT_CK_RESOURCE, rt_db_external5_to_internal5(), and RT_DB_INTERNAL_INIT.

Referenced by db_functree(), db_preorder_traverse(), rt_db_get_internal(), and rt_retrieve_binunif().

Here is the call graph for this function:

void db5_export_color_table ( struct bu_vls ostr,
struct db_i dbip 
)

Definition at line 988 of file db5_io.c.

References BU_CK_VLS, RT_CK_DBI, and rt_vls_color_map().

Referenced by db5_put_color_table().

Here is the call graph for this function:

void db5_import_color_table ( char *  cp)

Definition at line 996 of file db5_io.c.

References rt_color_addrec(), and strchr().

Referenced by db_dirbuild(), ged_concat(), and ged_dbcopy().

Here is the call graph for this function:

int db5_put_color_table ( struct db_i dbip)

Put the old region-id-color-table into the global object. A null attribute is set if the material table is empty.

Returns - <0 error 0 OK

Definition at line 1009 of file db5_io.c.

References BU_ASSERT_LONG, bu_vls_addr(), bu_vls_free(), BU_VLS_INIT_ZERO, db5_export_color_table(), db5_update_attribute(), db_i::dbi_version, and RT_CK_DBI.

Referenced by mk_write_color_table().

Here is the call graph for this function:

int db5_get_attributes ( const struct db_i dbip,
struct bu_attribute_value_set avs,
const struct directory dp 
)

Get attributes for an object pointed to by *dp

returns: 0 - all is well <0 - error

Definition at line 1027 of file db5_io.c.

References BU_AVS_INIT, BU_EXTERNAL_INIT_ZERO, bu_free_external(), db5_get_raw_internal_ptr(), db5_import_attributes(), db_get_external(), db_i::dbi_version, bu_external::ext_buf, RT_CK_DBI, and RT_CK_DIR.

Referenced by _ged_do_list(), _ged_print_node(), _rt_gettree_region_end(), color_shader_clear(), constraint_eval(), constraint_get(), constraint_set(), constraint_show(), db_lookup_by_attr(), f_attr(), f_stdattr(), ged_attr(), ged_concat(), ged_dbcopy(), ged_lc(), ged_mater(), region_flag_clear(), region_flag_set(), rt_load_attrs(), and write_comb().

Here is the call graph for this function:

int db5_type_tag_from_major ( char **  tag,
const int  major 
)

Definition at line 113 of file db5_types.c.

References db5_type::heed_minor, db5_type::major_code, and db5_type::tag.

int db5_type_descrip_from_major ( char **  descrip,
const int  major 
)

Definition at line 130 of file db5_types.c.

References db5_type::description, db5_type::heed_minor, and db5_type::major_code.

int db5_type_tag_from_codes ( char **  tag,
const int  major,
const int  minor 
)
int db5_type_descrip_from_codes ( char **  descrip,
const int  major,
const int  minor 
)
int db5_type_codes_from_tag ( int *  major,
int *  minor,
const char *  tag 
)

Definition at line 191 of file db5_types.c.

References BU_STR_EQUAL, db5_type::major_code, db5_type::minor_code, and db5_type::tag.

int db5_type_codes_from_descrip ( int *  major,
int *  minor,
const char *  descrip 
)
size_t db5_type_sizeof_h_binu ( const int  minor)

Definition at line 228 of file db5_types.c.

Referenced by ged_bo(), mk_binunif(), and rt_mk_binunif().

size_t db5_type_sizeof_n_binu ( const int  minor)

Definition at line 253 of file db5_types.c.

References SIZEOF_NETWORK_DOUBLE, and SIZEOF_NETWORK_FLOAT.

Variable Documentation

const struct db5_attr_ctype db5_attr_std[]

Definition at line 41 of file db5_attr.c.

Referenced by db5_standard_attribute(), and db5_standardize_attribute().